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; }