soot.shimple.internal
Class SPhiExpr

java.lang.Object
  extended by soot.shimple.internal.SPhiExpr
All Implemented Interfaces:
Serializable, EquivTo, Expr, PhiExpr, ShimpleExpr, UnitBoxOwner, Switchable, Value

public class SPhiExpr
extends Object
implements PhiExpr

Internal implementation of Phi nodes.

Author:
Navindra Umanee
See Also:
PhiExpr, Serialized Form

Field Summary
protected  List argPairs
           
protected  Map predToPair
           
protected  Type type
           
 
Constructor Summary
SPhiExpr(List<Value> args, List<Unit> preds)
          Create a Phi expression from the given list of Values and Blocks.
SPhiExpr(Local leftLocal, List preds)
          Create a trivial Phi expression for leftLocal.
 
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.
 void clearUnitBoxes()
           
 Object clone()
          Returns a clone of this Value.
 int equivHashCode()
          Returns a (not necessarily fixed) hash code for this object.
 boolean equivTo(Object o)
          Returns true if this object is equivalent to o.
 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.
 List getArgs()
          Returns an unmodifiable, backed view of the arguments to this PhiExpr.
 int getBlockId()
          Returns the id number of the block from which the Phi node originated from.
 Unit getPred(int index)
          Returns the control flow predecessor Unit for the given index into the PhiExpr.
 List<Unit> 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.
 List getUnitBoxes()
           
 List getUseBoxes()
          Returns a List of boxes corresponding to Values which are used by (ie contained within) this Value.
 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.
 List<Value> 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.
 void setBlockId(int blockId)
          Set the block number of the Phi node.
 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.
 String toString()
           
 void toString(UnitPrinter up)
           
protected  void updateCache()
          Update predToPair cache map which could be out-of-sync due to external setUnit or clone operations on the UnitBoxes.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

argPairs

protected List argPairs

predToPair

protected Map predToPair

type

protected Type type
Constructor Detail

SPhiExpr

public SPhiExpr(Local leftLocal,
                List preds)
Create a trivial Phi expression for leftLocal. preds is an ordered list of the control flow predecessor Blocks of the PhiExpr.


SPhiExpr

public SPhiExpr(List<Value> args,
                List<Unit> preds)
Create a Phi expression from the given list of Values and Blocks.

Method Detail

getArgs

public List getArgs()
Description copied from interface: PhiExpr
Returns an unmodifiable, backed view of the arguments to this PhiExpr. Each argument is a ValueUnitPair.

Specified by:
getArgs in interface PhiExpr
See Also:
ValueUnitPair

getValues

public List<Value> getValues()
Description copied from interface: PhiExpr
Returns a list of the values used by this PhiExpr.

Specified by:
getValues in interface PhiExpr

getPreds

public List<Unit> getPreds()
Description copied from interface: PhiExpr
Returns a list of the control flow predecessor Units being tracked by this PhiExpr

Specified by:
getPreds in interface PhiExpr

getArgCount

public int getArgCount()
Description copied from interface: PhiExpr
Returns the number of arguments in this PhiExpr.

Specified by:
getArgCount in interface PhiExpr

getArgBox

public ValueUnitPair getArgBox(int index)
Description copied from interface: PhiExpr
Returns the argument pair for the given index. Null if out-of-bounds.

Specified by:
getArgBox in interface PhiExpr

getValue

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

Specified by:
getValue in interface PhiExpr

getPred

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

Specified by:
getPred in interface PhiExpr

getArgIndex

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

Specified by:
getArgIndex in interface PhiExpr

getArgBox

public ValueUnitPair getArgBox(Unit predTailUnit)
Description copied from interface: PhiExpr
Returns the argument pair corresponding to the given CFG predecessor. Returns null if not found.

Specified by:
getArgBox in interface PhiExpr

getValue

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

Specified by:
getValue in interface PhiExpr

getArgIndex

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

Specified by:
getArgIndex in interface PhiExpr

getArgBox

public ValueUnitPair getArgBox(Block pred)
Description copied from interface: PhiExpr
Returns the argument pair corresponding to the given CFG predecessor. Returns null if not found.

Specified by:
getArgBox in interface PhiExpr

getValue

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

Specified by:
getValue in interface PhiExpr

setArg

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

Specified by:
setArg in interface PhiExpr

setArg

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

Specified by:
setArg in interface PhiExpr

setValue

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

Specified by:
setValue in interface PhiExpr

setValue

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

Specified by:
setValue in interface PhiExpr

setValue

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

Specified by:
setValue in interface PhiExpr

setPred

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

Specified by:
setPred in interface PhiExpr

setPred

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

Specified by:
setPred in interface PhiExpr

removeArg

public boolean removeArg(int index)
Description copied from interface: PhiExpr
Remove the argument at the given index. Returns false on failure.

Specified by:
removeArg in interface PhiExpr

removeArg

public boolean removeArg(Unit predTailUnit)
Description copied from interface: PhiExpr
Remove the argument corresponding to the given CFG predecessor. Returns false on failure.

Specified by:
removeArg in interface PhiExpr

removeArg

public boolean removeArg(Block pred)
Description copied from interface: PhiExpr
Remove the argument corresponding to the given CFG predecessor. Returns false on failure.

Specified by:
removeArg in interface PhiExpr

removeArg

public boolean removeArg(ValueUnitPair arg)
Description copied from interface: PhiExpr
Remove the given argument. Returns false on failure.

Specified by:
removeArg in interface PhiExpr

addArg

public boolean addArg(Value arg,
                      Block pred)
Description copied from interface: PhiExpr
Add the given argument associated with the given CFG predecessor. Returns false on failure.

Specified by:
addArg in interface PhiExpr

addArg

public boolean addArg(Value arg,
                      Unit predTailUnit)
Description copied from interface: PhiExpr
Add the given argument associated with the given CFG predecessor. Returns false on failure.

Specified by:
addArg in interface PhiExpr

setBlockId

public void setBlockId(int blockId)
Description copied from interface: PhiExpr
Set the block number of the Phi node.

Specified by:
setBlockId in interface PhiExpr

getBlockId

public int getBlockId()
Description copied from interface: PhiExpr
Returns the id number of the block from which the Phi node originated from.

Specified by:
getBlockId in interface PhiExpr

updateCache

protected void updateCache()
Update predToPair cache map which could be out-of-sync due to external setUnit or clone operations on the UnitBoxes.


equivTo

public boolean equivTo(Object o)
Description copied from interface: EquivTo
Returns true if this object is equivalent to o.

Specified by:
equivTo in interface EquivTo

equivHashCode

public int equivHashCode()
Description copied from interface: EquivTo
Returns a (not necessarily fixed) hash code for this object. This hash code coincides with equivTo; it is undefined in the presence of mutable objects.

Specified by:
equivHashCode in interface EquivTo

getUnitBoxes

public List getUnitBoxes()
Specified by:
getUnitBoxes in interface UnitBoxOwner

clearUnitBoxes

public void clearUnitBoxes()
Specified by:
clearUnitBoxes in interface UnitBoxOwner

getUseBoxes

public List getUseBoxes()
Description copied from interface: Value
Returns a List of boxes corresponding to Values which are used by (ie contained within) this Value.

Specified by:
getUseBoxes in interface Value

getType

public Type getType()
Description copied from interface: PhiExpr
The type of the PhiExpr is usually the same as the type of its arguments.

Specified by:
getType in interface PhiExpr
Specified by:
getType in interface Value

toString

public String toString()
Overrides:
toString in class Object

toString

public void toString(UnitPrinter up)
Specified by:
toString in interface Value

apply

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

Specified by:
apply in interface PhiExpr
Specified by:
apply in interface Switchable

clone

public Object clone()
Description copied from interface: Value
Returns a clone of this Value.

Specified by:
clone in interface Value
Overrides:
clone in class Object