[Vm-dev] squeak decompiler
casey.obrien.r at gmail.com
Mon Oct 20 10:01:50 UTC 2014
I don't know anything about how the Squeak decompiler works.
One approach to translating code in one language to another is to build a parser for the source language in order to obtain an abstract syntax tree (AST) and then use a pretty-printer for the target language on the AST. That's the short, short version of an explanation of how we translate the Squeak VM from Slang to C.
In the case of a decompiler for a byte compiled system, the source language (using the above approach) would be the bytecodes themselves, and the target language could be any language with sufficient facilities to support the semantics of the source language (in the case of a decompiler, the target language would be the original language used to compile the e.g. bytecode.)
I hesitated to respond, because I definitely don't know anything about Squeak's decompiler, and also because what I've described is in some ways a massive oversimplification (if the compiler is optimizing things, deoptimization may be necessary to approach the intent and style of the original programmer's code, and that's just one thing I can think of.)
We have available to us a couple of tools which make it (relatively) easy to play around with this idea and get a feel for it (OMeta/Squeak and PetitParser.)
Decompilation hasn't been an area of interest for me, and I don't know much about it, so I may be sending you down the primrose path. In the immortal words of LeVar Burton, "don't take my word for it."
I know that several research papers have been written about OMeta, and I'd bet some have been written about PetitParser as well. The focus of these systems is on parsing expression grammars (PEGs,) but language to language translation is a thing, and it seems to me that a decompiler can be viewed as a special case of this thing. Following the references cited in such papers could prove valuable to whatever your cause is.
For historical perspective on OMeta and PetitParser, it might be helpful looking into the meta language called Meta-2.
Arguably, this question would be as well addressed on squeak-dev, as both the compiler and the decompiler are image-residents, and not built into the VM (though both are tied to the VM's behavior wrt interpreting bytecode.)
HTH, sorry if it doesn't.
People who actually know how Squeak's decompiler works should still probably chime in here :D
> On Oct 20, 2014, at 1:51 AM, Whiter Walt <whiter.walt at gmail.com> wrote:
> I am interested in the Squeak Decompiler class. Is there any technical information in the net, which explains the functionality? Or maybe it follows some common "rules", I can find in some paper or book?
More information about the Vm-dev