|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.clef.Node scale.clef.type.Type
public abstract class Type
This class is the root class for type nodes.
$Id: Type.java,v 1.104 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.
A type is represented by a graph (DAG) of type nodes.
The current list of special case nodes is as follows:
Types should not have annotations unless the annotation applies to every instance where the type may be used.
Constructor Summary | |
---|---|
Type()
|
Method Summary | |
---|---|
abstract int |
alignment(Machine machine)
Calculate the alignment needed for this data type. |
boolean |
canBeInRegister()
True if values of this type can be placed in a register. |
static void |
cleanup()
Remove static lists of types. |
long |
elementSize(Machine machine)
Return the number of addressable memory units are needed to represent an element of the type. |
abstract boolean |
equivalent(Type t)
Return true if the types are equivalent. |
Type |
getCompleteType()
Return the completed type or null if it is not complete. |
Type |
getCoreType()
This method filters out some of the special case type nodes from a type DAG. |
DColor |
getDisplayColorHint()
Return a String specifying the color to use for coloring this node in a graphical display. |
java.lang.String |
getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. |
DShape |
getDisplayShapeHint()
Return a String specifying a shape to use when drawing this node in a graphical display. |
protected Type |
getEquivalentType()
Return the type to be used by the equivalence method. |
Type |
getNonAttributeType()
Return the type without any attributes such as "const". |
Type |
getNonConstType()
Return the type without any "const" attributes. |
Type |
getPointedTo()
Return the type of the thing pointed to. |
Type |
getPointedToCore()
Return the type of the thing pointed to. |
int |
getRank()
Return the rank of the type. |
Type |
getSignedType()
Return the equivalent signed type of the core type. |
int |
getTag()
Return the tag associated with this variable. |
Type |
getType()
Return the Type associated with this Node. |
boolean |
isAggregateType()
Return true if type represents an aggregate object. |
boolean |
isAllocArrayType()
Return true if type represents an array whose dimensions are not known at compile time. |
boolean |
isArrayType()
Return true if type represents an array. |
boolean |
isAtomicType()
Return true if type represents an atomic type. |
boolean |
isAttributeSet(RefAttr attribute)
Return true if the attribute is associated with this type. |
boolean |
isBooleanType()
Return true if type represents a boolean type. |
boolean |
isCharacterType()
Return true if type represents a character type. |
boolean |
isClassType()
Return true if type represents a class 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 |
isEnumerationType()
Return true if type represents an enumeration value. |
boolean |
isFixedArrayType()
Return true if type represents an array whose dimensions are known at compile time. |
boolean |
isFloatType()
Return true if type represents a character type. |
boolean |
isFortranCharType()
Return true if type represents a Fortran CHARACTER type. |
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 TypeDecl or TypeName. |
boolean |
isNumericType()
Return true if type represents a numeric type. |
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 |
isRefType()
Return true if type represents a reference type. |
boolean |
isRestricted()
Return true if the type specifies restricted. |
boolean |
isSigned()
Return true if the type is signed. |
boolean |
isUnionType()
Return true if type represents a union. |
boolean |
isVoidType()
Return true if type represents no type. |
boolean |
isVolatile()
Return true if the type specifies volatile. |
java.lang.String |
mapTypeToCString()
Map a type to a C string. |
java.lang.String |
mapTypeToF77String()
Map a type to a Fortran string. |
abstract long |
memorySize(Machine machine)
Return the number of addressable memory units that are needed to represent the type. |
int |
memorySizeAsInt(Machine machine)
Calculate how many addressable memory units that are needed to represent the type. |
static void |
nextVisit()
Set up for a new traversal - that is, use the next color value. |
long |
numberOfElements()
Return the number of elements represented by this type. |
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. |
AggregateType |
returnAggregateType()
Return if this is a AggregateType , return this . |
AllocArrayType |
returnAllocArrayType()
Return if this is a AllocArrayType , return this . |
ArrayType |
returnArrayType()
Return if this is a ArrayType
return this . |
AtomicType |
returnAtomicType()
Return if this is a AtomicType
return this . |
BooleanType |
returnBooleanType()
Return if this is a BooleanType
return this . |
CharacterType |
returnCharacterType()
Return if this is a CharacterType , return this . |
ComplexType |
returnComplexType()
Return if this is a ComplexType
return this . |
CompositeType |
returnCompositeType()
Return if this is a CompositeType , return this . |
EnumerationType |
returnEnumerationType()
Return if this is a EnumerationType , return this . |
FixedArrayType |
returnFixedArrayType()
Return if this is a FixedArrayType , return this . |
FloatType |
returnFloatType()
Return if this is a FloatType
return this . |
FortranCharType |
returnFortranCharType()
Return if this is a FortranCharType , return this . |
IncompleteType |
returnIncompleteType()
Return if this is a IncompleteType , return this . |
IntegerType |
returnIntegerType()
Return if this is a IntegerType
return this . |
NumericType |
returnNumericType()
Return if this is a NumericType
return this . |
PointerType |
returnPointerType()
Return if this is a PointerType
return this . |
ProcedureType |
returnProcedureType()
Return if this is a ProcedureType , return this . |
RealType |
returnRealType()
Return if this is a RealType ,
return this . |
RecordType |
returnRecordType()
Return if this is a RecordType
return this . |
RefType |
returnRefType()
Return if this is a RefType , return
this . |
SignedIntegerType |
returnSignedIntegerType()
Return if this is a SignedIntegerType , return this . |
UnionType |
returnUnionType()
Return if this is a UnionType
return this . |
UnsignedIntegerType |
returnUnsignedIntegerType()
Return if this is a UnsignedIntegerType , return this . |
VoidType |
returnVoidType()
Return if this is a VoidType ,
return this . |
void |
setTag(int tag)
Set the tag for this variable. |
void |
setVisited()
Associate the current color value with this Type. |
void |
specifyCanBeInRegister(boolean canBeInRegister)
Specify that values of this type can be placed in a register. |
java.lang.String |
toString()
|
java.lang.String |
toStringShort()
|
void |
visit(Predicate p)
Process a node by calling its associated routine. |
void |
visit(TypePredicate p)
Process a node by calling its associated routine. |
boolean |
visited()
Return true if this Type has been visited during the current visit (i.e., is the current color). |
Methods inherited from class scale.clef.Node |
---|
getChild, getDecl, getSourceLineNumber, numChildren, 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 |
Constructor Detail |
---|
public Type()
Method Detail |
---|
public static void nextVisit()
setVisited()
,
visited()
,
nextVisit()
public void setVisited()
nextVisit()
,
visited()
public final boolean visited()
nextVisit()
,
setVisited()
public final void setTag(int tag)
public final int getTag()
public final void specifyCanBeInRegister(boolean canBeInRegister)
public final boolean canBeInRegister()
specifyCanBeInRegister()
method has been called for the type
instance. (See the code in
scale.backend.Generator#processCoreType().)
public java.lang.String toString()
toString
in class Node
public java.lang.String toStringShort()
public java.lang.String getDisplayLabel()
getDisplayLabel
in interface DisplayNode
getDisplayLabel
in class Root
public DColor getDisplayColorHint()
getDisplayColorHint
in interface DisplayNode
getDisplayColorHint
in class Root
DColor
public DShape getDisplayShapeHint()
getDisplayShapeHint
in interface DisplayNode
getDisplayShapeHint
in class Root
DShape
public AggregateType returnAggregateType()
this
is a AggregateType
, return this
. Otherwise, return
null
.
public AllocArrayType returnAllocArrayType()
this
is a AllocArrayType
, return this
. Otherwise, return
null
.
public ArrayType returnArrayType()
this
is a ArrayType
return this
. Otherwise, return null
.
public AtomicType returnAtomicType()
this
is a AtomicType
return this
. Otherwise, return null
.
public BooleanType returnBooleanType()
this
is a BooleanType
return this
. Otherwise, return null
.
public CharacterType returnCharacterType()
this
is a CharacterType
, return this
. Otherwise, return
null
.
public ComplexType returnComplexType()
this
is a ComplexType
return this
. Otherwise, return null
.
public CompositeType returnCompositeType()
this
is a CompositeType
, return this
. Otherwise, return
null
.
public EnumerationType returnEnumerationType()
this
is a EnumerationType
, return this
. Otherwise, return
null
.
public FixedArrayType returnFixedArrayType()
this
is a FixedArrayType
, return this
. Otherwise, return
null
.
public FloatType returnFloatType()
this
is a FloatType
return this
. Otherwise, return null
.
public FortranCharType returnFortranCharType()
this
is a FortranCharType
, return this
. Otherwise, return
null
.
public IncompleteType returnIncompleteType()
this
is a IncompleteType
, return this
. Otherwise, return
null
.
public IntegerType returnIntegerType()
this
is a IntegerType
return this
. Otherwise, return null
.
public NumericType returnNumericType()
this
is a NumericType
return this
. Otherwise, return null
.
public PointerType returnPointerType()
this
is a PointerType
return this
. Otherwise, return null
.
public ProcedureType returnProcedureType()
this
is a ProcedureType
, return this
. Otherwise, return
null
.
public RealType returnRealType()
this
is a RealType
,
return this
. Otherwise, return null
.
public RecordType returnRecordType()
this
is a RecordType
return this
. Otherwise, return null
.
public RefType returnRefType()
this
is a RefType
, return
this
. Otherwise, return null
.
public SignedIntegerType returnSignedIntegerType()
this
is a SignedIntegerType
, return this
. Otherwise, return
null
.
public UnionType returnUnionType()
this
is a UnionType
return this
. Otherwise, return null
.
public UnsignedIntegerType returnUnsignedIntegerType()
this
is a UnsignedIntegerType
, return this
. Otherwise,
return null
.
public VoidType returnVoidType()
this
is a VoidType
,
return this
. Otherwise, return null
.
public boolean isArrayType()
public boolean isAllocArrayType()
public boolean isFixedArrayType()
public boolean isClassType()
public boolean isFloatType()
public boolean isRefType()
public boolean isCharacterType()
public boolean isIncompleteType()
public boolean isPointerType()
public boolean isVoidType()
public boolean isAggregateType()
public boolean isUnionType()
public boolean isCompositeType()
public boolean isRealType()
public boolean isIntegerType()
public boolean isEnumerationType()
public boolean isComplexType()
public boolean isAtomicType()
public boolean isBooleanType()
public boolean isFortranCharType()
public boolean isNumericType()
public boolean isNamedType()
public boolean isProcedureType()
public boolean isSigned()
public Type getSignedType()
public long numberOfElements()
public boolean isAttributeSet(RefAttr attribute)
RefType
public 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 Node
Predicate
public void visit(TypePredicate p)
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.
TypePredicate
public Type getCoreType()
We define
The remaining two special case type nodes are simply irrelevant for my current application, so I haven't bothered to determine what happens to them. This nondecision may be changed as appropriate in the future. Null implies the absense of a type, so no core type would exist.
This method instance defines the behavior for all core types, which is to simply return the current type. This method needs to be overridden in the select special case type classes.
getCoreType
in class Node
Node.getType()
,
RefType
public Type getType()
Node
getType
in class Node
public Type registerType()
public Type getCompleteType()
IncompleteType
public Type getNonAttributeType()
RefType
public Type getNonConstType()
RefType.getNonConstType()
public abstract boolean equivalent(Type t)
struct x { int a; int b;}is equivalent to
struct x { int c; int d;}
protected Type getEquivalentType()
public Type getPointedTo()
public final Type getPointedToCore()
getCoreType().getPointedTo().getCoreType()
public int getRank()
public boolean isConst()
public boolean isVolatile()
public boolean isRestricted()
public abstract long memorySize(Machine machine)
machine
- is the machine-specific data machinepublic long elementSize(Machine machine)
memorySize()
.
machine
- is the machine-specific data machinepublic final int memorySizeAsInt(Machine machine)
machine
- is the machine-specific data machine
public abstract int alignment(Machine machine)
public int precedence()
public java.lang.String mapTypeToCString()
public java.lang.String mapTypeToF77String()
public static void cleanup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |