@Override public Instr cloneForBlockCloning(InlinerInfo ii) { return new ReceiveClosureInstr(ii.getRenamedVariable(result)); }
@Override public Instr cloneForBlockCloning(InlinerInfo ii) { return new ReceiveClosureInstr(ii.getRenamedVariable(result)); }
private void receiveClosureArg(BlockArgNode blockVarNode, IRScope s) { Variable blockVar = null; if (blockVarNode != null) { String blockArgName = blockVarNode.getName(); blockVar = s.getNewLocalVariable(blockArgName, 0); if (s instanceof IRMethod) ((IRMethod)s).addArgDesc("block", blockArgName); s.addInstr(new ReceiveClosureInstr(blockVar)); } // SSS FIXME: This instruction is only needed if there is an yield instr somewhere! // In addition, store the block argument in an implicit block variable Variable implicitBlockArg = s.getImplicitBlockArg(); if (blockVar == null) s.addInstr(new ReceiveClosureInstr(implicitBlockArg)); else s.addInstr(new CopyInstr(implicitBlockArg, blockVar)); }
private void receiveClosureArg(BlockArgNode blockVarNode, IRScope s) { Variable blockVar = null; if (blockVarNode != null) { String blockArgName = blockVarNode.getName(); blockVar = s.getNewLocalVariable(blockArgName, 0); if (s instanceof IRMethod) ((IRMethod)s).addArgDesc("block", blockArgName); s.addInstr(new ReceiveClosureInstr(blockVar)); } // SSS FIXME: This instruction is only needed if there is an yield instr somewhere! // In addition, store the block argument in an implicit block variable Variable implicitBlockArg = s.getImplicitBlockArg(); if (blockVar == null) s.addInstr(new ReceiveClosureInstr(implicitBlockArg)); else s.addInstr(new CopyInstr(implicitBlockArg, blockVar)); }
private void receiveMethodClosureArg(ArgsNode argsNode, IRScope s) { Variable blockVar = null; if (argsNode.getBlock() != null) { String blockArgName = argsNode.getBlock().getName(); blockVar = s.getLocalVariable(blockArgName, 0); if (s instanceof IRMethod) ((IRMethod)s).addArgDesc("block", blockArgName); s.addInstr(new ReceiveClosureInstr(blockVar)); } // SSS FIXME: This instruction is only needed if there is an yield instr somewhere! // In addition, store the block argument in an implicit block variable Variable implicitBlockArg = s.getImplicitBlockArg(); if (blockVar == null) s.addInstr(new ReceiveClosureInstr(implicitBlockArg)); else s.addInstr(new CopyInstr(implicitBlockArg, blockVar)); }
private void receiveMethodClosureArg(ArgsNode argsNode, IRScope s) { Variable blockVar = null; if (argsNode.getBlock() != null) { String blockArgName = argsNode.getBlock().getName(); blockVar = s.getLocalVariable(blockArgName, 0); if (s instanceof IRMethod) ((IRMethod)s).addArgDesc("block", blockArgName); s.addInstr(new ReceiveClosureInstr(blockVar)); } // SSS FIXME: This instruction is only needed if there is an yield instr somewhere! // In addition, store the block argument in an implicit block variable Variable implicitBlockArg = s.getImplicitBlockArg(); if (blockVar == null) s.addInstr(new ReceiveClosureInstr(implicitBlockArg)); else s.addInstr(new CopyInstr(implicitBlockArg, blockVar)); }
protected void receiveBlockArg(IRScope s, Variable v, Operand argsArray, int argIndex, boolean isClosureArg, boolean isSplat) { if (argsArray != null) { // We are in a nested receive situation -- when we are not at the root of a masgn tree // Ex: We are trying to receive (b,c) in this example: "|a, (b,c), d| = ..." if (isSplat) s.addInstr(new RestArgMultipleAsgnInstr(v, argsArray, argIndex)); else s.addInstr(new ReqdArgMultipleAsgnInstr(v, argsArray, argIndex)); } else { // argsArray can be null when the first node in the args-node-ast is a multiple-assignment // For example, for-nodes s.addInstr(isClosureArg ? new ReceiveClosureInstr(v) : (isSplat ? new ReceiveRestArgInstr(v, argIndex, argIndex) : new ReceivePreReqdArgInstr(v, argIndex))); } }
protected void receiveBlockArg(IRScope s, Variable v, Operand argsArray, int argIndex, boolean isClosureArg, boolean isSplat) { if (argsArray != null) { // We are in a nested receive situation -- when we are not at the root of a masgn tree // Ex: We are trying to receive (b,c) in this example: "|a, (b,c), d| = ..." if (isSplat) s.addInstr(new RestArgMultipleAsgnInstr(v, argsArray, argIndex)); else s.addInstr(new ReqdArgMultipleAsgnInstr(v, argsArray, argIndex)); } else { // argsArray can be null when the first node in the args-node-ast is a multiple-assignment // For example, for-nodes s.addInstr(isClosureArg ? new ReceiveClosureInstr(v) : (isSplat ? new ReceiveRestArgInstr(v, argIndex, argIndex) : new ReceivePreReqdArgInstr(v, argIndex))); } }
public Operand buildSClass(SClassNode sclassNode, IRScope s) { // class Foo // ... // class << self // ... // end // ... // end // // Here, the class << self declaration is in Foo's body. // Foo is the class in whose context this is being defined. Operand receiver = build(sclassNode.getReceiverNode(), s); // Create a dummy meta class and record it as being lexically defined in scope s IRModuleBody mc = new IRMetaClassBody(manager, s, manager.getMetaClassName(), sclassNode.getPosition().getLine(), sclassNode.getScope()); Variable classBody = s.getNewTemporaryVariable(); s.addInstr(new DefineMetaClassInstr(classBody, receiver, mc)); Variable ret = s.getNewTemporaryVariable(); s.addInstr(new ProcessModuleBodyInstr(ret, classBody)); mc.addInstr(new ReceiveSelfInstr(mc.getSelf())); // Set %current_scope = <current-scope> // Set %current_module = <current-module> mc.addInstr(new ReceiveClosureInstr(mc.getImplicitBlockArg())); mc.addInstr(new CopyInstr(mc.getCurrentScopeVariable(), new CurrentScope(mc))); mc.addInstr(new CopyInstr(mc.getCurrentModuleVariable(), new ScopeModule(mc))); // Create a new nested builder to ensure this gets its own IR builder state Operand rv = newIRBuilder(manager).build(sclassNode.getBodyNode(), mc); if (rv != null) mc.addInstr(new ReturnInstr(rv)); return ret; }
public Operand buildSClass(SClassNode sclassNode, IRScope s) { // class Foo // ... // class << self // ... // end // ... // end // // Here, the class << self declaration is in Foo's body. // Foo is the class in whose context this is being defined. Operand receiver = build(sclassNode.getReceiverNode(), s); // Create a dummy meta class and record it as being lexically defined in scope s IRModuleBody mc = new IRMetaClassBody(manager, s, manager.getMetaClassName(), sclassNode.getPosition().getLine(), sclassNode.getScope()); Variable classBody = s.getNewTemporaryVariable(); s.addInstr(new DefineMetaClassInstr(classBody, receiver, mc)); Variable ret = s.getNewTemporaryVariable(); s.addInstr(new ProcessModuleBodyInstr(ret, classBody)); mc.addInstr(new ReceiveSelfInstr(mc.getSelf())); // Set %current_scope = <current-scope> // Set %current_module = <current-module> mc.addInstr(new ReceiveClosureInstr(mc.getImplicitBlockArg())); mc.addInstr(new CopyInstr(mc.getCurrentScopeVariable(), new CurrentScope(mc))); mc.addInstr(new CopyInstr(mc.getCurrentModuleVariable(), new ScopeModule(mc))); // Create a new nested builder to ensure this gets its own IR builder state Operand rv = newIRBuilder(manager).build(sclassNode.getBodyNode(), mc); if (rv != null) mc.addInstr(new ReturnInstr(rv)); return ret; }