<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi,<br>
    <br>
    thanks for your reply!<br>
    it is a pity, there is no documentation about decompiling. Anyway,
    thanks for your summary/introduction about decompiling squeak
    bytecode...<br>
    <br>
    Regards,<br>
    Walt<br>
    <br>
    <div class="moz-cite-prefix">Am 20.10.2014 11:31, schrieb ClĂ©ment
      Bera:<br>
    </div>
    <blockquote
cite="mid:CAJrdCbXXb=ogx8F9MJF4QN99J2AVDZTX4xDSYFwa+2N6XLZkNA@mail.gmail.com"
      type="cite">
      <pre wrap=""> </pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <div dir="ltr">
        <div>Hello,</div>
        <div><br>
        </div>
        I don't think there'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'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'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's a little complexity from cascade too. They'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 moz-do-not-send="true"
              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 "rules", 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>
    </blockquote>
    <br>
  </body>
</html>