The superclass of all types.
The class hierarchy for types distinguishes basic from wrapped types, with wrapped types providing additional information for basic types. For each basic type, this class provides
isName()
and
toName()
methods to replace instanceof tests and casts, respectively. For each wrapped type, this class additionally provides a
hasName()
method, which identifies instances of the wrapped type even if they are wrapped inside another (wrapped) type. In other words, invocations of
hasName()
are forwarded across wrapped types while invocations of
isName()
only apply to the outermost type object. For wrapped types, invocations of
toName()
are also forwarded across (other) wrapped types.
As an example, consider an int type wrapped in an annotated type and an alias type:
Type i = NumberT.INT; Type j = new AnnotatedT(i); Type k = new AliasT("alias", j);
Then the following method invocations have the following results:
k.isAlias() ⇒ true k.hasAlias() ⇒ true k.toAlias() ⇒ k k.isAnnotated() ⇒ false k.hasAnnotated() ⇒ true k.toAnnotated() ⇒ j k.isInteger() ⇒ false k.toInteger() ⇒ error
The {@link #resolve()} method can be used to strip any wrappedtypes:
Type r = k.resolve(); r.isAlias() ⇒ false r.isAnnotated() ⇒ false r.isInteger() ⇒ true r.toInteger() ⇒ i
The {@link Tag} enumeration also identifies particular types.A type's tag can be accessed through {@link #tag()}, which is forwarded across wrapped types, and through {@link #wtag()}, which is
not forwarded across wrapped types. As a result,
tag()
identifies basic types independent of whether they are wrapped or not, while
wtag()
always identifies the outermost type:
k.tag() ⇒ Tag.INTEGER k.wtag() ⇒ Tag.ALIAS i.tag() ⇒ Tag.INTEGER i.tag() ⇒ Tag.INTEGER
Each type can have one or more of the following annotations:
- Its source location represented as a {@link Location}.
- Its source language represented as a {@link Language} tag.
- Its scope represented as a {@link String}.
- Its constant value represented as a {@link Constant}.
- Its memory shape represented as a {@link Reference}. Only lvalues can have a shape.
- Its attributes represented as a list of {@link Attribute}values.
For each kind of annotation, this class defines tester, getter, and setter methods. The tester and getter methods come in two versions, one that is forwarded across wrapped types and one that uses a boolean parameter to control forwarding.
@author Robert Grimm
@version $Revision: 1.112 $