"/
"/ $Header$
"/
"/ bytecode compiler frontend for smalltalk
"/ usage: stbc file.st
"/
"/ creates file.cls, which can be binary loaded.
"/
"/ Notice:
"/ this is an experiment to provide a tool which looks like javac;
"/ stbc is actually not used in the current system.
"/ (the same functionality is provided by the browsers fileOut-binary function)
"/
"/ By the way - this is an example for a headless application.
"/ load the files, save binary versions
|args|
Compiler stcCompilation:#never.
Object userInterruptSignal handlerBlock:[:ex | Smalltalk exit].
args := Smalltalk commandLineArguments.
args do:[:arg |
|inFile outFile baseName className class|
(arg startsWith:'-') ifFalse:[
inFile := arg asFilename.
('loading ' , inFile name , ' ...') errorPrintCR.
Object errorSignal handle:[:ex |
'error while loading: ' errorPrint. ex errorString errorPrintCR.
] do:[
Smalltalk fileIn:inFile name.
].
('done loading') errorPrintCR.
baseName := inFile withoutSuffix.
className := baseName baseName.
outFile := baseName construct:'.cls'.
className := Smalltalk classNameForFile:className.
class := Smalltalk classNamed:className.
class notNil ifTrue:[
('saving ' , class name , ' ...') errorPrintCR.
class binaryFileOutWithSourceMode:#reference
] ifFalse:[
('no class for ' , className) errorPrintCR
]
]
].
!
Smalltalk exit.
!