public DefineClassInstr(Variable result, IRClassBody newIRClassBody, Operand container, Operand superClass) { super(Operation.DEF_CLASS); assert result != null: "DefineClassInstr result is null"; this.container = container; this.superClass = superClass == null ? newIRClassBody.getManager().getNil() : superClass; this.newIRClassBody = newIRClassBody; this.result = result; }
public Operand run(Object[] args) { // Nothing to do -- ignore the exception, and restore stashed error info! IRScope m = (IRScope)args[0]; m.addInstr(new RestoreErrorInfoInstr((Operand) args[1])); return manager.getNil(); } };
private Operand buildAttrAssign(final AttrAssignNode attrAssignNode, IRScope s) { Operand obj = build(attrAssignNode.getReceiverNode(), s); List<Operand> args = new ArrayList<Operand>(); Node argsNode = attrAssignNode.getArgsNode(); Operand lastArg = (argsNode == null) ? manager.getNil() : buildCallArgs(args, argsNode, s); s.addInstr(new AttrAssignInstr(obj, new MethAddr(attrAssignNode.getName()), args.toArray(new Operand[args.size()]))); return lastArg; }
public Operand buildDefn(MethodDefNode node, IRScope s) { // Instance method IRMethod method = defineNewMethod(node, s, true); s.addInstr(new DefineInstanceMethodInstr(new StringLiteral("--unused--"), method)); return manager.getNil(); }
public Operand buildDefn(MethodDefNode node, IRScope s) { // Instance method IRMethod method = defineNewMethod(node, s, true); s.addInstr(new DefineInstanceMethodInstr(new StringLiteral("--unused--"), method)); return manager.getNil(); }
public Operand buildAlias(final AliasNode alias) { Operand newName = build(alias.getNewName()); Operand oldName = build(alias.getOldName()); addInstr(new AliasInstr(newName, oldName)); return manager.getNil(); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) { // SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well? // // JRUBY-5686: do this before executing so first time sets cref module getLambdaBody().getStaticScope().determineModule(); IRClosure body = getLambdaBody(); // ENEBO: Now can live nil be passed as block reference? return RubyProc.newProc(context.runtime, (Block) (body == null ? context.runtime.getIRManager().getNil() : operands[0]).retrieve(context, self, currDynScope, temp), Block.Type.LAMBDA, position); }
public Operand buildAlias(final AliasNode alias, IRScope s) { Operand newName = build(alias.getNewName(), s); Operand oldName = build(alias.getOldName(), s); s.addInstr(new AliasInstr(getSelf(s), newName, oldName)); return manager.getNil(); }
public Operand buildVAlias(Node node, IRScope s) { VAliasNode valiasNode = (VAliasNode) node; s.addInstr(new GVarAliasInstr(new StringLiteral(valiasNode.getNewName()), new StringLiteral(valiasNode.getOldName()))); return manager.getNil(); }
public Operand buildVAlias(Node node, IRScope s) { VAliasNode valiasNode = (VAliasNode) node; s.addInstr(new GVarAliasInstr(new StringLiteral(valiasNode.getNewName()), new StringLiteral(valiasNode.getOldName()))); return manager.getNil(); }
public Operand buildPreExe(PreExeNode preExeNode) { IRScope topLevel = scope.getRootLexicalScope(); IRClosure beginClosure = new IRFor(manager, scope, preExeNode.getLine(), topLevel.getStaticScope(), Signature.from(preExeNode), IRFor._BEGIN_); // Create a new nested builder to ensure this gets its own IR builder state like the ensure block stack newIRBuilder(manager, beginClosure).buildPrePostExeInner(preExeNode.getBodyNode()); topLevel.recordBeginBlock(beginClosure); // Record the begin block at IR build time return manager.getNil(); }
public Operand buildPreExe(PreExeNode preExeNode) { IRScope topLevel = scope.getRootLexicalScope(); IRClosure beginClosure = new IRFor(manager, scope, preExeNode.getLine(), topLevel.getStaticScope(), Signature.from(preExeNode), IRFor._BEGIN_); // Create a new nested builder to ensure this gets its own IR builder state like the ensure block stack newIRBuilder(manager, beginClosure).buildPrePostExeInner(preExeNode.getBodyNode()); topLevel.recordBeginBlock(beginClosure); // Record the begin block at IR build time return manager.getNil(); }
protected Variable buildDefnCheckIfThenPaths(Label undefLabel, Operand defVal) { Label defLabel = getNewLabel(); Variable tmpVar = getValueInTemporaryVariable(defVal); addInstr(new JumpInstr(defLabel)); addInstr(new LabelInstr(undefLabel)); addInstr(new CopyInstr(tmpVar, manager.getNil())); addInstr(new LabelInstr(defLabel)); return tmpVar; }
protected Variable buildDefnCheckIfThenPaths(Label undefLabel, Operand defVal) { Label defLabel = getNewLabel(); Variable tmpVar = getValueInTemporaryVariable(defVal); addInstr(new JumpInstr(defLabel)); addInstr(new LabelInstr(undefLabel)); addInstr(new CopyInstr(tmpVar, manager.getNil())); addInstr(new LabelInstr(defLabel)); return tmpVar; }
protected Variable buildDefnCheckIfThenPaths(IRScope s, Label undefLabel, Operand defVal) { Label defLabel = s.getNewLabel(); Variable tmpVar = getValueInTemporaryVariable(s, defVal); s.addInstr(new JumpInstr(defLabel)); s.addInstr(new LabelInstr(undefLabel)); s.addInstr(new CopyInstr(tmpVar, manager.getNil())); s.addInstr(new LabelInstr(defLabel)); return tmpVar; }
private InterpreterContext buildLambdaInner(LambdaNode node) { prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module receiveBlockArgs(node); Operand closureRetVal = node.getBody() == null ? manager.getNil() : build(node.getBody()); // can be U_NIL if the node is an if node with returns in both branches. if (closureRetVal != U_NIL) addInstr(new ReturnInstr(closureRetVal)); handleBreakAndReturnsInLambdas(); return scope.allocateInterpreterContext(instructions); }
@Override public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc) { Object value1 = getArg1().retrieve(context, self, currScope, currDynScope, temp); Object value2 = getArg2().retrieve(context, self, currScope, currDynScope, temp); boolean eql = getArg2() == context.getRuntime().getIRManager().getNil() || getArg2() == UndefinedValue.UNDEFINED ? value1 == value2 : ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue(); return !eql ? getJumpTarget().getTargetPC() : ipc; }
@Override public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) { Object value1 = getArg1().retrieve(context, self, currDynScope, temp); Object value2 = getArg2().retrieve(context, self, currDynScope, temp); boolean eql = getArg2() == context.getRuntime().getIRManager().getNil() || getArg2() == UndefinedValue.UNDEFINED ? value1 == value2 : ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue(); return !eql ? getJumpTarget().getTargetPC() : ipc; }
public Operand buildPostExe(PostExeNode postExeNode, IRScope s) { IRClosure endClosure = new IRClosure(manager, s, false, postExeNode.getPosition().getStartLine(), postExeNode.getScope(), Arity.procArityOf(postExeNode.getVarNode()), postExeNode.getArgumentType(), !is1_9() && !is2_0()); // Set up %current_scope and %current_module endClosure.addInstr(new CopyInstr(endClosure.getCurrentScopeVariable(), new CurrentScope(endClosure))); endClosure.addInstr(new CopyInstr(endClosure.getCurrentModuleVariable(), new ScopeModule(endClosure))); build(postExeNode.getBodyNode(), endClosure); // Add an instruction to record the end block at runtime s.addInstr(new RecordEndBlockInstr(s, endClosure)); return manager.getNil(); }
public Operand buildPreExe(PreExeNode preExeNode, IRScope s) { IRClosure beginClosure = new IRClosure(manager, s, false, preExeNode.getPosition().getStartLine(), preExeNode.getScope(), Arity.procArityOf(preExeNode.getVarNode()), preExeNode.getArgumentType(), !is1_9() && !is2_0()); // Set up %current_scope and %current_module beginClosure.addInstr(new CopyInstr(beginClosure.getCurrentScopeVariable(), new CurrentScope(beginClosure))); beginClosure.addInstr(new CopyInstr(beginClosure.getCurrentModuleVariable(), new ScopeModule(beginClosure))); build(preExeNode.getBodyNode(), beginClosure); // Record the begin block at IR build time s.getTopLevelScope().recordBeginBlock(beginClosure); return manager.getNil(); }