Skip to content

Commit

Permalink
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/kernel/eval_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
fails:Kernel#eval uses the filename of the binding if none is provided
fails:Kernel#eval uses the receiver as self inside the eval
fails:Kernel#eval returns from the scope calling #eval when evaluating 'return'
fails:Kernel#eval unwinds through a Proc-style closure and returns from a lambda-style closure in the closure chain
slow:Kernel#eval raises a LocalJumpError if there is no lambda-style closure in the chain
Original file line number Diff line number Diff line change
@@ -559,7 +559,7 @@ public Object evalNoBindingCached(
final DynamicObject callerBinding = getCallerBinding(frame);

final MaterializedFrame parentFrame = Layouts.BINDING.getFrame(callerBinding);
final Object callerSelf = RubyArguments.getSelf(parentFrame.getArguments());
final Object callerSelf = RubyArguments.getSelf(frame.getArguments());

final InternalMethod method = new InternalMethod(
cachedRootNode.getRootNode().getSharedMethodInfo(),
@@ -583,9 +583,12 @@ public Object evalNoBindingCached(
@Specialization(guards = {
"isRubyString(source)"
}, contains = "evalNoBindingCached")
public Object evalNoBindingUncached(VirtualFrame frame, DynamicObject source, NotProvided binding,
public Object evalNoBindingUncached(VirtualFrame frame, DynamicObject source, NotProvided noBinding,
NotProvided filename, NotProvided lineNumber) {
return doEval(source, getCallerBinding(frame), "(eval)", true);
final DynamicObject binding = getCallerBinding(frame);
final MaterializedFrame topFrame = Layouts.BINDING.getFrame(binding);
RubyArguments.setSelf(topFrame.getArguments(), RubyArguments.getSelf(frame.getArguments()));
return doEval(source, binding, "(eval)", true);
}

@Specialization(guards = {
Original file line number Diff line number Diff line change
@@ -291,7 +291,7 @@ public SetReceiverNode(RubyContext context, SourceSection sourceSection, Object

@Override
public Object execute(VirtualFrame frame) {
frame.getArguments()[RubyArguments.SELF_INDEX] = receiver;
RubyArguments.setSelf(frame.getArguments(), receiver);
return methodCallNode.call(frame, frame.getArguments());
}

Original file line number Diff line number Diff line change
@@ -70,6 +70,10 @@ public static Object getSelf(Object[] arguments) {
return arguments[SELF_INDEX];
}

public static void setSelf(Object[] arguments, Object self) {
arguments[SELF_INDEX] = self;
}

public static DynamicObject getBlock(Object[] arguments) {
return (DynamicObject) arguments[BLOCK_INDEX];
}

0 comments on commit 6df63cc

Please sign in to comment.