@Override public Operand cloneForInlining(CloneInfo ii) { if (ii instanceof InlineCloneInfo) { return ((InlineCloneInfo) ii).getRenamedSelfVariable(this); } else { return super.cloneForInlining(ii); } }
@Override public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) { // SSS FIXME: Is this correct? Are we guaranteed this returns a variable always? target = (Variable)target.getSimplifiedOperand(valueMap, force); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { Block block = (Block) getSource().retrieve(context, self, currScope, currDynScope, temp); return IRRuntimeHelpers.newProc(context.runtime, block); }
public void addDFVar(Variable v) { Integer dfv = addDataFlowVar(); dfVarMap.put(v, dfv); varDfVarMap.put(dfv, v); if (v instanceof LocalVariable && !v.isSelf()) { //System.out.println("Adding df var for " + v + ":" + dfv.id); localVars.add((LocalVariable) v); } }
public boolean isImplicitBlockArg() { return getName().equals(BLOCK); }
public int getLongestVariable(int longest, ResultInstr i) { Variable result = i.getResult(); longest = Math.max(longest, result.getId().length() + ((result instanceof LocalVariable) ? 1 : 0)); return longest; }
if (!x.isImplicitBlockArg()) living.set(lvp.getDFVar(x).getId());
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getName()); e.encode(getScopeDepth()); // We do not encode location because we rebuild lvars from IRScope when being rebuilt }
protected Variable getRenamedVariableSimple(Variable v) { return v.clone(this); }
public Variable getRenamedVariable(Variable v) { Variable newVar = this.varRenameMap.get(v); if (newVar == null) { if (inClosureCloneMode) { // when cloning a closure, local vars and temps are not renamed newVar = v.cloneForCloningClosure(this); } else if (inClosureInlineMode) { // when inlining a closure, // - local var depths are reduced by 1 (to move them to the host scope) // - tmp vars are reallocated in the host scope if (v instanceof LocalVariable) { LocalVariable lv = (LocalVariable)v; int depth = lv.getScopeDepth(); newVar = getInlineHostScope().getLocalVariable(lv.getName(), depth > 1 ? depth - 1 : 0); } else { newVar = getInlineHostScope().getNewTemporaryVariable(); } } else { // when inlining a method, local vars and temps have to be renamed newVar = getInlineHostScope().getNewInlineVariable(inlineVarPrefix, v); } this.varRenameMap.put(v, newVar); } else if (inClosureCloneMode && (v instanceof LocalVariable)) { LocalVariable l_v = (LocalVariable)v; LocalVariable l_newVar = (LocalVariable)newVar; if (l_v.getScopeDepth() != l_newVar.getScopeDepth()) newVar = l_newVar.cloneForDepth(l_v.getScopeDepth()); } return newVar; }
public void addDFVar(Variable v) { Integer dfv = addDataFlowVar(); dfVarMap.put(v, dfv); varDfVarMap.put(dfv, v); if (v instanceof LocalVariable && !v.isSelf()) { //System.out.println("Adding df var for " + v + ":" + dfv.id); localVars.add((LocalVariable) v); } }
public boolean isImplicitBlockArg() { return getName().equals(BLOCK); }
public int local(Variable variable, Type type) { String newName = variable.getId().replace('%', '$'); return local(newName, type); }
if (v.isImplicitBlockArg()) lvp.getScope().markUnusedImplicitBlockArg(); } else { if (!x.isImplicitBlockArg()) living.set(lvp.getDFVar(x).getId());
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getName()); e.encode(getScopeDepth()); // We do not encode location because we rebuild lvars from IRScope when being rebuilt }
protected Variable getRenamedVariableSimple(Variable v) { return v.clone(this); }
public Variable getRenamedVariable(Variable v) { Variable newVar = this.varRenameMap.get(v); if (newVar == null) { if (inClosureCloneMode) { // when cloning a closure, local vars and temps are not renamed newVar = v.cloneForCloningClosure(this); } else if (inClosureInlineMode) { // when inlining a closure, // - local var depths are reduced by 1 (to move them to the host scope) // - tmp vars are reallocated in the host scope if (v instanceof LocalVariable) { LocalVariable lv = (LocalVariable)v; int depth = lv.getScopeDepth(); newVar = getInlineHostScope().getLocalVariable(lv.getName(), depth > 1 ? depth - 1 : 0); } else { newVar = getInlineHostScope().getNewTemporaryVariable(); } } else { // when inlining a method, local vars and temps have to be renamed newVar = getInlineHostScope().getNewInlineVariable(inlineVarPrefix, v); } this.varRenameMap.put(v, newVar); } else if (inClosureCloneMode && (v instanceof LocalVariable)) { LocalVariable l_v = (LocalVariable)v; LocalVariable l_newVar = (LocalVariable)newVar; if (l_v.getScopeDepth() != l_newVar.getScopeDepth()) newVar = l_newVar.cloneForDepth(l_v.getScopeDepth()); } return newVar; }
@Override public Operand cloneForInlining(CloneInfo ii) { if (ii instanceof InlineCloneInfo) { return ((InlineCloneInfo) ii).getRenamedSelfVariable(this); } else { return super.cloneForInlining(ii); } }
@Override public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) { return ((Label)getJumpTarget().retrieve(context, self, currDynScope, temp)).getTargetPC(); }
@Override public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) { // SSS FIXME: Is this correct? Are we guaranteed this returns a variable always? target = (Variable)target.getSimplifiedOperand(valueMap, force); }