<div dir="ltr"><div>Hello,</div><div><br></div>I don&#39;t think there&#39;s much documentation available.<div><br></div><div>Basically it builds a method AST from a compiled method. It is composed of the Decompiler that walks over the bytecode and the AST constructor that builds the AST.</div><div><br></div><div>Most nodes maps one to one to AST nodes and are easy to decompile. The main complexity comes from the decompilation of inlined control flow structures, which is based on heuristics:</div><div>- loops are decompiled to while loops and if a certain pattern is met (there&#39;s an iterator incremented at each loop iteration) then the while loop is replaced by #to:do: or #to:by:do:<br></div><div>- conditions are decompiled to ifTrue:ifFalse:, except if the pattern matches a #ifNil:ifNotNil: (there&#39;s == nil bytecodes), and except if the conditional jumps jumps to a push true or push false bytecode, in which case it is decompiled to #and: or #or:<br></div><div>- dup mixed with jumps are decompiled to #caseOf: or #caseOf:otherwise:</div><div><br></div><div>There&#39;s a little complexity from cascade too. They&#39;re detected with dup bytecode without jumps on the contrary to #caseOf: .</div><div><br></div><div>Note that the Decompiler is unreliable, recompiling the whole image from decompiled sources crashes, and seemingly it has not been possible to do that in the past decade (it was possible in Smalltalk 80). So you can consider that the decompiler can decompile 99% of methods but not all of them.</div><div><br></div><div>An interesting work would be to improve the decompiler so that the image does not crash when all the methods are recompiled from decompiled sources.</div><div><br></div><div>Regards,</div><div><br></div><div>Clement</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-20 10:51 GMT+02:00 Whiter Walt <span dir="ltr">&lt;<a href="mailto:whiter.walt@gmail.com" target="_blank">whiter.walt@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br>
<br>
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 &quot;rules&quot;, I can find in some paper or book?<br>
<br>
cheers<span class="HOEnZb"><font color="#888888"><br>
Walt<br>
</font></span></blockquote></div><br></div>