private void allocate() { if(variableValues == null) { int size = staticScope.getNumberOfVariables(); variableValues = new IRubyObject[size]; } }
private void allocate() { if(variableValues == null) { int size = staticScope.getNumberOfVariables(); variableValues = new IRubyObject[size]; } }
private void allocate() { if(variableValues == null) { int size = staticScope.getNumberOfVariables(); variableValues = new IRubyObject[size]; } }
private void allocate() { if(variableValues == null) { int size = staticScope.getNumberOfVariables(); variableValues = new IRubyObject[size]; } }
protected void growIfNeeded(int size, String message) { if (staticScope.getNumberOfVariables() != size) { throw new RuntimeException(message); } }
protected void growIfNeeded(int size, String message) { if (staticScope.getNumberOfVariables() != size) { throw new RuntimeException(message); } }
protected void growIfNeeded(int size, String message) { if (staticScope.getNumberOfVariables() != size) { throw new RuntimeException(message); } }
protected void growIfNeeded(int size, String message) { if (staticScope.getNumberOfVariables() != size) { throw new RuntimeException(message); } }
/** * * Make a larger dynamic scope if the static scope grew. * * Eval's with bindings require us to possibly change the size of the dynamic scope if * things like 'eval "b = 2", binding' happens. * */ public void growIfNeeded() { int dynamicSize = variableValues == null ? 0: variableValues.length; if (staticScope.getNumberOfVariables() > dynamicSize) { IRubyObject values[] = new IRubyObject[staticScope.getNumberOfVariables()]; if (dynamicSize > 0) { ArraySupport.copy(variableValues, 0, values, 0, dynamicSize); } variableValues = values; } }
@Override public int getNumberOfVariables() { return (irScope == null) ? super.getNumberOfVariables() : irScope.getUsedVariablesCount(); }
public IRubyObject[] getValues() { int numberOfVariables = staticScope.getNumberOfVariables(); IRubyObject[] values = new IRubyObject[numberOfVariables]; for (int i = 0; i < numberOfVariables; i++) { values[i] = getValueDepthZero(i); } return values; };
public IRubyObject[] getValues() { int numberOfVariables = staticScope.getNumberOfVariables(); IRubyObject[] values = new IRubyObject[numberOfVariables]; for (int i = 0; i < numberOfVariables; i++) { values[i] = getValueDepthZero(i); } return values; };
private synchronized MethodHandle acquireConstructor() { // check again MethodHandle constructor = this.constructor; if (constructor != null) return constructor; int numberOfVariables = getNumberOfVariables(); if (numberOfVariables > MAX_SPECIALIZED_SIZE) { constructor = ManyVarsDynamicScope.CONSTRUCTOR; } else { constructor = DynamicScopeGenerator.generate(numberOfVariables); } this.constructor = constructor; return constructor; }
@Override public int getNumberOfVariables() { return (irScope == null) ? super.getNumberOfVariables() : irScope.getUsedVariablesCount(); }
private synchronized MethodHandle acquireConstructor() { // check again MethodHandle constructor = this.constructor; if (constructor != null) return constructor; int numberOfVariables = getNumberOfVariables(); if (numberOfVariables > MAX_SPECIALIZED_SIZE) { constructor = ManyVarsDynamicScope.CONSTRUCTOR; } else { constructor = DynamicScopeGenerator.generate(numberOfVariables); } this.constructor = constructor; return constructor; }
public void beginClass(StaticScope scope) { assert scope != null : "compiling a class body with no scope"; // fill in all vars with nil so compiler is happy about future accesses if (scope.getNumberOfVariables() > 0) { // if we don't have opt args, start after args (they will be assigned later) // this is for crap like def foo(a = (b = true; 1)) which numbers b before a // FIXME: only starting after required args, since opt args may access others // and rest args conflicts with compileRoot using "0" to indicate [] signature. int start = scope.getRequiredArgs(); for (int i = start; i < scope.getNumberOfVariables(); i++) { methodCompiler.loadNil(); assignLocalVariable(i, false); } // temp locals must start after last real local tempVariableIndex += scope.getNumberOfVariables(); } }
public static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent) { switch (staticScope.getNumberOfVariables()) { case 0: return new NoVarsDynamicScope(staticScope, parent); case 1: return new OneVarDynamicScope(staticScope, parent); case 2: return new TwoVarDynamicScope(staticScope, parent); case 3: return new ThreeVarDynamicScope(staticScope, parent); case 4: return new FourVarDynamicScope(staticScope, parent); default: return new ManyVarsDynamicScope(staticScope, parent); } }
public static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent) { switch (staticScope.getNumberOfVariables()) { case 0: return new NoVarsDynamicScope(staticScope, parent); case 1: return new OneVarDynamicScope(staticScope, parent); case 2: return new TwoVarDynamicScope(staticScope, parent); case 3: return new ThreeVarDynamicScope(staticScope, parent); case 4: return new FourVarDynamicScope(staticScope, parent); default: return new ManyVarsDynamicScope(staticScope, parent); } }
public void beginChainedMethod() { method.start(); method.aload(StandardASMCompiler.THREADCONTEXT_INDEX); method.invokevirtual(p(ThreadContext.class), "getCurrentScope", sig(DynamicScope.class)); method.astore(getDynamicScopeIndex()); // if more than 4 locals, get the locals array too if (scope.getNumberOfVariables() > 4) { method.aload(getDynamicScopeIndex()); method.invokevirtual(p(DynamicScope.class), "getValues", sig(IRubyObject[].class)); method.astore(getVarsArrayIndex()); } // visit a label to start scoping for local vars in this method method.label(scopeStart); }
public void beginChainedMethod() { method.start(); method.aload(StandardASMCompiler.THREADCONTEXT_INDEX); method.invokevirtual(p(ThreadContext.class), "getCurrentScope", sig(DynamicScope.class)); method.astore(getDynamicScopeIndex()); // if more than 4 locals, get the locals array too if (scope.getNumberOfVariables() > 4) { method.aload(getDynamicScopeIndex()); method.invokevirtual(p(DynamicScope.class), "getValues", sig(IRubyObject[].class)); method.astore(getVarsArrayIndex()); } // visit a label to start scoping for local vars in this method method.label(scopeStart); }