scale.clef.type
Class RefType

java.lang.Object
  |
  +--scale.common.Root
        |
        +--scale.clef.Node
              |
              +--scale.clef.type.Type
                    |
                    +--scale.clef.type.RefType
All Implemented Interfaces:
AnnotationInterface, DisplayNode, java.io.Serializable

public class RefType
extends Type

A RefType node is used to represent an exisiting type when attributes must be set on a new equivalent type.

$Id: RefType.java,v 1.45 2002/01/03 21:44:14 burrill Exp $

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

For example:

   char *s;
   typedef const char *Identifier;
   Identifier id;
 
would be represented in clef as:
      VariableDecl(s)  VariableDecl(id)  TypeDecl(Identifier)
             \                 |          |
              \                |          |
               \               v          v
                \             RefType{const}
                 \            /
                  \          /
                   |         |
                   v         v
                   PointerType
                        |
                        v
                   CharacterType
 

See Also:
Serialized Form

Field Summary
static java.lang.String[] attributeMap
           
static int cConstantType
          Indicates that instances of this type have a constant value.
static int cNone
          This section describes what attributes are associated with a type.
static int cOrdered
          For types with substructures, this attribute indicates if the source language requires the data layout to preserve the order of substructures (declaration order is assumed).
static int cTraced
          Supports Modula-3's traced data types.
static int cUnordered
          For types with substructures, this attribute indicates if the type may be layed out in an arbitrary order.
static int cUntraced
          Supports Modula-3's untraced data types.
static int cVaList
          For the type that represents the builtin type va_list.
static int cVolatile
          Marks a value which may be changed by something which a compiler cannot detect.
 
Fields inherited from interface scale.common.DisplayNode
ANNO, CLEF, DD, DEFUSE, DOM, EXPR, MAYUSE, TYPE
 
Method Summary
 int alignment(Machine machine)
          Calculate the alignment needed for this data type.
static RefType create(Type refTo, Declaration myDecl)
           
static RefType create(Type refTo, int attribute)
           
static RefType create(Type refTo, int attribute, Declaration myDecl)
          Re-use an existing instance of a particular reference type.
protected  Vector createChildren()
          Create the list of children for the node - each node that has children must implement this method.
 boolean equivalent(Type t)
          Return true if the types are equivalent.
protected  void finalize()
          Keep the count of instances up-to-date.
 int getAttribute()
          Return the attribute of this type reference.
 Type getCoreType()
          This method filters out some the special case type nodes from a type DAG.
 Declaration getDecl()
          Return the TypeDecl or TypeName of this type reference.
 java.lang.String getDisplayText()
          Return a String suitable for labeling this node in a graphical display.
 Type getRefTo()
           
static java.util.Enumeration getTypes()
          Return an Enumeration of all the different types.
 boolean isAddressType()
          Return true if type represents the address of something.
 boolean isAggregateType()
          Return true if type represents an aggregate object.
 boolean isArrayType()
          Return true if type represents an array.
 boolean isAtomicType()
          Return true if type represents a scaler value.
 boolean isAttributeSet(int attribute)
          Return true if the attribute is associated with this type.
 boolean isComplexType()
          Return true if type represents a complex value.
 boolean isCompositeType()
          Return true if type represents a composite type.
 boolean isConst()
          Return true if the type specifies const.
 boolean isIntegerType()
          Return true if type represents an integer value.
 boolean isNamedType()
          Return true if this type has an associated TypeName or TypeDecl.
 boolean isNumericType()
          Return true if type represents a numeric value.
 boolean isPointerType()
          Return true if type represents an address.
 boolean isRealType()
          Return true if type represents a floating point value.
 boolean isSigned()
          Return true is the type is signed.
 boolean isVoidType()
          Return true if type represents no type.
 boolean isVolatile()
          Return true if the type specifies volatile.
 int memorySize(Machine machine)
          Calculate how many addressable memory units are needed to represent the type.
static int number()
          Return the current number of instances of this class.
 java.lang.String toString()
           
 java.lang.String toStringShort()
           
 void visit(Predicate p)
          The visit() method is used to implement a visit 'pattern'.
 
Methods inherited from class scale.clef.type.Type
getCompleteType, getDisplayColorHint, getDisplayShapeHint, getPointedTo, getTag, getType, nextVisit, setTag, setVisited, visited
 
Methods inherited from class scale.clef.Node
getChildren, getParent, setAnnotationLevel, setParent, setReportLevel, toString, toStringChildren, toStringSpecial
 
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
 

Field Detail

cNone

public static final int cNone
This section describes what attributes are associated with a type. Attributes are non-type information that is associated with a type because they can be associated with just a part of a type declaration. Attributes should generally not affect type equivalence (except perhaps in some minor cases). Ideally, equivalent types would share the same physical representation. However, types that differ only in attributes should be equivalent, yet cannot share attributes.

cTraced

public static final int cTraced
Supports Modula-3's traced data types.

cUntraced

public static final int cUntraced
Supports Modula-3's untraced data types. This is the default attribute for all types.

cConstantType

public static final int cConstantType
Indicates that instances of this type have a constant value. By default, instances of a type are mutable.

One could reasonably argue that the immutability of a value is not a property (or attribute) of a type. However, C++'s typedef construct permits immutability to be included with the type.


cVolatile

public static final int cVolatile
Marks a value which may be changed by something which a compiler cannot detect.

cOrdered

public static final int cOrdered
For types with substructures, this attribute indicates if the source language requires the data layout to preserve the order of substructures (declaration order is assumed).

cUnordered

public static final int cUnordered
For types with substructures, this attribute indicates if the type may be layed out in an arbitrary order.

cVaList

public static final int cVaList
For the type that represents the builtin type va_list.

attributeMap

public static final java.lang.String[] attributeMap
Method Detail

finalize

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

number

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

create

public static RefType create(Type refTo,
                             int attribute,
                             Declaration myDecl)
Re-use an existing instance of a particular reference type. If no equivalent reference type exists, create a new one.
Parameters:
refTo - the actual type
attribute - an attribute of the type
myDecl - null or a TypeName or TypeDecl declaration

create

public static RefType create(Type refTo,
                             Declaration myDecl)

create

public static RefType create(Type refTo,
                             int attribute)

getRefTo

public final Type getRefTo()

isAttributeSet

public boolean isAttributeSet(int attribute)
Return true if the attribute is associated with this type.
Overrides:
isAttributeSet in class Type
Following copied from class: scale.clef.type.Type
See Also:
RefType

getAttribute

public int getAttribute()
Return the attribute of this type reference.

isConst

public boolean isConst()
Return true if the type specifies const.
Overrides:
isConst in class Type

isVolatile

public boolean isVolatile()
Return true if the type specifies volatile.
Overrides:
isVolatile in class Type

getDecl

public Declaration getDecl()
Return the TypeDecl or TypeName of this type reference.
Overrides:
getDecl in class Node

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 Type

createChildren

protected Vector createChildren()
Description copied from class: Node
Create the list of children for the node - each node that has children must implement this method. However, use getChildren() to actually get the children.
Overrides:
createChildren in class Node
Following copied from class: scale.clef.Node
Returns:
the list of children

getCoreType

public Type getCoreType()
This method filters out some the special case type nodes from a type DAG.
Overrides:
getCoreType in class Type
See Also:
Type.getCoreType()

isAddressType

public boolean isAddressType()
Return true if type represents the address of something.
Overrides:
isAddressType in class Type

isArrayType

public boolean isArrayType()
Return true if type represents an array.
Overrides:
isArrayType in class Type

isPointerType

public boolean isPointerType()
Return true if type represents an address.
Overrides:
isPointerType in class Type

isVoidType

public boolean isVoidType()
Return true if type represents no type.
Overrides:
isVoidType in class Type

isAggregateType

public boolean isAggregateType()
Return true if type represents an aggregate object.
Overrides:
isAggregateType in class Type

isCompositeType

public boolean isCompositeType()
Return true if type represents a composite type.
Overrides:
isCompositeType in class Type

isRealType

public boolean isRealType()
Return true if type represents a floating point value.
Overrides:
isRealType in class Type

isIntegerType

public boolean isIntegerType()
Return true if type represents an integer value.
Overrides:
isIntegerType in class Type

isComplexType

public boolean isComplexType()
Return true if type represents a complex value.
Overrides:
isComplexType in class Type

isAtomicType

public boolean isAtomicType()
Return true if type represents a scaler value.
Overrides:
isAtomicType in class Type

isNumericType

public boolean isNumericType()
Return true if type represents a numeric value.
Overrides:
isNumericType in class Type

isNamedType

public boolean isNamedType()
Return true if this type has an associated TypeName or TypeDecl.
Overrides:
isNamedType in class Type

isSigned

public boolean isSigned()
Return true is the type is signed.
Overrides:
isSigned in class Type

memorySize

public int memorySize(Machine machine)
Calculate how many addressable memory units are needed to represent the type.
Overrides:
memorySize in class Type
Parameters:
machine - is the machine-specific data machine
Returns:
the number of addressable memory units required to represent this type

alignment

public int alignment(Machine machine)
Calculate the alignment needed for this data type.
Overrides:
alignment in class Type

equivalent

public boolean equivalent(Type t)
Return true if the types are equivalent.
Overrides:
equivalent in class Type

getTypes

public static java.util.Enumeration getTypes()
Return an Enumeration of all the different types.

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 Type

toString

public java.lang.String toString()
Overrides:
toString in class Type

toStringShort

public java.lang.String toStringShort()
Overrides:
toStringShort in class Type