<br><br><div class="gmail_quote">On Tue, May 18, 2010 at 4:10 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On 19 May 2010 00:17, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt; Hi Hans-Martin,<br>
&gt;<br>
&gt; On Tue, May 18, 2010 at 12:15 PM, Hans-Martin Mosner &lt;<a href="mailto:hmm@heeg.de">hmm@heeg.de</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hello,<br>
&gt;&gt; while looking at the decompiled code of some OMeta methods I noticed<br>
&gt;&gt; that the temp name handling in the decompiler seems to be broken.<br>
&gt;&gt; When you compile a method with temps that are referenced from blocks,<br>
&gt;&gt; the decompiler tends to rearrange the temp names, so this method<br>
&gt;&gt;<br>
&gt;&gt; test<br>
&gt;&gt;    | one two |<br>
&gt;&gt;    two := 2.<br>
&gt;&gt;    ^{[one := 1].<br>
&gt;&gt;    [ [one + two] value]}<br>
&gt;&gt;<br>
&gt;&gt; gets decompiled to this:<br>
&gt;&gt;<br>
&gt;&gt; test<br>
&gt;&gt;    | one two |<br>
&gt;&gt;    one := 2.<br>
&gt;&gt;    ^ {[two := 1]. [[two + one] value]}<br>
&gt;<br>
&gt; OK, the issue in Squeak 4.1 is that the<br>
&gt; CodeHolder&gt;&gt;decompiledSourceIntoContents method is out of date.  Find<br>
&gt; attached.<br>
&gt;<br>
&gt;&gt; But that&#39;s only a nuisance. The bug really shows up when you decompile a<br>
&gt;&gt; method compiled using OMeta.<br>
&gt;&gt; To see what I mean, load the OMeta2 package and have a look at method<br>
&gt;&gt; OMeta2AndOrOpt&gt;&gt;and.<br>
&gt;<br>
&gt; Any way of reproducing this without OMeta, e.g. in a workspace?<br>
&gt; e.g. to test the above I used things like<br>
&gt; | mn m |<br>
&gt; mn := Compiler new compile: &#39;test<br>
&gt;    | one two |<br>
&gt;    two := 2.<br>
&gt;    ^{[one := 1].<br>
&gt;    [ [one + two] value]}&#39; in: nil class classified: nil notifying: nil<br>
&gt; ifFail: nil.<br>
&gt; m := (mn generate: #(0 0 0 0)) copyWithTempsFromMethodNode: mn.<br>
&gt; {m decompile. m tempNamesString}<br>
&gt; where in 4.1 &quot;generate: #(0 0 0 0)&quot; needs to be replaced with &quot;generate:<br>
&gt; CompiledMethodTrailer defaultMethodTrailer&quot; (although asMethodTrailer on<br>
&gt; ArrayedCollection would be nice for backward-compatibility).<br>
<br>
</div></div>There is a Behavior&gt;&gt;#defaultMethodTrailer , which is backwards compatible.<br></blockquote><div><br></div><div>CompiledMethod class&gt;&gt;newBytes:trailerBytes:nArgs:nTemps:nStack:nLits:primitive: (and hence BytecodeAgnosticMethodNode&gt;&gt;generate:) is no longer backward-compatible.  Call it with the old meaningless #(0 0 0 0) and you get an error.  One might be able to provide backward-compatibility if there was an implementation of asMethodTrailer in Arrayed Collection that deferred to CompiledMethodTrailer and the relevant part of newBytes:trailerBytes:nArgs:nTemps:nStack:nLits:primitive: read:</div>
<div><br></div><div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^ trailer asMethodTrailer createMethod: numberOfBytes</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> header: (nArgs bitShift: 24) +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>(nTemps bitShift: 18) +</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>(largeBit bitShift: 17) +</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>(nLits bitShift: 9) +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>primBits.</div><div><br></div><div>In any case the selector keyword is &quot;trailerBytes:&quot; not &quot;methodTrailer:&quot; or &quot;trailer&quot;.  IMO you should add a new method that takes a trailer and revert the old one to read</div>
<div><br></div><div><div>newBytes: numberOfBytes trailerBytes: trailer nArgs: nArgs nTemps: nTemps nStack: stackSize nLits: nLits primitive: primitiveIndex</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&quot;Answer an instance of me. The header is specified by the message </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>arguments. The remaining parts are not as yet determined.&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^self newBytes: numberOfBytes</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>trailer: trailer asMethodTrailer</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>nArgs: nArgs</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>nTemps: nTemps</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>nStack: stackSize</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>nLits: nLits</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>primitive: primitiveIndex</div>
</div></div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
So, one should use it instead of putting meaningless #(0 0 0 0) everywhere.<br></blockquote><div><br></div><div>Its not an issue of #(0 0 0 0) being meaningless.  Its an issue of not breaking the old way where #(0 0 0 0) was used to mean empty.</div>
<div><br></div><div>best</div><div>Eliot </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Hans-Martin<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</font></blockquote></div><br>