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 buildRootInner(RootNode rootNode) { needsCodeCoverage = rootNode.needsCoverage(); prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module // Build IR for the tree and return the result of the expression tree addInstr(new ReturnInstr(build(rootNode.getBodyNode()))); scope.computeScopeFlagsEarly(instructions); // Root scope can receive returns now, so we add non-local return logic if necessary (2.5+) if (scope.canReceiveNonlocalReturns()) handleNonlocalReturnInMethod(); return scope.allocateInterpreterContext(instructions); }
private InterpreterContext buildRootInner(RootNode rootNode) { needsCodeCoverage = rootNode.needsCoverage(); prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module // Build IR for the tree and return the result of the expression tree addInstr(new ReturnInstr(build(rootNode.getBodyNode()))); scope.computeScopeFlagsEarly(instructions); // Root scope can receive returns now, so we add non-local return logic if necessary (2.5+) if (scope.canReceiveNonlocalReturns()) handleNonlocalReturnInMethod(); 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); }
public InterpreterContext buildEvalRoot(RootNode rootNode) { needsCodeCoverage = false; // Assuming there is no path into build eval root without actually being an eval. addInstr(manager.newLineNumber(scope.getLine())); prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module Operand returnValue = rootNode.getBodyNode() == null ? manager.getNil() : build(rootNode.getBodyNode()); addInstr(new ReturnInstr(returnValue)); return scope.allocateInterpreterContext(instructions); }
public InterpreterContext buildEvalRoot(RootNode rootNode) { needsCodeCoverage = false; // Assuming there is no path into build eval root without actually being an eval. addInstr(manager.newLineNumber(scope.getLine())); prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module Operand returnValue = rootNode.getBodyNode() == null ? manager.getNil() : build(rootNode.getBodyNode()); addInstr(new ReturnInstr(returnValue)); 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 buildModuleOrClassBody(Node bodyNode, int startLine, int endLine) { if (RubyInstanceConfig.FULL_TRACE_ENABLED) { addInstr(new TraceInstr(RubyEvent.CLASS, null, getFileName(), startLine)); } prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module Operand bodyReturnValue = build(bodyNode); if (RubyInstanceConfig.FULL_TRACE_ENABLED) { // This is only added when tracing is enabled because an 'end' will normally have no other instrs which can // raise after this point. When we add trace we need to add one so backtrace generated shows the 'end' line. addInstr(manager.newLineNumber(endLine)); addInstr(new TraceInstr(RubyEvent.END, null, getFileName(), endLine)); } addInstr(new ReturnInstr(bodyReturnValue)); return scope.allocateInterpreterContext(instructions); }
private InterpreterContext buildModuleOrClassBody(Node bodyNode, int startLine, int endLine) { if (RubyInstanceConfig.FULL_TRACE_ENABLED) { addInstr(new TraceInstr(RubyEvent.CLASS, null, getFileName(), startLine)); } prepareImplicitState(); // recv_self, add frame block, etc) addCurrentScopeAndModule(); // %current_scope/%current_module Operand bodyReturnValue = build(bodyNode); if (RubyInstanceConfig.FULL_TRACE_ENABLED) { // This is only added when tracing is enabled because an 'end' will normally have no other instrs which can // raise after this point. When we add trace we need to add one so backtrace generated shows the 'end' line. addInstr(manager.newLineNumber(endLine)); addInstr(new TraceInstr(RubyEvent.END, null, getFileName(), endLine)); } addInstr(new ReturnInstr(bodyReturnValue)); 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) {
prepareImplicitState(); // recv_self, add frame block, etc)
prepareImplicitState(); // recv_self, add frame block, etc)