private Operand processEnsureRescueBlocks(Operand retVal) { // Before we return, // - have to go execute all the ensure blocks if there are any. // this code also takes care of resetting "$!" if (!activeEnsureBlockStack.empty()) { retVal = addResultInstr(new CopyInstr(createTemporaryVariable(), retVal)); emitEnsureBlocks(null); } return retVal; }
public Operand buildEncoding(EncodingNode node) { Variable ret = createTemporaryVariable(); addInstr(new GetEncodingInstr(ret, node.getEncoding())); return ret; }
public Operand buildBackref(Variable result, BackRefNode node) { if (result == null) result = createTemporaryVariable(); return addResultInstr(new BuildBackrefInstr(result, node.getType())); }
public Operand buildMatch(Variable result, MatchNode matchNode) { Operand regexp = build(matchNode.getRegexpNode()); Variable tempLastLine = createTemporaryVariable(); addResultInstr(new GetGlobalVariableInstr(tempLastLine, symbol("$_"))); if (result == null) result = createTemporaryVariable(); return addResultInstr(new MatchInstr(scope, result, regexp, tempLastLine)); }
private Variable argumentResult(RubySymbol name) { boolean isUnderscore = name.getBytes().realSize() == 1 && name.getBytes().charAt(0) == '_'; if (isUnderscore && underscoreVariableSeen) { return createTemporaryVariable(); } else { if (isUnderscore) underscoreVariableSeen = true; return getNewLocalVariable(name, 0); } }
private Variable argumentResult(RubySymbol name) { boolean isUnderscore = name.getBytes().realSize() == 1 && name.getBytes().charAt(0) == '_'; if (isUnderscore && underscoreVariableSeen) { return createTemporaryVariable(); } else { if (isUnderscore) underscoreVariableSeen = true; return getNewLocalVariable(name, 0); } }
public Operand buildDRegexp(Variable result, DRegexpNode node) { Node[] nodePieces = node.children(); Operand[] pieces = new Operand[nodePieces.length]; for (int i = 0; i < pieces.length; i++) { pieces[i] = dynamicPiece(nodePieces[i]); } if (result == null) result = createTemporaryVariable(); addInstr(new BuildDynRegExpInstr(result, pieces, node.getOptions())); return result; }
public Operand buildDRegexp(Variable result, DRegexpNode node) { Node[] nodePieces = node.children(); Operand[] pieces = new Operand[nodePieces.length]; for (int i = 0; i < pieces.length; i++) { pieces[i] = dynamicPiece(nodePieces[i]); } if (result == null) result = createTemporaryVariable(); addInstr(new BuildDynRegExpInstr(result, pieces, node.getOptions())); return result; }
private void outputExceptionCheck(Operand excType, Operand excObj, Label caughtLabel) { Variable eqqResult = addResultInstr(new RescueEQQInstr(createTemporaryVariable(), excType, excObj)); addInstr(createBranch(eqqResult, manager.getTrue(), caughtLabel)); }
public Operand buildArgsPush(final ArgsPushNode node) { Operand lhs = build(node.getFirstNode()); Operand rhs = build(node.getSecondNode()); return addResultInstr(new BuildCompoundArrayInstr(createTemporaryVariable(), lhs, rhs, true)); }
public Operand buildMatch3(Variable result, Match3Node matchNode) { Operand receiver = build(matchNode.getReceiverNode()); Operand value = build(matchNode.getValueNode()); if (result == null) result = createTemporaryVariable(); return addResultInstr(new MatchInstr(scope, result, receiver, value)); }
public Operand buildMatch3(Variable result, Match3Node matchNode) { Operand receiver = build(matchNode.getReceiverNode()); Operand value = build(matchNode.getValueNode()); if (result == null) result = createTemporaryVariable(); return addResultInstr(new MatchInstr(scope, result, receiver, value)); }
public Operand buildArgsCat(final ArgsCatNode argsCatNode) { Operand lhs = build(argsCatNode.getFirstNode()); Operand rhs = build(argsCatNode.getSecondNode()); return addResultInstr(new BuildCompoundArrayInstr(createTemporaryVariable(), lhs, rhs, false)); }
public Operand buildFor(ForNode forNode) { Variable result = createTemporaryVariable(); Operand receiver = build(forNode.getIterNode()); Operand forBlock = buildForIter(forNode); CallInstr callInstr = new CallInstr(scope, CallType.NORMAL, result, manager.runtime.newSymbol(CommonByteLists.EACH), receiver, NO_ARGS, forBlock, scope.maybeUsingRefinements()); receiveBreakException(forBlock, callInstr); return result; }
public Operand buildFor(ForNode forNode) { Variable result = createTemporaryVariable(); Operand receiver = build(forNode.getIterNode()); Operand forBlock = buildForIter(forNode); CallInstr callInstr = new CallInstr(scope, CallType.NORMAL, result, manager.runtime.newSymbol(CommonByteLists.EACH), receiver, NO_ARGS, forBlock, scope.maybeUsingRefinements()); receiveBreakException(forBlock, callInstr); return result; }
public Operand buildMultipleAsgn19(MultipleAsgnNode multipleAsgnNode) { Node valueNode = multipleAsgnNode.getValueNode(); Operand values = build(valueNode); Variable ret = getValueInTemporaryVariable(values); if (valueNode instanceof ArrayNode) { buildMultipleAsgn19Assignment(multipleAsgnNode, null, ret); } else { Variable tmp = createTemporaryVariable(); addInstr(new ToAryInstr(tmp, ret)); buildMultipleAsgn19Assignment(multipleAsgnNode, null, tmp); } return ret; }
public Operand buildModule(ModuleNode moduleNode) { Colon3Node cpath = moduleNode.getCPath(); RubySymbol moduleName = cpath.getName(); Operand container = getContainerFromCPath(cpath); IRModuleBody body = new IRModuleBody(manager, scope, moduleName, moduleNode.getLine(), moduleNode.getScope()); Variable moduleVar = addResultInstr(new DefineModuleInstr(createTemporaryVariable(), body, container)); Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), moduleVar, NullBlock.INSTANCE)); newIRBuilder(manager, body).buildModuleOrClassBody(moduleNode.getBodyNode(), moduleNode.getLine(), moduleNode.getEndLine()); return processBodyResult; }
public Operand buildSClass(SClassNode sclassNode) { Operand receiver = build(sclassNode.getReceiverNode()); // FIXME: metaclass name should be a bytelist IRModuleBody body = new IRMetaClassBody(manager, scope, manager.getMetaClassName(), sclassNode.getLine(), sclassNode.getScope()); Variable sClassVar = addResultInstr(new DefineMetaClassInstr(createTemporaryVariable(), receiver, body)); // sclass bodies inherit the block of their containing method Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), sClassVar, scope.getYieldClosureVariable())); newIRBuilder(manager, body).buildModuleOrClassBody(sclassNode.getBodyNode(), sclassNode.getLine(), sclassNode.getEndLine()); return processBodyResult; }
public Operand buildDStr(Variable result, DStrNode node) { Node[] nodePieces = node.children(); Operand[] pieces = new Operand[nodePieces.length]; for (int i = 0; i < pieces.length; i++) { pieces[i] = dynamicPiece(nodePieces[i]); } if (result == null) result = createTemporaryVariable(); boolean debuggingFrozenStringLiteral = manager.getInstanceConfig().isDebuggingFrozenStringLiteral(); addInstr(new BuildCompoundStringInstr(result, pieces, node.getEncoding(), node.isFrozen(), debuggingFrozenStringLiteral, getFileName(), node.getLine())); return result; }
public Operand buildDSymbol(Variable result, DSymbolNode node) { Node[] nodePieces = node.children(); Operand[] pieces = new Operand[nodePieces.length]; for (int i = 0; i < pieces.length; i++) { pieces[i] = dynamicPiece(nodePieces[i]); } if (result == null) result = createTemporaryVariable(); boolean debuggingFrozenStringLiteral = manager.getInstanceConfig().isDebuggingFrozenStringLiteral(); addInstr(new BuildCompoundStringInstr(result, pieces, node.getEncoding(), false, debuggingFrozenStringLiteral, getFileName(), node.getLine())); return copyAndReturnValue(new DynamicSymbol(result)); }