|
|||||||||
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 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 declarationpublic static RefType create(Type refTo, RefAttr attribute)
refTo
- the actual typeattribute
- an attribute of the typepublic static RefType createAligned(Type refTo, int alignment)
refTo
- the actual typealignment
- is the user-specified alignmentpublic Type getNonConstType()
getNonConstType
in class Type
RefType
public Type registerType()
registerType
in class Type
public final Type getRefTo()
public final void setRefTo(Type refTo)
public boolean isAttributeSet(RefAttr attribute)
isAttributeSet
in class Type
RefType
public final RefType returnRefType()
Type
this
is a RefType
, return
this
. Otherwise, return null
.
returnRefType
in class Type
public RefAttr getAttribute()
public boolean isConst()
isConst
in class Type
public boolean isVolatile()
isVolatile
in class Type
public boolean isRestricted()
isRestricted
in class Type
public Declaration getDecl()
getDecl
in class Node
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 Type
Predicate
public 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 Type
TypePredicate
public Node getChild(int i)
getChild
in class Node
public int numChildren()
numChildren
in class Node
public Type getCoreType()
getCoreType
in class Type
Type.getCoreType()
public int getRank()
getRank
in class Type
public boolean isArrayType()
isArrayType
in class Type
public boolean isPointerType()
isPointerType
in class Type
public boolean isVoidType()
isVoidType
in class Type
public boolean isAggregateType()
isAggregateType
in class Type
public boolean isUnionType()
isUnionType
in class Type
public boolean isCompositeType()
isCompositeType
in class Type
public boolean isRealType()
isRealType
in class Type
public boolean isIntegerType()
isIntegerType
in class Type
public boolean isComplexType()
isComplexType
in class Type
public boolean isAtomicType()
isAtomicType
in class Type
public boolean isNumericType()
isNumericType
in class Type
public final boolean isRefType()
isRefType
in class Type
public boolean isNamedType()
isNamedType
in class Type
public boolean isProcedureType()
isProcedureType
in class Type
public boolean isSigned()
isSigned
in class Type
public Type getSignedType()
getSignedType
in class Type
public long memorySize(Machine machine)
memorySize
in class Type
machine
- is the machine-specific data machinepublic long elementSize(Machine machine)
memorySize()
.
elementSize
in class Type
machine
- is the machine-specific data machinepublic int alignment(Machine machine)
alignment
in class Type
public 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 Type
protected Type getEquivalentType()
getEquivalentType
in class Type
public static java.util.Enumeration<RefType> getTypes()
public java.lang.String getDisplayLabel()
getDisplayLabel
in interface DisplayNode
getDisplayLabel
in class Type
public java.lang.String toString()
toString
in class Type
public java.lang.String toStringShort()
toStringShort
in class Type
public int precedence()
precedence
in class Type
public static void cleanup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |