ModifiedTypeSpec

public final class ModifiedTypeSpec extends TypeSpec

A type with additional modifications, e.g. size.

Fields

sizeModifier

public Tree sizeModifier

The tree of the expression that modifies the size of this type (if any).

sizeModifierResolved

protected Tree sizeModifierResolved

The size modifier, resolved as much as possible (if any and computable).

typeSign

protected int typeSign

SymbolTableConstants.SIGNED for “signed”, SymbolTableConstants.UNSIGNED for “unsigned”, SymbolTableConstants.UNSPECIFIED_SIGNED if unspecified.

Constructors

ModifiedTypeSpec

public ModifiedTypeSpec(WrapperTypeSpec elementType, Tree sizeModifier, SymbolTable symbolTable)

Create a modified type around the given elementType, with given modifiers.

ModifiedTypeSpec

public ModifiedTypeSpec(WrapperTypeSpec elementType, ModifiedTypeSpec model)

Create a modified type around the given elementType, following the given model modified type.

Methods

acceptsMultiDirDimension

public boolean acceptsMultiDirDimension()

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

checkTypeSpecValidity

protected boolean checkTypeSpecValidity(TapList<TypeSpec> dejaVu)

cloneAsUndefinedNumeric

protected TypeSpec cloneAsUndefinedNumeric(boolean undefined)

collectUsedTrees

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

compareModifiersWith

protected static boolean compareModifiersWith(int leftModifierInteger, Tree leftModifierTree, int rightModifierInteger, Tree rightModifierTree, int comparison)
Convention: integer size modifiers may be:
n>0 for a known size in bytes,
    -> in this case the "Tree" modifier is the size expression, that could be evaluated to n
0 for unmodified base type size (but not explicited because compiler_dependent)
    -> in this case the "Tree" modifier is null, since there was no modifier!
-1 for unknown size value (specified by Tree T)
    -> in this case the "Tree" modifier is the size expression, which could not be evaluated
-2 for double base type size
    -> in this case the "Tree" modifier is op_intCst:-2 meaning "double" or "long"
-3 for short,
    -> in this case the "Tree" modifier is op_intCst:-3 meaning "short"
-4 for double double base type size.
    -> in this case the "Tree" modifier is op_intCst:-4 meaning "long double" or "long long"
In the tables below, leftmodifier is on the left, rightmodifier on the top,
tt means ok, ff means not-ok, * means acceptable but possible accuracy problem
Parameters
  • leftModifierInteger

  • leftModifierTree

  • rightModifierInteger

  • rightModifierTree

  • comparison

complexDuplModifier

public Tree complexDuplModifier()

Given the size modifier of this ModifiedTypeSpec, which is assumedly applied to a non-complex type, tries to build a size modifier Tree that would apply to a complex that has this type of real/imaginary parts.

complexHalfModifier

public Tree complexHalfModifier()

Given the size modifier of this ModifiedTypeSpec, which is assumedly applied to a complex type, tries to build a size modifier Tree that would apply to either the real or imaginary part.

computeSize

protected int computeSize()

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

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)

doUpdateAfterImports

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

dump

public void dump()

elementType

public WrapperTypeSpec elementType()

The unmodified type inside.

generateTree

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

getModifierFrom

protected void getModifierFrom(ModifiedTypeSpec model)

Set the modifier of this modified type, following the given model modified type.

hasCbindingModifier

public boolean hasCbindingModifier()

hasCbindingModifier

public boolean hasCbindingModifier(String cModifier)

hasKindEqual

public boolean hasKindEqual()

hasUndefinedSize

protected boolean hasUndefinedSize()

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)

isPointer

public boolean isPointer()

isString

public boolean isString()

isTarget

public boolean isTarget()

isUndefinedNumeric

protected boolean isUndefinedNumeric()

localize

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

needsADiffType

public boolean needsADiffType(TapList<TypeSpec> dejaVu)

nestedLevelType

public TypeSpec nestedLevelType()

peelPointer

protected TypeSpec peelPointer()

preciseDimensions

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

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

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

resolveSizeModifier

protected void resolveSizeModifier(SymbolTable symbolTable)

Tries to evaluate the sizeModifier expression tree that is used to declare this modified type. If sizeModifier is null (e.g. modifier is only an “unsigned”) then evaluation returns null. Else if the expression is “double”, “long”, “long long”, etc then the evaluation returns intCst -2 or -4. Else if the expression evaluates to an integer value, then the evaluation returns this value in an intCst. Else if the expression is a constant with an initial value, returns the evaluation of this initial value. Else returns the sizeModifier itself.

setHasUndefinedSize

protected void setHasUndefinedSize(boolean val)

setUndefinedNumeric

protected void setUndefinedNumeric(boolean value)

setWrappedType

public void setWrappedType(TypeSpec type)

showType

public String showType()

sizeModifierIntegerSmaller

protected static boolean sizeModifierIntegerSmaller(int smallSize, int largeSize)

sizeModifierValue

public int sizeModifierValue()
Returns

the size of this modified type, if statically known, else returns -1. If size is a dynamic variable, returns -1. If the size is defined relatively (e.g. “double”), then doesn’t compute the final, compiler-dependent value, and instead returns -2 or -4 for “long double”.

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