summaryrefslogtreecommitdiff
path: root/vaporize/library/SpillEverywhere.java
diff options
context:
space:
mode:
Diffstat (limited to 'vaporize/library/SpillEverywhere.java')
-rw-r--r--vaporize/library/SpillEverywhere.java61
1 files changed, 41 insertions, 20 deletions
diff --git a/vaporize/library/SpillEverywhere.java b/vaporize/library/SpillEverywhere.java
index 5edbbfc..b910270 100644
--- a/vaporize/library/SpillEverywhere.java
+++ b/vaporize/library/SpillEverywhere.java
@@ -5,77 +5,98 @@ import st.*;
import misc.*;
import java.util.*;
-public class SpillEverywhere<P, R> extends VInstr.VisitorPR<P, R, RuntimeException> {
+public class SpillEverywhere extends VInstr.VisitorPR<String, String, RuntimeException> {
- ArrayList<String> vapor;
+ VaporProgram vp;
+ Kettle kettle;
String vaporm;
+ // public CFGSimp(VaporProgram v) {
- public SpillEverywhere(ArrayList<String> vapor) {
- this.vapor = vapor;
+ // // 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<String> 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.indexOriginal(f), true);
+ }
}
- public R visit(P p, VMemRead n) throws RuntimeException {
+ public String visit(String p, VMemRead n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.getClass().getSimpleName(),
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}
- public R visit(P p, VMemWrite n) throws RuntimeException {
+ public String visit(String p, VMemWrite n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.getClass().getSimpleName(),
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}
- public R visit(P p, VAssign n) throws RuntimeException {
+ public String visit(String p, VAssign n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.getClass().getSimpleName(),
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}
- public R visit(P p, VBranch n) throws RuntimeException {
+ public String visit(String p, VBranch n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.getClass().getSimpleName(),
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}
- public R visit(P p, VGoto n) throws RuntimeException {
+ public String visit(String p, VGoto n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.getClass().getSimpleName(),
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}
- public R visit(P p, VCall n) throws RuntimeException {
+ public String visit(String p, VCall n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.getClass().getSimpleName(),
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}
- public R visit(P p, VBuiltIn n) throws RuntimeException {
+ public String visit(String p, VBuiltIn n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.op.name,
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}
- public R visit(P p, VReturn n) throws RuntimeException {
+ public String visit(String p, VReturn n) throws RuntimeException {
PrintFilter.print(String.format("%s (%s:%s)",
n.getClass().getSimpleName(),
- this.vapor.get(n.sourcePos.line-1),
+ this.kettle.indexOriginal(n),
n.sourcePos.toString()), true);
return null;
}