File tree Expand file tree Collapse file tree 5 files changed +52
-28
lines changed
java/org/truffleruby/core Expand file tree Collapse file tree 5 files changed +52
-28
lines changed Original file line number Diff line number Diff line change @@ -1131,6 +1131,7 @@ public boolean isTruffleBootMainMethod(SharedMethodInfo info) {
1131
1131
"/core/class.rb" ,
1132
1132
"/core/binding.rb" ,
1133
1133
"/core/math.rb" ,
1134
+ "/core/truffle/method_operations.rb" ,
1134
1135
"/core/method.rb" ,
1135
1136
"/core/unbound_method.rb" ,
1136
1137
"/core/warning.rb" ,
Original file line number Diff line number Diff line change @@ -320,22 +320,33 @@ protected int getCacheLimit() {
320
320
public abstract static class MethodUnimplementNode extends PrimitiveArrayArgumentsNode {
321
321
322
322
@ Specialization
323
- protected Object methodUnimplement (RubyMethod rubyMethod ) {
324
- final InternalMethod method = rubyMethod .method ;
325
- method .getDeclaringModule ().fields .addMethod (
326
- getContext (),
327
- this ,
328
- method .unimplemented ());
323
+ protected Object bound (RubyMethod rubyMethod ) {
324
+ unimplement (rubyMethod .method );
325
+ return nil ;
326
+ }
327
+
328
+ @ Specialization
329
+ protected Object unbound (RubyUnboundMethod rubyMethod ) {
330
+ unimplement (rubyMethod .method );
329
331
return nil ;
330
332
}
331
333
334
+ @ TruffleBoundary
335
+ private void unimplement (InternalMethod method ) {
336
+ method .getDeclaringModule ().fields .addMethod (getContext (), this , method .unimplemented ());
337
+ }
332
338
}
333
339
334
340
@ Primitive (name = "method_unimplemented?" )
335
- public abstract static class MethodUnimplementedQueryNode extends PrimitiveArrayArgumentsNode {
341
+ public abstract static class MethodIsUnimplementedNode extends PrimitiveArrayArgumentsNode {
342
+
343
+ @ Specialization
344
+ protected boolean bound (RubyMethod rubyMethod ) {
345
+ return rubyMethod .method .isUnimplemented ();
346
+ }
336
347
337
348
@ Specialization
338
- protected boolean isMethodUnimplemented ( RubyMethod rubyMethod ) {
349
+ protected boolean unbound ( RubyUnboundMethod rubyMethod ) {
339
350
return rubyMethod .method .isUnimplemented ();
340
351
}
341
352
Original file line number Diff line number Diff line change 9
9
# GNU Lesser General Public License version 2.1.
10
10
11
11
class Method
12
-
13
12
def inspect
14
- extra = ''
15
-
16
- if Primitive . method_unimplemented? self
17
- extra = ' (not-implemented)'
18
- else
19
- file , line = source_location
20
-
21
- if file && line
22
- extra = " #{ file } :#{ line } "
23
- end
24
- end
25
-
26
- "#<#{ self . class } : #{ receiver . class } (#{ owner } )##{ name } #{ extra } >"
13
+ Truffle ::MethodOperations . inspect_method ( self , receiver . class , owner )
27
14
end
15
+ alias_method :to_s , :inspect
28
16
29
17
def curry ( curried_arity = nil )
30
18
self . to_proc . curry ( curried_arity )
@@ -37,7 +25,4 @@ def >>(other)
37
25
def <<( other )
38
26
self . to_proc << other
39
27
end
40
-
41
- alias_method :to_s , :inspect
42
-
43
28
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. This
4
+ # code is released under a tri EPL/GPL/LGPL license. You can use it,
5
+ # redistribute it and/or modify it under the terms of the:
6
+ #
7
+ # Eclipse Public License version 2.0, or
8
+ # GNU General Public License version 2, or
9
+ # GNU Lesser General Public License version 2.1.
10
+
11
+ module Truffle
12
+ module MethodOperations
13
+ def self . inspect_method ( meth , origin , owner )
14
+ extra = ''
15
+ if Primitive . method_unimplemented? meth
16
+ extra = ' (not-implemented)'
17
+ else
18
+ file , line = meth . source_location
19
+
20
+ if file && line
21
+ extra = " #{ file } :#{ line } "
22
+ end
23
+ end
24
+
25
+ origin_owner = origin == owner ? origin : "#{ origin } (#{ owner } )"
26
+ "#<#{ meth . class } : #{ origin_owner } ##{ meth . name } #{ extra } >"
27
+ end
28
+ end
29
+ end
Original file line number Diff line number Diff line change 9
9
# GNU Lesser General Public License version 2.1.
10
10
11
11
class UnboundMethod
12
-
13
12
def inspect
14
- "#< #{ self . class } : #{ origin } ( #{ owner } )# #{ name } >"
13
+ Truffle :: MethodOperations . inspect_method ( self , origin , owner )
15
14
end
16
-
17
15
alias_method :to_s , :inspect
18
16
19
17
def bind_call ( recv , *args , &block )
You can’t perform that action at this time.
0 commit comments