public static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent, EvalType evalType) { DynamicScope newScope = newDynamicScope(staticScope, parent); newScope.setEvalType(evalType); return newScope; }
public static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent, EvalType evalType) { DynamicScope newScope = newDynamicScope(staticScope, parent); newScope.setEvalType(evalType); return newScope; }
/** * Get a new dynamic scope. Note: This only works for method scopes (ClosureIC will throw). */ public DynamicScope newDynamicScope(ThreadContext context) { // Add a parent-link to current dynscope to support non-local returns cheaply. This doesn't // affect variable scoping since local variables will all have the right scope depth. if (metaClassBodyScope) return DynamicScope.newDynamicScope(getStaticScope(), context.getCurrentScope()); return DynamicScope.newDynamicScope(getStaticScope()); }
/** * Get a new dynamic scope. Note: This only works for method scopes (ClosureIC will throw). */ public DynamicScope newDynamicScope(ThreadContext context) { // Add a parent-link to current dynscope to support non-local returns cheaply. This doesn't // affect variable scoping since local variables will all have the right scope depth. if (metaClassBodyScope) return DynamicScope.newDynamicScope(getStaticScope(), context.getCurrentScope()); return DynamicScope.newDynamicScope(getStaticScope()); }
public void preMethodFrameAndScope(RubyModule clazz, String name, IRubyObject self, Block block, StaticScope staticScope) { pushCallFrame(clazz, name, self, block); pushScope(DynamicScope.newDynamicScope(staticScope)); }
public DynamicScope allocScope(DynamicScope parentScope) { // 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! DynamicScope newScope = DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, body.getEvalType()); if (type == Block.Type.LAMBDA) newScope.setLambda(true); return newScope; }
public DynamicScope allocScope(DynamicScope parentScope) { // 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! DynamicScope newScope = DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, body.getEvalType()); if (type == Block.Type.LAMBDA) newScope.setLambda(true); return newScope; }
public Frame preYieldSpecificBlock(Binding binding, StaticScope scope) { Frame lastFrame = preYieldNoScope(binding); // new scope for this invocation of the block, based on parent scope pushScope(DynamicScope.newDynamicScope(scope, binding.getDynamicScope())); return lastFrame; }
public Frame preYieldSpecificBlock(Binding binding, StaticScope scope) { Frame lastFrame = preYieldNoScope(binding); // new scope for this invocation of the block, based on parent scope pushScope(DynamicScope.newDynamicScope(scope, binding.getDynamicScope())); return lastFrame; }
protected void pre(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block, RubyModule implClass) { // update call stacks (push: frame, class, scope, etc.) context.preMethodFrameOnly(implClass, name, self, block); if (ic.pushNewDynScope()) { context.pushScope(DynamicScope.newDynamicScope(ic.getStaticScope())); } }
protected void pre(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block, RubyModule implClass) { // update call stacks (push: frame, class, scope, etc.) context.preMethodFrameOnly(implClass, name, self, block); if (ic.pushNewDynScope()) { context.pushScope(DynamicScope.newDynamicScope(ic.getStaticScope())); } }
protected void pre(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block, RubyModule implClass) { // update call stacks (push: frame, class, scope, etc.) context.preMethodFrameOnly(implClass, name, self, block); if (ic.pushNewDynScope()) { context.pushScope(DynamicScope.newDynamicScope(ic.getStaticScope())); } }
protected void pre(ThreadContext context, StaticScope staticScope, RubyModule implementationClass, IRubyObject self, String name, Block block) { // update call stacks (push: frame, class, needsDynamicScope, etc.) context.preMethodFrameOnly(implementationClass, name, self, block); if (needsDynamicScope) { // Add a parent-link to current dynscope to support non-local returns cheaply // This doesn't affect variable scoping since local variables will all have // the right needsDynamicScope depth. context.pushScope(DynamicScope.newDynamicScope(staticScope, context.getCurrentScope())); } context.setCurrentVisibility(getVisibility()); }
protected void pre(ThreadContext context, StaticScope staticScope, RubyModule implementationClass, IRubyObject self, String name, Block block) { // update call stacks (push: frame, class, needsDynamicScope, etc.) context.preMethodFrameOnly(implementationClass, name, self, block); if (needsDynamicScope) { // Add a parent-link to current dynscope to support non-local returns cheaply // This doesn't affect variable scoping since local variables will all have // the right needsDynamicScope depth. context.pushScope(DynamicScope.newDynamicScope(staticScope, context.getCurrentScope())); } context.setCurrentVisibility(getVisibility()); }
public static void preLoadCommon(ThreadContext context, StaticScope staticScope, boolean wrap) { RubyModule objectClass = context.runtime.getObject(); if (wrap) { objectClass = RubyModule.newModule(context.runtime); } staticScope.setModule(objectClass); DynamicScope scope = DynamicScope.newDynamicScope(staticScope); // Each root node has a top-level scope that we need to push context.preScopedBody(scope); context.preNodeEval(context.runtime.getTopSelf()); }
public void preClassEval(StaticScope staticScope, RubyModule type) { pushRubyClass(type); pushFrameCopy(); getCurrentFrame().setSelf(type); getCurrentFrame().setVisibility(Visibility.PUBLIC); pushScope(DynamicScope.newDynamicScope(staticScope, null)); }
@Override protected void pre(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block, RubyModule implClass) { // update call stacks (push: frame, class, scope, etc.) context.preMethodFrameOnly(getImplementationClass(), name, self, block); if (ic.pushNewDynScope()) { // Add a parent-link to current dynscope to support non-local returns cheaply // This doesn't affect variable scoping since local variables will all have // the right scope depth. context.pushScope(DynamicScope.newDynamicScope(ic.getStaticScope(), context.getCurrentScope())); } context.setCurrentVisibility(getVisibility()); }
public static IRubyObject runBeginBlock(ThreadContext context, IRubyObject self, String scopeString, CompiledBlockCallback callback) { StaticScope staticScope = decodeScope(context, context.getCurrentStaticScope(), scopeString); context.preScopedBody(DynamicScope.newDynamicScope(staticScope, context.getCurrentScope())); Block block = CompiledBlock.newCompiledClosure(context, self, Arity.createArity(0), staticScope, callback, false, BlockBody.ZERO_ARGS); try { block.yield(context, null); } finally { context.postScopedBody(); } return context.runtime.getNil(); }
public void preExecuteUnder(IRubyObject executeUnderObj, RubyModule executeUnderClass, Block block) { Frame frame = getCurrentFrame(); DynamicScope scope = getCurrentScope(); StaticScope sScope = runtime.getStaticScopeFactory().newBlockScope(scope.getStaticScope()); sScope.setModule(executeUnderClass); pushScope(DynamicScope.newDynamicScope(sScope, scope)); pushCallFrame(frame.getKlazz(), frame.getName(), executeUnderObj, block); getCurrentFrame().setVisibility(getPreviousFrame().getVisibility()); }
public void preExecuteUnder(RubyModule executeUnderClass, Block block) { Frame frame = getCurrentFrame(); pushRubyClass(executeUnderClass); DynamicScope scope = getCurrentScope(); StaticScope sScope = runtime.getStaticScopeFactory().newBlockScope(scope.getStaticScope()); sScope.setModule(executeUnderClass); pushScope(DynamicScope.newDynamicScope(sScope, scope)); pushCallFrame(frame.getKlazz(), frame.getName(), frame.getSelf(), block); getCurrentFrame().setVisibility(getPreviousFrame().getVisibility()); }