harpoon.IR.Tree
Class BINOP

java.lang.Object
  extended by harpoon.IR.Tree.Tree
      extended by harpoon.IR.Tree.Exp
          extended by harpoon.IR.Tree.OPER
              extended by harpoon.IR.Tree.BINOP
All Implemented Interfaces:
HCodeElement, Typed

public class BINOP
extends OPER

BINOP objects are expressions which stand for result of applying some binary operator o to a pair of subexpressions.

Version:
$Id: BINOP.java,v 1.5 2003/10/20 04:26:37 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>, based on Modern Compiler Implementation in Java by Andrew Appel.
See Also:
Bop

Nested Class Summary
 
Nested classes/interfaces inherited from class harpoon.IR.Tree.Tree
Tree.CloneCallback
 
Field Summary
 
Fields inherited from class harpoon.IR.Tree.OPER
op, optype
 
Fields inherited from class harpoon.IR.Tree.Tree
arrayFactory, child
 
Fields inherited from interface harpoon.IR.Tree.Typed
DOUBLE, FLOAT, INT, LONG, POINTER
 
Constructor Summary
BINOP(TreeFactory tf, HCodeElement source, int optype, int binop, Exp left, Exp right)
          Constructor.
 
Method Summary
 void accept(TreeVisitor v)
          Accept a visitor
 Exp build(TreeFactory tf, ExpList kids)
           
static Object evalValue(TreeFactory tf, int op, int optype, Object left, Object right)
          Evaluates a constant value for the result of a BINOP, given constant values for the operands.
 Exp getLeft()
          Returns the subexpression of the left-hand side of the operator.
 Exp getRight()
          Returns the subexpression of the right-hand side of the operator.
 int kind()
          Return an integer enumeration of the kind of this Tree.
 Tree rename(TreeFactory tf, TempMap tm, Tree.CloneCallback cb)
          Rename while cloning a subtree.
 void setLeft(Exp left)
          Sets the subexpression of the left-hand side of the operator.
 void setRight(Exp right)
          Sets the subexpression of the right-hand side of the operator.
 String toString()
           
 int type()
          Return result type.
 
Methods inherited from class harpoon.IR.Tree.OPER
operandType
 
Methods inherited from class harpoon.IR.Tree.Exp
build, isDoubleWord, isFloatingPoint
 
Methods inherited from class harpoon.IR.Tree.Tree
clone, clone, getChild, getFactory, getFirstChild, getID, getLineNumber, getParent, getSibling, getSourceFile, hashCode, kids, rename, replace, setChild, unlink
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BINOP

public BINOP(TreeFactory tf,
             HCodeElement source,
             int optype,
             int binop,
             Exp left,
             Exp right)
Constructor.

Parameters:
binop - Enumerated operation type, from Bop.
Method Detail

type

public int type()
Description copied from class: OPER
Return result type.

Specified by:
type in interface Typed
Specified by:
type in class OPER

getLeft

public Exp getLeft()
Returns the subexpression of the left-hand side of the operator.


getRight

public Exp getRight()
Returns the subexpression of the right-hand side of the operator.


setLeft

public void setLeft(Exp left)
Sets the subexpression of the left-hand side of the operator.


setRight

public void setRight(Exp right)
Sets the subexpression of the right-hand side of the operator.


kind

public int kind()
Description copied from class: Tree
Return an integer enumeration of the kind of this Tree. The enumerated values are defined in TreeKind.

Specified by:
kind in class Tree

build

public Exp build(TreeFactory tf,
                 ExpList kids)
Specified by:
build in class Exp

accept

public void accept(TreeVisitor v)
Accept a visitor

Overrides:
accept in class OPER

rename

public Tree rename(TreeFactory tf,
                   TempMap tm,
                   Tree.CloneCallback cb)
Description copied from class: Tree
Rename while cloning a subtree. This node and all child nodes are cloned; the 'temp' information of all TEMP nodes are renamed according to the supplied TempMap. Note that Temps not belonging to this.getFactory().tempFactory() are not affected. The callback() method of the supplied CloneCallback is invoked once on each subtree cloned, starting from the leaves and working back to the root in a post-order depth-first manner.

Specified by:
rename in class Tree

evalValue

public static Object evalValue(TreeFactory tf,
                               int op,
                               int optype,
                               Object left,
                               Object right)
Evaluates a constant value for the result of a BINOP, given constant values for the operands.


toString

public String toString()
Overrides:
toString in class Object