MCPcopy Create free account
hub / github.com/dynjs/dynjs / renameLocalVariables

Method renameLocalVariables

src/main/java/org/dynjs/ir/Scope.java:213–244  ·  view source on GitHub ↗
(List<BasicBlock> linearizedCFG)

Source from the content-addressed store, hash-verified

211 }
212
213 private void renameLocalVariables(List<BasicBlock> linearizedCFG) {
214 Map<Operand, Operand> renameMap = new HashMap<Operand, Operand>();
215
216 //System.out.println("BEFORE:");
217 for (BasicBlock b: linearizedCFG) {
218 for (Instruction i: b.getInstructions()) {
219 //System.out.println("I: " + i);
220 if (i instanceof ResultInstruction) {
221 Variable v = ((ResultInstruction) i).getResult();
222
223 if (v instanceof LocalVariable) {
224 setupLocalVarReplacement((LocalVariable) v, renameMap);
225 }
226 }
227
228 for (Variable v : i.getUsedVariables()) {
229 if (v instanceof LocalVariable) {
230 setupLocalVarReplacement((LocalVariable) v, renameMap);
231 }
232 }
233 }
234 }
235
236 //System.out.println("AFTER:");
237 // Rename all local var uses with their tmp-var stand-ins
238 for (BasicBlock b: linearizedCFG) {
239 for (Instruction i: b.getInstructions()) {
240 i.renameVariables(renameMap);
241 //System.out.println("I: " + i);
242 }
243 }
244 }
245
246 private static Label[] catLabels(Label[] labels, Label cat) {
247 if (labels == null) return new Label[] {cat};

Callers 2

prepareForInterpretMethod · 0.95
prepareForCompilationMethod · 0.95

Calls 5

getUsedVariablesMethod · 0.80
renameVariablesMethod · 0.80
getResultMethod · 0.65
getInstructionsMethod · 0.45

Tested by

no test coverage detected