|
|||||||||
| 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.CompositeType
scale.clef.type.ArrayType
scale.clef.type.AllocArrayType
public class AllocArrayType
This class represents array types with bounds that are determined at run time.
$Id: AllocArrayType.java,v 1.3 2007-06-15 18:21:56 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Allocatable arrays are allocated at run time.
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.
| 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 AllocArrayType |
create(int rank,
Type struct,
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 vector of the array indexes. |
int |
getRank()
Return the rank of the type. |
Type |
getStruct()
Return the structure used to represent the array at run time. |
static java.util.Enumeration<AllocArrayType> |
getTypes()
Return an enumeration of all the different types. |
boolean |
isAllocArrayType()
Return true. |
boolean |
isBounded()
Return true if the array has definite bounds. |
boolean |
isSizeKnown()
Return false - the size is not known at compile time. |
long |
numberOfElements()
Calculate how many elements are in the array. |
int |
numChildren()
Return the number of AST children of this node. |
AllocArrayType |
returnAllocArrayType()
Return if this is a AllocArrayType, 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 AllocArrayType create(int rank,
Type struct,
Type elementType)
rank - specifies the number of array dimensionsstruct - specifies the structure used to represent array at run time.elementType - the type of elements in the array.public ArrayType copy(Type elementType)
copy in class ArrayTypeelementType - the new array element type
protected final Vector<Bound> getIndexes()
getIndexes in class ArrayTypepublic final Bound getIndex(int i)
getIndex in class ArrayTypepublic final int getRank()
getRank in class ArrayTypepublic final Type getStruct()
public final boolean isSizeKnown()
isSizeKnown in class ArrayTypepublic final AllocArrayType returnAllocArrayType()
Typethis is a AllocArrayType, return this. Otherwise, return
null.
returnAllocArrayType in class Typepublic final boolean isAllocArrayType()
isAllocArrayType in class Typepublic final long numberOfElements()
numberOfElements in class ArrayTypepublic final Bound getFirstIndex()
getFirstIndex in class ArrayTypepublic 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 ArrayTypePredicatepublic 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 ArrayTypeTypePredicatepublic Node getChild(int i)
getChild in class Nodepublic int numChildren()
numChildren in class Nodepublic boolean equivalent(Type t)
equivalent in class Typepublic boolean isBounded()
isBounded in class ArrayTypepublic Type getArraySubtype(int n)
null if there are too many
subscripts.
getArraySubtype in class ArrayTypepublic static java.util.Enumeration<AllocArrayType> getTypes()
public static void cleanup()
public final ArrayType addIndex(Bound index)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||