soot.shimple
Interface PhiExpr

All Known Implementing Classes:
SPhiExpr

public interface PhiExpr
extends Expr, UnitBoxOwner

A fully defined PhiExpr usually consists of a list of Values for the arguments alongst with the corresponding control flow predecessor for each argument. This may be provided either as a Soot CFG Block or more directly as the Unit at the end of the corresponding CFG block.

As much as possible we try to conform to the semantics as described by Cytron et al., TOPLAS Oct. 91. A Phi node such as "x_1 = Phi(x_2, x_3)" is eliminated by respectively adding the statements "x_1 = x_2" and "x_1 = x_3" at the end of the corresponding control flow predecessor.

However, due to the fact that each argument is explicitly associated with the control flow predecessor, there may be some subtle differences. We tried to make the behaviour as robust and transparent as possible by handling the common cases of Unit chain manipulations in the Shimple internal implementation of PatchingChain.

See Also:
Efficiently Computing Static Single Assignment Form and the Control Dependence Graph, Shimple.newPhiExpr(List, List), Shimple.newPhiExpr(Local, List)

Method Summary
 boolean addArg(Value arg, Block pred)
          Add the given argument associated with the given CFG predecessor.
 boolean addArg(Value arg, Unit predTailUnit)
          Add the given argument associated with the given CFG predecessor.
 void apply(Switch sw)
          Called when this object is visited.
 ValueUnitPair getArgBox(Block pred)
          Returns the argument pair corresponding to the given CFG predecessor.
 ValueUnitPair getArgBox(int index)
          Returns the argument pair for the given index.
 ValueUnitPair getArgBox(Unit predTailUnit)
          Returns the argument pair corresponding to the given CFG predecessor.
 int getArgCount()
          Returns the number of arguments in this PhiExpr.
 int getArgIndex(Block pred)
          Returns the index of the argument associated with the given control flow predecessor.
 int getArgIndex(Unit predTailUnit)
          Returns the index of the argument associated with the given control flow predecessor Unit.
 java.util.List getArgs()
          Returns an unmodifiable, backed view of the arguments to this PhiExpr.
 Unit getPred(int index)
          Returns the control flow predecessor Unit for the given index into the PhiExpr.
 java.util.List getPreds()
          Returns a list of the control flow predecessor Units being tracked by this PhiExpr
 Type getType()
          The type of the PhiExpr is usually the same as the type of its arguments.
 Value getValue(Block pred)
          Get the PhiExpr argument corresponding to the given control flow predecessor, returns null if not available.
 Value getValue(int index)
          Returns the value for the given index into the PhiExpr.
 Value getValue(Unit predTailUnit)
          Get the PhiExpr argument corresponding to the given control flow predecessor, returns null if not available.
 java.util.List getValues()
          Returns a list of the values used by this PhiExpr.
 boolean removeArg(Block pred)
          Remove the argument corresponding to the given CFG predecessor.
 boolean removeArg(int index)
          Remove the argument at the given index.
 boolean removeArg(Unit predTailUnit)
          Remove the argument corresponding to the given CFG predecessor.
 boolean removeArg(ValueUnitPair arg)
          Remove the given argument.
 boolean setArg(int index, Value arg, Block pred)
          Modify the PhiExpr argument at the given index with the given information.
 boolean setArg(int index, Value arg, Unit predTailUnit)
          Modify the PhiExpr argument at the given index with the given information.
 boolean setPred(int index, Block pred)
          Update the CFG predecessor associated with the PhiExpr argument at the given index.
 boolean setPred(int index, Unit predTailUnit)
          Update the CFG predecessor associated with the PhiExpr argument at the given index.
 boolean setValue(Block pred, Value arg)
          Locate the argument assocatiated with the given CFG predecessor and set the value.
 boolean setValue(int index, Value arg)
          Set the value at the given index into the PhiExpr.
 boolean setValue(Unit predTailUnit, Value arg)
          Locate the argument assocatiated with the given CFG predecessor unit and set the value.
 
Methods inherited from interface soot.UnitBoxOwner
getUnitBoxes
 
Methods inherited from interface soot.Value
clone, getUseBoxes, toString
 
Methods inherited from interface soot.EquivTo
equivHashCode, equivTo
 

Method Detail

getArgs

public java.util.List getArgs()
Returns an unmodifiable, backed view of the arguments to this PhiExpr. Each argument is a ValueUnitPair.
See Also:
ValueUnitPair

getValues

public java.util.List getValues()
Returns a list of the values used by this PhiExpr.

getPreds

public java.util.List getPreds()
Returns a list of the control flow predecessor Units being tracked by this PhiExpr

getArgCount

public int getArgCount()
Returns the number of arguments in this PhiExpr.

getArgBox

public ValueUnitPair getArgBox(int index)
Returns the argument pair for the given index. Null if out-of-bounds.

getValue

public Value getValue(int index)
Returns the value for the given index into the PhiExpr. Null if out-of-bounds.

getPred

public Unit getPred(int index)
Returns the control flow predecessor Unit for the given index into the PhiExpr. Null if out-of-bounds.

getArgIndex

public int getArgIndex(Unit predTailUnit)
Returns the index of the argument associated with the given control flow predecessor Unit. Returns -1 if not found.

getArgBox

public ValueUnitPair getArgBox(Unit predTailUnit)
Returns the argument pair corresponding to the given CFG predecessor. Returns null if not found.

getValue

public Value getValue(Unit predTailUnit)
Get the PhiExpr argument corresponding to the given control flow predecessor, returns null if not available.

getArgIndex

public int getArgIndex(Block pred)
Returns the index of the argument associated with the given control flow predecessor. Returns -1 if not found.

getArgBox

public ValueUnitPair getArgBox(Block pred)
Returns the argument pair corresponding to the given CFG predecessor. Returns null if not found.

getValue

public Value getValue(Block pred)
Get the PhiExpr argument corresponding to the given control flow predecessor, returns null if not available.

setArg

public boolean setArg(int index,
                      Value arg,
                      Unit predTailUnit)
Modify the PhiExpr argument at the given index with the given information. Returns false on failure.

setArg

public boolean setArg(int index,
                      Value arg,
                      Block pred)
Modify the PhiExpr argument at the given index with the given information. Returns false on failure.

setValue

public boolean setValue(int index,
                        Value arg)
Set the value at the given index into the PhiExpr. Returns false on failure.

setValue

public boolean setValue(Unit predTailUnit,
                        Value arg)
Locate the argument assocatiated with the given CFG predecessor unit and set the value. Returns false on failure.

setValue

public boolean setValue(Block pred,
                        Value arg)
Locate the argument assocatiated with the given CFG predecessor and set the value. Returns false on failure.

setPred

public boolean setPred(int index,
                       Unit predTailUnit)
Update the CFG predecessor associated with the PhiExpr argument at the given index. Returns false on failure.

setPred

public boolean setPred(int index,
                       Block pred)
Update the CFG predecessor associated with the PhiExpr argument at the given index. Returns false on failure.

removeArg

public boolean removeArg(int index)
Remove the argument at the given index. Returns false on failure.

removeArg

public boolean removeArg(Unit predTailUnit)
Remove the argument corresponding to the given CFG predecessor. Returns false on failure.

removeArg

public boolean removeArg(Block pred)
Remove the argument corresponding to the given CFG predecessor. Returns false on failure.

removeArg

public boolean removeArg(ValueUnitPair arg)
Remove the given argument. Returns false on failure.

addArg

public boolean addArg(Value arg,
                      Block pred)
Add the given argument associated with the given CFG predecessor. Returns false on failure.

addArg

public boolean addArg(Value arg,
                      Unit predTailUnit)
Add the given argument associated with the given CFG predecessor. Returns false on failure.

getType

public Type getType()
The type of the PhiExpr is usually the same as the type of its arguments.

apply

public void apply(Switch sw)
Description copied from interface: Switchable
Called when this object is visited.