author | Jan Vrany <jan.vrany@labware.com> |
Thu, 06 Aug 2020 09:33:44 +0100 | |
branch | jv |
changeset 1626 | 62ac134d4f7f |
parent 609 | f0f51d4a0066 |
permissions | -rw-r--r-- |
609 | 1 |
"/ Encoding: iso8859-1 |
127 | 2 |
"/ |
3 |
"/ $Header$ |
|
4 |
"/ |
|
399 | 5 |
"/ MIMEType: application/x-smalltalk-source |
6 |
"/ |
|
209 | 7 |
"/ ST/X startup command file: |
8 |
"/ |
|
127 | 9 |
"/ bytecode compiler frontend for smalltalk |
161 | 10 |
"/ usage: stbc file.st |
127 | 11 |
"/ |
161 | 12 |
"/ creates file.cls, which can be binary loaded. |
13 |
"/ |
|
609 | 14 |
"/ Notice: |
15 |
"/ this is an experiment to provide a tool which looks like javac; |
|
161 | 16 |
"/ stbc is actually not used in the current system. |
17 |
"/ (the same functionality is provided by the browsers fileOut-binary function) |
|
18 |
"/ |
|
19 |
"/ By the way - this is an example for a headless application. |
|
127 | 20 |
|
21 |
"/ load the files, save binary versions |
|
22 |
||
381
45c00a5b27ab
allow reading of .st files without writing them (-r)
Stefan Vogel <sv@exept.de>
parents:
209
diff
changeset
|
23 |
|args readOnly| |
127 | 24 |
|
382 | 25 |
ObjectMemory infoPrinting: false. |
26 |
"/ObjectMemory debugPrinting: true. |
|
27 |
Object infoPrinting: false. |
|
28 |
Smalltalk silentLoading:true. |
|
29 |
||
161 | 30 |
Compiler stcCompilation:#never. |
387 | 31 |
Compiler warnSTXSpecials:false. |
32 |
Compiler warnings:false. |
|
127 | 33 |
|
480 | 34 |
[ |
35 |
readOnly := false. |
|
36 |
args := Smalltalk commandLineArguments. |
|
37 |
args do:[:arg | |
|
38 |
|inFile outFile baseName className class| |
|
39 |
||
40 |
arg = '-r' ifTrue:[ |
|
41 |
readOnly := true |
|
128 | 42 |
]. |
480 | 43 |
(arg startsWith:'-') ifFalse:[ |
44 |
inFile := arg asFilename. |
|
45 |
('stbc [info]: loading ' , inFile name , ' ...') errorPrintCR. |
|
46 |
Object errorSignal handle:[:ex | |
|
47 |
'stbc [error]: error while loading: ' errorPrint. ex errorString errorPrintCR. |
|
48 |
] do:[ |
|
49 |
Smalltalk fileIn:inFile name. |
|
50 |
]. |
|
51 |
('stbc [info]: loaded ' , inFile name) errorPrintCR. |
|
127 | 52 |
|
480 | 53 |
readOnly ifFalse:[ |
54 |
baseName := inFile withoutSuffix. |
|
55 |
className := baseName baseName. |
|
56 |
outFile := baseName withSuffix:'cls'. |
|
127 | 57 |
|
480 | 58 |
className := Smalltalk classNameForFile:className. |
59 |
class := Smalltalk classNamed:className. |
|
60 |
class notNil ifTrue:[ |
|
61 |
('stbc [info]: saving ' , class name , ' into ', outFile pathName, ' ...') errorPrintCR. |
|
62 |
class binaryFileOutWithSourceMode:#reference as:outFile. |
|
63 |
] ifFalse:[ |
|
64 |
('stbc [error]: no class for ' , className) errorPrintCR |
|
65 |
]. |
|
381
45c00a5b27ab
allow reading of .st files without writing them (-r)
Stefan Vogel <sv@exept.de>
parents:
209
diff
changeset
|
66 |
]. |
480 | 67 |
readOnly := false. |
68 |
] |
|
69 |
]. |
|
70 |
] on:UserInterruptSignal do:[:ex| |
|
71 |
('stbc [error]: aborted by user') errorPrintCR. |
|
72 |
Smalltalk exit. |
|
127 | 73 |
]. |
74 |
! |
|
480 | 75 |
('stbc [info]: done') errorPrintCR. |
127 | 76 |
Smalltalk exit. |
77 |
! |