[squeak-dev] The Inbox: Compiler-HenrikSperreJohansen.144.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 27 12:17:34 UTC 2010


A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-HenrikSperreJohansen.144.mcz

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

Name: Compiler-HenrikSperreJohansen.144
Author: HenrikSperreJohansen
Time: 27 May 2010, 2:17:23.995 pm
UUID: a77bbe8a-ac19-4883-943a-a47c1a8db1ad
Ancestors: Compiler-ar.143

Fix for BlockClosure decompilation in Workspace doits.

Previously, blocks with remoteTemps would fail to decompile, f.ex:

| x y |
[:a :b | x := a. y := b] decompile
(http://code.google.com/p/pharo/issues/detail?id=767)

Also, temp names would not be preserved when inspecting a non-remoteTemps block, say

[:x :y | | temp | 1 + x at y. ^temp] decompile printString.

Getting the instvar names from MethodTrailer if present in decompileBlock:  solves both these issues.





=============== Diff against Compiler-ar.143 ===============

Item was changed:
  ----- Method: Decompiler>>decompileBlock: (in category 'public access') -----
+ decompileBlock: aBlock
- decompileBlock: aBlock 
  	"Decompile aBlock, returning the result as a BlockNode.  
  	Show temp names from source if available."
+ 
  	"Decompiler new decompileBlock: [3 + 4]"
+ 
  	| startpc end homeClass blockNode methodNode home source |
+ 	(home := aBlock home) ifNil: [ ^ nil ].
- 	(home := aBlock home) ifNil: [^ nil].
  	method := home method.
+ 	(homeClass := home methodClass) == #unknown
+ 		ifTrue: [ ^ nil ].
- 	(homeClass := home methodClass) == #unknown ifTrue: [^ nil].
  	constructor := self constructorForMethod: aBlock method.
+ 	(method tempNamesString ifNil:[
+ 	method fileIndex ~~ 0
+ 		ifTrue: [ 
+ 			"got any source code?"
+ 			source := [ method getSourceFromFile ] on: Error do: [ :ex | ^ nil ].
+ 			methodNode := [ homeClass compilerClass new parse: source in: homeClass notifying: nil ]
+ 				on: (Smalltalk globals classNamed: 'SyntaxErrorNotification')
+ 				do: [ :ex | ^ nil ].
+ 			methodNode schematicTempNamesString ]]) ifNotNil: [:temps | self withTempNames: temps].
- 	method fileIndex ~~ 0 ifTrue: "got any source code?"
- 		[source := [method getSourceFromFile]
- 						on: Error
- 						do: [:ex | ^ nil].
- 		 methodNode := [homeClass compilerClass new
- 								parse: source
- 								in: homeClass
- 								notifying: nil]
- 							on: (Smalltalk classNamed: 'SyntaxErrorNotification')
- 							do: [:ex | ^ nil].
- 		 self withTempNames: methodNode schematicTempNamesString].
  	self initSymbols: homeClass.
  	startpc := aBlock startpc.
  	end := aBlock isClosure
+ 		ifTrue: [ (method at: startpc - 2) * 256 + (method at: startpc - 1) + startpc - 1 ]
+ 		ifFalse: [ ((method at: startpc - 2) \\ 16 - 4) * 256 + (method at: startpc - 1) + startpc - 1 ].
- 				ifTrue: [(method at: startpc - 2) * 256
- 					  + (method at: startpc - 1) + startpc - 1]
- 				ifFalse:
- 					[(method at: startpc - 2) \\ 16 - 4 * 256
- 					+ (method at: startpc - 1) + startpc - 1].
  	stack := OrderedCollection new: method frameSize.
  	caseExits := OrderedCollection new.
  	statements := OrderedCollection new: 20.
  	super
  		method: method
+ 		pc:
+ 			(aBlock isClosure
+ 				ifTrue: [ startpc - 4 ]
+ 				ifFalse: [ startpc - 5 ]).
+ 	aBlock isClosure
+ 		ifTrue: [ numLocalTemps := #decompileBlock:	"Get pushClosureCopy... to hack fake temps for copied values" ].
- 		pc: (aBlock isClosure ifTrue: [startpc - 4] ifFalse: [startpc - 5]).
- 	aBlock isClosure ifTrue:
- 		[numLocalTemps := #decompileBlock: "Get pushClosureCopy... to hack fake temps for copied values"].
  	blockNode := self blockTo: end.
+ 	stack isEmpty
+ 		ifFalse: [ self error: 'stack not empty' ].
+ 	^ blockNode statements first!
- 	stack isEmpty ifFalse: [self error: 'stack not empty'].
- 	^blockNode statements first!




More information about the Squeak-dev mailing list