private static void setResult(Object[] temp, DynamicScope currDynScope, Variable resultVar, Object result) { if (resultVar instanceof TemporaryVariable) { temp[((TemporaryVariable)resultVar).offset] = result; } else { LocalVariable lv = (LocalVariable)resultVar; currDynScope.setValue((IRubyObject)result, lv.getLocation(), lv.getScopeDepth()); } }
private static void setResult(Object[] temp, DynamicScope currDynScope, Variable resultVar, Object result) { if (resultVar instanceof TemporaryVariable) { temp[((TemporaryVariable)resultVar).offset] = result; } else { LocalVariable lv = (LocalVariable)resultVar; currDynScope.setValue((IRubyObject)result, lv.getLocation(), lv.getScopeDepth()); } }
protected static void setResult(Object[] temp, DynamicScope currDynScope, Variable resultVar, Object result) { if (resultVar instanceof TemporaryVariable) { // Unboxed Java primitives (float/double/int/long) don't come here because result is an Object // So, it is safe to use offset directly without any correction as long as IRScope uses // three different allocators (each with its own 'offset' counter) // * one for LOCAL, BOOLEAN, CURRENT_SCOPE, CURRENT_MODULE, CLOSURE tmpvars // * one for FIXNUM // * one for FLOAT temp[((TemporaryLocalVariable)resultVar).offset] = result; } else { LocalVariable lv = (LocalVariable)resultVar; currDynScope.setValueVoid((IRubyObject) result, lv.getLocation(), lv.getScopeDepth()); } }
protected static void setResult(Object[] temp, DynamicScope currDynScope, Variable resultVar, Object result) { if (resultVar instanceof TemporaryVariable) { // Unboxed Java primitives (float/double/int/long) don't come here because result is an Object // So, it is safe to use offset directly without any correction as long as IRScope uses // three different allocators (each with its own 'offset' counter) // * one for LOCAL, BOOLEAN, CURRENT_SCOPE, CURRENT_MODULE, CLOSURE tmpvars // * one for FIXNUM // * one for FLOAT temp[((TemporaryLocalVariable)resultVar).offset] = result; } else { LocalVariable lv = (LocalVariable)resultVar; currDynScope.setValueVoid((IRubyObject) result, lv.getLocation(), lv.getScopeDepth()); } }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object varValue = value.retrieve(context, self, currDynScope, temp); currDynScope.setValue((IRubyObject)varValue, lvar.getLocation(), lvar.getScopeDepth()); return null; }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object varValue = value.retrieve(context, self, currDynScope, temp); currDynScope.setValue((IRubyObject)varValue, lvar.getLocation(), lvar.getScopeDepth()); return null; }
protected static Object retrieveOp(Operand r, ThreadContext context, IRubyObject self, DynamicScope currDynScope, StaticScope currScope, Object[] temp) { Object res; if (r instanceof Self) { return self; } else if (r instanceof TemporaryLocalVariable) { res = temp[((TemporaryLocalVariable)r).offset]; return res == null ? context.nil : res; } else if (r instanceof LocalVariable) { LocalVariable lv = (LocalVariable)r; res = currDynScope.getValue(lv.getLocation(), lv.getScopeDepth()); return res == null ? context.nil : res; } else { return r.retrieve(context, self, currScope, currDynScope, temp); } }
private static Object retrieveOp(Operand r, ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { Object res; if (r instanceof Self) { return self; } else if (r instanceof TemporaryVariable) { res = temp[((TemporaryVariable)r).offset]; return res == null ? context.nil : res; } else if (r instanceof LocalVariable) { LocalVariable lv = (LocalVariable)r; res = currDynScope.getValue(lv.getLocation(), lv.getScopeDepth()); return res == null ? context.nil : res; } else { return r.retrieve(context, self, currDynScope, temp); } }
protected static Object retrieveOp(Operand r, ThreadContext context, IRubyObject self, DynamicScope currDynScope, StaticScope currScope, Object[] temp) { Object res; if (r instanceof Self) { return self; } else if (r instanceof TemporaryLocalVariable) { res = temp[((TemporaryLocalVariable)r).offset]; return res == null ? context.nil : res; } else if (r instanceof LocalVariable) { LocalVariable lv = (LocalVariable)r; res = currDynScope.getValue(lv.getLocation(), lv.getScopeDepth()); return res == null ? context.nil : res; } else { return r.retrieve(context, self, currScope, currDynScope, temp); } }
private static Object retrieveOp(Operand r, ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { Object res; if (r instanceof Self) { return self; } else if (r instanceof TemporaryVariable) { res = temp[((TemporaryVariable)r).offset]; return res == null ? context.nil : res; } else if (r instanceof LocalVariable) { LocalVariable lv = (LocalVariable)r; res = currDynScope.getValue(lv.getLocation(), lv.getScopeDepth()); return res == null ? context.nil : res; } else { return r.retrieve(context, self, currDynScope, temp); } }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { Object varValue = getValue().retrieve(context, self, currScope, currDynScope, temp); currDynScope.setValue((IRubyObject)varValue, getLocalVar().getLocation(), getLocalVar().getScopeDepth()); return null; }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { Object varValue = getValue().retrieve(context, self, currScope, currDynScope, temp); currDynScope.setValue((IRubyObject)varValue, getLocalVar().getLocation(), getLocalVar().getScopeDepth()); return null; }
private void genSetValue(LocalVariable localvariable) { int depth = localvariable.getScopeDepth(); int location = localvariable.getLocation(); String baseName = p(DynamicScope.class); if (depth == 0) { if (location < DynamicScopeGenerator.SPECIALIZED_SETS.size()) { jvmAdapter().invokevirtual(baseName, DynamicScopeGenerator.SPECIALIZED_SETS.get(location), sig(void.class, IRubyObject.class)); } else { jvmAdapter().pushInt(location); jvmAdapter().invokevirtual(baseName, "setValueDepthZeroVoid", sig(void.class, IRubyObject.class, int.class)); } } else { jvmAdapter().pushInt(location); jvmAdapter().pushInt(depth); jvmAdapter().invokevirtual(baseName, "setValueVoid", sig(void.class, IRubyObject.class, int.class, int.class)); } }
private void genSetValue(LocalVariable localvariable) { int depth = localvariable.getScopeDepth(); int location = localvariable.getLocation(); String baseName = p(DynamicScope.class); if (depth == 0) { if (location < DynamicScopeGenerator.SPECIALIZED_SETS.size()) { jvmAdapter().invokevirtual(baseName, DynamicScopeGenerator.SPECIALIZED_SETS.get(location), sig(void.class, IRubyObject.class)); } else { jvmAdapter().pushInt(location); jvmAdapter().invokevirtual(baseName, "setValueDepthZeroVoid", sig(void.class, IRubyObject.class, int.class)); } } else { jvmAdapter().pushInt(location); jvmAdapter().pushInt(depth); jvmAdapter().invokevirtual(baseName, "setValueVoid", sig(void.class, IRubyObject.class, int.class, int.class)); } }
int location = localvariable.getLocation();
int location = localvariable.getLocation();
int depth = loadlocalvarinstr.getLocalVar().getScopeDepth(); int location = loadlocalvarinstr.getLocalVar().getLocation() - 1;
int depth = loadlocalvarinstr.getLocalVar().getScopeDepth(); int location = loadlocalvarinstr.getLocalVar().getLocation() - 1;
int depth = storelocalvarinstr.getLocalVar().getScopeDepth(); int location = storelocalvarinstr.getLocalVar().getLocation() - 1; Operand storeValue = storelocalvarinstr.getValue(); switch (depth) {
jvmLoadLocal(DYNAMIC_SCOPE); int depth = storelocalvarinstr.getLocalVar().getScopeDepth(); int location = storelocalvarinstr.getLocalVar().getLocation(); Operand storeValue = storelocalvarinstr.getValue(); switch (depth) {