xtc.type
Class WrappedT

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.type.Type
          extended by xtc.type.WrappedT
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable
Direct Known Subclasses:
AliasT, AnnotatedT, EnumeratorT, EnumT, InstantiatedT, ParameterizedT, VariableT

public abstract class WrappedT
extends Type

The superclass of all wrapped types. A wrapped type adds (mostly) symbolic information to another, more basic type.

Version:
$Revision: 1.37 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.type.Type
Type.Tag
 
Constructor Summary
WrappedT(Type type)
          Create a new wrapped type.
WrappedT(Type template, Type type)
          Create a new wrapped type.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determine whether this type equals the specified object.
 Attribute getAttribute(java.lang.String name, boolean forward)
          Get the attribute with the specified name.
 Constant getConstant(boolean forward)
          Get this type's or any wrapped type's constant.
 Language getLanguage(boolean forward)
          Get this type's or any wrapped type's language.
 Location getLocation(boolean forward)
          Get this type's or any wrapped type's location.
 java.lang.String getScope(boolean forward)
          Get this type's or any wrapped type's scope.
 Reference getShape(boolean forward)
          Get this type's or any wrapped type's shape.
 Type getType()
          Get the type.
 boolean hasAlias()
          Determine whether this type contains an alias.
 boolean hasAnnotated()
          Determine whether this type has an annotated type.
 boolean hasAttribute(Attribute att, boolean forward)
          Determine whether this type or any wrapped type has the specified attribute.
 boolean hasConstant(boolean forward)
          Determine whether this type or any wrapped type has a constant.
 boolean hasEnum()
          Determine whether this type contains an enum.
 boolean hasEnumerator()
          Determine whether this type contains an enumerator.
 int hashCode()
          Get this type's hash code.
 boolean hasInstantiated()
          Determine whether this type has an instantiated type.
 boolean hasLanguage(boolean forward)
          Determine whether this type or any wrapped type has a language.
 boolean hasLocation(boolean forward)
          Determine whether this type or any wrapped type has a location.
 boolean hasParameterized()
          Determine whether this type has a parameterized type.
 boolean hasScope(boolean forward)
          Determine whether this type or any wrapped type has a scope.
 boolean hasShape(boolean forward)
          Determine whether this type or any wrapped type has a shape.
 boolean hasTagged()
          Determine whether this type is tagged.
 boolean hasVariable()
          Determine whether this type contains a variable.
 boolean isWrapped()
          Determine whether this type is wrapped.
 Type resolve()
          Resolve this type.
 Type seal()
          Seal this type.
 void setType(Type type)
          Set the type.
 Type.Tag tag()
          Get this type's tag.
 AliasT toAlias()
          Get this type as an alias.
 AnnotatedT toAnnotated()
          Get this type as an annotated type.
 EnumT toEnum()
          Get this type as an enum.
 EnumeratorT toEnumerator()
          Get this type as an enumerator.
 InstantiatedT toInstantiated()
          Get this type as an instantiated type.
 ParameterizedT toParameterized()
          Get this type as a parameterized type.
 StructOrUnionT toStructOrUnion()
          Get this type as a struct or union.
 Tagged toTagged()
          Get this type as a tagged type.
 VariableT toVariable()
          Get this type as a variable.
 WrappedT toWrapped()
          Get this type as a wrapped type.
 
Methods inherited from class xtc.type.Type
addAttribute, annotate, attribute, attribute, attribute, attributes, cast, checkNotSealed, constant, constant, copy, copy, deannotate, getAttribute, getConstant, getLanguage, getLocation, getScope, getShape, hasAttribute, hasAttribute, hasAttribute, hasAttributes, hasConstant, hasError, hasLanguage, hasLocation, hasScope, hasShape, hasStructOrUnion, hasTag, hasWTag, isAlias, isAnnotated, isArray, isBoolean, isClass, isConcrete, isDerived, isEnum, isEnumerator, isError, isFloat, isFunction, isInstantiated, isInteger, isInterface, isInternal, isInternalParameter, isLabel, isMethod, isNamedParameter, isNumber, isPackage, isParameter, isParameterized, isPointer, isSealed, isStruct, isTuple, isUnion, isUnit, isVariable, isVariant, isVoid, isWildcard, language, locate, locate, mark, properties, removeAttribute, removeProperty, resolve, scope, seal, setLocation, setLocation, setProperty, shape, shape, toArray, toBoolean, toClass, toFloat, toFunction, toInteger, toInterface, toInternal, toInternalParameter, toLabel, toMethod, toNamedParameter, toNumber, toPackage, toParameter, toPointer, toStruct, toTuple, toUnion, toUnit, toVariant, toVoid, toWildcard, trace, wtag
 
Methods inherited from class xtc.tree.Node
add, add, addAll, addAll, addAll, addAll, addAllTo, addNode, contains, get, getBoolean, getBooleanProperty, getGeneric, getList, getName, getNode, getProperty, getString, getStringProperty, getTokenText, hasName, hasProperty, hasTraversal, indexOf, isAnnotation, isEmpty, isGeneric, isList, isToken, iterator, lastIndexOf, remove, set, size, strip, toAnnotation, toList, toString, toToken, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WrappedT

public WrappedT(Type type)
Create a new wrapped type.

Parameters:
type - The actual type.

WrappedT

public WrappedT(Type template,
                Type type)
Create a new wrapped type.

Parameters:
template - The type whose annotations to copy.
type - The actual type.
Method Detail

seal

public Type seal()
Description copied from class: Type
Seal this type. Subclasses that reference other types must override this method and, if the instance is not sealed, first invoke the superclass' version and then seal all referenced types. For example, if a subclass references a single type type, the corresponding overridden method reads:
 public Type seal() {
   if (! isSealed()) {
     super.seal();
     type.seal();
   }
   return this;
 }
 
First testing whether a type is sealed and then invoking the superclass' seal() method avoids infinite recursions for mutually recursive types.

Overrides:
seal in class Type
Returns:
This type.
See Also:
Type.seal(List)

tag

public Type.Tag tag()
Description copied from class: Type
Get this type's tag. Invocations to this method are forwarded across wrapped types.

Specified by:
tag in class Type
Returns:
This type's tag.
See Also:
Type.wtag()

isWrapped

public boolean isWrapped()
Description copied from class: Type
Determine whether this type is wrapped.

Overrides:
isWrapped in class Type
Returns:
true if this type is wrapped.

toWrapped

public WrappedT toWrapped()
Description copied from class: Type
Get this type as a wrapped type.

Overrides:
toWrapped in class Type
Returns:
This type as a wrapped type.

hasLocation

public boolean hasLocation(boolean forward)
Description copied from class: Type
Determine whether this type or any wrapped type has a location.

Overrides:
hasLocation in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
true if this type or any wrapped type has a location.

getLocation

public Location getLocation(boolean forward)
Description copied from class: Type
Get this type's or any wrapped type's location.

Overrides:
getLocation in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
The location or null if this type or any wrapped type does not have a location.

hasLanguage

public boolean hasLanguage(boolean forward)
Description copied from class: Type
Determine whether this type or any wrapped type has a language.

Overrides:
hasLanguage in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
true if this type or any wrapped type has a language.

getLanguage

public Language getLanguage(boolean forward)
Description copied from class: Type
Get this type's or any wrapped type's language.

Overrides:
getLanguage in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
The language or null if this type or any wrapped type does not have a language.

hasScope

public boolean hasScope(boolean forward)
Description copied from class: Type
Determine whether this type or any wrapped type has a scope.

Overrides:
hasScope in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
true if this type or any wrapped type has a scope.

getScope

public java.lang.String getScope(boolean forward)
Description copied from class: Type
Get this type's or any wrapped type's scope.

Overrides:
getScope in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
The scope or null if this type or any wrapped type does not have a scope.

hasConstant

public boolean hasConstant(boolean forward)
Description copied from class: Type
Determine whether this type or any wrapped type has a constant.

Overrides:
hasConstant in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
true if this type or any wrapped type has a constant.

getConstant

public Constant getConstant(boolean forward)
Description copied from class: Type
Get this type's or any wrapped type's constant.

Overrides:
getConstant in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
The constant or null if this type or any wrapped type does not have a constant.

hasShape

public boolean hasShape(boolean forward)
Description copied from class: Type
Determine whether this type or any wrapped type has a shape.

Overrides:
hasShape in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
true if this type or any wrapped type has a shape.

getShape

public Reference getShape(boolean forward)
Description copied from class: Type
Get this type's or any wrapped type's shape.

Overrides:
getShape in class Type
Parameters:
forward - The flag for whether to forward this method across wrapped types.
Returns:
The shape or null if this type or any wrapped type does not have a shape.

hasAttribute

public boolean hasAttribute(Attribute att,
                            boolean forward)
Description copied from class: Type
Determine whether this type or any wrapped type has the specified attribute.

Overrides:
hasAttribute in class Type
Parameters:
att - The attribute.
forward - The flag for whether to forward this method across wrapped types.
Returns:
true if this type or any wrapped type has the attribute.

getAttribute

public Attribute getAttribute(java.lang.String name,
                              boolean forward)
Description copied from class: Type
Get the attribute with the specified name.

Overrides:
getAttribute in class Type
Parameters:
name - The name.
forward - The flag for whether to forward this method across wrapped types.
Returns:
An attribute with the name or null if this or any wrapped type does not have such an attribute.

getType

public Type getType()
Get the type.

Returns:
The type.

setType

public void setType(Type type)
Set the type.

Parameters:
type - The type.
Throws:
java.lang.IllegalStateException - Signals that this type is sealed.

hasAnnotated

public boolean hasAnnotated()
Description copied from class: Type
Determine whether this type has an annotated type.

Overrides:
hasAnnotated in class Type
Returns:
true if this type has an annotated type.

toAnnotated

public AnnotatedT toAnnotated()
Description copied from class: Type
Get this type as an annotated type.

Overrides:
toAnnotated in class Type
Returns:
This type as an annotated type.

hasAlias

public boolean hasAlias()
Description copied from class: Type
Determine whether this type contains an alias.

Overrides:
hasAlias in class Type
Returns:
true if this type contains an alias.

toAlias

public AliasT toAlias()
Description copied from class: Type
Get this type as an alias.

Overrides:
toAlias in class Type
Returns:
This type as an alias.

hasEnum

public boolean hasEnum()
Description copied from class: Type
Determine whether this type contains an enum.

Overrides:
hasEnum in class Type
Returns:
true if this type contains an enum.

toEnum

public EnumT toEnum()
Description copied from class: Type
Get this type as an enum.

Overrides:
toEnum in class Type
Returns:
This type as an enum.

hasEnumerator

public boolean hasEnumerator()
Description copied from class: Type
Determine whether this type contains an enumerator.

Overrides:
hasEnumerator in class Type
Returns:
true if this type contains an enumerator.

toEnumerator

public EnumeratorT toEnumerator()
Description copied from class: Type
Get this type as an enumerator.

Overrides:
toEnumerator in class Type
Returns:
This type as an enumerator.

hasVariable

public boolean hasVariable()
Description copied from class: Type
Determine whether this type contains a variable.

Overrides:
hasVariable in class Type
Returns:
true if this type contains a variable.
See Also:
Node.hasTraversal()

toVariable

public VariableT toVariable()
Description copied from class: Type
Get this type as a variable.

Overrides:
toVariable in class Type
Returns:
This type as a variable.

hasInstantiated

public boolean hasInstantiated()
Description copied from class: Type
Determine whether this type has an instantiated type.

Overrides:
hasInstantiated in class Type
Returns:
true if this type has an instantiated type.

toInstantiated

public InstantiatedT toInstantiated()
Description copied from class: Type
Get this type as an instantiated type.

Overrides:
toInstantiated in class Type
Returns:
This type as an instantiated type.

hasParameterized

public boolean hasParameterized()
Description copied from class: Type
Determine whether this type has a parameterized type.

Overrides:
hasParameterized in class Type
Returns:
true if this type has a parameterized type.

toParameterized

public ParameterizedT toParameterized()
Description copied from class: Type
Get this type as a parameterized type.

Overrides:
toParameterized in class Type
Returns:
This type as a parameterized type.

toStructOrUnion

public StructOrUnionT toStructOrUnion()
Description copied from class: Type
Get this type as a struct or union.

Overrides:
toStructOrUnion in class Type
Returns:
This type as a struct or union.

hasTagged

public boolean hasTagged()
Description copied from class: Type
Determine whether this type is tagged.

Overrides:
hasTagged in class Type
Returns:
true if this type is tagged.

toTagged

public Tagged toTagged()
Description copied from class: Type
Get this type as a tagged type.

Overrides:
toTagged in class Type
Returns:
This type as a tagged type.
See Also:
Type.hasTagged()

resolve

public Type resolve()
Description copied from class: Type
Resolve this type. This method removes any symbolic information, i.e., wrapped types, and returns the underlying, "raw" type.

Overrides:
resolve in class Type
Returns:
The resolved type.

hashCode

public int hashCode()
Get this type's hash code. This method forwards the method invocation to the wrapped type.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.

equals

public boolean equals(java.lang.Object o)
Determine whether this type equals the specified object. This method forwards the method invocation to the wrapped type.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object.
Returns:
true if this type equals the object.


Copyright © 2012. All Rights Reserved.