|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.clef.Node scale.clef.expr.Expression
public abstract class Expression
This is the base class for expressions such as add, subscript, etc.
$Id: Expression.java,v 1.74 2007-08-28 21:10:10 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Constructor Summary | |
---|---|
Expression(Type type)
|
Method Summary | |
---|---|
long |
canonical()
Return a unique value representing this particular expression. |
boolean |
containsDeclaration(Declaration decl)
Return true if this expression contains a reference to the variable. |
boolean |
equivalent(java.lang.Object exp)
Return true if the two expressions are equivalent. |
Literal |
getConstantValue()
Return the constant value of the expression. |
Type |
getCoreType()
Get the actual Type in cases where getting a RefType will be a problem. |
abstract void |
getDeclList(java.util.AbstractCollection<Declaration> varList)
Add all declarations referenced in this expression to the collection. |
DColor |
getDisplayColorHint()
Return a String specifying the color to use for coloring this node in a graphical display. |
java.lang.String |
getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. |
DShape |
getDisplayShapeHint()
Return a String specifying a shape to use when drawing this node in a graphical display. |
Type |
getPointedToCore()
Return the type of the thing pointed to by the type of the expression. |
Type |
getType()
Return the Type associated with this Node. |
boolean |
hasTrueFalseResult()
Return true if the result of the expression is either true (1) or false (0). |
boolean |
isSimpleOp()
Return true if compilation of this expression will not result in the generation of a CFG node . |
void |
setType(Type type)
Specify the type associated with this expression. |
java.lang.String |
toStringSpecial()
This method allows sub-classes to provide class specific stuff to the string. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.clef.Node |
---|
getChild, getDecl, getSourceLineNumber, numChildren, setAnnotationLevel, setReportLevel, setSourceLineNumber, toString, toString, toStringChildren |
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 Expression(Type type)
Method Detail |
---|
public abstract void getDeclList(java.util.AbstractCollection<Declaration> varList)
public boolean equivalent(java.lang.Object exp)
public java.lang.String toStringSpecial()
Node
toStringSpecial
in class Node
public java.lang.String getDisplayLabel()
getDisplayLabel
in interface DisplayNode
getDisplayLabel
in class Root
public DColor getDisplayColorHint()
getDisplayColorHint
in interface DisplayNode
getDisplayColorHint
in class Root
DColor
public DShape getDisplayShapeHint()
getDisplayShapeHint
in interface DisplayNode
getDisplayShapeHint
in class Root
DShape
public void visit(Predicate p)
Node
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(Node n) { ABC a = (ABC) n; ... }Thus, the class that implements
Predicate
can call
n.visit(this);where
n
is a Node
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 Node
Predicate
public final Type getType()
Node
getType
in class Node
public void setType(Type type)
public final Type getCoreType()
getCoreType
in class Node
getType()
,
RefType
public final Type getPointedToCore()
getCoreType().getPointedTo().getCoreType()
public Literal getConstantValue()
Lattice
public long canonical()
public boolean isSimpleOp()
CFG node
.
For example, (a && b)
may require a branch
to represent and
i++
requires a store
.
public boolean hasTrueFalseResult()
public boolean containsDeclaration(Declaration decl)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |