ArrayDim

public class ArrayDim

One dimension of an ArrayTypeSpec. Holds the original Tree, and the computed lower and upper dimensions.

Fields

lower

protected Integer lower

Array lower bound.

overEstimate

public String overEstimate

String that may describe a possible overestimate of this dimension’s length (can be useful when unDeclarableLength is true)

rankInRef

protected int rankInRef

The rank of the reference dimension inside the reference array. -1 for unknown, 0 for unique dimension, else 1 for 1st child, etc.

refArrayTree

protected Tree refArrayTree

A “reference” array variable whose rankInRef’th dimension size determines this dimension size.

refNDims

protected int refNDims

The number of dimensions of the reference array.

refQuality

protected int refQuality

Prefer sizes that are given as an immediate integer, then as an integer variable, then declared as “:” but certainly allocated, then as a last resort declared as allocatable…

treeForDeclaration

public Tree treeForDeclaration

Special case: special dimension Tree to be used in declaration only

unDeclarableLength

public boolean unDeclarableLength

true when we cannot declare this dimension because its size is “dynamic”, so that actual refs to this dimension must use an explicit arrayTriplet instead of just “:”

upper

protected Integer upper

Array lower bound.

Constructors

ArrayDim

public ArrayDim(Tree dimensionTree, Integer lower, Integer upper, Tree refArrayTree, int rankInRef, int refNDims, int refQuality)

Methods

copy

protected ArrayDim copy()

Copy this ArrayDim.

Returns

a copy, with a copy of the array tree dimension.

detectUnDeclarableLength

public void detectUnDeclarableLength(SymbolTable symbolTable)

Mark this dimension (which evaluates well in “symbolTable”) when it cannot be evaluated correctly in the (publicST) SymbolTable in which it must be used for an array declaration

dump

public void dump()

Prints in detail the contents of this ArrayDim, onto TapEnv.curOutputStream().

equalLength

protected boolean equalLength(ArrayDim otherDim, int comparison)

erasePrivateInfo

protected void erasePrivateInfo(Unit publishedUnit)

Erase “tree” if it uses local symbols of publishedUnit:

Parameters
  • publishedUnit – Unit.

fullArrayTriplet

public boolean fullArrayTriplet(Tree tree)

getSize

public Tree getSize()
Returns

a tree representing the array size.

isNone

protected boolean isNone()
Returns

true if dimension is “none”.

isNullOrNoneOrStar

public boolean isNullOrNoneOrStar()

isSufficientlyDefined

protected boolean isSufficientlyDefined()

isUnknown

protected boolean isUnknown()
Returns

true if unknown dimension.

lowerTree

protected Tree lowerTree()

preciseDimension

protected static ArrayDim preciseDimension(ArrayDim mainDim, ArrayDim complementDim, SymbolTable symbolTable)

setSize

protected void setSize(Tree sizeTree)

Modifies the upper bound of this ArrayDim so that its total size becomes equal to “sizeTree”.

setSizeForDeclaration

public void setSizeForDeclaration(Tree sizeTree)

setTree

protected void setTree(Tree tree)

Set the array dimension tree.

Parameters
  • tree – the array dimension.

showType

protected String showType()

size

public int size()
Returns

intger array size using lower and upper bounds.

testConformingAndChoose

protected static ArrayDim testConformingAndChoose(ArrayDim dim1, ArrayDim dim2)
Returns

When dim1 and dim2 conform, the one which is best suited to provide the size of this dimension. Otherwise return null.

toString

public String toString()

tree

public Tree tree()
Returns

the array dimension tree.

updateImportedDim

protected void updateImportedDim(SymbolTable symbolTable)

upperTree

protected Tree upperTree()

weakenForInference

protected ArrayDim weakenForInference()