// Analyzer does not initialize some frames before newControlFlowExceptionEdge
// is called, so remember the edges for later use.
final ArrayList<Integer> edgeInsns = new ArrayList<Integer>();
final ArrayList<Integer> edgeSuccessors = new ArrayList<Integer>();
Analyzer a = new Analyzer(new IsNullInterpreter()) {
@Override protected Frame newFrame(int nLocals, int nStack) {
return new Node(nLocals, nStack);
}
@Override protected Frame newFrame(Frame src) {
return new Node(src);
}
@Override protected void newControlFlowEdge(int insn, int successor) {
edgeInsns.add(insn);
edgeSuccessors.add(successor);
}
@Override protected boolean newControlFlowExceptionEdge(int insn, int successor) {
newControlFlowEdge(insn, successor);
return true;
}
};
Frame[] frames;
try {
frames = a.analyze(internalName, this);
} catch (AnalyzerException e) {
throw new RuntimeException(e);
}
assert frames.length == instructions.size();
// Use stored edges to build the graph.
for (int i = 0; i < edgeInsns.size(); i++) {
int insn = edgeInsns.get(i);
int successor = edgeSuccessors.get(i);
Node n = (Node)a.getFrames()[insn];
Node m = (Node)a.getFrames()[successor];
n.addSucc(m);
m.addPred(n);
}
edgeInsns.clear();
edgeSuccessors.clear();