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); }
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); }
private InterpreterContext buildForIterInner(ForNode forNode) { prepareImplicitState(); // recv_self, add frame block, etc) Node varNode = forNode.getVarNode(); if (varNode != null && varNode.getNodeType() != null) receiveBlockArgs(forNode); addCurrentScopeAndModule(); // %current_scope/%current_module addInstr(new LabelInstr(((IRClosure) scope).startLabel)); // Start label -- used by redo! // Build closure body and return the result of the closure Operand closureRetVal = forNode.getBodyNode() == null ? manager.getNil() : build(forNode.getBodyNode()); if (closureRetVal != U_NIL) { // can be null if the node is an if node with returns in both branches. addInstr(new ReturnInstr(closureRetVal)); } return scope.allocateInterpreterContext(instructions); }
private InterpreterContext buildForIterInner(ForNode forNode) { prepareImplicitState(); // recv_self, add frame block, etc) Node varNode = forNode.getVarNode(); if (varNode != null && varNode.getNodeType() != null) receiveBlockArgs(forNode); addCurrentScopeAndModule(); // %current_scope/%current_module addInstr(new LabelInstr(((IRClosure) scope).startLabel)); // Start label -- used by redo! // Build closure body and return the result of the closure Operand closureRetVal = forNode.getBodyNode() == null ? manager.getNil() : build(forNode.getBodyNode()); if (closureRetVal != U_NIL) { // can be null if the node is an if node with returns in both branches. addInstr(new ReturnInstr(closureRetVal)); } return scope.allocateInterpreterContext(instructions); }
private InterpreterContext buildIterInner(IterNode iterNode) { prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module if (iterNode.getVarNode().getNodeType() != null) receiveBlockArgs(iterNode); addInstr(new LabelInstr(((IRClosure) scope).startLabel)); // start label -- used by redo! // Build closure body and return the result of the closure Operand closureRetVal = iterNode.getBodyNode() == null ? manager.getNil() : build(iterNode.getBodyNode()); if (closureRetVal != U_NIL) { // can be U_NIL if the node is an if node with returns in both branches. addInstr(new ReturnInstr(closureRetVal)); } // Always add break/return handling even though this // is only required for lambdas, but we don't know at this time, // if this is a lambda or not. // // SSS FIXME: At a later time, see if we can optimize this and // do this on demand. handleBreakAndReturnsInLambdas(); return scope.allocateInterpreterContext(instructions); } public Operand buildIter(final IterNode iterNode) {
private InterpreterContext buildIterInner(IterNode iterNode) { prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module if (iterNode.getVarNode().getNodeType() != null) receiveBlockArgs(iterNode); addInstr(new LabelInstr(((IRClosure) scope).startLabel)); // start label -- used by redo! // Build closure body and return the result of the closure Operand closureRetVal = iterNode.getBodyNode() == null ? manager.getNil() : build(iterNode.getBodyNode()); if (closureRetVal != U_NIL) { // can be U_NIL if the node is an if node with returns in both branches. addInstr(new ReturnInstr(closureRetVal)); } // Always add break/return handling even though this // is only required for lambdas, but we don't know at this time, // if this is a lambda or not. // // SSS FIXME: At a later time, see if we can optimize this and // do this on demand. handleBreakAndReturnsInLambdas(); return scope.allocateInterpreterContext(instructions); } public Operand buildIter(final IterNode iterNode) {
public Operand buildLambda(LambdaNode node, IRScope s) { IRClosure closure = new IRClosure(manager, s, false, node.getPosition().getStartLine(), node.getScope(), Arity.procArityOf(node.getArgs()), node.getArgumentType(), true); s.addClosure(closure); // Create a new nested builder to ensure this gets its own IR builder state // like the ensure block stack IRBuilder closureBuilder = newIRBuilder(manager); // Receive self closure.addInstr(new ReceiveSelfInstr(getSelf(closure))); // args closureBuilder.receiveBlockArgs(node, closure); closureBuilder.receiveBlockClosureArg(node.getBlockVarNode(), closure); Operand closureRetVal = node.getBody() == null ? manager.getNil() : closureBuilder.build(node.getBody(), closure); // can be U_NIL if the node is an if node with returns in both branches. if (closureRetVal != U_NIL) closure.addInstr(new ReturnInstr(closureRetVal)); // Added as part of 'prepareForInterpretation' code. // catchUncaughtBreakInLambdas(closure); Variable lambda = s.getNewTemporaryVariable(); s.addInstr(new BuildLambdaInstr(lambda, closure, node.getPosition())); return lambda; }
public Operand buildLambda(LambdaNode node, IRScope s) { IRClosure closure = new IRClosure(manager, s, false, node.getPosition().getStartLine(), node.getScope(), Arity.procArityOf(node.getArgs()), node.getArgumentType(), true); s.addClosure(closure); // Create a new nested builder to ensure this gets its own IR builder state // like the ensure block stack IRBuilder closureBuilder = newIRBuilder(manager); // Receive self closure.addInstr(new ReceiveSelfInstr(getSelf(closure))); // args closureBuilder.receiveBlockArgs(node, closure); closureBuilder.receiveBlockClosureArg(node.getBlockVarNode(), closure); Operand closureRetVal = node.getBody() == null ? manager.getNil() : closureBuilder.build(node.getBody(), closure); // can be U_NIL if the node is an if node with returns in both branches. if (closureRetVal != U_NIL) closure.addInstr(new ReturnInstr(closureRetVal)); // Added as part of 'prepareForInterpretation' code. // catchUncaughtBreakInLambdas(closure); Variable lambda = s.getNewTemporaryVariable(); s.addInstr(new BuildLambdaInstr(lambda, closure, node.getPosition())); return lambda; }
public Operand buildIter(final IterNode iterNode, IRScope s) { IRClosure closure = new IRClosure(manager, s, false, iterNode.getPosition().getStartLine(), iterNode.getScope(), Arity.procArityOf(iterNode.getVarNode()), iterNode.getArgumentType(), !is1_9() && !is2_0()); s.addClosure(closure); // Create a new nested builder to ensure this gets its own IR builder state // like the ensure block stack IRBuilder closureBuilder = newIRBuilder(manager); // Receive self closure.addInstr(new ReceiveSelfInstr(getSelf(closure))); // Build args NodeType argsNodeId = BlockBody.getArgumentTypeWackyHack(iterNode); if ((iterNode.getVarNode() != null) && (argsNodeId != null)) closureBuilder.receiveBlockArgs(iterNode, closure); closureBuilder.receiveBlockClosureArg(iterNode.getBlockVarNode(), closure); // Set %current_scope = <current-scope> // Set %current_module = <current-module> closure.addInstr(new CopyInstr(closure.getCurrentScopeVariable(), new CurrentScope(closure))); closure.addInstr(new CopyInstr(closure.getCurrentModuleVariable(), new ScopeModule(closure))); // Thread poll on entry of closure closure.addInstr(new ThreadPollInstr()); // start label -- used by redo! closure.addInstr(new LabelInstr(closure.startLabel)); // Build closure body and return the result of the closure Operand closureRetVal = iterNode.getBodyNode() == null ? manager.getNil() : closureBuilder.build(iterNode.getBodyNode(), closure); if (closureRetVal != U_NIL) { // can be U_NIL if the node is an if node with returns in both branches. closure.addInstr(new ReturnInstr(closureRetVal)); } return new WrappedIRClosure(closure); }
public Operand buildForIter(final ForNode forNode, IRScope s) { // Create a new closure context IRClosure closure = new IRClosure(manager, s, true, forNode.getPosition().getStartLine(), forNode.getScope(), Arity.procArityOf(forNode.getVarNode()), forNode.getArgumentType(), !is1_9() && !is2_0()); s.addClosure(closure); // Create a new nested builder to ensure this gets its own IR builder state // like the ensure block stack IRBuilder forBuilder = newIRBuilder(manager); // Receive self closure.addInstr(new ReceiveSelfInstr(getSelf(closure))); // Build args Node varNode = forNode.getVarNode(); if (varNode != null && varNode.getNodeType() != null) forBuilder.receiveBlockArgs(forNode, closure); // Set %current_scope = <current-scope> // Set %current_module = <current-module> closure.addInstr(new CopyInstr(closure.getCurrentScopeVariable(), new CurrentScope(closure))); closure.addInstr(new CopyInstr(closure.getCurrentModuleVariable(), new ScopeModule(closure))); // Thread poll on entry of closure closure.addInstr(new ThreadPollInstr()); // Start label -- used by redo! closure.addInstr(new LabelInstr(closure.startLabel)); // Build closure body and return the result of the closure Operand closureRetVal = forNode.getBodyNode() == null ? manager.getNil() : forBuilder.build(forNode.getBodyNode(), closure); if (closureRetVal != U_NIL) { // can be null if the node is an if node with returns in both branches. closure.addInstr(new ReturnInstr(closureRetVal)); } return new WrappedIRClosure(closure); }
public Operand buildForIter(final ForNode forNode, IRScope s) { // Create a new closure context IRClosure closure = new IRClosure(manager, s, true, forNode.getPosition().getStartLine(), forNode.getScope(), Arity.procArityOf(forNode.getVarNode()), forNode.getArgumentType(), !is1_9() && !is2_0()); s.addClosure(closure); // Create a new nested builder to ensure this gets its own IR builder state // like the ensure block stack IRBuilder forBuilder = newIRBuilder(manager); // Receive self closure.addInstr(new ReceiveSelfInstr(getSelf(closure))); // Build args Node varNode = forNode.getVarNode(); if (varNode != null && varNode.getNodeType() != null) forBuilder.receiveBlockArgs(forNode, closure); // Set %current_scope = <current-scope> // Set %current_module = <current-module> closure.addInstr(new CopyInstr(closure.getCurrentScopeVariable(), new CurrentScope(closure))); closure.addInstr(new CopyInstr(closure.getCurrentModuleVariable(), new ScopeModule(closure))); // Thread poll on entry of closure closure.addInstr(new ThreadPollInstr()); // Start label -- used by redo! closure.addInstr(new LabelInstr(closure.startLabel)); // Build closure body and return the result of the closure Operand closureRetVal = forNode.getBodyNode() == null ? manager.getNil() : forBuilder.build(forNode.getBodyNode(), closure); if (closureRetVal != U_NIL) { // can be null if the node is an if node with returns in both branches. closure.addInstr(new ReturnInstr(closureRetVal)); } return new WrappedIRClosure(closure); }
public Operand buildIter(final IterNode iterNode, IRScope s) { IRClosure closure = new IRClosure(manager, s, false, iterNode.getPosition().getStartLine(), iterNode.getScope(), Arity.procArityOf(iterNode.getVarNode()), iterNode.getArgumentType(), !is1_9() && !is2_0()); s.addClosure(closure); // Create a new nested builder to ensure this gets its own IR builder state // like the ensure block stack IRBuilder closureBuilder = newIRBuilder(manager); // Receive self closure.addInstr(new ReceiveSelfInstr(getSelf(closure))); // Build args NodeType argsNodeId = BlockBody.getArgumentTypeWackyHack(iterNode); if ((iterNode.getVarNode() != null) && (argsNodeId != null)) closureBuilder.receiveBlockArgs(iterNode, closure); closureBuilder.receiveBlockClosureArg(iterNode.getBlockVarNode(), closure); // Set %current_scope = <current-scope> // Set %current_module = <current-module> closure.addInstr(new CopyInstr(closure.getCurrentScopeVariable(), new CurrentScope(closure))); closure.addInstr(new CopyInstr(closure.getCurrentModuleVariable(), new ScopeModule(closure))); // Thread poll on entry of closure closure.addInstr(new ThreadPollInstr()); // start label -- used by redo! closure.addInstr(new LabelInstr(closure.startLabel)); // Build closure body and return the result of the closure Operand closureRetVal = iterNode.getBodyNode() == null ? manager.getNil() : closureBuilder.build(iterNode.getBodyNode(), closure); if (closureRetVal != U_NIL) { // can be U_NIL if the node is an if node with returns in both branches. closure.addInstr(new ReturnInstr(closureRetVal)); } return new WrappedIRClosure(closure); }