xtc.type
Class StructOrUnionT

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.type.Type
          extended by xtc.type.DerivedT
              extended by xtc.type.StructOrUnionT
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable, Tagged
Direct Known Subclasses:
StructT, UnionT

public abstract class StructOrUnionT
extends DerivedT
implements Tagged

The superclass of struct and union types.

Version:
$Revision: 1.42 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.type.Type
Type.Tag
 
Field Summary
protected  java.util.List<VariableT> members
          The list of members represents as VariableT.
protected  java.lang.String name
          The name.
protected  Nonce nonce
          The nonce.
 
Constructor Summary
StructOrUnionT(Type template, Nonce nonce, java.lang.String name, java.util.List<VariableT> members)
          Create a new struct or union type.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determine whether this type equals the specified object.
 VariableT getMember(int index)
          Get the member with the specified index.
 int getMemberCount()
          Get the number of members.
 java.util.List<VariableT> getMembers()
          Get the members of the tagged type.
 java.lang.String getName()
          Get the name of this node.
 Nonce getNonce()
          Get this tagged type's nonce.
 int hashCode()
           
 boolean hasName(java.lang.String name)
          Determine whether this node's name is the same as the specified name.
 boolean hasTagged()
          Determine whether this type is tagged.
 boolean isUnnamed()
          Determine whether this tagged type is unnamed.
 Type lookup(java.lang.String name)
          Look up the member with the specified name.
 Type seal()
          Seal this struct or union.
 void setMembers(java.util.List<VariableT> members)
          Set the members.
 StructOrUnionT toStructOrUnion()
          Get this type as a struct or union.
 Tagged toTagged()
          Get this type as a tagged type.
 
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, 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, hasVariable, hasWTag, isAlias, isAnnotated, isArray, 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, tag, toAlias, toAnnotated, toArray, toBoolean, toClass, toEnum, toEnumerator, toFloat, toFunction, toInstantiated, toInteger, toInterface, toInternal, toInternalParameter, toLabel, toMethod, toNamedParameter, toNumber, toPackage, toParameter, toParameterized, toPointer, toStruct, 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, getNode, getProperty, getString, getStringProperty, getTokenText, 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
 
Methods inherited from interface xtc.type.Tagged
isEnum, isStruct, isUnion
 

Field Detail

nonce

protected final Nonce nonce
The nonce.


name

protected final java.lang.String name
The name.


members

protected java.util.List<VariableT> members
The list of members represents as VariableT.

Constructor Detail

StructOrUnionT

public StructOrUnionT(Type template,
                      Nonce nonce,
                      java.lang.String name,
                      java.util.List<VariableT> members)
Create a new struct or union type.

Parameters:
template - The type whose annotations to copy.
nonce - The nonce.
name - The name.
members - The members.
Throws:
java.lang.NullPointerException - Signals a null name.
Method Detail

seal

public Type seal()
Seal this struct or union. If this struct or union is incomplete, i.e., does not have any members, invocations to this method have no effect.

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

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

getNonce

public Nonce getNonce()
Description copied from interface: Tagged
Get this tagged type's nonce. The nonce is used to determine equality of tagged types while still allowing for several type instances.

Specified by:
getNonce in interface Tagged
Returns:
The nonce.

isUnnamed

public boolean isUnnamed()
Description copied from interface: Tagged
Determine whether this tagged type is unnamed. Note that an unnamed tagged type still has a name of the form tag(nonce).

Specified by:
isUnnamed in interface Tagged
Returns:
true if this tagged type is unnamed.

hasName

public boolean hasName(java.lang.String name)
Description copied from class: Node
Determine whether this node's name is the same as the specified name.

User-specified classes must not override this method.

Specified by:
hasName in interface Tagged
Overrides:
hasName in class Node
Parameters:
name - The name.
Returns:
true if this node's name equals the specified name.

getName

public java.lang.String getName()
Description copied from class: Node
Get the name of this node. For strongly typed nodes, the name is implicitly specified by the node's class. For generic nodes, the name is the generic node's explicit name. The default implementation returns the node's class name.

User-specified classes must not override this method.

Specified by:
getName in interface Tagged
Overrides:
getName in class Node
Returns:
The name.

lookup

public Type lookup(java.lang.String name)
Description copied from interface: Tagged
Look up the member with the specified name. If this type is a struct or union and has any unnnamed struct or union fields, this method also tries to look up the name in the unnamed struct or union.

Specified by:
lookup in interface Tagged
Parameters:
name - The name.
Returns:
The type or ErrorT.TYPE if the tagged type has no such member.

getMemberCount

public int getMemberCount()
Description copied from interface: Tagged
Get the number of members. For struct and union types, the returned count excludes any anonymous bit-fields. It also excludes the individual members of an unnamed struct or union member.

Specified by:
getMemberCount in interface Tagged
Returns:
The number of members or -1 if this type is incomplete.

getMember

public VariableT getMember(int index)
Description copied from interface: Tagged
Get the member with the specified index. For struct and union types, anonymous bit-fields are not considered.

Specified by:
getMember in interface Tagged
Parameters:
index - The index.
Returns:
The corresponding member.

getMembers

public java.util.List<VariableT> getMembers()
Description copied from interface: Tagged
Get the members of the tagged type.

Specified by:
getMembers in interface Tagged
Returns:
The list of members or null if this type is incomplete.

setMembers

public void setMembers(java.util.List<VariableT> members)
Set the members.

Parameters:
members - The members.
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)
Determine whether this type equals the specified object. A struct or union equals the specified object if the specified object is a struct or union with the same nonce.

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


Copyright © 2012. All Rights Reserved.