On Oct 17, 2011, at 4:57 PM, Norbert Hartl wrote:
I'm trying to learn how to get temp names from a BlockClosure. Well, I try to be able to treat BlockClosures the same way than CompileMethod when it comes to arguments. I can do
[:a :b :c| ] asContext tempNames #('a' 'b' 'c')
but I'm not sure if this is the best to go.
Yes, this uses the DebuggerMethodMap and thus should hide the temps that are there just to store the tempVecor. (with the closure design, there are temps that are just implementation artefacts, not temps that where defined).
While looking I found
[:a :b :c| ] method tempNames #('[a' 'b' 'c]')
For me there are two errors.
yes, this is wrong. The real problem is that the CompiledMethod does not store any info about temp names, so you need to either go to the source text or (better) AST... and than there is Dan's clever hack that can save temp names in the method trailer to allow decompiling without sources, complicating the logic in addition. I always think that all this is an epic mess... but other people like it. Marcus -- Marcus Denker -- http://marcusdenker.de