File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
spec/truffle/tags/core/kernel
truffle/src/main/java/org/jruby/truffle/nodes/core Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 11fails:Kernel.__callee__ returns the current method, even when aliased
22fails:Kernel.__callee__ returns the aliased name when aliased method
33fails:Kernel.__callee__ returns the caller from blocks too
4- fails:Kernel.__callee__ returns the caller from define_method too
5- fails:Kernel.__callee__ returns the caller from block inside define_method too
6- fails:Kernel.__callee__ returns the caller from a define_method called from the same class
74fails:Kernel.__callee__ returns method name even from eval
85fails:Kernel.__callee__ returns nil when not called from a method
96fails:Kernel.__callee__ returns the caller when sent as a string
Original file line number Diff line number Diff line change 1- fails:Kernel.__method__ returns the caller from define_method too
2- fails:Kernel.__method__ returns the caller from block inside define_method too
31fails:Kernel.__method__ returns method name even from eval
42fails:Kernel.__method__ returns nil from inside a class body
53fails:Kernel.__method__ returns nil when not called from a method
Original file line number Diff line number Diff line change @@ -353,6 +353,25 @@ public boolean blockGiven() {
353353 }
354354 }
355355
356+ @ CoreMethod (names = "__callee__" , needsSelf = false )
357+ public abstract static class CalleeNameNode extends CoreMethodNode {
358+
359+ public CalleeNameNode (RubyContext context , SourceSection sourceSection ) {
360+ super (context , sourceSection );
361+ }
362+
363+ public CalleeNameNode (CalleeNameNode prev ) {
364+ super (prev );
365+ }
366+
367+ @ Specialization
368+ public RubySymbol calleeName (VirtualFrame frame ) {
369+ notDesignedForCompilation ();
370+ // the "called name" of a method.
371+ return getContext ().getSymbolTable ().getSymbol (RubyCallStack .getCallingMethod (frame ).getName ());
372+ }
373+ }
374+
356375 @ CoreMethod (names = "caller" , isModuleFunction = true , optional = 1 )
357376 public abstract static class CallerNode extends CoreMethodNode {
358377
@@ -1287,6 +1306,7 @@ public MethodNameNode(MethodNameNode prev) {
12871306 @ Specialization
12881307 public RubySymbol methodName (VirtualFrame frame ) {
12891308 notDesignedForCompilation ();
1309+ // the "original/definition name" of the method.
12901310 return getContext ().getSymbolTable ().getSymbol (RubyCallStack .getCallingMethod (frame ).getSharedMethodInfo ().getName ());
12911311 }
12921312
You can’t perform that action at this time.
0 commit comments