printing blocks
FixPoint
FixPoint at aol.com
Wed Jan 28 23:31:06 UTC 1998
Content-ID: <0_886030267 at inet_out.mail.aol.com.1>
Content-type: text/plain; charset=US-ASCII
Here is a method useful for printing blocks.
--Sheldon Nicholl
Content-ID: <0_886030267 at inet_out.mail.aol.com.2>
Content-type: text/plain;
name="DECOMP~1.ST"
Content-disposition: inline
'From Squeak 1.23 of October 4, 1997 on 26 January 1998 at 6:32:39 pm'!
!Decompiler methodsFor: 'public access' stamp: 'sn 1/26/98 18:27'!
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 tempNames home |
(home _ aBlock home) isNil ifTrue: [^nil].
method _ home method.
(homeClass _ method who first) == #unknown ifTrue: [^nil].
constructor _ DecompilerConstructor new.
method fileIndex ~~ 0 "got any source code?"
ifTrue:
[tempNames _ (homeClass compilerClass new
parse: method getSourceFromFile
in: homeClass
notifying: nil) tempNames.
self withTempNames: tempNames].
self initSymbols: homeClass.
startpc _ aBlock startpc.
end _ (method at: startpc-2)\\16-4*256 +
(method at: startpc-1) + startpc - 1.
stack _ OrderedCollection new: method frameSize.
statements _ OrderedCollection new: 20.
super method: method pc: startpc - 5.
blockNode _ self blockTo: end.
stack isEmpty ifFalse: [self error: 'stack not empty'].
^blockNode statements first! !
More information about the Squeak-dev
mailing list
|