OP (JEL API)
Keywords: gnu.jel.OP class

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

## gnu.jel
Class OP

    java.lang.Object
      gnu.jel.OP

Direct Known Subclasses:
  OPbinary, OPcall, OPcondtnl, OPload, OPunary

    public abstract class OP

extends Object

A tree node, representing an operation.

Field Summary
`OP[]` | `chi` Holds references to children of this node
`int` | `resID` Holds type ID of the result of this OP
`Class` | `resType` Holds type of the result of this OP
`static Class[]` | `specialTypes` Classes of the special types by ID.
`static byte[]` | `unwrapType` Unwraps the type ID.

Constructor Summary
`OP()`

Method Summary
`abstract void` | `compile(ClassFile cf)` Called to generate the code implementing this OP.
`abstract Object` | `eval()` Called to evaluate this node and all its sub-nodes.
`static boolean` | `isWidening(Class c1, Class c2)` Used to find out if the conversion t1->t2 is widening.
`static boolean` | `isWidening(int id1, Class c1, int id2, Class c2)` Used to find out if the conversion t1->t2 is widening.
`protected static Object` | `narrow(Number val, int clsID)` Narrows the value back to desired primitiva type.
`static int` | `typeID(Class c)` Identifies the primitive type of the given class.
`static int` | `typeIDObject(Object o)` Identify the primitive type corresponding to the given reflection object.
`protected static Number` | `widen(Object o, int clsID)` Makes widest possible representation of a value of Java primitive type.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### chi

    public OP[] chi

  Holds references to children of this node

### resID

    public int resID

  Holds type ID of the result of this OP

### resType

    public Class resType

  Holds type of the result of this OP

### specialTypes

    public static final 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.

### unwrapType

    public static final byte[] unwrapType

  Unwraps the type ID.

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

Constructor Detail

### OP

    public OP()

Method Detail

### eval

    public abstract Object eval()
                         throws Exception

  Called 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:
    `if` - can't evaluate, in this case the sub-nodes
    `Exception`

### compile

    public abstract void compile(ClassFile cf)

  Called to generate the code implementing this OP.

  Parameters:
    `cf` - class file with a new open method to write the code into.

### typeID

    public static final int typeID(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(Object o)

  Identify the primitive type corresponding to the given reflection object.

  Parameters:
    `o` - object to identify.
  Returns:
    id of the corresponding primitive type.

### isWidening

    public static boolean isWidening(int id1,
                                     Class c1,
                                     int id2,
                                     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)

### isWidening

    public static boolean isWidening(Class c1,
                                     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 Number widen(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.

### narrow

    protected static Object narrow(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.

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

Copyright © 1998-2006 Konstantin L. Metlov All Rights Reserved.