WrapperTypeSpec

public final class WrapperTypeSpec extends TypeSpec

A simple wrapper around another type. Used to build a type (possibly empty) that can later be created or modified by anyone sharing this wrapper, so that everyone sharing the wrapper will see the modification. In principle all wrappers may be removed when all type choices are done, i.e. after type-checking.

Fields

wrappedType

public TypeSpec wrappedType

The type inside the wrapper.

Constructors

WrapperTypeSpec

public WrapperTypeSpec(TypeSpec wrappedType)

Create a new wrapper type around “wrappedType”.

Methods

acceptsMultiDirDimension

public boolean acceptsMultiDirDimension()

addMultiDirDimension

protected WrapperTypeSpec addMultiDirDimension(ArrayDim dimension)

addRefDiffTypeSpec

protected void addRefDiffTypeSpec(SymbolTable symbolTable, SymbolTable srcSymbolTable)

addWith

public WrapperTypeSpec addWith(WrapperTypeSpec type)

baseTypeName

public String baseTypeName()

baseTypeSpec

public WrapperTypeSpec baseTypeSpec(boolean stopOnPointer)

buildConstantOne

public Tree buildConstantOne()

buildConstantZero

public Tree buildConstantZero()

buildTypeNameForProcName

public String buildTypeNameForProcName(TapList<Tree> toArraySize, SymbolTable symbolTable)
Returns

a String that represents the present WrapperTypeSpec, to be used in a procedure name that is specialized for this type.

Examples: INTEGER4, INTEGER8, REAL4, REAL8, REAL8ARRAY,… “toArraySize” must contain upon input a Tree which is the size of this WrapperTypeSpec if it is an array, null otherwise. Upon output this size is modified when this typeSpec is a string: it is multiplied by the number of characters.

canMatchPointerTo

public boolean canMatchPointerTo(WrapperTypeSpec destTypeSpec)
Returns

true if the 2 types are similar enough so that a pointer to “this” may point to a “destTypeSpec”.

canReceiveVectorialDim

public static boolean canReceiveVectorialDim(WrapperTypeSpec typeSpec, boolean passedArray)
Returns

true if this type is deep/simple enough to receive the extra vectorial dimension. Example: REAL(:,:), REAL → true RECORD, REAL*, REAL(:,:)(:) → false.

checkArray

protected boolean checkArray()
Returns

true if this type is a wrapper around an array type. If this wrapper is free, fills it with an array type of free element type.

checkBoolean

protected boolean checkBoolean()
Returns

true if this type is a wrapper around boolean type. If this wrapper is free, fills it with boolean type.

checkNoneDimensionsOfNewSH

public WrapperTypeSpec checkNoneDimensionsOfNewSH(String hintNameInText, String hintNameInIdent, Tree hintTreeInCallSize, SymbolTable symbolTable, NewSymbolHolder symbolHolder)

checkNumeric

protected boolean checkNumeric()
Returns

true if this type is a wrapper around some numeric type. If this wrapper is free, fills it with a “generic” numeric type.

checkNumericInt

protected boolean checkNumericInt()
Returns

true if this type is a wrapper around integer type. If this wrapper is free, fills it with integer type.

checkPointer

protected boolean checkPointer()
Returns

true if this type is a wrapper around a pointer type. If this wrapper is free, fills it with a pointer to free type.

checkRecord

protected boolean checkRecord()
Returns

true if this type is a wrapper around a composite type. If this wrapper is free, fills it with a composite RECORD type.

checkTypeSpecValidity

protected boolean checkTypeSpecValidity(TapList<TypeSpec> dejaVu)

cloneAsUndefinedNumeric

protected TypeSpec cloneAsUndefinedNumeric(boolean undefined)

combineWith

public WrapperTypeSpec combineWith(WrapperTypeSpec newTypeSpec, SymbolTable symbolTable)

computeSize

protected int computeSize()

conformingTypeSpec

protected WrapperTypeSpec conformingTypeSpec(WrapperTypeSpec type1, WrapperTypeSpec type2)

Expand this type into an array type that makes it conform with array types type1 (and type2 if non-null).

containsAPointer

public boolean containsAPointer()

containsMetaType

protected boolean containsMetaType(TapList<TypeSpec> dejaVu)

containsUnknownDimension

public boolean containsUnknownDimension()

copy

public TypeSpec copy()

copyStopOnComposite

public TypeSpec copyStopOnComposite(Unit publishedUnit)

cumulActiveParts

public void cumulActiveParts(TapList diffInfos, SymbolTable symbolTable)

differentiateTypeSpecMemo

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

doUpdateAfterImports

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

dump

public void dump()

easilyDeclared

public boolean easilyDeclared()
Returns

true if a declaration of a variable of this WrapperTypeSpec is cheap and easy Example: a primitive, a pointer, a void Counter example: an array of dynamic size (⇒ requiring a decl with ISIZEOF).

elementType

public WrapperTypeSpec elementType()

equalsDiffTypeSpecAndTypeSpec

public WrapperTypeSpec equalsDiffTypeSpecAndTypeSpec()

generateTree

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

getAllDimensions

public TapList<ArrayDim> getAllDimensions()

hasAnArrayDimension

protected static boolean hasAnArrayDimension(WrapperTypeSpec typeSpec)

hasPointerOnTop

public static boolean hasPointerOnTop(WrapperTypeSpec typeSpec)
Returns

true if contains a Pointer level before reaching an array or record type.

hasUndefinedSize

protected boolean hasUndefinedSize()

intToReal

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

When the given origType is non-differentiable (e.g. integer), returns a copied WrapperTypeSpec with integers replaced with reals. Otherwise returns the same origType.

isAnIOTypeSpec

public boolean isAnIOTypeSpec(SymbolTable symbolTable)

isArray

public boolean isArray()

isCharacter

public boolean isCharacter()

isDifferentiated

public boolean isDifferentiated(TapList<TypeSpec> dejaVu)

isFree

public static boolean isFree(WrapperTypeSpec typeSpec)

isFunction

public boolean isFunction()

isFunctionOrPointerToFunction

public static boolean isFunctionOrPointerToFunction(WrapperTypeSpec typeSpec)

isMetaType

protected boolean isMetaType()

isNamedType

public boolean isNamedType()

isNullOrVoid

public static boolean isNullOrVoid(WrapperTypeSpec typeSpec)

isPointer

public boolean isPointer()

isPointerOrArrayOfPointer

public static boolean isPointerOrArrayOfPointer(WrapperTypeSpec typeSpec)

isPrimitiveTypeCharacter

public boolean isPrimitiveTypeCharacter()

isPrimitiveTypeFloat

protected boolean isPrimitiveTypeFloat()

isPrimitiveTypeInteger

protected boolean isPrimitiveTypeInteger()

isScalar

public boolean isScalar()

isString

public boolean isString()

isTarget

public boolean isTarget()

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()

peelPointer

public TypeSpec peelPointer()

pointerToArrayTypeSpec

protected WrapperTypeSpec pointerToArrayTypeSpec()

preciseDimensions

public static WrapperTypeSpec preciseDimensions(WrapperTypeSpec mainType, WrapperTypeSpec complementType, TapList<TapPair<TypeSpec, TypeSpec>> dejaVu, SymbolTable symbolTable)
Returns

a WrapperTypeSpec built from “mainType” by replacing wherever possible imprecise dimensions by fixed dimensions found in the matching complementType. We assume that mainType and complementType have similar shapes except possibly for dimensions. The returned result may share parts with mainType, or may even be strictly eq to it.

precisionSize

public int precisionSize()

realToComplex

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

scalarTypeSpec

public WrapperTypeSpec scalarTypeSpec(boolean stopOnPointer, SymbolTable symbolTable)

Seeks into this type the deepest array element type.

setHasUndefinedSize

protected void setHasUndefinedSize(boolean val)

setWrappedType

public void setWrappedType(TypeSpec type)

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()

weakenForInference

protected TypeSpec weakenForInference(int comparison)

wrappedType

public TypeSpec wrappedType()