private CallBlock(Signature signature, BlockCallback callback, ThreadContext context) { super(signature); this.callback = callback; this.dummyScope = context.runtime.getStaticScopeFactory().getDummyScope(); }
public static StaticScope decodeScope(ThreadContext context, StaticScope parent, String scopeString) { String[][] decodedScope = decodeScopeDescriptor(scopeString); StaticScope scope = null; switch (StaticScope.Type.valueOf(decodedScope[0][0])) { case BLOCK: scope = context.runtime.getStaticScopeFactory().newBlockScope(parent, decodedScope[1]); break; case EVAL: scope = context.runtime.getStaticScopeFactory().newEvalScope(parent, decodedScope[1]); break; case LOCAL: scope = context.runtime.getStaticScopeFactory().newLocalScope(parent, decodedScope[1]); break; } setAritiesFromDecodedScope(scope, decodedScope[0]); return scope; }
public IRFor(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature) { this(manager, lexicalParent, lineNumber, StaticScopeFactory.newIRBlockScope(staticScope), signature, FOR_LOOP); }
@SuppressWarnings("deprecation") public static StaticScope preLoad(ThreadContext context, String[] varNames) { StaticScope staticScope = context.runtime.getStaticScopeFactory().newLocalScope(null, varNames); preLoadCommon(context, staticScope, false); return staticScope; }
static ManyVarsDynamicScope getManyVarsDynamicScope(ScriptingContainer container, int depth) { ManyVarsDynamicScope scope; StaticScopeFactory scopeFactory = container.getProvider().getRuntime().getStaticScopeFactory(); // root our parsing scope with a dummy scope StaticScope topStaticScope = scopeFactory.newLocalScope(null); topStaticScope.setModule(container.getProvider().getRuntime().getObject()); DynamicScope currentScope = new ManyVarsDynamicScope(topStaticScope, null); String[] names4Injection = container.getVarMap().getLocalVarNames(); StaticScope evalScope = names4Injection == null || names4Injection.length == 0 ? scopeFactory.newEvalScope(currentScope.getStaticScope()) : scopeFactory.newEvalScope(currentScope.getStaticScope(), names4Injection); scope = new ManyVarsDynamicScope(evalScope, currentScope); // JRUBY-5501: ensure we've set up a cref for the scope too scope.getStaticScope().determineModule(); return scope; }
public final DynamicScope getEvalScope(Ruby runtime) { // We create one extra dynamicScope on a binding so that when we 'eval "b=1", binding' the // 'b' will get put into this new dynamic scope. The original scope does not see the new // 'b' and successive evals with this binding will. Note: This only happens for explicit // bindings. Implicit bindings will always dispose of the scope they create. // No eval scope set, so we create one if (evalScopeBinding.evalScope == null) { // bindings scopes must always be ManyVars scopes since evals can grow them evalScopeBinding.evalScope = new ManyVarsDynamicScope(runtime.getStaticScopeFactory().newEvalScope(dynamicScope.getStaticScope()), dynamicScope); } return evalScopeBinding.evalScope; }
public void pushBlockScope() { currentScope = getRuntime().getStaticScopeFactory().newBlockScope(currentScope); }
void reinitialize(boolean reinitCore) { this.doNotReverseLookupEnabled = true; this.staticScopeFactory = new StaticScopeFactory(this); this.in = config.getInput(); this.out = config.getOutput(); this.err = config.getError(); this.objectSpaceEnabled = config.isObjectSpaceEnabled(); this.siphashEnabled = config.isSiphashEnabled(); this.profile = config.getProfile(); this.currentDirectory = config.getCurrentDirectory(); this.kcode = config.getKCode(); if (reinitCore) { RubyGlobal.initARGV(this); RubyGlobal.initSTDIO(this, globalVariables); } }
private static StaticScope decodeStaticScope(IRReaderDecoder decoder, StaticScope parentScope) { StaticScope scope = StaticScopeFactory.newStaticScope(parentScope, decoder.decodeStaticScopeType(), decoder.decodeStringArray(), decoder.decodeInt()); scope.setSignature(decoder.decodeSignature()); return scope; }
@SuppressWarnings("deprecation") public static StaticScope preLoad(ThreadContext context, String[] varNames) { StaticScope staticScope = context.runtime.getStaticScopeFactory().newLocalScope(null, varNames); preLoadCommon(context, staticScope, false); return staticScope; }
static ManyVarsDynamicScope getManyVarsDynamicScope(ScriptingContainer container, int depth) { ManyVarsDynamicScope scope; StaticScopeFactory scopeFactory = container.getProvider().getRuntime().getStaticScopeFactory(); // root our parsing scope with a dummy scope StaticScope topStaticScope = scopeFactory.newLocalScope(null); topStaticScope.setModule(container.getProvider().getRuntime().getObject()); DynamicScope currentScope = new ManyVarsDynamicScope(topStaticScope, null); String[] names4Injection = container.getVarMap().getLocalVarNames(); StaticScope evalScope = names4Injection == null || names4Injection.length == 0 ? scopeFactory.newEvalScope(currentScope.getStaticScope()) : scopeFactory.newEvalScope(currentScope.getStaticScope(), names4Injection); scope = new ManyVarsDynamicScope(evalScope, currentScope); // JRUBY-5501: ensure we've set up a cref for the scope too scope.getStaticScope().determineModule(); return scope; }
public final DynamicScope getEvalScope(Ruby runtime) { // We create one extra dynamicScope on a binding so that when we 'eval "b=1", binding' the // 'b' will get put into this new dynamic scope. The original scope does not see the new // 'b' and successive evals with this binding will. Note: This only happens for explicit // bindings. Implicit bindings will always dispose of the scope they create. // No eval scope set, so we create one if (evalScopeBinding.evalScope == null) { // bindings scopes must always be ManyVars scopes since evals can grow them evalScopeBinding.evalScope = new ManyVarsDynamicScope(runtime.getStaticScopeFactory().newEvalScope(dynamicScope.getStaticScope()), dynamicScope); } return evalScopeBinding.evalScope; }
public void pushBlockScope() { currentScope = configuration.getRuntime().getStaticScopeFactory().newBlockScope(currentScope); }
void reinitialize(boolean reinitCore) { this.doNotReverseLookupEnabled = true; this.staticScopeFactory = new StaticScopeFactory(this); this.in = config.getInput(); this.out = config.getOutput(); this.err = config.getError(); this.objectSpaceEnabled = config.isObjectSpaceEnabled(); this.siphashEnabled = config.isSiphashEnabled(); this.profile = config.getProfile(); this.currentDirectory = config.getCurrentDirectory(); this.kcode = config.getKCode(); if (reinitCore) { RubyGlobal.initARGV(this); RubyGlobal.initSTDIO(this, globalVariables); } }
private static StaticScope decodeStaticScope(IRReaderDecoder decoder, StaticScope parentScope) { StaticScope scope = StaticScopeFactory.newStaticScope(parentScope, decoder.decodeStaticScopeType(), decoder.decodeStringArray(), decoder.decodeInt()); scope.setSignature(decoder.decodeSignature()); return scope; }
public static StaticScope decodeScope(ThreadContext context, StaticScope parent, String scopeString) { String[][] decodedScope = decodeScopeDescriptor(scopeString); StaticScope scope = null; switch (StaticScope.Type.valueOf(decodedScope[0][0])) { case BLOCK: scope = context.runtime.getStaticScopeFactory().newBlockScope(parent, decodedScope[1]); break; case EVAL: scope = context.runtime.getStaticScopeFactory().newEvalScope(parent, decodedScope[1]); break; case LOCAL: scope = context.runtime.getStaticScopeFactory().newLocalScope(parent, decodedScope[1]); break; } setAritiesFromDecodedScope(scope, decodedScope[0]); return scope; }
public static StaticScope preLoad(ThreadContext context, String[] varNames) { StaticScope staticScope = context.runtime.getStaticScopeFactory().newLocalScope(null, varNames); preLoadCommon(context, staticScope, false); return staticScope; }
public CallBlock19(Signature signature, BlockCallback callback, ThreadContext context) { super(signature); this.callback = callback; this.dummy = context.runtime.getStaticScopeFactory().getDummyScope(); }
static ManyVarsDynamicScope getManyVarsDynamicScope(ScriptingContainer container, int depth) { ManyVarsDynamicScope scope; StaticScopeFactory scopeFactory = container.getProvider().getRuntime().getStaticScopeFactory(); // root our parsing scope with a dummy scope StaticScope topStaticScope = scopeFactory.newLocalScope(null); topStaticScope.setModule(container.getProvider().getRuntime().getObject()); DynamicScope currentScope = new ManyVarsDynamicScope(topStaticScope, null); String[] names4Injection = container.getVarMap().getLocalVarNames(); StaticScope evalScope = names4Injection == null || names4Injection.length == 0 ? scopeFactory.newEvalScope(currentScope.getStaticScope()) : scopeFactory.newEvalScope(currentScope.getStaticScope(), names4Injection); scope = new ManyVarsDynamicScope(evalScope, currentScope); // JRUBY-5501: ensure we've set up a cref for the scope too scope.getStaticScope().determineModule(); return scope; }
/** * Evaluates a script under the current scope (perhaps the top-level * scope) and returns the result (generally the last value calculated). * This version goes straight into the interpreter, bypassing compilation * and runtime preparation typical to normal script runs. * * @param script The scriptlet to run * @returns The result of the eval */ public IRubyObject evalScriptlet(String script) { ThreadContext context = getCurrentContext(); DynamicScope currentScope = context.getCurrentScope(); ManyVarsDynamicScope newScope = new ManyVarsDynamicScope(getStaticScopeFactory().newEvalScope(currentScope.getStaticScope()), currentScope); return evalScriptlet(script, newScope); }