coins.sym
Class TypeImpl

java.lang.Object
  extended bycoins.sym.SymImpl
      extended bycoins.sym.TypeImpl
All Implemented Interfaces:
java.lang.Cloneable, HasStringObject, Sym, Sym0, Type
Direct Known Subclasses:
BaseTypeImpl, DefinedTypeImpl, EntryType, EnumTypeImpl, PointerTypeImpl, RegionTypeImpl, StmtFuncParamType, StructTypeImpl, SubpTypeImpl, UnionTypeImpl, VectorTypeImpl

public class TypeImpl
extends SymImpl
implements Type

 TypeImpl Class


Field Summary
protected  Type fCompleteType
          fCompleteType Complete type corresponding to this type.
protected  boolean fConst
          This type is const or not
protected  Type fOrigin
          Type from which this type derived.
protected  boolean fRestrict
          This type is restrict or not
protected  java.lang.String fTypeCore
          fTypeCore is core part of this type, that is, excluding type qualifier and vector element count.
protected  int fTypeKind
          The indication of this Type kind
protected  boolean fVolatile
          This type is volatile or not
 
Fields inherited from class coins.sym.SymImpl
fDbgLevel, fDefinedIn, fFlagBox, fKind, fName, fNextSym, fRecordedIn, fSourceInf, fSymInf, fType, fUniqueNameSym, fWork, machineParam, sourceLanguage, symRoot
 
Fields inherited from interface coins.sym.Type
KIND_ADDRESS, KIND_ALIGNMENT, KIND_BASE_LIM, KIND_BOOL, KIND_CHAR, KIND_DEFINED, KIND_DOUBLE, KIND_ENUM, KIND_FLOAT, KIND_FLOAT_LOWER_LIM, KIND_FLOAT_UPPER_LIM, KIND_INT, KIND_INT_UPPER_LIM, KIND_LONG, KIND_LONG_DOUBLE, KIND_LONG_LONG, KIND_OFFSET, KIND_POINTER, KIND_RANKS, KIND_REGION, KIND_SHORT, KIND_STRING, KIND_STRUCT, KIND_SUBP, KIND_U_CHAR, KIND_U_INT, KIND_U_LONG, KIND_U_LONG_LONG, KIND_U_SHORT, KIND_UNDEF, KIND_UNION, KIND_UNSIGNED_LOWER_LIM, KIND_VECTOR, KIND_VOID, KIND_WCHAR
 
Fields inherited from interface coins.sym.Sym
KIND_NAME, VISIBILITY
 
Fields inherited from interface coins.sym.Sym0
FLAG_ADDRESS_TAKEN, FLAG_CASTLESS_SUBP, FLAG_COMMON, FLAG_COMPLEX_STRUCT, FLAG_DERIVED_SYM, FLAG_GENERATED_SYM, FLAG_INCOMPLETE_TYPE, FLAG_POINTER_OPERATION, FLAG_REGION_ELEM, FLAG_RESERVED_NAME, FLAG_SIZEOF_TAKEN, FLAG_UNFIXED_SIZE, FLAG_UNIFORM_SIZE, FLAG_VALUE_IS_ASSIGNED, KIND_AREG, KIND_BOOL_CONST, KIND_CHAR_CONST, KIND_CONST_FIRST, KIND_CONST_LAST, KIND_ELEM, KIND_EXP_ID, KIND_FLOAT_CONST, KIND_INT_CONST, KIND_LABEL, KIND_MREG, KIND_NAMED_CONST, KIND_OTHER, KIND_PARAM, KIND_REMOVED, KIND_STRING_CONST, KIND_TAG, KIND_TYPE, KIND_VAR, SYM_COMPILE_UNIT, SYM_EXTERN, SYM_PRIVATE, SYM_PROTECTED, SYM_PUBLIC
 
Constructor Summary
TypeImpl()
           
TypeImpl(SymRoot pSymRoot)
           
 
Method Summary
 int getAlignment()
          getAlignment Get alignment value for this type.
 int getAlignmentGap(long pPrecedingSize)
          getAlignmentGap Get alignment gap size if cumulative size of preceeding elements is pPreceedingSize.
 Type getCompleteType()
          getCompleteType Get complete type corresponding to this type.
 int getDimension()
          getDimension Get the dimension of this type.
 IrList getElemList()
          getElemList: Get the list of struct/union elements.
 java.lang.String getElemListString()
          getElemListString Get element type list of struct, union type in String form.
static java.lang.String getElemListString(IrList pElemList)
           
static java.lang.String getEnumListString(IrList pEnumList)
          getEnumListString Get element list of enum list pEnumList in String form.
 Type getFinalOrigin()
          getFinalOrigin Trace the chain of origin types and return the origin as the last one of the chain.
 Type getOrigin()
          getOrigin
 Type getPointedType()
          getPointedType Get the type of pointed object for PointerType.
 Exp getSizeExp()
          getSizeExp Get size of type.
 long getSizeValue()
          getSizeValue Get the size of this type in bytes.
 int getTypeKind()
          getTypeKind Get the type kind code (Type.KIND_INT, KIND_FLOAT, KIND_POINTER, KIND_STRUCT, etc.
 int getTypeRank()
          getTypeRank The type rank shows conversion rank.
 Type getUnqualifiedType()
          Trace the chain of origin types and return unqualified type.
 boolean isBasicType()
          isBasicType
 boolean isCompatibleWith(Type pType)
          isCompatibleWith See isCompatibleWith in VectorType, StructType, UnionType, EnumType, PointerType, SubpType.
 boolean isConst()
          isConst See the qualification of "this" type.
 boolean isFloating()
          isUnsigned
 boolean isInteger()
          isInteger
 boolean isRestrict()
          isRestrict See the qualification of "this" type.
 boolean isScalar()
           
 boolean isSizeEvaluable()
          isSizeEvaluable
 boolean isUnsigned()
          isUnsigned
 boolean isVolatile()
          isVolatile See the qualification of "this" type.
 Type makeConstType()
          makeConstType Make a new type qualifying this type by "const" and return it.
 Type makeRestrictType()
          makeRestrictType Make a new type qualifying this type by "restrict" and return it.
 Type makeVolatileType()
          makeVolatileType Make a new type qualifying this type by "volatile" and return it.
 Type searchTypeCompatibleWithThis()
           
 void setOrigin(Type pOrigin)
          setOrigin Set the origin type.
 void setSizeExp(Exp pSizeExp)
          setSizeExp Set the size expression of this type.
 void setSizeValue(long pSizeValue)
          setSizeValue Set the size of this type.
 void setStaticTable(MachineParam pMachineParam)
          setStaticTable set up static table KIND_ALIGNMENT.
 java.lang.String toString()
          Get the string image of object.
 java.lang.String toStringDetail()
          toStringDetail Get detailed attributes of this symbol in text which is not interned.
 java.lang.String toStringShort()
          toStringShort Get name and index of this symbol in text which is not interned.
 
Methods inherited from class coins.sym.SymImpl
bareStringConst, baseType, boolConst, charConst, charConst, charConst, definedType, definedType, defineElem, defineLabel, defineParam, defineRegionVar, defineSubp, defineVar, defineVar, derivedSym, enumType, enumType, floatConst, floatConst, getDefinedColumn, getDefinedFile, getDefinedIn, getDefinedInName, getDefinedLine, getFlag, getInf, getName, getNameOrNull, getNextSym, getOrAddInf, getOriginalSym, getOriginalSym, getPureName, getRecordedIn, getSourceInf, getSymKind, getSymKindName, getSymType, getUniqueName, getWork, intConst, intConst, intObject, isGlobal, isHIR, isRemoved, isSym, linkSym, makeCstring, makeCstringWithTrailing0, makeEnumTypeName, makeExpString, makeJavaString, makeStructUnionTypeName, makeSubpTypeName, makeSubpTypeName, makeVectorTypeName, makeVectorTypeName, makeVectorTypeName, namedConst, namedConst, pointerType, pointerType, pointerType, pointerType, pointerType, print, print, regionType, regionType, remove, setDefinedFile, setDefinedIn, setDefinedLine, setFlag, setOriginalSym, setParameters, setRecordedIn, setSourceInf, setSymKind, setSymType, setUniqueNameSym, setWork, stringConst, stringConstFromQuotedString, structType, structType, subpType, subpType, symbol, unionType, unionType, vectorType, vectorType, vectorType, vectorType, vectorTypeUnfixed, vectorTypeUnfixed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface coins.sym.Sym
baseType, boolConst, charConst, defineVar, derivedSym, floatConst, getDefinedColumn, getDefinedInName, getDefinedLine, getInf, getNameOrNull, getOrAddInf, getOriginalSym, getOriginalSym, getPureName, getSymKindName, getWork, intConst, intObject, isRemoved, makeCstring, makeCstringWithTrailing0, makeEnumTypeName, makeJavaString, makeStructUnionTypeName, makeSubpTypeName, makeVectorTypeName, makeVectorTypeName, makeVectorTypeName, namedConst, pointerType, pointerType, pointerType, regionType, remove, setDefinedFile, setDefinedIn, setDefinedLine, setRecordedIn, setSymKind, setSymType, setUniqueNameSym, setWork, stringConstFromQuotedString, symbol, vectorType, vectorType, vectorType, vectorTypeUnfixed
 
Methods inherited from interface coins.sym.Sym0
charConst, definedType, defineElem, defineLabel, defineParam, defineSubp, defineVar, enumType, floatConst, getDefinedFile, getDefinedIn, getFlag, getName, getNextSym, getRecordedIn, getSymKind, getSymType, getUniqueName, intConst, isGlobal, namedConst, pointerType, setFlag, stringConst, structType, subpType, unionType, vectorType, vectorTypeUnfixed
 

Field Detail

fTypeKind

protected int fTypeKind
The indication of this Type kind


fOrigin

protected Type fOrigin
Type from which this type derived.


fConst

protected boolean fConst
This type is const or not


fVolatile

protected boolean fVolatile
This type is volatile or not


fRestrict

protected boolean fRestrict
This type is restrict or not


fCompleteType

protected Type fCompleteType
fCompleteType Complete type corresponding to this type.


fTypeCore

protected java.lang.String fTypeCore
fTypeCore is core part of this type, that is, excluding type qualifier and vector element count. It should be a name with intern().

Constructor Detail

TypeImpl

public TypeImpl()

TypeImpl

public TypeImpl(SymRoot pSymRoot)
Method Detail

getTypeKind

public int getTypeKind()
Description copied from interface: Type
getTypeKind Get the type kind code (Type.KIND_INT, KIND_FLOAT, KIND_POINTER, KIND_STRUCT, etc. defined in Type interface).

Specified by:
getTypeKind in interface Type
Returns:
the type kind code of this type.

getOrigin

public Type getOrigin()
Description copied from interface: Type
getOrigin

Specified by:
getOrigin in interface Type
Returns:
the origin type of this type.

getFinalOrigin

public Type getFinalOrigin()
Description copied from interface: Type
getFinalOrigin Trace the chain of origin types and return the origin as the last one of the chain.

Specified by:
getFinalOrigin in interface Type
Returns:
the final origin type of this type.

getUnqualifiedType

public Type getUnqualifiedType()
Description copied from interface: Type
Trace the chain of origin types and return unqualified type.

Specified by:
getUnqualifiedType in interface Type
Returns:
unqualified type of this type.

setOrigin

public void setOrigin(Type pOrigin)
Description copied from interface: Type
setOrigin Set the origin type.

Specified by:
setOrigin in interface Type
Parameters:
pOrigin - origin type of this type.

isBasicType

public boolean isBasicType()
Description copied from interface: Type
isBasicType

Specified by:
isBasicType in interface Type
Returns:
true if this is a basic type, false otherwize.

isInteger

public boolean isInteger()
Description copied from interface: Type
isInteger

Specified by:
isInteger in interface Type
Returns:
true if this is an integer type, that is, either int, short, long, long_long, u_int, u_short, u_long, u_long_long.

isUnsigned

public boolean isUnsigned()
Description copied from interface: Type
isUnsigned

Specified by:
isUnsigned in interface Type
Returns:
true if this is an unsigned integer type, that is, either u_int, u_short, u_long, u_long_long.

isFloating

public boolean isFloating()
Description copied from interface: Type
isUnsigned

Specified by:
isFloating in interface Type
Returns:
true if this is a floating point type, that is, either float, double, long_double.

isScalar

public boolean isScalar()
Specified by:
isScalar in interface Type

getSizeExp

public Exp getSizeExp()
getSizeExp Get size of type. "this" should be a type symbol. return@ get the size of this type.

Specified by:
getSizeExp in interface Type
Returns:
the size expression of this type.

setSizeExp

public void setSizeExp(Exp pSizeExp)
Description copied from interface: Type
setSizeExp Set the size expression of this type. If pSizeExp can be evaluated as long integer, then the size value is adjusted to it.

Specified by:
setSizeExp in interface Type
Parameters:
pSizeExp - Size expression or null if the size is not yet defined.

getSizeValue

public long getSizeValue()
Description copied from interface: Type
getSizeValue Get the size of this type in bytes. If size value is given as constant, then return 0 or plus value. If getSizeValue() < 0 and getSizeExp() != null, then the size is given as non-constant expression (use getSizeExp()). If getSizeValue() < 0 and getSizeExp() == null, then no size information is given (incomplete type).

Specified by:
getSizeValue in interface Type
Returns:
the size of this type.

setSizeValue

public void setSizeValue(long pSizeValue)
Description copied from interface: Type
setSizeValue Set the size of this type. if pSizeValue >= 0, then the size expression is adjusted to it.

Specified by:
setSizeValue in interface Type
Parameters:
pSizeValue - size of this type;

isSizeEvaluable

public boolean isSizeEvaluable()
Description copied from interface: Type
isSizeEvaluable

Specified by:
isSizeEvaluable in interface Type
Returns:
true if the size is evaluable as long integer value, false otherwise.

makeConstType

public Type makeConstType()
Description copied from interface: Type
makeConstType Make a new type qualifying this type by "const" and return it. If this is already a qualified type, then return this. If this is StructType/UnionType/EnumType, finishStructType/finishUnionType/finishEnumType should be called before calling makeConstType/makeVolatileType/makeRestrictType. Error if const is given for volatile type.

Specified by:
makeConstType in interface Type
Returns:
the qualified type.

makeVolatileType

public Type makeVolatileType()
Description copied from interface: Type
makeVolatileType Make a new type qualifying this type by "volatile" and return it. If this is already a qualified type, then return this. If this is StructType/UnionType/EnumType, finishStructType/finishUnionType/finishEnumType should be called before calling makeConstType/makeVolatileType. Error if volatile is given to const type.

Specified by:
makeVolatileType in interface Type
Returns:
the qualified type.

makeRestrictType

public Type makeRestrictType()
Description copied from interface: Type
makeRestrictType Make a new type qualifying this type by "restrict" and return it. If this is already a qualified type, then return this. If this is StructType/UnionType/EnumType, finishStructType/finishUnionType/finishEnumType should be called before calling makeConstType/makeVolatileType/makeRestrict.

Specified by:
makeRestrictType in interface Type
Returns:
the qualified type.

isConst

public boolean isConst()
isConst See the qualification of "this" type. "this" should be a type symbol.

Specified by:
isConst in interface Type
Returns:
boolean true if "this" type is qualified as const, false otherwise.

isVolatile

public boolean isVolatile()
isVolatile See the qualification of "this" type. "this" should be a type symbol.

Specified by:
isVolatile in interface Type
Returns:
true if "this" type is qualified as volatile, false otherwise.

isRestrict

public boolean isRestrict()
isRestrict See the qualification of "this" type. "this" should be a type symbol.

Specified by:
isRestrict in interface Type
Returns:
true if "this" type is qualified as restrict, false otherwise.

getTypeRank

public int getTypeRank()
Description copied from interface: Type
getTypeRank The type rank shows conversion rank. The type of operand with lower rank is to be converted to the type of operand with higher rank in binary arithmetic operation.

Specified by:
getTypeRank in interface Type
Returns:
teh conversion rank of this type.

getDimension

public int getDimension()
getDimension Get the dimension of this type. "this" is an array type.

Specified by:
getDimension in interface Type
Returns:
the dimension of this type if this is an array type. 1: 1-dimensinal array, 2: 2-dimensional array, ,,, . If this is not an array type, return 0.

getElemList

public IrList getElemList()
Description copied from interface: Type
getElemList: Get the list of struct/union elements. The elements of the list is an instance of Elem. If this type is neither struct nore union, then null is returned.

Specified by:
getElemList in interface Type
Returns:
the list of elements or null.

getPointedType

public Type getPointedType()
Description copied from interface: Type
getPointedType Get the type of pointed object for PointerType. If this type is not PointerType, then null is returned.

Specified by:
getPointedType in interface Type
Returns:
the type of pointed object if this is a pointer, otherwise return null.

getElemListString

public java.lang.String getElemListString()
Description copied from interface: Type
getElemListString Get element type list of struct, union type in String form. The elements of the list represents the type name of struct/union type. If this type has no element, then "{}" is returned.

Specified by:
getElemListString in interface Type
Returns:
the list of element type names of struct/union.

getElemListString

public static java.lang.String getElemListString(IrList pElemList)

getEnumListString

public static java.lang.String getEnumListString(IrList pEnumList)
getEnumListString Get element list of enum list pEnumList in String form.


getAlignment

public int getAlignment()
Description copied from interface: Type
getAlignment Get alignment value for this type. It depends on target machine. For basic types, the alignment value is a byte count specified in MachineParam.java. The default value of alignment of VectorType is the alignment of element type which may differ vector by vector. The defalut alignment value of StructType or UnionType is set to that of its element with the largest alignment value which may differ struct by struct or union by union. The alignment value of StructType, UnionType, or VectorType should be set by setAlignment method of corresponding type when the type is defined. As for subprogram, if alignment of return value is required, get it by subp.getReturnValueType().getAlignment(), and if alignment of subprogram object code is required, get it by symRoot.machineParam.getAlignment(Type.KIND_SUBP). //##67

Specified by:
getAlignment in interface Type
Returns:
the alignment number of this type in bytes.

getAlignmentGap

public int getAlignmentGap(long pPrecedingSize)
Description copied from interface: Type
getAlignmentGap Get alignment gap size if cumulative size of preceeding elements is pPreceedingSize.

Specified by:
getAlignmentGap in interface Type

isCompatibleWith

public boolean isCompatibleWith(Type pType)
isCompatibleWith See isCompatibleWith in VectorType, StructType, UnionType, EnumType, PointerType, SubpType.

Specified by:
isCompatibleWith in interface Type
Parameters:
pType - a type to be compared with this type.
Returns:
true if this type is compatible with pType.

getCompleteType

public Type getCompleteType()
getCompleteType Get complete type corresponding to this type. If this is a complete type, return this type. See getCompleteType in VectorType, StructType, UnionType, EnumType.

Specified by:
getCompleteType in interface Type

searchTypeCompatibleWithThis

public Type searchTypeCompatibleWithThis()

setStaticTable

public void setStaticTable(MachineParam pMachineParam)
setStaticTable set up static table KIND_ALIGNMENT. This method is not recommended to be called except from SymRoot.


toString

public java.lang.String toString()
Description copied from interface: HasStringObject
Get the string image of object.

Specified by:
toString in interface HasStringObject
Overrides:
toString in class SymImpl

toStringShort

public java.lang.String toStringShort()
Description copied from interface: Sym
toStringShort Get name and index of this symbol in text which is not interned.

Specified by:
toStringShort in interface Sym
Overrides:
toStringShort in class SymImpl

toStringDetail

public java.lang.String toStringDetail()
Description copied from interface: Sym
toStringDetail Get detailed attributes of this symbol in text which is not interned.

Specified by:
toStringDetail in interface Sym
Overrides:
toStringDetail in class SymImpl