|
|||||||||
| 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.RefType
public class RefType
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.76 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.
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
| Method Summary | |
|---|---|
int |
alignment(Machine machine)
Calculate the alignment needed for this data type. |
static void |
cleanup()
Remove static lists of types. |
static RefType |
create(Type refTo,
Declaration myDecl)
Re-use an existing instance of a particular reference type. |
static RefType |
create(Type refTo,
RefAttr attribute)
Re-use an existing instance of a particular reference type. |
static RefType |
createAligned(Type refTo,
int alignment)
Re-use an existing instance of a particular reference 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. |
RefAttr |
getAttribute()
Return the attribute of this type reference. |
Node |
getChild(int i)
Return the specified AST child of this node. |
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 |
getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. |
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 |
getRefTo()
Return the type referenced. |
Type |
getSignedType()
Return the equivalent signed type. |
static java.util.Enumeration<RefType> |
getTypes()
Return an enumeration of all the different types. |
boolean |
hasDecl()
Return true if this instance references a Declaration. |
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 |
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 |
isRefType()
Return true if type represents a reference type. |
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. |
RefType |
returnRefType()
Return if this is a RefType, return
this. |
void |
setRefTo(Type refTo)
Set the type referenced. |
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. |
| Methods inherited from class scale.clef.Node |
|---|
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 |
| Method Detail |
|---|
public static RefType create(Type refTo,
Declaration myDecl)
refTo - the actual typemyDecl - null or a TypeName or TypeDecl declaration
public static RefType create(Type refTo,
RefAttr attribute)
refTo - the actual typeattribute - an attribute of the type
public static RefType createAligned(Type refTo,
int alignment)
refTo - the actual typealignment - is the user-specified alignmentpublic Type getNonConstType()
getNonConstType in class TypeRefTypepublic Type registerType()
registerType in class Typepublic final Type getRefTo()
public final void setRefTo(Type refTo)
public boolean isAttributeSet(RefAttr attribute)
isAttributeSet in class TypeRefTypepublic final RefType returnRefType()
Typethis is a RefType, return
this. Otherwise, return null.
returnRefType in class Typepublic RefAttr getAttribute()
public boolean isConst()
isConst in class Typepublic boolean isVolatile()
isVolatile in class Typepublic boolean isRestricted()
isRestricted in class Typepublic Declaration getDecl()
getDecl in class Nodepublic 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 TypePredicatepublic 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 TypeTypePredicatepublic Node getChild(int i)
getChild in class Nodepublic int numChildren()
numChildren in class Nodepublic Type getCoreType()
getCoreType in class TypeType.getCoreType()public int getRank()
getRank in class Typepublic boolean isArrayType()
isArrayType in class Typepublic boolean isPointerType()
isPointerType in class Typepublic boolean isVoidType()
isVoidType in class Typepublic boolean isAggregateType()
isAggregateType in class Typepublic boolean isUnionType()
isUnionType in class Typepublic boolean isCompositeType()
isCompositeType in class Typepublic boolean isRealType()
isRealType in class Typepublic boolean isIntegerType()
isIntegerType in class Typepublic boolean isComplexType()
isComplexType in class Typepublic boolean isAtomicType()
isAtomicType in class Typepublic boolean isNumericType()
isNumericType in class Typepublic final boolean isRefType()
isRefType in class Typepublic boolean isNamedType()
isNamedType in class Typepublic boolean isProcedureType()
isProcedureType in class Typepublic boolean isSigned()
isSigned in class Typepublic Type getSignedType()
getSignedType in class Typepublic long memorySize(Machine machine)
memorySize in class Typemachine - is the machine-specific data machinepublic long elementSize(Machine machine)
memorySize().
elementSize in class Typemachine - is the machine-specific data machinepublic int alignment(Machine machine)
alignment in class Typepublic final boolean hasDecl()
Declaration. Note that
hasDecl() may return false even when
getDecl() returns a non-null result.
public boolean equivalent(Type t)
typedef int X;
then types X and int are equivalent.
equivalent in class Typeprotected Type getEquivalentType()
getEquivalentType in class Typepublic static java.util.Enumeration<RefType> getTypes()
public java.lang.String getDisplayLabel()
getDisplayLabel in interface DisplayNodegetDisplayLabel in class Typepublic java.lang.String toString()
toString in class Typepublic java.lang.String toStringShort()
toStringShort in class Typepublic int precedence()
precedence in class Typepublic static void cleanup()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||