stbc.rc
author Claus Gittinger <cg@exept.de>
Fri, 08 Nov 1996 19:45:36 +0100
changeset 167 b1b75bc122f3
parent 161 4a5bc7860889
child 195 1cf850844da9
permissions -rw-r--r--
*** empty log message ***

"/
"/ $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.
!