Package gnu.jel

Class OPbinary

java.lang.Object
gnu.jel.OP
gnu.jel.OPbinary

public class OPbinary
extends OP
A tree node, representing binary operation.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    int code
    code of this operation
    protected static byte[][] promotions
    binary promotions of base types

    Fields inherited from class gnu.jel.OP

    chi, resID, resType, specialTypes, unwrapType
  • Constructor Summary

    Constructors 
    Constructor Description
    OPbinary​(java.util.Stack<OP> paramOPs, int opcode)
    Constructs a new binary operation.
  • Method Summary

    Modifier and Type Method Description
    void compile​(ClassFile cf)
    Called to generate the code implementing this OP.
    java.lang.Object eval()
    Called to evaluate this node and all its sub-nodes.

    Methods inherited from class gnu.jel.OP

    isWidening, isWidening, narrow, typeID, typeIDObject, widen

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • code

      public int code
      code of this operation
    • promotions

      protected static final byte[][] promotions
      binary promotions of base types
  • Constructor Details

    • OPbinary

      public OPbinary​(java.util.Stack<OP> paramOPs, int opcode) throws CompilationException
      Constructs a new binary operation.

      Codes are following:

       0   --  addition
       1   --  substraction
       2   --  multiplication
       3   --  division
       4   --  remainder
       5   --  bitwise AND
       6   --  bitwise OR
       7   --  bitwise and logical XOR
       8   --  comparizon for equality
       9   --  comparizon for non-equality
       10  --  comparizon for "less" <
       11  --  comparizon for "greater or equal" >=
       12  --  comparizon for "greater" >
       13  --  comparizon for "less or equal" <=
       14  --  bitwise left shift <<
       15  --  bitwise right signed shift >>
       16  --  bitwise right unsigned shift >>>
       17  --  logical conjunction operator (AND)
       18  --  logical disjunction operator (OR)
       19  --  array element access operation
       20  --  reserved (used internally for string concatenation)
       
      Parameters:
      paramOPs - stack holding the operands
      opcode - is the operation code
      Throws:
      CompilationException
  • Method Details

    • compile

      public void compile​(ClassFile cf)
      Description copied from class: OP
      Called to generate the code implementing this OP.
      Specified by:
      compile in class OP
      Parameters:
      cf - class file with a new open method to write the code into.
    • eval

      public java.lang.Object eval() throws java.lang.Exception
      Description copied from class: OP
      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.

      Specified by:
      eval in class OP
      Returns:
      an object to which this node evaluates
      Throws:
      java.lang.Exception