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