stbc.rc
author Claus Gittinger <cg@exept.de>
Thu, 06 May 1999 12:23:51 +0200
changeset 349 97acd4385192
parent 209 22793de5d56e
child 381 45c00a5b27ab
permissions -rw-r--r--
*** empty log message ***

"/
"/ $Header$
"/
"/ ST/X startup command file:
"/
"/ 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.
	('stbc [info]: loading ' , inFile name , ' ...') infoPrintCR.
	Object errorSignal handle:[:ex |
	    'stbc [error]: error while loading: ' errorPrint. ex errorString errorPrintCR.
	] do:[
	    Smalltalk fileIn:inFile name.
	].
	('stbc [info]: done loading') errorPrintCR.

	baseName := inFile withoutSuffix.
	className := baseName baseName.
	outFile := baseName construct:'.cls'.

	className := Smalltalk classNameForFile:className.
	class := Smalltalk classNamed:className.
	class notNil ifTrue:[
	    ('stbc [info]: saving ' , class name , ' ...') infoPrintCR.
	    class binaryFileOutWithSourceMode:#reference
	] ifFalse:[
	    ('stbc [error]: no class for ' , className) errorPrintCR
	]
    ]
].
!

Smalltalk exit.
!