diff options
-rw-r--r-- | V2VM.java | 11 | ||||
-rw-r--r-- | vaporize/library/TotalSpill.java | 55 |
2 files changed, 63 insertions, 3 deletions
@@ -3,6 +3,7 @@ import cs132.util.ProblemException; import cs132.vapor.parser.VaporParser; import cs132.vapor.ast.VaporProgram; import cs132.vapor.ast.VBuiltIn.Op; +import cs132.vapor.ast.VFunction; import java.io.InputStreamReader; import java.io.IOException; @@ -16,10 +17,14 @@ public class V2VM { public static void main(String[] args) { try { - VaporProgram pgrm = parseVapor(System.in, System.out); - System.out.println(pgrm); + VFunction[] funts = parseVapor(System.in, System.out).functions; - ControlFlowGraph vp = new ControlFlowGraph<Void, Void>(); + ControlFlowGraph cfg = new ControlFlowGraph<Void, Void>(); + + TotalSpill<String, Void> ts = new TotalSpill<String, Void>(); + for (VFunction f : funts) { + f.body[0].accept("", ts); + } } catch (IOException e) { System.out.println(e.toString()); diff --git a/vaporize/library/TotalSpill.java b/vaporize/library/TotalSpill.java new file mode 100644 index 0000000..9af45ea --- /dev/null +++ b/vaporize/library/TotalSpill.java @@ -0,0 +1,55 @@ +package vaporize.library; + +import cs132.vapor.ast.*; +import st.*; +import misc.*; +import java.util.*; + +public class TotalSpill<P, R> extends VInstr.VisitorPR<P, R, RuntimeException> { + + + private void printNode(P p, Node n) { + PrintFilter.print(n.getClass().getSimpleName(), true); + } + + public R visit(P p, VMemRead n) throws RuntimeException { + this.printNode(p, n); + return null; + } + + public R visit(P p, VMemWrite n) throws RuntimeException { + this.printNode(p, n); + return null; + } + + public R visit(P p, VAssign n) throws RuntimeException { + this.printNode(p, n); + return null; + } + + public R visit(P p, VBranch n) throws RuntimeException { + this.printNode(p, n); + return null; + } + + public R visit(P p, VGoto n) throws RuntimeException { + this.printNode(p, n); + return null; + } + + public R visit(P p, VCall n) throws RuntimeException { + this.printNode(p, n); + return null; + } + + public R visit(P p, VBuiltIn n) throws RuntimeException { + this.printNode(p, n); + return null; + } + + public R visit(P p, VReturn n) throws RuntimeException { + this.printNode(p, n); + return null; + } + +} |