[squeak-dev] decompiler breaks some methods

Igor Stasenko siguctua at gmail.com
Tue May 18 23:10:21 UTC 2010


On 19 May 2010 00:17, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> Hi Hans-Martin,
>
> On Tue, May 18, 2010 at 12:15 PM, Hans-Martin Mosner <hmm at heeg.de> wrote:
>>
>> Hello,
>> while looking at the decompiled code of some OMeta methods I noticed
>> that the temp name handling in the decompiler seems to be broken.
>> When you compile a method with temps that are referenced from blocks,
>> the decompiler tends to rearrange the temp names, so this method
>>
>> test
>>    | one two |
>>    two := 2.
>>    ^{[one := 1].
>>    [ [one + two] value]}
>>
>> gets decompiled to this:
>>
>> test
>>    | one two |
>>    one := 2.
>>    ^ {[two := 1]. [[two + one] value]}
>
> OK, the issue in Squeak 4.1 is that the
> CodeHolder>>decompiledSourceIntoContents method is out of date.  Find
> attached.
>
>> But that's only a nuisance. The bug really shows up when you decompile a
>> method compiled using OMeta.
>> To see what I mean, load the OMeta2 package and have a look at method
>> OMeta2AndOrOpt>>and.
>
> Any way of reproducing this without OMeta, e.g. in a workspace?
> e.g. to test the above I used things like
> | mn m |
> mn := Compiler new compile: 'test
>    | one two |
>    two := 2.
>    ^{[one := 1].
>    [ [one + two] value]}' in: nil class classified: nil notifying: nil
> ifFail: nil.
> m := (mn generate: #(0 0 0 0)) copyWithTempsFromMethodNode: mn.
> {m decompile. m tempNamesString}
> where in 4.1 "generate: #(0 0 0 0)" needs to be replaced with "generate:
> CompiledMethodTrailer defaultMethodTrailer" (although asMethodTrailer on
> ArrayedCollection would be nice for backward-compatibility).

There is a Behavior>>#defaultMethodTrailer , which is backwards compatible.
So, one should use it instead of putting meaningless #(0 0 0 0) everywhere.



>>
>> Cheers,
>> Hans-Martin
>>
>
>
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list