[Soot-list] How compare 2 Stmt objects for equality?

Eric Bodden eric.bodden at ec-spride.de
Wed Jul 11 18:08:27 EDT 2012


Hi John.

> 1. Can someone tell me the best way to compare two Stmt objects for
> equality?
>
> I looked for an equals method for Stmt and also for some of Stmt's
> implementing classes, and all I see in the API is the standard equals method
> from the Object class (and testing for reference equality doesn't help me).
> I also looked for get methods so I could compare fields within a Stmt, and
> that doesn't appear to help.

I think the reason for this is that testing statements for equality
most often does not make much sense, as the semantics of a statement
heavily depends on its context. Soot does, however, support equality
checking on individual values via the EquivTo interface:

http://www.sable.mcgill.ca/soot/doc/soot/EquivTo.html

What problem are you actually trying to solve?

> 2. To test for Stmt equality, I even looked at the Stmt class's toString
> method, but I'm having a hard time understanding it. What is its UnitPrinter
> parameter for? Why is the return type void?

toString(UnitPrinter) emits a string representation of the respective
statement to the UnitPrinter argument object. However, there should
also be a standard toString() method.

Eric


More information about the Soot-list mailing list