|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.visit.CFGBuilder
public class CFGBuilder
Class used to construct a CFG.
Nested Class Summary | |
---|---|
protected static class |
CFGBuilder.EdgeKeyTermPair
|
Field Summary | |
---|---|
protected static int |
counter
|
protected DataFlow |
df
The data flow analysis for which we are constructing the graph. |
protected boolean |
errorEdgesToExitNode
True if we should add edges for uncaught Errors to the exit node of the graph. |
protected FlowGraph |
graph
The flowgraph under construction. |
protected Stmt |
innermostTarget
The innermost loop or try-block in lexical scope. |
protected CFGBuilder |
outer
The outer CFGBuilder. |
protected java.util.List |
path_to_finally
List of terms on the path to the innermost finally block. |
protected boolean |
skipInnermostCatches
True if we should skip the catch blocks for the innermost try when building edges for an exception throw. |
protected TypeSystem |
ts
The type system. |
Constructor Summary | |
---|---|
CFGBuilder(TypeSystem ts,
FlowGraph graph,
DataFlow df)
|
Method Summary | |
---|---|
java.lang.Object |
copy()
Copy the CFGBuilder. |
DataFlow |
dataflow()
|
void |
edge(CFGBuilder p_visitor,
Term p,
int pEntry,
Term q,
int qEntry,
FlowGraph.EdgeKey edgeKey)
|
void |
edge(CFGBuilder p_visitor,
Term p,
Term q,
int qEntry,
FlowGraph.EdgeKey edgeKey)
Add an edge to the CFG from the exit of p to either the
entry or exit of q . |
void |
edge(Term p,
Term q,
int qEntry)
Add an edge to the CFG from the exit of p to either the
entry or exit of q . |
void |
edge(Term p,
Term q,
int qEntry,
FlowGraph.EdgeKey edgeKey)
Add an edge to the CFG from the exit of p to either the
entry or exit of q . |
protected CFGBuilder |
enterFinally(Term from)
Enter a finally block. |
FlowGraph |
graph()
|
CFGBuilder |
outer()
|
CFGBuilder |
push(Stmt n)
Construct a new CFGBuilder with the a new innermost loop or try-block n . |
CFGBuilder |
push(Stmt n,
boolean skipInnermostCatches)
Construct a new CFGBuilder with the a new innermost loop or try-block n , optionally skipping innermost catch blocks. |
protected static CFGBuilder |
tryFinally(CFGBuilder v,
Term last,
CFGBuilder last_visitor,
Block finallyBlock)
Create edges for the finally block of a try-finally construct. |
TypeSystem |
typeSystem()
Get the type system. |
void |
visitBranchTarget(Branch b)
Visit edges from a branch. |
void |
visitCFG(Term a,
FlowGraph.EdgeKey edgeKey,
java.util.List succ,
int entry)
Create edges from node a to all successors succ
with the EdgeKey edgeKey for all edges created. |
void |
visitCFG(Term a,
FlowGraph.EdgeKey edgeKey,
java.util.List succ,
java.util.List entry)
Create edges from node a to all successors
succ with the EdgeKey edgeKey for all edges
created. |
void |
visitCFG(Term a,
FlowGraph.EdgeKey edgeKey,
Term succ,
int entry)
Create an edge for a node a with a single successor
succ , and EdgeKey edgeKey . |
void |
visitCFG(Term a,
FlowGraph.EdgeKey edgeKey1,
Term succ1,
int entry1,
FlowGraph.EdgeKey edgeKey2,
Term succ2,
int entry2)
Create edges from node a to successors succ1
and succ2 with EdgeKeys edgeKey1 and
edgeKey2 respecitvely. |
protected void |
visitCFG(Term a,
java.util.List succs)
Create edges for a node a with successors
succs . |
void |
visitCFG(Term a,
Term succ,
int entry)
Create an edge for a node a with a single successor
succ . |
void |
visitCFGList(java.util.List elements,
Term after,
int entry)
Utility function to visit all edges in a list. |
void |
visitGraph()
Visit the AST, constructing the CFG. |
void |
visitReturn(Return r)
Visit edges for a return statement. |
void |
visitThrow(Term a)
|
void |
visitThrow(Term t,
int entry,
Type type)
Create edges for an exception thrown from term t . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected FlowGraph graph
protected TypeSystem ts
protected CFGBuilder outer
protected Stmt innermostTarget
protected java.util.List path_to_finally
protected DataFlow df
protected boolean skipInnermostCatches
protected boolean errorEdgesToExitNode
protected static int counter
Constructor Detail |
---|
public CFGBuilder(TypeSystem ts, FlowGraph graph, DataFlow df)
Method Detail |
---|
public FlowGraph graph()
public DataFlow dataflow()
public CFGBuilder outer()
public TypeSystem typeSystem()
public java.lang.Object copy()
copy
in interface Copy
public CFGBuilder push(Stmt n)
n
.
public CFGBuilder push(Stmt n, boolean skipInnermostCatches)
n
, optionally skipping innermost catch blocks.
public void visitBranchTarget(Branch b)
public void visitReturn(Return r)
public void visitGraph()
public void visitCFGList(java.util.List elements, Term after, int entry)
entry
is Term.ENTRY, the final successor is
after
's entry node; if it's Term.EXIT, it's
after
's exit.
public void visitCFG(Term a, Term succ, int entry)
a
with a single successor
succ
.
The EdgeKey used for the edge from a
to succ
will be FlowGraph.EDGE_KEY_OTHER.
If entry
is Term.ENTRY, the successor is succ
's
entry node; if it's Term.EXIT, it's succ
's exit.
public void visitCFG(Term a, FlowGraph.EdgeKey edgeKey, Term succ, int entry)
a
with a single successor
succ
, and EdgeKey edgeKey
.
If entry
is Term.ENTRY, the successor is succ
's
entry node; if it's Term.EXIT, it's succ
's exit.
public void visitCFG(Term a, FlowGraph.EdgeKey edgeKey1, Term succ1, int entry1, FlowGraph.EdgeKey edgeKey2, Term succ2, int entry2)
a
to successors succ1
and succ2
with EdgeKeys edgeKey1
and
edgeKey2
respecitvely.
entry1
and entry2
determine whether the
successors are entry or exit nodes. They can be Term.ENTRY or Term.EXIT.
public void visitCFG(Term a, FlowGraph.EdgeKey edgeKey, java.util.List succ, int entry)
a
to all successors succ
with the EdgeKey edgeKey
for all edges created.
If entry
is Term.ENTRY, all terms in succ
are
treated as entry nodes; if it's Term.EXIT, they are treated as exit
nodes.
public void visitCFG(Term a, FlowGraph.EdgeKey edgeKey, java.util.List succ, java.util.List entry)
a
to all successors
succ
with the EdgeKey edgeKey
for all edges
created.
The entry
list must have the same size as
succ
, and each corresponding element determines whether a
successor is an entry or exit node (using Term.ENTRY or Term.EXIT).
protected void visitCFG(Term a, java.util.List succs)
a
with successors
succs
.
a
- the source node for the edges.succs
- a list of EdgeKeyTermPair
spublic void visitThrow(Term a)
public void visitThrow(Term t, int entry, Type type)
t
.
protected static CFGBuilder tryFinally(CFGBuilder v, Term last, CFGBuilder last_visitor, Block finallyBlock)
v
- v.innermostTarget is the Try term that the finallyBlock is assoicated with. @@@XXXlast
- the last term visited before the finally block is entered.last_visitor
- @@@XXXfinallyBlock
- the finally block associated with a try finally block.protected CFGBuilder enterFinally(Term from)
from
appended.
public void edge(Term p, Term q, int qEntry)
p
to either the
entry or exit of q
.
public void edge(Term p, Term q, int qEntry, FlowGraph.EdgeKey edgeKey)
p
to either the
entry or exit of q
.
public void edge(CFGBuilder p_visitor, Term p, Term q, int qEntry, FlowGraph.EdgeKey edgeKey)
p
to either the
entry or exit of q
.
public void edge(CFGBuilder p_visitor, Term p, int pEntry, Term q, int qEntry, FlowGraph.EdgeKey edgeKey)
p_visitor
- The visitor used to create p ("this" is the visitor
that created q)p
- The predecessor node in the forward graphpEntry
- whether we are working with the entry or exit of p. Can be
Term.ENTRY or Term.EXIT.q
- The successor node in the forward graphqEntry
- whether we are working with the entry or exit of q. Can be
Term.ENTRY or Term.EXIT.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |