gnu.jel
Class TypesStack

java.lang.Object
  |
  +--gnu.jel.TypesStack

public class TypesStack
extends java.lang.Object
implements java.lang.Cloneable

Organizes stack of types, supports type identification and automatically calculates the maximum occupation. Efficiently supports primitive types identification.


Field Summary
protected  int currWords
           
static char[] primitiveCodes
          Java codes for primitive types.
static java.lang.String[] primitiveTypeNames
          Names of the primitive types by ID in readable form.
static java.lang.Class[] primitiveTypes
          Classes of the primitive types by ID.
protected static byte[] stkoccup
           
protected static java.lang.Class string_class
           
protected static java.lang.Class tsb_class
           
 
Constructor Summary
TypesStack()
          Constructs a new empty TypesStack.
 
Method Summary
 java.lang.Object clone()
          Makes a clone of this object.
 int getMaxOccupation()
          Used to get a maximum number of Java words needed to store the stack.
static boolean isString(java.lang.Class c)
          Used to find out if the given class represents a Java string.
static boolean isTSB(java.lang.Class c)
          Used to find out if the given class represents a temporary sttring buffer.
static boolean isWidening(java.lang.Class t1, java.lang.Class t2)
          Used to find out if the conversion t1->t2 is widening.
static boolean isWidening(int it1, int it2)
          Used to find out if the conversion t1->t2 is widening.
static void main(java.lang.String[] args)
          Performs unitary test of this class.
protected static java.lang.Object narrow(java.lang.Number val, int clsID)
           
 java.lang.Class peek()
          Peeks the class on top of the stack without removing it.
 java.lang.Class peek(int i)
          Peeks the class from the body of the stack.
 int peekID()
          Peeks the ID of the class on top of the stack without removing it.
 int peekID(int i)
          Peeks the ID of the class from the body of the stack.
 java.lang.Class pop()
          Pops the top class from the stack.
static int primitiveID(java.lang.Class c)
          Identifies the primitive type of the given class.
static int primitiveID(java.lang.Object o)
          Identify the primitive type corresponding to the given reflection object.
 void push(java.lang.Class c)
          Pushes a given class into stack.
 void push(java.lang.Class cls, int i)
          Adds a new element to the stack at a given position from top of it.
 void pushID(int id)
          Pushes the class representing the primitive type into stack.
 void pushID(int id, java.lang.Class c)
          Pushes the class representing the primitive type into stack.
 void pushID(int id, int i)
          Adds a new element to the stack at a given position from top of it.
 void resetStats()
          Used to adjust maximum stack occupation by a given amount.
 int size()
          Used to determine the number of elements in this stack.
 void tempExcessWords(int nw)
          Used to adjust maximum stack occupation by a given amount.
static void test(Tester t)
          Performs unitary test of this class.
protected static java.lang.Number widen(java.lang.Object o, int clsID)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tsb_class

protected static java.lang.Class tsb_class

string_class

protected static java.lang.Class string_class

primitiveTypes

public static final java.lang.Class[] primitiveTypes
Classes of the primitive types by ID.

primitiveCodes

public static final char[] primitiveCodes
Java codes for primitive types.

primitiveTypeNames

public static final java.lang.String[] primitiveTypeNames
Names of the primitive types by ID in readable form.

stkoccup

protected static final byte[] stkoccup

currWords

protected int currWords
Constructor Detail

TypesStack

public TypesStack()
Constructs a new empty TypesStack.
Method Detail

primitiveID

public static final int primitiveID(java.lang.Class c)
Identifies the primitive type of the given class.
Parameters:
c - class to identify.
Returns:
id of the corresponding primitive type.

primitiveID

public static final int primitiveID(java.lang.Object o)
Identify the primitive type corresponding to the given reflection object.
Parameters:
o - object to identify.
Returns:
id of the corresponding primitive type.

clone

public java.lang.Object clone()
Makes a clone of this object.
Overrides:
clone in class java.lang.Object
Returns:
a clone of this object

peek

public final java.lang.Class peek()
Peeks the class on top of the stack without removing it.
Returns:
class on top of the stack.

peekID

public final int peekID()
Peeks the ID of the class on top of the stack without removing it.
Returns:
ID of the class on top of the stack.

peek

public final java.lang.Class peek(int i)
Peeks the class from the body of the stack.
Parameters:
i - number of the class to peek (0 means the top of the stack)
Returns:
class number i from the top of the stack.

peekID

public final int peekID(int i)
Peeks the ID of the class from the body of the stack.
Parameters:
i - number of the class to peek (0-peek)
Returns:
ID of the class number i from the top of the stack.

pop

public final java.lang.Class pop()
Pops the top class from the stack.
Returns:
class formerly on top of the stack.

pushID

public final void pushID(int id,
                         java.lang.Class c)
Pushes the class representing the primitive type into stack.

pushID

public final void pushID(int id)
Pushes the class representing the primitive type into stack.

push

public final void push(java.lang.Class c)
Pushes a given class into stack.

push

public final void push(java.lang.Class cls,
                       int i)
Adds a new element to the stack at a given position from top of it.
Parameters:
cls - class to add
i - position of new element from the top of the stack (0 -- push)

pushID

public final void pushID(int id,
                         int i)
Adds a new element to the stack at a given position from top of it.
Parameters:
id - ID of the class to add
i - position of new element from the top of the stack (0 -- push)

size

public final int size()
Used to determine the number of elements in this stack.
Returns:
the number of elements in this stack.

resetStats

public final void resetStats()
Used to adjust maximum stack occupation by a given amount.

This method is called when there were data pushed on top of Java stack bypassing this class.


tempExcessWords

public final void tempExcessWords(int nw)
Used to adjust maximum stack occupation by a given amount.

This method is called when there were data pushed on top of Java stack bypassing this class.


getMaxOccupation

public final int getMaxOccupation()
Used to get a maximum number of Java words needed to store the stack.
Returns:
number of words.

isWidening

public static boolean isWidening(java.lang.Class t1,
                                 java.lang.Class t2)
Used to find out if the conversion t1->t2 is widening.
Parameters:
t1 - type to convert from
t2 - type to convert to
Returns:
true if the given conversion is widening

isWidening

public static boolean isWidening(int it1,
                                 int it2)
Used to find out if the conversion t1->t2 is widening.
Parameters:
it1 - type ID to convert from
it2 - type ID to convert to
Returns:
true if the given conversion is widening

isString

public static boolean isString(java.lang.Class c)
Used to find out if the given class represents a Java string.
Parameters:
c - class to check
Returns:
true if this class is a string

isTSB

public static boolean isTSB(java.lang.Class c)
Used to find out if the given class represents a temporary sttring buffer.
Parameters:
c - class to check
Returns:
true if this class is a temporary string buffer.

widen

protected static java.lang.Number widen(java.lang.Object o,
                                        int clsID)

narrow

protected static java.lang.Object narrow(java.lang.Number val,
                                         int clsID)

main

public static void main(java.lang.String[] args)
Performs unitary test of this class.
Parameters:
args - ignored.

test

public static void test(Tester t)
Performs unitary test of this class.

Used if all package is being tested and not just codegen.

Parameters:
t - Tester to report test results.