|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gnu.jel.TypesStack
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 java.lang.Class[] |
getParameterTypes(java.lang.reflect.Member m)
Used to get types of formal parameters of a member. |
static java.lang.String |
getSignature(java.lang.Class cls)
Computes the signature of the given class. |
static java.lang.String |
getSignature(java.lang.reflect.Member m)
Computes signature of the given member. |
static java.lang.Class |
getType(java.lang.reflect.Member m)
Used to get return type of a class member. |
static boolean |
isField(java.lang.reflect.Member m)
|
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. |
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 java.lang.String |
toHistoricalForm(java.lang.String className)
|
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 |
public static final java.lang.Class[] specialTypes
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.
public static final byte[] baseType
That is all special types which are references are translated into 8.
public static final byte[] unwrapType
That is all special types which are references are translated into 8.
public static final char[] primitiveCodes
protected static final byte[] stkoccup
protected int currWords
Constructor Detail |
public TypesStack()
Method Detail |
public static final int typeID(java.lang.Class c)
c
- class to identify.public static final int typeIDObject(java.lang.Object o)
o
- object to identify.public java.lang.Object clone()
clone
in class java.lang.Object
public final java.lang.Class peek()
public final int peekID()
public final java.lang.Class peek(int i)
i
- number of the class to peek (0 means the top of the stack)public final int peekID(int i)
i
- number of the class to peek (0-peek)public final java.lang.Class pop()
public final void pushID(int id, java.lang.Class c)
public final void pushID(int id)
public final void push(java.lang.Class c)
public final void push(java.lang.Class cls, int i)
cls
- class to addi
- position of new element from the top of the stack (0 -- push)public final void pushID(int id, int i)
id
- ID of the class to addi
- position of new element from the top of the stack (0 -- push)public final int size()
public final void resetStats()
Should be called when this stack is reused for another method.
public final void tempExcessWords(int nw)
This method is called when there were data pushed on top of Java stack bypassing this class.
public final int getMaxOccupation()
public static boolean isWidening(int id1, java.lang.Class c1, int id2, java.lang.Class c2)
id1
- type ID to convert fromc1
- class to convert from (used if id1==8)id2
- type ID to convert toc2
- class to convert to (used if id2==8)public static boolean isIntegral(int id1)
public static boolean isWidening(java.lang.Class c1, java.lang.Class c2)
c1
- class to convert from (used if id1==8)c2
- class to convert to (used if id2==8)protected static java.lang.Number widen(java.lang.Object o, int clsID)
protected static java.lang.Object narrow(java.lang.Number val, int clsID)
public static java.lang.Class getType(java.lang.reflect.Member m)
The type of a Method is its return type, the type of a Constructor is void.
m
- member whose type is to be determinedpublic static java.lang.Class[] getParameterTypes(java.lang.reflect.Member m)
The reference to the class instance "this" is not counted by this method.
m
- member whose formal parameters are to be obtainedpublic static java.lang.String getSignature(java.lang.reflect.Member m)
m
- the member to compute the sugnature of.public static boolean isField(java.lang.reflect.Member m)
public static java.lang.String getSignature(java.lang.Class cls)
The signature of the class (Field descriptor) is the string and it's format is described in the paragraph 4.3.2 of the Java VM specification (ISBN 0-201-63451-1).
The same can be done using java.lang.Class.getName() by converting it's result into the "historical form".
This utility method can be used outside of the JEL package it does not involve any JEL specific assumptions and should follow JVM Specification precisely.
cls
- is the class to compute the signature of. Can be primitive or
array type.public static java.lang.String toHistoricalForm(java.lang.String className)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |