TypeSpec¶
-
public abstract class
TypeSpec
¶ Abstract class, parent of all classes that actually specify a type. All type classes derive from TypeSpec.
Fields¶
compare_debug_indent¶
-
protected static int
compare_debug_indent
¶ Current indentation in debug display of the progress of comparesWith() comparison.
diffTypeDeclSymbolHolder¶
-
public NewSymbolHolder
diffTypeDeclSymbolHolder
¶ When this TypeSpec is in fact a differentiated type, this field holds the NewSymbolHolder of the name of this differentiated type.
diffTypeSpec¶
-
public WrapperTypeSpec
diffTypeSpec
¶
Constructors¶
TypeSpec¶
-
protected
TypeSpec
(int kind)¶ Creation.
- Parameters
kind – The kind of this type, may be in strange cases UNKNOWNTYPE, ACTUALTYPE, METATYPE, WRAPPERTYPE, also still bizarre NAMEDTYPE but this may disappear, otherwise belonging to {VOIDTYPE, LABELTYPE, PRIMITIVETYPE, MODIFIEDTYPE, ENUMTYPE, POINTERTYPE, ARRAYTYPE, COMPOSITETYPE, FUNCTIONTYPE}.
Methods¶
acceptsMultiDirDimension¶
-
public boolean
acceptsMultiDirDimension
()¶ - Returns
true when the new dimension added by multiDirMode can apply to this typeSpec, instead of at some deeper level e.g. included in composite or pointer types.
addDeclaratorModifiers¶
addDiffTypeSpec¶
-
protected void
addDiffTypeSpec
(SymbolTable symbolTable, SymbolTable srcSymbolTable)¶ Only for association by address.
addTypeModifiers¶
addUsedSymbolsInType¶
-
public void
addUsedSymbolsInType
(TapList<SymbolDecl> dependsOn, SymbolTable symbolTable)¶ Augments the given (hatted) list dependsOn with the SymbolDecl’s of all symbols used in this type.
baseTypeName¶
baseTypeSpec¶
-
public WrapperTypeSpec
baseTypeSpec
(boolean stopOnPointer)¶ - Parameters
stopOnPointer – when false, will also go down into pointers destination type
- Returns
the base type found.
build¶
-
public static WrapperTypeSpec
build
(Tree typeTree, SymbolTable symbolTable, Instruction instruction, TapList<SymbolDecl> toTypeUsedSymbols, TapList<String> toSymbolDeclInfos, TapList<String> toSymbolDeclAccess, ToBool isPointer, WrapperTypeSpec currentBuiltTypeSpec)¶ Build a TypeSpec from a tree.
- Parameters
typeTree – tree representing a type.
symbolTable – current symbolTable.
instruction – Instruction containing the type definition.
toTypeUsedSymbols – types used in the definition.
toSymbolDeclInfos – type modifiers.
toSymbolDeclAccess – type access modifiers.
isPointer – pointer or not pointer.
currentBuiltTypeSpec – for recursive type definition.
- Returns
a typeSpec.
buildConstantOne¶
buildConstantZero¶
canCompare¶
-
protected static boolean
canCompare
(WrapperTypeSpec type1, WrapperTypeSpec type2)¶
checkTypeSpecValidity¶
cloneAsUndefinedNumeric¶
collectUsedTrees¶
combineWith¶
-
protected TypeSpec
combineWith
(TypeSpec newActualTypeSpec, SymbolTable symbolTable)¶ Combination of two TypeSpec’s. Combines, when possible, this current TypeSpec with a new one “newActualTypeSpec”. If the combination succeeds, returns the combined TypeSpec. Otherwise returns null. Warning, both this and newActualTypeSpec may be modified. Warning: source language dependent!!!!
comparesWith¶
-
public boolean
comparesWith
(TypeSpec other, int comparison, TypeSpec toThis, TypeSpec toOther, TapList<TapPair<TypeSpec, TypeSpec>> dejaVu)¶ Perform “comparison” of this type with an “other” type, with possible type inference by side-effect.
- Parameters
other – The other type, with respect to which comparison is made.
comparison – the comparison performed. See possible comparisons in the comments around showComparison() If comparison allows for type inference, then the types wrapped immediately around this and other should be provided in toThis and toOther, otherwise type inference will not be done at the top level of types.
toThis – the TypeSpec immediately containing this type. Useful only if type inference is requested, otherwise may be null.
toOther – the TypeSpec immediately containing the other type. Useful only if type inference is requested, otherwise may be null.
dejaVu – the list of type pairs already being compared as “this” vs. “other”, and being the destination of some pointer type. This classically avoids infinite loops in cycles of types.
- Returns
true if this type compares well according to “comparison” with the “other” type.
containsAPointer¶
-
public boolean
containsAPointer
()¶ - Returns
true if this type is a pointer or at least contains a pointer field.
containsMetaType¶
-
protected boolean
containsMetaType
(TapList<TypeSpec> dejaVu)¶ - Parameters
dejaVu – List of dejaVu sub-types, to avoid looping. Pass null at call.
- Returns
true when some component of this type is an unsolved TypeSpec, because it contains either a MetaTypeSpec or an unknown array (or pointer) dimension.
containsUnknownDimension¶
-
public boolean
containsUnknownDimension
()¶ - Returns
true when this type has at least one dimension which is not known explicitly.
copy¶
-
public TypeSpec
copy
()¶ - Returns
a copy of this type, copying recursively inside the nested types tree structure, but stopping copy (i.e. returning the same objects) for the fields of a CompositeTypeSpec, the sub-types of a FunctionTypeSpec, or for MetaTypeSpec, EnumTypeSpec, NamedTypeSpec, VoidTypeSpec.
copyStopOnComposite¶
-
public abstract TypeSpec
copyStopOnComposite
(Unit publishedUnit)¶ - Parameters
publishedUnit – when non-null, remove from this type all information that relates to local data of publishedUnit, i.e. that is not visible from outside publishedUnit
- Returns
a copy of this type, copying recursively inside the nested types tree structure, but stopping copy (i.e. returning the same objects) for (WrapperTypeSpec’s on) CompositeTypeSpec, the sub-types of a FunctionTypeSpec, or for MetaTypeSpec, EnumTypeSpec, NamedTypeSpec, VoidTypeSpec
createOrGetDiffTypeDeclSymbolHolder¶
-
protected void
createOrGetDiffTypeDeclSymbolHolder
(SymbolTable diffSymbolTable, WrapperTypeSpec diffTypeSpec, String fSuffix)¶ only for association By Address.
cumulActiveParts¶
-
protected void
cumulActiveParts
(TapList diffInfos, SymbolTable symbolTable)¶ Accumulates into this type and into its sub-types, the given information about which types parts (e.g. named types, record fields..) are used as active, which implies that they must have a differentiated counterpart in the differentiate type of this type.
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)¶ - Returns
the differentiated counterpart of this type, which is assumed differentiable. Returning null means that the differentiated counterpart is exactly the same as this type. The returned type is different from “this” either if the differentiated element type is different, or if dimensions must change, e.g. vector mode, or F90 using dimension “*” which must be replaced by “:” in the diff type.
dispatchModifiers¶
-
protected static int
dispatchModifiers
(Tree[] modifiersTrees, Tree modifiedTree, TapPair<Tree, ArrayDim[]> sizeAndDims, ToBool isPointer, TapList<String> toSymbolDeclInfos, TapList<String> toSymbolDeclAccess, TapList<SymbolDecl> toTypeUsedSymbols, Tree typeTree, Instruction instruction, SymbolTable symbolTable)¶ Dispatch modifiers: – “type size” modifiers are combined into one “sizeTypeModifier”, that will be stored eventually in the returned ModifiedTypeSpec – “signed” and “unsigned” modifiers are collected into int “typeSign” (default 0) which will be stored eventually in the returned ModifiedTypeSpec (similarly to “type size” modifiers) – “dimension” modifiers are collected into “dimensions” and used eventually to build an ArrayTypeSpec layer in the returned ModifiedTypeSpec – “pointer” modifiers sets boolean “isPointer”, that will be used eventually to add a pointer layer at the appropriate location in the SymbolDecl’s type. – “accessDecl(bind,…)” modifiers are directly attached to the Instruction.tree – “restrict”, “const”… modifiers are collected into “toSymbolDeclAccess” and will be stored eventually into the “subAccessInfo” of the enclosing TypeSpec or of the SymbolDecl – all other modifiers are collected into “toSymbolDeclInfos”, that will be stored eventually into the “extraInfo” of the SymbolDecl (but maybe they should all be treated like “const” etc ?)
doUpdateAfterImports¶
-
protected void
doUpdateAfterImports
(SymbolTable symbolTable, TapList<TypeSpec> dejaVu)¶ Utility for updateAfterImports(). Don’t use otherwise!
dump¶
-
public void
dump
()¶ Prints in detail the contents of this type, onto TapEnv.curOutputStream().
elementType¶
-
public WrapperTypeSpec
elementType
()¶ - Returns
the type of the elements of the deepest array type in this type.
equalsCompilDep¶
equalsCompilDepNeglectLengthes¶
-
public boolean
equalsCompilDepNeglectLengthes
(TypeSpec other)¶ - Returns
true if this type is equal to the other, in a laxist way that compares the number of dimensions but not their lengthes, and additionally accepts vectorial notation (i.e. array:this vs scalar:other), and in the “compile-dep” way regarding primitive type sizes.
equalsCompilIndep¶
equalsLiterally¶
equalsNeglectSizes¶
equalsNeglectSizesNeglectLengthes¶
-
public boolean
equalsNeglectSizesNeglectLengthes
(TypeSpec other)¶ - Returns
true if this type is equal to the other, in a laxist way that compares the number of dimensions but not their lengthes and additionally accepts vectorial notation (i.e. array:this vs scalar:other), and not caring about different type precision at the leaf primitive types.
findAlreadyCopiedType¶
findFunctionTypeSpecUnderTypeSpec¶
-
protected static FunctionTypeSpec
findFunctionTypeSpecUnderTypeSpec
(WrapperTypeSpec typeSpec)¶
findShortName¶
-
protected String
findShortName
(TapList<SymbolDecl> dependsOn, TapList<SymbolDecl> shortNames)¶ Utility for generateTree(): finds a short name for this type, if it exists.
generateDeclaratorTree¶
-
public static Tree
generateDeclaratorTree
(WrapperTypeSpec stoppingTypeSpec, TapList<SymbolDecl> declaredTypes, Tree declarator, WrapperTypeSpec typeSpec)¶ - Returns
a declarator tree built by wrapping declarator layers around the given declarator tree “declarator”, each added declarator layer corresponding to the successive nested type layers in “typeSpec”, but stopping when reaching the type layer “stoppingTypeSpec”.
generateTree¶
-
public Tree
generateTree
(SymbolTable symbolTable, TapList<SymbolDecl> dependsOn, TapList<SymbolDecl> shortNames, boolean useShortNames, TapList<TypeSpec> dejaVu)¶ Generate a Tree for this type.
- Parameters
symbolTable – The SymbolTable context where the generated Tree will appear.
dependsOn – ?used during findShortName()?
shortNames – The list of types that have a short name.
useShortNames – When true, if this type has a short name in “shortNames”, the generated Tree will simply use that name. Set it to false to avoid silly “typedef truc=truc ;”.
- Returns
A Tree that stands for this type.
getAllDimensions¶
getRenamedTypeDeclName¶
intToReal¶
-
public TypeSpec
intToReal
(TapList<TapPair<TypeSpec, TypeSpec>> dejaVu, SymbolTable symbolTable)¶ When this type is non-differentiable (e.g. integer), returns a copied type with integers replaced with reals. Otherwise returns the original type.
- Parameters
dejaVu – List of dejaVu sub-types, to avoid looping. Pass null at call.
isA¶
-
public static boolean
isA
(TypeSpec type, int kind)¶ - Parameters
kind – may be ACTUALTYPE, ARRAYTYPE, FUNCTIONTYPE, LABELTYPE MOFIFIEDTYPE, PRIMITIVETYPE, COMPOSITETYPE, POINTERTYPE, VOIDTYPE, METATYPE (defined in SymbolTableConstants).
- Returns
true when this TypeSpec is of the given kind “testKind” Skips over layers of WrapperTypeSpec’s.
isAnIOTypeSpec¶
-
protected boolean
isAnIOTypeSpec
(SymbolTable symbolTable)¶ - Returns
true when this type is the C predefined type FILE or IO_FILE.
isAugmentedDoubleBase¶
-
public boolean
isAugmentedDoubleBase
()¶ - Returns
true if the base of this type is the augmented type for overloading-based AD.
isDifferentiablePlainType¶
-
public boolean
isDifferentiablePlainType
()¶ - Returns
true if this type is a PRIMITIVETYPE, possibly wrapped in MODIFIEDTYPE’s, and its primitive type is differentiable.
isDifferentiableType¶
-
public static boolean
isDifferentiableType
(TypeSpec actualTypeSpec)¶ True if the given type is possibly differentiable i.e. contains some continuous component such as a float. This is weaker than isDifferentiated(), which checks that at least one variable of this type has been found active.
- Parameters
actualTypeSpec – the given type
- Returns
true if the given “actualTypeSpec” is possibly differentiable.
isDifferentiated¶
-
public boolean
isDifferentiated
(TapList<TypeSpec> dejaVu)¶ - Parameters
dejaVu – List of dejaVu sub-types, to avoid looping. Pass null at call.
- Returns
true if at least one variable with this type has at least one active part. This is stronger than isDifferentiableType() i.e. this.isDifferentiated() ⇒ isDifferentiableType(this).
isNamedType¶
-
public boolean
isNamedType
()¶ - Returns
true if this is a plain named type, i.e. a placeholder for a type that should be defined elsewhere, later during building the representation.
isNumericBase¶
-
public boolean
isNumericBase
()¶ - Returns
true if the base of this type is numeric, which means either integer or real or complex (or boolean or char in C).
isProbablyRealOrComplexBase¶
-
boolean
isProbablyRealOrComplexBase
()¶ - Returns
true if the base of this type is either “float” or “complex” or a yet undefined type which can/will be only “float” or “complex”.
isRealOrComplexBase¶
-
public boolean
isRealOrComplexBase
()¶ - Returns
true if the base of this type is either “float” or “complex”, which means a type that may be differentiated.
isString¶
-
public boolean
isString
()¶ - Returns
true if this type is a string type, i.e. a one-dimensional array of characters.
localize¶
-
protected TypeSpec
localize
(TapList<TapTriplet<TypeSpec, TypeSpec, Boolean>> toAlreadyCopied, ToBool containsMeta)¶ - Parameters
toAlreadyCopied – the hatted A-list from each original sub-type to its copy plus a boolean which is true iff the original sub-type contains a meta Type.
containsMeta – contains true upon return iff this type contains a Meta sub-type. We assume containsMeta is initialized upon false upon call.
- Returns
the copied type.
modifiedBaseTypeSpec¶
-
public WrapperTypeSpec
modifiedBaseTypeSpec
()¶ - Returns
the ModifiedTypeSpec around the base of this type. If no ModifiedTypeSpec around, returns the same as baseTypeSpec(false).
needsADiffType¶
-
public boolean
needsADiffType
(TapList<TypeSpec> dejaVu)¶ - Parameters
dejaVu – TapList of TypeSpec
- Returns
true iff there must be a differentiated type for this type, different from this type. For instance a record with all fields passive need no diff type, and a record with all fields completely active, do not need a diff type either because the original type also works as well. Also note that in modes associationByAddress, float types and also records with all fields completely active DO need a diff type, because float type is replaced by a special type aka “aDouble”.
nestedLevelType¶
peelArrayDimsAroundComposite¶
-
protected static TapPair<WrapperTypeSpec, ArrayDim[]>
peelArrayDimsAroundComposite
(WrapperTypeSpec typeSpec)¶ Peels all array dimensions around the given type, until it reaches a composite type or a leaf type.
- Returns
a TapPair of (1) the bottom composite or leaf type found and of (2) the array of ArrayDim objects that were found on the way.
peelDimensionsTo¶
peelPointer¶
peelSizeModifier¶
-
public static WrapperTypeSpec
peelSizeModifier
(WrapperTypeSpec typeSpec, ToObject<ModifiedTypeSpec> toModifiedType)¶
peelSizeModifiersTo¶
peelWrapperAndModifiedTo¶
preciseDimensions¶
-
protected TypeSpec
preciseDimensions
(TypeSpec complementType, TapList<TapPair<TypeSpec, TypeSpec>> dejaVu, SymbolTable symbolTable)¶ Try and refine the dimension information inside this type, by matching it with the given complementType, which has the same structure.
- Parameters
dejaVu – List of dejaVu sub-types, to avoid looping. Pass null at call.
precisionSize¶
-
public int
precisionSize
()¶ - Returns
the size in bytes of this numeric type, or -1 for unknown, or -2, -3, or -4 for double,short,or quadruple.
realToComplex¶
receives¶
receivesNoInferenceNoVector¶
receivesNoVector¶
receivesNoVectorNeglectSizes¶
-
public boolean
receivesNoVectorNeglectSizes
(TypeSpec other, TypeSpec toThis, TypeSpec toOther)¶ - Returns
true it this type can receive a value of the other type, performing type inference if needed and possible, and not caring about different type precision at the leaf primitive types, but without allowing array operations in the style of F90.
receivesVectorNeglectSizes¶
showType¶
size¶
-
public int
size
()¶ - Returns
(and stores for later reference) the memory size in bytes occupied by objects of this type.
testComparesWith¶
updateAfterImports¶
-
public void
updateAfterImports
(SymbolTable symbolTable, TapList<TypeSpec> dejaVu)¶ Updates this type with the full information available from the given “symbolTable” and from the other symbol tables that it imports. Example: a type may use a variable name (for size, dimension…) that was not known before all symbols from USE’d Modules have been imported.