package vaporize.library; import cs132.vapor.ast.*; import st.*; import misc.*; import java.util.*; public class CFGSimp extends VInstr.VisitorPR { private VaporProgram vp; private Kettle kettle; private ArrayList cfgs; public CFGSimp(VaporProgram vp, ArrayList vapor) { this.vp = vp; this.kettle = new Kettle(vapor); this.cfgs = new ArrayList(); for (VFunction f : this.vp.functions) { ControlFlowGraph cfg = new ControlFlowGraph(); CFGNode start = new CFGNode(f.body[0]); cfg.setStart(start); // nodes MinimalLogger.info(String.format("CFGSimp is collecting nodes for %s", this.kettle.parseFuncName(f))); for (VInstr s : f.body) cfg.addNode(new CFGNode(s)); // edges MinimalLogger.info(String.format("CFGSimp is collecting edges for %s", this.kettle.parseFuncName(f))); for (VInstr s : f.body) s.accept("", this); this.cfgs.add(cfg); } } public ArrayList getCFGs() { return this.cfgs; } public String visit(String p, VMemRead n) throws RuntimeException { return null; } public String visit(String p, VMemWrite n) throws RuntimeException { return null; } public String visit(String p, VAssign n) throws RuntimeException { return null; } public String visit(String p, VBranch n) throws RuntimeException { // two edges return null; } public String visit(String p, VGoto n) throws RuntimeException { return null; } public String visit(String p, VCall n) throws RuntimeException { return null; } public String visit(String p, VBuiltIn n) throws RuntimeException { return null; } public String visit(String p, VReturn n) throws RuntimeException { return null; } }