edu.cmu.cs.crystal.tac.eclipse
Class ReturnInstructionImpl

java.lang.Object
  extended by edu.cmu.cs.crystal.tac.eclipse.ReturnInstructionImpl
All Implemented Interfaces:
ReturnInstruction, TACInstruction

public class ReturnInstructionImpl
extends Object
implements ReturnInstruction

Since:
3.3.2
Author:
Kevin Bierhoff

Constructor Summary
ReturnInstructionImpl(ReturnStatement node, IEclipseVariableQuery tac)
          Creates a return instruction for the given return statement, which must return a value.
 
Method Summary
 E getNode()
          Returns the node this instruction is for.
 Variable getReturnedVariable()
          Returns the variable carrying the value being returned.
 String toString()
           
<LE> IResult<LE>
transfer(ITACBranchSensitiveTransferFunction<LE> tf, List<ILabel> labels, LE value)
          Use this method to transfer over an instruction.
<LE> LE
transfer(ITACTransferFunction<LE> tf, LE value)
          Use this method to transfer over an instruction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.cmu.cs.crystal.tac.model.TACInstruction
getNode
 

Constructor Detail

ReturnInstructionImpl

public ReturnInstructionImpl(ReturnStatement node,
                             IEclipseVariableQuery tac)
Creates a return instruction for the given return statement, which must return a value.

Parameters:
node - Return statement with non-null expression.
tac -
Method Detail

getReturnedVariable

public Variable getReturnedVariable()
Description copied from interface: ReturnInstruction
Returns the variable carrying the value being returned.

Specified by:
getReturnedVariable in interface ReturnInstruction
Returns:
the variable carrying the value being returned.

transfer

public <LE> LE transfer(ITACTransferFunction<LE> tf,
                        LE value)
Use this method to transfer over an instruction. This method performs double-dispatch to call the appropriate transfer method on the transfer function being passed.

Specified by:
transfer in interface TACInstruction
Type Parameters:
LE - Lattice element used in the transfer function.
Parameters:
tf - Transfer function.
value - Incoming lattice value.
Returns:
Outgoing lattice value after transfering over this instruction.

transfer

public <LE> IResult<LE> transfer(ITACBranchSensitiveTransferFunction<LE> tf,
                                 List<ILabel> labels,
                                 LE value)
Use this method to transfer over an instruction. This method performs double-dispatch to call the appropriate transfer method on the transfer function being passed.

Specified by:
transfer in interface TACInstruction
Type Parameters:
LE - Lattice element used in the transfer function.
Parameters:
tf - Transfer function.
labels - Branch labels to consider.
value - Incoming lattice value.
Returns:
Outgoing lattice values for given labels after transfering over this instruction.

toString

public String toString()
Overrides:
toString in class Object

getNode

public E getNode()
Description copied from interface: TACInstruction
Returns the node this instruction is for. Usually, one instruction exists per AST node, but can be more when AST nodes are desugared, such as for post-increment. Subtypes may give more specific information on the type of AST node returned, but more specific typing is not guaranteed due to possible evolution of the Eclipse AST or these interfaces.

Specified by:
getNode in interface TACInstruction
Returns:
The AST node this instruction is for.