scale.clef.type
Class AggregateType

java.lang.Object
  extended by scale.common.Root
      extended by scale.clef.Node
          extended by scale.clef.type.Type
              extended by scale.clef.type.CompositeType
                  extended by scale.clef.type.AggregateType
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
RecordType

public abstract class AggregateType
extends CompositeType

An aggregate type contains a list of fields (either field declarations or routine declarations).

$Id: AggregateType.java,v 1.72 2007-10-04 19:58:08 burrill Exp $

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


Field Summary
static int FT_F32
          All fields are 32-bit floating point.
static int FT_F64
          All fields are 64-bit floating point.
static int FT_FP
          All fields are floating point.
static int FT_INT
          All fields are integer or address type.
static int FT_MIX
           
static int FT_START
          No fields in the structure.
 
Constructor Summary
AggregateType(Vector<FieldDecl> fields)
           
AggregateType(Vector<FieldDecl> fields, boolean ordered)
           
 
Method Summary
 int alignment(Machine machine)
          Calculate the alignment needed for this data type.
 int allFieldsType()
          Return the "type" of all the fields in a structure including any sub-structures.
 boolean compareFields(AggregateType t2, boolean useFieldName, boolean useFieldType, boolean useMethod)
          Check the set of fields for equivalence.
 boolean compareFields(AggregateType t2, boolean inOrder, boolean useFieldName, boolean useFieldType, boolean useMethod)
          Check the set of fields for equivalence.
 boolean compareFields(Vector<FieldDecl> fields, boolean useFieldName, boolean useFieldType, boolean useMethod)
          Check the set of fields for equivalence.
protected static boolean compareUnique(Vector<FieldDecl> fields1, Vector<FieldDecl> fields2)
          Return true if the two sets of fields are identical (==).
 FieldDecl findField(java.lang.String name)
          Return the field with the specified name or null.
 Vector<FieldDecl> getAgFields()
          Return the vector containing the fields.
 Node getChild(int i)
          Return the specified AST child of this node.
 FieldDecl getField(int i)
          Return the specified field.
 FieldDecl getFieldFromOffset(long offset)
          Return the field whose offset is specified.
 int getFieldIndex(FieldDecl fd)
          Return the index of the field in the aggregation or -1 if not found.
 boolean isAggregateType()
          Return true if type represents an aggregate object.
 boolean isOrdered()
          Return true if the fields are ordered.
 int numChildren()
          Return the number of AST children of this node.
 int numFields()
          Return the number of fields in the aggragate type.
 AggregateType returnAggregateType()
          Return if this is a AggregateType, return this.
protected  void setFields(Vector<FieldDecl> fs)
          Go back through and fix up the field declarations so that each declaration has a pointer to this class instance.
 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.CompositeType
isCompositeType, returnCompositeType
 
Methods inherited from class scale.clef.type.Type
canBeInRegister, cleanup, elementSize, equivalent, getCompleteType, getCoreType, getDisplayColorHint, getDisplayLabel, getDisplayShapeHint, getEquivalentType, getNonAttributeType, getNonConstType, getPointedTo, getPointedToCore, getRank, getSignedType, getTag, getType, isAllocArrayType, isArrayType, isAtomicType, isAttributeSet, isBooleanType, isCharacterType, isClassType, isComplexType, isConst, isEnumerationType, isFixedArrayType, isFloatType, isFortranCharType, isIncompleteType, isIntegerType, isNamedType, isNumericType, isPointerType, isProcedureType, isRealType, isRefType, isRestricted, isSigned, isUnionType, isVoidType, isVolatile, mapTypeToCString, mapTypeToF77String, memorySize, memorySizeAsInt, nextVisit, numberOfElements, precedence, registerType, returnAllocArrayType, returnArrayType, returnAtomicType, returnBooleanType, returnCharacterType, returnComplexType, returnEnumerationType, returnFixedArrayType, returnFloatType, returnFortranCharType, returnIncompleteType, returnIntegerType, returnNumericType, returnPointerType, returnProcedureType, returnRealType, returnRecordType, returnRefType, returnSignedIntegerType, returnUnionType, returnUnsignedIntegerType, returnVoidType, setTag, setVisited, specifyCanBeInRegister, toString, toStringShort, visited
 
Methods inherited from class scale.clef.Node
getDecl, getSourceLineNumber, setAnnotationLevel, setReportLevel, setSourceLineNumber, 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, trace, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FT_START

public static final int FT_START
No fields in the structure.

See Also:
allFieldsType(), Constant Field Values

FT_INT

public static final int FT_INT
All fields are integer or address type.

See Also:
allFieldsType(), Constant Field Values

FT_F32

public static final int FT_F32
All fields are 32-bit floating point.

See Also:
allFieldsType(), Constant Field Values

FT_F64

public static final int FT_F64
All fields are 64-bit floating point.

See Also:
allFieldsType(), Constant Field Values

FT_FP

public static final int FT_FP
All fields are floating point.

See Also:
allFieldsType(), Constant Field Values

FT_MIX

public static final int FT_MIX
See Also:
Constant Field Values
Constructor Detail

AggregateType

public AggregateType(Vector<FieldDecl> fields,
                     boolean ordered)

AggregateType

public AggregateType(Vector<FieldDecl> fields)
Method Detail

isAggregateType

public final boolean isAggregateType()
Return true if type represents an aggregate object.

Overrides:
isAggregateType in class Type

returnAggregateType

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

Overrides:
returnAggregateType in class Type

findField

public final FieldDecl findField(java.lang.String name)
Return the field with the specified name or null.


numFields

public final int numFields()
Return the number of fields in the aggragate type.


getField

public final FieldDecl getField(int i)
Return the specified field.


getFieldFromOffset

public final FieldDecl getFieldFromOffset(long offset)
Return the field whose offset is specified.


getFieldIndex

public int getFieldIndex(FieldDecl fd)
Return the index of the field in the aggregation or -1 if not found.


getAgFields

public Vector<FieldDecl> getAgFields()
Return the vector containing the fields.


allFieldsType

public final int allFieldsType()
Return the "type" of all the fields in a structure including any sub-structures. The returned "type" is one of


isOrdered

public final boolean isOrdered()
Return true if the fields are ordered.


alignment

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

Specified by:
alignment 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 CompositeType
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 CompositeType
See Also:
TypePredicate

setFields

protected final void setFields(Vector<FieldDecl> fs)
Go back through and fix up the field declarations so that each declaration has a pointer to this class instance. This is a chicken and egg problem because we want to add the class to the method declarations before the class is created. But, if we create the class first, then the class doesn't have any declarations to begin with and we have to add them later (along with the base clases).

Parameters:
fs - is the list of fields

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

compareUnique

protected static boolean compareUnique(Vector<FieldDecl> fields1,
                                       Vector<FieldDecl> fields2)
Return true if the two sets of fields are identical (==).


compareFields

public boolean compareFields(Vector<FieldDecl> fields,
                             boolean useFieldName,
                             boolean useFieldType,
                             boolean useMethod)
Check the set of fields for equivalence.

Parameters:
fields - is the list of fields to compare to this types fields
useFieldName - is true to compare field names
useFieldType - is true to compare field types
useMethod - is true to compare method fields

compareFields

public boolean compareFields(AggregateType t2,
                             boolean useFieldName,
                             boolean useFieldType,
                             boolean useMethod)
Check the set of fields for equivalence.


compareFields

public boolean compareFields(AggregateType t2,
                             boolean inOrder,
                             boolean useFieldName,
                             boolean useFieldType,
                             boolean useMethod)
Check the set of fields for equivalence.