@Override protected IRubyObject yieldDirect(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self) { InterpreterContext ic = ensureInstrsReady(); // so we get debugging output return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, block.getBinding().getMethod(), Block.NULL_BLOCK); }
@Override protected IRubyObject callDirect(ThreadContext context, Block block, IRubyObject[] args, Block blockArg) { InterpreterContext ic = ensureInstrsReady(); // so we get debugging output return Interpreter.INTERPRET_BLOCK(context, block, null, ic, args, block.getBinding().getMethod(), blockArg); }
@Override protected IRubyObject callDirect(ThreadContext context, Block block, IRubyObject[] args, Block blockArg) { InterpreterContext ic = ensureInstrsReady(); // so we get debugging output return Interpreter.INTERPRET_BLOCK(context, block, null, ic, args, block.getBinding().getMethod(), blockArg); }
@Override protected IRubyObject yieldDirect(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self) { InterpreterContext ic = ensureInstrsReady(); // so we get debugging output return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, block.getBinding().getMethod(), Block.NULL_BLOCK); }
private IRubyObject evalBlockBody(ThreadContext context, Binding binding, IRubyObject self) { // This while loop is for restarting the block call in case a 'redo' fires. while (true) { try { return ASTInterpreter.INTERPRET_BLOCK(context.runtime, context, file, line, body, binding.getMethod(), self, Block.NULL_BLOCK); } catch (JumpException.RedoJump rj) { context.pollThreadEvents(); // do nothing, allow loop to redo } catch (StackOverflowError soe) { throw context.runtime.newSystemStackError("stack level too deep", soe); } } }
private IRubyObject evalBlockBody(ThreadContext context, Binding binding, IRubyObject self) { // This while loop is for restarting the block call in case a 'redo' fires. while (true) { try { return ASTInterpreter.INTERPRET_BLOCK(context.runtime, context, file, line, bodyNode, binding.getMethod(), self, Block.NULL_BLOCK); } catch (JumpException.RedoJump rj) { context.pollThreadEvents(); // do nothing, allow loop to redo } catch (StackOverflowError soe) { throw context.runtime.newSystemStackError("stack level too deep", soe); } } }
private IRubyObject evalBlockBody(ThreadContext context, Binding binding, IRubyObject self) { // This while loop is for restarting the block call in case a 'redo' fires. while (true) { try { return ASTInterpreter.INTERPRET_BLOCK(context.runtime, context, file, line, bodyNode, binding.getMethod(), self, Block.NULL_BLOCK); } catch (JumpException.RedoJump rj) { context.pollThreadEvents(); // do nothing, allow loop to redo } catch (StackOverflowError soe) { throw context.runtime.newSystemStackError("stack level too deep", soe); } } }
private IRubyObject evalBlockBody(ThreadContext context, Binding binding, IRubyObject self) { // This while loop is for restarting the block call in case a 'redo' fires. while (true) { try { return ASTInterpreter.INTERPRET_BLOCK(context.runtime, context, file, line, body, binding.getMethod(), self, Block.NULL_BLOCK); } catch (JumpException.RedoJump rj) { context.pollThreadEvents(); // do nothing, allow loop to redo } catch (StackOverflowError soe) { throw context.runtime.newSystemStackError("stack level too deep", soe); } } }
public Block cloneBlockAndFrame() { Binding oldBinding = binding; Binding binding = new Binding( oldBinding.getSelf(), oldBinding.getFrame().duplicate(), oldBinding.getVisibility(), oldBinding.getDynamicScope(), oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine()); Block newBlock = new Block(body, binding); newBlock.type = type; newBlock.escapeBlock = this; return newBlock; }
public Block cloneBlockAndFrame() { Binding oldBinding = binding; Binding binding = new Binding( oldBinding.getSelf(), oldBinding.getFrame().duplicate(), oldBinding.getVisibility(), oldBinding.getDynamicScope(), oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine()); Block newBlock = new Block(body, binding); newBlock.type = type; newBlock.escapeBlock = this; return newBlock; }
/** * Evaluate the given string under the specified binding object. If the binding is not a Proc or Binding object * (RubyProc or RubyBinding) throw an appropriate type error. * @param context the thread context for the current thread * @param self the self against which eval was called; used as self in the eval in 1.9 mode * @param src The string containing the text to be evaluated * @param binding The binding object under which to perform the evaluation * @return An IRubyObject result from the evaluation */ public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject self, IRubyObject src, Binding binding) { Ruby runtime = context.runtime; DynamicScope evalScope = binding.getEvalScope(runtime); evalScope.getStaticScope().determineModule(); // FIXME: It would be nice to just set this or remove it from staticScope altogether Frame lastFrame = context.preEvalWithBinding(binding); try { return evalCommon(context, evalScope, self, src, binding.getFile(), binding.getLine(), binding.getMethod(), binding.getFrame().getBlock(), EvalType.BINDING_EVAL); } finally { context.postEvalWithBinding(binding, lastFrame); } }
/** * Evaluate the given string under the specified binding object. If the binding is not a Proc or Binding object * (RubyProc or RubyBinding) throw an appropriate type error. * @param context the thread context for the current thread * @param self the self against which eval was called; used as self in the eval in 1.9 mode * @param src The string containing the text to be evaluated * @param binding The binding object under which to perform the evaluation * @return An IRubyObject result from the evaluation */ public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject self, IRubyObject src, Binding binding) { Ruby runtime = context.runtime; DynamicScope evalScope = binding.getEvalScope(runtime); evalScope.getStaticScope().determineModule(); // FIXME: It would be nice to just set this or remove it from staticScope altogether Frame lastFrame = context.preEvalWithBinding(binding); try { return evalCommon(context, evalScope, self, src, binding.getFile(), binding.getLine(), binding.getMethod(), binding.getFrame().getBlock(), EvalType.BINDING_EVAL); } finally { context.postEvalWithBinding(binding, lastFrame); } }
protected IRubyObject commonYieldPath(ThreadContext context, IRubyObject[] args, IRubyObject self, RubyModule klass, Binding binding, Type type, Block block) { // SSS: Important! Use getStaticScope() to use a copy of the static-scope stored in the block-body. // Do not use 'closure.getStaticScope()' -- that returns the original copy of the static scope. // This matters because blocks created for Thread bodies modify the static-scope field of the block-body // that records additional state about the block body. // // FIXME: Rather than modify static-scope, it seems we ought to set a field in block-body which is then // used to tell dynamic-scope that it is a dynamic scope for a thread body. Anyway, to be revisited later! Visibility oldVis = binding.getFrame().getVisibility(); RubyModule currentModule = getStaticScope().getModule(); Frame prevFrame = context.preYieldNoScope(binding, klass); if (klass == null) self = prepareSelf(binding); try { DynamicScope prevScope = binding.getDynamicScope(); DynamicScope newScope = closure.isForLoopBody() ? prevScope : DynamicScope.newDynamicScope(getStaticScope(), prevScope); context.pushScope(newScope); return Interpreter.INTERPRET_BLOCK(context, self, closure, args, binding.getMethod(), block, type); } finally { binding.getFrame().setVisibility(oldVis); context.postYield(binding, prevFrame); } }
protected IRubyObject commonYieldPath(ThreadContext context, IRubyObject[] args, IRubyObject self, RubyModule klass, Binding binding, Type type, Block block) { // SSS: Important! Use getStaticScope() to use a copy of the static-scope stored in the block-body. // Do not use 'closure.getStaticScope()' -- that returns the original copy of the static scope. // This matters because blocks created for Thread bodies modify the static-scope field of the block-body // that records additional state about the block body. // // FIXME: Rather than modify static-scope, it seems we ought to set a field in block-body which is then // used to tell dynamic-scope that it is a dynamic scope for a thread body. Anyway, to be revisited later! Visibility oldVis = binding.getFrame().getVisibility(); RubyModule currentModule = getStaticScope().getModule(); Frame prevFrame = context.preYieldNoScope(binding, klass); if (klass == null) self = prepareSelf(binding); try { DynamicScope prevScope = binding.getDynamicScope(); DynamicScope newScope = closure.isForLoopBody() ? prevScope : DynamicScope.newDynamicScope(getStaticScope(), prevScope); context.pushScope(newScope); return Interpreter.INTERPRET_BLOCK(context, self, closure, args, binding.getMethod(), block, type); } finally { binding.getFrame().setVisibility(oldVis); context.postYield(binding, prevFrame); } }
@Override protected IRubyObject commonYieldPath(ThreadContext context, Block block, Block.Type type, IRubyObject[] args, IRubyObject self, Block blockArg) { if (callCount >= 0) promoteToFullBuild(context); InterpreterContext ic = ensureInstrsReady(); Binding binding = block.getBinding(); Visibility oldVis = binding.getFrame().getVisibility(); Frame prevFrame = context.preYieldNoScope(binding); // SSS FIXME: Maybe, we should allocate a NoVarsScope/DummyScope for for-loop bodies because the static-scope here // probably points to the parent scope? To be verified and fixed if necessary. There is no harm as it is now. It // is just wasteful allocation since the scope is not used at all. DynamicScope actualScope = binding.getDynamicScope(); if (ic.pushNewDynScope()) { context.pushScope(block.allocScope(actualScope)); } else if (ic.reuseParentDynScope()) { // Reuse! We can avoid the push only if surrounding vars aren't referenced! context.pushScope(actualScope); } self = IRRuntimeHelpers.updateBlockState(block, self); try { return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, binding.getMethod(), blockArg); } finally { postYield(context, ic, binding, oldVis, prevFrame); } }
@Override protected IRubyObject commonYieldPath(ThreadContext context, Block block, Block.Type type, IRubyObject[] args, IRubyObject self, Block blockArg) { if (callCount >= 0) promoteToFullBuild(context); InterpreterContext ic = ensureInstrsReady(); Binding binding = block.getBinding(); Visibility oldVis = binding.getFrame().getVisibility(); Frame prevFrame = context.preYieldNoScope(binding); // SSS FIXME: Maybe, we should allocate a NoVarsScope/DummyScope for for-loop bodies because the static-scope here // probably points to the parent scope? To be verified and fixed if necessary. There is no harm as it is now. It // is just wasteful allocation since the scope is not used at all. DynamicScope actualScope = binding.getDynamicScope(); if (ic.pushNewDynScope()) { context.pushScope(block.allocScope(actualScope)); } else if (ic.reuseParentDynScope()) { // Reuse! We can avoid the push only if surrounding vars aren't referenced! context.pushScope(actualScope); } self = IRRuntimeHelpers.updateBlockState(block, self); try { return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, binding.getMethod(), blockArg); } finally { postYield(context, ic, binding, oldVis, prevFrame); } }
@Override protected IRubyObject commonYieldPath(ThreadContext context, Block block, Block.Type type, IRubyObject[] args, IRubyObject self, Block blockArg) { if (callCount >= 0) promoteToFullBuild(context); InterpreterContext ic = ensureInstrsReady(); // Update interpreter context for next time this block is executed // This ensures that if we had determined canCallDirect() is false // based on the old IC, we continue to execute with it. interpreterContext = fullInterpreterContext; Binding binding = block.getBinding(); Visibility oldVis = binding.getFrame().getVisibility(); Frame prevFrame = context.preYieldNoScope(binding); // SSS FIXME: Maybe, we should allocate a NoVarsScope/DummyScope for for-loop bodies because the static-scope here // probably points to the parent scope? To be verified and fixed if necessary. There is no harm as it is now. It // is just wasteful allocation since the scope is not used at all. DynamicScope actualScope = binding.getDynamicScope(); if (ic.pushNewDynScope()) { context.pushScope(block.allocScope(actualScope)); } else if (ic.reuseParentDynScope()) { // Reuse! We can avoid the push only if surrounding vars aren't referenced! context.pushScope(actualScope); } self = IRRuntimeHelpers.updateBlockState(block, self); try { return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, binding.getMethod(), blockArg); } finally { postYield(context, ic, binding, oldVis, prevFrame); } }
@Override protected IRubyObject commonYieldPath(ThreadContext context, Block block, Block.Type type, IRubyObject[] args, IRubyObject self, Block blockArg) { if (callCount >= 0) promoteToFullBuild(context); InterpreterContext ic = ensureInstrsReady(); // Update interpreter context for next time this block is executed // This ensures that if we had determined canCallDirect() is false // based on the old IC, we continue to execute with it. interpreterContext = fullInterpreterContext; Binding binding = block.getBinding(); Visibility oldVis = binding.getFrame().getVisibility(); Frame prevFrame = context.preYieldNoScope(binding); // SSS FIXME: Maybe, we should allocate a NoVarsScope/DummyScope for for-loop bodies because the static-scope here // probably points to the parent scope? To be verified and fixed if necessary. There is no harm as it is now. It // is just wasteful allocation since the scope is not used at all. DynamicScope actualScope = binding.getDynamicScope(); if (ic.pushNewDynScope()) { context.pushScope(block.allocScope(actualScope)); } else if (ic.reuseParentDynScope()) { // Reuse! We can avoid the push only if surrounding vars aren't referenced! context.pushScope(actualScope); } self = IRRuntimeHelpers.updateBlockState(block, self); try { return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, binding.getMethod(), blockArg); } finally { postYield(context, ic, binding, oldVis, prevFrame); } }
oldBinding.getVisibility(), oldBinding.getDynamicScope(), oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine());
oldBinding.getVisibility(), oldBinding.getDynamicScope(), oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine());