Re: Re: how to get the name of a local variable

lucefe <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Thank you.
But for the source code:
     Node node = new Node();
     node.key = data;
I can use the next code to get the name of "data".

     List locVars = mn.localVariables;
     ... ...
     LocalVariableNode locVar = (LocalVariableNode)locVars.get(var);
     String name = locVar.name;

but how about "node.key", now I can only get "key" from "GRTFIELD"
instruction.

Perhaps frame is useful, but how to get the current frame?

lucefe

2010/7/19 Eugene Kuleshov <[email protected]>

>
>  You can only get it if corresponding debug info is present in the bytecode
> (e.g. javac -g:vars ...):
> http://asm.ow2.org/asm33/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitLocalVariable%28java.lang.String,%20java.lang.String,%20java.lang.String,%20org.objectweb.asm.Label,%20org.objectweb.asm.Label,%20int%29
>
>  regards,
>  Eugene
>
>
> lucefe wrote:
>
>> I want to get the name of a local variable, for example:
>> To the assignment statement "node.key = data", how can I get local
>> variable's name "data".
>> The related byte code of the statement is:
>> ALOAD 2
>> ILOAD 1
>> PUTFIELD src/Node.key : I
>>
>> I know "data" is the first value on the operand stack, but how can I get
>> the name "data"and "node"?
>>
>> Thank you all!
>>
>> lucefe
>>
>
>
>
> --
> 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
>
>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.