1 "run this with -Z to write clean image"
6 {| doclass totalwin file srcsize |
10 cls methods do: [:m :mn :msgs :p |
11 "cls print. '>>' print. m name printNl."
12 srcsize := srcsize + m text size.
15 p warningBlock: [:msg :line |
16 msgs addLast: 'WARNING near line ' + line asString + ': ' + msg.
18 p errorBlock: [:msg :line |
19 msgs addLast: 'ERROR near line ' + line asString + ': ' + msg.
21 mn := cls compileMethod: m text withCompiler: p.
22 msgs isEmpty ifTrue: [
23 p := (m byteCodes size) - (mn byteCodes size).
24 totalwin := totalwin + p.
26 cls print. '>>' print. m name print. ' win: ' print. p printNl.
28 cls replaceMethod: m name with: mn.
30 cls print. '>>' print. m name print. ' win: ' print.
32 p := (m byteCodes size) - (mn byteCodes size).
33 totalwin := totalwin + p.
35 cls replaceMethod: m name with: mn.
36 ] ifNil: [ 'unknown' printNl. ].
38 System isStdOutTTY ifTrue: [
39 (i firstChar = $W ifTrue: [ '\e[31m' ] ifFalse: [ '\e[41m' ]) print.
42 System isStdOutTTY ifTrue: [ '\e[0m' printNl ] ifFalse: [ '\n' print ].
50 globals keysAndValuesDo: [:name :value |
51 ((value isKindOf: Class) and: [ (name asString from: 1 to: 4) ~= 'Meta' ]) ifTrue: [
52 doclass value: (value class).
57 'total source code size: ' print. srcsize print. ' (' print. (srcsize / 1024) print. 'kb)' printNl.
58 'total bytecode win: ' print. totalwin printNl.
60 cliArgs size > 1 ifTrue: [
61 doclass := cliArgs at: 2.
62 'MESSAGE: writing image to ' print. doclass printNl.
63 file := File openWrite: doclass.
64 file opened ifFalse: [ ^self error: 'cannot open image file' ].