xtc.type
Class FunctionOrMethodT

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.type.Type
          extended by xtc.type.DerivedT
              extended by xtc.type.FunctionOrMethodT
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable
Direct Known Subclasses:
FunctionT, MethodT

public abstract class FunctionOrMethodT
extends DerivedT

The superclass of function and method types.

Version:
$Revision: 1.22 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.type.Type
Type.Tag
 
Field Summary
protected  java.util.List<Type> exceptions
          The optional list of exceptions.
protected  java.lang.String name
          The optional name.
protected  java.util.List<Type> parameters
          The list of parameter types.
protected  Type result
          The result type.
protected  boolean varargs
          The flag for whether the function accepts a variable number of arguments.
 
Constructor Summary
FunctionOrMethodT(Type template, Type result, java.lang.String name, java.util.List<Type> parameters, boolean varargs, java.util.List<Type> exceptions)
          Create a new function or method type.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.util.List<Type> getExceptions()
          Get the list of exceptions.
 java.lang.String getName()
          Get the name.
 java.util.List<Type> getParameters()
          Get the list of parameter types.
 Type getResult()
          Get the result type.
 int hashCode()
           
 boolean isVarArgs()
          Determine whether this function accepts a variable number of arguments.
 Type seal()
          Seal this type.
 void setExceptions(java.util.List<Type> exceptions)
          Set the list of parameter types.
 void setParameters(java.util.List<Type> parameters)
          Set the list of parameter types.
 void setResult(Type result)
          Set the result type.
 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, 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, 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, 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, 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
 

Field Detail

result

protected Type result
The result type.


name

protected java.lang.String name
The optional name.


parameters

protected java.util.List<Type> parameters
The list of parameter types.


varargs

protected boolean varargs
The flag for whether the function accepts a variable number of arguments.


exceptions

protected java.util.List<Type> exceptions
The optional list of exceptions.

Constructor Detail

FunctionOrMethodT

public FunctionOrMethodT(Type template,
                         Type result,
                         java.lang.String name,
                         java.util.List<Type> parameters,
                         boolean varargs,
                         java.util.List<Type> exceptions)
Create a new function or method type.

Parameters:
template - The type whose annotations to copy.
result - The result type.
name - The name.
parameters - The list of parameter types.
varargs - The flag for accepting a variable number of arguments.
exceptions - The list of exception types.
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)

getResult

public Type getResult()
Get the result type.

Returns:
The result type.

setResult

public void setResult(Type result)
Set the result type.

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

getName

public java.lang.String getName()
Get the name.

Overrides:
getName in class Node
Returns:
The name.

getParameters

public java.util.List<Type> getParameters()
Get the list of parameter types.

Returns:
The parameter types.

setParameters

public void setParameters(java.util.List<Type> parameters)
Set the list of parameter types.

Parameters:
parameters - The list of parameter types.
Throws:
java.lang.IllegalStateException - Signals that this type is sealed.

isVarArgs

public boolean isVarArgs()
Determine whether this function accepts a variable number of arguments.

Returns:
true if this function accepts a variable number of arguments.

getExceptions

public java.util.List<Type> getExceptions()
Get the list of exceptions.

Returns:
The list of exceptions.

setExceptions

public void setExceptions(java.util.List<Type> exceptions)
Set the list of parameter types.

Parameters:
exceptions - The list of exception types.
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.