|
|||||||||
| 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.type.Type
scale.clef.type.CompositeType
scale.clef.type.AggregateType
public abstract class AggregateType
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.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 |
|---|
public static final int FT_START
allFieldsType(),
Constant Field Valuespublic static final int FT_INT
allFieldsType(),
Constant Field Valuespublic static final int FT_F32
allFieldsType(),
Constant Field Valuespublic static final int FT_F64
allFieldsType(),
Constant Field Valuespublic static final int FT_FP
allFieldsType(),
Constant Field Valuespublic static final int FT_MIX
| Constructor Detail |
|---|
public AggregateType(Vector<FieldDecl> fields,
boolean ordered)
public AggregateType(Vector<FieldDecl> fields)
| Method Detail |
|---|
public final boolean isAggregateType()
isAggregateType in class Typepublic final AggregateType returnAggregateType()
Typethis is a AggregateType, return this. Otherwise, return
null.
returnAggregateType in class Typepublic final FieldDecl findField(java.lang.String name)
null.
public final int numFields()
public final FieldDecl getField(int i)
public final FieldDecl getFieldFromOffset(long offset)
public int getFieldIndex(FieldDecl fd)
public Vector<FieldDecl> getAgFields()
public final int allFieldsType()
public final boolean isOrdered()
public int alignment(Machine machine)
alignment in class Typepublic 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 CompositeTypePredicatepublic void visit(TypePredicate p)
Type
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.
visit in class CompositeTypeTypePredicateprotected final void setFields(Vector<FieldDecl> fs)
fs - is the list of fieldspublic Node getChild(int i)
getChild in class Nodepublic int numChildren()
numChildren in class Node
protected static boolean compareUnique(Vector<FieldDecl> fields1,
Vector<FieldDecl> fields2)
public boolean compareFields(Vector<FieldDecl> fields,
boolean useFieldName,
boolean useFieldType,
boolean useMethod)
fields - is the list of fields to compare to this types fieldsuseFieldName - is true to compare field namesuseFieldType - is true to compare field typesuseMethod - is true to compare method fields
public boolean compareFields(AggregateType t2,
boolean useFieldName,
boolean useFieldType,
boolean useMethod)
public boolean compareFields(AggregateType t2,
boolean inOrder,
boolean useFieldName,
boolean useFieldType,
boolean useMethod)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||