| 
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectdk.brics.string.java.ControlFlowBuilder
public class ControlFlowBuilder
Utility class assisting in the construction of method bodies.
The control-flow builder acts as a cursor in the control-flow graph. When a new statement is added, it becomes the successor of the statement under the cursor, and the cursor then moves to the new statement. As a result, successive calls toaddStatement(dk.brics.string.intermediate.Statement)
 creates a chain of statement nodes.
 
 The control-flow graph can be split with startBranch(). After calling, one or more calls
 to useBranch() must be made at points where the branches should join. Finally endBranch()
 should be called after the last useBranch(). For example, to create the following control-flow,
 
     A
   / | \
  B  C  D
  |  |  |
  E  |  |
   \ | /
     F
 
 one could add the statements in this fashion:
 A startBranch() B E useBranch() C useBranch() D useBranch() endBranch() F
| Constructor Summary | |
|---|---|
ControlFlowBuilder(Method method)
Creates a builder for inserting statements in the specified method's body.  | 
|
| Method Summary | |
|---|---|
 void | 
addStatement(Statement s)
Adds a statement at the current position in the control flow graph being built.  | 
 void | 
endBranch()
Ends the current branching.  | 
 Pair<Statement,Statement> | 
finish()
Finishes the subgraph created by the builder, and returns the first and last statement in the subgraph.  | 
 void | 
moveToIsolation()
Removes the cursor from the control-flow graph, so statements will be placed in an isolated subgraph of their own.  | 
 void | 
moveToStatement(Statement to)
Moves the cursor to the specified statement, so new statements will be successors of the specified statement.  | 
 void | 
startBranch()
Starts a new branching and opens one branch in it.  | 
 void | 
useBranch()
Ends the current branch and starts a new one.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public ControlFlowBuilder(Method method)
method - an intermediate method to add statements to.| Method Detail | 
|---|
public void addStatement(Statement s)
s - a statement to add.public void endBranch()
useBranch().
 See ControlFlowBuilder for a description of the branching methods.
public Pair<Statement,Statement> finish()
moveToStatement(dk.brics.string.intermediate.Statement),
 addStatement(dk.brics.string.intermediate.Statement), or
 Nop statement preceeding all statements added with addStatement(dk.brics.string.intermediate.Statement).
 addStatement(dk.brics.string.intermediate.Statement), or a Nop
 succeeding it.
public void moveToIsolation()
public void moveToStatement(Statement to)
to - statement to add from.
IllegalStateException - if a branch is currently unclosed.
IllegalArgumentException - if the specified statement belongs to a different method than the builderpublic void startBranch()
ControlFlowBuilder for a description of the branching methods.
public void useBranch()
ControlFlowBuilder for a description of the branching methods.
  | 
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||