|
|||||||||
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.AtomicType scale.clef.type.PointerType
public class PointerType
The PointerType represents the type address of some other type.
$Id: PointerType.java,v 1.58 2007-08-27 18:13:32 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Constructor Summary | |
---|---|
protected |
PointerType(Type pointedTo)
|
Method Summary | |
---|---|
static int |
addressableMemorySize(Machine machine)
Return the number of bytes required to represent this type. |
int |
bitSize()
Return the number of bits required to represent the type. |
static void |
cleanup()
Remove static lists of types. |
static PointerType |
create(Type pointedTo)
Re-use an existing instance of a particular pointer type. |
boolean |
equivalent(Type t)
Return true if the types are equivalent. |
Node |
getChild(int i)
Return the specified AST child of this node. |
static int |
getMinBitSize()
Specify the size of a pointer in bits. |
Type |
getPointedTo()
Return the type of the thing pointed to. |
static java.util.Enumeration<PointerType> |
getTypes()
Return an enumeration of all the different types. |
boolean |
isPointerType()
Return true if type represents an address. |
java.lang.String |
mapTypeToCString()
Map a type to a C string. |
long |
memorySize(Machine machine)
Calculate how many addressable memory units are needed to represent the type. |
int |
numChildren()
Return the number of AST children of this node. |
static int |
pAlignment(Machine machine)
Calculate the alignment needed for this data type. |
PointerType |
returnPointerType()
Return if this is a PointerType
return this . |
static void |
setMinBitSize(int bitSize)
Specify the size of a pointer in bits. |
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.type.AtomicType |
---|
alignment, isAtomicType, returnAtomicType |
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 |
Constructor Detail |
---|
protected PointerType(Type pointedTo)
Method Detail |
---|
public static void setMinBitSize(int bitSize)
public static int getMinBitSize()
public static PointerType create(Type pointedTo)
pointedTo
- the type pointed topublic final Type getPointedTo()
Type
getPointedTo
in class Type
public int bitSize()
AtomicType
bitSize
in class AtomicType
public static int addressableMemorySize(Machine machine)
public boolean isPointerType()
isPointerType
in class Type
public final PointerType returnPointerType()
Type
this
is a PointerType
return this
. Otherwise, return null
.
returnPointerType
in class Type
public java.lang.String toString()
toString
in class Type
public java.lang.String toStringShort()
toStringShort
in class Type
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 AtomicType
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 AtomicType
TypePredicate
public Node getChild(int i)
getChild
in class Node
public int numChildren()
numChildren
in class Node
public boolean equivalent(Type t)
equivalent
in class Type
public static java.util.Enumeration<PointerType> getTypes()
public long memorySize(Machine machine)
memorySize
in class AtomicType
machine
- is the machine-specific data machine
public static int pAlignment(Machine machine)
public java.lang.String mapTypeToCString()
mapTypeToCString
in class Type
public static void cleanup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |