scale.clef.expr
Class Expression

java.lang.Object
  |
  +--scale.common.Root
        |
        +--scale.clef.Node
              |
              +--scale.clef.expr.Expression
All Implemented Interfaces:
AnnotationInterface, DisplayNode, java.io.Serializable
Direct Known Subclasses:
Argument, IdReferenceOp, Literal, Operator

public abstract class Expression
extends Node

This is the base class for expressions such as add, subscript, etc.

$Id: Expression.java,v 1.55 2002/01/03 21:43:05 burrill Exp $

Copyright 2002 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

See Also:
Serialized Form

Fields inherited from interface scale.common.DisplayNode
ANNO, CLEF, DD, DEFUSE, DOM, EXPR, MAYUSE, TYPE
 
Constructor Summary
Expression(Type type)
           
 
Method Summary
 long canonical()
          Return a unique value representing this particular expression.
 boolean equivalent(java.lang.Object exp)
          Return true if the two expressions are equivalent.
protected  void finalize()
          Keep the count of instances up-to-date.
 java.lang.Object getConstantValue()
          Return the constant value of the expression.
 Type getCoreType()
          Get the actual Type in cases where getting a RefType will be a problem.
 java.lang.String getDisplayColorHint()
          Return a String specifying the color to use for coloring this node in a graphical display.
 java.lang.String getDisplayShapeHint()
          Return a String specifying a shape to use when drawing this node in a graphical display.
 java.lang.String getDisplayText()
          Return a String suitable for labeling this node in a graphical display.
 Node getParent()
          Return my parent in the Clef tree if any.
 Type getType()
          Return the Type associated with this Node.
static int number()
          Return the current number of instances of this class.
protected  void setChildParent(Vector list)
           
 void setParent(Node parent)
          Not all nodes have parents in the CLEF AST since it is really a DAG and not a tree structure.
 void setType(Type type)
          Specify the type associated with this expression.
 java.lang.String toStringSpecial()
          Return any special information of a node that is not a child or annotation.
 void visit(Predicate p)
          The visit() method is used to implement a visit 'pattern'.
 
Methods inherited from class scale.clef.Node
createChildren, getChildren, getDecl, setAnnotationLevel, setReportLevel, 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
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expression

public Expression(Type type)
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Keep the count of instances up-to-date.
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - [needs description]

number

public static int number()
Return the current number of instances of this class.

equivalent

public boolean equivalent(java.lang.Object exp)
Return true if the two expressions are equivalent.

getParent

public final Node getParent()
Return my parent in the Clef tree if any.
Overrides:
getParent in class Node
Following copied from class: scale.clef.Node
Returns:
my parent in the Clef tree if any

setParent

public void setParent(Node parent)
Description copied from class: Node
Not all nodes have parents in the CLEF AST since it is really a DAG and not a tree structure. Generate an error unless this method is defined for the derived class.
Overrides:
setParent in class Node
Parameters:
p - my parent in the Clef tree

setChildParent

protected void setChildParent(Vector list)

toStringSpecial

public java.lang.String toStringSpecial()
Description copied from class: Root
Return any special information of a node that is not a child or annotation. This method is meant to be overridden by nodes that need to provide special output.
Overrides:
toStringSpecial in class Node

getDisplayText

public java.lang.String getDisplayText()
Return a String suitable for labeling this node in a graphical display. This method should be over-ridden as it simplay returns the class name.
Overrides:
getDisplayText in class Root

getDisplayColorHint

public java.lang.String getDisplayColorHint()
Return a String specifying the color to use for coloring this node in a graphical display. This method should be over-ridden as it simplay returns the color red.
Overrides:
getDisplayColorHint in class Root

getDisplayShapeHint

public java.lang.String getDisplayShapeHint()
Return a String specifying a shape to use when drawing this node in a graphical display. This method should be over-ridden as it simplay returns the shape "box".
Overrides:
getDisplayShapeHint in class Root

visit

public void visit(Predicate p)
Description copied from class: Node
The visit() method is used to implement a visit 'pattern'.
Overrides:
visit in class Node

getType

public final Type getType()
Description copied from class: Node
Return the Type associated with this Node.
Overrides:
getType in class Node

setType

public void setType(Type type)
Specify the type associated with this expression.

getCoreType

public final Type getCoreType()
Get the actual Type in cases where getting a RefType will be a problem. For example, if the expression should be of type PointerType, a cast of a RefType to PointerType will cause an exception eventhough the RefType contains the PointerType. Note - getType() should always be used when the Type is not examined or when the attributes are needed.
Overrides:
getCoreType in class Node
See Also:
getType(), RefType

getConstantValue

public java.lang.Object getConstantValue()
Return the constant value of the expression.
See Also:
Lattice

canonical

public long canonical()
Return a unique value representing this particular expression.