ArrayTypeSpec

public final class ArrayTypeSpec extends TypeSpec

An array type.

Constructors

ArrayTypeSpec

public ArrayTypeSpec(WrapperTypeSpec elementType, ArrayDim[] dimensions)

Create an array type on “elementType” with “dimensions”.

Methods

acceptsMultiDirDimension

public boolean acceptsMultiDirDimension()

addDiffTypeSpec

protected void addDiffTypeSpec(SymbolTable symbolTable, SymbolTable srcSymbolTable)

addMultiDirDimension

protected TypeSpec addMultiDirDimension(ArrayDim dimension)

addUsedSymbolsInType

public void addUsedSymbolsInType(TapList<SymbolDecl> toDependsOn, SymbolTable symbolTable)

baseTypeName

protected String baseTypeName()

baseTypeSpec

public WrapperTypeSpec baseTypeSpec(boolean stopOnPointer)

buildConstantOne

public Tree buildConstantOne()

buildConstantZero

public Tree buildConstantZero()

checkDimensions

public void checkDimensions(Tree arrayAccessTree, SymbolTable symbolTable)

Tries to improve dimension info contained in this ArrayTypeSpec by incorporating info from the given arrayAccessTree.

checkNoneDimensions

public ArrayDim[] checkNoneDimensions(ArrayDim[] origDimensions, boolean localDecl, boolean addMultiDirDim, ArrayDim multiDirDimensionMax, String hintArrayNameInText, String hintArrayNameInIdent, Tree hintTreeSize, Tree nameTree, SymbolTable targetSymbolTable, NewSymbolHolder symbolHolder)

Check the given array of array-dimensions “origDimensions” for problematic cases. When necessary, builds and returns a new array of array-dimensions that is better for the symbols that use these dimensions and for their declaration instruction. Also returns a new array of dimensions when there is a vector dimension appended. Modification cases: – orig dimension was “*” and we are targetting F90 so it must become “:” – orig dimension was unspecified and we are building the type of a local var. – orig dimension is known only at run-time so we can’t use it for declaration.

Returns

the new array of array-dimensions, or none if the given array is fine.

checkTypeSpecValidity

protected boolean checkTypeSpecValidity(TapList<TypeSpec> dejaVu)

collectUsedTrees

public void collectUsedTrees(TapList<Tree> toUsedTrees, TapList<TypeSpec> toDejaVu)

combineArrayWith

protected TypeSpec combineArrayWith(TypeSpec newActualTypeSpec)

computeSize

protected int computeSize()

containsAPointer

public boolean containsAPointer()

containsMetaType

protected boolean containsMetaType(TapList<TypeSpec> dejaVu)

containsUndefinedType

public boolean containsUndefinedType()

containsUnknownDimension

public boolean containsUnknownDimension()

copy

public TypeSpec copy()

copyStopOnComposite

public TypeSpec copyStopOnComposite(Unit publishedUnit)

createDimensions

public static ArrayDim[] createDimensions(TapList<ArrayDim> dimsList)
Returns

an array of dimensions from “dimsList”.

cumulActiveParts

protected void cumulActiveParts(TapList diffInfos, SymbolTable symbolTable)

differentiateTypeSpec

public WrapperTypeSpec differentiateTypeSpec(SymbolTable symbolTable, SymbolTable srcSymbolTable, int diffUnitSort, String fSuffix, boolean localDecl, boolean multiDirMode, ArrayDim multiDirDimensionMax, String hintArrayNameInText, String hintArrayNameInIdent, Tree hintArrayNameTree, Tree nameTree)

dimensions

public ArrayDim[] dimensions()
Returns

The dimensions of the array, in the C-like order i.e. slow dimensions first.

doUpdateAfterImports

public void doUpdateAfterImports(SymbolTable symbolTable, TapList<TypeSpec> dejaVu)

dump

public void dump()

elementType

public WrapperTypeSpec elementType()

generateTree

public Tree generateTree(SymbolTable symbolTable, TapList<SymbolDecl> dependsOn, TapList<SymbolDecl> shortNames, boolean useShortNames, TapList<TypeSpec> dejaVu)

getAllDimensions

public TapList<ArrayDim> getAllDimensions()

intToReal

public TypeSpec intToReal(TapList<TapPair<TypeSpec, TypeSpec>> dejaVu, SymbolTable symbolTable)

isArray

public boolean isArray()

isCharacter

public boolean isCharacter()

isDifferentiated

public boolean isDifferentiated(TapList<TypeSpec> dejaVu)

isString

public boolean isString()

isTarget

public boolean isTarget()

linearizeAllDim

protected ArrayDim linearizeAllDim()

Transforms array[n1:n2][p1:p2] into array[(n2-n1+1)*(p2-p1+1)].

localize

protected TypeSpec localize(TapList<TapTriplet<TypeSpec, TypeSpec, Boolean>> toAlreadyCopied, ToBool containsMeta)

modifiedBaseTypeSpec

public WrapperTypeSpec modifiedBaseTypeSpec()

needsADiffType

public boolean needsADiffType(TapList<TypeSpec> dejaVu)

nestedLevelType

public TypeSpec nestedLevelType()

preciseDimensions

public TypeSpec preciseDimensions(TypeSpec complementType, TapList<TapPair<TypeSpec, TypeSpec>> dejaVu, SymbolTable symbolTable)

preciseSizeReferences

public void preciseSizeReferences(Tree refArrayTree, int newRefQuality)

Adds “size reference” info into this array type’s ArrayDim. For each dimension’s ArrayDim, inserts the info (if not already present with a better quality) that this dimension’s size is the size of the corresponding dimension of variable “referenceName”.

precisionSize

public int precisionSize()

realToComplex

protected TypeSpec realToComplex(TapList<TapPair<TypeSpec, TypeSpec>> dejaVu, WrapperTypeSpec complexTypeSpec)

setDimensions

public void setDimensions(ArrayDim[] dimensions)

Set the dimensions of the array.

Parameters
  • dimensions – The dimensions of the array, in the C-like order i.e. slow dimensions first.

setElementType

public void setElementType(WrapperTypeSpec elementType)

setWrappedType

public void setWrappedType(TypeSpec type)

showDimensions

public String showDimensions()

showType

public String showType()

testComparesWith

protected boolean testComparesWith(TypeSpec other, int comparison, TypeSpec toThis, TypeSpec toOther, TapList<TapPair<TypeSpec, TypeSpec>> dejaVu)

toString

public String toString()

totalArrayLength

public static int totalArrayLength(TapList<ArrayDim> arrayDims)
Returns

-1 if length is statically unknown, e.g. ([3],[2:*]) returns -1.

weakenForInference

protected TypeSpec weakenForInference(int comparison)

wrappedType

public TypeSpec wrappedType()