: Class TypesStack

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gnu.jel
Class TypesStack

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

All Implemented Interfaces:
  java.lang.Cloneable

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
`static byte[]` | `baseType` Translates the type ID into the Java base type ID.
`protected int` | `currWords`
`static char[]` | `primitiveCodes` Java codes for base types by base ID.
`static java.lang.Class[]` | `specialTypes` Classes of the special types by ID.
`protected static byte[]` | `stkoccup`
`static byte[]` | `unwrapType` Translates the type ID into the Java base type ID.

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` | `isIntegral(int id1)`
`static boolean` | `isWidening(java.lang.Class c1, java.lang.Class c2)` Used to find out if the conversion t1->t2 is widening.
`static boolean` | `isWidening(int id1, java.lang.Class c1, int id2, java.lang.Class c2)` 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.
`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 special type into stack.
`void` | `pushID(int id, java.lang.Class c)` Pushes the class with given typeID into stack.
`void` | `pushID(int id, int i)` Adds a special type to the stack at a given position from top of it.
`void` | `resetStats()` Resets maximum stack occupation statistics.
`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.
`static int` | `typeID(java.lang.Class c)` Identifies the primitive type of the given class.
`static int` | `typeIDObject(java.lang.Object o)` Identify the primitive type corresponding to the given reflection object.
`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

### specialTypes

    public static final java.lang.Class[] specialTypes

  Classes of the special types by ID.

  The frequently used types (those on which many operations are defined) are identified by an integer number. The advantage is the possibility to have almost completely table driven code generator.

  So, the special types are only special in the fact that except of the reference to their class object they are also identified by an integer number.

### baseType

    public static final byte[] baseType

  Translates the type ID into the Java base type ID.

  That is all special types which are references are translated into 8.

### unwrapType

    public static final byte[] unwrapType

  Translates the type ID into the Java base type ID.

  That is all special types which are references are translated into 8.

### primitiveCodes

    public static final char[] primitiveCodes

  Java codes for base types by base ID.

### stkoccup

    protected static final byte[] stkoccup

### currWords

    protected int currWords

Constructor Detail

### TypesStack

    public TypesStack()

  Constructs a new empty TypesStack.

Method Detail

### typeID

    public static final int typeID(java.lang.Class c)

  Identifies the primitive type of the given class.
  Parameters:
    `c` - class to identify.
  Returns:
    id of the corresponding primitive type.

### typeIDObject

    public static final int typeIDObject(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 with given typeID into stack.

### pushID

    public final void pushID(int id)

  Pushes the class representing the special 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 special type 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()

  Resets maximum stack occupation statistics.

  Should be called when this stack is reused for another method.

### 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(int id1,
                                     java.lang.Class c1,
                                     int id2,
                                     java.lang.Class c2)

  Used to find out if the conversion t1->t2 is widening.
  Parameters:
    `id1` - type ID to convert from
    `c1` - class to convert from (used if id1==8)
    `id2` - type ID to convert to
    `c2` - class to convert to (used if id2==8)
  Returns:
    true if the given conversion is widening (can be done automatically)

### isIntegral

    public static boolean isIntegral(int id1)

### isWidening

    public static boolean isWidening(java.lang.Class c1,
                                     java.lang.Class c2)

  Used to find out if the conversion t1->t2 is widening.
  Parameters:
    `c1` - class to convert from (used if id1==8)
    `c2` - class to convert to (used if id2==8)
  Returns:
    true if the given conversion is widening (can be done automatically)

### 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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD