[Pkg] The Trunk: Tools-dtl.240.mcz

commits at source.squeak.org commits at source.squeak.org
Wed May 19 00:50:44 UTC 2010


David T. Lewis uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-dtl.240.mcz

==================== Summary ====================

Name: Tools-dtl.240
Author: dtl
Time: 18 May 2010, 8:49:12.479 pm
UUID: d922cd2f-7f7e-42b6-8f70-2bf5cd857117
Ancestors: Tools-fbs.239

Eliot's decompiler fix

Date: Tue, 18 May 2010 14:17:40 -0700
Subject: Re: [squeak-dev] decompiler breaks some methods
From: Eliot Miranda <eliot.miranda at gmail.com>
To: The general-purpose Squeak developers list <squeak-dev at lists.squeakfoundation.org>

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.

[-- Attachment #2: Decompiler.1.cs --]


=============== Diff against Tools-fbs.239 ===============

Item was changed:
  ----- Method: CodeHolder>>decompiledSourceIntoContents (in category 'message list') -----
  decompiledSourceIntoContents
+ 	"For backwards compatibility."
- 	"Obtain a source string by decompiling the method's code, and place 
- 	that source string into my contents. Also return the string.
- 	Get temps from source file if shift key is pressed."
- 	
- 	|  class |
- 	class := self selectedClassOrMetaClass.
- 	"Was method deleted while in another project?"
- 	currentCompiledMethod := (class compiledMethodAt: self selectedMessageName ifAbsent: [^ '']).
  
+ 	^self  decompiledSourceIntoContentsWithTempNames: (Sensor leftShiftDown not) 
+ !
- 	contents := (Sensor leftShiftDown not) 
- 		ifTrue: [currentCompiledMethod decompileWithTemps]
- 		ifFalse: [currentCompiledMethod decompile].
- 	contents := contents decompileString asText makeSelectorBoldIn: class.
- 	^ contents copy!

Item was added:
+ ----- Method: CodeHolder>>decompiledSourceIntoContentsWithTempNames: (in category 'message list') -----
+ decompiledSourceIntoContentsWithTempNames: showTempNames 
+ 	"Obtain a source string by decompiling the method's code, and place 
+ 	that source string into my contents.
+ 	Also return the string.
+ 	Get temps from source file if showTempNames is true."
+ 
+ 	| tempNames class selector method |
+ 	class := self selectedClassOrMetaClass.
+ 	selector := self selectedMessageName.
+ 	"Was method deleted while in another project?"
+ 	method := class compiledMethodAt: selector ifAbsent: [^ ''].
+ 
+ 	currentCompiledMethod := method.
+ 	(showTempNames not
+ 			or: [method fileIndex > 0
+ 					and: [(SourceFiles at: method fileIndex) isNil]])
+ 		ifTrue: [
+ 			"Emergency or no source file -- decompile without temp names "
+ 			contents := (class decompilerClass new
+ 						decompile: selector
+ 						in: class
+ 						method: method) decompileString]
+ 		ifFalse: [tempNames := (class compilerClass new
+ 									parse: method getSourceFromFile asString
+ 									in: class
+ 									notifying: nil)
+ 										generate: CompiledMethodTrailer defaultMethodTrailer;
+ 										schematicTempNamesString.
+ 			contents := ((class decompilerClass new withTempNames: tempNames)
+ 						decompile: selector
+ 						in: class
+ 						method: method) decompileString].
+ 	contents := contents asText makeSelectorBoldIn: class.
+ 	^ contents copy!



More information about the Packages mailing list