the decompiler

Tim Olson tim at
Tue Mar 3 18:47:05 UTC 1998

>	Why not just make decompiled method sources have a friendly little method
>comment, saying something like "This is decompiled code." or somesuch,
>perhaps even with a hyperlink to instructions on setting up the sources

This can be done by modifying a single method:

'From Squeak 1.31 of Feb 4, 1998 on 3 March 1998 at 12:45:32 pm'!

!DecompilerConstructor methodsFor: 'constructor' stamp: 'tao 3/3/98 
codeMethod: selector block: block tempVars: vars primitive: primitive 
class: class 
	| node precedence regenComment |
	node _ self codeSelector: selector code: nil.
	precedence _ selector isInfix
				ifTrue: [2]
				ifFalse: [selector isKeyword
						ifTrue: [3]
						ifFalse: [1]].
	tempVars _ vars.
	node _ MethodNode new
				selector: node
				arguments: (tempVars copyFrom: 1 to: nArgs)
				precedence: precedence
				temporaries: (tempVars copyFrom: nArgs + 1 to: tempVars size)
				block: block
				encoder: (Encoder new initScopeAndLiteralTables
						nTemps: tempVars size
						literals: literalValues
						class: class)
				primitive: primitive.
	regenComment _ OrderedCollection
		with: 'source automatically re-generated by the Decompiler'
		with: 'temporary variable names may have been substituted with t1, 
	node comment:
		(node comment isNil
			ifTrue: [regenComment]
			ifFalse: [node comment addAllFirst: regenComment; yourself]).
	^ node! !

     -- tim

More information about the Squeak-dev mailing list