package vaporize.library; import misc.*; import cfg.*; import java.util.*; public class LIRDict { private TreeSet intervals; public LIRDict(ControlFlowGraph cfg) { this.intervals = new TreeSet(); for (CFGNode n : cfg.getNodes()) { int line = n.getInstruction().sourcePos.line; for (String var : n.getReaching()) if (!this.contains(var)) this.intervals.add(new LIRVar(var, line, line)); for (String var : n.getLiveness()) { if (!this.contains(var)) MinimalLogger.severe(String.format("%s was used before defined!", var)); this.getInterval(var).trySetLastUse(line); } } } public LIRVar getInterval(String s) { LIRVar ret = null; for (LIRVar v : this.intervals) { if (v.equals(s)) { ret = v; break; } } return ret; } public boolean contains(String s) { return this.getInterval(s) != null; } public SortedSet getIntervals() { return Collections.unmodifiableSortedSet(this.intervals); } }