From 2f59e052e5272bb2833c91c84b89486bd1b5f592 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Fri, 19 Apr 2024 17:30:41 -0600 Subject: Create 'Kettle' class --- vaporize/library/SpillEverywhere.java | 61 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 20 deletions(-) (limited to 'vaporize/library/SpillEverywhere.java') 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 extends VInstr.VisitorPR { +public class SpillEverywhere extends VInstr.VisitorPR { - ArrayList vapor; + VaporProgram vp; + Kettle kettle; String vaporm; + // public CFGSimp(VaporProgram v) { - public SpillEverywhere(ArrayList 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 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; } -- cgit v1.2.3