Re: Local variables map
"Markus Heiden" <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <B58BB6B2FC7347388CF166D58024A014@Gonzo> |
Hello Robert, >> mv.visitVarInsn(ALOAD, 3); >> mv.visitVarInsn(ALOAD, 1); >> mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "addAll", >> "(Ljava/util/Collection;)Z"); > > I'm assuming that, the object in which the method is invoked is the last > one that has been ALOADed but, as the above example demonstrate, this is > not the case since with my procedure I'm saying that the 'addAll' is > invoked on variable # 1 and, in reality it is invoked on variable # 2 with > variable # 1 as parameter. > > I tried to use also the Analyzer and the two Interpreters but without > success. I suggest using Type.getArgumentTypes(String methodDescriptor). With the argument types returned you can compute where the collection has to be on the stack (via Type.getSize()). Then you can pop and save the arguments, pop and save the collection and do something with it. Afterward you can restore everything as it had been before and execute the call. This is the straight forward approach. Alternatively you can implement a backward trace algorithm to compute who had put the collection on the stack. Because the collection does not have to been loaded by an ALOAD, e.g. it may had been put on the stack as a result of a method call, you have to implement different strategies to get the collection. Markus
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws