soot.toolkits.scalar
Class ValueUnitPair

java.lang.Object
  extended by soot.tagkit.AbstractHost
      extended by soot.AbstractValueBox
          extended by soot.toolkits.scalar.ValueUnitPair
All Implemented Interfaces:
Serializable, EquivTo, Host, UnitBox, ValueBox
Direct Known Subclasses:
SValueUnitPair

public class ValueUnitPair
extends AbstractValueBox
implements UnitBox, EquivTo

Utility class used to package a Value and a Unit together.

Author:
Navindra Umanee
See Also:
Serialized Form

Field Summary
protected  Unit unit
           
 
Constructor Summary
ValueUnitPair(Value value, Unit unit)
          Constructs a ValueUnitPair from a Unit object and a Value object.
 
Method Summary
 boolean canContainUnit(Unit u)
          Returns true if this box can contain the given Unit.
 boolean canContainValue(Value value)
          Returns true if the given Value fits in this box.
 Object clone()
           
 boolean equals(Object other)
           
 int equivHashCode()
          Non-deterministic hashcode consistent with equivTo() implementation.
 boolean equivTo(Object other)
          Two ValueUnitPairs are equivTo iff they hold the same Unit objects and equivalent Value objects within them.
 Unit getUnit()
          Returns the unit contained within this box.
 int hashCode()
           
 boolean isBranchTarget()
          Returns true if the UnitBox is holding a Unit that is the target of a branch (ie a Unit at the beginning of a CFG block).
 void setUnit(Unit unit)
          Sets this box to contain the given unit.
 String toString()
           
 void toString(UnitPrinter up)
           
 
Methods inherited from class soot.AbstractValueBox
getValue, setValue
 
Methods inherited from class soot.tagkit.AbstractHost
addAllTagsOf, addTag, getTag, getTags, hasTag, removeAllTags, removeTag
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface soot.tagkit.Host
addAllTagsOf, addTag, getTag, getTags, hasTag, removeAllTags, removeTag
 

Field Detail

unit

protected Unit unit
Constructor Detail

ValueUnitPair

public ValueUnitPair(Value value,
                     Unit unit)
Constructs a ValueUnitPair from a Unit object and a Value object.

Parameters:
value - some Value
unit - some Unit.
Method Detail

canContainValue

public boolean canContainValue(Value value)
Description copied from interface: ValueBox
Returns true if the given Value fits in this box.

Specified by:
canContainValue in interface ValueBox

setUnit

public void setUnit(Unit unit)
Description copied from interface: UnitBox
Sets this box to contain the given unit. Subject to canContainValue() checks.

Specified by:
setUnit in interface UnitBox
See Also:
UnitBox.setUnit(Unit)

getUnit

public Unit getUnit()
Description copied from interface: UnitBox
Returns the unit contained within this box.

Specified by:
getUnit in interface UnitBox
See Also:
UnitBox.getUnit()

canContainUnit

public boolean canContainUnit(Unit u)
Description copied from interface: UnitBox
Returns true if this box can contain the given Unit.

Specified by:
canContainUnit in interface UnitBox
See Also:
UnitBox.canContainUnit(Unit)

isBranchTarget

public boolean isBranchTarget()
Description copied from interface: UnitBox
Returns true if the UnitBox is holding a Unit that is the target of a branch (ie a Unit at the beginning of a CFG block). This is the default case.

Returns false if the UnitBox is holding a Unit that indicates the end of a CFG block and may require specialised processing for SSA.

Specified by:
isBranchTarget in interface UnitBox
See Also:
UnitBox.isBranchTarget()

toString

public String toString()
Overrides:
toString in class AbstractValueBox

toString

public void toString(UnitPrinter up)
Specified by:
toString in interface UnitBox
Specified by:
toString in interface ValueBox
Overrides:
toString in class AbstractValueBox

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

equivTo

public boolean equivTo(Object other)
Two ValueUnitPairs are equivTo iff they hold the same Unit objects and equivalent Value objects within them.

Specified by:
equivTo in interface EquivTo
Parameters:
other - another ValueUnitPair
Returns:
true if other contains the same objects as this.

equivHashCode

public int equivHashCode()
Non-deterministic hashcode consistent with equivTo() implementation.

Note: If you are concerned about non-determinism, remember that current implementations of equivHashCode() in other parts of Soot are non-deterministic as well (see Constant.java for example).

Specified by:
equivHashCode in interface EquivTo

clone

public Object clone()
Overrides:
clone in class Object