|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectscale.common.Root
scale.score.Note
scale.score.chords.Chord
scale.score.chords.DecisionChord
scale.score.chords.IfThenElseChord
public class IfThenElseChord
This class represents a if-then-else statement node in a Scribble CFG.
$Id: IfThenElseChord.java,v 1.41 2007-10-04 19:58:22 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
| Field Summary |
|---|
| Fields inherited from class scale.score.chords.Chord |
|---|
lineNumber |
| Constructor Summary | |
|---|---|
IfThenElseChord(Expr predicate)
|
|
IfThenElseChord(Expr predicate,
Chord trueEdge,
Chord falseEdge)
|
|
| Method Summary | |
|---|---|
void |
changeOutCfgEdge(Chord oldEdge,
Chord newEdge)
Change the out-going CFG edge indicated by the position to the new edge. |
void |
clearEdge(int edge)
Clear the marker associated with the specified out-going CFG edge. |
void |
clearEdgeMarkers()
Clear all the markers. |
Chord |
copy()
Make a copy of this CFG node with the same out-going CFG edges. |
void |
deleteOutCfgEdges()
Set both out-going CFG edges to null. |
boolean |
edgeMarked(int edge)
Return the marker associated with the specified out-going CFG edge. |
int |
executionCostEstimate()
Return a relative cost estimate for executing the expression. |
int |
getBranchEdgeIndex(java.lang.Object key)
Return the index of the selected out-going CFG edge. |
double |
getBranchProbability(Chord edge)
Return the probability that the specified edge will be executed next. |
Chord |
getFalseCfgEdge()
Return the edge that is followed if the predicate evaluates to false. |
Chord |
getOutCfgEdge(int i)
Return the specified out-going CFG edge. |
Chord[] |
getOutCfgEdgeArray()
Use this method when you may be modifying an out-going CFG edge from this Chord while iterating over the out-going edges. |
Chord |
getTrueCfgEdge()
Return the edge that is followed if the predicate evaluates to true. |
int |
indexOfOutCfgEdge(Chord to,
int skip)
This routine is needed because it is possible for more than one out-going edge from a CFG node to go the the same CFG node. |
void |
linkSubgraph(HashMap<Chord,Chord> nm)
Link a new CFG node that contains old links. |
void |
markEdge(int edge)
Set the marker associated with the specified out-going CFG edge. |
int |
numOutCfgEdges()
Return the number of out-going CFG edges. |
void |
pushAllOutCfgEdges(Stack<Chord> wl)
Add the successors of this Chord to the stack. |
void |
pushOutCfgEdges(Stack<Chord> wl)
Add the successors of this Chord to the stack if they haven't been visited before. |
void |
pushOutCfgEdges(Stack<Chord> wl,
HashSet<Chord> done)
Add the successors of this Chord to the stack if they haven't been visited before. |
void |
pushSortedOutCfgEdges(Stack<Chord> wl)
Add the successors of this Chord to the stack if they haven't been visited, and all their parents have. |
void |
pushSortedOutCfgEdges(Stack<Chord> wl,
HashSet<Chord> finished)
Add the successors of this Chord to the stack if they haven't been visited, and all their parents have. |
void |
replaceOutCfgEdge(Chord oldChord,
Chord newChord)
Replace the existing out-going CFG edge with a new edge. |
void |
setFalseEdge(Chord falseEdge)
Specify the false out-going CFG edge. |
void |
setTrueEdge(Chord trueEdge)
Specify the true out-going CFG edge. |
void |
specifyBranchProbability(Chord edge,
double probability)
Specify the probability that the specified edge will be executed next. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
| Methods inherited from class scale.score.chords.DecisionChord |
|---|
changeInDataEdge, deleteInDataEdges, getDeclList, getDisplayColorHint, getDisplayShapeHint, getExprList, getInDataEdge, getInDataEdgeArray, getLoadExprList, getNextChord, getPredicateExpr, isBranch, isLastInBasicBlock, numInDataEdges, pushInDataEdges, recordRefs, removeDualExprs, removeRefs, removeUseDef, replaceDecl, toStringSpecial, validate |
| Methods inherited from class scale.score.Note |
|---|
getChord, getEssentialUse, setAnnotationLevel, setReportLevel, toString |
| Methods inherited from class scale.common.Root |
|---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IfThenElseChord(Expr predicate,
Chord trueEdge,
Chord falseEdge)
predicate - is the test valuetrueEdge - is the next Chord if the predicate evaluates to truefalseEdge - is the next Chord if the predicate evaluates to falsepublic IfThenElseChord(Expr predicate)
predicate - is the test value| Method Detail |
|---|
public Chord copy()
Chord
copy in class Chordpublic Chord getTrueCfgEdge()
public Chord getFalseCfgEdge()
public void deleteOutCfgEdges()
null.
This method does not maintain the validity of the CFG as the
nodes at the other ends of the edges are not modified.
deleteOutCfgEdges in class Chord
public final void specifyBranchProbability(Chord edge,
double probability)
specifyBranchProbability in class DecisionChordpublic final double getBranchProbability(Chord edge)
getBranchProbability in class DecisionChordpublic void visit(Predicate p)
Note
Each class has a visit(Predicate p) method. For
example, in class ABC:
public void visit(Predicate p)
{
p.visitABC(this);
}
and the class that implements Predicate has a method
public void visitABC(Note n)
{
ABC a = (ABC) n;
...
}
Thus, the class that implements Predicate can call
n.visit(this);where
n is a Note sub-class without
determining which specific sub-class n is.
The visit pattern basically avoids implementing a large
switch statement or defining different methods
in each class for some purpose.
visit in class NotePredicatepublic void setTrueEdge(Chord trueEdge)
public void setFalseEdge(Chord falseEdge)
public final void pushAllOutCfgEdges(Stack<Chord> wl)
pushAllOutCfgEdges in class Chordpublic final void pushOutCfgEdges(Stack<Chord> wl)
pushOutCfgEdges in class ChordChord.nextVisit(),
Chord.setVisited(),
Chord.visited()
public final void pushOutCfgEdges(Stack<Chord> wl,
HashSet<Chord> done)
pushOutCfgEdges in class Chorddone - is the set of visited CFG nodespublic final void pushSortedOutCfgEdges(Stack<Chord> wl)
pushSortedOutCfgEdges in class Chord
public void pushSortedOutCfgEdges(Stack<Chord> wl,
HashSet<Chord> finished)
pushSortedOutCfgEdges in class Chordfinished - is the set of finished nodes.public void clearEdgeMarkers()
clearEdgeMarkers in class Chordpublic boolean edgeMarked(int edge)
edgeMarked in class Chordedge - specifies the edge associated with the marker
getOutCfgEdge(int)public void markEdge(int edge)
markEdge in class Chordedge - specifies the edge associated with the markergetOutCfgEdge(int)public void clearEdge(int edge)
clearEdge in class Chordedge - specifies the edge associated with the markergetOutCfgEdge(int)public final int numOutCfgEdges()
numOutCfgEdges in class Chordpublic final Chord getOutCfgEdge(int i)
getOutCfgEdge in class Chordpublic final Chord[] getOutCfgEdgeArray()
getOutCfgEdgeArray in class Chord
public final int indexOfOutCfgEdge(Chord to,
int skip)
indexOfOutCfgEdge in class Chordto - is the target CFG nodeskip - ispecifies how many occurrances of to to
skip
public void replaceOutCfgEdge(Chord oldChord,
Chord newChord)
replaceOutCfgEdge in class ChordoldChord - is the old edgenewChord - is the new edge
public void changeOutCfgEdge(Chord oldEdge,
Chord newEdge)
changeOutCfgEdge in class ChordoldEdge - the out-going CFG edge to be changednewEdge - the new out-going CFG edgepublic void linkSubgraph(HashMap<Chord,Chord> nm)
linkSubgraph in class Chordnm - is a map from the old nodes to the new nodes.Scribble.linkSubgraph(scale.common.Vector, scale.common.HashMap, scale.common.Vector) public int getBranchEdgeIndex(java.lang.Object key)
getBranchEdgeIndex in class DecisionChordkey - specifies the out-going CFG edgepublic int executionCostEstimate()
executionCostEstimate in class Note
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||