summaryrefslogtreecommitdiff
path: root/vaporize/library/SpillEverywhere.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-19 19:04:01 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-19 19:04:01 -0600
commit66ffeaf968bd332f1e18cb27aad11b50e4dd0eab (patch)
treec0d52e8e82590c0656f915610b5a7027a6abd057 /vaporize/library/SpillEverywhere.java
parente98ca14483fb531c41d51677cc7075a0b8e6bd55 (diff)
Switched to use of Logger Module
Diffstat (limited to 'vaporize/library/SpillEverywhere.java')
-rw-r--r--vaporize/library/SpillEverywhere.java107
1 files changed, 58 insertions, 49 deletions
diff --git a/vaporize/library/SpillEverywhere.java b/vaporize/library/SpillEverywhere.java
index a1b0968..d9e9f3f 100644
--- a/vaporize/library/SpillEverywhere.java
+++ b/vaporize/library/SpillEverywhere.java
@@ -1,5 +1,8 @@
package vaporize.library;
+import java.util.logging.Logger;
+import java.util.logging.ConsoleHandler;
+
import cs132.vapor.ast.*;
import st.*;
import misc.*;
@@ -7,9 +10,16 @@ import java.util.*;
public class SpillEverywhere extends VInstr.VisitorPR<String, String, RuntimeException> {
- VaporProgram vp;
- Kettle kettle;
- String vaporm;
+ private static Logger log = Logger.getLogger(SpillEverywhere.class.getName());
+ private static ConsoleHandler consoleHandler = new ConsoleHandler();
+ static {
+ consoleHandler.setFormatter(new MinimalSimpleFormatter());
+ log.addHandler(consoleHandler);
+ }
+
+ private VaporProgram vp;
+ private Kettle kettle;
+ private String vaporm;
// public CFGSimp(VaporProgram v) {
@@ -25,82 +35,81 @@ public class SpillEverywhere extends VInstr.VisitorPR<String, String, RuntimeExc
// }
public SpillEverywhere(VaporProgram vp, ArrayList<String> vapor) {
- this.vp = vp;
+ 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);
+ for (VFunction f : vp.functions) {
+ for (VInstr s : f.body) {
+ // s.accept("", this);
+ }
+ this.kettle.replaceFunctionDeclare(f, 0, 0, 0);
+ }
+ this.log.info(kettle.dump());
}
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);
+ log.info(String.format("%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n),
+ n.sourcePos.toString()));
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);
+ log.info(String.format("%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n),
+ n.sourcePos.toString()));
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);
+ log.info(String.format("%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n),
+ n.sourcePos.toString()));
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;
+ log.info(String.format("%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n),
+ n.sourcePos.toString()));
+ 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;
+ log.info(String.format("%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n),
+ n.sourcePos.toString()));
+ 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;
+ log.info(String.format("%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n),
+ n.sourcePos.toString()));
+ 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;
+ log.info(String.format("%s (%s:%s)",
+ n.op.name,
+ this.kettle.get(n),
+ n.sourcePos.toString()));
+ 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;
+ log.info(String.format("%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n),
+ n.sourcePos.toString()));
+ return null;
}
}