/** * Set value in current dynamic scope or one of its captured scopes. * * @param offset zero-indexed value that represents where variable lives * @param value to set * @param depth how many captured scopes down this variable should be set */ public IRubyObject setValue(IRubyObject value, int offset, int depth) { return setValue(offset, value, depth); }
/** * Set value in current dynamic scope or one of its captured scopes. * * @param offset zero-indexed value that represents where variable lives * @param value to set * @param depth how many captured scopes down this variable should be set */ public IRubyObject setValue(int offset, IRubyObject value, int depth) { return parent.setValue(offset, value, depth - 1); }
/** * Set value in current dynamic scope or one of its captured scopes. * * @param offset zero-indexed value that represents where variable lives * @param value to set * @param depth how many captured scopes down this variable should be set */ public IRubyObject setValue(int offset, IRubyObject value, int depth) { return parent.setValue(offset, value, depth - 1); }
protected void prepareRestArg(ThreadContext context, Ruby runtime, DynamicScope scope, IRubyObject[] args, int arglen, int givenArgsCount) { if (restArg >= 0) { int sizeOfRestArg = arglen - postCount - givenArgsCount - (postCount == 0 && keywords == null && keyRest != null ? 1 : 0); if (sizeOfRestArg <= 0) { // no more values to stick in rest arg scope.setValue(restArg, RubyArray.newArray(runtime), 0); } else { scope.setValue(restArg, RubyArray.newArrayNoCopy(runtime, args, givenArgsCount, sizeOfRestArg), 0); } } }
protected void prepareRestArg(ThreadContext context, Ruby runtime, DynamicScope scope, IRubyObject[] args, int arglen, int givenArgsCount) { if (restArg >= 0) { int sizeOfRestArg = arglen - postCount - givenArgsCount - (postCount == 0 && keywords == null && keyRest != null ? 1 : 0); if (sizeOfRestArg <= 0) { // no more values to stick in rest arg scope.setValue(restArg, RubyArray.newArray(runtime), 0); } else { scope.setValue(restArg, RubyArray.newArrayNoCopy(runtime, args, givenArgsCount, sizeOfRestArg), 0); } } }
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()); } }
@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; }
@Override public IRubyObject assign(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject value, Block block, boolean checkArity) { context.getCurrentScope().setValue(getIndex(), value, getDepth()); return runtime.getNil(); } }
@Override public IRubyObject assign(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject value, Block block, boolean checkArity) { context.getCurrentScope().setValue(getIndex(), value, getDepth()); return runtime.getNil(); } }
@Override public IRubyObject assign(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject value, Block block, boolean checkArity) { context.getCurrentScope().setValue(getIndex(), value, getDepth()); return runtime.getNil(); } }
@JRubyMethod public IRubyObject local_variable_set(ThreadContext context, IRubyObject symbol, IRubyObject value) { String name = symbol.asJavaString().intern(); DynamicScope evalScope = binding.getEvalScope(context.runtime); int slot = evalScope.getStaticScope().isDefined(name); if (slot == -1) { // Yay! New variable associated with this binding slot = evalScope.getStaticScope().addVariable(name.intern()); evalScope.growIfNeeded(); } return evalScope.setValue(slot & 0xffff, value, slot >> 16); }
@JRubyMethod public IRubyObject local_variable_set(ThreadContext context, IRubyObject symbol, IRubyObject value) { String name = symbol.asJavaString().intern(); DynamicScope evalScope = binding.getEvalScope(context.runtime); int slot = evalScope.getStaticScope().isDefined(name); if (slot == -1) { // Yay! New variable associated with this binding slot = evalScope.getStaticScope().addVariable(name.intern()); evalScope.growIfNeeded(); } return evalScope.setValue(slot & 0xffff, value, slot >> 16); }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { return context.getCurrentScope().setValue(getIndex(), getValueNode().interpret(runtime, context, self, aBlock), getDepth()); }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { return context.getCurrentScope().setValue(getIndex(), getValueNode().interpret(runtime, context, self, aBlock), getDepth()); }
@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 IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { // ignore compiler pragmas if (location == 0xFFFFFFFF) return runtime.getNil(); return context.getCurrentScope().setValue(getIndex(), getValueNode().interpret(runtime,context, self, aBlock), getDepth()); }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { // ignore compiler pragmas if (location == 0xFFFFFFFF) return runtime.getNil(); return context.getCurrentScope().setValue(getIndex(), getValueNode().interpret(runtime,context, self, aBlock), getDepth()); }
@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; }