scale.clef.type
Class IncompleteType

java.lang.Object
  extended by scale.common.Root
      extended by scale.clef.Node
          extended by scale.clef.type.Type
              extended by scale.clef.type.IncompleteType
All Implemented Interfaces:
AnnotationInterface, DisplayNode

public class IncompleteType
extends Type

An IncompleteType is used to represent a type before the complete type is known.

$Id: IncompleteType.java,v 1.63 2007-08-27 18:13:32 burrill Exp $

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

For example, when creating a struct type in C, a field of the struct may reference itself.


Constructor Summary
IncompleteType()
           
 
Method Summary
 int alignment(Machine machine)
          Calculate the alignment needed for this data type.
 long elementSize(Machine machine)
          Return the number of addressable memory units are needed to represent an element of the type.
 boolean equivalent(Type t)
          Return true if the types are equivalent.
 Node getChild(int i)
          Return the specified AST child of this node.
 Type getCompleteType()
          Return the completed type or null if it is not complete.
 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.
protected  Type getEquivalentType()
          Return the type to be used by the equivalence method.
 Type getNonConstType()
          Return the type without any "const" attributes.
 int getRank()
          Return the rank of the type.
 Type getSignedType()
          Return the equivalent signed type.
 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(RefAttr 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 isIncompleteType()
          Return true if type represents an incomplete type.
 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 isProcedureType()
          Return true if this type represents a procedure.
 boolean isRealType()
          Return true if type represents a floating point value.
 boolean isRestricted()
          Return true if the type specifies restricted.
 boolean isSigned()
          Return true is the type is signed.
 boolean isUnionType()
          Return true if type represents a union object.
 boolean isVoidType()
          Return true if type represents no type.
 boolean isVolatile()
          Return true if the type specifies volatile.
 long memorySize(Machine machine)
          Return the number of addressable memory units are needed to represent the type.
 int numChildren()
          Return the number of AST children of this node.
 int precedence()
          Return a precedence value for types.
 Type registerType()
          Return the type to use if a variable of this type is in a register.
 IncompleteType returnIncompleteType()
          Return if this is a IncompleteType, return this.
 void setCompleteType(Type type)
          Specify the completed type.
 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.
 void visit(TypePredicate p)
          Process a node by calling its associated routine.
 
Methods inherited from class scale.clef.type.Type
canBeInRegister, cleanup, getDisplayColorHint, getDisplayLabel, getDisplayShapeHint, getNonAttributeType, getPointedTo, getPointedToCore, getTag, getType, isAllocArrayType, isBooleanType, isCharacterType, isClassType, isEnumerationType, isFixedArrayType, isFloatType, isFortranCharType, isRefType, mapTypeToCString, mapTypeToF77String, memorySizeAsInt, nextVisit, numberOfElements, returnAggregateType, returnAllocArrayType, returnArrayType, returnAtomicType, returnBooleanType, returnCharacterType, returnComplexType, returnCompositeType, returnEnumerationType, returnFixedArrayType, returnFloatType, returnFortranCharType, returnIntegerType, returnNumericType, returnPointerType, returnProcedureType, returnRealType, returnRecordType, returnRefType, returnSignedIntegerType, returnUnionType, returnUnsignedIntegerType, returnVoidType, setTag, setVisited, specifyCanBeInRegister, toString, toStringShort, visited
 
Methods inherited from class scale.clef.Node
getSourceLineNumber, setAnnotationLevel, setReportLevel, setSourceLineNumber, 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

IncompleteType

public IncompleteType()
Method Detail

getCompleteType

public Type getCompleteType()
Return the completed type or null if it is not complete.

Overrides:
getCompleteType in class Type
See Also:
IncompleteType

setCompleteType

public final void setCompleteType(Type type)
Specify the completed type.


getNonConstType

public Type getNonConstType()
Return the type without any "const" attributes.

Overrides:
getNonConstType in class Type
See Also:
RefType

isAttributeSet

public boolean isAttributeSet(RefAttr attribute)
Return true if the attribute is associated with this type.

Overrides:
isAttributeSet in class Type
See Also:
RefType

isIncompleteType

public final boolean isIncompleteType()
Return true if type represents an incomplete type.

Overrides:
isIncompleteType in class Type

returnIncompleteType

public final IncompleteType returnIncompleteType()
Description copied from class: Type
Return if this is a IncompleteType, return this. Otherwise, return null.

Overrides:
returnIncompleteType 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

isUnionType

public boolean isUnionType()
Return true if type represents a union object.

Overrides:
isUnionType 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

isProcedureType

public boolean isProcedureType()
Return true if this type represents a procedure.

Overrides:
isProcedureType in class Type

isSigned

public boolean isSigned()
Return true is the type is signed.

Overrides:
isSigned in class Type

getSignedType

public Type getSignedType()
Return the equivalent signed type.

Overrides:
getSignedType in class Type

getDecl

public Declaration getDecl()
Return the TypeDecl or TypeName of this type reference.

Overrides:
getDecl in class Node

registerType

public Type registerType()
Return the type to use if a variable of this type is in a register.

Overrides:
registerType in class Type

visit

public void visit(Predicate p)
Description copied from class: Node
Process a node by calling its associated routine. See the "visitor" design pattern in Design Patterns: Elements of Reusable Object-Oriented Software by E. Gamma, et al, Addison Wesley, ISBN 0-201-63361-2.

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.

Overrides:
visit in class Type
See Also:
Predicate

visit

public void visit(TypePredicate p)
Description copied from class: Type
Process a node by calling its associated routine. See the "visitor" design pattern in Design Patterns: Elements of Reusable Object-Oriented Software by E. Gamma, et al, Addison Wesley, ISBN 0-201-63361-2.

Each type class has a visit(TypePredicate 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 TypePredicate 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.

Overrides:
visit in class Type
See Also:
TypePredicate

getChild

public Node getChild(int i)
Return the specified AST child of this node.

Overrides:
getChild in class Node

numChildren

public int numChildren()
Return the number of AST children of this node.

Overrides:
numChildren in class Node

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()

getRank

public int getRank()
Return the rank of the type. For a scalar, the rank is 0. For an array, the rank is the number of dimensions.

Overrides:
getRank in class Type

memorySize

public long memorySize(Machine machine)
Return the number of addressable memory units are needed to represent the type.

Specified by:
memorySize in class Type
Parameters:
machine - is the machine-specific data machine

elementSize

public long elementSize(Machine machine)
Return the number of addressable memory units are needed to represent an element of the type. Except for arrays this is identical to the value return by memorySize().

Overrides:
elementSize in class Type
Parameters:
machine - is the machine-specific data machine

alignment

public int alignment(Machine machine)
Calculate the alignment needed for this data type.

Specified by:
alignment in class Type

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

isRestricted

public boolean isRestricted()
Return true if the type specifies restricted.

Overrides:
isRestricted in class Type

toStringSpecial

public java.lang.String toStringSpecial()
Description copied from class: Node
This method allows sub-classes to provide class specific stuff to the string.

Overrides:
toStringSpecial in class Node

equivalent

public boolean equivalent(Type t)
Return true if the types are equivalent.

Specified by:
equivalent in class Type

getEquivalentType

protected Type getEquivalentType()
Return the type to be used by the equivalence method.

Overrides:
getEquivalentType in class Type

precedence

public int precedence()
Return a precedence value for types. We assign precendence values to declarators that use operators (e.g., arrays, functions, pointers). The precendence values are relative to the other operators - larger values mean higher precedence.

Overrides:
precedence in class Type
Returns:
an integer representing the precendence value for the type relative to the other values.