xtc.type
Class ArrayT

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.type.Type
          extended by xtc.type.DerivedT
              extended by xtc.type.ArrayT
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable

public class ArrayT
extends DerivedT

An array type. An array can either be of fixed or variable length, with a length of -1 indicating that a fixed length array is incomplete.

Version:
$Revision: 1.40 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.type.Type
Type.Tag
 
Constructor Summary
ArrayT(Type type)
          Create a new, incomplete array type.
ArrayT(Type type, boolean varlength)
          Create a new variable length array.
ArrayT(Type type, long length)
          Create a new array type.
ArrayT(Type template, Type type, boolean varlength, long length)
          Create a new array type.
 
Method Summary
 ArrayT copy()
          Create a deep copy of this type.
 boolean equals(java.lang.Object o)
           
 long getLength()
          Get the length.
 Type getType()
          Get the element type.
 int hashCode()
           
 boolean hasLength()
          Determine whether this array has a length.
 boolean isArray()
          Determine whether this type is an array.
 boolean isVarLength()
          Determine whether the array is of variable length.
 Type seal()
          Seal this type.
 void setLength(long length)
          Set the length.
 void setVarLength(boolean varlength)
          Set the variable length flag.
 Type.Tag tag()
          Get this type's tag.
 ArrayT toArray()
          Get this type as an array.
 void write(java.lang.Appendable out)
          Write a human readable representation to the specified appendable.
 
Methods inherited from class xtc.type.DerivedT
isDerived
 
Methods inherited from class xtc.type.Type
addAttribute, annotate, attribute, attribute, attribute, attributes, cast, checkNotSealed, constant, constant, 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, isBoolean, isClass, isConcrete, 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, isWrapped, language, locate, locate, mark, properties, removeAttribute, removeProperty, resolve, resolve, scope, seal, setLocation, setLocation, setProperty, shape, shape, toAlias, toAnnotated, toBoolean, toClass, toEnum, toEnumerator, toFloat, toFunction, toInstantiated, toInteger, toInterface, toInternal, toInternalParameter, toLabel, toMethod, toNamedParameter, toNumber, toPackage, toParameter, 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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayT

public ArrayT(Type type)
Create a new, incomplete array type.

Parameters:
type - The element type.

ArrayT

public ArrayT(Type type,
              boolean varlength)
Create a new variable length array.

Parameters:
type - The element type.
varlength - The flag for whether this array is of variable length, which must be true.

ArrayT

public ArrayT(Type type,
              long length)
Create a new array type.

Parameters:
type - The element type.
length - The length.

ArrayT

public ArrayT(Type template,
              Type type,
              boolean varlength,
              long length)
Create a new array type.

Parameters:
template - The type whose annotations to copy.
type - The element type.
varlength - The flag for whether this array is variable.
length - The length.
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)

copy

public ArrayT copy()
Description copied from class: Type
Create a deep copy of this type. The resulting type is not sealed.

Specified by:
copy in class Type
Returns:
A deep copy of this type.

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()

isArray

public boolean isArray()
Description copied from class: Type
Determine whether this type is an array.

Overrides:
isArray in class Type
Returns:
true if this type is an array.

toArray

public ArrayT toArray()
Description copied from class: Type
Get this type as an array.

Overrides:
toArray in class Type
Returns:
This type as an array.

getType

public Type getType()
Get the element type.

Returns:
The element type.

isVarLength

public boolean isVarLength()
Determine whether the array is of variable length.

Returns:
true if this array is variable length.

setVarLength

public void setVarLength(boolean varlength)
Set the variable length flag.

Parameters:
varlength - The variable length flag.
Throws:
java.lang.IllegalStateException - Signals that this type is sealed.

hasLength

public boolean hasLength()
Determine whether this array has a length.

Returns:
true if this array has a length.

getLength

public long getLength()
Get the length.

Returns:
The length or -1 if this type is either of variable length or incomplete.

setLength

public void setLength(long length)
Set the length.

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

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

write

public void write(java.lang.Appendable out)
           throws java.io.IOException
Description copied from class: Node
Write a human readable representation to the specified appendable. If this node supports generic traversal, the default implementation writes this node in algebraic term-format; otherwise, it writes the string returned by Object.toString().

Overrides:
write in class Node
Parameters:
out - The appendable.
Throws:
java.io.IOException - Signals an I/O error.


Copyright © 2012. All Rights Reserved.