Package gnu.jel
Class OP
java.lang.Object
gnu.jel.OP
public abstract class OP
extends java.lang.Object
A tree node, representing an operation.
- 
Field SummaryFields Modifier and Type Field Description OP[]chiHolds references to children of this nodeintresIDHolds type ID of the result of this OPjava.lang.Class<?>resTypeHolds type of the result of this OPstatic java.lang.Class<?>[]specialTypesClasses of the special types by ID.static byte[]unwrapTypeUnwraps the type ID.
- 
Constructor SummaryConstructors Constructor Description OP()
- 
Method SummaryModifier and Type Method Description abstract voidcompile(ClassFile cf)Called to generate the code implementing this OP.abstract java.lang.Objecteval()Called to evaluate this node and all its sub-nodes.static booleanisWidening(int id1, java.lang.Class<?> c1, int id2, java.lang.Class<?> c2)Used to find out if the conversion t1->t2 is widening.static booleanisWidening(java.lang.Class<?> c1, java.lang.Class<?> c2)Used to find out if the conversion t1->t2 is widening.protected static java.lang.Objectnarrow(java.lang.Number val, int clsID)Narrows the value back to desired primitiva type.static inttypeID(java.lang.Class<?> c)Identifies the primitive type of the given class.static inttypeIDObject(java.lang.Object o)Identify the primitive type corresponding to the given reflection object.protected static java.lang.Numberwiden(java.lang.Object o, int clsID)Makes widest possible representation of a value of Java primitive type.
- 
Field Details- 
chiHolds references to children of this node
- 
resIDpublic int resIDHolds type ID of the result of this OP
- 
resTypepublic java.lang.Class<?> resTypeHolds type of the result of this OP
- 
specialTypespublic static final java.lang.Class<?>[] specialTypesClasses 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. 
- 
unwrapTypepublic static final byte[] unwrapTypeUnwraps the type ID.That is all special types which are references are translated into 8. 
 
- 
- 
Constructor Details- 
OPpublic OP()
 
- 
- 
Method Details- 
evalpublic abstract java.lang.Object eval() throws java.lang.ExceptionCalled to evaluate this node and all its sub-nodes.Upon success this node is to be replaced by the constant node holding the returned object. - Returns:
- an object to which this node evaluates
- Throws:
- java.lang.Exception
 
- 
compileCalled to generate the code implementing this OP.- Parameters:
- cf- class file with a new open method to write the code into.
 
- 
typeIDpublic 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.
 
- 
typeIDObjectpublic 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.
 
- 
isWideningpublic 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)
 
- 
isWideningpublic 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)
 
- 
widenprotected static java.lang.Number widen(java.lang.Object o, int clsID)Makes widest possible representation of a value of Java primitive type.- Parameters:
- o- reflection object, containing value to represent.
- clsID- ID of a type of this reflection object (to save lookup).
- Returns:
- Number, representing the given value.
 
- 
narrowprotected static java.lang.Object narrow(java.lang.Number val, int clsID)Narrows the value back to desired primitiva type.- Parameters:
- val- reflection object, containing value to narrow.
- clsID- ID of a type to narrow the given object into.
- Returns:
- narrowed reflection object.
 
 
-