xtc.type
Class NumberT

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.type.Type
          extended by xtc.type.NumberT
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable
Direct Known Subclasses:
FloatT, IntegerT

public abstract class NumberT
extends Type

The superclass of all number types.

Version:
$Revision: 1.27 $
Author:
Robert Grimm

Nested Class Summary
static class NumberT.Kind
          The number kind.
 
Nested classes/interfaces inherited from class xtc.type.Type
Type.Tag
 
Field Summary
static IntegerT BYTE
          The canonical signed byte type.
static IntegerT CHAR
          The canonical char type.
static FloatT DOUBLE
          The canonical double type.
static FloatT DOUBLE_COMPLEX
          The canonical double complex type.
static FloatT FLOAT
          The canonical float type.
static FloatT FLOAT_COMPLEX
          The canonical float complex type.
static IntegerT INT
          The canonical int type.
protected  NumberT.Kind kind
          The kind.
static IntegerT LONG
          The canonical signed long type.
static FloatT LONG_DOUBLE
          The canonical long double type.
static FloatT LONG_DOUBLE_COMPLEX
          The canonical long double complex type.
static IntegerT LONG_LONG
          The canonical signed long long type.
static IntegerT S_CHAR
          The canonical signed char type.
static IntegerT S_INT
          The canonical signed int type.
static IntegerT SHORT
          The canonical short type.
static IntegerT U_CHAR
          The canonical unsigned char type.
static IntegerT U_INT
          The cannical unsigned int type.
static IntegerT U_LONG
          The canonical unsigned long type.
static IntegerT U_LONG_LONG
          The canonical unsigned long long type.
static IntegerT U_SHORT
          The canonical unsigned short type.
 
Constructor Summary
NumberT(NumberT.Kind kind)
          Create a new number type.
NumberT(Type template, NumberT.Kind kind)
          Create a new number type.
 
Method Summary
static boolean equal(NumberT.Kind k1, NumberT.Kind k2)
          Determine whether the specified kinds equal each other.
static boolean equalIgnoringSign(NumberT.Kind k1, NumberT.Kind k2)
          Determine whether the specified kinds equal each other, modulo their signs.
 boolean equals(java.lang.Object o)
          Determine whether this type equals the specified object.
 NumberT.Kind getKind()
          Get the kind.
 int hashCode()
           
 boolean hasKind(NumberT.Kind kind)
          Determine whether this number has the specified kind.
 boolean isNumber()
          Determine whether this type is a number.
 boolean isSigned()
          Determine whether this number is signed.
 NumberT toNumber()
          Get this type as a number.
 java.lang.String toString()
          Return a human readable representation of this node.
 void write(java.lang.Appendable out)
          Write a human readable representation to the specified appendable.
 
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, 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, seal, setLocation, setLocation, setProperty, shape, shape, tag, toAlias, toAnnotated, toArray, toBoolean, toClass, toEnum, toEnumerator, toFloat, toFunction, toInstantiated, toInteger, toInterface, toInternal, toInternalParameter, toLabel, toMethod, toNamedParameter, 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, toToken
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BYTE

public static final IntegerT BYTE
The canonical signed byte type.


CHAR

public static final IntegerT CHAR
The canonical char type.


S_CHAR

public static final IntegerT S_CHAR
The canonical signed char type.


U_CHAR

public static final IntegerT U_CHAR
The canonical unsigned char type.


SHORT

public static final IntegerT SHORT
The canonical short type.


U_SHORT

public static final IntegerT U_SHORT
The canonical unsigned short type.


INT

public static final IntegerT INT
The canonical int type.


S_INT

public static final IntegerT S_INT
The canonical signed int type.


U_INT

public static final IntegerT U_INT
The cannical unsigned int type.


LONG

public static final IntegerT LONG
The canonical signed long type.


U_LONG

public static final IntegerT U_LONG
The canonical unsigned long type.


LONG_LONG

public static final IntegerT LONG_LONG
The canonical signed long long type.


U_LONG_LONG

public static final IntegerT U_LONG_LONG
The canonical unsigned long long type.


FLOAT

public static final FloatT FLOAT
The canonical float type.


DOUBLE

public static final FloatT DOUBLE
The canonical double type.


LONG_DOUBLE

public static final FloatT LONG_DOUBLE
The canonical long double type.


FLOAT_COMPLEX

public static final FloatT FLOAT_COMPLEX
The canonical float complex type.


DOUBLE_COMPLEX

public static final FloatT DOUBLE_COMPLEX
The canonical double complex type.


LONG_DOUBLE_COMPLEX

public static final FloatT LONG_DOUBLE_COMPLEX
The canonical long double complex type.


kind

protected final NumberT.Kind kind
The kind.

Constructor Detail

NumberT

public NumberT(NumberT.Kind kind)
Create a new number type. The specified kind must be a valid integer or float kind.

Parameters:
kind - The kind.

NumberT

public NumberT(Type template,
               NumberT.Kind kind)
Create a new number type. The specified kind must be a valid integer or float kind.

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

isNumber

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

Overrides:
isNumber in class Type
Returns:
true if this type is a number.

toNumber

public NumberT toNumber()
Description copied from class: Type
Get this type as a number.

Overrides:
toNumber in class Type
Returns:
This type as a number.

hasKind

public boolean hasKind(NumberT.Kind kind)
Determine whether this number has the specified kind. Note that this method uses equal(Kind,Kind) to perform the kind comparison.

Parameters:
kind - The kind.
Returns:
true if this number has the specified kind.

getKind

public NumberT.Kind getKind()
Get the kind.

Returns:
The kind.

isSigned

public boolean isSigned()
Determine whether this number is signed.

Returns:
true if this number is signed.

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. This number equals the specified object if the specified object also is a number and the two numbers' kinds are either the same or a combination of the int and signed int kinds.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object.
Returns:
true if this type equals the 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.

toString

public java.lang.String toString()
Description copied from class: Node
Return a human readable representation of this node. The default implementation creates a new string builder, writes this node to the builder, and then returns the corresponding string. Subclasses should typically override Node.write(Appendable).

Overrides:
toString in class Node
Returns:
A human readable representation.

equal

public static boolean equal(NumberT.Kind k1,
                            NumberT.Kind k2)
Determine whether the specified kinds equal each other. This method treats implicit, int, and signed int types as equal.

Parameters:
k1 - The first kind.
k2 - The second kind.
Returns:
true if the kinds are equal.

equalIgnoringSign

public static boolean equalIgnoringSign(NumberT.Kind k1,
                                        NumberT.Kind k2)
Determine whether the specified kinds equal each other, modulo their signs. This method treats implicit, int, and signed int types as equal.

Parameters:
k1 - The first kind.
k2 - The second kind.
Returns:
true if the kinds are equal modulo their signs.


Copyright © 2012. All Rights Reserved.