harpoon.IR.Tree
Class CALL

java.lang.Object
  extended by harpoon.IR.Tree.Tree
      extended by harpoon.IR.Tree.Stm
          extended by harpoon.IR.Tree.INVOCATION
              extended by harpoon.IR.Tree.CALL
All Implemented Interfaces:
HCodeElement

public class CALL
extends INVOCATION

CALL objects are statements which stand for java method invocations, using our runtime's calling convention.

The handler expression is a Tree.NAME specifying the label to which we should return from this call if an exception occurs. If the called method throws an exception, the throwable object is placed in the Temp specified by retex and a control tranfer to the Label specified by handler occurs. Note the value in retval is undefined (that is, it may have any value at all) when an "exceptional" return occurs.

If there is no exception thrown by the callee, then the return value is placed in the Temp specified by retval and execution continues normally. The value in retex is undefined (may be given any value) in this case. Note that retval may be null if the called method has void return type.

See also IR.LowQuad.PCALL and IR.Quads.CALL, which have similar execution semantics.

Version:
$Id: CALL.java,v 1.4 2002/04/10 03:05:38 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>, based on Modern Compiler Implementation in Java by Andrew Appel.
See Also:
CALL, INVOCATION, NATIVECALL

Nested Class Summary
 
Nested classes/interfaces inherited from class harpoon.IR.Tree.Tree
Tree.CloneCallback
 
Field Summary
 boolean isTailCall
          Whether this invocation should be performed as a tail call.
 
Fields inherited from class harpoon.IR.Tree.Tree
arrayFactory, child
 
Constructor Summary
CALL(TreeFactory tf, HCodeElement source, TEMP retval, TEMP retex, Exp func, ExpList args, NAME handler, boolean isTailCall)
          Create a CALL object.
 
Method Summary
 void accept(TreeVisitor v)
          Accept a visitor
 Stm build(TreeFactory tf, ExpList kids)
           
 NAME getHandler()
          Returns an expression indicating the destination to which we should return if our caller throws an exception.
 TEMP getRetex()
          Returns the destination expression for any exception which the callee might throw.
 boolean isNative()
           
 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 setHandler(NAME handler)
          Sets the destination to which we should return if our caller throws an exception.
 void setRetex(TEMP retex)
          Sets the destination temp for any exception which the callee might throw.
 String toString()
           
 
Methods inherited from class harpoon.IR.Tree.INVOCATION
getArgs, getFunc, getRetval, kids, setArgs, setFunc, setRetval
 
Methods inherited from class harpoon.IR.Tree.Stm
build, isNop, linearize, toStm
 
Methods inherited from class harpoon.IR.Tree.Tree
clone, clone, getChild, getFactory, getFirstChild, getID, getLineNumber, getParent, getSibling, getSourceFile, hashCode, rename, replace, setChild, unlink
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

isTailCall

public final boolean isTailCall
Whether this invocation should be performed as a tail call.

Constructor Detail

CALL

public CALL(TreeFactory tf,
            HCodeElement source,
            TEMP retval,
            TEMP retex,
            Exp func,
            ExpList args,
            NAME handler,
            boolean isTailCall)
Create a CALL object.

Parameters:
retex - Destination for any exception which the callee might throw. Must be non-null.
handler - Expression indicating the destination to which we should return if our caller throws an exception.
Method Detail

getRetex

public TEMP getRetex()
Returns the destination expression for any exception which the callee might throw. Guaranteed to be non-null.


getHandler

public NAME getHandler()
Returns an expression indicating the destination to which we should return if our caller throws an exception.


setRetex

public void setRetex(TEMP retex)
Sets the destination temp for any exception which the callee might throw. Must be non-null.


setHandler

public void setHandler(NAME handler)
Sets the destination to which we should return if our caller throws an exception.


isNative

public boolean isNative()
Specified by:
isNative in class INVOCATION

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 Stm build(TreeFactory tf,
                 ExpList kids)
Specified by:
build in class Stm

accept

public void accept(TreeVisitor v)
Accept a visitor

Specified by:
accept in class INVOCATION

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

toString

public String toString()
Overrides:
toString in class Object