xtc.type
Class Parameter

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.type.Type
          extended by xtc.type.Parameter
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable
Direct Known Subclasses:
InternalParameter, NamedParameter, Wildcard

public abstract class Parameter
extends Type

The superclass of all type parameters. When a type is parameterized, all occurrences of the same parameter should also be the same instance of a subclass. Furthermore, the type should be wrapped in a ParameterizedT listing all parameters. Instantiation of a parameterized type does not require replacing all parameters, but rather should be implemented by wrapping the paramterized type in an InstantiatedT listing all arguments. To support efficient unification, this class implements union/find operations with path compression through the bind(Type) and lookup() operations.

Version:
$Revision: 1.4 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.type.Type
Type.Tag
 
Constructor Summary
Parameter()
          Create a new parameter.
Parameter(Type template)
          Create a new parameter.
 
Method Summary
 void bind(Type type)
          Bind this parameter to the specified type.
 boolean isParameter()
          Determine whether this type is a type parameter.
 Type lookup()
          Look up this parameter's binding.
 Parameter toParameter()
          Get this type as a type parameter.
 
Methods inherited from class xtc.type.Type
addAttribute, annotate, attribute, attribute, attribute, attributes, cast, checkNotSealed, constant, constant, copy, copy, deannotate, getAttribute, getAttribute, getConstant, getConstant, getLanguage, getLanguage, getLocation, getLocation, getScope, getScope, getShape, getShape, hasAlias, hasAnnotated, hasAttribute, hasAttribute, hasAttribute, hasAttribute, hasAttributes, hasConstant, hasConstant, hasEnum, hasEnumerator, hasError, hasInstantiated, hasLanguage, hasLanguage, hasLocation, hasLocation, hasParameterized, hasScope, hasScope, hasShape, hasShape, hasStructOrUnion, hasTag, hasTagged, hasVariable, hasWTag, isAlias, isAnnotated, isArray, isBoolean, isClass, isConcrete, isDerived, isEnum, isEnumerator, isError, isFloat, isFunction, isInstantiated, isInteger, isInterface, isInternal, isInternalParameter, isLabel, isMethod, isNamedParameter, isNumber, isPackage, isParameterized, isPointer, isSealed, isStruct, isTuple, isUnion, isUnit, isVariable, isVariant, isVoid, isWildcard, isWrapped, language, locate, locate, mark, properties, removeAttribute, removeProperty, resolve, resolve, scope, seal, seal, setLocation, setLocation, setProperty, shape, shape, tag, toAlias, toAnnotated, toArray, toBoolean, toClass, toEnum, toEnumerator, toFloat, toFunction, toInstantiated, toInteger, toInterface, toInternal, toInternalParameter, toLabel, toMethod, toNamedParameter, toNumber, toPackage, toParameterized, toPointer, toStruct, toStructOrUnion, toTagged, toTuple, toUnion, toUnit, toVariable, toVariant, toVoid, toWildcard, toWrapped, 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Parameter

public Parameter()
Create a new parameter.


Parameter

public Parameter(Type template)
Create a new parameter.

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

isParameter

public boolean isParameter()
Description copied from class: Type
Determine whether this type is a type parameter.

Overrides:
isParameter in class Type
Returns:
true if this type is a parameter.

toParameter

public Parameter toParameter()
Description copied from class: Type
Get this type as a type parameter.

Overrides:
toParameter in class Type
Returns:
This type as a parameter.

bind

public void bind(Type type)
Bind this parameter to the specified type.

Parameters:
type - The type.
Throws:
java.lang.IllegalStateException - Signals that this parameter is sealed or already bound.

lookup

public Type lookup()
Look up this parameter's binding. If this parameter is not bound, this method returns the parameter. Otherwise, it returns the bound type.

Returns:
This parameter's binding.


Copyright © 2012. All Rights Reserved.