From 664e7846c0ca942dc94029010b94dcc41d78f492 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Mon, 15 Apr 2024 01:30:48 -0600 Subject: Correctly call Vapor visitor --- V2VM.java | 11 +++++--- vaporize/library/TotalSpill.java | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 vaporize/library/TotalSpill.java diff --git a/V2VM.java b/V2VM.java index 0f745f0..155c239 100644 --- a/V2VM.java +++ b/V2VM.java @@ -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(); + ControlFlowGraph cfg = new ControlFlowGraph(); + + TotalSpill ts = new TotalSpill(); + 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 extends VInstr.VisitorPR { + + + 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; + } + +} -- cgit v1.2.3