author | Claus Gittinger <cg@exept.de> |
Mon, 05 Aug 1996 18:57:35 +0200 | |
changeset 325 | c94aaca6f94c |
parent 323 | 0d6e05191a9b |
child 328 | c63c54ff95d3 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
45 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Parser subclass:#ByteCodeCompiler |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
14 |
instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
15 |
maxStackDepth relocList' |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
16 |
classVariableNames:'JumpToAbsJump SequenceNumber STCCompilationDefines |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
17 |
STCCompilationIncludes STCCompilationOptions STCCompilation |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
18 |
ShareCode STCKeepCIntermediate STCModulePath' |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
19 |
poolDictionaries:'' |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
20 |
category:'System-Compiler' |
0 | 21 |
! |
22 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
23 |
!ByteCodeCompiler class methodsFor:'documentation'! |
3 | 24 |
|
141 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
128
diff
changeset
|
37 |
! |
20 | 38 |
|
3 | 39 |
documentation |
40 |
" |
|
19 | 41 |
This class performs compilation into ByteCodes. |
42 |
First, parsing is done using superclass methods, |
|
43 |
then the parse-tree is converted into an array of symbolic codes |
|
44 |
and a relocation table; |
|
45 |
these two are finally combined into a byteArray of the codes. |
|
0 | 46 |
|
19 | 47 |
(the intermediate step through symbolic codes is for debugging |
48 |
only - it will vanish) |
|
49 |
||
50 |
There are many dependencies to the run-time-system (especially the |
|
51 |
interpreter) in here - be careful when playing around ... |
|
0 | 52 |
|
259 | 53 |
[Instance variables:] |
0 | 54 |
|
259 | 55 |
codeBytes <ByteArry> bytecodes |
56 |
codeIndex <SmallInteger> next index to put into code array |
|
57 |
litArray <OrderedCollection> literals |
|
58 |
stackDelta <SmallInteger> return value of byteCodeFor: |
|
59 |
extra <Symbol> return value of byteCodeFor: |
|
60 |
lineno <Boolean> return value of byteCodeFor: |
|
61 |
extraLiteral <Symbol> return value of byteCodeFor: |
|
62 |
maxStackDepth <SmallInteger> stack need of method |
|
63 |
relocList <Array> used temporary for relocation |
|
19 | 64 |
|
259 | 65 |
[Class variables:] |
19 | 66 |
|
259 | 67 |
JumpToAbsJump <Dictionary> internal table to map opcodes |
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
68 |
|
259 | 69 |
SequenceNumber <Integer> counting intermediate stc-compiled |
70 |
objects (for unique o-file naming) |
|
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
71 |
|
259 | 72 |
STCCompilationDefines passed to stc as command line arguments |
73 |
STCCompilationIncludes |
|
74 |
STCCompilationOptions |
|
75 |
<String> |
|
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
76 |
|
259 | 77 |
STCCompilation <Symbol> #always, #primitiveOnly or #never |
78 |
controls when stc compilation is wanted |
|
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
79 |
|
259 | 80 |
ShareCode <Boolean> reuse byteArrays for common (simple) code sequences |
81 |
This is normally a 'good' optimization, |
|
82 |
expect if you plan to modify the byteCodes. |
|
263 | 83 |
|
84 |
[author:] |
|
85 |
Claus Gittinger |
|
86 |
||
3 | 87 |
" |
98 | 88 |
! ! |
89 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
90 |
!ByteCodeCompiler class methodsFor:'initialization'! |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
91 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
92 |
initialize |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
93 |
ShareCode := true. |
295 | 94 |
STCKeepCIntermediate := false. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
95 |
STCModulePath := './modules'. |
211
1fd13827a2fc
ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
96 |
|
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
97 |
"Modified: 12.7.1996 / 12:14:53 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
98 |
! ! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
99 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
100 |
!ByteCodeCompiler class methodsFor:'compiling methods'! |
98 | 101 |
|
0 | 102 |
compile:methodText forClass:classToCompileFor |
103 |
"compile a source-string for a method in classToCompileFor" |
|
104 |
||
105 |
^ self compile:methodText |
|
45 | 106 |
forClass:classToCompileFor |
107 |
inCategory:'others' |
|
108 |
notifying:nil |
|
109 |
install:true |
|
110 |
skipIfSame:false |
|
111 |
silent:false |
|
0 | 112 |
! |
113 |
||
114 |
compile:aString forClass:aClass inCategory:cat |
|
115 |
"compile a source-string for a method in classToCompileFor. |
|
116 |
The method will get cat as category" |
|
117 |
||
118 |
^ self compile:aString |
|
45 | 119 |
forClass:aClass |
120 |
inCategory:cat |
|
121 |
notifying:nil |
|
122 |
install:true |
|
123 |
skipIfSame:false |
|
124 |
silent:false |
|
0 | 125 |
! |
126 |
||
84 | 127 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
0 | 128 |
"compile a source-string for a method in classToCompileFor. |
84 | 129 |
errors are forwarded to requestor. |
0 | 130 |
The method will get cat as category" |
131 |
||
132 |
^ self compile:aString |
|
45 | 133 |
forClass:aClass |
134 |
inCategory:cat |
|
84 | 135 |
notifying:requestor |
45 | 136 |
install:true |
137 |
skipIfSame:false |
|
138 |
silent:false |
|
0 | 139 |
! |
140 |
||
141 | 141 |
compile:aString forClass:aClass inCategory:cat notifying:requestor install:install |
142 |
"compile a source-string for a method in classToCompileFor. |
|
143 |
The install-argument controls if the method is to be installed into the |
|
144 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
145 |
Errors are forwarded to requestor. The method will get cat as category" |
|
146 |
||
147 |
^ self compile:aString |
|
148 |
forClass:aClass |
|
149 |
inCategory:cat |
|
150 |
notifying:requestor |
|
151 |
install:install |
|
152 |
skipIfSame:false |
|
153 |
silent:false |
|
154 |
! |
|
155 |
||
156 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
|
157 |
install:install skipIfSame:skipIfSame |
|
158 |
"compile a source-string for a method in classToCompileFor. |
|
159 |
The install-argument controls if the method is to be installed into the |
|
160 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
161 |
Errors are forwarded to requestor. The method will get cat as category. |
|
162 |
If skipIsSame is true, and the source is the same as an existing |
|
163 |
methods source, this is a noop (for fast fileIn)." |
|
164 |
||
165 |
^ self compile:aString |
|
166 |
forClass:aClass |
|
167 |
inCategory:cat |
|
168 |
notifying:requestor |
|
169 |
install:install |
|
170 |
skipIfSame:skipIfSame |
|
171 |
silent:false |
|
172 |
! |
|
173 |
||
84 | 174 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
175 |
install:install skipIfSame:skipIfSame silent:silent |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
176 |
|
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
177 |
^ self |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
178 |
compile:aString |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
179 |
forClass:aClass |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
180 |
inCategory:cat |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
181 |
notifying:requestor |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
182 |
install:install |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
183 |
skipIfSame:skipIfSame |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
184 |
silent:silent |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
185 |
foldConstants:true |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
186 |
! |
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
187 |
|
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
188 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
189 |
install:install skipIfSame:skipIfSame silent:silent foldConstants:fold |
20 | 190 |
|
191 |
"the basic workhorse method for compiling: |
|
0 | 192 |
compile a source-string for a method in classToCompileFor. |
84 | 193 |
errors are forwarded to requestor (report on Transcript and return |
194 |
#Error, if requestor is nil). |
|
0 | 195 |
|
20 | 196 |
The new method will get cat as category. |
197 |
If install is true, the method will go into the classes method-table, |
|
198 |
otherwise the method is simply returned (for anonymous methods). |
|
0 | 199 |
If skipIsSame is true, and the source is the same as an existing |
20 | 200 |
methods source, this is a noop (for fast fileIn). |
201 |
The argument, silent controls if errors are to be reported." |
|
0 | 202 |
|
54 | 203 |
|compiler newMethod tree lits symbolicCodeArray oldMethod lazy silencio |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
204 |
sourceFile sourceStream newSource primNr pos sel keptOldCode msg answer| |
0 | 205 |
|
206 |
aString isNil ifTrue:[^ nil]. |
|
54 | 207 |
silencio := silent or:[Smalltalk silentLoading == true]. |
0 | 208 |
|
19 | 209 |
"lazy compilation is EXPERIMENTAL" |
210 |
lazy := (LazyCompilation == true) and:[install]. |
|
211 |
||
0 | 212 |
"create a compiler, let it parse and create the parsetree" |
213 |
||
54 | 214 |
compiler := self for:(ReadStream on:aString) in:aClass. |
84 | 215 |
compiler parseForCode. |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
216 |
fold ifFalse:[compiler foldConstants:nil]. |
84 | 217 |
compiler notifying:requestor. |
54 | 218 |
silent ifTrue:[ |
219 |
"/ compiler ignoreErrors. |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
220 |
compiler ignoreWarnings |
54 | 221 |
]. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
222 |
"/ compiler nextToken. |
0 | 223 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
224 |
compiler parseError:'syntax error in method specification'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
225 |
tree := #Error |
0 | 226 |
] ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
227 |
lazy ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
228 |
"check if same source" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
229 |
(skipIfSame and:[(sel := compiler selector) notNil]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
230 |
oldMethod := aClass compiledMethodAt:sel. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
231 |
oldMethod notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
232 |
oldMethod source = aString ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
233 |
oldMethod isInvalid ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
234 |
silencio ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
235 |
Transcript showCR:(' unchanged: ',aClass name,' ',compiler selector) |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
236 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
237 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
238 |
same. however, category may be different |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
239 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
240 |
(cat notNil and:[cat ~= oldMethod category]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
241 |
oldMethod category:cat. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
242 |
oldMethod changed:#category. |
191 | 243 |
"/ aClass updateRevisionString. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
244 |
aClass addChangeRecordForMethodCategory:oldMethod category:cat. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
245 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
246 |
^ oldMethod |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
247 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
248 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
249 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
250 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
251 |
tree := compiler parseMethodBody. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
252 |
compiler tree:tree. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
253 |
] |
0 | 254 |
]. |
255 |
||
256 |
(compiler errorFlag or:[tree == #Error]) ifTrue:[ |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
257 |
compiler showErrorMessageForClass:aClass. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
258 |
^ #Error |
0 | 259 |
]. |
260 |
||
191 | 261 |
sel := compiler selector. |
19 | 262 |
"if no error and also no selector ..." |
90 | 263 |
sel isNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
264 |
"... it was just a comment or other empty stuff" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
265 |
^ nil |
0 | 266 |
]. |
267 |
||
191 | 268 |
lazy ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
269 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
270 |
freak-out support ... |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
271 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
272 |
(compiler hasNonOptionalPrimitiveCode |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
273 |
or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode]) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
274 |
or:[STCCompilation == #always and:[sel ~~ #doIt]]]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
275 |
newMethod := compiler |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
276 |
compileToMachineCode:aString |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
277 |
forClass:aClass |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
278 |
inCategory:cat |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
279 |
notifying:requestor |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
280 |
install:install |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
281 |
skipIfSame:skipIfSame |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
282 |
silent:silent. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
283 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
284 |
newMethod == #Error ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
285 |
compiler showErrorMessageForClass:aClass. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
286 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
287 |
]. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
288 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
289 |
(newMethod == #CannotLoad) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
290 |
newMethod := compiler trappingStubMethodFor:aString inCategory:cat. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
291 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
292 |
keptOldCode := false. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
293 |
install ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
294 |
"/ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
295 |
"/ be very careful with existing methods |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
296 |
"/ (otherwise, you could easily make your system unusable in systems which cannot load) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
297 |
"/ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
298 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
299 |
oldMethod := aClass compiledMethodAt:sel |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
300 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
301 |
(oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
302 |
answer := Dialog |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
303 |
confirm:'installation of binary code is not possible or disabled. |
97 | 304 |
|
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
305 |
Shall I use the old methods functionality |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
306 |
or instead create a dummy trap method for it ? |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
307 |
|
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
308 |
Hint: |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
309 |
if that method is needed by the system, you better leave the |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
310 |
original functionality in the system. |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
311 |
|
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
312 |
Close this warnBox to abort the compilation. |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
313 |
' |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
314 |
yesLabel:'trap code' |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
315 |
noLabel:'keep old'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
316 |
answer isNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
317 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
318 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
319 |
answer == false ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
320 |
newMethod code:(oldMethod code). |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
321 |
keptOldCode := true. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
322 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
323 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
324 |
aClass addSelector:sel withMethod:newMethod |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
325 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
326 |
Transcript show:'*** '. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
327 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
328 |
Transcript show:(sel ,' ') |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
329 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
330 |
keptOldCode ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
331 |
msg := 'not really compiled - method still shows previous behavior'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
332 |
] ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
333 |
msg := 'not compiled to machine code - created a stub instead.'. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
334 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
335 |
Transcript showCR:msg. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
336 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
337 |
^ newMethod |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
338 |
]. |
19 | 339 |
]. |
340 |
||
54 | 341 |
" |
342 |
EXPERIMENTAL: quick loading |
|
343 |
only create a lazyMethod, which has no byteCode and will |
|
344 |
compile itself when first called. |
|
345 |
" |
|
19 | 346 |
lazy ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
347 |
newMethod := LazyMethod new. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
348 |
(ClassCategoryReader sourceMode == #sourceReference) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
349 |
sourceFile := ObjectMemory nameForSources. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
350 |
sourceFile notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
351 |
sourceStream := sourceFile asFilename appendingWriteStream. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
352 |
] |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
353 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
354 |
sourceStream isNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
355 |
newMethod source:aString. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
356 |
] ifFalse:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
357 |
sourceStream setToEnd. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
358 |
pos := sourceStream position. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
359 |
sourceStream nextChunkPut:aString. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
360 |
sourceStream close. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
361 |
newMethod sourceFilename:sourceFile position:pos. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
362 |
]. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
363 |
newMethod category:cat. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
364 |
Project notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
365 |
newMethod package:(Project currentPackageName) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
366 |
]. |
19 | 367 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
368 |
aClass addSelector:sel withLazyMethod:newMethod. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
369 |
^ newMethod |
19 | 370 |
]. |
371 |
||
90 | 372 |
(primNr := compiler primitiveNumber) isNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
373 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
374 |
produce symbolic code first |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
375 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
376 |
symbolicCodeArray := compiler genSymbolicCode. |
90 | 377 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
378 |
(symbolicCodeArray == #Error) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
379 |
Transcript show:' '. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
380 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
381 |
Transcript show:(sel ,' ') |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
382 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
383 |
Transcript showCR:'translation error'. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
384 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
385 |
]. |
0 | 386 |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
387 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
388 |
take this, producing bytecode |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
389 |
(someone willin' to make machine code :-) |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
390 |
" |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
391 |
((compiler genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
392 |
Transcript show:' '. |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
393 |
sel notNil ifTrue:[ |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
394 |
Transcript show:(sel ,' ') |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
395 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
396 |
Transcript showCR:'relocation error - must be simplified'. |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
397 |
^ #Error |
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
398 |
]. |
0 | 399 |
]. |
400 |
||
54 | 401 |
" |
402 |
finally create the new method-object |
|
403 |
" |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
404 |
newMethod := compiler createMethod. |
90 | 405 |
primNr notNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
406 |
newMethod code:(compiler checkForPrimitiveCode:primNr). |
78 | 407 |
] ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
408 |
newMethod byteCode:(compiler code). |
78 | 409 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
410 |
"/ newMethod numberOfMethodVars:(compiler numberOfMethodVars). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
411 |
"/ newMethod numberOfMethodArgs:(compiler numberOfMethodArgs). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
412 |
"/ newMethod stackSize:(compiler maxStackDepth). |
19 | 413 |
|
54 | 414 |
" |
415 |
if there where any corrections, install the updated source |
|
416 |
" |
|
90 | 417 |
(newSource := compiler correctedSource) notNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
418 |
newMethod source:newSource |
19 | 419 |
] ifFalse:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
420 |
newMethod source:aString. |
19 | 421 |
]. |
0 | 422 |
newMethod category:cat. |
54 | 423 |
Project notNil ifTrue:[ |
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
424 |
newMethod package:(Project currentPackageName) |
54 | 425 |
]. |
0 | 426 |
|
427 |
install ifTrue:[ |
|
256
ae09ebb4aa35
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
253
diff
changeset
|
428 |
aClass addSelector:sel withMethod:newMethod |
0 | 429 |
]. |
430 |
||
54 | 431 |
silencio ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
432 |
Transcript showCR:(' compiled: ', aClass name,' ', sel) |
0 | 433 |
]. |
434 |
||
435 |
^ newMethod |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
436 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
437 |
"Created: 29.10.1995 / 19:59:36 / cg" |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
438 |
"Modified: 18.5.1996 / 16:39:55 / cg" |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
439 |
"Modified: 24.6.1996 / 12:41:13 / stefan" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
440 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
441 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
442 |
compile:methodText forClass:classToCompileFor notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
443 |
"compile a source-string for a method in classToCompileFor. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
444 |
Errors are forwarded to requestor." |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
445 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
446 |
^ self compile:methodText |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
447 |
forClass:classToCompileFor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
448 |
inCategory:'others' |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
449 |
notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
450 |
install:true |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
451 |
skipIfSame:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
452 |
silent:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
453 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
454 |
|
141 | 455 |
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock |
456 |
"name alias for ST-80 compatibility" |
|
457 |
||
458 |
|m| |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
459 |
|
141 | 460 |
m := self |
461 |
compile:textOrStream |
|
462 |
forClass:aClass |
|
463 |
inCategory:'others' |
|
464 |
notifying:requestor |
|
465 |
install:true |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
466 |
skipIfSame:false |
141 | 467 |
silent:false. |
468 |
m == #Error ifTrue:[ |
|
469 |
^ exceptionBlock value |
|
470 |
]. |
|
471 |
^ m |
|
472 |
||
0 | 473 |
! ! |
474 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
475 |
!ByteCodeCompiler class methodsFor:'constants'! |
15 | 476 |
|
477 |
byteCodeFor:aSymbol |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
478 |
"returns the numeric code for some symbolic bytecodes." |
15 | 479 |
|
25 | 480 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
481 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
482 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
483 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
484 |
(aSymbol == #retTop) ifTrue:[^ 0]. |
|
485 |
||
15 | 486 |
(aSymbol == #push0) ifTrue:[^120]. |
487 |
(aSymbol == #push1) ifTrue:[^121]. |
|
488 |
(aSymbol == #push2) ifTrue:[^139]. |
|
489 |
(aSymbol == #pushMinus1) ifTrue:[^122]. |
|
490 |
(aSymbol == #pushNil) ifTrue:[^ 10]. |
|
491 |
(aSymbol == #pushTrue) ifTrue:[^ 11]. |
|
492 |
(aSymbol == #pushFalse) ifTrue:[^ 12]. |
|
493 |
(aSymbol == #pushSelf) ifTrue:[^ 15]. |
|
494 |
self error |
|
495 |
! ! |
|
496 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
497 |
!ByteCodeCompiler class methodsFor:'stc compilation defaults'! |
54 | 498 |
|
141 | 499 |
canCreateMachineCode |
500 |
"return true, if compilation to machine code is supported. |
|
501 |
Currently, all SYSV4 and Linux systems do so; |
|
502 |
REAL/IX, AIX and HPUX do not (due to the need for dynamic loading |
|
503 |
of object files, which is not supported by those). |
|
504 |
MIPS ULTRIX is almost finished, but not yet released. |
|
124 | 505 |
|
141 | 506 |
However, if no compiler is around (i.e. the demo distribution), |
507 |
there is no chance ..." |
|
508 |
||
509 |
|canDo| |
|
510 |
||
511 |
ObjectFileLoader isNil ifTrue:[^ false]. |
|
512 |
ObjectFileLoader canLoadObjectFiles ifFalse:[^ false]. |
|
513 |
||
514 |
"/ no chance, if no stc is available |
|
515 |
^ self incrementalStcPath notNil |
|
124 | 516 |
|
517 |
" |
|
141 | 518 |
Compiler canCreateMachineCode |
519 |
" |
|
520 |
||
521 |
"Modified: 13.9.1995 / 15:15:11 / claus" |
|
522 |
! |
|
523 |
||
524 |
incrementalStcPath |
|
525 |
"return the path to the stc command for incremental method compilation, |
|
526 |
or nil if not found." |
|
527 |
||
528 |
|f| |
|
529 |
||
530 |
(f := self stcPathOf:'stc') notNil ifTrue:[^ f]. |
|
531 |
^ self stcPathOf:'demostc' |
|
532 |
||
533 |
" |
|
534 |
Compiler incrementalStcPath |
|
535 |
" |
|
536 |
||
537 |
"Created: 13.9.1995 / 14:36:36 / claus" |
|
538 |
"Modified: 13.9.1995 / 15:15:04 / claus" |
|
539 |
! |
|
540 |
||
541 |
stcCompilation |
|
542 |
"return the flag which controls compilation to machine code. |
|
543 |
If #always, methods are always compiled to machine code (which takes |
|
544 |
longer, but provides faster code). If #none, methods are never compiled |
|
545 |
to machine code, instead for non-primitive ones, compilation is to bytecode |
|
546 |
and for primitive ones, a trapping stub is generated. |
|
547 |
Anything else lets the compiler compile to bytecode, |
|
548 |
except for methods containing primitive code. |
|
549 |
This can be set from your private.rc file or from a workspace |
|
550 |
for selective compilation to machine code." |
|
124 | 551 |
|
141 | 552 |
^ STCCompilation |
54 | 553 |
|
554 |
" |
|
141 | 555 |
Compiler stcCompilation |
124 | 556 |
" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
557 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
558 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
559 |
stcCompilation:how |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
560 |
"set the flag which controls compilation to machine code. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
561 |
If #always, methods are always compiled to machine code (which takes |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
562 |
longer, but provides faster code). If #none, methods are never compiled |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
563 |
to machine code, instead for non-primitive ones, compilation is to bytecode |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
564 |
and for primitive ones, a trapping stub is generated. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
565 |
Anything else lets the compiler compile to bytecode, |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
566 |
except for methods containing primitive code. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
567 |
This can be set from your private.rc file or from a workspace |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
568 |
for selective compilation to machine code." |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
569 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
570 |
|ret| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
571 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
572 |
ret := STCCompilation. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
573 |
STCCompilation := how. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
574 |
^ ret |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
575 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
576 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
577 |
Compiler stcCompilation:#always |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
578 |
Compiler stcCompilation:#never |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
579 |
Compiler stcCompilation:#default |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
580 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
581 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
582 |
|
141 | 583 |
stcCompilationDefines |
584 |
"return the defines used with stc compilation" |
|
585 |
||
586 |
^ STCCompilationDefines |
|
587 |
! |
|
588 |
||
589 |
stcCompilationDefines:aString |
|
590 |
"define the flags (for example, additional -D defines) |
|
591 |
to be used when compiling to machine code. |
|
592 |
These are passed to stc. Can be set from your private.rc file." |
|
593 |
||
594 |
STCCompilationDefines := aString |
|
595 |
||
596 |
" |
|
597 |
Compiler stcCompilationDefines:'-DVGL -DDEBUG' |
|
598 |
" |
|
599 |
! |
|
600 |
||
601 |
stcCompilationIncludes |
|
602 |
"return the includes used with stc compilation" |
|
603 |
||
604 |
^ STCCompilationIncludes |
|
605 |
! |
|
606 |
||
607 |
stcCompilationIncludes:aString |
|
608 |
"define the include directories via additional -I flags. |
|
609 |
These are passed to stc. Can be set in your private.rc file" |
|
610 |
||
611 |
STCCompilationIncludes := aString |
|
612 |
||
613 |
" |
|
614 |
Compiler stcCompilationIncludes:'-I/usr/local/include -I../../include' |
|
615 |
Compiler stcCompilationIncludes:(Compiler stcCompilationIncludes , ' -I../../libxt') |
|
616 |
" |
|
617 |
! |
|
618 |
||
124 | 619 |
stcCompilationOptions |
620 |
"return the options used with stc compilation" |
|
621 |
||
622 |
^ STCCompilationOptions |
|
623 |
! |
|
624 |
||
141 | 625 |
stcCompilationOptions:aString |
626 |
"define the compilation options |
|
627 |
to be used when compiling to machine code. |
|
628 |
These are passed to stc. Can be set from your private.rc file." |
|
101 | 629 |
|
141 | 630 |
STCCompilationOptions := aString |
101 | 631 |
|
632 |
" |
|
141 | 633 |
Compiler stcCompilationOptions:'+optinline' |
101 | 634 |
" |
635 |
! |
|
636 |
||
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
637 |
stcModulePath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
638 |
"return the path, where temporary modules are created" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
639 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
640 |
^ STCModulePath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
641 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
642 |
"Created: 12.7.1996 / 12:15:26 / cg" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
643 |
! |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
644 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
645 |
stcModulePath:aPath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
646 |
"set the path to the directory, where temporary modules are created" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
647 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
648 |
STCModulePath := aPath |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
649 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
650 |
"Created: 12.7.1996 / 12:15:49 / cg" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
651 |
! |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
652 |
|
141 | 653 |
stcPath |
654 |
"return the path to the stc command, or nil if not found." |
|
655 |
||
656 |
^ self stcPathOf:'stc' |
|
657 |
||
658 |
" |
|
659 |
Compiler stcPath |
|
660 |
" |
|
661 |
||
662 |
"Modified: 13.9.1995 / 14:37:26 / claus" |
|
663 |
! |
|
664 |
||
120 | 665 |
stcPathOf:command |
666 |
"return the path to an stc command, or nil if not found." |
|
101 | 667 |
|
668 |
|f| |
|
97 | 669 |
|
120 | 670 |
((f := '../../stc' asFilename construct:command)) isExecutable ifTrue:[ |
101 | 671 |
^ f pathName |
672 |
]. |
|
126 | 673 |
^ OperatingSystem pathOfCommand:command |
97 | 674 |
|
675 |
" |
|
120 | 676 |
Compiler stcPathOf:'stc' |
677 |
" |
|
678 |
||
679 |
"Created: 13.9.1995 / 14:37:16 / claus" |
|
54 | 680 |
! ! |
681 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
682 |
!ByteCodeCompiler methodsFor:'ST-80 compatibility'! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
683 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
684 |
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
685 |
"name alias for ST-80 compatibility" |
0 | 686 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
687 |
^ self class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
688 |
compile:textOrStream |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
689 |
in:aClass |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
690 |
notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
691 |
ifFail:exceptionBlock |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
692 |
"/ |m| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
693 |
"/ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
694 |
"/ m := self class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
695 |
"/ compile:textOrStream |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
696 |
"/ forClass:aClass |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
697 |
"/ inCategory:'no category' |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
698 |
"/ notifying:requestor |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
699 |
"/ install:true |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
700 |
"/ skipIfSame:false |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
701 |
"/ silent:false. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
702 |
"/ m == #Error ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
703 |
"/ ^ exceptionBlock value |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
704 |
"/ ]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
705 |
"/ ^ m |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
706 |
! ! |
0 | 707 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
708 |
!ByteCodeCompiler methodsFor:'accessing'! |
0 | 709 |
|
710 |
code |
|
3 | 711 |
"return the bytecode array - only valid after code-generation" |
0 | 712 |
|
49 | 713 |
^ codeBytes |
0 | 714 |
! |
715 |
||
141 | 716 |
literalArray |
717 |
"return the literal array - only valid after parsing" |
|
718 |
||
719 |
^ litArray |
|
720 |
! |
|
721 |
||
0 | 722 |
maxStackDepth |
723 |
"return the stack-need of the method - only valid after code-generation" |
|
724 |
||
725 |
^ maxStackDepth |
|
726 |
! ! |
|
727 |
||
728 |
!ByteCodeCompiler methodsFor:'code generation'! |
|
729 |
||
141 | 730 |
absJumpFromJump:code |
731 |
"given a jump-symbolic code, return corresponding absolute jump" |
|
0 | 732 |
|
141 | 733 |
JumpToAbsJump isNil ifTrue:[ |
734 |
JumpToAbsJump := IdentityDictionary new. |
|
735 |
JumpToAbsJump at:#jump put:#jumpabs. |
|
736 |
JumpToAbsJump at:#trueJump put:#trueJumpabs. |
|
737 |
JumpToAbsJump at:#falseJump put:#falseJumpabs. |
|
738 |
JumpToAbsJump at:#nilJump put:#nilJumpabs. |
|
739 |
JumpToAbsJump at:#notNilJump put:#notNilJumpabs. |
|
740 |
JumpToAbsJump at:#eqJump put:#eqJumpabs. |
|
741 |
JumpToAbsJump at:#notEqJump put:#notEqJumpabs. |
|
742 |
JumpToAbsJump at:#zeroJump put:#zeroJumpabs. |
|
743 |
JumpToAbsJump at:#notZeroJump put:#notZeroJumpabs. |
|
744 |
JumpToAbsJump at:#makeBlock put:#makeBlockabs. |
|
0 | 745 |
]. |
141 | 746 |
^ JumpToAbsJump at:code |
0 | 747 |
! |
748 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
749 |
addLiteral:anObject |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
750 |
"add a literal to the literalArray - watch for and eliminate |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
751 |
duplicates. return the index of the literal in the Array" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
752 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
753 |
|index class| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
754 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
755 |
litArray isNil ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
756 |
litArray := Array with:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
757 |
^ 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
758 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
759 |
index := litArray identityIndexOf:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
760 |
(index == 0) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
761 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
762 |
reuse constants if same value and same class |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
763 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
764 |
class := anObject class. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
765 |
((class == Float) |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
766 |
or:[class == Fraction]) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
767 |
index := litArray indexOf:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
768 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
769 |
((index == 0) or:[(litArray at:index) class ~~ class]) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
770 |
litArray := litArray copyWith:anObject. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
771 |
^ litArray size |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
772 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
773 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
774 |
^ index |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
775 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
776 |
|
141 | 777 |
addReloc:symIndex |
778 |
"remember to relocate offset at symIndex later ..." |
|
3 | 779 |
|
141 | 780 |
relocList isNil ifTrue:[ |
781 |
relocList := OrderedCollection new. |
|
1 | 782 |
]. |
141 | 783 |
relocList add:symIndex |
1 | 784 |
! |
785 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
786 |
appendByte:aByte |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
787 |
"append a byte to the code-Array, checking for byte-range (debug-only)" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
788 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
789 |
|idx "{Class: SmallInteger }"| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
790 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
791 |
idx := codeIndex. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
792 |
(aByte between:0 and:255) ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
793 |
codeBytes at:idx put:aByte. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
794 |
codeIndex := idx + 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
795 |
] ifFalse:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
796 |
self error:'byte range error'. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
797 |
errorFlag := #Error |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
798 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
799 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
800 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
801 |
appendByteCodeFor:codeSymbol |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
802 |
"append the byteCode for an instructionSymbol to the code-Array" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
803 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
804 |
|idx "{Class: SmallInteger }"| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
805 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
806 |
idx := codeIndex. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
807 |
codeBytes at:idx put:(self byteCodeFor:codeSymbol). |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
808 |
codeIndex := idx + 1 |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
809 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
810 |
|
141 | 811 |
appendEmptyByte |
812 |
"append an empty byte to the code-Array" |
|
3 | 813 |
|
141 | 814 |
|idx "{Class: SmallInteger }"| |
3 | 815 |
|
141 | 816 |
idx := codeIndex. |
817 |
codeBytes at:idx put:0. |
|
818 |
codeIndex := idx + 1 |
|
45 | 819 |
! |
820 |
||
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
821 |
appendEmptyLong |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
822 |
"append an empty long (4 bytes) to the code-Array" |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
823 |
|
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
824 |
|idx "{Class: SmallInteger }"| |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
825 |
|
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
826 |
idx := codeIndex. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
827 |
codeBytes at:idx put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
828 |
codeBytes at:idx+1 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
829 |
codeBytes at:idx+2 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
830 |
codeBytes at:idx+3 put:0. |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
831 |
codeIndex := idx + 4 |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
832 |
! |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
833 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
834 |
appendEmptyShort |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
835 |
"append an empty short (2 bytes) to the code-Array" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
836 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
837 |
|idx "{Class: SmallInteger }"| |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
838 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
839 |
idx := codeIndex. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
840 |
codeBytes at:idx put:0. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
841 |
codeBytes at:idx+1 put:0. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
842 |
codeIndex := idx + 2 |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
843 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
844 |
|
0 | 845 |
appendSignedByte:aByte |
846 |
"append a signedbyte (as in jump-offsets) to the code-Array, |
|
847 |
check range and report an error if invalid" |
|
848 |
||
49 | 849 |
|b "{Class: SmallInteger }" |
850 |
idx "{Class: SmallInteger }"| |
|
0 | 851 |
|
49 | 852 |
idx := codeIndex. |
0 | 853 |
b := aByte. |
854 |
(b >= 0) ifTrue:[ |
|
45 | 855 |
(b > 127) ifTrue:[ |
856 |
self error:'jump-range error'. |
|
857 |
errorFlag := #Error |
|
858 |
]. |
|
49 | 859 |
codeBytes at:idx put:b |
0 | 860 |
] ifFalse:[ |
45 | 861 |
(b < -128) ifTrue:[ |
862 |
self error:'jump-range error'. |
|
863 |
errorFlag := #Error |
|
864 |
]. |
|
49 | 865 |
b := 256 + b |
0 | 866 |
]. |
49 | 867 |
codeBytes at:idx put:b. |
868 |
codeIndex := idx + 1 |
|
0 | 869 |
! |
870 |
||
46 | 871 |
appendSignedWord:aWord |
872 |
"append a signed word to the code-Array, |
|
873 |
check range and report an error if invalid" |
|
874 |
||
49 | 875 |
|w "{Class: SmallInteger }"| |
46 | 876 |
|
877 |
w := aWord. |
|
878 |
(w >= 0) ifTrue:[ |
|
879 |
(w > 16r7FFFF) ifTrue:[ |
|
880 |
self error:'word-range error'. |
|
881 |
errorFlag := #Error |
|
882 |
]. |
|
883 |
] ifFalse:[ |
|
884 |
(w < 16r-8000) ifTrue:[ |
|
885 |
self error:'word-range error'. |
|
886 |
errorFlag := #Error |
|
887 |
]. |
|
888 |
w := (16r10000 + w). |
|
889 |
]. |
|
890 |
self appendWord:w |
|
891 |
! |
|
892 |
||
141 | 893 |
appendWord:aWord |
894 |
"append an unsigned word (low-high) to the code-Array, |
|
895 |
checking for word-range (debug-only)" |
|
896 |
||
897 |
|idx "{Class: SmallInteger }"| |
|
898 |
||
899 |
idx := codeIndex. |
|
900 |
(aWord between:0 and:16rFFFF) ifTrue:[ |
|
901 |
codeBytes at:idx put:(aWord bitAnd:16rFF). |
|
902 |
idx := idx + 1. |
|
903 |
codeBytes at:idx put:(aWord bitShift:-8). |
|
904 |
codeIndex := idx + 1 |
|
905 |
] ifFalse:[ |
|
906 |
self error:'word range error'. |
|
907 |
errorFlag := #Error |
|
908 |
] |
|
909 |
! |
|
910 |
||
0 | 911 |
byteCodeFor:aSymbol |
912 |
"given a symbolic instruction, return the corresponding bytecode. |
|
913 |
as a side-effect, leave number of bytes pushed/popped by this instr. |
|
914 |
in stackDelta, and, if the instruction needs extra arguments, leave |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
915 |
this info in extra. Also lineno is set to true, if this code has line |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
916 |
information and extraLiteral is set if any hidden send is performed by it." |
0 | 917 |
|
918 |
"standard bytecodes" |
|
919 |
||
920 |
(aSymbol == #pushNil) ifTrue:[stackDelta := 1. ^ 10]. |
|
921 |
(aSymbol == #pushTrue) ifTrue:[stackDelta := 1. ^ 11]. |
|
922 |
(aSymbol == #pushFalse) ifTrue:[stackDelta := 1. ^ 12]. |
|
923 |
(aSymbol == #pushLit) ifTrue:[stackDelta := 1. extra := #lit. ^ 14]. |
|
105 | 924 |
(aSymbol == #pushLitS) ifTrue:[stackDelta := 1. extra := #index. ^ 14]. |
0 | 925 |
(aSymbol == #pushSelf) ifTrue:[stackDelta := 1. ^ 15]. |
926 |
(aSymbol == #pushNum) ifTrue:[stackDelta := 1. extra := #number. ^ 16]. |
|
927 |
||
928 |
(aSymbol == #pushMethodArg) ifTrue:[stackDelta := 1. extra := #index. ^ 30]. |
|
929 |
(aSymbol == #pushMethodVar) ifTrue:[stackDelta := 1. extra := #index. ^ 31]. |
|
930 |
(aSymbol == #pushBlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 32]. |
|
931 |
(aSymbol == #pushBlockVar) ifTrue:[stackDelta := 1. extra := #index. ^ 33]. |
|
932 |
(aSymbol == #pushInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 34]. |
|
1 | 933 |
(aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42]. |
934 |
(aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128]. |
|
0 | 935 |
|
936 |
(aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0]. |
|
937 |
(aSymbol == #retSelf) ifTrue:[^5]. |
|
938 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
939 |
(aSymbol == #==) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 45]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
940 |
(aSymbol == #~~) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 46]. |
0 | 941 |
|
942 |
(aSymbol == #falseJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 50]. |
|
943 |
(aSymbol == #trueJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 51]. |
|
944 |
(aSymbol == #nilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 52]. |
|
945 |
(aSymbol == #notNilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 53]. |
|
946 |
(aSymbol == #jump) ifTrue:[extra := #offset. ^ 54]. |
|
1 | 947 |
(aSymbol == #makeBlock) ifTrue:[stackDelta := 1. extra := #offsetNvarNarg. ^ 55]. |
0 | 948 |
(aSymbol == #zeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 56]. |
949 |
(aSymbol == #notZeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 57]. |
|
950 |
(aSymbol == #eqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 58]. |
|
951 |
(aSymbol == #notEqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 59]. |
|
952 |
||
54 | 953 |
(aSymbol == #lineno) ifTrue:[lineno := true. ^ 8]. |
954 |
||
106 | 955 |
(aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19]. |
956 |
(aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20]. |
|
957 |
(aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20]. |
|
117 | 958 |
(aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13]. |
0 | 959 |
|
960 |
(aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18]. |
|
961 |
(aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47]. |
|
962 |
||
117 | 963 |
(aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37]. |
964 |
(aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38]. |
|
965 |
(aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39]. |
|
0 | 966 |
|
117 | 967 |
(aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35]. |
968 |
(aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35]. |
|
969 |
||
970 |
(aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40]. |
|
971 |
(aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 40]. |
|
247 | 972 |
(aSymbol == #pushSpecialGlobal) ifTrue:[stackDelta := 1. extra := #index. ^ 200]. |
117 | 973 |
|
1 | 974 |
(aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129]. |
0 | 975 |
|
117 | 976 |
(aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176]. |
977 |
(aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177]. |
|
105 | 978 |
|
0 | 979 |
"optimized bytecodes" |
980 |
||
981 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
|
982 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
983 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
984 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
985 |
(aSymbol == #retNum) ifTrue:[extra := #number. ^ 127]. |
|
25 | 986 |
(aSymbol == #homeRetTop) ifTrue:[^ 7]. |
0 | 987 |
|
46 | 988 |
(aSymbol == #pushNum16) ifTrue:[stackDelta := 1. extra := #number16. ^ 17]. |
0 | 989 |
(aSymbol == #push0) ifTrue:[stackDelta := 1. ^120]. |
990 |
(aSymbol == #push1) ifTrue:[stackDelta := 1. ^121]. |
|
3 | 991 |
(aSymbol == #push2) ifTrue:[stackDelta := 1. ^139]. |
0 | 992 |
(aSymbol == #pushMinus1) ifTrue:[stackDelta := 1. ^122]. |
993 |
||
106 | 994 |
(aSymbol == #send0) ifTrue:[lineno := true. extra := #index. ^21]. |
995 |
(aSymbol == #send1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^22]. |
|
996 |
(aSymbol == #send2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^23]. |
|
997 |
(aSymbol == #send3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^24]. |
|
0 | 998 |
|
106 | 999 |
(aSymbol == #sendSelf0) ifTrue:[lineno := true. extra := #index. stackDelta := 1. ^180]. |
1000 |
(aSymbol == #sendSelf1) ifTrue:[lineno := true. extra := #index. ^181]. |
|
1001 |
(aSymbol == #sendSelf2) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^182]. |
|
1002 |
(aSymbol == #sendSelf3) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^183]. |
|
1003 |
(aSymbol == #sendSelfDrop0) ifTrue:[lineno := true. extra := #index. ^184]. |
|
1004 |
(aSymbol == #sendSelfDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^185]. |
|
1005 |
(aSymbol == #sendSelfDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^186]. |
|
1006 |
(aSymbol == #sendSelfDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^187]. |
|
0 | 1007 |
|
106 | 1008 |
(aSymbol == #sendDrop) ifTrue:[lineno := true. extra := #special. ^25]. |
1009 |
(aSymbol == #sendDrop0) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^26]. |
|
1010 |
(aSymbol == #sendDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^27]. |
|
1011 |
(aSymbol == #sendDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^28]. |
|
1012 |
(aSymbol == #sendDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -4. ^29]. |
|
0 | 1013 |
|
1014 |
(aSymbol == #pushMethodVar1) ifTrue:[stackDelta := 1. ^80]. |
|
1015 |
(aSymbol == #pushMethodVar2) ifTrue:[stackDelta := 1. ^81]. |
|
1016 |
(aSymbol == #pushMethodVar3) ifTrue:[stackDelta := 1. ^82]. |
|
1017 |
(aSymbol == #pushMethodVar4) ifTrue:[stackDelta := 1. ^83]. |
|
1018 |
(aSymbol == #pushMethodVar5) ifTrue:[stackDelta := 1. ^84]. |
|
1019 |
(aSymbol == #pushMethodVar6) ifTrue:[stackDelta := 1. ^85]. |
|
1020 |
||
1021 |
(aSymbol == #pushMethodArg1) ifTrue:[stackDelta := 1. ^86]. |
|
1022 |
(aSymbol == #pushMethodArg2) ifTrue:[stackDelta := 1. ^87]. |
|
1023 |
(aSymbol == #pushMethodArg3) ifTrue:[stackDelta := 1. ^88]. |
|
1024 |
(aSymbol == #pushMethodArg4) ifTrue:[stackDelta := 1. ^89]. |
|
1025 |
||
1026 |
(aSymbol == #pushInstVar1) ifTrue:[stackDelta := 1. ^90]. |
|
1027 |
(aSymbol == #pushInstVar2) ifTrue:[stackDelta := 1. ^91]. |
|
1028 |
(aSymbol == #pushInstVar3) ifTrue:[stackDelta := 1. ^92]. |
|
1029 |
(aSymbol == #pushInstVar4) ifTrue:[stackDelta := 1. ^93]. |
|
1030 |
(aSymbol == #pushInstVar5) ifTrue:[stackDelta := 1. ^94]. |
|
1031 |
(aSymbol == #pushInstVar6) ifTrue:[stackDelta := 1. ^95]. |
|
1032 |
(aSymbol == #pushInstVar7) ifTrue:[stackDelta := 1. ^96]. |
|
1033 |
(aSymbol == #pushInstVar8) ifTrue:[stackDelta := 1. ^97]. |
|
1034 |
(aSymbol == #pushInstVar9) ifTrue:[stackDelta := 1. ^98]. |
|
1035 |
(aSymbol == #pushInstVar10) ifTrue:[stackDelta := 1. ^99]. |
|
1036 |
||
1037 |
(aSymbol == #storeMethodVar1) ifTrue:[stackDelta := -1. ^100]. |
|
1038 |
(aSymbol == #storeMethodVar2) ifTrue:[stackDelta := -1. ^101]. |
|
1039 |
(aSymbol == #storeMethodVar3) ifTrue:[stackDelta := -1. ^102]. |
|
1040 |
(aSymbol == #storeMethodVar4) ifTrue:[stackDelta := -1. ^103]. |
|
1041 |
(aSymbol == #storeMethodVar5) ifTrue:[stackDelta := -1. ^104]. |
|
1042 |
(aSymbol == #storeMethodVar6) ifTrue:[stackDelta := -1. ^105]. |
|
1043 |
||
1044 |
(aSymbol == #storeInstVar1) ifTrue:[stackDelta := -1. ^110]. |
|
1045 |
(aSymbol == #storeInstVar2) ifTrue:[stackDelta := -1. ^111]. |
|
1046 |
(aSymbol == #storeInstVar3) ifTrue:[stackDelta := -1. ^112]. |
|
1047 |
(aSymbol == #storeInstVar4) ifTrue:[stackDelta := -1. ^113]. |
|
1048 |
(aSymbol == #storeInstVar5) ifTrue:[stackDelta := -1. ^114]. |
|
1049 |
(aSymbol == #storeInstVar6) ifTrue:[stackDelta := -1. ^115]. |
|
1050 |
(aSymbol == #storeInstVar7) ifTrue:[stackDelta := -1. ^116]. |
|
1051 |
(aSymbol == #storeInstVar8) ifTrue:[stackDelta := -1. ^117]. |
|
1052 |
(aSymbol == #storeInstVar9) ifTrue:[stackDelta := -1. ^118]. |
|
1053 |
(aSymbol == #storeInstVar10) ifTrue:[stackDelta := -1. ^119]. |
|
1054 |
||
103 | 1055 |
(aSymbol == #pushLit1) ifTrue:[stackDelta := 1. ^ 222]. |
1056 |
(aSymbol == #pushLit2) ifTrue:[stackDelta := 1. ^ 223]. |
|
1057 |
(aSymbol == #pushLit3) ifTrue:[stackDelta := 1. ^ 224]. |
|
1058 |
(aSymbol == #pushLit4) ifTrue:[stackDelta := 1. ^ 225]. |
|
1059 |
(aSymbol == #pushLit5) ifTrue:[stackDelta := 1. ^ 226]. |
|
1060 |
(aSymbol == #pushLit6) ifTrue:[stackDelta := 1. ^ 227]. |
|
1061 |
(aSymbol == #pushLit7) ifTrue:[stackDelta := 1. ^ 228]. |
|
1062 |
(aSymbol == #pushLit8) ifTrue:[stackDelta := 1. ^ 229]. |
|
1063 |
||
0 | 1064 |
(aSymbol == #retMethodVar1) ifTrue:[^160]. |
1065 |
(aSymbol == #retMethodVar2) ifTrue:[^161]. |
|
1066 |
(aSymbol == #retMethodVar3) ifTrue:[^162]. |
|
1067 |
(aSymbol == #retMethodVar4) ifTrue:[^163]. |
|
1068 |
(aSymbol == #retMethodVar5) ifTrue:[^164]. |
|
1069 |
(aSymbol == #retMethodVar6) ifTrue:[^165]. |
|
1070 |
||
1071 |
(aSymbol == #retInstVar1) ifTrue:[^166]. |
|
1072 |
(aSymbol == #retInstVar2) ifTrue:[^167]. |
|
1073 |
(aSymbol == #retInstVar3) ifTrue:[^168]. |
|
1074 |
(aSymbol == #retInstVar4) ifTrue:[^169]. |
|
1075 |
(aSymbol == #retInstVar5) ifTrue:[^170]. |
|
1076 |
(aSymbol == #retInstVar6) ifTrue:[^171]. |
|
1077 |
(aSymbol == #retInstVar7) ifTrue:[^172]. |
|
1078 |
(aSymbol == #retInstVar8) ifTrue:[^173]. |
|
1079 |
||
1080 |
(aSymbol == #retMethodArg1) ifTrue:[^174]. |
|
1081 |
(aSymbol == #retMethodArg2) ifTrue:[^175]. |
|
1082 |
||
1083 |
(aSymbol == #pushBlockArg1) ifTrue:[stackDelta := 1. ^140]. |
|
1084 |
(aSymbol == #pushBlockArg2) ifTrue:[stackDelta := 1. ^141]. |
|
1085 |
(aSymbol == #pushBlockArg3) ifTrue:[stackDelta := 1. ^142]. |
|
1086 |
(aSymbol == #pushBlockArg4) ifTrue:[stackDelta := 1. ^143]. |
|
1087 |
||
1 | 1088 |
(aSymbol == #pushOuter1BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 43]. |
1089 |
(aSymbol == #pushOuter2BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 44]. |
|
0 | 1090 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1091 |
(aSymbol == #=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^130]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1092 |
(aSymbol == #+) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^131]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1093 |
(aSymbol == #~=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^132]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1094 |
(aSymbol == #-) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^133]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1095 |
(aSymbol == #*) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^230]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1096 |
(aSymbol == #class) ifTrue:[extraLiteral := aSymbol. ^134]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1097 |
(aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. ^106]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1098 |
(aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. ^107]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1099 |
(aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. ^108]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1100 |
(aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. ^109]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1101 |
(aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. ^154]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1102 |
(aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. ^155]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1103 |
(aSymbol == #at:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^135]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1104 |
(aSymbol == #at:put:)ifTrue:[lineno := true. stackDelta := -2. extraLiteral := aSymbol. ^136]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1105 |
(aSymbol == #bitAnd:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^137]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1106 |
(aSymbol == #bitOr:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^138]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1107 |
(aSymbol == #plus1) ifTrue:[lineno := true. extraLiteral := #+. ^123]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1108 |
(aSymbol == #minus1) ifTrue:[lineno := true. extraLiteral := #-. ^124]. |
0 | 1109 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1110 |
(aSymbol == #incMethodVar) ifTrue:[lineno := true. extraLiteral := #+. extra := #index. ^125]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1111 |
(aSymbol == #decMethodVar) ifTrue:[lineno := true. extraLiteral := #-. extra := #index. ^126]. |
0 | 1112 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1113 |
(aSymbol == #eq0) ifTrue:[extraLiteral := #==. ^48]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1114 |
(aSymbol == #ne0) ifTrue:[extraLiteral := #~~. ^49]. |
0 | 1115 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1116 |
(aSymbol == #>) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 145]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1117 |
(aSymbol == #>=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 146]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1118 |
(aSymbol == #<) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 147]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1119 |
(aSymbol == #<=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 148]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1120 |
(aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 149]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1121 |
(aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 150]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1122 |
(aSymbol == #value) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 151]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1123 |
(aSymbol == #value:) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 152]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1124 |
(aSymbol == #value:value:) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -2. ^ 178]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1125 |
(aSymbol == #size) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 153]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1126 |
(aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 158]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1127 |
(aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 159]. |
0 | 1128 |
(aSymbol == #mk0Block) ifTrue:[^ 156]. |
1129 |
(aSymbol == #mkNilBlock) ifTrue:[^ 157]. |
|
1130 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1131 |
(aSymbol == #gt0) ifTrue:[lineno := true. extraLiteral := #>. ^ 212]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1132 |
(aSymbol == #pushgt0) ifTrue:[lineno := true. stackDelta := 1. extraLiteral := #>. ^ 208]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1133 |
(aSymbol == #basicNew) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 211]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1134 |
(aSymbol == #new) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 213]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1135 |
(aSymbol == #basicNew:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 214]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1136 |
(aSymbol == #new:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 215]. |
103 | 1137 |
|
217 | 1138 |
(aSymbol == #pushBlockVar1) ifTrue:[stackDelta := 1. ^ 232]. |
1139 |
(aSymbol == #pushBlockVar2) ifTrue:[stackDelta := 1. ^ 233]. |
|
1140 |
(aSymbol == #pushBlockVar3) ifTrue:[stackDelta := 1. ^ 234]. |
|
1141 |
(aSymbol == #storeBlockVar1) ifTrue:[stackDelta := -1. ^ 235]. |
|
1142 |
(aSymbol == #storeBlockVar2) ifTrue:[stackDelta := -1. ^ 236]. |
|
1143 |
(aSymbol == #storeBlockVar3) ifTrue:[stackDelta := -1. ^ 237]. |
|
1144 |
||
0 | 1145 |
(aSymbol == #falseJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 190]. |
1146 |
(aSymbol == #trueJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 191]. |
|
1147 |
(aSymbol == #nilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 192]. |
|
1148 |
(aSymbol == #notNilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 193]. |
|
1149 |
(aSymbol == #jumpabs) ifTrue:[extra := #absoffset. ^ 194]. |
|
1 | 1150 |
(aSymbol == #makeBlockabs) ifTrue:[stackDelta := 1. extra := #absoffsetNvarNarg. ^ 195]. |
0 | 1151 |
(aSymbol == #zeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 196]. |
1152 |
(aSymbol == #notZeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 197]. |
|
1 | 1153 |
(aSymbol == #eqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 198]. |
1154 |
(aSymbol == #notEqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 199]. |
|
0 | 1155 |
|
1156 |
(aSymbol == #pushThisContext) ifTrue:[stackDelta := 1. ^ 144]. |
|
1157 |
||
76 | 1158 |
(aSymbol == #isNil) ifTrue:[^ 188]. |
1159 |
(aSymbol == #notNil) ifTrue:[^ 189]. |
|
1160 |
(aSymbol == #not) ifTrue:[lineno := true. ^ 179]. |
|
110 | 1161 |
(aSymbol == #&) ifTrue:[lineno := true. ^ 216]. |
1162 |
(aSymbol == #|) ifTrue:[lineno := true. ^ 217]. |
|
76 | 1163 |
|
117 | 1164 |
(aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
1165 |
(aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
|
1166 |
(aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219]. |
|
1167 |
(aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219]. |
|
1168 |
(aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201]. |
|
1169 |
||
1170 |
(aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205]. |
|
1171 |
(aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207]. |
|
1172 |
(aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204]. |
|
1173 |
(aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206]. |
|
1174 |
(aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206]. |
|
106 | 1175 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1176 |
(aSymbol == #top) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1177 |
(aSymbol == #bottom) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1178 |
(aSymbol == #left) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1179 |
(aSymbol == #right) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1180 |
|
217 | 1181 |
(aSymbol == #blockRef) ifTrue:[stackDelta := 0. ^ 238]. |
1182 |
||
0 | 1183 |
self error:'invalid code symbol'. |
1184 |
errorFlag := #Error |
|
117 | 1185 |
|
1186 |
"Modified: 3.9.1995 / 12:58:47 / claus" |
|
217 | 1187 |
"Modified: 1.3.1996 / 00:09:50 / cg" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1188 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1189 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1190 |
checkForCommonCode:symbolicCodeArray |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1191 |
"hook to return the code for common code sequences. |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1192 |
This reduces the in-memory number of byteArrays somewhat. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1193 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1194 |
Not yet fully implemented - just an idea ... theres certainly more to do here |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1195 |
(does it make sense to scan all methods, collect code in a set and unify things |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1196 |
automatically in the background - or upon request ?)" |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1197 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1198 |
|sz insn1| |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1199 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1200 |
(sz := symbolicCodeArray size) == 2 ifTrue:[ |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1201 |
"/ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1202 |
"/ a very common sequence: return the first literal |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1203 |
"/ |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1204 |
(insn1 := symbolicCodeArray at:1) == #pushLit1 ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1205 |
(symbolicCodeArray at:2) == #retTop ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1206 |
^ #[222 0] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1207 |
] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1208 |
] |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1209 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1210 |
sz == 1 ifTrue:[ |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1211 |
"/ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1212 |
"/ another common sequence: return the receiver |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1213 |
"/ |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1214 |
(insn1 := symbolicCodeArray at:1) == #retSelf ifTrue:[ |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1215 |
^ #[5] |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1216 |
]. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1217 |
insn1 == #retTrue ifTrue:[ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1218 |
^ #[2] |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1219 |
]. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1220 |
insn1 == #retFalse ifTrue:[ |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1221 |
^ #[3] |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1222 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1223 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1224 |
^ nil |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1225 |
! |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1226 |
|
141 | 1227 |
checkForPrimitiveCode:nr |
1228 |
"return the code for an ST-80 primitive method. |
|
1229 |
Since many primitives available on ST-80 should also be available |
|
1230 |
somewhere in ST/X, this may work for many primitive numbers. |
|
1231 |
However, more information is needed and more things to be added below. |
|
1232 |
||
1233 |
This was added to allow emulation of (some) ST-80 |
|
1234 |
primitives (to fileIn RemoteInvocation & Monitor41 packages)" |
|
1235 |
||
1236 |
|cls sel| |
|
1237 |
||
1238 |
(nr == 75) ifTrue:[ cls := Object. sel := #identityHash ]. |
|
1239 |
(nr == 110) ifTrue:[ cls := Object. sel := #== ]. |
|
1240 |
(nr == 111) ifTrue:[ cls := Object. sel := #class ]. |
|
1241 |
" |
|
1242 |
should add more here, to be able to fileIn ST-80 methods |
|
1243 |
containing primitive calls (who gives me the numbers ... ?) |
|
1244 |
" |
|
1245 |
cls notNil ifTrue:[ |
|
1246 |
^ (cls compiledMethodAt:sel) code |
|
1247 |
]. |
|
1248 |
^ nil |
|
1249 |
! |
|
1250 |
||
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1251 |
createMethod |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1252 |
|newMethod i| |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1253 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1254 |
newMethod := Method new:(litArray size). |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1255 |
litArray notNil ifTrue:[ |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1256 |
newMethod literals:litArray |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1257 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1258 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1259 |
newMethod numberOfMethodVars:(self numberOfMethodVars). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1260 |
newMethod numberOfMethodArgs:(self numberOfMethodArgs). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1261 |
newMethod stackSize:(self maxStackDepth). |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1262 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1263 |
primitiveResource notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1264 |
newMethod setResourceFlag |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1265 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1266 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1267 |
^ newMethod |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1268 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1269 |
"Created: 18.5.1996 / 16:33:17 / cg" |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1270 |
"Modified: 18.5.1996 / 16:41:31 / cg" |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
1271 |
"Modified: 24.6.1996 / 12:32:50 / stefan" |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1272 |
! |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1273 |
|
141 | 1274 |
genByteCodeFrom:symbolicCodeArray |
1275 |
"convert symbolicCode into bytecodes" |
|
1276 |
||
1277 |
|symIndex "{Class: SmallInteger }" |
|
1278 |
codeSize "{Class: SmallInteger }" |
|
1279 |
symCodeSize "{Class: SmallInteger }" |
|
1280 |
index addr |
|
1281 |
codeSymbol nargs needRetry |
|
1282 |
stackDepth relocInfo level nvars round t| |
|
1283 |
||
1284 |
symbolicCodeArray isNil ifTrue:[^ self]. |
|
1285 |
||
1286 |
round := 0. |
|
1287 |
needRetry := true. |
|
1288 |
symCodeSize := symbolicCodeArray size. |
|
192
5f5ecdcffc67
share common byteCodes - just an idea and more is needed for most compact code
Claus Gittinger <cg@exept.de>
parents:
191
diff
changeset
|
1289 |
ShareCode ifTrue:[ |
280 | 1290 |
codeBytes := self checkForCommonCode:symbolicCodeArray. |
1291 |
codeBytes notNil ifTrue:[ |
|
1292 |
^ self |
|
1293 |
]. |
|
192
5f5ecdcffc67
share common byteCodes - just an idea and more is needed for most compact code
Claus Gittinger <cg@exept.de>
parents:
191
diff
changeset
|
1294 |
]. |
141 | 1295 |
codeSize := symCodeSize. |
1296 |
||
1297 |
[needRetry] whileTrue:[ |
|
280 | 1298 |
stackDepth := 0. |
1299 |
maxStackDepth := 0. |
|
141 | 1300 |
|
280 | 1301 |
codeBytes := ByteArray uninitializedNew:codeSize. |
1302 |
relocInfo := Array basicNew:(codeSize + 1). |
|
1303 |
symIndex := 1. |
|
1304 |
codeIndex := 1. |
|
141 | 1305 |
|
280 | 1306 |
needRetry := false. |
1307 |
round := round + 1. |
|
141 | 1308 |
|
280 | 1309 |
[symIndex <= symCodeSize] whileTrue:[ |
1310 |
relocInfo at:symIndex put:codeIndex. |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1311 |
|
280 | 1312 |
codeSymbol := symbolicCodeArray at:symIndex. |
1313 |
symIndex := symIndex + 1. |
|
1314 |
stackDelta := 0. |
|
1315 |
extra := extraLiteral := nil. |
|
1316 |
lineno := false. |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1317 |
|
280 | 1318 |
self appendByteCodeFor:codeSymbol. |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1319 |
|
280 | 1320 |
extraLiteral notNil ifTrue:[ |
1321 |
self addLiteral:extraLiteral |
|
1322 |
]. |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1323 |
|
280 | 1324 |
lineno ifTrue:[ |
1325 |
self appendByte:((symbolicCodeArray at:symIndex) min:255). |
|
1326 |
symIndex := symIndex + 1 |
|
1327 |
]. |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1328 |
|
280 | 1329 |
extra notNil ifTrue:[ |
1330 |
(extra == #number) ifTrue:[ |
|
1331 |
index := symbolicCodeArray at:symIndex. |
|
1332 |
symIndex := symIndex + 1. |
|
1333 |
self appendSignedByte:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1334 |
|
280 | 1335 |
] ifFalse:[ (extra == #number16) ifTrue:[ |
1336 |
index := symbolicCodeArray at:symIndex. |
|
1337 |
symIndex := symIndex + 2. |
|
1338 |
self appendSignedWord:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1339 |
|
280 | 1340 |
] ifFalse:[ (extra == #unsigned16) ifTrue:[ |
1341 |
index := symbolicCodeArray at:symIndex. |
|
1342 |
symIndex := symIndex + 2. |
|
1343 |
self appendWord:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1344 |
|
280 | 1345 |
] ifFalse:[ (extra == #index) ifTrue:[ |
1346 |
index := symbolicCodeArray at:symIndex. |
|
1347 |
symIndex := symIndex + 1. |
|
1348 |
self appendByte:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1349 |
|
280 | 1350 |
] ifFalse:[ (extra == #lit) ifTrue:[ |
1351 |
index := self addLiteral:(symbolicCodeArray at:symIndex). |
|
1352 |
symIndex := symIndex + 1. |
|
1353 |
self appendByte:index |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1354 |
|
280 | 1355 |
] ifFalse:[ (extra == #speciallit) ifTrue:[ |
1356 |
index := self addLiteral:(symbolicCodeArray at:symIndex). |
|
1357 |
index > 255 ifTrue:[ |
|
1358 |
self parseError:'too many globals (' , |
|
1359 |
(symbolicCodeArray at:symIndex) , |
|
1360 |
' index=' , index printString , |
|
1361 |
') in method - please simplify'. |
|
1362 |
^ #Error |
|
1363 |
]. |
|
1364 |
symIndex := symIndex + 1. |
|
1365 |
self appendByte:index. |
|
1366 |
self appendEmptyShort. "space for inline-generation" |
|
1367 |
self appendEmptyLong. "space for inline-address" |
|
1368 |
symIndex := symIndex + 6 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1369 |
|
280 | 1370 |
] ifFalse:[ (extra == #speciallitS) ifTrue:[ |
1371 |
index := symbolicCodeArray at:symIndex. |
|
1372 |
symIndex := symIndex + 1. |
|
1373 |
self appendByte:index. |
|
1374 |
self appendEmptyShort. "space for inline-generation" |
|
1375 |
self appendEmptyLong. "space for inline-address" |
|
1376 |
symIndex := symIndex + 6 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1377 |
|
280 | 1378 |
] ifFalse:[ (extra == #speciallitL) ifTrue:[ |
1379 |
index := symbolicCodeArray at:symIndex. |
|
1380 |
symIndex := symIndex + 2. |
|
1381 |
self appendWord:index. |
|
1382 |
self appendEmptyShort. "space for inline-generation" |
|
1383 |
self appendEmptyLong. "space for inline-address" |
|
1384 |
symIndex := symIndex + 6 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1385 |
|
280 | 1386 |
] ifFalse:[ (extra == #offset) ifTrue:[ |
1387 |
relocInfo at:symIndex put:codeIndex. |
|
1388 |
self addReloc:symIndex. |
|
1389 |
symIndex := symIndex + 1. |
|
1390 |
self appendByte:0 |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1391 |
|
280 | 1392 |
] ifFalse:[ (extra == #indexLevel) ifTrue:[ |
1393 |
index := symbolicCodeArray at:symIndex. |
|
1394 |
symIndex := symIndex + 1. |
|
1395 |
self appendByte:index. |
|
1396 |
level := symbolicCodeArray at:symIndex. |
|
1397 |
symIndex := symIndex + 1. |
|
1398 |
self appendByte:level |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1399 |
|
280 | 1400 |
] ifFalse:[ (extra == #offsetNvarNarg) ifTrue:[ |
1401 |
relocInfo at:symIndex put:codeIndex. |
|
1402 |
self addReloc:symIndex. |
|
1403 |
symIndex := symIndex + 1. |
|
1404 |
self appendEmptyByte. |
|
1405 |
nvars := symbolicCodeArray at:symIndex. |
|
1406 |
symIndex := symIndex + 1. |
|
1407 |
self appendByte:nvars. |
|
1408 |
level := symbolicCodeArray at:symIndex. |
|
1409 |
symIndex := symIndex + 1. |
|
1410 |
self appendByte:level |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1411 |
|
280 | 1412 |
] ifFalse:[ (extra == #absoffset) ifTrue:[ |
1413 |
relocInfo at:symIndex put:codeIndex. |
|
1414 |
self addReloc:symIndex. |
|
1415 |
addr := symbolicCodeArray at:symIndex. |
|
1416 |
symIndex := symIndex + 1. |
|
1417 |
self appendByte:(addr bitAnd:16rFF). |
|
1418 |
self appendByte:((addr bitShift:-8) bitAnd:16rFF). |
|
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1419 |
|
280 | 1420 |
] ifFalse:[ (extra == #absoffsetNvarNarg) ifTrue:[ |
1421 |
relocInfo at:symIndex put:codeIndex. |
|
1422 |
self addReloc:symIndex. |
|
1423 |
addr := symbolicCodeArray at:symIndex. |
|
1424 |
symIndex := symIndex + 1. |
|
1425 |
self appendByte:(addr bitAnd:16rFF). |
|
1426 |
self appendByte:((addr bitShift:-8) bitAnd:16rFF). |
|
1427 |
nvars := symbolicCodeArray at:symIndex. |
|
1428 |
symIndex := symIndex + 1. |
|
1429 |
self appendByte:nvars. |
|
1430 |
level := symbolicCodeArray at:symIndex. |
|
1431 |
symIndex := symIndex + 1. |
|
1432 |
self appendByte:level |
|
141 | 1433 |
|
280 | 1434 |
] ifFalse:[ (extra == #special) ifTrue:[ |
1435 |
((codeSymbol == #send) |
|
1436 |
or:[codeSymbol == #sendSelf |
|
1437 |
or:[codeSymbol == #superSend |
|
1438 |
or:[codeSymbol == #hereSend]]]) ifTrue:[ |
|
1439 |
index := symbolicCodeArray at:symIndex. |
|
1440 |
symIndex := symIndex + 1. |
|
1441 |
nargs := symbolicCodeArray at:symIndex. |
|
1442 |
symIndex := symIndex + 1. |
|
1443 |
self appendByte:nargs. |
|
1444 |
self appendByte:index. |
|
141 | 1445 |
|
280 | 1446 |
(codeSymbol == #superSend |
1447 |
or:[codeSymbol == #hereSend]) ifTrue:[ |
|
1448 |
index := symbolicCodeArray at:symIndex. |
|
1449 |
symIndex := symIndex + 1. |
|
1450 |
self appendByte:index |
|
1451 |
]. |
|
1452 |
stackDelta := nargs negated. |
|
1453 |
codeSymbol == #sendSelf ifTrue:[ |
|
1454 |
stackDelta := stackDelta + 1 |
|
1455 |
] |
|
1456 |
] ifFalse:[ |
|
1457 |
(codeSymbol == #sendDrop) ifTrue:[ |
|
1458 |
index := symbolicCodeArray at:symIndex. |
|
1459 |
symIndex := symIndex + 1. |
|
1460 |
nargs := symbolicCodeArray at:symIndex. |
|
1461 |
symIndex := symIndex + 1. |
|
1462 |
self appendByte:nargs. |
|
1463 |
self appendByte:index. |
|
1464 |
stackDelta := (nargs + 1) negated |
|
1465 |
] |
|
1466 |
] |
|
141 | 1467 |
|
280 | 1468 |
] ifFalse:[ (extra == #specialL) ifTrue:[ |
1469 |
((codeSymbol == #sendL) |
|
1470 |
or:[codeSymbol == #sendSelfL |
|
1471 |
or:[codeSymbol == #superSendL |
|
1472 |
or:[codeSymbol == #hereSendL]]]) ifTrue:[ |
|
1473 |
index := symbolicCodeArray at:symIndex. |
|
1474 |
symIndex := symIndex + 2. |
|
1475 |
nargs := symbolicCodeArray at:symIndex. |
|
1476 |
symIndex := symIndex + 1. |
|
1477 |
self appendByte:nargs. |
|
1478 |
self appendWord:index. |
|
1479 |
(codeSymbol == #superSendL |
|
1480 |
or:[codeSymbol == #hereSendL]) ifTrue:[ |
|
1481 |
index := symbolicCodeArray at:symIndex. |
|
1482 |
symIndex := symIndex + 2. |
|
1483 |
self appendWord:index. |
|
1484 |
]. |
|
1485 |
stackDelta := nargs negated. |
|
1486 |
codeSymbol == #sendSelfL ifTrue:[ |
|
1487 |
stackDelta := stackDelta + 1 |
|
1488 |
] |
|
1489 |
] |
|
1490 |
] ifFalse:[ (extra == #specialSend) ifTrue:[ |
|
1491 |
index := symbolicCodeArray at:symIndex. |
|
1492 |
symIndex := symIndex + 1. |
|
1493 |
self appendByte:index. |
|
1494 |
]]]]]]]]]]]]]]]] |
|
1495 |
]. |
|
141 | 1496 |
|
280 | 1497 |
stackDepth := stackDepth + stackDelta. |
1498 |
(stackDepth > maxStackDepth) ifTrue:[ |
|
1499 |
maxStackDepth := stackDepth |
|
1500 |
] |
|
1501 |
]. |
|
1502 |
relocInfo at:symIndex put:codeIndex. |
|
141 | 1503 |
|
280 | 1504 |
needRetry ifFalse:[ |
1505 |
" |
|
1506 |
now relocate - returns true if ok, false if we have to do it again |
|
1507 |
(when short jumps have been changed to long jumps) |
|
1508 |
" |
|
1509 |
relocList notNil ifTrue:[ |
|
1510 |
needRetry := (self relocateWith:symbolicCodeArray relocInfo:relocInfo) not. |
|
1511 |
" |
|
1512 |
if returned with false, a relative jump was made into |
|
1513 |
an absolute jump - need to start over with one more byte space |
|
1514 |
" |
|
1515 |
needRetry ifTrue:[ |
|
1516 |
relocList := nil. |
|
1517 |
codeSize := codeSize + 1. |
|
1518 |
] |
|
1519 |
] |
|
1520 |
] ifTrue:[ |
|
1521 |
'compiling again ...' infoPrintCR. |
|
1522 |
] |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1523 |
]. |
141 | 1524 |
"code printNL." |
1525 |
^ errorFlag |
|
1526 |
||
1527 |
"Modified: 3.9.1995 / 12:59:43 / claus" |
|
280 | 1528 |
"Modified: 20.5.1996 / 10:31:20 / cg" |
141 | 1529 |
! |
1530 |
||
1531 |
genSymbolicCode |
|
1532 |
"traverse the parse-tree producing symbolicCode - return the codeArray" |
|
1533 |
||
1534 |
|codeStream code thisStatement lastStatement| |
|
1535 |
||
1536 |
litArray := nil. |
|
1537 |
codeStream := WriteStream on:(OrderedCollection new:100). |
|
1538 |
||
1539 |
thisStatement := tree. |
|
1540 |
[thisStatement notNil] whileTrue:[ |
|
1541 |
lastStatement := thisStatement. |
|
1542 |
thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
1543 |
thisStatement := thisStatement nextStatement |
|
1544 |
]. |
|
1545 |
(lastStatement isNil or:[lastStatement isReturnNode not]) |
|
1546 |
ifTrue:[ |
|
1547 |
"not a return - add retSelf" |
|
1548 |
" |
|
1549 |
if the last statement was a send for side-effect, |
|
1550 |
replace the previous drop by a retSelf |
|
1551 |
" |
|
1552 |
lastStatement notNil ifTrue:[ |
|
1553 |
((code := codeStream contents) notNil |
|
1554 |
and:[code size > 0 |
|
1555 |
and:[code last == #drop]]) ifTrue:[ |
|
1556 |
codeStream position:(codeStream position - 1). |
|
1557 |
codeStream nextPut:#retSelf |
|
1558 |
] |
|
1559 |
]. |
|
1560 |
codeStream nextPut:#retSelf |
|
1561 |
]. |
|
1562 |
^ codeStream contents |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1563 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1564 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1565 |
hasLineNumber:sel |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1566 |
"return true, if special send code needs lineNr" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1567 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1568 |
(sel == #==) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1569 |
(sel == #~~) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1570 |
(sel == #class) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1571 |
(sel == #isNil) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1572 |
(sel == #notNil) ifTrue:[^ false]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1573 |
^ true |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1574 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1575 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1576 |
isBuiltIn1ArgSelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1577 |
"return true, if selector sel is built-in. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1578 |
(i.e. there is a single bytecode for it)" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1579 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1580 |
(sel == #at:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1581 |
(sel == #value:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1582 |
(sel == #bitAnd:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1583 |
(sel == #bitOr:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1584 |
(sel == #new:) ifTrue:[^ true]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1585 |
(sel == #basicNew:) ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1586 |
"/ this one is critical - some redefine it |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1587 |
receiver isGlobal ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1588 |
(#('String' 'ByteArray' 'Array' |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1589 |
'Point' 'Rectangle' 'Object') |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1590 |
includes:receiver name) ifTrue:[^ true]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1591 |
]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1592 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1593 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1594 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1595 |
"Created: 17.4.1996 / 22:33:13 / cg" |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1596 |
"Modified: 17.4.1996 / 22:38:08 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1597 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1598 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1599 |
isBuiltIn2ArgSelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1600 |
"return true, if selector sel is built-in. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1601 |
(i.e. there is a single bytecode for it)" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1602 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1603 |
(sel == #at:put:) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1604 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1605 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1606 |
"Created: 17.4.1996 / 22:33:16 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1607 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1608 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1609 |
isBuiltInBinarySelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1610 |
sel == #== ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1611 |
sel == #~~ ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1612 |
sel == #= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1613 |
sel == #~= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1614 |
sel == #+ ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1615 |
sel == #- ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1616 |
sel == #< ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1617 |
sel == #<= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1618 |
sel == #> ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1619 |
sel == #>= ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1620 |
sel == #* ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1621 |
sel == #& ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1622 |
sel == #| ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1623 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1624 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1625 |
"Created: 17.4.1996 / 22:34:27 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1626 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1627 |
|
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1628 |
isBuiltInUnarySelector:sel forReceiver:receiver |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1629 |
"return true, if unary selector sel is built-in. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1630 |
(i.e. there is a single bytecode for it)" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1631 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1632 |
(sel == #peek) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1633 |
(sel == #value) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1634 |
(sel == #next) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1635 |
(sel == #class) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1636 |
(sel == #size) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1637 |
(sel == #x) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1638 |
(sel == #y) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1639 |
(sel == #width) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1640 |
(sel == #height) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1641 |
(sel == #origin) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1642 |
(sel == #extent) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1643 |
(sel == #asInteger) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1644 |
(sel == #rounded) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1645 |
(sel == #isNil) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1646 |
(sel == #notNil) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1647 |
(sel == #not) ifTrue:[^ true]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1648 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1649 |
(sel == #new) ifTrue:[^ true]. |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1650 |
(sel == #basicNew) ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1651 |
"/ this one is critical - some redefine it |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1652 |
receiver isGlobal ifTrue:[ |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1653 |
(#('String' 'ByteArray' 'Array' |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1654 |
'Point' 'Rectangle' 'Object') |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1655 |
includes:receiver name) ifTrue:[^ true]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1656 |
]. |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1657 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1658 |
^ false |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1659 |
|
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1660 |
"Created: 17.4.1996 / 22:32:16 / cg" |
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
1661 |
"Modified: 17.4.1996 / 22:38:14 / cg" |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1662 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1663 |
|
247 | 1664 |
isSpecialGlobalSymbol:nm |
1665 |
"return true, if unary selector sel is a special selector" |
|
1666 |
||
1667 |
^ #(Array String FloatArray DoubleArray |
|
325 | 1668 |
Point Symbol Smalltalk Processor |
1669 |
SmallInteger Character Float |
|
1670 |
Process |
|
1671 |
Set IdentitySet Dictionary IdentityDictionary |
|
1672 |
Sempahore |
|
1673 |
OrderedCollection |
|
1674 |
) includesIdentical:nm |
|
247 | 1675 |
|
1676 |
"Created: 13.4.1996 / 20:15:35 / cg" |
|
325 | 1677 |
"Modified: 5.8.1996 / 16:56:58 / cg" |
247 | 1678 |
! |
1679 |
||
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1680 |
isSpecialSendSelector:sel |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1681 |
"return true, if unary selector sel is a special selector" |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1682 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1683 |
(sel == #top) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1684 |
(sel == #bottom) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1685 |
(sel == #left) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1686 |
(sel == #right) ifTrue:[^ true]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1687 |
^ false |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1688 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1689 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1690 |
moveGlobalsToFront |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1691 |
"move all global-literals to the front of the literal array. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1692 |
This may be the last chance to compile the method, since |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1693 |
for globals, the maximum literal index is 255 - while for normal |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1694 |
literals its a stress-less 65535" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1695 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1696 |
litArray isNil ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1697 |
^ self error:'oops compiler botch'. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1698 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1699 |
litArray sort:[:a :b | "a < b -> #(a b)" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1700 |
(a isMemberOf:Symbol) ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1701 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1702 |
(b isMemberOf:Symbol) ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1703 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1704 |
(a at:1) isUppercase ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1705 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1706 |
(b at:1) isUppercase ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1707 |
ifTrue:[a < b]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1708 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1709 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1710 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1711 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1712 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1713 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1714 |
#(#A #c #B #D #E #a #b #F) |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1715 |
sort:[:a :b | |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1716 |
(a isMemberOf:Symbol) ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1717 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1718 |
(b isMemberOf:Symbol) ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1719 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1720 |
(a at:1) isUppercase ifFalse:[false] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1721 |
ifTrue:[ |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1722 |
(b at:1) isUppercase ifFalse:[true] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1723 |
ifTrue:[(a < b)]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1724 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1725 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1726 |
] |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1727 |
]. |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1728 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1729 |
" |
141 | 1730 |
! |
1731 |
||
1732 |
relocateWith:symbolicCodeArray relocInfo:relocInfo |
|
1733 |
"helper for genByteCodeFrom - relocate code using relocInfo. |
|
1734 |
if relocation fails badly (due to long relative jumps) patch |
|
1735 |
symbolicCode to use absolute jumps instead and return false |
|
1736 |
(genByteCodeFrom will then try again). Otherwise return true. |
|
1737 |
Also, on the fly, jumps to jumps and jumps to return are handled." |
|
1738 |
||
1739 |
|delta "{Class: SmallInteger }" |
|
1740 |
codePos "{Class: SmallInteger }" |
|
1741 |
opCodePos "{Class: SmallInteger }" |
|
1742 |
codeOffset "{Class: SmallInteger }" |
|
1743 |
symOffset |
|
1744 |
opcode "{Class: SmallInteger }" |
|
1745 |
dstOpcode jumpTarget |
|
1746 |
jumpCode deleteSet| |
|
1747 |
||
1748 |
deleteSet := OrderedCollection new. |
|
1749 |
relocList do:[:sIndex | |
|
1750 |
"have to relocate symCode at sIndex ..." |
|
1751 |
symOffset := symbolicCodeArray at:sIndex. "the target in the symbolic code" |
|
1752 |
codePos := relocInfo at:sIndex. "position of the offet in byte code" |
|
1753 |
codeOffset := relocInfo at:symOffset. "position of the target in byte code" |
|
1754 |
delta := codeOffset - codePos - 1. |
|
1755 |
opCodePos := codePos - 1. |
|
1756 |
opcode := codeBytes at:opCodePos. |
|
1757 |
||
1758 |
(opcode between:190 and:199) ifTrue:[ |
|
1759 |
"an absolute jump/makeBlock" |
|
1760 |
||
1761 |
codeBytes at:codePos put:(codeOffset bitAnd:16rFF). |
|
1762 |
codeBytes at:(codePos + 1) put:(codeOffset bitShift:-8) |
|
1763 |
] ifFalse:[ |
|
1764 |
"get jump-code from long and vlong codes" |
|
1765 |
(opcode between:50 and:59) ifFalse:[ |
|
1766 |
(opcode between:60 and:69) ifTrue:[ |
|
1767 |
opcode := opcode - 10 |
|
1768 |
] ifFalse:[ |
|
1769 |
(opcode between:70 and:79) ifTrue:[ |
|
1770 |
opcode := opcode - 20 |
|
1771 |
] ifFalse:[ |
|
1772 |
self error:'invalid code to relocate' |
|
1773 |
] |
|
1774 |
]. |
|
1775 |
]. |
|
1776 |
||
1777 |
"optimize jump to return and jump to jump" |
|
1778 |
||
1779 |
(opcode == 54) ifTrue:[ |
|
1780 |
"a jump" |
|
1781 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
1782 |
||
1783 |
(#(retSelf retTop retNil retTrue retFalse ret0 "blockRetTop") includes:dstOpcode) ifTrue:[ |
|
1784 |
"a jump to a return - put in the return instead jump" |
|
1785 |
||
1786 |
symbolicCodeArray at:(sIndex - 1) put:dstOpcode. |
|
1787 |
symbolicCodeArray at:sIndex put:dstOpcode. |
|
1788 |
codeBytes at:opCodePos put:(self byteCodeFor:dstOpcode). |
|
1789 |
delta := 0. |
|
1790 |
deleteSet add:sIndex. |
|
1791 |
||
1792 |
" |
|
1793 |
'jump to return at: ' print. (sIndex - 1) printNL. |
|
1794 |
" |
|
1795 |
] ifFalse:[ |
|
1796 |
(dstOpcode == #jump) ifTrue:[ |
|
1797 |
"jump to jump to be done soon" |
|
1798 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
1799 |
" |
|
1800 |
'jump to jump at: ' print. (sIndex - 1) print. |
|
1801 |
' newTarget:' print. jumpTarget printNL. |
|
1802 |
" |
|
1803 |
||
1804 |
symbolicCodeArray at:sIndex put:jumpTarget. |
|
1805 |
symOffset := jumpTarget. |
|
1806 |
codeOffset := relocInfo at:symOffset. |
|
1807 |
delta := codeOffset - codePos - 1. |
|
1808 |
||
1809 |
"continue with new delta" |
|
1810 |
] |
|
1811 |
] |
|
1812 |
]. |
|
1813 |
(#(50 51 52 53 56 57 58 59) includes:opcode) ifTrue:[ |
|
1814 |
"a conditional jump" |
|
1815 |
||
1816 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
1817 |
(dstOpcode == #jump) ifTrue:[ |
|
1818 |
"conditional jump to unconditional jump" |
|
1819 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
1820 |
" |
|
1821 |
'cond jump to jump at: ' print. (sIndex - 1) print. |
|
1822 |
' newTarget:' print. jumpTarget printNL. |
|
1823 |
" |
|
1824 |
||
1825 |
symbolicCodeArray at:sIndex put:jumpTarget. |
|
1826 |
symOffset := jumpTarget. |
|
1827 |
codeOffset := relocInfo at:symOffset. |
|
1828 |
delta := codeOffset - codePos - 1. |
|
1829 |
||
1830 |
"continue with new delta" |
|
1831 |
]. |
|
1832 |
]. |
|
1833 |
||
1834 |
(delta >= 0) ifTrue:[ |
|
1835 |
(delta > 127) ifTrue:[ |
|
1836 |
(opcode between:50 and:59) ifFalse:[ |
|
1837 |
self error:'invalid code to relocate' |
|
1838 |
] ifTrue:[ |
|
1839 |
(delta > 255) ifTrue:[ |
|
1840 |
"change jmp into vljmp ..." |
|
1841 |
codeBytes at:opCodePos put:(opcode + 20). |
|
1842 |
delta := delta - 256 |
|
1843 |
] ifFalse:[ |
|
1844 |
"change jmp into ljmp ..." |
|
1845 |
codeBytes at:opCodePos put:(opcode + 10). |
|
1846 |
delta := delta - 128 |
|
1847 |
]. |
|
1848 |
(delta > 127) ifTrue:[ |
|
1849 |
"change symbolic into a jump absolute and fail" |
|
1850 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
1851 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
1852 |
symbolicCodeArray at:sIndex put:symOffset. |
|
1853 |
" |
|
1854 |
'change short into abs jump' printNL. |
|
1855 |
" |
|
1856 |
deleteSet do:[:d | relocList remove:d]. |
|
1857 |
^ false |
|
1858 |
] |
|
1859 |
]. |
|
1860 |
]. |
|
1861 |
codeBytes at:codePos put:delta |
|
1862 |
] ifFalse:[ |
|
1863 |
(delta < -128) ifTrue:[ |
|
1864 |
(opcode between:50 and:59) ifFalse:[ |
|
1865 |
self error:'invalid code to relocate' |
|
1866 |
] ifTrue:[ |
|
1867 |
(delta < -256) ifTrue:[ |
|
1868 |
"change jmp into vljmp ..." |
|
1869 |
codeBytes at:opCodePos put:(opcode + 20). |
|
1870 |
delta := delta + 256 |
|
1871 |
] ifFalse:[ |
|
1872 |
"change jmp into ljmp ..." |
|
1873 |
codeBytes at:opCodePos put:(opcode + 10). |
|
1874 |
delta := delta + 128 |
|
1875 |
]. |
|
1876 |
(delta < -128) ifTrue:[ |
|
1877 |
"change symbolic into a jump absolute and fail" |
|
1878 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
1879 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
1880 |
symbolicCodeArray at:sIndex put:symOffset. |
|
1881 |
" |
|
1882 |
'change short into abs jump' printNL. |
|
1883 |
" |
|
1884 |
deleteSet do:[:d | relocList remove:d]. |
|
1885 |
^ false |
|
1886 |
] |
|
1887 |
] |
|
1888 |
]. |
|
1889 |
codeBytes at:codePos put:(256 + delta) |
|
1890 |
] |
|
1891 |
] |
|
1892 |
]. |
|
1893 |
(errorFlag == #Error) ifTrue:[ |
|
1894 |
self error:'relocation range error' |
|
1895 |
]. |
|
1896 |
^ true |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1897 |
! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1898 |
|
247 | 1899 |
specialGlobalCodeFor:aSymbol |
1900 |
aSymbol == #Array ifTrue:[^ 0]. |
|
1901 |
aSymbol == #String ifTrue:[^ 1]. |
|
1902 |
aSymbol == #FloatArray ifTrue:[^ 2]. |
|
1903 |
aSymbol == #DoubleArray ifTrue:[^ 3]. |
|
1904 |
aSymbol == #Point ifTrue:[^ 4]. |
|
1905 |
aSymbol == #Symbol ifTrue:[^ 5]. |
|
1906 |
aSymbol == #Smalltalk ifTrue:[^ 6]. |
|
1907 |
aSymbol == #Processor ifTrue:[^ 7]. |
|
325 | 1908 |
aSymbol == #SmallInteger ifTrue:[^ 8]. |
1909 |
aSymbol == #Character ifTrue:[^ 9]. |
|
1910 |
aSymbol == #Float ifTrue:[^ 10]. |
|
1911 |
aSymbol == #Process ifTrue:[^ 11]. |
|
1912 |
aSymbol == #Set ifTrue:[^ 12]. |
|
1913 |
aSymbol == #IdentitySet ifTrue:[^ 13]. |
|
1914 |
aSymbol == #Dictionary ifTrue:[^ 14]. |
|
1915 |
aSymbol == #IdentityDictionary ifTrue:[^ 15]. |
|
1916 |
aSymbol == #Sempahore ifTrue:[^ 16]. |
|
1917 |
aSymbol == #OrderedCollection ifTrue:[^ 17]. |
|
247 | 1918 |
|
1919 |
self error:'invalid special global symbol'. |
|
1920 |
errorFlag := #Error |
|
325 | 1921 |
|
1922 |
"Modified: 5.8.1996 / 16:51:45 / cg" |
|
247 | 1923 |
! |
1924 |
||
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1925 |
specialSendCodeFor:aSymbol |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1926 |
aSymbol == #top ifTrue:[^ 0]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1927 |
aSymbol == #bottom ifTrue:[^ 1]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1928 |
aSymbol == #left ifTrue:[^ 2]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1929 |
aSymbol == #right ifTrue:[^ 3]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1930 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1931 |
self error:'invalid special send symbol'. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1932 |
errorFlag := #Error |
0 | 1933 |
! ! |
49 | 1934 |
|
1935 |
!ByteCodeCompiler methodsFor:'machine code generation'! |
|
1936 |
||
1937 |
compileToMachineCode:aString forClass:aClass inCategory:cat |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1938 |
notifying:requestor install:install skipIfSame:skipIfSame silent:silent |
49 | 1939 |
"this is called to compile primitive code. |
1940 |
This is EXPERIMENTAL and going to be changed to raise an error, |
|
1941 |
an redefined in subclasses which can do it (either by direct compilation, or by calling |
|
1942 |
the external stc do do it. |
|
1943 |
For a description of the arguments, see compile:forClass....." |
|
1944 |
||
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1945 |
|stFileName stream handle address flags command oFileName |
120 | 1946 |
initName newMethod ok status className sep class stcPath |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1947 |
errorStream errorMessages eMsg m supers mP moduleFileName| |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1948 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1949 |
(mP := STCModulePath asFilename) exists ifFalse:[ |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1950 |
mP makeDirectory |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1951 |
]. |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1952 |
(mP isDirectory |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1953 |
and:[mP isReadable |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1954 |
and:[mP isWritable]]) ifFalse:[ |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1955 |
self parseError:('no access to tempDir: ' , mP pathName) position:1. |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1956 |
^ #CannotLoad |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1957 |
]. |
96 | 1958 |
|
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
1959 |
ObjectFileLoader isNil ifTrue:[^ #CannotLoad]. |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
1960 |
STCCompilation == #never ifTrue:[^ #CannotLoad]. |
120 | 1961 |
(stcPath := self class incrementalStcPath) isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1962 |
self parseError:'no stc compiler available - cannot create machine code' position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1963 |
^ #CannotLoad |
120 | 1964 |
]. |
54 | 1965 |
|
298
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
1966 |
"/ generate a unique name, consisting of my processID and a sequence number |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
1967 |
"/ the processId is added to allow filein of modules from different |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
1968 |
"/ lifes |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
1969 |
|
54 | 1970 |
SequenceNumber isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1971 |
SequenceNumber := 0. |
54 | 1972 |
]. |
1973 |
SequenceNumber := SequenceNumber + 1. |
|
49 | 1974 |
|
298
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
1975 |
initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString. |
118648c3b590
include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
1976 |
|
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1977 |
stFileName := './' , initName , '.st'. |
54 | 1978 |
stream := stFileName asFilename writeStream. |
187 | 1979 |
stream isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1980 |
self parseError:'cannot create temporary sourcefile for compilation'. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1981 |
^ #CannotLoad |
187 | 1982 |
]. |
97 | 1983 |
sep := stream class chunkSeparator. |
49 | 1984 |
|
101 | 1985 |
class := aClass. |
1986 |
class isMeta ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1987 |
class := aClass soleInstance |
101 | 1988 |
]. |
235
8dde5344f785
oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents:
230
diff
changeset
|
1989 |
supers := class allSuperclasses. |
214
683adf870f54
oops - couldn't compile for Object (no superclass)
Claus Gittinger <cg@exept.de>
parents:
212
diff
changeset
|
1990 |
supers notNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1991 |
supers reverseDo:[:cls| |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1992 |
cls ~~ Object ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1993 |
cls isLoaded ifFalse:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1994 |
^ #CannotLoad |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1995 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1996 |
cls fileOutDefinitionOn:stream. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1997 |
stream nextPut:sep; cr. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1998 |
] |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1999 |
] |
54 | 2000 |
]. |
101 | 2001 |
class fileOutDefinitionOn:stream. |
96 | 2002 |
stream nextPut:sep; cr. |
54 | 2003 |
|
101 | 2004 |
class fileOutPrimitiveDefinitionsOn:stream. |
49 | 2005 |
|
96 | 2006 |
stream nextPut:sep. |
235
8dde5344f785
oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents:
230
diff
changeset
|
2007 |
className := class name. |
96 | 2008 |
|
235
8dde5344f785
oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents:
230
diff
changeset
|
2009 |
stream nextPutAll:className. |
49 | 2010 |
aClass isMeta ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2011 |
stream nextPutAll:' class'. |
49 | 2012 |
]. |
96 | 2013 |
stream nextPutAll:' methodsFor:'''; nextPutAll:cat; nextPutAll:''''. |
296
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2014 |
stream nextPut:sep; cr. |
49 | 2015 |
|
296
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2016 |
stream nextPutAll:'"{ Line: 0 }"'; cr; |
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2017 |
nextChunkPut:aString; |
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2018 |
space; nextPut:sep. |
96 | 2019 |
|
49 | 2020 |
stream close. |
2021 |
||
2022 |
" |
|
2023 |
call stc to compile it |
|
2024 |
" |
|
94 | 2025 |
oFileName := './' , initName , '.o'. |
2026 |
oFileName asFilename delete. |
|
49 | 2027 |
|
150 | 2028 |
flags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName . |
124 | 2029 |
STCCompilationDefines notNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2030 |
flags := STCCompilationDefines , ' ' , flags |
124 | 2031 |
]. |
2032 |
STCCompilationIncludes notNil ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2033 |
flags := STCCompilationIncludes , ' ' , flags |
124 | 2034 |
]. |
2035 |
STCCompilationOptions notNil ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2036 |
flags := STCCompilationOptions , ' ' , flags |
54 | 2037 |
]. |
2038 |
||
101 | 2039 |
command := stcPath , ' ' , flags , ' -c ' , stFileName. |
54 | 2040 |
"/ command printNL. |
2041 |
||
215 | 2042 |
self activityNotification:'compiling'. |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2043 |
ok := OperatingSystem executeCommand:command onError:[:stat| |
296
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2044 |
status := stat. |
999d5fdf0bde
oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2045 |
false |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2046 |
]. |
101 | 2047 |
|
120 | 2048 |
"for debugging - leave c intermediate" |
2049 |
STCKeepCIntermediate == true ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2050 |
command := stcPath , ' ' , flags , ' -C ' , stFileName. |
280 | 2051 |
'executing: ' infoPrint. command infoPrintCR. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2052 |
OperatingSystem executeCommand:command |
49 | 2053 |
]. |
2054 |
||
94 | 2055 |
oFileName asFilename exists ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2056 |
ok ifFalse:[ |
280 | 2057 |
'oops - system says it failed - but o-file is there ...' infoPrintCR. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2058 |
ok := true |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2059 |
] |
94 | 2060 |
] ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2061 |
ok := false |
94 | 2062 |
]. |
2063 |
||
54 | 2064 |
ok ifFalse:[ |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2065 |
(status notNil and:[status couldNotExecute]) ifTrue:[ |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2066 |
eMsg := 'oops, no STC - cannot create machine code' |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2067 |
] ifFalse:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2068 |
errorStream := 'errorOutput' asFilename readStream. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2069 |
errorStream notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2070 |
errorMessages := errorStream contents. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2071 |
errorMessages notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2072 |
errorMessages := errorMessages asStringCollection. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2073 |
errorMessages size > 20 ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2074 |
errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2075 |
]. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2076 |
"/ errorMessages := errorMessages collect:[:line | |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2077 |
"/ (line startsWith:(stFileName , ':')) ifTrue:[ |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2078 |
"/ 'Line: ' , (line copyFrom:(stFileName size + 2)) |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2079 |
"/ ] ifFalse:[ |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2080 |
"/ line |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2081 |
"/ ] |
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2082 |
"/ ]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2083 |
errorMessages := errorMessages asString |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2084 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2085 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2086 |
errorMessages isNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2087 |
errorMessages := '' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2088 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2089 |
eMsg := ('STC / CC error during compilation:\\',errorMessages) withCRs. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2090 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2091 |
'errorOutput' asFilename remove. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2092 |
self parseError:eMsg position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2093 |
OperatingSystem removeFile:stFileName. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2094 |
OperatingSystem removeFile:oFileName. |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2095 |
OperatingSystem removeFile:'errorOutput'. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2096 |
^ #Error |
120 | 2097 |
]. |
2098 |
||
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2099 |
OperatingSystem removeFile:'errorOutput'. |
297 | 2100 |
|
120 | 2101 |
(ObjectFileLoader notNil |
2102 |
and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2103 |
self parseError:'no dynamic load configured - cannot load machine code' position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2104 |
OperatingSystem removeFile:stFileName. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2105 |
OperatingSystem removeFile:oFileName. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2106 |
^ #CannotLoad |
54 | 2107 |
]. |
2108 |
||
215 | 2109 |
" |
2110 |
if required, make a shared or otherwise loadable object file for it |
|
2111 |
" |
|
2112 |
self activityNotification:'linking'. |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2113 |
oFileName := ObjectFileLoader createLoadableObjectFor:initName. |
323
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2114 |
oFileName isNil ifTrue:[ |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2115 |
"/ something went wrong |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2116 |
OperatingSystem removeFile:stFileName. |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2117 |
self parseError:(ObjectFileLoader lastError) position:1. |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2118 |
^ #CannotLoad |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2119 |
]. |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2120 |
|
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2121 |
oFileName asFilename exists ifFalse:[ |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2122 |
OperatingSystem removeFile:stFileName. |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2123 |
OperatingSystem removeFile:oFileName. |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2124 |
self parseError:'link failed - cannot create machine code' position:1. |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2125 |
^ #CannotLoad |
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2126 |
]. |
49 | 2127 |
|
2128 |
" |
|
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2129 |
move it into the modules directory |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2130 |
" |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2131 |
moduleFileName := STCModulePath , '/' , initName , '.' , (oFileName asFilename suffix). |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2132 |
oFileName asFilename moveTo:moduleFileName. |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2133 |
oFileName := moduleFileName. |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2134 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2135 |
" |
49 | 2136 |
load the objectfile |
2137 |
" |
|
215 | 2138 |
self activityNotification:'loading'. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2139 |
handle := ObjectFileLoader loadDynamicObject:moduleFileName. |
49 | 2140 |
handle isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2141 |
OperatingSystem removeFile:stFileName. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2142 |
OperatingSystem removeFile:moduleFileName. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2143 |
self parseError:'dynamic load failed - cannot create machine code' position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2144 |
^ #CannotLoad |
49 | 2145 |
]. |
280 | 2146 |
"/ ('handle is ' , handle printString) infoPrintCR. |
49 | 2147 |
|
54 | 2148 |
address := ObjectFileLoader getFunction:'__' , initName , '_Init' from:handle. |
49 | 2149 |
address isNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2150 |
address := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2151 |
address isNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2152 |
(ObjectFileLoader getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2153 |
ObjectFileLoader listUndefinedSymbolsIn:handle. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2154 |
eMsg := 'undefined symbols in primitive code'. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2155 |
] ifFalse:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2156 |
eMsg := initName , '_Init() lookup failed' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2157 |
]. |
125 | 2158 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2159 |
ObjectFileLoader unloadDynamicObject:handle. |
125 | 2160 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2161 |
OperatingSystem removeFile:stFileName. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2162 |
OperatingSystem removeFile:moduleFileName. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2163 |
self parseError:(eMsg , ' - cannot create machine code') position:1. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2164 |
^ #CannotLoad |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2165 |
] |
49 | 2166 |
]. |
2167 |
||
280 | 2168 |
"/ ('init at ' , address printString) infoPrintCR. |
54 | 2169 |
|
156 | 2170 |
m := ObjectFileLoader |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2171 |
callInitFunctionAt:address |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2172 |
specialInit:true |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2173 |
forceOld:true |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2174 |
interruptable:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2175 |
argument:2 |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2176 |
identifyAs:handle |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2177 |
returnsObject:true. |
49 | 2178 |
|
54 | 2179 |
" |
2180 |
did it work ? |
|
2181 |
" |
|
96 | 2182 |
newMethod := aClass compiledMethodAt:selector. |
54 | 2183 |
newMethod notNil ifTrue:[ |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2184 |
m ~~ newMethod ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2185 |
'BCOMPILER: oops - loaded method installed itself elsewhere' errorPrintNL. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2186 |
]. |
156 | 2187 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2188 |
newMethod source:aString. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2189 |
Project notNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2190 |
newMethod package:(Project currentPackageName) |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2191 |
]. |
160
5e01f0113d6e
dont forget package-info in compiled methods
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
2192 |
|
162 | 2193 |
"/ aClass updateRevisionString. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2194 |
aClass addChangeRecordForMethod:newMethod. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2195 |
(silent or:[Smalltalk silentLoading == true]) ifFalse:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2196 |
Transcript showCR:(' compiled: ', className,' ',selector,' - machine code') |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2197 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2198 |
ObjectMemory flushCaches. |
120 | 2199 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2200 |
OperatingSystem removeFile:stFileName. |
120 | 2201 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2202 |
handle method:newMethod. |
120 | 2203 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2204 |
"/ check for obsolete loaded objects and unload them |
120 | 2205 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2206 |
ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle | |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2207 |
anotherHandle isMethodHandle ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2208 |
anotherHandle method isNil ifTrue:[ |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2209 |
ObjectFileLoader unloadObjectFile:anotherHandle pathName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2210 |
OperatingSystem removeFile:anotherHandle pathName. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2211 |
] |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2212 |
] |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2213 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2214 |
^ newMethod. |
54 | 2215 |
]. |
2216 |
||
120 | 2217 |
OperatingSystem removeFile:stFileName. |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
2218 |
OperatingSystem removeFile:moduleFileName. |
54 | 2219 |
self parseError:'dynamic load failed' position:1. |
172
85ad12831217
give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents:
162
diff
changeset
|
2220 |
^ #CannotLoad |
49 | 2221 |
|
2222 |
" |
|
2223 |
|m| |
|
2224 |
||
2225 |
Object subclass:#Test |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2226 |
instanceVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2227 |
classVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2228 |
poolDictionaries:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2229 |
category:'tests'. |
49 | 2230 |
m := ByteCodeCompiler |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2231 |
compile:'foo ^ ''hello''' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2232 |
forClass:Test |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2233 |
inCategory:'tests' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2234 |
notifying:nil |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2235 |
install:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2236 |
skipIfSame:false. |
49 | 2237 |
m inspect |
2238 |
" |
|
2239 |
" |
|
2240 |
|m| |
|
2241 |
||
2242 |
Object subclass:#Test |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2243 |
instanceVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2244 |
classVariableNames:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2245 |
poolDictionaries:'' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2246 |
category:'tests'. |
49 | 2247 |
m := ByteCodeCompiler |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2248 |
compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2249 |
forClass:Test |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2250 |
inCategory:'tests' |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2251 |
notifying:nil |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2252 |
install:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2253 |
skipIfSame:false |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2254 |
silent:false. |
49 | 2255 |
m inspect |
2256 |
" |
|
120 | 2257 |
|
2258 |
"Modified: 14.9.1995 / 22:33:04 / claus" |
|
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2259 |
"Modified: 28.12.1995 / 15:52:48 / stefan" |
323
0d6e05191a9b
check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents:
301
diff
changeset
|
2260 |
"Modified: 29.7.1996 / 13:18:00 / cg" |
97 | 2261 |
! |
2262 |
||
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2263 |
createLoadableObjectFor:baseFileName |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2264 |
|osType oFileName soFileName| |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2265 |
|
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2266 |
osType := OperatingSystem getOSType. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2267 |
osType = 'irix' ifTrue:[ |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2268 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2269 |
link it to a shared object |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2270 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2271 |
oFileName := './' , baseFileName , '.o'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2272 |
soFileName := './' , baseFileName , '.so'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2273 |
OperatingSystem removeFile:soFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2274 |
OperatingSystem executeCommand:'ld -shared -all -o ' , soFileName , ' ' , oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2275 |
OperatingSystem removeFile:oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2276 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2277 |
]. |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2278 |
osType = 'sys5_4' ifTrue:[ |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2279 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2280 |
link it to a shared object |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2281 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2282 |
oFileName := './' , baseFileName , '.o'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2283 |
soFileName := './' , baseFileName , '.so'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2284 |
OperatingSystem removeFile:soFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2285 |
OperatingSystem executeCommand:'ld -G -o ' , soFileName , ' ' , oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2286 |
OperatingSystem removeFile:oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2287 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2288 |
]. |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2289 |
osType = 'linux' ifTrue:[ |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2290 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2291 |
link it to a shared object |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2292 |
" |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2293 |
oFileName := './' , baseFileName , '.o'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2294 |
soFileName := './' , baseFileName , '.so'. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2295 |
OperatingSystem removeFile:soFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2296 |
OperatingSystem executeCommand:'ld -shared -o ' , soFileName , ' ' , oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2297 |
OperatingSystem removeFile:oFileName. |
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2298 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2299 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2300 |
^ oFileName |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2301 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2302 |
"Created: 3.1.1996 / 16:04:45 / cg" |
287
dc42dd240e5c
Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents:
280
diff
changeset
|
2303 |
"Modified: 14.6.1996 / 11:16:46 / stefan" |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2304 |
! |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2305 |
|
97 | 2306 |
trappingStubMethodFor:aString inCategory:cat |
2307 |
"return a stub method which traps and reports an error whenever |
|
2308 |
called." |
|
2309 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2310 |
|newMethod| |
97 | 2311 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2312 |
newMethod := Method new:(litArray size). |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2313 |
litArray notNil ifTrue:[ |
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2314 |
newMethod literals:litArray |
97 | 2315 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2316 |
|
124 | 2317 |
newMethod makeUncompiled. |
97 | 2318 |
newMethod numberOfMethodVars:(self numberOfMethodVars). |
2319 |
newMethod numberOfMethodArgs:(self numberOfMethodArgs). |
|
2320 |
newMethod source:aString. |
|
2321 |
newMethod category:cat. |
|
2322 |
Project notNil ifTrue:[ |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2323 |
newMethod package:(Project currentPackageName) |
97 | 2324 |
]. |
2325 |
^ newMethod |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2326 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2327 |
"Modified: 18.5.1996 / 16:39:12 / cg" |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2328 |
"Modified: 24.6.1996 / 12:28:24 / stefan" |
49 | 2329 |
! ! |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2330 |
|
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2331 |
!ByteCodeCompiler class methodsFor:'documentation'! |
148 | 2332 |
|
2333 |
version |
|
325 | 2334 |
^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.88 1996-08-05 16:57:35 cg Exp $' |
148 | 2335 |
! ! |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
2336 |
ByteCodeCompiler initialize! |