|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.score.Note
public abstract class Note
This class is the base class for the CFG class hierarchy.
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Score has two kinds of nodes:
Expressions represent the expected notion of expression (e.g., a + b).Chords
represent executable
statements in a program. These two kinds of nodes are realized as
derived classes of this class.
The CFG does not use the special/region node subhierarchy. The CFG
uses "cfg" edges instead of control edges. We build a CDG
on top of an existing CFG.
Chords have an unknown number of incoming cfg edges (aka, data flow edges) and a fixed number of outgoing CFG edges. Chords also have a fixed number of incoming data edges but no outgoing data edges. Exprs have a fixed number of incoming data edges and one outgoing data edge.
Our represntation maintains bi-directional edges. For every graph edge which points to this node, this node also has a pointer back to the source of the graph edge. Hence, a CFG has twice as many edges as the conceptual graph which it is implementing.
From a very high-level view, nodes support a fully general graph. But in reality, different types of nodes have different restrictions on their incoming and outgoing edges.
Constructor Summary | |
---|---|
protected |
Note()
Constructor for a CFG node instance. |
Method Summary | |
---|---|
abstract void |
changeInDataEdge(Expr oldExpr,
Expr newExpr)
This method changes an incoming data edge to point to a new expression. |
abstract int |
executionCostEstimate()
Return a relative cost estimate for executing this node. |
Chord |
getChord()
Return the Chord instance
containing this Note. |
Note |
getEssentialUse()
Return this Note instance unless it is a non-essential expression. |
abstract Expr |
getInDataEdge(int i)
Return the specified in-coming data edge. |
abstract Expr[] |
getInDataEdgeArray()
Use this method when you may be modifying an in-coming data edge while iterating over the edges. |
abstract int |
numInDataEdges()
Return number of in-coming data edges. |
static void |
setAnnotationLevel(int level)
Set the depth to which a node displays it's annotations. |
static void |
setReportLevel(int level)
Set the depth to which a node displays its children. |
java.lang.String |
toString()
|
void |
validate()
Check this node for validity. |
abstract void |
visit(Predicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.common.Root |
---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayColorHint, getDisplayLabel, getDisplayName, getDisplayShapeHint, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, toStringSpecial, trace, trace, trace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected Note()
Method Detail |
---|
public abstract Expr[] getInDataEdgeArray()
public abstract Expr getInDataEdge(int i)
public abstract int numInDataEdges()
public abstract void changeInDataEdge(Expr oldExpr, Expr newExpr)
This method ensures that the node previously pointing to this one is updated properly, as well as, the node which will now point to this node.
Expr and Chord nodes have a fixed number of incoming edges with specific meaning applied to each. Hence, the edge being replaced is indicated by position.
oldExpr
- is the expression to be replacednewExpr
- is the new expressionpublic abstract void visit(Predicate p)
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.
Predicate
public static void setReportLevel(int level)
public static void setAnnotationLevel(int level)
public final java.lang.String toString()
toString
in class Root
public final Chord getChord()
Chord
instance
containing this Note.
public void validate()
public Note getEssentialUse()
Chord
this
method returns this
. For a DualExpr
or an address cast (e.g.,
ConversionExpr
) this
method returns the out data edge.
public abstract int executionCostEstimate()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |