|
|||||||||
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 scale.clef.type.FixedArrayType
public class FixedArrayType
This class represents array types with fixed bounds.
$Id: FixedArrayType.java,v 1.53 2007-03-21 13:31:56 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
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.
It is not necessary for the upper-bound of the outer-most bounds to be known at compile time for this value is not needed to calculate offsets into the array.
Method Summary | |
---|---|
ArrayType |
addIndex(Bound index)
Return a new array type with the additional dimension. |
static void |
cleanup()
Remove static lists of types. |
ArrayType |
copy(Type elementType)
Creates an array type with the same dimensions but a different element type. |
static FixedArrayType |
create(long minIndex,
long maxIndex,
Type elementType)
Re-use an existing instance of a one-dimensional fixed array type. |
static FixedArrayType |
create(Vector<Bound> indicies,
Type elementType)
Re-use an existing instance of a particular fixed array type. |
boolean |
equivalent(Type t)
Return true if the types are equivalent. |
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. |
Node |
getChild(int i)
Return the specified AST child of this node. |
Bound |
getFirstIndex()
Return the type of the first index of the array. |
Bound |
getIndex(int i)
Return the specified array index. |
protected Vector<Bound> |
getIndexes()
Return a new vector of the array indexes. |
int |
getRank()
Return the rank of the type. |
static java.util.Enumeration<FixedArrayType> |
getTypes()
Return an enumeration of all the different types. |
boolean |
isBounded()
Return true if the array has definite bounds. |
boolean |
isFixedArrayType()
Return true if type represents an array whose dimensions are known at compile time. |
boolean |
isSizeKnown()
Return true if the size of the array is known. |
long |
numberOfElements()
Calculate how many elements are in the array. |
int |
numChildren()
Return the number of AST children of this node. |
FixedArrayType |
returnFixedArrayType()
Return if this is a FixedArrayType , 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.ArrayType |
---|
alignment, elementSize, getArraySubtype, getElementType, isArrayType, memorySize, precedence, returnArrayType |
Methods inherited from class scale.clef.type.CompositeType |
---|
isCompositeType, returnCompositeType |
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 |
Method Detail |
---|
public static FixedArrayType create(Vector<Bound> indicies, Type elementType)
indicies
- a vector of Bound
entries - one for
each dimension.elementType
- the type of elements in the array.public static FixedArrayType create(long minIndex, long maxIndex, Type elementType)
minIndex > maxIndex
, the range is
considered to be unbounded.
minIndex
- is the lower bound on the arraymaxIndex
- is the upper bound on the arrayelementType
- the type of elements in the array.public ArrayType copy(Type elementType)
copy
in class ArrayType
elementType
- the new array element type
protected final Vector<Bound> getIndexes()
getIndexes
in class ArrayType
public final Bound getIndex(int i)
getIndex
in class ArrayType
public final int getRank()
getRank
in class ArrayType
public final boolean isSizeKnown()
isSizeKnown
in class ArrayType
public final long numberOfElements()
numberOfElements
in class ArrayType
public final Bound getFirstIndex()
getFirstIndex
in class ArrayType
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 ArrayType
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 ArrayType
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 boolean isBounded()
isBounded
in class ArrayType
public Type getArraySubtype(int n)
null
if there are too many
subscripts.
getArraySubtype
in class ArrayType
public static java.util.Enumeration<FixedArrayType> getTypes()
public static void cleanup()
public final ArrayType addIndex(Bound index)
public boolean isFixedArrayType()
isFixedArrayType
in class Type
public final FixedArrayType returnFixedArrayType()
Type
this
is a FixedArrayType
, return this
. Otherwise, return
null
.
returnFixedArrayType
in class Type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |