public class C
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.math.BigInteger |
FACTOR_CHAR
The factor for chars.
|
protected java.math.BigInteger |
FACTOR_WIDE
The factor for wide chars.
|
static boolean |
GCC_LEGACY_LAYOUT
The flag for GCC's legacy structure layout.
|
static IntegerT |
IMPLICIT
The canonical implicit int type.
|
protected static NumberT.Kind |
KIND_PTR_DIFF
The integer kind of the pointer difference type.
|
protected static NumberT.Kind |
KIND_SIZEOF
The integer kind of the sizeof type.
|
protected static NumberT.Kind |
KIND_WCHAR
The number kind of the wchar_t type.
|
static IntegerT |
PTR_DIFF
The canonical pointer difference type.
|
static IntegerT |
SIZEOF
The canonical sizeof type.
|
static IntegerT |
WCHAR
The canonical wide char type.
|
| Constructor and Description |
|---|
C()
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
Type |
compose(Type t1,
Type t2,
boolean pedantic)
Compose the specified types.
|
protected Type |
compose(Type t1,
Type t2,
boolean pedantic,
boolean recursive)
Compose the specified types.
|
protected Type |
composeArrays(ArrayT a1,
ArrayT a2)
Compose the specified array types (C99 6.2.7).
|
protected Type |
composeFunctions(FunctionT f1,
FunctionT f2,
boolean pedantic)
Compose the specified function types (C99 6.2.7).
|
Type |
convert(Type t1,
Type t2)
Perform the usual arithmetic conversions.
|
boolean |
equal(Type t1,
Type t2)
Determine whether the specified types are equal to each other.
|
Type |
fit(java.math.BigInteger number)
Fit the specified number to the closest integer type, starting
with
int. |
boolean |
fits(java.math.BigInteger number,
Type type)
Determine whether the specified number fits the specified integer
type.
|
protected long |
getAligned(Type type)
Get the specified type's alignment.
|
long |
getAlignment(Type type)
Get the specified type's alignment in bytes.
|
long |
getAlignment(Type type,
boolean natural)
Get the specified type's alignment in bytes.
|
Reference |
getConstRef(Type type)
Get the specified type's constant reference.
|
long |
getOffset(StructOrUnionT type,
java.lang.String name)
Get the specified member's offset for the specified structure or
union.
|
long |
getSize(Type type)
Get the specified type's size in bytes.
|
long |
getWidth(Type number)
Get the specified number's size in bits.
|
boolean |
hasConstRef(Type type)
Determine whether this type has a constant reference.
|
boolean |
hasQualifiers(Type type)
Determine whether the specified type has any qualifiers.
|
boolean |
hasQualifiers(Type type,
Type template)
Determine whether the specified type has at least the qualifiers
of the specified template.
|
boolean |
hasSameQualifiers(Type type,
Type template)
Determine whether the specified type has the same qualifiers as
the specified template.
|
boolean |
hasThreadLocals()
Determine whether the current target supports thread-local
storage.
|
boolean |
hasTrailingArray(Type type)
Determine whether the specified type has a trailing array.
|
boolean |
isArithmetic(Type type)
Determine whether the specified type is arithmetic.
|
boolean |
isChar(Type type)
Determine whether the specified type is a char.
|
boolean |
isConstant(Type type)
Determine whether the specified type is qualified as constant.
|
boolean |
isIncomplete(Type type)
Determine whether the specified type is incomplete.
|
boolean |
isIntegral(Type type)
Determine whether the specified type is integral.
|
boolean |
isModifiable(Type type)
Determine whether the specified type represents a modifiable
lvalue.
|
protected boolean |
isPacked(Type type)
Determine whether the specified type has a GCC packed attribute.
|
boolean |
isReal(Type type)
Determine whether the specified type is real.
|
boolean |
isScalar(Type type)
Determine whether the specified type is scalar.
|
boolean |
isString(Type type)
Determine whether the specified type is a string.
|
boolean |
isStringLiteral(Type type)
Determine whether the specified type is a string literal.
|
boolean |
isVariablyModified(Type type)
Determine whether the specified type is variably modified.
|
boolean |
isWideChar(Type type)
Determine whether the specified type is a wide char.
|
boolean |
isWideString(Type type)
Determine whether the specified type is a wide string.
|
long |
layout(StructT type,
java.lang.String name)
Lay out the specified structure.
|
java.math.BigInteger |
mask(java.math.BigInteger number,
Type type)
Mask the specified number as a value of this integer type.
|
Type |
pointerize(Type type)
Pointerize the specified type.
|
Type |
promote(Type type)
Integer promote the specified type.
|
Type |
promoteArgument(Type type)
Argument promote this type.
|
Type |
qualify(Type type,
Type template)
Qualify the specified type with the qualifiers of the specified
template.
|
Type |
reattribute(Type type,
Type template)
Reattribute the specified type with the specified template's GCC
attributes.
|
java.lang.String |
toDesignation(Type type)
Get the specified type's designation.
|
Type |
toRValue(Type type)
Convert the specified type to an rvalue.
|
Type |
typeCharacter(java.lang.String literal)
Type the specified C character literal.
|
Type |
typeFloat(java.lang.String literal)
Type the specified floating point literal.
|
Type |
typeInteger(java.lang.String literal)
Type the specified integer literal.
|
public static final boolean GCC_LEGACY_LAYOUT
public static final IntegerT IMPLICIT
Constants.ATT_IMPLICIT attribute.protected static final NumberT.Kind KIND_SIZEOF
public static final IntegerT SIZEOF
protected static final NumberT.Kind KIND_PTR_DIFF
public static final IntegerT PTR_DIFF
protected static final NumberT.Kind KIND_WCHAR
public static final IntegerT WCHAR
protected final java.math.BigInteger FACTOR_CHAR
protected final java.math.BigInteger FACTOR_WIDE
public boolean isChar(Type type)
type - The type.true if the type is a char.public boolean isWideChar(Type type)
type - The type.true if the type is a wide char.public boolean isString(Type type)
type - The type.true if the type is a string.public boolean isWideString(Type type)
type - The type.true if the type is a wide string.public boolean isStringLiteral(Type type)
type - The type.true if the type is a string literal.public boolean isIntegral(Type type)
type - The type.true if the specified type is integral.public boolean isReal(Type type)
type - The type.true if the specified type is real.public boolean isArithmetic(Type type)
type - The type.true if the specified type is arithmetic.public boolean isScalar(Type type)
type - The type.true if the specified type is scalar.public boolean isIncomplete(Type type)
type - The type.true if the type is incomplete.public boolean hasTrailingArray(Type type)
type - The type.true if the type has a trailing array.public boolean isVariablyModified(Type type)
type - The type.true if the type is variably modified.public boolean isConstant(Type type)
Constants.ATT_CONSTANT attribute and, if it is an
array, struct, or union, whether any member or element of the
type has that attribute.type - The type.true if the specified type is constant
qualified.public boolean isModifiable(Type type)
type - The type.true if the type represents a modifiable
lvalue.public boolean hasConstRef(Type type)
true either if the specified
type has a constant reference or if this type is an array or
function and has a constant reference.type - The type.true if the type has a constant reference.public Reference getConstRef(Type type)
type - The type.java.lang.IllegalArgumentException - Signals that the type does not
have a constant reference.public boolean hasQualifiers(Type type)
type - The type.true if the type has any qualifiers.public boolean hasQualifiers(Type type, Type template)
type - The type.template - The template.true if the type has at least the template's
qualifiers.public boolean hasSameQualifiers(Type type, Type template)
type - The type.template - The template.true if the type has the same qualifiers
as the template.public Type qualify(Type type, Type template)
annotates the specified type first.type - The type.template - The template.public Type reattribute(Type type, Type template)
type - The type.template - The template.public Type toRValue(Type type)
type - The type.public boolean hasThreadLocals()
true if the current target supports
thread-local storage.public long getAlignment(Type type)
type - The type.java.lang.IllegalArgumentException - Signals that the type does not
have a static alignment.public long getAlignment(Type type, boolean natural)
type - The type.natural - The flag for determining the natural alignment.java.lang.IllegalArgumentException - Signals that the type does not have a static alignment.public long getSize(Type type)
type - The type.java.lang.IllegalArgumentException - Signals that the type does not
have a static size.public long getOffset(StructOrUnionT type, java.lang.String name)
type - The structure or union.name - The member's name.public long layout(StructT type, java.lang.String name)
type - The structure.name - The member name or null for the entire
structure.protected boolean isPacked(Type type)
type - The type.true if the type has a packed attribute.protected long getAligned(Type type)
type - The type.public long getWidth(Type number)
number - The number.public Type fit(java.math.BigInteger number)
int.number - The number.ErrorT.TYPE if the number is too large.public boolean fits(java.math.BigInteger number,
Type type)
number - The number.type - The integer type.true if the number fits the type.public java.math.BigInteger mask(java.math.BigInteger number,
Type type)
number - The number.type - The type.public java.lang.String toDesignation(Type type)
type - The type.public Type promote(Type type)
type - The type.public Type promoteArgument(Type type)
type - The type.public Type pointerize(Type type)
type - The type.public Type convert(Type t1, Type t2)
t1 - The first type.t2 - The second type.java.lang.IllegalArgumentException - Signals that either type is
not arithmetic.public Type compose(Type t1, Type t2, boolean pedantic)
ErrorT.TYPE.
Note that if both types are derived types, this method
ensures that any referenced types have the same qualifiers.
However, it does not ensure that the two types have the same
qualifiers. As a result, two types t1 and
t2 are compatible if:
C.hasSameQualfiers(t1, t2) && (! C.compose(t1, t2).isError())Further note that the composed type does not preserve any annotations or wraped types and thus needs to be annotated with the two type's qualifiers etc.
t1 - The first type.t2 - The second type.pedantic - The flag for pedantic composition.equal(Type,Type)protected Type compose(Type t1, Type t2, boolean pedantic, boolean recursive)
t1 - The first type.t2 - The second type.pedantic - The flag for pedantic composition.recursive - The flag for recursive invocations.protected Type composeArrays(ArrayT a1, ArrayT a2)
a1 - The first array.a2 - The second array.protected Type composeFunctions(FunctionT f1, FunctionT f2, boolean pedantic)
f1 - The first function.f2 - The second function.pedantic - The flag for pedantic composition.public boolean equal(Type t1, Type t2)
t1 and t2
is equivalent to:
C.hasSameQualifiers(t1, t2) && (! C.compose(t1, t2).isError())
t1 - The first type.t2 - The second type.true if the types are equal.public Type typeCharacter(java.lang.String literal)
literal - The literal.public Type typeInteger(java.lang.String literal)
literal - The literal.public Type typeFloat(java.lang.String literal)
literal - The literal.Copyright © 2014. All Rights Reserved.