[Soot-list] Constructor with parameters (JNewExpr) ?

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Mon Jun 14 03:13:38 EDT 2010


I am confused. Where is there an IntConstant or DoubleConstant in your code?

In general: yes, I think that you are right that you cannot use constants in
a method call. Instead you must first assign each constant to a fresh local
variable and then use that variable as an argument.

Eric

--
Dr. Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt


On 13 June 2010 14:37, Cristina Ilie <crysgirlro at yahoo.com> wrote:

>         I have instantiated the object how I wanted but the parameters I
> give can be only Local objects - I tried with constants(IntConstant or
> DoubleConstant and it throws an exception - I think this happens because an
> Value can't be added to the derivlocalsChain ). How can I give a constant as
> parameter?
>         JimpleLocal as I see, can't be set with a double value (I don't
> want to use a new assignment in my code).
>
>         ArrayList arg = new ArrayList();
>         JimpleLocal ct = new JimpleLocal("a",DoubleType.v());
>         derivLocalsChain.add(ct);
>         arg.add(ct);
>         derivUnits.insertAfter(
>                 Jimple.v().newInvokeStmt(
>                         new JSpecialInvokeExpr(
>                                 tst,
>                                 initMethod.makeRef(),
>                                 arg)),
>                 stmt);
>
>         // current local of DerivType (add the "new DerivType()" call
>         derivUnits.insertAfter(
>                         Jimple.v().newAssignStmt(tst,Jimple.v().newNewExpr(
>                                 derivTypeClass.getType())),
>                 stmt);
>
> Result:  "inst-default = new DerivType(a);"
>
> Cristina
>
> ------------------------------
> *From:* Eric Bodden <bodden at st.informatik.tu-darmstadt.de>
> *To:* Cristina Ilie <crysgirlro at yahoo.com>
> *Cc:* soot-list at sable.mcgill.ca
> *Sent:* Sat, June 12, 2010 2:27:55 PM
> *Subject:* Re: [Soot-list] Constructor with parameters (JNewExpr) ?
>
> Hi Cristina.
>
> In bytecode (and Jimple), a constructor call "x = new X(a,b)" is
> modeled as sequence of *two* statements, one new-statement and one
> invokespecial-statement that calls the constuctor:
>
> x = new X;
> invokespecial x.<init>(a,b);
>
> So after your new statement just create an appropriate JInvokeStmt
> with a JSpecialInvokeExpr.
>
> Eric
>
> --
> Dr. Eric Bodden
> Software Technology Group, Technische Universität Darmstadt, Germany
> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>
>
>
> On 12 June 2010 09:46, Cristina Ilie <crysgirlro at yahoo.com> wrote:
> > Hi,
> >
> > How do add parameters when I instantiate an object of a class created by
> me.
> > I did so:
> >                         RefType parameter = RefType.v("DerivType");
> >                         locSExprDTRHS[i] = new JNewExpr(parameter);
> >
> > JNewExpr will contain: new DerivType - but I want to give some parameters
> (I
> > have 2 constructors for the class DerivType).
> >
> > Thanks,
> > Cristina
> >
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100614/251f2f04/attachment.html 


More information about the Soot-list mailing list