Is it possible to see the bytecode that makes up a method of an object? If so, how? How can I get a reference to an actual method object?
In trying to find this out I see some interesting objects like 'methodDisassembler' and other objects that have 'abstractBytecodeInterpreter' as parents (localAccessFinder for example). How can these be used? I couldn't find any references of usage anywhere.
Chris.
Hey Chris,
I don't know the full answer, but:
If you get a mirror on an object, eg tmp: reflect: traits string Then get a mirror on a slot containing a method, eg tmp: tmp first Then get the value in that slot, eg tmp: tmp value
You should now have a mirror on the method itself.
When I do it, the mirror I get has 'traits mirrors method' as a parent, which contains lots of nice behavior such as 'dissasemble' and 'codes'
Russell
On 10/02/2010, at 2:23 PM, Chris Double wrote:
Is it possible to see the bytecode that makes up a method of an object? If so, how? How can I get a reference to an actual method object?
In trying to find this out I see some interesting objects like 'methodDisassembler' and other objects that have 'abstractBytecodeInterpreter' as parents (localAccessFinder for example). How can these be used? I couldn't find any references of usage anywhere.
Chris.
On 10/02/10 17:42, Russell Allen wrote:
When I do it, the mirror I get has 'traits mirrors method' as a parent, which contains lots of nice behavior such as 'dissasemble' and 'codes'
Great, exactly what I wanted, thanks!
This seems to be the way to use methodDisassembler and other abstractBytecodeInterpreters:
tmp: methodDisassembler clone tmp initializeForMethod: (reflect: traits string) first value tmp interpretMethod
The result pf the 'interpretMethod' call in this case is the string of disassembled bytecodes (same as the 'dissasemble' method from your example).
replacing 'methodDisassembler' with 'branchTargetFinder' results in a different object returned from interpretMethod (a vector) which I assume is whatever that particular bytecode interpreter finds about the method.
That gives me a lot to go on, thanks.
Chris.
self-interest@lists.selflanguage.org