|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectscale.common.Root
scale.clef.Node
scale.clef.expr.Expression
scale.clef.expr.Literal
public class Literal
The base class for classes which represent a literal, or constant, value.
$Id: Literal.java,v 1.61 2007-08-28 17:58:21 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
This class is also used to provide special literal values such
as needed by the Lattice class.
| Constructor Summary | |
|---|---|
Literal(Type type)
|
|
| Method Summary | |
|---|---|
int |
executionCostEstimate()
Return a relative cost estimate for executing the expression. |
int |
findCoefficient()
Return the coefficient value. |
static java.lang.String |
formatRealValue(double value)
Return a string representing the floating point value. |
Literal |
getConstantValue()
Return the constant value of the expression. |
int |
getCount()
Return the number of elements in the Literal. |
void |
getDeclList(java.util.AbstractCollection<Declaration> varList)
Add all declarations referenced in this expression to the collection. |
java.lang.String |
getDisplayLabel()
Return short description of current node. |
Literal |
getElement(long index)
Return the specified element of the constant. |
java.lang.String |
getGenericValue()
Get the string version of the literal using C syntax. |
boolean |
isOne()
Return true if the value of this literal is known to be one. |
boolean |
isZero()
Return true if the value of this literal is known to be zero. |
int |
linearity()
Return linearity of literal. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
| Methods inherited from class scale.clef.expr.Expression |
|---|
canonical, containsDeclaration, equivalent, getCoreType, getDisplayColorHint, getDisplayShapeHint, getPointedToCore, getType, hasTrueFalseResult, isSimpleOp, setType, toStringSpecial |
| 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 Literal(Type type)
| Method Detail |
|---|
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 ExpressionPredicatepublic java.lang.String getGenericValue()
public int getCount()
public Literal getElement(long index)
throws InvalidException
InvalidExceptionpublic Literal getConstantValue()
getConstantValue in class ExpressionLatticepublic java.lang.String getDisplayLabel()
getDisplayLabel in interface DisplayNodegetDisplayLabel in class Expressionpublic int linearity()
public int findCoefficient()
public int executionCostEstimate()
public boolean isZero()
public boolean isOne()
public static java.lang.String formatRealValue(double value)
public void getDeclList(java.util.AbstractCollection<Declaration> varList)
Expression
getDeclList in class Expression
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||