127
|
1 |
"/
|
|
2 |
"/ $Header$
|
|
3 |
"/
|
209
|
4 |
"/ ST/X startup command file:
|
|
5 |
"/
|
127
|
6 |
"/ bytecode compiler frontend for smalltalk
|
161
|
7 |
"/ usage: stbc file.st
|
127
|
8 |
"/
|
161
|
9 |
"/ creates file.cls, which can be binary loaded.
|
|
10 |
"/
|
|
11 |
"/ Notice:
|
|
12 |
"/ this is an experiment to provide a tool which looks like javac;
|
|
13 |
"/ stbc is actually not used in the current system.
|
|
14 |
"/ (the same functionality is provided by the browsers fileOut-binary function)
|
|
15 |
"/
|
|
16 |
"/ By the way - this is an example for a headless application.
|
127
|
17 |
|
|
18 |
"/ load the files, save binary versions
|
|
19 |
|
|
20 |
|args|
|
|
21 |
|
161
|
22 |
Compiler stcCompilation:#never.
|
129
|
23 |
Object userInterruptSignal handlerBlock:[:ex | Smalltalk exit].
|
|
24 |
|
127
|
25 |
args := Smalltalk commandLineArguments.
|
|
26 |
args do:[:arg |
|
|
27 |
|inFile outFile baseName className class|
|
|
28 |
|
|
29 |
(arg startsWith:'-') ifFalse:[
|
|
30 |
inFile := arg asFilename.
|
195
|
31 |
('stbc [info]: loading ' , inFile name , ' ...') infoPrintCR.
|
128
|
32 |
Object errorSignal handle:[:ex |
|
195
|
33 |
'stbc [error]: error while loading: ' errorPrint. ex errorString errorPrintCR.
|
161
|
34 |
] do:[
|
128
|
35 |
Smalltalk fileIn:inFile name.
|
|
36 |
].
|
195
|
37 |
('stbc [info]: done loading') errorPrintCR.
|
127
|
38 |
|
|
39 |
baseName := inFile withoutSuffix.
|
|
40 |
className := baseName baseName.
|
|
41 |
outFile := baseName construct:'.cls'.
|
|
42 |
|
128
|
43 |
className := Smalltalk classNameForFile:className.
|
127
|
44 |
class := Smalltalk classNamed:className.
|
|
45 |
class notNil ifTrue:[
|
195
|
46 |
('stbc [info]: saving ' , class name , ' ...') infoPrintCR.
|
127
|
47 |
class binaryFileOutWithSourceMode:#reference
|
128
|
48 |
] ifFalse:[
|
195
|
49 |
('stbc [error]: no class for ' , className) errorPrintCR
|
127
|
50 |
]
|
|
51 |
]
|
|
52 |
].
|
|
53 |
!
|
|
54 |
|
|
55 |
Smalltalk exit.
|
|
56 |
!
|