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