|
|||||||||
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.CompositeType scale.clef.type.ArrayType
public abstract class ArrayType
The abstract class for all array types.
$Id: ArrayType.java,v 1.77 2007-03-21 13:31:55 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
All arrays have this type. Note, this is not an address type.
Regardless of whether the source language uses row major or column major array ordering, the dimensions represented by this type are always in row major (C style) ordering.
Constructor Summary | |
---|---|
ArrayType(Type elementType)
|
Method Summary | |
---|---|
int |
alignment(Machine machine)
Calculate the alignment needed for this data type. |
abstract ArrayType |
copy(Type elementType)
Creates an array type with the same dimensions but a different element type. |
long |
elementSize(Machine machine)
Return the number of addressable memory units that are needed to represent a single element of the array. |
Type |
getArraySubtype()
Return the type of a subscript expression with one subscript. |
abstract Type |
getArraySubtype(int n)
Return the type of a subscript expression with the specified number of subscripts or null if there are too many
subscripts. |
Type |
getElementType()
Return the type of the array elements. |
abstract Bound |
getFirstIndex()
Return the type of the first index of the array. |
abstract Bound |
getIndex(int i)
Return the specified array index. |
protected abstract Vector<Bound> |
getIndexes()
Return a vector of the array indexes. |
abstract int |
getRank()
Return the rank of the type. |
boolean |
isArrayType()
Return true if type represents an array. |
abstract boolean |
isBounded()
Return true if the array has definite bounds known at compile time. |
abstract boolean |
isSizeKnown()
Return true if the size of the array is known. |
long |
memorySize(Machine machine)
Calculate how many addressable memory units are needed to represent the type. |
abstract long |
numberOfElements()
Calculate how many elements are in the array. |
int |
precedence()
Return a precedence value for types. |
ArrayType |
returnArrayType()
Return if this is a ArrayType
return this . |
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 |
---|
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 ArrayType(Type elementType)
Method Detail |
---|
public abstract ArrayType copy(Type elementType)
elementType
- the new array element type
protected abstract Vector<Bound> getIndexes()
public abstract Bound getIndex(int i)
public abstract int getRank()
getRank
in class Type
public long elementSize(Machine machine)
elementSize
in class Type
machine
- is the machine-specific data machinepublic long memorySize(Machine machine)
memorySize
in class Type
machine
- is the machine-specific data machine
public abstract boolean isSizeKnown()
public abstract long numberOfElements()
numberOfElements
in class Type
public abstract Bound getFirstIndex()
public final Type getElementType()
public final ArrayType returnArrayType()
Type
this
is a ArrayType
return this
. Otherwise, return null
.
returnArrayType
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 CompositeType
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 CompositeType
TypePredicate
public abstract boolean isBounded()
public final boolean isArrayType()
isArrayType
in class Type
public Type getArraySubtype()
public abstract Type getArraySubtype(int n)
null
if there are too many
subscripts.
public final int alignment(Machine machine)
alignment
in class Type
public final int precedence()
precedence
in class Type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |