package vaporize.library; import cs132.vapor.ast.*; import st.*; import misc.*; import java.util.*; public class SpillEverywhere extends VInstr.VisitorPR { VaporProgram vp; Kettle kettle; String vaporm; // public CFGSimp(VaporProgram v) { // // nodes // for (VInstr s : n.body) // this.cfg.addNode(new CFGNode(s)); // // edges // for (VInstr s : n.body) // s.accept("", this); // System.out.println(this.cfg.getNodes().toString()); // } public SpillEverywhere(VaporProgram vp, ArrayList vapor) { this.vp = vp; this.kettle = new Kettle(vapor); this.vaporm = ""; for (VFunction f : vp.functions) { for (VInstr s : f.body) { // s.accept("", this); } PrintFilter.print(this.kettle.get(f), true); this.kettle.replaceFunctionDeclare(f, 0, 0, 0); } PrintFilter.print(kettle.dump(), true); } public String visit(String p, VMemRead n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.getClass().getSimpleName(), this.kettle.get(n), n.sourcePos.toString()), true); return null; } public String visit(String p, VMemWrite n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.getClass().getSimpleName(), this.kettle.get(n), n.sourcePos.toString()), true); return null; } public String visit(String p, VAssign n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.getClass().getSimpleName(), this.kettle.get(n), n.sourcePos.toString()), true); return null; } public String visit(String p, VBranch n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.getClass().getSimpleName(), this.kettle.get(n), n.sourcePos.toString()), true); return null; } public String visit(String p, VGoto n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.getClass().getSimpleName(), this.kettle.get(n), n.sourcePos.toString()), true); return null; } public String visit(String p, VCall n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.getClass().getSimpleName(), this.kettle.get(n), n.sourcePos.toString()), true); return null; } public String visit(String p, VBuiltIn n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.op.name, this.kettle.get(n), n.sourcePos.toString()), true); return null; } public String visit(String p, VReturn n) throws RuntimeException { PrintFilter.print(String.format("%s (%s:%s)", n.getClass().getSimpleName(), this.kettle.get(n), n.sourcePos.toString()), true); return null; } }