blob: b32647c871c02451cc32a4de5fbe15adf38d3a45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package vaporize.library;
import misc.*;
import cfg.*;
import java.util.*;
public class LIRDict {
private TreeSet<LIRVar> intervals;
public LIRDict(ControlFlowGraph cfg) {
this.intervals = new TreeSet<LIRVar>();
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<LIRVar> getIntervals() {
return Collections.unmodifiableSortedSet(this.intervals);
}
}
|