public Variable getCurrentScopeVariable() { // SSS: Used in only 1 case in generated IR: // -> searching a constant in the lexical scope hierarchy if (currentScopeVar == null) currentScopeVar = getNewTemporaryVariable(Variable.CURRENT_SCOPE); return currentScopeVar; }
public Variable getCurrentScopeVariable() { // SSS: Used in only 1 case in generated IR: // -> searching a constant in the lexical scope hierarchy if (currentScopeVar == null) currentScopeVar = getNewTemporaryVariable(Variable.CURRENT_SCOPE); return currentScopeVar; }
public Variable getCurrentModuleVariable() { // SSS: Used in only 3 cases in generated IR: // -> searching a constant in the inheritance hierarchy // -> searching a super-method in the inheritance hierarchy // -> looking up 'StandardError' (which can be eliminated by creating a special operand type for this) if (currentModuleVar == null) currentModuleVar = getNewTemporaryVariable(Variable.CURRENT_MODULE); return currentModuleVar; }
private static void allocVar(Operand oldVar, IRScope s, List<TemporaryVariable> freeVarsList, Map<Operand, Operand> newVarMap) { // If we dont have a var mapping, get a new var -- try the free list first // and if none available, allocate a fresh one if (newVarMap.get(oldVar) == null) { newVarMap.put(oldVar, freeVarsList.isEmpty() ? s.getNewTemporaryVariable() : freeVarsList.remove(0)); } }
private TemporaryVariable getLocalVarReplacement(LocalVariable v, IRScope scope, Map<Operand, Operand> varRenameMap) { TemporaryVariable value = (TemporaryVariable)varRenameMap.get(v); if (value == null) { value = scope.getNewTemporaryVariable("%t_" + v.getName()); varRenameMap.put(v, value); } return value; }
@Override public TemporaryLocalVariable getNewTemporaryVariable(TemporaryVariableType type) { if (type == TemporaryVariableType.CLOSURE) { temporaryVariableIndex++; return new TemporaryClosureVariable(closureId, temporaryVariableIndex); } return super.getNewTemporaryVariable(type); }
private Operand searchConstInInheritanceHierarchy(IRScope s, Operand startingModule, String name) { Variable constVal = s.getNewTemporaryVariable(); genInheritanceSearchInstrs(s, startingModule, constVal, s.getNewLabel(), true, name); return constVal; }
protected Variable copyAndReturnValue(IRScope s, Operand val) { Variable v = s.getNewTemporaryVariable(); s.addInstr(new CopyInstr(v, val)); return v; }
private Operand searchConstInInheritanceHierarchy(IRScope s, Operand startingModule, String name) { Variable constVal = s.getNewTemporaryVariable(); genInheritanceSearchInstrs(s, startingModule, constVal, s.getNewLabel(), true, name); return constVal; }
public Operand buildEncoding(EncodingNode node, IRScope s) { Variable ret = s.getNewTemporaryVariable(); s.addInstr(new GetEncodingInstr(ret, node.getEncoding())); return ret; }
public Variable getNewInlineVariable(String inlinePrefix, Variable v) { if (v instanceof LocalVariable) { LocalVariable lv = (LocalVariable)v; return getLocalVariable(inlinePrefix + lv.getName(), lv.getScopeDepth()); } else { return getNewTemporaryVariable(); } }
private Operand buildSuperInScriptBody(IRScope s) { Variable ret = s.getNewTemporaryVariable(); s.addInstr(new UnresolvedSuperInstr(ret, getSelf(s), NO_ARGS, null)); return ret; }
public Operand buildGlobalVar(GlobalVarNode node, IRScope s) { Variable rv = s.getNewTemporaryVariable(); s.addInstr(new GetGlobalVariableInstr(rv, node.getName())); return rv; }
private Operand buildSuperInScriptBody(IRScope s) { Variable ret = s.getNewTemporaryVariable(); s.addInstr(new UnresolvedSuperInstr(ret, getSelf(s), NO_ARGS, null)); return ret; }
public Operand buildUndef(Node node, IRScope s) { Operand methName = build(((UndefNode) node).getName(), s); Variable result = s.getNewTemporaryVariable(); s.addInstr(new UndefMethodInstr(result, methName)); return result; }
public Operand buildNot(NotNode node, IRScope s) { Variable ret = s.getNewTemporaryVariable(); s.addInstr(new NotInstr(ret, build(node.getConditionNode(), s))); return ret; }
public EnsureBlockInfo(IRScope s, RescueNode n, IRLoop l) { regionStart = s.getNewLabel(); start = s.getNewLabel(); end = s.getNewLabel(); returnAddr = s.getNewTemporaryVariable(); dummyRescueBlockLabel = s.getNewLabel(); savedGlobalException = null; innermostLoop = l; matchingRescueNode = n; }
public Operand buildClassVar(ClassVarNode node, IRScope s) { Variable ret = s.getNewTemporaryVariable(); s.addInstr(new GetClassVariableInstr(ret, classVarDefinitionContainer(s), node.getName())); return ret; }
public Operand buildVCall(VCallNode node, IRScope s) { Variable callResult = s.getNewTemporaryVariable(); Instr callInstr = CallInstr.create(CallType.VARIABLE, callResult, new MethAddr(node.getName()), getSelf(s), NO_ARGS, null); s.addInstr(callInstr); return callResult; }
public Operand run(Object[] args) { IRScope s = (IRScope)args[0]; Node n = (Node)args[1]; String name = (String)args[2]; Operand v = (n instanceof Colon2Node) ? build(((Colon2Node)n).getLeftNode(), s) : new ObjectClass(); Variable tmpVar = s.getNewTemporaryVariable(); s.addInstr(new GetDefinedConstantOrMethodInstr(tmpVar, v, new StringLiteral(name))); return tmpVar; } };