Skip to content

Commit

Permalink
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
Original file line number Diff line number Diff line change
@@ -106,17 +106,15 @@ public IRubyObject interpret(ThreadContext context, Block block, IRubyObject sel
return interpret(context, block, self, interpreterContext, implClass, name, new IRubyObject[] {arg1, arg2, arg3, arg4}, blockArg);
}

private DynamicScope getBlockScope(ThreadContext context, Block block, InterpreterContext interpreterContext) {
private DynamicScope getNewBlockScope(ThreadContext context, Block block, InterpreterContext interpreterContext) {
DynamicScope newScope = block.getBinding().getDynamicScope();
if (interpreterContext.pushNewDynScope()) {
newScope = block.allocScope(newScope);
context.pushScope(newScope);
} else if (interpreterContext.reuseParentDynScope()) {
// Reuse! We can avoid the push only if surrounding vars aren't referenced!
context.pushScope(newScope);
}
if (interpreterContext.pushNewDynScope()) return block.allocScope(newScope);

// Reuse! We can avoid the push only if surrounding vars aren't referenced!
if (interpreterContext.reuseParentDynScope()) return newScope;

return newScope;
// No change
return null;
}

public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
@@ -181,16 +179,19 @@ public IRubyObject interpret(ThreadContext context, Block block, IRubyObject sel
}
break;
case BOOK_KEEPING_OP:
// IMPORTANT: Preserve these update to currDynScope, self, and args.
// They affect execution of all following instructions in this scope.
switch (operation) {
case PUSH_METHOD_BINDING:
// IMPORTANT: Preserve this update of currDynScope.
// This affects execution of all instructions in this scope
// which will now use the updated value of currDynScope.
currDynScope = interpreterContext.newDynamicScope(context);
context.pushScope(currDynScope);
break;
case PUSH_BLOCK_BINDING:
currDynScope = getBlockScope(context, block, interpreterContext);
DynamicScope newScope = getNewBlockScope(context, block, interpreterContext);
if (newScope != null) {
currDynScope = newScope;
context.pushScope(currDynScope);
}
break;
case UPDATE_BLOCK_STATE:
if (self == null || block.getEvalType() == EvalType.BINDING_EVAL) {

0 comments on commit ad919a7

Please sign in to comment.