[Soot-list] visitor for Jimple IR

Marc-André Laverdière-Papineau marc-andre.laverdiere-papineau at polymtl.ca
Thu Jun 27 19:29:32 EDT 2013


Hello,

Two things

1) When it comes to source correspondence information, there are some
annotations that can give the source file and the line number (with
restrictions). So please make sure you are not reinventing the wheel :)

2) About the visitor, there are a few concerns to keep in mind
a) SootClass, SootField, etc. are objects that do not depend on the IR
that you are using. In some cases, they are even 'dandling', meaning
that they don't have much information associated with them.

b) If you are using Jimple, there is the Switch API. It looks like you
already found it. You will quickly notice that the options are related
to the Jimple statements in the method bodies. (see
AbstractJimpleValueSwitch)

That being said, I never had an issue with the lack of visitor in
SootClass and its friends. Would you please tell us more about your use
case?


Marc-André Laverdière-Papineau
Doctorant - PhD Candidate

On 27/06/13 06:01 PM, Sergio Ferrero wrote:
> Hello Al,
> 
> Thanks for the reply.
> I see Value and Stmt implement Switchable and thus they implement the
> apply() method.
> However, the Walker gives me a SootClass object which is the root of the
> parsed Jimple file.
> I was wondering whether there is a visitor that works for these objects:
> SootClass, SootField, SootMethod, etc (that is all descendants of Host)
> 
> Sergio
> 
> 
> 
> On Thu, Jun 27, 2013 at 5:53 PM, Al <aaloanmiftah at yahoo.com
> <mailto:aaloanmiftah at yahoo.com>> wrote:
> 
>     Yes jimple does have a visitor pattern implementation. Look at the
>     source tree and find value/statement visitor. Also each value and
>     statement class has a apply method.
> 
>     On Jun 27, 2013, at 3:05 PM, Sergio Ferrero <sferrero at ensoftcorp.com
>     <mailto:sferrero at ensoftcorp.com>> wrote:
> 
>     > Hello,
>     >
>     > I'd like to associate source correspondence information in the
>     format of (offset, length) with an in-memory representation of a
>     Jimple file.
>     >
>     > I'm using the Jimple parser to create a Jimple AST (classes in
>     soot.jimple.parser.node) and then invoking Walker.java to create the
>     in-memory representation of the jimple file (classes are in
>     soot.jimple and soot.jimple.internal).
>     >
>     > It is to this in-memory representation I would like to attach
>     source correspondence information.  I originally tried attaching the
>     information to the Jimple AST generated by the Jimple parser, but
>     this representation was missing some necessary information.
>     >
>     > Sable provides a visitor infrastructure to navigate the Jimple
>     AST. Walker.java is based on this.
>     > I'd like to know whether there is a similar visitor infrastructure
>     for navigating the in-memory representation of the jimple file.
>     >
>     > Thanks in advance
>     > -S
>     >
>     >
>     > _______________________________________________
>     > Soot-list mailing list
>     > Soot-list at sable.mcgill.ca <mailto:Soot-list at sable.mcgill.ca>
>     > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 
> 
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 


More information about the Soot-list mailing list