author | Claus Gittinger <cg@exept.de> |
Tue, 31 Jul 2018 14:37:19 +0200 | |
changeset 4289 | d628b74f6130 |
parent 4288 | a55901caec8b |
child 4290 | 9d83c5d83330 |
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 |
" |
|
1046 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
3564 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
Parser subclass:#ByteCodeCompiler |
253
759ba0ddb672
oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
17 |
instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral |
1094
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
18 |
maxStackDepth relocList methodTempVars numTemp maxNumTemp |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
19 |
methodClass extraOP allLiterals allIdenticalLiterals |
3162
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
20 |
breakpointedLines currentLineNumber' |
1667 | 21 |
classVariableNames:'JumpToAbsJump ShareCode ListCompiledMethods NewCodeSet |
22 |
NewPrimitives' |
|
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
|
23 |
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
|
24 |
category:'System-Compiler' |
0 | 25 |
! |
26 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
27 |
!ByteCodeCompiler class methodsFor:'documentation'! |
3 | 28 |
|
1030 | 29 |
byteCode |
30 |
" |
|
31 |
TOS - top of stack |
|
32 |
NOS - next on stack |
|
33 |
uu - byte-valued unsigned (0..16rFF) |
|
34 |
uuuu - twoByte-valued unsigned (0..16rFFFF); msb-first |
|
35 |
ll - byte-valued literal index (0..16rFF) |
|
36 |
nn - byte-valued signed (-128..+127) |
|
37 |
nnnn - twoByte-valued signed (16r-8000 .. 16r7FFF) |
|
38 |
||
1815 | 39 |
Notes: |
3161 | 40 |
- bytecode optimized for space, not interpreter speed, |
41 |
since JITTER is assumed to be present and compensate for decoding |
|
42 |
overhead. |
|
43 |
- number assignments due to backward compatible extensions of the |
|
44 |
bytecode set - reassignment & cleanup would be nice. |
|
45 |
- codes marked with (*) make the minimal set; all others duplicate |
|
46 |
the functionality of a minimalSet code, but provides dense encoding |
|
1030 | 47 |
|
48 |
definition of ST/X byteCode: |
|
49 |
||
50 |
* 00 RET_TOP return TOS from current context |
|
3161 | 51 |
01 RET_NIL return nil from current context |
52 |
02 RET_TRUE return true from current context |
|
53 |
03 RET_FALSE return false from current context |
|
54 |
04 RET_0 return 0 (zero) from current context |
|
55 |
05 RET_SELF return the current receiver from current context |
|
1030 | 56 |
* 06 DUP_OVER push NOS (used with inlined loops) |
57 |
* 07 HOME_RET_TOP return TOS from home context (method return from block) |
|
3161 | 58 |
08 uu LINENO line number information dummy |
1030 | 59 |
* 09 uuuu LINENO16 line number information dummy |
3161 | 60 |
0A PUSH_NIL push nil onto stack |
61 |
0B PUSH_TRUE push true onto stack |
|
62 |
0C PUSH_FALSE push false onto stack |
|
63 |
0D SEND_SELF self-send |
|
1030 | 64 |
* 0E ll PUSH_LIT push a literal |
3161 | 65 |
0F PUSH_SELF push the current receiver onto stack |
66 |
10 nn PUSH_NUM push a byte-valued smallInteger onto stack |
|
67 |
11 nnnn PUSH_NUM16 push a twoByte-valued smallInteger onto stack |
|
1030 | 68 |
* 12 DROP pop & forget |
1815 | 69 |
* 13 SEND send |
70 |
* 14 SUPER_SEND super-send (actually: directed send) |
|
3161 | 71 |
15 SEND0 send 0-arg message |
72 |
16 SEND1 send 1-arg message |
|
73 |
17 SEND2 send 2-arg message |
|
74 |
18 SEND3 send 3-arg message |
|
75 |
19 SEND_DROP send & forget result |
|
76 |
1A SEND0_DROP send 0-arg message & forget result |
|
77 |
1B SEND1_DROP send 1-arg message & forget result |
|
78 |
1C SEND2_DROP send 2-arg message & forget result |
|
79 |
1D SEND3_DROP send 3-arg message & forget result |
|
1030 | 80 |
* 1E PUSH_MARG push method arg |
81 |
* 1F PUSH_MVAR push method variable |
|
82 |
* 20 PUSH_BARG push block arg |
|
83 |
* 21 PUSH_BVAR push block variable |
|
84 |
* 22 PUSH_IVAR push instance variable |
|
3161 | 85 |
23 PUSH_CVAR -- obsolete -- no longer used. |
1030 | 86 |
* 24 PUSH_GLOB push global |
87 |
* 25 STORE_MVAR pop and store into method variable |
|
88 |
* 26 STORE_BVAR pop and store into block variable |
|
89 |
* 27 STORE_IVAR pop and store into instance variable |
|
3161 | 90 |
28 STORE_CVAR -- obsolete -- no longer used. |
1030 | 91 |
* 29 STORE_GLOB pop and store into global |
92 |
* 2A PUSH_OBARG push outer block arg (n levels) |
|
3161 | 93 |
2B PUSH_OBARG1 push outer block arg (1 level) |
94 |
2C PUSH_OBARG2 push outer block arg (2 levels) |
|
95 |
2D EQEQ == -> pop a,b; push a==b |
|
96 |
2E NENE ~~ -> pop a,b; push a~~b |
|
1030 | 97 |
* 2F DUP duplicate TOS |
3161 | 98 |
30 EQEQ0 ==0 -> pop a; push a==0 |
99 |
31 NENE0 ~~0 -> pop a; push a~~0 |
|
100 |
||
101 |
32 JMP_FALSE pop; branch if false |
|
102 |
33 JMP_TRUE pop; branch if true |
|
103 |
34 JMP_NIL pop; branch if nil |
|
104 |
35 JMP_NOTNIL pop; branch if not nil |
|
105 |
36 JMP branch always |
|
106 |
37 MAKE_BLOCK make a block |
|
107 |
38 JMP_ZERO pop; branch if ==0 |
|
108 |
39 JMP_NOTZERO pop; branch if ~~0 |
|
109 |
3A JMP_EQEQ pop a,b; branch if a==b |
|
110 |
3B JMP_NENE pop a,b; branch if a~~b |
|
111 |
||
112 |
3C JMPL_FALSE like above, extended branch delta, (add +128/-128 to offs) |
|
113 |
... ... |
|
114 |
45 JMPL_NENE like above, extended branch delta, (add +128/-128 to offs) |
|
115 |
||
116 |
46 JMPVL_FALSE like above, extended branch delta, (add +256/-256 to offs) |
|
117 |
... ... |
|
118 |
4F JMPVL_NENE like above, extended branch delta, (add +256/-256 to offs) |
|
119 |
||
120 |
50 PUSH_MVAR1 push method variable 1 (first variable) |
|
121 |
51 PUSH_MVAR2 push method variable 2 |
|
122 |
52 PUSH_MVAR3 push method variable 3 |
|
123 |
53 PUSH_MVAR4 push method variable 4 |
|
124 |
54 PUSH_MVAR5 push method variable 5 |
|
125 |
55 PUSH_MVAR6 push method variable 6 |
|
126 |
||
127 |
56 PUSH_MARG1 push method arg 1 |
|
128 |
57 PUSH_MARG2 push method arg 2 |
|
129 |
58 PUSH_MARG3 push method arg 3 |
|
130 |
59 PUSH_MARG4 push method arg 4 |
|
131 |
||
132 |
5A PUSH_IVAR1 push inst variable 1 (first variable) |
|
133 |
5B PUSH_IVAR2 push inst variable 2 |
|
134 |
5C PUSH_IVAR3 push inst variable 3 |
|
135 |
5D PUSH_IVAR4 push inst variable 4 |
|
136 |
5E PUSH_IVAR5 push inst variable 5 |
|
137 |
5F PUSH_IVAR6 push inst variable 6 |
|
138 |
60 PUSH_IVAR7 push inst variable 7 |
|
139 |
61 PUSH_IVAR8 push inst variable 8 |
|
140 |
62 PUSH_IVAR9 push inst variable 9 |
|
141 |
63 PUSH_IVAR10 push inst variable 10 |
|
142 |
||
143 |
64 STORE_MVAR1 pop and store into method variable 1 (first variable) |
|
144 |
65 STORE_MVAR2 pop and store into method variable 2 |
|
145 |
66 STORE_MVAR3 pop and store into method variable 3 |
|
146 |
67 STORE_MVAR4 pop and store into method variable 4 |
|
147 |
68 STORE_MVAR5 pop and store into method variable 5 |
|
148 |
69 STORE_MVAR6 pop and store into method variable 6 |
|
149 |
||
150 |
6A unused |
|
151 |
6B unused |
|
152 |
6C unused |
|
153 |
6D unused |
|
154 |
||
155 |
6E STORE_IVAR1 pop and store into inst variable 1 (first variable) |
|
156 |
6F STORE_IVAR2 pop and store into inst variable 2 |
|
157 |
70 STORE_IVAR3 pop and store into inst variable 3 |
|
158 |
71 STORE_IVAR4 pop and store into inst variable 4 |
|
159 |
72 STORE_IVAR5 pop and store into inst variable 5 |
|
160 |
73 STORE_IVAR6 pop and store into inst variable 6 |
|
161 |
74 STORE_IVAR7 pop and store into inst variable 7 |
|
162 |
75 STORE_IVAR8 pop and store into inst variable 8 |
|
163 |
76 STORE_IVAR9 pop and store into inst variable 9 |
|
164 |
77 STORE_IVAR10 pop and store into inst variable 10 |
|
165 |
||
166 |
78 PUSH_0 push smallinteger 0 constant |
|
167 |
79 PUSH_1 push smallinteger 1 constant |
|
168 |
7A PUSH_M1 push smallinteger -1 constant |
|
169 |
||
170 |
7B SEND_PLUS1 send '+ 1' to TOS; replace TOS by result |
|
171 |
7C SEND_MINUS1 send '- 1' to TOS; replace TOS by result |
|
172 |
7D INC_MVAR send '+ 1' to a method variable; store result into same mvar (for inlined loops) |
|
173 |
7E DEC_MVAR send '- 1' to a method variable; store result into same mvar (for inlined loops) |
|
174 |
7F nn RET_NUM return a smallInteger from current context |
|
1030 | 175 |
* 80 PUSH_OBVAR push outer block variable |
176 |
* 81 STORE_OBVAR pop and store into outer block variable |
|
177 |
||
3161 | 178 |
82 SEND_EQ send #= |
179 |
83 SEND_PLUS send #+ |
|
180 |
84 SEND_NE send #~= |
|
181 |
85 SEND_MINUS send #- |
|
182 |
86 SEND_CLASS send #class |
|
183 |
87 SEND_AT send #at: |
|
184 |
88 SEND_ATPUT send #at:put: |
|
185 |
89 SEND_BITAND send #bitAnd: |
|
186 |
8A SEND_BITOR send #bitOr: |
|
187 |
||
188 |
8B PUSH_2 push constant 2 |
|
189 |
||
190 |
8C PUSH_BARG1 push block argument 1 |
|
191 |
8D PUSH_BARG2 |
|
192 |
8E PUSH_BARG3 |
|
193 |
8F PUSH_BARG4 |
|
1031 | 194 |
|
195 |
* 90 PUSH_CONTEXT push thisContext |
|
196 |
||
3161 | 197 |
91 SEND_GT send > |
198 |
92 SEND_GE send >= |
|
199 |
93 SEND_LT send < |
|
200 |
94 SEND_LE send <= |
|
201 |
||
202 |
95 UNUSED_149 obsolete; was: send #next |
|
203 |
96 UNUSED_150 obsolete; was: send #peek |
|
204 |
97 SEND_VALUE send #value |
|
205 |
98 SEND_VALUE1 send #value: |
|
206 |
99 SEND_SIZE send #size |
|
207 |
9A UNUSED_154 |
|
208 |
9B UNUSED_155 |
|
209 |
||
210 |
9C MK0BLOCK make a 0-returning block |
|
211 |
9D MKNILBLOCK make a nil-returning block |
|
212 |
||
213 |
9E UNUSED_158 obsolete; was: send #asInteger */ |
|
214 |
9F UNUSED_159 obsolete; was: send #rounded */ |
|
215 |
||
216 |
A0 RET_MVAR1 return method variable 1 from current context |
|
217 |
A1 RET_MVAR2 return method variable 2 from current context |
|
218 |
A2 RET_MVAR3 |
|
219 |
A3 RET_MVAR4 |
|
220 |
A4 RET_MVAR5 |
|
221 |
A5 RET_MVAR6 return method variable 6 from current context |
|
222 |
||
223 |
A6 RET_IVAR1 return instance variable 1 from current context |
|
224 |
A7 RET_IVAR2 return instance variable 2 from current context |
|
225 |
A8 RET_IVAR3 |
|
226 |
A9 RET_IVAR4 |
|
227 |
AA RET_IVAR5 |
|
228 |
AB RET_IVAR6 |
|
229 |
AC RET_IVAR7 |
|
230 |
AD RET_IVAR8 return instance variable 8 from current context |
|
231 |
||
232 |
AE RET_MARG1 return method arg 1 from current context |
|
233 |
AF RET_MARG2 return method arg 1 from current context |
|
234 |
||
235 |
B0 PUSH_CIVAR obsolete; push class instance variable |
|
236 |
B1 STORE_CIVAR obsolete; store top of stack in class instance variable |
|
237 |
||
238 |
B2 SEND_VALUE2 send #value:value: |
|
239 |
B3 SEND_NOT send #not |
|
240 |
||
241 |
B4 SEND_SELF0 send a 0-arg message to self |
|
242 |
B5 SEND_SELF1 send a 1-arg message to self |
|
243 |
B6 SEND_SELF2 send a 2-arg message to self |
|
244 |
B7 SEND_SELF3 send a 3-arg message to self |
|
245 |
||
246 |
B8 SEND_SELF_DROP0 send a 0-arg message to self forget result |
|
247 |
B9 SEND_SELF_DROP1 send a 1-arg message to self forget result |
|
248 |
BA SEND_SELF_DROP2 send a 2-arg message to self forget result |
|
249 |
BB SEND_SELF_DROP3 send a 3-arg message to self forget result |
|
250 |
||
251 |
BC ISNIL replace TOS by 'TOS isNil' |
|
252 |
BD NOTNIL replace TOS by 'TOS notNil' |
|
253 |
||
254 |
BE uuuu JMPA_FALSE jumps to absolute offset (2 byte hi-lo) |
|
255 |
BF uuuu JMPA_TRUE |
|
256 |
C0 uuuu JMPA_NIL |
|
257 |
C1 uuuu JMPA_NOTNIL |
|
258 |
C2 uuuu JMPA |
|
259 |
C3 MAKE_ABLOCK |
|
260 |
C4 uuuu JMPA_ZERO |
|
261 |
C5 uuuu JMPA_NOTZERO |
|
262 |
C6 uuuu JMPA_EQ |
|
263 |
C7 uuuu JMPA_NOTEQ |
|
264 |
||
265 |
C8 xx PUSH_GSPECIAL push a special global; xx specifies what: |
|
266 |
00 Array (push 'Smalltalk at:#Array'; i.e. the Array class) |
|
267 |
01 String (push 'Smalltalk at:#String'; i.e. the String class) |
|
268 |
02 FloatArray |
|
269 |
03 DoubleArray |
|
270 |
04 Point |
|
271 |
05 Symbol |
|
272 |
06 Smalltalk |
|
273 |
07 Processor |
|
274 |
08 SmallInteger |
|
275 |
09 Character |
|
276 |
0A Float |
|
277 |
0B Process |
|
278 |
0C Set |
|
279 |
0D IdentitySet |
|
280 |
0E Dictionary |
|
281 |
0F IdentityDictionary |
|
282 |
10 Semaphore |
|
283 |
11 OrderedCollection |
|
284 |
||
285 |
C9 uuuu PUSH_LLIT push a literal (2-byte literal-number) |
|
286 |
||
287 |
CA nn JMP_FALSE_L jump if top is false (+127 .. -128) |
|
288 |
CB nn JMP_TRUE_L jump if top is true |
|
289 |
||
290 |
CC UNUSED_204 |
|
291 |
CD LSEND_MSG send with 16 bit literal index */ |
|
292 |
CE LSUPERSEND_MSG super send with 16 bit literal index */ |
|
293 |
CF LSEND_SELF self-send send with 16 bit literal index */ |
|
294 |
D0 PUSH_GT0 push 'TOS > 0'; leaves original TOS as NOS |
|
295 |
||
296 |
D1 UNUSED_209 |
|
297 |
||
298 |
D2 SEND_ARRAY_NEW use for new/basicNew; top is size (0 for Array new) |
|
299 |
D3 SEND_BASICNEW top is class (receiver) |
|
300 |
D4 SEND_GT0 replace TOS by result of send 'TOS > 0' |
|
301 |
D5 SEND_NEW top is class (receiver) |
|
302 |
D6 SEND_BASICNEWN top is class (receiver) and arg |
|
303 |
D7 SEND_NEWN top is class (receiver) and arg |
|
304 |
D8 SEND_LOGAND send & |
|
305 |
D9 SEND_LOGOR send | |
|
306 |
||
307 |
DA uuuu PUSH_LGLOB push global variable word index literal |
|
308 |
DB uuuu STORE_LGLOB store global with word index literal |
|
309 |
||
310 |
DC UNUSED_220 |
|
311 |
DE UNUSED_221 |
|
312 |
||
313 |
DF PUSH_LIT1 push 1st literal |
|
314 |
E0 PUSH_LIT2 push 2nd literal |
|
315 |
E1 PUSH_LIT3 push literal 3 |
|
316 |
E2 PUSH_LIT4 push literal 4 |
|
317 |
E3 PUSH_LIT5 push literal 5 |
|
318 |
E4 PUSH_LIT6 push literal 6 |
|
319 |
E5 PUSH_LIT7 push literal 7 |
|
320 |
E6 PUSH_LIT8 push literal 8 |
|
321 |
||
322 |
E7 SEND_MUL send #* |
|
323 |
E8 xx SEND_SPECIAL special send; as specified by xx: |
|
324 |
00 top send #top |
|
325 |
01 bottom send #bottom |
|
326 |
02 left send #left |
|
327 |
03 right send #right |
|
328 |
04 x send #x |
|
329 |
05 y send #y |
|
330 |
06 width send #width |
|
331 |
07 height send #height |
|
332 |
08 origin send #origin |
|
333 |
09 extent send #extent |
|
334 |
0A asInteger send #asInteger |
|
335 |
0B rounded send #rounded |
|
336 |
0C next send #next |
|
337 |
0D peek send #peek |
|
338 |
||
339 |
E9 PUSH_BVAR1 push block variable 1 |
|
340 |
EA PUSH_BVAR2 push block variable 2 |
|
341 |
EB PUSH_BVAR3 push block variable 3 |
|
342 |
||
343 |
EC STORE_BVAR1 store TOS in block variable 1 and drop |
|
344 |
ED STORE_BVAR2 store TOS in block variable 2 and drop |
|
345 |
EE STORE_BVAR3 store TOS in block variable 3 and drop |
|
1031 | 346 |
|
347 |
* EF BLOCK_REF internal - check if a block is referenced by TOS |
|
348 |
||
3161 | 349 |
F0 PUSH_LVAR push local variable 0..numArgs-1 for args; numArgs..numArgs+nLocal-1 for mVars |
350 |
F1 STORE_LVAR store local variable 0..numArgs-1 for args; numArgs..numArgs+nLocal-1 for mVars |
|
351 |
F2 STORE_OUTBLOCK_LVAR store local variable in outer context 0..numArgs-1 for args; numArgs..numArgs+nLocal-1 for bVars |
|
352 |
F3 SWAP swap TOS with NOS |
|
3162
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
353 |
|
3161 | 354 |
F4 UNUSED_244 |
355 |
F5 UNUSED_245 |
|
356 |
F6 UNUSED_246 |
|
357 |
F7 UNUSED_247 |
|
358 |
F8 UNUSED_248 |
|
359 |
F9 UNUSED_249 |
|
360 |
FA UNUSED_250 |
|
361 |
FB UNUSED_251 |
|
362 |
FC UNUSED_252 |
|
363 |
FD UNUSED_253 |
|
364 |
FE UNUSED_254 |
|
365 |
FF UNUSED_255 |
|
1030 | 366 |
|
367 |
[author:] |
|
3161 | 368 |
Claus Gittinger |
1030 | 369 |
|
370 |
" |
|
371 |
! |
|
372 |
||
141 | 373 |
copyright |
374 |
" |
|
375 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
376 |
All Rights Reserved |
|
377 |
||
378 |
This software is furnished under a license and may be used |
|
379 |
only in accordance with the terms of that license and with the |
|
380 |
inclusion of the above copyright notice. This software may not |
|
381 |
be provided or otherwise made available to, or used by, any |
|
382 |
other person. No title to or ownership of the software is |
|
383 |
hereby transferred. |
|
384 |
" |
|
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
128
diff
changeset
|
385 |
! |
20 | 386 |
|
3 | 387 |
documentation |
388 |
" |
|
19 | 389 |
This class performs compilation into ByteCodes. |
390 |
First, parsing is done using superclass methods, |
|
391 |
then the parse-tree is converted into an array of symbolic codes |
|
1815 | 392 |
and a relocation table; |
19 | 393 |
these two are finally combined into a byteArray of the codes. |
0 | 394 |
|
19 | 395 |
(the intermediate step through symbolic codes is for debugging |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
396 |
only - it may vanish in future releases) |
19 | 397 |
|
398 |
There are many dependencies to the run-time-system (especially the |
|
399 |
interpreter) in here - be careful when playing around ... |
|
0 | 400 |
|
259 | 401 |
[Instance variables:] |
0 | 402 |
|
1815 | 403 |
codeBytes <ByteArry> bytecodes |
404 |
codeIndex <SmallInteger> next index to put into code array |
|
405 |
litArray <OrderedCollection> literals |
|
406 |
stackDelta <SmallInteger> return value of byteCodeFor: |
|
407 |
extra <Symbol> return value of byteCodeFor: |
|
408 |
lineno <Boolean> return value of byteCodeFor: |
|
409 |
extraLiteral <Symbol> return value of byteCodeFor: |
|
410 |
maxStackDepth <SmallInteger> stack need of method |
|
411 |
relocList <Array> used temporary for relocation |
|
19 | 412 |
|
259 | 413 |
[Class variables:] |
19 | 414 |
|
1815 | 415 |
JumpToAbsJump <Dictionary> internal table to map opcodes |
416 |
||
417 |
STCCompilationDefines passed to stc as command line arguments |
|
418 |
STCCompilationIncludes |
|
419 |
STCCompilationOptions |
|
420 |
<String> |
|
421 |
||
422 |
STCCompilation <Symbol> #always, #primitiveOnly or #never |
|
423 |
controls when stc compilation is wanted |
|
424 |
||
425 |
ShareCode <Boolean> reuse byteArrays for common (simple) code sequences |
|
426 |
This is normally a 'good' optimization, |
|
427 |
except if you plan to modify the byteCodes. |
|
263 | 428 |
|
429 |
[author:] |
|
1815 | 430 |
Claus Gittinger |
263 | 431 |
|
3 | 432 |
" |
3681 | 433 |
! |
434 |
||
435 |
examples |
|
436 |
" |
|
437 |
a GNU-Smalltalk method: |
|
438 |
[exBegin] |
|
439 |
Compiler |
|
440 |
compile:'bla |
|
441 |
<category: ''tests''> |
|
442 |
||
443 |
^ 123 |
|
444 |
' |
|
445 |
forClass: Object |
|
446 |
[exEnd] |
|
447 |
" |
|
98 | 448 |
! ! |
449 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
450 |
!ByteCodeCompiler class methodsFor:'initialization'! |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
451 |
|
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
452 |
initialize |
1050 | 453 |
Smalltalk vmMajorVersionNr >= 5 ifTrue:[ |
3393 | 454 |
NewCodeSet := true. |
455 |
NewPrimitives := true. |
|
1050 | 456 |
] ifFalse:[ |
3393 | 457 |
NewCodeSet := false. |
458 |
NewPrimitives := false. |
|
1050 | 459 |
]. |
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
460 |
ShareCode := true. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
600
diff
changeset
|
461 |
ListCompiledMethods := false. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
600
diff
changeset
|
462 |
|
1219
e5c891489441
support compilation restart (after a fix)
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
463 |
"Modified: / 15.11.2001 / 17:20:51 / cg" |
1046 | 464 |
! |
465 |
||
466 |
newCodeSet |
|
1815 | 467 |
^ NewCodeSet |
1046 | 468 |
|
469 |
! |
|
470 |
||
471 |
newCodeSet:aBoolean |
|
472 |
NewCodeSet := aBoolean. |
|
473 |
||
474 |
" |
|
475 |
ByteCodeCompiler newCodeSet:true |
|
476 |
" |
|
1049 | 477 |
! |
478 |
||
479 |
newPrimitives |
|
1815 | 480 |
^ NewPrimitives |
1049 | 481 |
|
482 |
! |
|
483 |
||
484 |
newPrimitives:aBoolean |
|
485 |
NewPrimitives := aBoolean. |
|
486 |
||
487 |
" |
|
488 |
ByteCodeCompiler newPrimitives:true |
|
489 |
" |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
490 |
! ! |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
491 |
|
3428
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
492 |
!ByteCodeCompiler class methodsFor:'instance creation'! |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
493 |
|
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
494 |
new |
3436
874d31b00f8a
Comment in ByteCodeCompiler>>#new
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3428
diff
changeset
|
495 |
|
874d31b00f8a
Comment in ByteCodeCompiler>>#new
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3428
diff
changeset
|
496 |
"/ Pretty ugly hack. A caller to compiler may provide a set of breakpoints |
874d31b00f8a
Comment in ByteCodeCompiler>>#new
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3428
diff
changeset
|
497 |
"/ that has to be injected to the code. However, since breakpoint injection |
874d31b00f8a
Comment in ByteCodeCompiler>>#new
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3428
diff
changeset
|
498 |
"/ is actually done by a subclass or me, so we have to return this subclass here. |
874d31b00f8a
Comment in ByteCodeCompiler>>#new
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3428
diff
changeset
|
499 |
"/ This subclass-to-tranform API is bit unfortunate. |
3428
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
500 |
^ self ~~ ByteCodeCompiler ifTrue:[ |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
501 |
super new. |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
502 |
] ifFalse:[ |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
503 |
| breakpoints | |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
504 |
|
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
505 |
breakpoints := BreakpointQuery query. |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
506 |
breakpoints notEmptyOrNil ifTrue:[ |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
507 |
ByteCodeCompilerWithBreakpointSupport new |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
508 |
breakpoints: breakpoints; |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
509 |
yourself. |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
510 |
] ifFalse:[ |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
511 |
super new. |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
512 |
]. |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
513 |
]. |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
514 |
|
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
515 |
"Created: / 08-05-2014 / 11:01:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
516 |
! ! |
eaf3ac065bf9
Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3416
diff
changeset
|
517 |
|
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
518 |
!ByteCodeCompiler class methodsFor:'compiling methods'! |
98 | 519 |
|
0 | 520 |
compile:methodText forClass:classToCompileFor |
890 | 521 |
"compile a source-string for a method in classToCompileFor. |
522 |
Returns the new method, #Error or nil." |
|
523 |
||
1815 | 524 |
^ self |
3281 | 525 |
compile:methodText |
526 |
forClass:classToCompileFor |
|
527 |
inCategory:(self asYetUncategorizedMethodCategory) |
|
528 |
notifying:nil |
|
529 |
install:true |
|
530 |
skipIfSame:false |
|
531 |
silent:false |
|
0 | 532 |
! |
533 |
||
534 |
compile:aString forClass:aClass inCategory:cat |
|
535 |
"compile a source-string for a method in classToCompileFor. |
|
890 | 536 |
The method will get cat as category. |
537 |
Returns the new method, #Error or nil." |
|
538 |
||
1815 | 539 |
^ self |
2735
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
540 |
compile:aString |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
541 |
forClass:aClass |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
542 |
inCategory:cat |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
543 |
notifying:nil |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
544 |
install:true |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
545 |
skipIfSame:false |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
546 |
silent:false |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
547 |
foldConstants:true |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
548 |
|
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
549 |
"Modified: / 30-09-2011 / 12:44:23 / cg" |
0 | 550 |
! |
551 |
||
84 | 552 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
0 | 553 |
"compile a source-string for a method in classToCompileFor. |
84 | 554 |
errors are forwarded to requestor. |
890 | 555 |
The method will get cat as category. |
556 |
Returns the new method, #Error or nil." |
|
557 |
||
1815 | 558 |
^ self |
559 |
compile:aString |
|
560 |
forClass:aClass |
|
561 |
inCategory:cat |
|
562 |
notifying:requestor |
|
563 |
install:true |
|
564 |
skipIfSame:false |
|
565 |
silent:false |
|
0 | 566 |
! |
567 |
||
141 | 568 |
compile:aString forClass:aClass inCategory:cat notifying:requestor install:install |
569 |
"compile a source-string for a method in classToCompileFor. |
|
570 |
The install-argument controls if the method is to be installed into the |
|
571 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
890 | 572 |
Errors are forwarded to requestor. The method will get cat as category. |
573 |
Returns the new method, #Error or nil." |
|
574 |
||
1815 | 575 |
^ self |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
576 |
compile:aString |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
577 |
forClass:aClass |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
578 |
inCategory:cat |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
579 |
notifying:requestor |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
580 |
install:install |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
581 |
skipIfSame:false |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
582 |
silent:false |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
583 |
|
141 | 584 |
! |
585 |
||
586 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
|
1815 | 587 |
install:install skipIfSame:skipIfSame |
141 | 588 |
"compile a source-string for a method in classToCompileFor. |
589 |
The install-argument controls if the method is to be installed into the |
|
590 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
591 |
Errors are forwarded to requestor. The method will get cat as category. |
|
592 |
If skipIsSame is true, and the source is the same as an existing |
|
890 | 593 |
methods source, this is a noop (for fast fileIn). |
594 |
Returns the new method, #Error or nil." |
|
595 |
||
1815 | 596 |
^ self |
597 |
compile:aString |
|
598 |
forClass:aClass |
|
599 |
inCategory:cat |
|
600 |
notifying:requestor |
|
601 |
install:install |
|
602 |
skipIfSame:skipIfSame |
|
603 |
silent:false |
|
141 | 604 |
! |
605 |
||
84 | 606 |
compile:aString forClass:aClass inCategory:cat notifying:requestor |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
607 |
install:install skipIfSame:skipIfSame silent:silent |
890 | 608 |
"compile a source-string for a method in aClass. |
609 |
errors are forwarded to requestor. |
|
610 |
The method will get cat as category. |
|
611 |
if install is true, the method is installed in the class. |
|
612 |
if skipIfSame, the method is not installed if there is no change |
|
613 |
(used when filing in). |
|
614 |
if silent is true, no warnings are output. |
|
615 |
Returns the new method, #Error or nil." |
|
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
616 |
|
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
617 |
^ self |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
618 |
compile:aString |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
619 |
forClass:aClass |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
620 |
inCategory:cat |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
621 |
notifying:requestor |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
622 |
install:install |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
623 |
skipIfSame:skipIfSame |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
624 |
silent:silent |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
625 |
foldConstants:true |
230
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
626 |
! |
54e13c76f143
allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
627 |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1219
diff
changeset
|
628 |
compile:aStringArg forClass:aClassArg inCategory:cat notifying:requestor |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
629 |
install:install skipIfSame:skipIfSame silent:silent foldConstants:fold |
20 | 630 |
|
631 |
"the basic workhorse method for compiling: |
|
0 | 632 |
compile a source-string for a method in classToCompileFor. |
1815 | 633 |
errors are forwarded to requestor |
890 | 634 |
(report on Transcript and return #Error, if requestor is nil). |
0 | 635 |
|
1815 | 636 |
The new method will get cat as category. |
637 |
If install is true, the method will go into the classes method-table, |
|
20 | 638 |
otherwise the method is simply returned (for anonymous methods). |
0 | 639 |
If skipIsSame is true, and the source is the same as an existing |
20 | 640 |
methods source, this is a noop (for fast fileIn). |
890 | 641 |
The argument, silent controls if errors are to be reported. |
642 |
Returns the method, #Error or nil." |
|
0 | 643 |
|
1363 | 644 |
^ self new |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
645 |
compile:aStringArg |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
646 |
forClass:aClassArg |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
647 |
inCategory:cat |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
648 |
notifying:requestor |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
649 |
install:install |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
650 |
skipIfSame:skipIfSame |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
651 |
silent:silent |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
652 |
foldConstants:fold |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
653 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
654 |
|
1466 | 655 |
compile:methodText forClass:classToCompileFor install:doInstall |
656 |
"compile a source-string for a method in classToCompileFor. |
|
657 |
The install-argument controls if the method is to be installed into the |
|
658 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
659 |
Returns the new method, #Error or nil." |
|
660 |
||
1815 | 661 |
^ self |
3281 | 662 |
compile:methodText |
663 |
forClass:classToCompileFor |
|
664 |
inCategory:(self defaultMethodCategory) |
|
665 |
notifying:nil |
|
666 |
install:doInstall |
|
667 |
skipIfSame:false |
|
668 |
silent:false |
|
1466 | 669 |
! |
670 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
671 |
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
|
672 |
"compile a source-string for a method in classToCompileFor. |
890 | 673 |
Errors are forwarded to requestor. |
674 |
Returns the new method, #Error or nil." |
|
675 |
||
1815 | 676 |
^ self |
3281 | 677 |
compile:methodText |
678 |
forClass:classToCompileFor |
|
679 |
inCategory:(self defaultMethodCategory) |
|
680 |
notifying:requestor |
|
681 |
install:true |
|
682 |
skipIfSame:false |
|
683 |
silent:false |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
684 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
685 |
|
141 | 686 |
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock |
890 | 687 |
"name alias for ST-80 compatibility. |
1201 | 688 |
Returns the new method, or the value from exceptionBlock." |
141 | 689 |
|
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
690 |
^ self new |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
691 |
compile:textOrStream |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
692 |
in:aClass |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
693 |
notifying:requestor |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
694 |
ifFail:exceptionBlock |
1549 | 695 |
! |
696 |
||
2428
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
697 |
compile:textOrStream in:aClass notifying:requestor install:install ifFail:exceptionBlock |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
698 |
"name alias for ST-80 compatibility. |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
699 |
Returns the new method, or the value from exceptionBlock." |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
700 |
|
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
701 |
^ self new |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
702 |
compile:textOrStream |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
703 |
in:aClass |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
704 |
notifying:requestor |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
705 |
install:install |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
706 |
ifFail:exceptionBlock |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
707 |
|
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
708 |
"Created: / 15-10-2010 / 10:39:27 / cg" |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
709 |
! |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
710 |
|
1549 | 711 |
stcCompileMethod:aMethod |
1815 | 712 |
ParserFlags |
713 |
withSTCCompilation:#always |
|
714 |
do:[ |
|
715 |
self |
|
716 |
compile:(aMethod source) |
|
717 |
forClass:(aMethod mclass) |
|
718 |
inCategory:(aMethod category) |
|
719 |
]. |
|
0 | 720 |
! ! |
721 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
722 |
!ByteCodeCompiler class methodsFor:'constants'! |
15 | 723 |
|
724 |
byteCodeFor:aSymbol |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
725 |
"returns the numeric code for some symbolic bytecodes." |
15 | 726 |
|
25 | 727 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
728 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
729 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
730 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
1402 | 731 |
(aSymbol == #retSelf) ifTrue:[^5]. |
1300
be5542fc877e
more bytecodes in #byteCodeFor class method
Stefan Vogel <sv@exept.de>
parents:
1280
diff
changeset
|
732 |
(aSymbol == #retNum) ifTrue:[^ 127]. |
25 | 733 |
(aSymbol == #retTop) ifTrue:[^ 0]. |
734 |
||
1300
be5542fc877e
more bytecodes in #byteCodeFor class method
Stefan Vogel <sv@exept.de>
parents:
1280
diff
changeset
|
735 |
(aSymbol == #mk0Block) ifTrue:[^ 156]. |
be5542fc877e
more bytecodes in #byteCodeFor class method
Stefan Vogel <sv@exept.de>
parents:
1280
diff
changeset
|
736 |
(aSymbol == #mkNilBlock) ifTrue:[^ 157]. |
be5542fc877e
more bytecodes in #byteCodeFor class method
Stefan Vogel <sv@exept.de>
parents:
1280
diff
changeset
|
737 |
|
15 | 738 |
(aSymbol == #push0) ifTrue:[^120]. |
739 |
(aSymbol == #push1) ifTrue:[^121]. |
|
740 |
(aSymbol == #push2) ifTrue:[^139]. |
|
741 |
(aSymbol == #pushMinus1) ifTrue:[^122]. |
|
742 |
(aSymbol == #pushNil) ifTrue:[^ 10]. |
|
743 |
(aSymbol == #pushTrue) ifTrue:[^ 11]. |
|
744 |
(aSymbol == #pushFalse) ifTrue:[^ 12]. |
|
745 |
(aSymbol == #pushSelf) ifTrue:[^ 15]. |
|
1402 | 746 |
self error:'unknown instruction'. |
15 | 747 |
! ! |
748 |
||
1324 | 749 |
!ByteCodeCompiler class methodsFor:'defaults'! |
750 |
||
1666 | 751 |
allowExtensionsToPrivateClasses |
752 |
^ ParserFlags allowExtensionsToPrivateClasses |
|
753 |
! |
|
754 |
||
3281 | 755 |
asYetUncategorizedMethodCategory |
756 |
^ '* As yet uncategorized *' |
|
757 |
! |
|
758 |
||
1324 | 759 |
defaultMethodCategory |
760 |
"/ ^ '** As yet uncategorized **'. |
|
761 |
^ '* uncategorized *' |
|
762 |
! ! |
|
763 |
||
1414 | 764 |
!ByteCodeCompiler class methodsFor:'private-utilities'! |
1280 | 765 |
|
766 |
stringWithSimpleCRs:aString |
|
767 |
|src dst ch| |
|
768 |
||
1496
7f31982d2933
replaced '' writeStream by String writeStream
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
769 |
dst := String writeStream. |
1280 | 770 |
src := aString readStream. |
771 |
[src atEnd] whileFalse:[ |
|
1815 | 772 |
ch := src next. |
773 |
ch = Character return ifTrue:[ |
|
774 |
src peek == Character linefeed ifTrue:[ |
|
775 |
src next. |
|
776 |
]. |
|
777 |
ch := Character cr. |
|
778 |
]. |
|
779 |
dst nextPut:ch |
|
1280 | 780 |
]. |
781 |
^ dst contents |
|
782 |
! ! |
|
783 |
||
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
784 |
!ByteCodeCompiler class methodsFor:'stc compilation defaults'! |
54 | 785 |
|
141 | 786 |
canCreateMachineCode |
787 |
"return true, if compilation to machine code is supported. |
|
1666 | 788 |
Currently, all SYSV4, Linux and WinNT/XP systems do so; |
1815 | 789 |
REAL/IX and HPUX9.x do not |
790 |
(due to the need for dynamic loading of object files, which is not supported by those). |
|
141 | 791 |
MIPS ULTRIX is almost finished, but not yet released. |
1666 | 792 |
(late note - we no longer care for REAL/IX, HPUX9.x and MIPS ULTRIX)" |
793 |
||
794 |
^ ObjectFileLoader notNil and:[ ObjectFileLoader canLoadObjectFiles ]. |
|
124 | 795 |
|
796 |
" |
|
1815 | 797 |
Compiler canCreateMachineCode |
141 | 798 |
" |
799 |
||
769
cabe7bdb46ec
changes for WIN32 machineCode generation & loading
Claus Gittinger <cg@exept.de>
parents:
768
diff
changeset
|
800 |
"Modified: / 13.9.1995 / 15:15:11 / claus" |
cabe7bdb46ec
changes for WIN32 machineCode generation & loading
Claus Gittinger <cg@exept.de>
parents:
768
diff
changeset
|
801 |
"Modified: / 3.9.1998 / 15:56:07 / cg" |
141 | 802 |
! |
803 |
||
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
804 |
ccCompilationOptions |
4101 | 805 |
<resource: #obsolete> |
806 |
||
807 |
"return the options used with cc compilation. |
|
808 |
This method remains here for backward compatibility (older script files)" |
|
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
809 |
|
1666 | 810 |
^ ParserFlags ccCompilationOptions |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
811 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
812 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
813 |
Compiler ccCompilationOptions |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
814 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
815 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
816 |
"Modified: 5.11.1996 / 17:38:56 / cg" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
817 |
! |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
818 |
|
4193 | 819 |
ccCompilationOptions:aString |
820 |
<resource: #obsolete> |
|
821 |
||
822 |
"define the compilation options |
|
823 |
to be used when compiling to machine code. |
|
824 |
These are passed to cc. Can be set from your private.rc file. |
|
825 |
This method remains here for backward compatibility (older script files)" |
|
826 |
||
827 |
ParserFlags ccCompilationOptions:aString |
|
828 |
||
829 |
" |
|
830 |
Compiler ccCompilationOptions:'-O' |
|
831 |
Compiler ccCompilationOptions:'-O -fPIC' |
|
832 |
Compiler ccCompilationOptions |
|
833 |
" |
|
834 |
||
835 |
"Created: 5.11.1996 / 17:37:05 / cg" |
|
836 |
"Modified: 5.11.1996 / 17:38:32 / cg" |
|
837 |
! |
|
838 |
||
1815 | 839 |
ccPath |
4101 | 840 |
<resource: #obsolete> |
841 |
||
842 |
"return the path to (name of) the cc command for incremental method compilation. |
|
843 |
This method remains here for backward compatibility (older script files)" |
|
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
844 |
|
1666 | 845 |
^ ParserFlags ccPath |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
846 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
847 |
" |
772 | 848 |
CC := nil |
1815 | 849 |
Compiler ccPath |
850 |
Compiler ccPath:'gcc' |
|
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
851 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
852 |
|
769
cabe7bdb46ec
changes for WIN32 machineCode generation & loading
Claus Gittinger <cg@exept.de>
parents:
768
diff
changeset
|
853 |
"Modified: / 13.9.1995 / 15:15:04 / claus" |
cabe7bdb46ec
changes for WIN32 machineCode generation & loading
Claus Gittinger <cg@exept.de>
parents:
768
diff
changeset
|
854 |
"Created: / 5.11.1996 / 17:35:40 / cg" |
772 | 855 |
"Modified: / 4.9.1998 / 15:48:40 / cg" |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
856 |
! |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
857 |
|
1815 | 858 |
ccPath:aPathOrCommandName |
4101 | 859 |
<resource: #obsolete> |
860 |
||
861 |
"set the path to the cc command for incremental method compilation. |
|
862 |
This method remains here for backward compatibility (older script files)" |
|
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
863 |
|
1666 | 864 |
ParserFlags ccPath:aPathOrCommandName |
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
865 |
|
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
866 |
" |
1815 | 867 |
Compiler ccPath |
868 |
Compiler ccPath:'gcc' |
|
869 |
Compiler ccPath:'bcc32' |
|
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
870 |
" |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
871 |
|
773 | 872 |
"Modified: / 13.9.1995 / 15:15:04 / claus" |
873 |
"Created: / 5.11.1996 / 17:38:11 / cg" |
|
874 |
"Modified: / 23.8.1998 / 13:58:57 / cg" |
|
411
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
875 |
! |
d4ca24ab1f4c
more control over cc command;
Claus Gittinger <cg@exept.de>
parents:
410
diff
changeset
|
876 |
|
141 | 877 |
stcCompilation |
4101 | 878 |
<resource: #obsolete> |
879 |
||
141 | 880 |
"return the flag which controls compilation to machine code. |
881 |
If #always, methods are always compiled to machine code (which takes |
|
882 |
longer, but provides faster code). If #none, methods are never compiled |
|
883 |
to machine code, instead for non-primitive ones, compilation is to bytecode |
|
884 |
and for primitive ones, a trapping stub is generated. |
|
885 |
Anything else lets the compiler compile to bytecode, |
|
886 |
except for methods containing primitive code. |
|
887 |
This can be set from your private.rc file or from a workspace |
|
4101 | 888 |
for selective compilation to machine code. |
889 |
This method remains here for backward compatibility (older script files)" |
|
124 | 890 |
|
1661 | 891 |
^ ParserFlags stcCompilation |
54 | 892 |
|
893 |
" |
|
141 | 894 |
Compiler stcCompilation |
124 | 895 |
" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
896 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
897 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
898 |
stcCompilation:how |
4101 | 899 |
<resource: #obsolete> |
900 |
||
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
901 |
"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
|
902 |
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
|
903 |
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
|
904 |
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
|
905 |
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
|
906 |
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
|
907 |
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
|
908 |
This can be set from your private.rc file or from a workspace |
4101 | 909 |
for selective compilation to machine code. |
910 |
This method remains here for backward compatibility (older script files)" |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
911 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
912 |
|ret| |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
913 |
|
1661 | 914 |
ret := ParserFlags stcCompilation. |
915 |
ParserFlags stcCompilation:how. |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
916 |
^ ret |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
917 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
918 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
919 |
Compiler stcCompilation:#always |
1815 | 920 |
Compiler stcCompilation:#never |
921 |
Compiler stcCompilation:#default |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
922 |
" |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
923 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
924 |
|
141 | 925 |
stcCompilationDefines |
4101 | 926 |
<resource: #obsolete> |
927 |
||
928 |
"return the defines used with stc compilation. |
|
929 |
This method remains here for backward compatibility (older script files)" |
|
141 | 930 |
|
1666 | 931 |
^ ParserFlags stcCompilationDefines |
141 | 932 |
! |
933 |
||
934 |
stcCompilationDefines:aString |
|
4101 | 935 |
<resource: #obsolete> |
936 |
||
141 | 937 |
"define the flags (for example, additional -D defines) |
938 |
to be used when compiling to machine code. |
|
4101 | 939 |
These are passed to stc. Can be set from your private.rc file. |
940 |
This method remains here for backward compatibility (older script files)" |
|
141 | 941 |
|
1666 | 942 |
ParserFlags stcCompilationDefines:aString |
141 | 943 |
|
944 |
" |
|
945 |
Compiler stcCompilationDefines:'-DVGL -DDEBUG' |
|
773 | 946 |
Compiler stcCompilationDefines:'-DWIN32' |
141 | 947 |
" |
773 | 948 |
|
949 |
"Modified: / 23.8.1998 / 14:00:40 / cg" |
|
141 | 950 |
! |
951 |
||
952 |
stcCompilationIncludes |
|
4101 | 953 |
<resource: #obsolete> |
954 |
||
955 |
"return the includes used with stc compilation. |
|
956 |
This method remains here for backward compatibility (older script files)" |
|
141 | 957 |
|
1666 | 958 |
^ ParserFlags stcCompilationIncludes |
141 | 959 |
! |
960 |
||
961 |
stcCompilationIncludes:aString |
|
4101 | 962 |
<resource: #obsolete> |
963 |
||
141 | 964 |
"define the include directories via additional -I flags. |
4101 | 965 |
These are passed to stc. Can be set in your private.rc file. |
966 |
This method remains here for backward compatibility (older script files)" |
|
141 | 967 |
|
1666 | 968 |
ParserFlags stcCompilationIncludes:aString |
141 | 969 |
|
970 |
" |
|
971 |
Compiler stcCompilationIncludes:'-I/usr/local/include -I../../include' |
|
972 |
Compiler stcCompilationIncludes:(Compiler stcCompilationIncludes , ' -I../../libxt') |
|
973 |
" |
|
586
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
974 |
|
e9ef451f36d0
automatically include STX_LIBDIR in -I-list
Claus Gittinger <cg@exept.de>
parents:
560
diff
changeset
|
975 |
"Modified: 18.7.1997 / 18:04:25 / cg" |
141 | 976 |
! |
977 |
||
124 | 978 |
stcCompilationOptions |
4101 | 979 |
<resource: #obsolete> |
980 |
||
981 |
"return the options used with stc compilation. |
|
982 |
This method remains here for backward compatibility (older script files)" |
|
124 | 983 |
|
1666 | 984 |
^ ParserFlags stcCompilationOptions |
124 | 985 |
! |
986 |
||
141 | 987 |
stcCompilationOptions:aString |
4101 | 988 |
<resource: #obsolete> |
989 |
||
1815 | 990 |
"define the compilation options |
141 | 991 |
to be used when compiling to machine code. |
4101 | 992 |
These are passed to stc. Can be set from your private.rc file. |
993 |
This method remains here for backward compatibility (older script files)" |
|
101 | 994 |
|
1666 | 995 |
ParserFlags stcCompilationOptions:aString |
101 | 996 |
|
997 |
" |
|
141 | 998 |
Compiler stcCompilationOptions:'+optinline' |
101 | 999 |
" |
1000 |
! |
|
1001 |
||
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1002 |
stcModulePath |
4101 | 1003 |
<resource: #obsolete> |
1004 |
||
1005 |
"return the path, where temporary modules are created. |
|
1006 |
This method remains here for backward compatibility (older script files)" |
|
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1007 |
|
1666 | 1008 |
^ ParserFlags stcModulePath |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1009 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1010 |
"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
|
1011 |
! |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1012 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1013 |
stcModulePath:aPath |
4101 | 1014 |
<resource: #obsolete> |
1015 |
||
4014 | 1016 |
"set the path to the directory, where temporary modules are created. |
1017 |
Obsolete; knowledge moved to parserFlags, |
|
1018 |
where it is also obsolete now, as this should not be set from the outside, |
|
4101 | 1019 |
but instead rely totally on the userPreferences. |
1020 |
This method remains here for backward compatibility (older script files)" |
|
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1021 |
|
1666 | 1022 |
ParserFlags stcModulePath:aPath |
301
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1023 |
|
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1024 |
"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
|
1025 |
! |
5c0add6f00e2
create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
1026 |
|
1815 | 1027 |
stcPath |
4101 | 1028 |
<resource: #obsolete> |
1029 |
||
1030 |
"return the path to the stc command, or nil if not found. |
|
1031 |
This method remains here for backward compatibility (older script files)" |
|
141 | 1032 |
|
1666 | 1033 |
^ ParserFlags stcPath |
141 | 1034 |
|
1035 |
" |
|
1815 | 1036 |
Compiler stcPath |
141 | 1037 |
" |
1038 |
||
1039 |
"Modified: 13.9.1995 / 14:37:26 / claus" |
|
1040 |
! |
|
1041 |
||
1815 | 1042 |
stcPath:aPath |
4101 | 1043 |
<resource: #obsolete> |
1044 |
||
1045 |
"set the path to the stc command - useful if private stc is wanted. |
|
1046 |
This method remains here for backward compatibility (older script files)" |
|
695 | 1047 |
|
1666 | 1048 |
ParserFlags stcPath:aPath |
695 | 1049 |
|
1050 |
" |
|
1815 | 1051 |
Compiler stcPath:'../../stc/stc' |
1052 |
Compiler stcPath:'..\stc\stc' |
|
695 | 1053 |
" |
1054 |
||
773 | 1055 |
"Modified: / 13.9.1995 / 14:37:26 / claus" |
1056 |
"Modified: / 23.8.1998 / 13:59:24 / cg" |
|
695 | 1057 |
! |
1058 |
||
1815 | 1059 |
stcPathOf:command |
120 | 1060 |
"return the path to an stc command, or nil if not found." |
101 | 1061 |
|
623 | 1062 |
|f d reqdSuffix cmd| |
1063 |
||
1064 |
"/ |
|
1065 |
"/ care for executable suffix |
|
1066 |
"/ |
|
1067 |
cmd := command. |
|
1068 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
1069 |
reqdSuffix := 'exe' |
|
1070 |
] ifFalse:[ |
|
1071 |
OperatingSystem isVMSlike ifTrue:[ |
|
1072 |
reqdSuffix := 'EXE' |
|
1073 |
]. |
|
1074 |
]. |
|
1075 |
reqdSuffix notNil ifTrue:[ |
|
658 | 1076 |
(f := cmd asFilename) suffix isEmpty ifTrue:[ |
1077 |
cmd := (f withSuffix:reqdSuffix) name |
|
623 | 1078 |
] |
1079 |
]. |
|
1080 |
"/ |
|
1081 |
"/ for our convenience, also check in current |
|
1082 |
"/ and parent directories; even if PATH does not |
|
1083 |
"/ include them ... |
|
1084 |
"/ |
|
658 | 1085 |
"/ look in current ... |
623 | 1086 |
d := Filename currentDirectory. |
1087 |
(f := d construct:cmd) isExecutable ifTrue:[ |
|
101 | 1088 |
^ f pathName |
1089 |
]. |
|
658 | 1090 |
"/ look in ../stc ... |
623 | 1091 |
d := d construct:'..'. |
1092 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
1093 |
^ f pathName |
|
1094 |
]. |
|
658 | 1095 |
"/ look in ../../stc ... |
623 | 1096 |
d := d construct:'..'. |
1097 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
1098 |
^ f pathName |
|
1099 |
]. |
|
1100 |
||
1101 |
"/ |
|
1102 |
"/ ok, stc must be installed in some directory along the PATH |
|
1103 |
"/ |
|
126 | 1104 |
^ OperatingSystem pathOfCommand:command |
97 | 1105 |
|
1106 |
" |
|
1815 | 1107 |
Compiler stcPathOf:'stc' |
120 | 1108 |
" |
1109 |
||
1110 |
"Created: 13.9.1995 / 14:37:16 / claus" |
|
54 | 1111 |
! ! |
1112 |
||
1417 | 1113 |
!ByteCodeCompiler methodsFor:'Compatibility-ST80'! |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1114 |
|
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1115 |
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
|
1116 |
"name alias for ST-80 compatibility" |
0 | 1117 |
|
1815 | 1118 |
^ self |
3281 | 1119 |
compile:textOrStream |
1120 |
forClass:aClass |
|
1121 |
inCategory:(self class defaultMethodCategory) |
|
1122 |
notifying:requestor |
|
1123 |
install:true |
|
1124 |
skipIfSame:false |
|
1125 |
silent:false |
|
1126 |
foldConstants:true |
|
1127 |
ifFail:exceptionBlock. |
|
2428
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1128 |
! |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1129 |
|
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1130 |
compile:textOrStream in:aClass notifying:requestor install:install ifFail:exceptionBlock |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1131 |
"name alias for ST-80 compatibility" |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1132 |
|
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1133 |
^ self |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1134 |
compile:textOrStream |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1135 |
forClass:aClass |
3281 | 1136 |
inCategory:(self class defaultMethodCategory) |
2428
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1137 |
notifying:requestor |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1138 |
install:install |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1139 |
skipIfSame:false |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1140 |
silent:false |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1141 |
foldConstants:true |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1142 |
ifFail:exceptionBlock. |
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1143 |
|
3e8b7caa22cb
added: #compile:in:notifying:install:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1144 |
"Created: / 15-10-2010 / 10:39:42 / cg" |
2474
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1145 |
! |
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1146 |
|
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1147 |
from:aStream class:aClass context:ctx notifying:aRequestor |
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1148 |
classToCompileFor := aClass. |
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1149 |
self source:aStream. |
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1150 |
|
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1151 |
self setClassToCompileFor:aClass. |
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1152 |
self notifying:aRequestor. |
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1153 |
|
c2fb6e429e46
added: #from:class:context:notifying:
Claus Gittinger <cg@exept.de>
parents:
2469
diff
changeset
|
1154 |
"Created: / 30-01-2011 / 03:38:00 / cg" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1155 |
! ! |
0 | 1156 |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1157 |
!ByteCodeCompiler methodsFor:'accessing'! |
0 | 1158 |
|
1159 |
code |
|
3 | 1160 |
"return the bytecode array - only valid after code-generation" |
0 | 1161 |
|
49 | 1162 |
^ codeBytes |
0 | 1163 |
! |
1164 |
||
141 | 1165 |
literalArray |
1166 |
"return the literal array - only valid after parsing" |
|
1167 |
||
1168 |
^ litArray |
|
1169 |
! |
|
1170 |
||
0 | 1171 |
maxStackDepth |
1172 |
"return the stack-need of the method - only valid after code-generation" |
|
1173 |
||
1174 |
^ maxStackDepth |
|
1094
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1175 |
! |
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1176 |
|
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1177 |
methodClass |
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1178 |
^ methodClass ? Method |
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1179 |
! |
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1180 |
|
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1181 |
methodClass:aClass |
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1182 |
methodClass := aClass |
0 | 1183 |
! ! |
1184 |
||
1185 |
!ByteCodeCompiler methodsFor:'code generation'! |
|
1186 |
||
1187 |
byteCodeFor:aSymbol |
|
1188 |
"given a symbolic instruction, return the corresponding bytecode. |
|
1189 |
as a side-effect, leave number of bytes pushed/popped by this instr. |
|
1190 |
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
|
1191 |
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
|
1192 |
information and extraLiteral is set if any hidden send is performed by it." |
0 | 1193 |
|
1194 |
"standard bytecodes" |
|
1195 |
||
1196 |
(aSymbol == #pushNil) ifTrue:[stackDelta := 1. ^ 10]. |
|
1197 |
(aSymbol == #pushTrue) ifTrue:[stackDelta := 1. ^ 11]. |
|
1198 |
(aSymbol == #pushFalse) ifTrue:[stackDelta := 1. ^ 12]. |
|
1199 |
(aSymbol == #pushLit) ifTrue:[stackDelta := 1. extra := #lit. ^ 14]. |
|
105 | 1200 |
(aSymbol == #pushLitS) ifTrue:[stackDelta := 1. extra := #index. ^ 14]. |
0 | 1201 |
(aSymbol == #pushSelf) ifTrue:[stackDelta := 1. ^ 15]. |
1202 |
(aSymbol == #pushNum) ifTrue:[stackDelta := 1. extra := #number. ^ 16]. |
|
1203 |
||
1204 |
(aSymbol == #pushMethodArg) ifTrue:[stackDelta := 1. extra := #index. ^ 30]. |
|
1205 |
(aSymbol == #pushMethodVar) ifTrue:[stackDelta := 1. extra := #index. ^ 31]. |
|
1206 |
(aSymbol == #pushBlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 32]. |
|
1207 |
(aSymbol == #pushBlockVar) ifTrue:[stackDelta := 1. extra := #index. ^ 33]. |
|
1208 |
(aSymbol == #pushInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 34]. |
|
1 | 1209 |
(aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42]. |
1210 |
(aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128]. |
|
0 | 1211 |
|
1212 |
(aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0]. |
|
1213 |
(aSymbol == #retSelf) ifTrue:[^5]. |
|
1214 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1215 |
(aSymbol == #==) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 45]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1216 |
(aSymbol == #~~) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 46]. |
0 | 1217 |
|
1218 |
(aSymbol == #falseJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 50]. |
|
1219 |
(aSymbol == #trueJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 51]. |
|
1220 |
(aSymbol == #nilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 52]. |
|
1221 |
(aSymbol == #notNilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 53]. |
|
1222 |
(aSymbol == #jump) ifTrue:[extra := #offset. ^ 54]. |
|
1 | 1223 |
(aSymbol == #makeBlock) ifTrue:[stackDelta := 1. extra := #offsetNvarNarg. ^ 55]. |
0 | 1224 |
(aSymbol == #zeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 56]. |
1225 |
(aSymbol == #notZeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 57]. |
|
1226 |
(aSymbol == #eqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 58]. |
|
1227 |
(aSymbol == #notEqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 59]. |
|
1228 |
||
54 | 1229 |
(aSymbol == #lineno) ifTrue:[lineno := true. ^ 8]. |
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
1230 |
(aSymbol == #lineno16) ifTrue:[lineno := true. ^ 9]. |
54 | 1231 |
|
106 | 1232 |
(aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19]. |
1233 |
(aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20]. |
|
117 | 1234 |
(aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13]. |
0 | 1235 |
|
1236 |
(aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18]. |
|
1237 |
(aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47]. |
|
1238 |
||
117 | 1239 |
(aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37]. |
1240 |
(aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38]. |
|
1241 |
(aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39]. |
|
0 | 1242 |
|
117 | 1243 |
(aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35]. |
356
bb3beb18de1f
6empty slots in GLOBL/CLASSVAR bytecodes removed
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
1244 |
(aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 36]. |
117 | 1245 |
|
1246 |
(aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40]. |
|
356
bb3beb18de1f
6empty slots in GLOBL/CLASSVAR bytecodes removed
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
1247 |
(aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 41]. |
247 | 1248 |
(aSymbol == #pushSpecialGlobal) ifTrue:[stackDelta := 1. extra := #index. ^ 200]. |
117 | 1249 |
|
1 | 1250 |
(aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129]. |
0 | 1251 |
|
117 | 1252 |
(aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176]. |
1253 |
(aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177]. |
|
105 | 1254 |
|
0 | 1255 |
"optimized bytecodes" |
1256 |
||
1822 | 1257 |
(aSymbol == #pushMethodVar1) ifTrue:[stackDelta := 1. ^80]. |
1258 |
(aSymbol == #pushMethodVar2) ifTrue:[stackDelta := 1. ^81]. |
|
1259 |
(aSymbol == #pushMethodVar3) ifTrue:[stackDelta := 1. ^82]. |
|
1260 |
(aSymbol == #pushMethodVar4) ifTrue:[stackDelta := 1. ^83]. |
|
1261 |
(aSymbol == #pushMethodVar5) ifTrue:[stackDelta := 1. ^84]. |
|
1262 |
(aSymbol == #pushMethodVar6) ifTrue:[stackDelta := 1. ^85]. |
|
1263 |
||
1264 |
(aSymbol == #pushMethodArg1) ifTrue:[stackDelta := 1. ^86]. |
|
1265 |
(aSymbol == #pushMethodArg2) ifTrue:[stackDelta := 1. ^87]. |
|
1266 |
(aSymbol == #pushMethodArg3) ifTrue:[stackDelta := 1. ^88]. |
|
1267 |
(aSymbol == #pushMethodArg4) ifTrue:[stackDelta := 1. ^89]. |
|
1268 |
||
0 | 1269 |
(aSymbol == #retNil) ifTrue:[^ 1]. |
1270 |
(aSymbol == #retTrue) ifTrue:[^ 2]. |
|
1271 |
(aSymbol == #retFalse) ifTrue:[^ 3]. |
|
1272 |
(aSymbol == #ret0) ifTrue:[^ 4]. |
|
1273 |
(aSymbol == #retNum) ifTrue:[extra := #number. ^ 127]. |
|
25 | 1274 |
(aSymbol == #homeRetTop) ifTrue:[^ 7]. |
0 | 1275 |
|
46 | 1276 |
(aSymbol == #pushNum16) ifTrue:[stackDelta := 1. extra := #number16. ^ 17]. |
0 | 1277 |
(aSymbol == #push0) ifTrue:[stackDelta := 1. ^120]. |
1278 |
(aSymbol == #push1) ifTrue:[stackDelta := 1. ^121]. |
|
3 | 1279 |
(aSymbol == #push2) ifTrue:[stackDelta := 1. ^139]. |
0 | 1280 |
(aSymbol == #pushMinus1) ifTrue:[stackDelta := 1. ^122]. |
1281 |
||
106 | 1282 |
(aSymbol == #send0) ifTrue:[lineno := true. extra := #index. ^21]. |
1283 |
(aSymbol == #send1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^22]. |
|
1284 |
(aSymbol == #send2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^23]. |
|
1285 |
(aSymbol == #send3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^24]. |
|
0 | 1286 |
|
106 | 1287 |
(aSymbol == #sendSelf0) ifTrue:[lineno := true. extra := #index. stackDelta := 1. ^180]. |
1288 |
(aSymbol == #sendSelf1) ifTrue:[lineno := true. extra := #index. ^181]. |
|
1289 |
(aSymbol == #sendSelf2) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^182]. |
|
1290 |
(aSymbol == #sendSelf3) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^183]. |
|
1291 |
(aSymbol == #sendSelfDrop0) ifTrue:[lineno := true. extra := #index. ^184]. |
|
1292 |
(aSymbol == #sendSelfDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^185]. |
|
1293 |
(aSymbol == #sendSelfDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^186]. |
|
1294 |
(aSymbol == #sendSelfDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^187]. |
|
0 | 1295 |
|
106 | 1296 |
(aSymbol == #sendDrop) ifTrue:[lineno := true. extra := #special. ^25]. |
1297 |
(aSymbol == #sendDrop0) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^26]. |
|
1298 |
(aSymbol == #sendDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^27]. |
|
1299 |
(aSymbol == #sendDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^28]. |
|
1300 |
(aSymbol == #sendDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -4. ^29]. |
|
0 | 1301 |
|
1302 |
(aSymbol == #pushInstVar1) ifTrue:[stackDelta := 1. ^90]. |
|
1303 |
(aSymbol == #pushInstVar2) ifTrue:[stackDelta := 1. ^91]. |
|
1304 |
(aSymbol == #pushInstVar3) ifTrue:[stackDelta := 1. ^92]. |
|
1305 |
(aSymbol == #pushInstVar4) ifTrue:[stackDelta := 1. ^93]. |
|
1306 |
(aSymbol == #pushInstVar5) ifTrue:[stackDelta := 1. ^94]. |
|
1307 |
(aSymbol == #pushInstVar6) ifTrue:[stackDelta := 1. ^95]. |
|
1308 |
(aSymbol == #pushInstVar7) ifTrue:[stackDelta := 1. ^96]. |
|
1309 |
(aSymbol == #pushInstVar8) ifTrue:[stackDelta := 1. ^97]. |
|
1310 |
(aSymbol == #pushInstVar9) ifTrue:[stackDelta := 1. ^98]. |
|
1311 |
(aSymbol == #pushInstVar10) ifTrue:[stackDelta := 1. ^99]. |
|
1312 |
||
1313 |
(aSymbol == #storeMethodVar1) ifTrue:[stackDelta := -1. ^100]. |
|
1314 |
(aSymbol == #storeMethodVar2) ifTrue:[stackDelta := -1. ^101]. |
|
1315 |
(aSymbol == #storeMethodVar3) ifTrue:[stackDelta := -1. ^102]. |
|
1316 |
(aSymbol == #storeMethodVar4) ifTrue:[stackDelta := -1. ^103]. |
|
1317 |
(aSymbol == #storeMethodVar5) ifTrue:[stackDelta := -1. ^104]. |
|
1318 |
(aSymbol == #storeMethodVar6) ifTrue:[stackDelta := -1. ^105]. |
|
1319 |
||
1320 |
(aSymbol == #storeInstVar1) ifTrue:[stackDelta := -1. ^110]. |
|
1321 |
(aSymbol == #storeInstVar2) ifTrue:[stackDelta := -1. ^111]. |
|
1322 |
(aSymbol == #storeInstVar3) ifTrue:[stackDelta := -1. ^112]. |
|
1323 |
(aSymbol == #storeInstVar4) ifTrue:[stackDelta := -1. ^113]. |
|
1324 |
(aSymbol == #storeInstVar5) ifTrue:[stackDelta := -1. ^114]. |
|
1325 |
(aSymbol == #storeInstVar6) ifTrue:[stackDelta := -1. ^115]. |
|
1326 |
(aSymbol == #storeInstVar7) ifTrue:[stackDelta := -1. ^116]. |
|
1327 |
(aSymbol == #storeInstVar8) ifTrue:[stackDelta := -1. ^117]. |
|
1328 |
(aSymbol == #storeInstVar9) ifTrue:[stackDelta := -1. ^118]. |
|
1329 |
(aSymbol == #storeInstVar10) ifTrue:[stackDelta := -1. ^119]. |
|
1330 |
||
103 | 1331 |
(aSymbol == #pushLit1) ifTrue:[stackDelta := 1. ^ 222]. |
1332 |
(aSymbol == #pushLit2) ifTrue:[stackDelta := 1. ^ 223]. |
|
1333 |
(aSymbol == #pushLit3) ifTrue:[stackDelta := 1. ^ 224]. |
|
1334 |
(aSymbol == #pushLit4) ifTrue:[stackDelta := 1. ^ 225]. |
|
1335 |
(aSymbol == #pushLit5) ifTrue:[stackDelta := 1. ^ 226]. |
|
1336 |
(aSymbol == #pushLit6) ifTrue:[stackDelta := 1. ^ 227]. |
|
1337 |
(aSymbol == #pushLit7) ifTrue:[stackDelta := 1. ^ 228]. |
|
1338 |
(aSymbol == #pushLit8) ifTrue:[stackDelta := 1. ^ 229]. |
|
1339 |
||
0 | 1340 |
(aSymbol == #retMethodVar1) ifTrue:[^160]. |
1341 |
(aSymbol == #retMethodVar2) ifTrue:[^161]. |
|
1342 |
(aSymbol == #retMethodVar3) ifTrue:[^162]. |
|
1343 |
(aSymbol == #retMethodVar4) ifTrue:[^163]. |
|
1344 |
(aSymbol == #retMethodVar5) ifTrue:[^164]. |
|
1345 |
(aSymbol == #retMethodVar6) ifTrue:[^165]. |
|
1346 |
||
1347 |
(aSymbol == #retInstVar1) ifTrue:[^166]. |
|
1348 |
(aSymbol == #retInstVar2) ifTrue:[^167]. |
|
1349 |
(aSymbol == #retInstVar3) ifTrue:[^168]. |
|
1350 |
(aSymbol == #retInstVar4) ifTrue:[^169]. |
|
1351 |
(aSymbol == #retInstVar5) ifTrue:[^170]. |
|
1352 |
(aSymbol == #retInstVar6) ifTrue:[^171]. |
|
1353 |
(aSymbol == #retInstVar7) ifTrue:[^172]. |
|
1354 |
(aSymbol == #retInstVar8) ifTrue:[^173]. |
|
1355 |
||
1356 |
(aSymbol == #retMethodArg1) ifTrue:[^174]. |
|
1357 |
(aSymbol == #retMethodArg2) ifTrue:[^175]. |
|
1358 |
||
1359 |
(aSymbol == #pushBlockArg1) ifTrue:[stackDelta := 1. ^140]. |
|
1360 |
(aSymbol == #pushBlockArg2) ifTrue:[stackDelta := 1. ^141]. |
|
1361 |
(aSymbol == #pushBlockArg3) ifTrue:[stackDelta := 1. ^142]. |
|
1362 |
(aSymbol == #pushBlockArg4) ifTrue:[stackDelta := 1. ^143]. |
|
1363 |
||
1 | 1364 |
(aSymbol == #pushOuter1BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 43]. |
1365 |
(aSymbol == #pushOuter2BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 44]. |
|
0 | 1366 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1367 |
(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
|
1368 |
(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
|
1369 |
(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
|
1370 |
(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
|
1371 |
(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
|
1372 |
(aSymbol == #class) ifTrue:[extraLiteral := aSymbol. ^134]. |
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1373 |
"/ (aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. ^106]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1374 |
"/ (aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. ^107]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1375 |
"/ (aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. ^108]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1376 |
"/ (aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. ^109]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1377 |
"/ (aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. ^154]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1378 |
"/ (aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. ^155]. |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1379 |
(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
|
1380 |
(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
|
1381 |
(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
|
1382 |
(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
|
1383 |
(aSymbol == #plus1) ifTrue:[lineno := true. extraLiteral := #+. ^123]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1384 |
(aSymbol == #minus1) ifTrue:[lineno := true. extraLiteral := #-. ^124]. |
0 | 1385 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1386 |
(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
|
1387 |
(aSymbol == #decMethodVar) ifTrue:[lineno := true. extraLiteral := #-. extra := #index. ^126]. |
0 | 1388 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1389 |
(aSymbol == #eq0) ifTrue:[extraLiteral := #==. ^48]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1390 |
(aSymbol == #ne0) ifTrue:[extraLiteral := #~~. ^49]. |
0 | 1391 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1392 |
(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
|
1393 |
(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
|
1394 |
(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
|
1395 |
(aSymbol == #<=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 148]. |
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1396 |
"/ (aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 149]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1397 |
"/ (aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 150]. |
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1398 |
(aSymbol == #value) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 151]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1399 |
(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
|
1400 |
(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
|
1401 |
(aSymbol == #size) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 153]. |
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1402 |
"/ (aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 158]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1403 |
"/ (aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 159]. |
0 | 1404 |
(aSymbol == #mk0Block) ifTrue:[^ 156]. |
1405 |
(aSymbol == #mkNilBlock) ifTrue:[^ 157]. |
|
1406 |
||
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1407 |
(aSymbol == #gt0) ifTrue:[lineno := true. extraLiteral := #>. ^ 212]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1408 |
(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
|
1409 |
(aSymbol == #basicNew) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 211]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1410 |
(aSymbol == #new) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 213]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1411 |
(aSymbol == #basicNew:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 214]. |
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1412 |
(aSymbol == #new:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 215]. |
103 | 1413 |
|
217 | 1414 |
(aSymbol == #pushBlockVar1) ifTrue:[stackDelta := 1. ^ 232]. |
1415 |
(aSymbol == #pushBlockVar2) ifTrue:[stackDelta := 1. ^ 233]. |
|
1416 |
(aSymbol == #pushBlockVar3) ifTrue:[stackDelta := 1. ^ 234]. |
|
1417 |
(aSymbol == #storeBlockVar1) ifTrue:[stackDelta := -1. ^ 235]. |
|
1418 |
(aSymbol == #storeBlockVar2) ifTrue:[stackDelta := -1. ^ 236]. |
|
1419 |
(aSymbol == #storeBlockVar3) ifTrue:[stackDelta := -1. ^ 237]. |
|
1420 |
||
0 | 1421 |
(aSymbol == #falseJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 190]. |
1422 |
(aSymbol == #trueJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 191]. |
|
1423 |
(aSymbol == #nilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 192]. |
|
1424 |
(aSymbol == #notNilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 193]. |
|
1425 |
(aSymbol == #jumpabs) ifTrue:[extra := #absoffset. ^ 194]. |
|
1 | 1426 |
(aSymbol == #makeBlockabs) ifTrue:[stackDelta := 1. extra := #absoffsetNvarNarg. ^ 195]. |
0 | 1427 |
(aSymbol == #zeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 196]. |
1428 |
(aSymbol == #notZeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 197]. |
|
1 | 1429 |
(aSymbol == #eqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 198]. |
1430 |
(aSymbol == #notEqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 199]. |
|
0 | 1431 |
|
1432 |
(aSymbol == #pushThisContext) ifTrue:[stackDelta := 1. ^ 144]. |
|
1433 |
||
1466 | 1434 |
(aSymbol == #isNil) ifTrue:["extraLiteral := aSymbol. -- could be synthetic" ^ 188]. |
1435 |
(aSymbol == #notNil) ifTrue:["extraLiteral := aSymbol. -- could be synthetic" ^ 189]. |
|
425
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1436 |
(aSymbol == #not) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 179]. |
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1437 |
(aSymbol == #&) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 216]. |
b046a32edb08
remember &, | and not in literal array
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
1438 |
(aSymbol == #|) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 217]. |
76 | 1439 |
|
117 | 1440 |
(aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
1441 |
(aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218]. |
|
1442 |
(aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219]. |
|
1443 |
(aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219]. |
|
1444 |
(aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201]. |
|
1445 |
||
1446 |
(aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205]. |
|
1447 |
(aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207]. |
|
1448 |
(aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204]. |
|
1449 |
(aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206]. |
|
106 | 1450 |
|
246
abf09d4821fe
new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1451 |
(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
|
1452 |
(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
|
1453 |
(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
|
1454 |
(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
|
1455 |
|
400
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1456 |
(aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1457 |
(aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1458 |
(aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1459 |
(aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1460 |
(aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1461 |
(aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1462 |
(aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1463 |
(aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1464 |
(aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1465 |
(aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231]. |
e5cfc008be47
bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents:
383
diff
changeset
|
1466 |
|
217 | 1467 |
(aSymbol == #blockRef) ifTrue:[stackDelta := 0. ^ 238]. |
549 | 1468 |
(aSymbol == #over) ifTrue:[stackDelta := 1. ^ 6]. |
1799 | 1469 |
|
1470 |
(aSymbol == #sendVL) ifTrue:[lineno := true. extra := #specialVL. extraOP := 0. ^ 204]. |
|
1471 |
(aSymbol == #superSendVL) ifTrue:[lineno := true. extra := #specialVL. extraOP := 1. ^ 204]. |
|
1792 | 1472 |
(aSymbol == #pushLitVL) ifTrue:[stackDelta := 1. extra := #unsigned32. extraOP := 2. ^ 204]. |
1799 | 1473 |
(aSymbol == #pushGlobalVL) ifTrue:[stackDelta := 1. extra := #speciallitVL. extraOP := 3. ^ 204]. |
1474 |
(aSymbol == #storeGlobalVL) ifTrue:[stackDelta := -1. extra := #speciallitVL. extraOP := 4. ^ 204]. |
|
217 | 1475 |
|
2756
4b1b41756f13
comment/format in: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
1476 |
"/ the next 2 are to be obsoleted soon (renamed as MethodLocal) |
1822 | 1477 |
(aSymbol == #pushLocal) ifTrue:[ stackDelta := 1. extra := #index. ^ 239]. |
1478 |
(aSymbol == #storeLocal) ifTrue:[ stackDelta := -1. extra := #index. ^ 240]. |
|
1479 |
||
2752 | 1480 |
(aSymbol == #pushMethodLocal) ifTrue:[ stackDelta := 1. extra := #index. ^ 239]. |
1481 |
(aSymbol == #storeMethodLocal) ifTrue:[ stackDelta := -1. extra := #index. ^ 240]. |
|
1482 |
(aSymbol == #storeBlockLocal) ifTrue:[ stackDelta := -1. extra := #index. ^ 241]. |
|
1483 |
(aSymbol == #storeOuterBlockLocal) ifTrue:[ stackDelta := -1. extra := #indexLevel. ^ 242]. |
|
3169 | 1484 |
(aSymbol == #swap) ifTrue:[stackDelta := 0. ^ 243]. |
2752 | 1485 |
|
3071 | 1486 |
self codeGeneratorError:'invalid code symbol'. |
117 | 1487 |
|
1822 | 1488 |
"Modified: / 03-09-1995 / 12:58:47 / claus" |
2752 | 1489 |
"Modified: / 25-10-2011 / 21:56:43 / cg" |
2756
4b1b41756f13
comment/format in: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
1490 |
"Modified (comment): / 31-10-2011 / 11:34:37 / cg" |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1491 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
1492 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1493 |
checkForCommonCode:symbolicCodeArray |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1494 |
"hook to return the code for common code sequences. |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1495 |
This reduces the in-memory number of byteArrays somewhat. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1496 |
|
1095 | 1497 |
Not yet fully implemented - just an idea ... there is certainly more to do here |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1498 |
(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
|
1499 |
automatically in the background - or upon request ?)" |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1500 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1501 |
|sz insn1| |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1502 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1503 |
(sz := symbolicCodeArray size) == 2 ifTrue:[ |
1815 | 1504 |
"/ |
1505 |
"/ a very common sequence: return the first literal |
|
1506 |
"/ |
|
1507 |
(insn1 := symbolicCodeArray at:1) == #pushLit1 ifTrue:[ |
|
1508 |
(symbolicCodeArray at:2) == #retTop ifTrue:[ |
|
1509 |
^ #[222 0] |
|
1510 |
] |
|
1511 |
] |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1512 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1513 |
sz == 1 ifTrue:[ |
1815 | 1514 |
"/ |
1515 |
"/ other common sequences: return the receiver, nil, true or false |
|
1516 |
"/ |
|
1517 |
(insn1 := symbolicCodeArray at:1) == #retSelf ifTrue:[ |
|
1518 |
^ #[5] |
|
1519 |
]. |
|
1520 |
insn1 == #retNil ifTrue:[ |
|
1521 |
^ #[1] |
|
1522 |
]. |
|
1523 |
insn1 == #retTrue ifTrue:[ |
|
1524 |
^ #[2] |
|
1525 |
]. |
|
1526 |
insn1 == #retFalse ifTrue:[ |
|
1527 |
^ #[3] |
|
1528 |
]. |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1529 |
]. |
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1530 |
^ nil |
199
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1531 |
! |
1b3b350a3f59
moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents:
197
diff
changeset
|
1532 |
|
141 | 1533 |
checkForPrimitiveCode:nr |
1534 |
"return the code for an ST-80 primitive method. |
|
1535 |
Since many primitives available on ST-80 should also be available |
|
1536 |
somewhere in ST/X, this may work for many primitive numbers. |
|
1537 |
However, more information is needed and more things to be added below. |
|
1538 |
||
1539 |
This was added to allow emulation of (some) ST-80 |
|
1540 |
primitives (to fileIn RemoteInvocation & Monitor41 packages)" |
|
1541 |
||
1542 |
|cls sel| |
|
1543 |
||
1544 |
(nr == 75) ifTrue:[ cls := Object. sel := #identityHash ]. |
|
1545 |
(nr == 110) ifTrue:[ cls := Object. sel := #== ]. |
|
1546 |
(nr == 111) ifTrue:[ cls := Object. sel := #class ]. |
|
1228 | 1547 |
|
141 | 1548 |
" |
1228 | 1549 |
should add more here, to be able to fileIn ST-80 and Squeak methods |
141 | 1550 |
containing primitive calls (who gives me the numbers ... ?) |
512 | 1551 |
mhmh - got some ..." |
1228 | 1552 |
|
1553 |
"/ ST80 and Squeak common: |
|
1554 |
"/ 18 Number @ |
|
1555 |
"/ 41 Float + |
|
1556 |
"/ 42 Float - |
|
1557 |
"/ 49 Float * |
|
1558 |
"/ 50 Float / |
|
1559 |
"/ 52 Float fractionPart |
|
1560 |
"/ 54 Float timesTwoPower: |
|
1561 |
||
907 | 1562 |
"/ ST80: |
1563 |
"/ |
|
1228 | 1564 |
"/ 18 Number @ |
1565 |
"/ 21 LargePositiveInteger + |
|
1566 |
"/ 22 LargePositiveInteger - |
|
1567 |
"/ 29 LargePositiveInteger * |
|
1568 |
"/ 30 LargePositiveInteger / |
|
1815 | 1569 |
"/ 31 LargePositiveInteger \\ |
1570 |
"/ 32 LargePositiveInteger // |
|
1228 | 1571 |
"/ 34 LargePositiveInteger bitAnd: |
1572 |
"/ 35 LargePositiveInteger bitOr: |
|
1573 |
"/ 36 LargePositiveInteger bitXor: |
|
1574 |
"/ 37 LargePositiveInteger bitShift: |
|
1575 |
"/ 40 SmallInteger asFloat |
|
1576 |
"/ 41 Float + |
|
1577 |
"/ 42 Float - |
|
1578 |
"/ 49 Float * |
|
1815 | 1579 |
"/ 50 Float / |
1228 | 1580 |
"/ 52 Float fractionPart |
1581 |
"/ 54 Float timesTwoPower: |
|
1582 |
"/ 70 Behavior basicNew |
|
1583 |
"/ 71 Behavior basicNew: |
|
1584 |
"/ 89 Behavior flushVMmethodCache |
|
1585 |
"/ 91 InputState primCursorLocPut: |
|
512 | 1586 |
"/ 105 ByteArray replaceElementsFrom:to:withByteArray:startingAt: |
1587 |
"/ 223 ByteString = |
|
1588 |
"/ 306 ObjectMemory class sizesAtStartup |
|
1589 |
"/ 307 ObjectMemory class defaultSizesAtStartup |
|
1590 |
"/ 309 ObjectMemory class defaultThresholds |
|
1591 |
"/ 326 ObjectMemory class getMemoryUsageAndZeroFragmentationStatisticsIf: |
|
1592 |
"/ 395 ExternalInterface ??? |
|
1593 |
"/ 400 FormBitmap class newWidth:height: |
|
1594 |
"/ 414 TwoByteString replaceElementsFrom:to:withTwoByteString:startingAt: |
|
1595 |
"/ 415 TwoByteString = |
|
1596 |
"/ 417 String trueCompare: |
|
1597 |
"/ 418 ByteString nextIndexOf:from:to: |
|
1598 |
"/ 419 ByteString prevIndexOf:from:to: |
|
1599 |
"/ 422 WeakArray indexOf:replaceWith:startingAt:stoppingAt: |
|
1600 |
"/ 522 Behavior flushVMmethodCacheEntriesFor: |
|
1601 |
"/ 524 Context nFromVPC: |
|
1602 |
"/ 525 Context vFromNPC: |
|
1603 |
"/ 532 Object shallowCopy |
|
1604 |
"/ 536 Behavior atomicAllInstances |
|
1605 |
"/ 537 Object allOwners |
|
1606 |
"/ 538 ObjectMemory class allObjects |
|
1607 |
"/ 546 UninterpretedBytes longAt: |
|
1608 |
"/ 548 UninterpretedBytes floatAt: |
|
1609 |
"/ 550 UninterpretedBytes longFloatAt: |
|
1610 |
"/ 544 UninterpretedBytes unsignedLongAt: |
|
1611 |
"/ 559 ByteArray replaceBytesFrom:to:with:startingAt: |
|
1612 |
"/ 560 Double class fromNumber: |
|
1613 |
"/ 561 Double + |
|
1614 |
"/ 562 Double - |
|
1615 |
"/ 569 Double * |
|
1616 |
"/ 570 Double / |
|
1617 |
"/ 572 Double fractionPart |
|
1618 |
"/ 574 Double timesTwoPower: |
|
1619 |
"/ 576 Double sin |
|
1620 |
"/ 577 Double cos |
|
1621 |
"/ 578 Double tan |
|
1622 |
"/ 579 Double arcSin |
|
1623 |
"/ 580 Double arcCos |
|
1624 |
"/ 581 Double arcTan |
|
1625 |
"/ 582 Double sqrt |
|
1626 |
"/ 583 Double ln |
|
1627 |
"/ 584 Double exp |
|
1628 |
"/ 585 Double raisedTo: |
|
1629 |
"/ 587 Double floorLog10 |
|
1630 |
"/ 588 Double asFloat |
|
1631 |
"/ 591 Float cos |
|
1632 |
"/ 592 Float arcSin |
|
1633 |
"/ 593 Float arcCos |
|
1634 |
"/ 600 Float sin |
|
1635 |
"/ 601 Float tan |
|
1636 |
"/ 602 Float arcTan |
|
1637 |
"/ 603 Float sqrt |
|
1638 |
"/ 604 Float ln |
|
1639 |
"/ 605 Float exp |
|
1640 |
"/ 606 Float raisedTo: |
|
1641 |
"/ 609 Float floorLog10 |
|
1642 |
"/ 610 Filename getDatesErrInto: |
|
1643 |
"/ 614 DosFilename class getVolumes |
|
1644 |
"/ 615 UnixFilename primSetProtection:errInto: |
|
1645 |
"/ 616 UnixFilename class primSetCreationMask:errInto: |
|
1646 |
"/ 617 UnixFilename primGetProtectionErrInto: |
|
1647 |
"/ 620 Filename listDirectoryErrInto: |
|
1648 |
"/ 621 Filename deleteErrInto: |
|
1649 |
"/ 622 Filename isDirectoryErrInto: |
|
1650 |
"/ 623 Filename renameTo:errInto: |
|
1651 |
"/ 624 Filename makeDirectoryErrInto: |
|
1652 |
"/ 625 Filename class defaultDirectoryErrInto: |
|
1653 |
"/ 626 Filename fileSizeErrInto: |
|
1654 |
"/ 627 Filename isWritableErrInto: |
|
1655 |
"/ 628 Filename setWritable:errInto: |
|
1656 |
"/ 629 Filename existsErrInto: |
|
1657 |
"/ 630 SocketAccessor setOptionsLevel:name:value: |
|
1658 |
"/ 631 SocketAccessor getOptionsLevel:name: |
|
1659 |
"/ 632 SocketAccessor primGetName |
|
1660 |
"/ 633 SocketAccessor primGetPeer |
|
1661 |
"/ 634 SocketAccessor atMark |
|
1662 |
"/ 637 UnixTtyAccessor primGetOptions |
|
1663 |
"/ 638 UnixTtyAccessor setOptions: |
|
1664 |
"/ 639 UnixRealTtyAccessor modemBits:mask:sendBreak: |
|
1665 |
"/ 640 IPSocketAddress class primHostAddressByName: |
|
1666 |
"/ 641 IPSocketAddress class netAddressByName: |
|
1667 |
"/ 642 IPSocketAddress class protocolNumberByName: |
|
1668 |
"/ 643 IPSocketAddress class servicePortByName: |
|
1669 |
"/ 645 IPSocketAddress class primHostNameByAddress: |
|
1670 |
"/ 646 IPSocketAddress class netNameByAddress: |
|
1671 |
"/ 647 IPSocketAddress class protocolNameByNumber: |
|
1672 |
"/ 648 IPSocketAddress class serviceNameByPort: |
|
1673 |
"/ 649 SocketAccessor class getHostname |
|
1674 |
"/ 650 Filename primOpenFileNamed:direction:creation:errorInto: |
|
1675 |
"/ 651 IOAccessor primClose |
|
1676 |
"/ 652 UnixPipeAccessor class primPipeErrorInto: |
|
1677 |
"/ 653 UnixPseudoTtyAccessor class primPtyErrorInto: |
|
1678 |
"/ 654 SocketAccessor class primPairErrorInto: |
|
1679 |
"/ 655 UnixRealTtyAccessor class primOpen:errInto: |
|
1680 |
"/ 660 IOAccessor primReadInto:startingAt:for: |
|
1681 |
"/ 661 IOAccessor primWriteFrom:startingAt:for: |
|
1682 |
"/ 662 IOAccessor primSeekTo: |
|
1683 |
"/ 664 IOAccessor truncateTo: |
|
1684 |
"/ 665 DosDiskFileAccessor commit |
|
1685 |
"/ 666 IOAccessor primGetSize |
|
1686 |
"/ 667 MacDiskFileAccessor lock:for: |
|
1687 |
"/ 669 UnixIOAccessor bytesForRead |
|
1688 |
"/ 670 SocketAccessor class primFamily:type:protocol:errInto: |
|
1689 |
"/ 671 SocketAccessor primAccept |
|
1690 |
"/ 672 SocketAccessor bindTo: |
|
1691 |
"/ 673 SocketAccessor listenFor: |
|
1692 |
"/ 674 SocketAccessor primConnectTo: |
|
1693 |
"/ 675 SocketAccessor primReceiveFrom:buffer:start:for:flags: |
|
1694 |
"/ 676 SocketAccessor sendTo:buffer:start:for:flags: |
|
1695 |
"/ 677 SocketAccessor shutdown: |
|
1696 |
"/ 681 UnixProcess class primFork:arguments:environment:descriptors:errorTo: |
|
1697 |
"/ 682 UnixProcess class reapOne |
|
1698 |
"/ 683 UnixProcess kill: |
|
1699 |
"/ 690 CEnvironment class primEnvironment |
|
1700 |
"/ 697 OSErrorHolder class errorDescriptionFor: |
|
1701 |
"/ 697 ErrorHolder class errorDescriptionFor: |
|
1702 |
"/ 698 SocketAccessor class primInit: |
|
1703 |
"/ 700 ParagraphEditor class getExternalSelectionOrNil: |
|
1704 |
"/ 701 ParagraphEditor class putExternalSelection:with: |
|
1705 |
"/ 705 Screen ringBell |
|
1706 |
"/ 706 Cursor class primOpenImage:mask:hotSpotX:hotSpotY:background:foreground: |
|
1707 |
"/ 707 Cursor primBeCursor |
|
1708 |
"/ 708 Cursor primFreeCursor |
|
1709 |
"/ 772 SoundManager enumerateSoundsFrom: |
|
1710 |
"/ 773 SoundManager playSoundFrom:sound: |
|
1711 |
"/ 774 SoundManager simpleBeep: |
|
1712 |
"/ 775 Pixmap primFromClipboard |
|
1713 |
"/ 776 Pixmap toClipboard |
|
1714 |
"/ 808 Context findNextMarkedUpTo: |
|
1715 |
"/ 809 Context terminateTo: |
|
1716 |
"/ 710 DosTtyAccessor class primOpen:errInto: |
|
1717 |
"/ 711 DosTtyAccessor primClose |
|
1718 |
"/ 712 DosTtyAccessor primReadInto:startingAt:for: |
|
1719 |
"/ 713 DosTtyAccessor primWriteFrom:startingAt:for: |
|
1720 |
"/ 714 DosTtyAccessor primGetOptions |
|
1721 |
"/ 715 DosTtyAccessor primSetOptions: |
|
1722 |
"/ 716 DosTtyAccessor setSem:forWrite: |
|
1723 |
"/ 717 DosTtyAccessor modemBits:mask:sendBreak: |
|
1724 |
"/ 750 MacFilename class getVolumes |
|
1725 |
"/ 752 MacFilename primSetCreator:type:errInto: |
|
1726 |
"/ 754 MacIOAccessor class getAccessories |
|
1727 |
"/ 755 MacIOAccessor class runAccessory: |
|
1728 |
"/ 756 MacOSFilename class getFileTypes:errInto: |
|
1729 |
"/ 757 MacOSFilename putFileWithPrompt:errInto: |
|
1730 |
"/ 758 MacOSFilename getFileInfoErrInto: |
|
1731 |
"/ 759 MacOSFilename stringFromVRefErrInto: |
|
1732 |
"/ 761 MacOSFilename class getStartupFilesErrInto: |
|
1733 |
"/ 770 DosFilename printPSFileErrInto: |
|
1734 |
"/ 771 DosFilename printTextFileErrInto: |
|
1735 |
"/ 780 MacTtyAccessor class primOpen:errInto: |
|
1736 |
"/ 781 MacTtyAccessor primClose |
|
1737 |
"/ 782 MacTtyAccessor primReadInto:startingAt:for: |
|
1738 |
"/ 783 MacTtyAccessor primWriteFrom:startingAt:for: |
|
1739 |
"/ 786 MacTtyAccessor primGetOptions |
|
1740 |
"/ 787 MacTtyAccessor setOptions: |
|
1741 |
"/ 788 MacTtyAccessor primBreak: |
|
1742 |
"/ 790 MacTtyAccessor primGetStatus |
|
1743 |
"/ 792 MacTtyAccessor setSem:forWrite: |
|
1744 |
"/ 793 MacTtyAccessor primAssertDTR: |
|
1745 |
"/ 794 MacTtyAccessor primGetSize |
|
1746 |
"/ 933 ByteArray copyBitsClippedStride:... |
|
1747 |
"/ 934 ByteArray tileBits32By32Stride:... |
|
1748 |
"/ 935 Screen dragShape:... |
|
1749 |
"/ 936 Screen resizeRectangle... |
|
1750 |
"/ 937 Screen displayShape:... |
|
1751 |
"/ 938 Window resizeFromUserWithMinimum:maximum: |
|
1752 |
"/ 940 Window primClose |
|
1753 |
"/ 942 Window getDimensions |
|
1754 |
"/ 943 Window moveTo:resize: |
|
1755 |
"/ 944 Window primMap |
|
1756 |
"/ 945 Window class primNewAt:extent:min:max:windowType: |
|
1757 |
"/ 946 Screen flush |
|
1758 |
"/ 947 Screen getScreenDimensions |
|
1759 |
"/ 948 Window unmap |
|
1760 |
"/ 950 Screen sync |
|
1761 |
"/ 951 Window setIconMask: |
|
1762 |
"/ 952 Window label:iconLabel: |
|
1763 |
"/ 953 Window raise |
|
1764 |
"/ 954 Window lower |
|
1765 |
"/ 955 Screen queryStackingOrder |
|
1766 |
"/ 956 TextMeasurer primScanCharactersFrom:... |
|
1767 |
"/ 957 GraphicsContext displayMappedString:from:to:at:withMap: |
|
1768 |
"/ 959 Window setBackgroundPixel: |
|
1769 |
"/ 960 Screen class primOpen: |
|
1770 |
"/ 965 UnmappableSurface contentsOfAreaOriginX:y:width:height: |
|
1771 |
"/ 966 Window contentsOfAreaOriginX:y:width:height: |
|
1772 |
"/ 967 Screen contentsOfAreaOriginX:y:width:height: |
|
1773 |
"/ 970 Mask class primExtent:depth: |
|
1774 |
"/ 971 Mask privateClose |
|
1775 |
"/ 976 GraphicsContext displayCharacterOfIndex:at: |
|
1776 |
"/ 978 DeviceFont class listFonts |
|
1777 |
"/ 979 DeviceFont primLoadFont |
|
1778 |
"/ 980 DeviceFont primUnLoadFont |
|
1779 |
"/ 985 GraphicsContext displayLineFrom:to: |
|
1780 |
"/ 986 GraphicsContext displayPolyline:at: |
|
1781 |
"/ 987 GraphicsContext displayPolygon:at: |
|
1782 |
"/ 988 GraphicsContext primDisplayRectangleOrigin:extent: |
|
1783 |
"/ 989 GraphicsContext primDisplayRectangularBorderOrigin:extent: |
|
1784 |
"/ 990 GraphicsContext primDisplayArcBBoxOrigin:extent:startAngle:sweepAngle: |
|
1785 |
"/ 991 GraphicsContext primDisplayWedgeBBoxOrigin:extent:startAngle:sweepAngle: |
|
1786 |
"/ 992 GraphicsContext displayMask:at:" |
|
1787 |
"/ 993 GraphicsContext displayUninterpretedImageBits:at: |
|
1788 |
"/ 994 GraphicsContext primCopyRectangularAreaExtent:from:sourceOffset:destinationOffset: |
|
1789 |
"/ 995 GraphicsContext primCopyMaskedArea:from:sourceOffset:destinationOffset: |
|
1790 |
"/ 996 Screen deviceColormap |
|
1791 |
"/ 998 GraphicsContext displayUninterpretedMonoImageBits:foreground:background:at: |
|
1792 |
||
907 | 1793 |
"/ Squeak: |
1794 |
"/ |
|
1795 |
"/ 1 + |
|
1796 |
"/ 2 - |
|
1797 |
"/ 3 < |
|
1798 |
"/ 4 > |
|
1799 |
"/ 5 <= |
|
1800 |
"/ 6 >= |
|
1801 |
"/ 7 = |
|
1802 |
"/ 8 ~= |
|
1803 |
"/ 9 * |
|
1804 |
"/ 10 / |
|
1805 |
"/ 11 mod: |
|
1806 |
"/ 12 div: |
|
1807 |
"/ 13 quo: |
|
1808 |
"/ 14 bitAnd: |
|
1809 |
"/ 15 bitOr: |
|
1810 |
"/ 16 bitXor: |
|
1811 |
"/ 17 bitShift: |
|
1812 |
"/ 18 @ |
|
1813 |
"/ 19 |
|
1814 |
"/ ... |
|
1815 |
"/ 39 fail - reserved/unimplemented |
|
1816 |
"/ 40 asFloat |
|
1817 |
"/ 41 Float + |
|
1818 |
"/ 42 Float - |
|
1819 |
"/ 43 Float < |
|
1820 |
"/ 44 Float > |
|
1821 |
"/ 45 Float <= |
|
1822 |
"/ 46 Float >= |
|
1823 |
"/ 47 Float = |
|
1824 |
"/ 48 Float ~= |
|
1825 |
"/ 49 Float * |
|
1826 |
"/ 50 Float / |
|
1827 |
"/ 51 Float truncated |
|
1828 |
"/ 52 Float fractionalPart |
|
1829 |
"/ 53 Float exponent |
|
1830 |
"/ 54 Float timeTwoPower |
|
1831 |
"/ 55 Float sqrt |
|
1832 |
"/ 56 Float sine |
|
1833 |
"/ 57 Float arcTan |
|
1834 |
"/ 58 Float logN |
|
1835 |
"/ 59 Float exp |
|
1836 |
"/ 60 at: |
|
1837 |
"/ 61 at:put: |
|
1838 |
"/ 62 size |
|
1839 |
"/ 63 stringAt: |
|
1840 |
"/ 64 stringAt:put: |
|
1841 |
"/ 65 next |
|
1842 |
"/ 66 nextPut: |
|
1843 |
"/ 67 atEnd |
|
1844 |
"/ 68 objectAt: |
|
1845 |
"/ 69 objectAt:put: |
|
1846 |
"/ 70 new |
|
1847 |
"/ 71 new: |
|
1848 |
"/ 72 becomeOneWay |
|
1849 |
"/ 73 instVarAt: |
|
1850 |
"/ 74 instVarAtPut: |
|
1851 |
"/ 75 asOop |
|
1852 |
"/ 76 storeStackP |
|
1853 |
"/ 77 someInstance |
|
1854 |
"/ 78 nextInstance |
|
1855 |
"/ 79 newMethod |
|
1856 |
"/ 80 blockCopy |
|
1857 |
"/ 81 value |
|
1858 |
"/ 82 valueWithArgs |
|
1859 |
"/ 83 perform |
|
1860 |
"/ 84 performWithArgs |
|
1861 |
"/ 85 signal |
|
1862 |
"/ 86 wait |
|
1863 |
"/ 87 resume |
|
1864 |
"/ 88 suspend |
|
1865 |
"/ 89 flushCache |
|
1866 |
"/ 90 mousePoint |
|
1867 |
"/ 91 fail/unimplemented/reserved |
|
1868 |
"/ 92 fail/unimplemented/reserved |
|
1869 |
"/ 93 inputSemaphore |
|
1870 |
"/ 94 fail/unimplemented/reserved |
|
1871 |
"/ 95 inputWord |
|
1872 |
"/ 96 copyBits |
|
1873 |
"/ 97 snapShot |
|
1874 |
"/ 98 fail/unimplemented/reserved |
|
1875 |
"/ 99 fail/unimplemented/reserved |
|
1876 |
"/ 100 fail/unimplemented/reserved |
|
1877 |
"/ 101 beCursor |
|
1878 |
"/ 102 beDisplay |
|
1879 |
"/ 103 scanCharacters |
|
1880 |
"/ 104 drawLoop |
|
1881 |
"/ 105 stringReplace |
|
1882 |
"/ 106 screenSize |
|
1883 |
"/ 107 mouseButtons |
|
1884 |
"/ 108 kbdNext |
|
1885 |
"/ 109 kbdPeek |
|
1886 |
"/ 110 equivalent |
|
1887 |
"/ 111 class |
|
1888 |
"/ 112 bytesLeft |
|
1889 |
"/ 113 quit |
|
1890 |
"/ 114 exitToDebugger |
|
1891 |
"/ 115 fail/unimplemented/reserved |
|
1892 |
"/ 116 flushCacheByMethod |
|
1893 |
"/ 117 externalCall |
|
1894 |
"/ 118 doPrimitiveWithArg |
|
1895 |
"/ 119 flushCacheSelective |
|
1896 |
"/ 120 fail/unimplemented/reserved |
|
1897 |
"/ 121 imageName |
|
1898 |
"/ 122 noop |
|
1899 |
"/ 123 fail/unimplemented/reserved |
|
1900 |
"/ 124 lowSpaceSemaphore |
|
1901 |
"/ 125 signalAtBytesLeft |
|
1902 |
"/ 126 deferDisplayUpdate |
|
1903 |
"/ 127 showDisplayRect |
|
1904 |
"/ 128 arrayBecome |
|
1905 |
"/ 129 specialObjectsOop |
|
1906 |
"/ 130 fullGC |
|
1907 |
"/ 131 incrementalGC |
|
1908 |
"/ 132 objectPointsTo |
|
1909 |
"/ 133 setInterruptKey |
|
1910 |
"/ 134 interruptSemaphore |
|
1911 |
"/ 135 millisecondClock |
|
1912 |
"/ 136 signalAtMilliseconds |
|
1913 |
"/ 137 secondsClock |
|
1914 |
"/ 138 someObject |
|
1915 |
"/ 139 nextObject |
|
1916 |
"/ 140 beep |
|
1917 |
"/ 141 clipboardText |
|
1918 |
"/ 142 vmPath |
|
1919 |
"/ 143 shortAt |
|
1920 |
"/ 144 shortAtPut |
|
1921 |
"/ 145 constantFill |
|
1922 |
"/ 146 readJoystick |
|
1923 |
"/ 147 warpBits |
|
1924 |
"/ 148 clone |
|
1925 |
"/ 149 getAttribute |
|
1926 |
"/ 150 fileAtEnd |
|
1927 |
"/ 151 fileClose |
|
1928 |
"/ 152 fileGetPosition |
|
1929 |
"/ 153 fileOpen |
|
1930 |
"/ 154 fileRead |
|
1931 |
"/ 155 fileSetPosition |
|
1932 |
"/ 156 fileDelete |
|
1933 |
"/ 157 fileSize |
|
1934 |
"/ 158 fileWrite |
|
1935 |
"/ 159 fileRename |
|
1936 |
"/ 160 directoryCreate |
|
1937 |
"/ 161 directoryDelimiter |
|
1938 |
"/ 162 directoryLookup |
|
1939 |
"/ 163 fail |
|
1940 |
"/ 164 fail |
|
1941 |
"/ 165 fail |
|
1942 |
"/ 166 fail |
|
1943 |
"/ 167 fail |
|
1944 |
"/ 168 fail |
|
1945 |
"/ 169 directorySetMacType |
|
1946 |
"/ 170 soundStart |
|
1947 |
"/ 171 soundStartWithSemaphore |
|
1948 |
"/ 172 soundStop |
|
1949 |
"/ 173 soundAvailableSpace |
|
1950 |
"/ 174 soundPlaySamples |
|
1951 |
"/ 175 soundPlaySilence |
|
1952 |
"/ 176 waveTableSoundmixSampleCountIntoStarrtingAtpan |
|
1953 |
"/ 177 fmSoundmixSampleCountintostartingAtpan |
|
1954 |
"/ 178 pluckedSoundmixSampleCountintostartingAtpan |
|
1955 |
"/ 179 sampledSoundmixSampleCountintostartingAtpan |
|
1956 |
"/ 180 fmSoundmixSampleCountintostartingAtleftVolrightVol |
|
1957 |
"/ 181 pluckedSoundmixSampleCountintostartingAtleftVolrightVol |
|
1958 |
"/ 182 sampledSoundmixSampleCountintostartingAtleftVolrightVol |
|
1959 |
"/ 183 reverbSoundapplyReverbTostartingAtcount |
|
1960 |
"/ 184 loopedSampledSoundmixSampleCountintostartingAtleftVolrightVol |
|
1961 |
"/ 185 fail |
|
1962 |
"/ 186 fail |
|
1963 |
"/ 187 fail |
|
1964 |
"/ 188 fail |
|
1965 |
"/ 189 soundInsertSamples |
|
1966 |
"/ 190 soundStartRecording |
|
1967 |
"/ 191 soundStopRecording |
|
1968 |
"/ 192 soundGetRecordingSampleRate |
|
1969 |
"/ 193 soundRecordSamples |
|
1970 |
"/ 194 soundSetRecordLevel |
|
1971 |
"/ 195 fail |
|
1972 |
"/ 196 fail |
|
1973 |
"/ 197 fail |
|
1974 |
"/ 198 fail |
|
1975 |
"/ 199 fail |
|
1976 |
"/ 200 initializeNetwork |
|
1977 |
"/ 201 resolverStartNameLookup |
|
1978 |
"/ 202 resolverNameLookupResult |
|
1979 |
"/ 203 resolverStartAddressLookup |
|
1980 |
"/ 204 resolverAddressLookupResult |
|
1981 |
"/ 205 resolverAbortLookup |
|
1982 |
"/ 206 resolverLocalAddress |
|
1983 |
"/ 207 resolverStatus |
|
1984 |
"/ 208 resolverError |
|
1985 |
"/ 209 socketCreate |
|
1986 |
"/ 210 socketDestroy |
|
1987 |
"/ 211 socketConnectionStatus |
|
1988 |
"/ 212 socketError |
|
1989 |
"/ 213 socketLocalAddress |
|
1990 |
"/ 214 socketLocalPort |
|
1991 |
"/ 215 socketRemoteAddress |
|
1992 |
"/ 216 socketRemotePort |
|
1993 |
"/ 217 socketConnectToPort |
|
1994 |
"/ 218 socketListenOnPort |
|
1995 |
"/ 219 socketCloseConnection |
|
1996 |
"/ 220 socketAbortConnection |
|
1997 |
"/ 221 socketReceiveDataBufCount |
|
1998 |
"/ 222 socketReceiveDataAvailable |
|
1999 |
"/ 223 socketSendDataBufCount |
|
2000 |
"/ 224 socketSendDone |
|
2001 |
"/ 225 fail |
|
2002 |
"/ 226 fail |
|
2003 |
"/ 227 fail |
|
2004 |
"/ 228 fail |
|
2005 |
"/ 229 fail |
|
2006 |
"/ 230 relinquishProcessor |
|
2007 |
"/ 231 forceDisplayUpdate |
|
2008 |
"/ 232 formPrint |
|
2009 |
"/ 233 setFullScreen |
|
2010 |
"/ 234 bitmapdecompressfromByteArrayat |
|
2011 |
"/ 235 stringcomparewithcollated |
|
2012 |
"/ 236 sampledSoundconvert8bitSignedFromto16Bit |
|
2013 |
"/ 237 bitmapcompresstoByteArray |
|
2014 |
"/ 238 serialPortOpen |
|
2015 |
"/ 239 serialPortClose |
|
2016 |
"/ 240 serialPortWrite |
|
2017 |
"/ 241 serialPortRead |
|
2018 |
"/ 242 fail |
|
2019 |
"/ 243 stringtranslatefromtotable |
|
2020 |
"/ 244 stringfindFirstInStringinSetstartingAt |
|
2021 |
"/ 245 stringindexOfAsciiinStringstartingAt |
|
2022 |
"/ 246 stringfindSubstringinstartingAtmatchTable |
|
2023 |
"/ 247 fail |
|
2024 |
"/ 248 fail |
|
2025 |
"/ 249 fail |
|
2026 |
"/ 250 clearProfile |
|
2027 |
"/ 251 dumpProfile |
|
2028 |
"/ 252 startProfiling |
|
2029 |
"/ 253 stopProfiling |
|
2030 |
"/ 254 vmParameter |
|
2031 |
"/ 255 instVarsPutFromStack |
|
2032 |
"/ 256 pushSelf |
|
2033 |
"/ 257 pushTrue |
|
2034 |
"/ 258 pushFalse |
|
2035 |
"/ 259 pushNil |
|
2036 |
"/ 260 pushMinusOne |
|
2037 |
"/ 261 pushZero |
|
2038 |
"/ 262 pushOne |
|
2039 |
"/ 263 pushTwo |
|
2040 |
"/ 264 loadInstVar |
|
2041 |
"/ .. loadInstVar |
|
2042 |
"/ 519 loadInstVar |
|
2043 |
"/ 520 fail |
|
2044 |
"/ 521 MIDIClosePort |
|
2045 |
"/ 522 MIDIGetClock |
|
2046 |
"/ 523 MIDIGetPortCount |
|
2047 |
"/ 524 MIDIGetPortDirectionality |
|
2048 |
"/ 525 MIDIGetPortName |
|
2049 |
"/ 526 MIDIOpenPort |
|
2050 |
"/ 527 MIDIParameterGetOrSet |
|
2051 |
"/ 528 MIDIRead |
|
2052 |
"/ 529 MIDIWrite |
|
2053 |
"/ 530 fail |
|
2054 |
"/ .. fail |
|
2055 |
"/ 539 fail |
|
2056 |
"/ 540 asyncFileClose |
|
2057 |
"/ 541 asyncFileOpen |
|
2058 |
"/ 542 asyncFileReadResult |
|
2059 |
"/ 543 asyncFileReadStart |
|
2060 |
"/ 544 asyncFileWriteResult |
|
2061 |
"/ 545 asyncFileWriteStart |
|
2062 |
"/ 546 fail |
|
1815 | 2063 |
"/ .. |
907 | 2064 |
"/ 700 fail |
2065 |
||
141 | 2066 |
cls notNil ifTrue:[ |
1815 | 2067 |
^ (cls compiledMethodAt:sel) code |
141 | 2068 |
]. |
2069 |
^ nil |
|
2070 |
! |
|
2071 |
||
3162
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2072 |
codeLineNumber:nr on:codeStream |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2073 |
"generate lineNumber information" |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2074 |
|
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2075 |
"/ caveat: (currently) there is no separate lineNumber or symbol table; |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2076 |
"/ the line numbers are coded right into the instruction stream. |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2077 |
"/ This might change in the future. |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2078 |
"/ (It is not a problem speed wise: the Jitter just skips them.) |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2079 |
|
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2080 |
(currentLineNumber = nr or:[nr <= 0]) ifTrue:[ |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2081 |
^ self |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2082 |
]. |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2083 |
|
3186 | 2084 |
"don't need line number information, if still on same line" |
3162
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2085 |
currentLineNumber := nr. |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2086 |
|
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2087 |
nr <= 255 ifTrue:[ |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2088 |
codeStream |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2089 |
nextPut:#lineno; |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2090 |
nextPut:nr. |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2091 |
] ifFalse:[ |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2092 |
nr <= 16rFFFF ifTrue:[ |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2093 |
codeStream |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2094 |
nextPut:#lineno16; |
3763 | 2095 |
nextPutInt16MSB:nr. |
3162
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2096 |
] |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2097 |
]. |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2098 |
! |
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2099 |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2100 |
createMethod |
429 | 2101 |
|newMethod| |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2102 |
|
1094
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
2103 |
newMethod := self methodClass new:(litArray size). |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
2104 |
litArray notNil ifTrue:[ |
2502 | 2105 |
"/ fixup CheapBlocks method-field in literal array, |
2106 |
litArray do:[:aLiteral | |
|
3416 | 2107 |
(aLiteral isBlock and:[aLiteral isCheapBlock]) ifTrue:[ |
2502 | 2108 |
aLiteral setMethod:newMethod. |
2109 |
] |
|
2110 |
]. |
|
2111 |
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
|
2112 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2113 |
|
594
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2114 |
newMethod numberOfVars:(self numberOfMethodVars + (maxNumTemp ? 0)). |
3648 | 2115 |
newMethod numberOfArgs:(self numberOfMethodArgs). |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2116 |
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
|
2117 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2118 |
primitiveResource notNil ifTrue:[ |
2502 | 2119 |
newMethod setResourceFlag |
2120 |
]. |
|
2121 |
||
2623 | 2122 |
annotations notEmptyOrNil ifTrue:[ |
3569 | 2123 |
newMethod annotations: (self annotations copy). |
2759 | 2124 |
(Smalltalk at: #NamespaceAwareLookup) notNil ifTrue:[ |
3569 | 2125 |
(annotations contains: [:annotation| (annotation key) == #namespace:]) |
2502 | 2126 |
ifTrue:[newMethod lookupObject:NamespaceAwareLookup instance] |
2127 |
] |
|
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2128 |
]. |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2129 |
|
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2130 |
^ newMethod |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2131 |
|
2502 | 2132 |
"Created: / 18-05-1996 / 16:33:17 / cg" |
2133 |
"Modified: / 24-06-1996 / 12:32:50 / stefan" |
|
2134 |
"Modified: / 10-07-2010 / 21:40:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2759 | 2135 |
"Modified: / 29-11-2011 / 11:22:15 / cg" |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2136 |
! |
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2137 |
|
141 | 2138 |
genByteCodeFrom:symbolicCodeArray |
2139 |
"convert symbolicCode into bytecodes" |
|
2140 |
||
2141 |
|symIndex "{Class: SmallInteger }" |
|
2142 |
codeSize "{Class: SmallInteger }" |
|
2143 |
symCodeSize "{Class: SmallInteger }" |
|
429 | 2144 |
index nextSym addr |
141 | 2145 |
codeSymbol nargs needRetry |
429 | 2146 |
stackDepth relocInfo level nvars round| |
141 | 2147 |
|
2148 |
symbolicCodeArray isNil ifTrue:[^ self]. |
|
2149 |
||
2150 |
round := 0. |
|
2151 |
needRetry := true. |
|
2152 |
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
|
2153 |
ShareCode ifTrue:[ |
3071 | 2154 |
codeBytes := self checkForCommonCode:symbolicCodeArray. |
2155 |
codeBytes notNil ifTrue:[ |
|
2156 |
^ self |
|
2157 |
]. |
|
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
|
2158 |
]. |
141 | 2159 |
codeSize := symCodeSize. |
2160 |
||
2161 |
[needRetry] whileTrue:[ |
|
3071 | 2162 |
stackDepth := 0. |
2163 |
maxStackDepth := 0. |
|
2164 |
||
2165 |
codeBytes := ByteArray uninitializedNew:codeSize. |
|
2166 |
relocInfo := Array basicNew:(codeSize + 1). |
|
2167 |
symIndex := 1. |
|
2168 |
codeIndex := 1. |
|
2169 |
||
2170 |
needRetry := false. |
|
2171 |
round := round + 1. |
|
2172 |
||
2173 |
[symIndex <= symCodeSize] whileTrue:[ |
|
2174 |
relocInfo at:symIndex put:codeIndex. |
|
2175 |
||
2176 |
codeSymbol := symbolicCodeArray at:symIndex. |
|
2177 |
symIndex := symIndex + 1. |
|
2178 |
stackDelta := 0. |
|
2179 |
extra := extraLiteral := extraOP := nil. |
|
2180 |
lineno := false. |
|
2181 |
||
2182 |
self appendByteCodeFor:codeSymbol. |
|
2183 |
extraOP notNil ifTrue:[ |
|
2184 |
self appendByte:extraOP. |
|
2185 |
symIndex := symIndex + 1. |
|
2186 |
]. |
|
2187 |
||
2188 |
extraLiteral notNil ifTrue:[ |
|
2189 |
self addLiteral:extraLiteral |
|
2190 |
]. |
|
2191 |
||
2192 |
lineno ifTrue:[ |
|
3162
d7d32920c1b4
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3161
diff
changeset
|
2193 |
"the instruction requires a line number byte" |
3071 | 2194 |
self appendByte:((symbolicCodeArray at:symIndex) min:255). |
2195 |
symIndex := symIndex + 1. |
|
2196 |
codeSymbol == #lineno16 ifTrue:[ |
|
2197 |
self appendByte:((symbolicCodeArray at:symIndex) min:255). |
|
2198 |
symIndex := symIndex + 1 |
|
2199 |
] |
|
2200 |
]. |
|
2201 |
||
2202 |
extra notNil ifTrue:[ |
|
2203 |
nextSym := symbolicCodeArray at:symIndex. |
|
2204 |
||
2205 |
(extra == #number) ifTrue:[ |
|
2206 |
index := nextSym. |
|
2207 |
symIndex := symIndex + 1. |
|
2208 |
self appendSignedByte:index |
|
2209 |
||
2210 |
] ifFalse:[ (extra == #number16) ifTrue:[ |
|
2211 |
index := nextSym. |
|
2212 |
symIndex := symIndex + 2. |
|
2213 |
self appendSignedWord:index |
|
2214 |
||
2215 |
] ifFalse:[ (extra == #unsigned16) ifTrue:[ |
|
2216 |
index := nextSym. |
|
2217 |
symIndex := symIndex + 2. |
|
2218 |
self appendWord:index |
|
2219 |
||
2220 |
] ifFalse:[ (extra == #unsigned32) ifTrue:[ |
|
2221 |
index := nextSym. |
|
2222 |
symIndex := symIndex + 4. |
|
2223 |
self appendLongWord:index |
|
2224 |
||
2225 |
] ifFalse:[ (extra == #index) ifTrue:[ |
|
2226 |
index := nextSym. |
|
2227 |
symIndex := symIndex + 1. |
|
2228 |
self appendByte:index |
|
2229 |
||
2230 |
] ifFalse:[ (extra == #lit) ifTrue:[ |
|
2231 |
index := self addLiteral:nextSym. |
|
2232 |
symIndex := symIndex + 1. |
|
2233 |
self appendByte:index |
|
2234 |
||
2235 |
] ifFalse:[ (extra == #speciallit) ifTrue:[ |
|
2236 |
index := self addLiteral:nextSym. |
|
2237 |
index > 255 ifTrue:[ |
|
2238 |
self codeGeneratorError:'too many globals (' , |
|
2239 |
(symbolicCodeArray at:symIndex) , |
|
2240 |
' index=' , index printString , |
|
2241 |
') in method - please simplify'. |
|
2242 |
^ #Error |
|
2243 |
]. |
|
2244 |
symIndex := symIndex + 1. |
|
2245 |
self appendByte:index. |
|
2246 |
||
2247 |
] ifFalse:[ (extra == #speciallitS) ifTrue:[ |
|
2248 |
index := nextSym. |
|
2249 |
symIndex := symIndex + 1. |
|
2250 |
self appendByte:index. |
|
2251 |
||
2252 |
] ifFalse:[ (extra == #speciallitL) ifTrue:[ |
|
2253 |
index := nextSym. |
|
2254 |
symIndex := symIndex + 2. |
|
2255 |
self appendWord:index. |
|
2256 |
||
2257 |
] ifFalse:[ (extra == #offset) ifTrue:[ |
|
2258 |
relocInfo at:symIndex put:codeIndex. |
|
2259 |
self addReloc:symIndex. |
|
2260 |
symIndex := symIndex + 1. |
|
2261 |
self appendByte:0 |
|
2262 |
||
2263 |
] ifFalse:[ (extra == #indexLevel) ifTrue:[ |
|
2264 |
index := nextSym. |
|
2265 |
symIndex := symIndex + 1. |
|
2266 |
self appendByte:index. |
|
2267 |
level := symbolicCodeArray at:symIndex. |
|
2268 |
symIndex := symIndex + 1. |
|
2269 |
self appendByte:level |
|
2270 |
||
2271 |
] ifFalse:[ (extra == #offsetNvarNarg) ifTrue:[ |
|
2272 |
relocInfo at:symIndex put:codeIndex. |
|
2273 |
self addReloc:symIndex. |
|
2274 |
symIndex := symIndex + 1. |
|
2275 |
self appendEmptyByte. |
|
2276 |
nvars := symbolicCodeArray at:symIndex. |
|
2277 |
symIndex := symIndex + 1. |
|
2278 |
self appendByte:nvars. |
|
2279 |
level := symbolicCodeArray at:symIndex. |
|
2280 |
symIndex := symIndex + 1. |
|
2281 |
self appendByte:level |
|
2282 |
||
2283 |
] ifFalse:[ (extra == #absoffset) ifTrue:[ |
|
2284 |
relocInfo at:symIndex put:codeIndex. |
|
2285 |
self addReloc:symIndex. |
|
2286 |
addr := symbolicCodeArray at:symIndex. |
|
2287 |
symIndex := symIndex + 1. |
|
3412 | 2288 |
self appendWord:addr. |
3071 | 2289 |
|
2290 |
] ifFalse:[ (extra == #absoffsetNvarNarg) ifTrue:[ |
|
2291 |
relocInfo at:symIndex put:codeIndex. |
|
2292 |
self addReloc:symIndex. |
|
2293 |
addr := symbolicCodeArray at:symIndex. |
|
2294 |
symIndex := symIndex + 1. |
|
3412 | 2295 |
self appendWord:addr. |
3071 | 2296 |
nvars := symbolicCodeArray at:symIndex. |
2297 |
symIndex := symIndex + 1. |
|
2298 |
self appendByte:nvars. |
|
2299 |
level := symbolicCodeArray at:symIndex. |
|
2300 |
symIndex := symIndex + 1. |
|
2301 |
self appendByte:level |
|
2302 |
||
2303 |
] ifFalse:[ (extra == #special) ifTrue:[ |
|
2304 |
((codeSymbol == #send) |
|
2305 |
or:[codeSymbol == #sendSelf |
|
2306 |
or:[codeSymbol == #superSend]]) ifTrue:[ |
|
2307 |
index := nextSym. |
|
2308 |
symIndex := symIndex + 1. |
|
2309 |
nargs := symbolicCodeArray at:symIndex. |
|
2310 |
symIndex := symIndex + 1. |
|
2311 |
self appendByte:nargs. |
|
2312 |
self appendByte:index. |
|
2313 |
||
2314 |
(codeSymbol == #superSend) ifTrue:[ |
|
2315 |
index := symbolicCodeArray at:symIndex. |
|
2316 |
symIndex := symIndex + 1. |
|
2317 |
self appendByte:index |
|
2318 |
]. |
|
2319 |
stackDelta := nargs negated. |
|
2320 |
codeSymbol == #sendSelf ifTrue:[ |
|
2321 |
stackDelta := stackDelta + 1 |
|
2322 |
] |
|
2323 |
] ifFalse:[ (codeSymbol == #sendDrop) ifTrue:[ |
|
2324 |
index := nextSym. |
|
2325 |
symIndex := symIndex + 1. |
|
2326 |
nargs := symbolicCodeArray at:symIndex. |
|
2327 |
symIndex := symIndex + 1. |
|
2328 |
self appendByte:nargs. |
|
2329 |
self appendByte:index. |
|
2330 |
stackDelta := (nargs + 1) negated |
|
2331 |
]] |
|
2332 |
||
2333 |
] ifFalse:[ (extra == #specialL) ifTrue:[ |
|
2334 |
((codeSymbol == #sendL) |
|
2335 |
or:[codeSymbol == #sendDropL |
|
2336 |
or:[codeSymbol == #sendSelfL |
|
2337 |
or:[codeSymbol == #superSendL]]]) ifTrue:[ |
|
2338 |
index := nextSym. |
|
2339 |
symIndex := symIndex + 2. |
|
2340 |
nargs := symbolicCodeArray at:symIndex. |
|
2341 |
symIndex := symIndex + 1. |
|
2342 |
self appendByte:nargs. |
|
2343 |
self appendWord:index. |
|
2344 |
(codeSymbol == #superSendL) ifTrue:[ |
|
2345 |
index := symbolicCodeArray at:symIndex. |
|
2346 |
symIndex := symIndex + 2. |
|
2347 |
self appendWord:index. |
|
2348 |
]. |
|
2349 |
stackDelta := nargs negated. |
|
2350 |
codeSymbol == #sendSelfL ifTrue:[ |
|
2351 |
stackDelta := stackDelta + 1 |
|
2352 |
] |
|
2353 |
] |
|
2354 |
] ifFalse:[ (extra == #specialSend) ifTrue:[ |
|
2355 |
index := nextSym. |
|
2356 |
symIndex := symIndex + 1. |
|
2357 |
self appendByte:index. |
|
2358 |
||
2359 |
] ifFalse:[ (extra == #specialVL) ifTrue:[ |
|
2360 |
((codeSymbol == #sendVL) |
|
2361 |
or:[codeSymbol == #superSendVL]) ifTrue:[ |
|
2362 |
index := nextSym. |
|
2363 |
symIndex := symIndex + 4. |
|
2364 |
nargs := symbolicCodeArray at:symIndex. |
|
2365 |
symIndex := symIndex + 1. |
|
2366 |
self appendByte:nargs. |
|
2367 |
self appendLongWord:index. |
|
2368 |
(codeSymbol == #superSendVL) ifTrue:[ |
|
2369 |
index := symbolicCodeArray at:symIndex. |
|
2370 |
symIndex := symIndex + 4. |
|
2371 |
self appendLongWord:index. |
|
2372 |
]. |
|
2373 |
stackDelta := nargs negated. |
|
2374 |
] |
|
2375 |
] ifFalse:[ |
|
2376 |
"/ self halt:'internal error' |
|
2377 |
||
2378 |
]]]]]]]]]]]]]]]]]] |
|
2379 |
]. |
|
2380 |
||
2381 |
stackDepth := stackDepth + stackDelta. |
|
2382 |
(stackDepth > maxStackDepth) ifTrue:[ |
|
2383 |
maxStackDepth := stackDepth |
|
2384 |
] |
|
2385 |
]. |
|
2386 |
relocInfo at:symIndex put:codeIndex. |
|
2387 |
||
2388 |
needRetry ifFalse:[ |
|
2389 |
" |
|
2390 |
now relocate - returns true if ok, false if we have to do it again |
|
2391 |
(when short jumps have been changed to long jumps) |
|
2392 |
" |
|
2393 |
relocList notNil ifTrue:[ |
|
2394 |
needRetry := (self relocateWith:symbolicCodeArray relocInfo:relocInfo) not. |
|
2395 |
" |
|
2396 |
if returned with false, a relative jump was made into |
|
2397 |
an absolute jump - need to start over with one more byte space |
|
2398 |
" |
|
2399 |
needRetry ifTrue:[ |
|
2400 |
relocList := nil. |
|
2401 |
codeSize := codeSize + 1. |
|
2402 |
] |
|
2403 |
] |
|
2404 |
] ifTrue:[ |
|
2405 |
'Compiler [info]: compiling again ...' infoPrintCR. |
|
2406 |
] |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2407 |
]. |
141 | 2408 |
"code printNL." |
2409 |
^ errorFlag |
|
2410 |
||
2411 |
"Modified: 3.9.1995 / 12:59:43 / claus" |
|
475 | 2412 |
"Modified: 10.1.1997 / 15:17:51 / cg" |
141 | 2413 |
! |
2414 |
||
937
21ca5ab983b7
support exception handle/raise/unwind pragmas
Claus Gittinger <cg@exept.de>
parents:
935
diff
changeset
|
2415 |
genSpecialStatement:selector on:codeStream |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2416 |
"/ generate: thisContext selector (to force a context). |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2417 |
|
1815 | 2418 |
(StatementNode |
2419 |
expression:(UnaryNode receiver:(VariableNode type:#ThisContext context:contextToEvaluateIn) |
|
2420 |
selector:selector)) |
|
2421 |
codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
937
21ca5ab983b7
support exception handle/raise/unwind pragmas
Claus Gittinger <cg@exept.de>
parents:
935
diff
changeset
|
2422 |
! |
21ca5ab983b7
support exception handle/raise/unwind pragmas
Claus Gittinger <cg@exept.de>
parents:
935
diff
changeset
|
2423 |
|
141 | 2424 |
genSymbolicCode |
2425 |
"traverse the parse-tree producing symbolicCode - return the codeArray" |
|
2426 |
||
2427 |
|codeStream code thisStatement lastStatement| |
|
2428 |
||
2429 |
litArray := nil. |
|
2430 |
codeStream := WriteStream on:(OrderedCollection new:100). |
|
2431 |
||
937
21ca5ab983b7
support exception handle/raise/unwind pragmas
Claus Gittinger <cg@exept.de>
parents:
935
diff
changeset
|
2432 |
primitiveContextInfo notNil ifTrue:[ |
3416 | 2433 |
(primitiveContextInfo includes:('exception:' -> #unwind)) ifTrue:[ |
2434 |
self genSpecialStatement:#markForUnwind on:codeStream |
|
2435 |
]. |
|
2436 |
(primitiveContextInfo includes:('exception:' -> #handle)) ifTrue:[ |
|
2437 |
self genSpecialStatement:#markForHandle on:codeStream |
|
2438 |
]. |
|
2439 |
(primitiveContextInfo includes:('exception:' -> #raise)) ifTrue:[ |
|
2440 |
self genSpecialStatement:#markForRaise on:codeStream |
|
2441 |
]. |
|
937
21ca5ab983b7
support exception handle/raise/unwind pragmas
Claus Gittinger <cg@exept.de>
parents:
935
diff
changeset
|
2442 |
]. |
21ca5ab983b7
support exception handle/raise/unwind pragmas
Claus Gittinger <cg@exept.de>
parents:
935
diff
changeset
|
2443 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2444 |
self startCodeGenerationHookOn:codeStream. |
1312 | 2445 |
self generateVariables:methodVars on:codeStream. |
2446 |
||
3416 | 2447 |
(tree notNil and:[tree isMethodNode]) ifTrue:[ |
2448 |
"kludge for VW compat." |
|
2449 |
tree codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
2450 |
lastStatement := tree statements last. |
|
1790 | 2451 |
] ifFalse:[ |
3416 | 2452 |
thisStatement := tree. |
2453 |
[thisStatement notNil] whileTrue:[ |
|
2454 |
lastStatement := thisStatement. |
|
2455 |
thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
2456 |
thisStatement := thisStatement nextStatement |
|
2457 |
]. |
|
141 | 2458 |
]. |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2459 |
|
141 | 2460 |
(lastStatement isNil or:[lastStatement isReturnNode not]) |
2461 |
ifTrue:[ |
|
3416 | 2462 |
"not a return - add retSelf" |
2463 |
" |
|
2464 |
if the last statement was a send for side-effect, |
|
2465 |
replace the previous drop by a retSelf. |
|
2466 |
In this case we have to keep an extra retSelf bacause |
|
2467 |
it could be a jump target. |
|
2468 |
" |
|
2469 |
(lastStatement notNil |
|
2470 |
and:[(code := codeStream contents) notNil |
|
2471 |
and:[code size > 0 |
|
2472 |
and:[code last == #drop]]]) ifTrue:[ |
|
2473 |
codeStream backStep. |
|
2474 |
codeStream nextPut:#retSelf |
|
2475 |
]. |
|
2476 |
codeStream nextPut:#retSelf |
|
141 | 2477 |
]. |
2478 |
^ codeStream contents |
|
328 | 2479 |
|
1790 | 2480 |
"Modified: / 15-08-1996 / 17:35:02 / stefan" |
2481 |
"Modified: / 06-08-2006 / 15:03:14 / cg" |
|
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2482 |
! |
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
2483 |
|
1312 | 2484 |
generateVariables:varCollection on:codeStream |
2485 |
varCollection isNil ifTrue:[^ self]. |
|
2486 |
||
2487 |
varCollection do:[:eachVar | |
|
1815 | 2488 |
eachVar type notNil ifTrue:[ |
2489 |
"/ generate code to set it up. |
|
2490 |
||
2491 |
(AssignmentNode |
|
2492 |
variable:(self nodeForMethodVariable:eachVar name) |
|
2493 |
expression:(eachVar expressionForSetup)) |
|
2494 |
codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
2495 |
] |
|
1312 | 2496 |
] |
2497 |
! |
|
2498 |
||
141 | 2499 |
relocateWith:symbolicCodeArray relocInfo:relocInfo |
2500 |
"helper for genByteCodeFrom - relocate code using relocInfo. |
|
2501 |
if relocation fails badly (due to long relative jumps) patch |
|
2502 |
symbolicCode to use absolute jumps instead and return false |
|
2503 |
(genByteCodeFrom will then try again). Otherwise return true. |
|
2504 |
Also, on the fly, jumps to jumps and jumps to return are handled." |
|
2505 |
||
2506 |
|delta "{Class: SmallInteger }" |
|
2507 |
codePos "{Class: SmallInteger }" |
|
2508 |
opCodePos "{Class: SmallInteger }" |
|
2509 |
codeOffset "{Class: SmallInteger }" |
|
1815 | 2510 |
symOffset |
141 | 2511 |
opcode "{Class: SmallInteger }" |
2512 |
dstOpcode jumpTarget |
|
2513 |
jumpCode deleteSet| |
|
2514 |
||
2515 |
deleteSet := OrderedCollection new. |
|
2516 |
relocList do:[:sIndex | |
|
3071 | 2517 |
"have to relocate symCode at sIndex ..." |
2518 |
symOffset := symbolicCodeArray at:sIndex. "the target in the symbolic code" |
|
2519 |
codePos := relocInfo at:sIndex. "position of the offet in byte code" |
|
2520 |
codeOffset := relocInfo at:symOffset. "position of the target in byte code" |
|
2521 |
delta := codeOffset - codePos - 1. |
|
2522 |
opCodePos := codePos - 1. |
|
2523 |
opcode := codeBytes at:opCodePos. |
|
2524 |
||
2525 |
(opcode between:190 and:199) ifTrue:[ |
|
2526 |
"an absolute jump/makeBlock" |
|
2527 |
||
2528 |
codeBytes at:codePos put:(codeOffset bitAnd:16rFF). |
|
2529 |
codeBytes at:(codePos + 1) put:(codeOffset bitShift:-8) |
|
2530 |
] ifFalse:[ |
|
2531 |
"get jump-code from long and vlong codes" |
|
2532 |
(opcode between:50 and:59) ifFalse:[ |
|
2533 |
(opcode between:60 and:69) ifTrue:[ |
|
2534 |
opcode := opcode - 10 |
|
2535 |
] ifFalse:[ |
|
2536 |
(opcode between:70 and:79) ifTrue:[ |
|
2537 |
opcode := opcode - 20 |
|
2538 |
] ifFalse:[ |
|
2539 |
self codeGeneratorError:'invalid code to relocate' |
|
2540 |
] |
|
2541 |
]. |
|
2542 |
]. |
|
2543 |
||
2544 |
"optimize jump to return and jump to jump" |
|
2545 |
||
2546 |
(opcode == 54) ifTrue:[ |
|
2547 |
"a jump" |
|
2548 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
2549 |
||
2550 |
(#(retSelf retTop retNil retTrue retFalse ret0 "blockRetTop") includes:dstOpcode) ifTrue:[ |
|
2551 |
"a jump to a return - put in the return instead jump" |
|
2552 |
||
2553 |
symbolicCodeArray at:(sIndex - 1) put:dstOpcode. |
|
2554 |
symbolicCodeArray at:sIndex put:dstOpcode. |
|
2555 |
codeBytes at:opCodePos put:(self byteCodeFor:dstOpcode). |
|
2556 |
delta := 0. |
|
2557 |
deleteSet add:sIndex. |
|
1815 | 2558 |
|
2559 |
" |
|
141 | 2560 |
'jump to return at: ' print. (sIndex - 1) printNL. |
1815 | 2561 |
" |
3071 | 2562 |
] ifFalse:[ |
2563 |
(dstOpcode == #jump) ifTrue:[ |
|
2564 |
"jump to jump to be done soon" |
|
2565 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
1815 | 2566 |
" |
141 | 2567 |
'jump to jump at: ' print. (sIndex - 1) print. |
2568 |
' newTarget:' print. jumpTarget printNL. |
|
1815 | 2569 |
" |
2570 |
||
3071 | 2571 |
symbolicCodeArray at:sIndex put:jumpTarget. |
2572 |
symOffset := jumpTarget. |
|
2573 |
codeOffset := relocInfo at:symOffset. |
|
2574 |
delta := codeOffset - codePos - 1. |
|
2575 |
||
2576 |
"continue with new delta" |
|
2577 |
] |
|
2578 |
] |
|
2579 |
]. |
|
3416 | 2580 |
(#[50 51 52 53 56 57 58 59] includes:opcode) ifTrue:[ |
3071 | 2581 |
"a conditional jump" |
2582 |
||
2583 |
dstOpcode := symbolicCodeArray at:symOffset. |
|
2584 |
(dstOpcode == #jump) ifTrue:[ |
|
2585 |
"conditional jump to unconditional jump" |
|
2586 |
jumpTarget := symbolicCodeArray at:(symOffset + 1). |
|
1815 | 2587 |
" |
141 | 2588 |
'cond jump to jump at: ' print. (sIndex - 1) print. |
2589 |
' newTarget:' print. jumpTarget printNL. |
|
1815 | 2590 |
" |
2591 |
||
3071 | 2592 |
symbolicCodeArray at:sIndex put:jumpTarget. |
2593 |
symOffset := jumpTarget. |
|
2594 |
codeOffset := relocInfo at:symOffset. |
|
2595 |
delta := codeOffset - codePos - 1. |
|
2596 |
||
2597 |
"continue with new delta" |
|
2598 |
]. |
|
2599 |
]. |
|
2600 |
||
2601 |
(delta >= 0) ifTrue:[ |
|
2602 |
(delta > 127) ifTrue:[ |
|
2603 |
(opcode between:50 and:59) ifFalse:[ |
|
2604 |
self codeGeneratorError:'invalid code to relocate' |
|
2605 |
] ifTrue:[ |
|
2606 |
(delta > 255) ifTrue:[ |
|
2607 |
"change jmp into vljmp ..." |
|
2608 |
codeBytes at:opCodePos put:(opcode + 20). |
|
2609 |
delta := delta - 256 |
|
2610 |
] ifFalse:[ |
|
2611 |
"change jmp into ljmp ..." |
|
2612 |
codeBytes at:opCodePos put:(opcode + 10). |
|
2613 |
delta := delta - 128 |
|
2614 |
]. |
|
2615 |
(delta > 127) ifTrue:[ |
|
2616 |
"change symbolic into a jump absolute and fail" |
|
2617 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
2618 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
2619 |
symbolicCodeArray at:sIndex put:symOffset. |
|
141 | 2620 |
" |
2621 |
'change short into abs jump' printNL. |
|
2622 |
" |
|
3071 | 2623 |
deleteSet do:[:d | relocList remove:d]. |
2624 |
^ false |
|
2625 |
] |
|
2626 |
]. |
|
2627 |
]. |
|
2628 |
codeBytes at:codePos put:delta |
|
2629 |
] ifFalse:[ |
|
2630 |
(delta < -128) ifTrue:[ |
|
2631 |
(opcode between:50 and:59) ifFalse:[ |
|
2632 |
self codeGeneratorError:'invalid code to relocate' |
|
2633 |
] ifTrue:[ |
|
2634 |
(delta < -256) ifTrue:[ |
|
2635 |
"change jmp into vljmp ..." |
|
2636 |
codeBytes at:opCodePos put:(opcode + 20). |
|
2637 |
delta := delta + 256 |
|
2638 |
] ifFalse:[ |
|
2639 |
"change jmp into ljmp ..." |
|
2640 |
codeBytes at:opCodePos put:(opcode + 10). |
|
2641 |
delta := delta + 128 |
|
2642 |
]. |
|
2643 |
(delta < -128) ifTrue:[ |
|
2644 |
"change symbolic into a jump absolute and fail" |
|
2645 |
jumpCode := symbolicCodeArray at:(sIndex - 1). |
|
2646 |
symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode). |
|
2647 |
symbolicCodeArray at:sIndex put:symOffset. |
|
141 | 2648 |
" |
2649 |
'change short into abs jump' printNL. |
|
2650 |
" |
|
3071 | 2651 |
deleteSet do:[:d | relocList remove:d]. |
2652 |
^ false |
|
2653 |
] |
|
2654 |
] |
|
2655 |
]. |
|
2656 |
codeBytes at:codePos put:(256 + delta) |
|
2657 |
] |
|
2658 |
] |
|
141 | 2659 |
]. |
3451 | 2660 |
self errorFlag ifTrue:[ |
3071 | 2661 |
self codeGeneratorError:'relocation range error' |
141 | 2662 |
]. |
2663 |
^ true |
|
0 | 2664 |
! ! |
49 | 2665 |
|
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2666 |
!ByteCodeCompiler methodsFor:'code generation helpers'! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2667 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2668 |
absJumpFromJump:code |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2669 |
"given a jump-symbolic code, return corresponding absolute jump" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2670 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2671 |
JumpToAbsJump isNil ifTrue:[ |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2672 |
JumpToAbsJump := IdentityDictionary new. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2673 |
JumpToAbsJump at:#jump put:#jumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2674 |
JumpToAbsJump at:#trueJump put:#trueJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2675 |
JumpToAbsJump at:#falseJump put:#falseJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2676 |
JumpToAbsJump at:#nilJump put:#nilJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2677 |
JumpToAbsJump at:#notNilJump put:#notNilJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2678 |
JumpToAbsJump at:#eqJump put:#eqJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2679 |
JumpToAbsJump at:#notEqJump put:#notEqJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2680 |
JumpToAbsJump at:#zeroJump put:#zeroJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2681 |
JumpToAbsJump at:#notZeroJump put:#notZeroJumpabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2682 |
JumpToAbsJump at:#makeBlock put:#makeBlockabs. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2683 |
]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2684 |
^ JumpToAbsJump at:code |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2685 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2686 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2687 |
addLiteral:anObject |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2688 |
"add a literal to the literalArray - watch for and eliminate |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2689 |
duplicates. return the index of the literal in the Array" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2690 |
|
3856 | 2691 |
|index oldLit class sharable sharableValue| |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2692 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2693 |
litArray isNil ifTrue:[ |
2337 | 2694 |
litArray := OrderedCollection with:anObject. |
2695 |
^ 1 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2696 |
]. |
1798 | 2697 |
|
3856 | 2698 |
sharable := sharableValue := false. |
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
2699 |
class := anObject class. |
1815 | 2700 |
class == Symbol |
3856 | 2701 |
ifTrue:[ sharable := true ] |
2337 | 2702 |
ifFalse:[ |
3765 | 2703 |
anObject isImmutable ifTrue:[ |
3856 | 2704 |
sharable := true |
3765 | 2705 |
] ifFalse:[ |
2706 |
((class == String) or:[class == Array or:[class == ByteArray]]) ifTrue:[ |
|
2707 |
anObject isEmpty ifTrue:[ |
|
3856 | 2708 |
sharable := true |
3765 | 2709 |
] |
2710 |
] ifFalse:[ |
|
2711 |
((class == Float) or:[class == Fraction or:[class == LargeInteger]]) ifTrue:[ |
|
3856 | 2712 |
sharableValue := true |
3765 | 2713 |
] |
2337 | 2714 |
] |
3765 | 2715 |
]. |
2337 | 2716 |
]. |
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
2717 |
|
3856 | 2718 |
(sharable not and:[sharableValue not]) ifTrue:[ |
2337 | 2719 |
litArray add:anObject. |
2720 |
index := litArray size. |
|
2721 |
^ index. |
|
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
2722 |
]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
2723 |
|
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
2724 |
"/ searching a dictionary is *much* faster; the code below starts to |
1798 | 2725 |
"/ keep track of literals whenever we have collected more than a threshold |
2726 |
allLiterals notNil ifTrue:[ |
|
3856 | 2727 |
sharable ifTrue:[ |
2337 | 2728 |
index := allLiterals at:anObject ifAbsent:nil. |
2729 |
index isNil ifTrue:[ |
|
2730 |
litArray add:anObject. |
|
2731 |
index := litArray size. |
|
2732 |
allLiterals at:anObject put:index. |
|
2733 |
^ index. |
|
2734 |
]. |
|
2735 |
(litArray at:index) class ~~ anObject class ifTrue:[ |
|
2736 |
index := nil. |
|
2737 |
]. |
|
2738 |
]. |
|
1798 | 2739 |
]. |
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
2740 |
index isNil ifTrue:[ |
2337 | 2741 |
index := litArray identityIndexOf:anObject. |
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
2742 |
]. |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2743 |
(index == 0) ifTrue:[ |
2337 | 2744 |
" |
2745 |
reuse constants if same value and same class |
|
2746 |
" |
|
2747 |
((class == Float) |
|
2748 |
or:[class == Fraction |
|
2749 |
or:[class == LargeInteger |
|
2750 |
"or:[class == String] --only if literalString option has been added---" ]]) ifTrue:[ |
|
2751 |
index := litArray indexOf:anObject. |
|
2752 |
index ~~ 0 ifTrue:[ |
|
2753 |
oldLit := litArray at:index. |
|
2754 |
oldLit class == class ifFalse:[ |
|
2755 |
index := 0. |
|
2756 |
] ifTrue:[ |
|
3765 | 2757 |
"/ don't mess up negative with positive zeros |
2337 | 2758 |
anObject = 0.0 ifTrue:[ |
2759 |
anObject isNegativeZero ~~ oldLit isNegativeZero ifTrue:[ |
|
2760 |
index := 0 |
|
2761 |
] |
|
2762 |
] |
|
2763 |
]. |
|
2764 |
]. |
|
2765 |
]. |
|
2766 |
||
2767 |
" |
|
2768 |
reuse empty collection literals |
|
2769 |
" |
|
2770 |
((class == String) or:[class == Array or:[class == ByteArray]]) ifTrue:[ |
|
2771 |
anObject size == 0 ifTrue:[ |
|
2772 |
index := litArray indexOf:anObject. |
|
2338 | 2773 |
index ~~ 0 ifTrue:[ |
2774 |
oldLit := litArray at:index. |
|
2775 |
oldLit class == class ifFalse:[ |
|
2776 |
index := 0. |
|
2777 |
] |
|
2337 | 2778 |
] |
2779 |
] |
|
2780 |
]. |
|
2781 |
||
2782 |
(index == 0) ifTrue:[ |
|
2783 |
litArray add:anObject. |
|
2784 |
index := litArray size. |
|
2785 |
index > 30 ifTrue:[ |
|
2786 |
allLiterals isNil ifTrue:[ |
|
2787 |
allLiterals := Dictionary new. |
|
2788 |
litArray keysAndValuesDo:[:idx :lit | allLiterals at:lit put:idx]. |
|
2789 |
]. |
|
2790 |
allLiterals at:anObject put:index. |
|
2791 |
]. |
|
2792 |
]. |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2793 |
]. |
1798 | 2794 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2795 |
^ index |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2796 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2797 |
"Modified: / 12.11.1997 / 18:49:43 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2798 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2799 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2800 |
addReloc:symIndex |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2801 |
"remember to relocate offset at symIndex later ..." |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2802 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2803 |
relocList isNil ifTrue:[ |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2804 |
relocList := OrderedCollection new. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2805 |
]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2806 |
relocList add:symIndex |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2807 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2808 |
|
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2809 |
addTempVar |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2810 |
"add a temporary variable; return its position (1-based). |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2811 |
Used when a block with args/locals is inlined." |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2812 |
|
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2813 |
numTemp isNil ifTrue:[numTemp := maxNumTemp := 0]. |
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2814 |
numTemp := numTemp + 1. |
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2815 |
maxNumTemp := maxNumTemp max:numTemp. |
560
9311c79529d4
inline blocks withs args/vars
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
2816 |
^ numTemp + methodVars size |
9311c79529d4
inline blocks withs args/vars
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
2817 |
|
9311c79529d4
inline blocks withs args/vars
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
2818 |
"Modified: 26.6.1997 / 10:22:23 / cg" |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2819 |
! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2820 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2821 |
appendByte:aByte |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2822 |
"append a byte to the code-Array, checking for byte-range (debug-only)" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2823 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2824 |
|idx "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2825 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2826 |
idx := codeIndex. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2827 |
(aByte between:0 and:255) ifTrue:[ |
3071 | 2828 |
codeBytes at:idx put:aByte. |
2829 |
codeIndex := idx + 1 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2830 |
] ifFalse:[ |
3071 | 2831 |
self codeGeneratorError:'byte range error'. |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2832 |
] |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2833 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2834 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2835 |
appendByteCodeFor:codeSymbol |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2836 |
"append the byteCode for an instructionSymbol to the code-Array" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2837 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2838 |
|idx "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2839 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2840 |
idx := codeIndex. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2841 |
codeBytes at:idx put:(self byteCodeFor:codeSymbol). |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2842 |
codeIndex := idx + 1 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2843 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2844 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2845 |
appendEmptyByte |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2846 |
"append an empty byte to the code-Array" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2847 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2848 |
|idx "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2849 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2850 |
idx := codeIndex. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2851 |
codeBytes at:idx put:0. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2852 |
codeIndex := idx + 1 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2853 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2854 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2855 |
appendEmptyLong |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2856 |
"append an empty long (4 bytes) to the code-Array" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2857 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2858 |
|idx "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2859 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2860 |
idx := codeIndex. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2861 |
codeBytes at:idx put:0. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2862 |
codeBytes at:idx+1 put:0. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2863 |
codeBytes at:idx+2 put:0. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2864 |
codeBytes at:idx+3 put:0. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2865 |
codeIndex := idx + 4 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2866 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2867 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2868 |
appendEmptyShort |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2869 |
"append an empty short (2 bytes) to the code-Array" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2870 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2871 |
|idx "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2872 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2873 |
idx := codeIndex. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2874 |
codeBytes at:idx put:0. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2875 |
codeBytes at:idx+1 put:0. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2876 |
codeIndex := idx + 2 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2877 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2878 |
|
1792 | 2879 |
appendLongWord:aWord |
1815 | 2880 |
"append an unsigned long word (low-high) to the code-Array, |
1792 | 2881 |
checking for long word-range (debug-only)" |
2882 |
||
2883 |
|idx "{Class: SmallInteger }"| |
|
2884 |
||
2885 |
idx := codeIndex. |
|
2886 |
(aWord between:0 and:16rFFFFFFFF) ifTrue:[ |
|
3071 | 2887 |
codeBytes at:idx put:(aWord bitAnd:16rFF). |
2888 |
idx := idx + 1. |
|
2889 |
codeBytes at:idx put:((aWord bitShift:-8) bitAnd:16rFF). |
|
2890 |
idx := idx + 1. |
|
2891 |
codeBytes at:idx put:((aWord bitShift:-16) bitAnd:16rFF). |
|
2892 |
idx := idx + 1. |
|
2893 |
codeBytes at:idx put:((aWord bitShift:-24) bitAnd:16rFF). |
|
2894 |
codeIndex := idx + 1 |
|
1792 | 2895 |
] ifFalse:[ |
3071 | 2896 |
self codeGeneratorError:'long word range error'. |
1792 | 2897 |
] |
2898 |
! |
|
2899 |
||
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2900 |
appendSignedByte:aByte |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2901 |
"append a signedbyte (as in jump-offsets) to the code-Array, |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2902 |
check range and report an error if invalid" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2903 |
|
1815 | 2904 |
|b "{Class: SmallInteger }" |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2905 |
idx "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2906 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2907 |
idx := codeIndex. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2908 |
b := aByte. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2909 |
(b >= 0) ifTrue:[ |
3071 | 2910 |
(b > 127) ifTrue:[ |
2911 |
self codeGeneratorError:'jump-range error'. |
|
2912 |
]. |
|
2913 |
codeBytes at:idx put:b |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2914 |
] ifFalse:[ |
3071 | 2915 |
(b < -128) ifTrue:[ |
2916 |
self codeGeneratorError:'jump-range error'. |
|
2917 |
]. |
|
2918 |
b := 256 + b |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2919 |
]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2920 |
codeBytes at:idx put:b. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2921 |
codeIndex := idx + 1 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2922 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2923 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2924 |
appendSignedWord:aWord |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2925 |
"append a signed word to the code-Array, |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2926 |
check range and report an error if invalid" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2927 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2928 |
|w "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2929 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2930 |
w := aWord. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2931 |
(w >= 0) ifTrue:[ |
3071 | 2932 |
(w > 16r7FFFF) ifTrue:[ |
2933 |
self codeGeneratorError:'word-range error'. |
|
2934 |
]. |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2935 |
] ifFalse:[ |
3071 | 2936 |
(w < 16r-8000) ifTrue:[ |
2937 |
self codeGeneratorError:'word-range error'. |
|
2938 |
]. |
|
2939 |
w := (16r10000 + w). |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2940 |
]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2941 |
self appendWord:w |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2942 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2943 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2944 |
appendWord:aWord |
1815 | 2945 |
"append an unsigned word (low-high) to the code-Array, |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2946 |
checking for word-range (debug-only)" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2947 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2948 |
|idx "{Class: SmallInteger }"| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2949 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2950 |
idx := codeIndex. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2951 |
(aWord between:0 and:16rFFFF) ifTrue:[ |
3071 | 2952 |
codeBytes at:idx put:(aWord bitAnd:16rFF). |
2953 |
idx := idx + 1. |
|
2954 |
codeBytes at:idx put:(aWord bitShift:-8). |
|
2955 |
codeIndex := idx + 1 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2956 |
] ifFalse:[ |
3071 | 2957 |
self codeGeneratorError:'word range error'. |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2958 |
] |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2959 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2960 |
|
1999 | 2961 |
nameSpaceSelectorFor:aSymbol |
2962 |
"Caring for the current namespace, return the real selector used for a send." |
|
2963 |
||
2964 |
|ns usedSym| |
|
2965 |
||
2966 |
usedSym := aSymbol. |
|
2967 |
||
2968 |
Smalltalk hasSelectorNameSpaces ifTrue:[ |
|
2969 |
ns := self currentNameSpace. |
|
2970 |
(ns notNil and:[ns ~~ Smalltalk]) ifTrue:[ |
|
2971 |
usedSym := (':',ns name,'::',aSymbol) asSymbol. |
|
2972 |
Transcript showCR:'compile ',aSymbol,' as ',usedSym. |
|
2973 |
]. |
|
2974 |
]. |
|
2975 |
^ usedSym. |
|
2976 |
||
2977 |
"Created: / 05-03-2007 / 13:28:59 / cg" |
|
2978 |
! |
|
2979 |
||
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2980 |
removeTempVar |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2981 |
"remove a temporary variable" |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2982 |
|
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2983 |
numTemp := numTemp - 1 |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2984 |
|
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2985 |
"Created: 25.6.1997 / 14:03:00 / cg" |
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
2986 |
"Modified: 25.6.1997 / 15:06:10 / cg" |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2987 |
! ! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
2988 |
|
2714 | 2989 |
!ByteCodeCompiler methodsFor:'code generation hooks'! |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2990 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2991 |
startCodeGenerationHookOn:codeStream |
2714 | 2992 |
"invoked before code is generated; |
2993 |
gives subclasses a chance to prepare and to inject code to be |
|
2994 |
executed on entry (instrumentation)" |
|
2995 |
||
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2996 |
"intentionally left blank - hook for subclasses" |
2714 | 2997 |
|
2998 |
"Modified (comment): / 30-09-2011 / 12:16:40 / cg" |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
2999 |
! ! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3000 |
|
1363 | 3001 |
!ByteCodeCompiler methodsFor:'compilation'! |
3002 |
||
2735
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3003 |
compile:aString forClass:aClass inCategory:cat |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3004 |
"compile a source-string for a method in classToCompileFor. |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3005 |
The method will get cat as category. |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3006 |
Returns the new method, #Error or nil." |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3007 |
|
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3008 |
^ self |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3009 |
compile:aString |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3010 |
forClass:aClass |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3011 |
inCategory:cat |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3012 |
notifying:nil |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3013 |
install:true |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3014 |
skipIfSame:false |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3015 |
silent:false |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3016 |
foldConstants:true |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3017 |
|
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3018 |
"Created: / 30-09-2011 / 12:44:50 / cg" |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3019 |
! |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3020 |
|
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3021 |
compile:aStringArg forClass:aClassArg inCategory:cat notifying:aRequestor |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3022 |
install:install skipIfSame:skipIfSame silent:silent foldConstants:fold |
1363 | 3023 |
|
3532 | 3024 |
aRequestor notNil ifTrue:[ |
3025 |
^ self |
|
3026 |
compile:aStringArg |
|
3027 |
forClass:aClassArg |
|
3028 |
inCategory:cat |
|
3029 |
notifying:aRequestor |
|
3030 |
install:install |
|
3031 |
skipIfSame:skipIfSame |
|
3032 |
silent:silent |
|
3033 |
foldConstants:fold |
|
3034 |
ifFail:nil |
|
3035 |
]. |
|
3036 |
||
1459 | 3037 |
^ self |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3038 |
compile:aStringArg |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3039 |
forClass:aClassArg |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3040 |
inCategory:cat |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3041 |
notifying:aRequestor |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3042 |
install:install |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3043 |
skipIfSame:skipIfSame |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3044 |
silent:silent |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3045 |
foldConstants:fold |
3532 | 3046 |
ifFail:[:exOrNil | |
3047 |
exOrNil notNil ifTrue:[ |
|
3048 |
ParseError new |
|
3049 |
errorMessage:(exOrNil errorMessage) startPosition:(exOrNil startPosition) endPosition:(exOrNil endPosition); |
|
3050 |
parameter:exOrNil parameter; |
|
3051 |
lineNumber:exOrNil lineNumber; |
|
3052 |
raiseRequest. |
|
3580 | 3053 |
] ifFalse:[ |
3054 |
ParseError raiseRequestErrorString:'compilation failed'. #Error |
|
3532 | 3055 |
]. |
3580 | 3056 |
(install and:[selector notNil]) ifTrue:[ |
3057 |
|newMethod| |
|
3058 |
||
3059 |
"/ if proceeded, install a trap method |
|
3060 |
newMethod := (Method trapMethodForNumArgs:selector numArgs) copy. |
|
3061 |
newMethod mclass:nil; setPackage:nil. |
|
3062 |
newMethod makeInvalid. |
|
3063 |
newMethod source:aStringArg. |
|
3064 |
aClassArg basicAddSelector:selector withMethod:newMethod |
|
3065 |
]. |
|
3532 | 3066 |
] |
2469 | 3067 |
|
3068 |
"Modified: / 18-01-2011 / 11:35:21 / cg" |
|
1459 | 3069 |
! |
3070 |
||
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3071 |
compile:sourceCodeStringArg forClass:aClassArg inCategory:cat notifying:aRequestor |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3072 |
install:install skipIfSame:skipIfSame silent:silent foldConstants:fold |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3073 |
ifFail:failBlock |
1459 | 3074 |
|
1363 | 3075 |
"the basic workhorse method for compiling: |
3076 |
compile a source-string for a method in classToCompileFor. |
|
1815 | 3077 |
errors are forwarded to requestor |
1459 | 3078 |
(report on Transcript and return the value of failBlock, if requestor is nil). |
1363 | 3079 |
|
1815 | 3080 |
The new method will get cat as category. |
3081 |
If install is true, the method will go into the classes method-table, |
|
1363 | 3082 |
otherwise the method is simply returned (for anonymous methods). |
3083 |
If skipIsSame is true, and the source is the same as an existing |
|
3084 |
methods source, this is a noop (for fast fileIn). |
|
3085 |
The argument, silent controls if errors are to be reported. |
|
3086 |
Returns the method, #Error or nil." |
|
3087 |
||
1984 | 3088 |
|newMethod tree symbolicCodeArray oldMethod silencio newSource primNr keptOldCode answer |
1999 | 3089 |
aClass sourceCodeString hasErrorInMethodHeader oldCategory newCategory oldPackage |
3681 | 3090 |
newPackage installSelector ns dialogText failureReason annotationCategory| |
1363 | 3091 |
|
3092 |
aClass := aClassArg. |
|
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3093 |
sourceCodeString := sourceCodeStringArg. |
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3094 |
|
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3095 |
sourceCodeString isNil ifTrue:[^ nil]. |
1815 | 3096 |
silencio := silent |
1984 | 3097 |
or:[Smalltalk silentLoading |
3098 |
or:[ListCompiledMethods not]]. |
|
1363 | 3099 |
|
3284 | 3100 |
"/ when a correction has been made, this signal is raised to try again |
3397 | 3101 |
self class restartCompilationSignal handle:[:ex | |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3102 |
"/ class could have changed ... |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3103 |
aClass := self classToCompileFor. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3104 |
sourceCodeString := self correctedSource ? sourceCodeStringArg. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3105 |
methodArgs := methodArgNames := methodVars := methodVarNames := nil. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3106 |
usedInstVars := usedClassVars := usedVars := nil. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3107 |
modifiedInstVars := modifiedClassVars := modifiedGlobals := nil. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3108 |
currentBlock := nil. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3109 |
ex restart |
1363 | 3110 |
] do:[ |
3531 | 3111 |
ParseError handle:[:ex | |
3112 |
failBlock isNil ifTrue:[ |
|
3113 |
ex reject |
|
3114 |
]. |
|
3115 |
self showErrorMessageForClass:aClass. |
|
3532 | 3116 |
^ failBlock valueWithOptionalArgument:ex. |
3531 | 3117 |
] do:[ |
3118 |
"create a compiler, let it parse and create the parsetree" |
|
3119 |
||
3731 | 3120 |
sourceCodeString isString ifTrue:[ |
3121 |
self source:(ReadStream on:sourceCodeString string). |
|
3122 |
] ifFalse:[ |
|
3123 |
self source:sourceCodeString readStream |
|
3124 |
]. |
|
3531 | 3125 |
self nextToken. |
3126 |
||
3127 |
self setClassToCompileFor:aClass. |
|
3128 |
||
3129 |
self parseForCode. |
|
3130 |
fold ifFalse:[self foldConstants:nil]. |
|
3131 |
self notifying:aRequestor. |
|
3132 |
silent ifTrue:[ |
|
3133 |
"/ self ignoreErrors:true. |
|
3134 |
self ignoreWarnings:true. |
|
3135 |
self warnUndeclared:false. |
|
3136 |
]. |
|
3137 |
||
3138 |
hasErrorInMethodHeader := (self parseMethodSpec == #Error). |
|
3139 |
hasErrorInMethodHeader ifTrue:[ |
|
3140 |
self parseError:'syntax error in method specification'. |
|
3141 |
tree := #Error. |
|
3142 |
] ifFalse:[ |
|
3143 |
tree := self parseMethodBody. |
|
3144 |
tree == #Error ifFalse:[ |
|
3145 |
self checkForEndOfInput. |
|
3146 |
self tree:tree. |
|
3147 |
]. |
|
3043 | 3148 |
]. |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3149 |
]. |
1363 | 3150 |
]. |
3151 |
||
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3152 |
hasErrorInMethodHeader ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3153 |
self showErrorMessageForClass:aClass. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3154 |
^ failBlock value. |
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3155 |
]. |
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3156 |
|
1378
01bd44f4360c
allow compiling a method for a nil class
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3157 |
(aClass notNil and:[selector notNil]) ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3158 |
oldMethod := aClass compiledMethodAt:selector. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3159 |
oldMethod notNil ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3160 |
oldCategory := oldMethod category. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3161 |
oldPackage := oldMethod package. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3162 |
]. |
1363 | 3163 |
]. |
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3164 |
|
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3165 |
(aClass notNil and:[aClass owningClass notNil |
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3166 |
and:[parserFlags allowExtensionsToPrivateClasses not]]) ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3167 |
"inherit private classe's package from owning class" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3168 |
newPackage := aClass owningClass package |
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3169 |
] ifFalse:[ |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3170 |
(aRequestor respondsTo:#packageToInstall) ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3171 |
"if there is an requestor who knows about the package, use it" |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3172 |
newPackage := aRequestor packageToInstall |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3173 |
] ifFalse:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3174 |
"if noone answers our package query, do not use the default |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3175 |
but use an existing method's package instead" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3176 |
(oldPackage isNil or:[Class packageQuerySignal isHandled]) ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3177 |
newPackage := Class packageQuerySignal query. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3178 |
] ifFalse:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3179 |
newPackage := oldPackage. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3180 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3181 |
]. |
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3182 |
]. |
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3183 |
|
1363 | 3184 |
newCategory := cat. |
3185 |
newCategory isNil ifTrue:[ |
|
3281 | 3186 |
newCategory := oldCategory ? (self class asYetUncategorizedMethodCategory). |
1363 | 3187 |
]. |
3188 |
||
1790 | 3189 |
"check if same source" |
4289 | 3190 |
(skipIfSame and:[oldMethod notNil and:[oldMethod source = sourceCodeString]]) ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3191 |
oldMethod isInvalid ifFalse:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3192 |
silencio ifFalse:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3193 |
Transcript showCR:(' unchanged: ',aClass name,' ',selector) |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3194 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3195 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3196 |
same. however, category may be different |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3197 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3198 |
(newCategory ~= oldCategory) ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3199 |
oldMethod category:newCategory. |
1790 | 3200 |
"/ aClass updateRevisionString. |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3201 |
silencio ifFalse:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3202 |
Transcript showCR:(' (category change only)') |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3203 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3204 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3205 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3206 |
and package may be too. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3207 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3208 |
(newPackage notNil and:[newPackage ~~ oldPackage]) ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3209 |
oldMethod package:newPackage. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3210 |
silencio ifFalse:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3211 |
Transcript showCR:(' (package-id change only)') |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3212 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3213 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3214 |
^ oldMethod |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3215 |
] |
1363 | 3216 |
]. |
3217 |
||
3218 |
(self errorFlag or:[tree == #Error]) ifTrue:[ |
|
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3219 |
"error in method body" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3220 |
self showErrorMessageForClass:aClass. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3221 |
^ failBlock value |
1363 | 3222 |
]. |
3223 |
||
3224 |
"if no error and also no selector ..." |
|
3225 |
selector isNil ifTrue:[ |
|
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3226 |
"... it was just a comment or other empty stuff" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3227 |
^ nil |
1363 | 3228 |
]. |
3229 |
||
3230 |
" |
|
3231 |
freak-out support for inline C-code... |
|
3232 |
" |
|
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3233 |
NewPrimitives ifFalse:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3234 |
((self hasNonOptionalPrimitiveCode |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3235 |
or:[(self hasPrimitiveCode and:[self class canCreateMachineCode]) |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3236 |
or:[ParserFlags stcCompilation == #always and:[selector ~~ #doIt]]]) |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3237 |
and:[(ParserFlags stcCompilation ~~ #never)]) ifTrue:[ |
3071 | 3238 |
ParseError handle:[:ex | |
4020 | 3239 |
self parseError:(ex description) line:(ex lineNumber ? 1). |
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3240 |
newMethod := #Error. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3241 |
] do:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3242 |
newMethod := |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3243 |
(STCCompilerInterface new |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3244 |
originator:self; |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3245 |
parserFlags:parserFlags) |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3246 |
compileToMachineCode:sourceCodeString |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3247 |
forClass:aClass |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3248 |
selector:selector |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3249 |
inCategory:cat |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3250 |
notifying:aRequestor |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3251 |
install:install |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3252 |
skipIfSame:skipIfSame |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3253 |
silent:silent. |
2462
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3254 |
]. |
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3255 |
|
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3256 |
newMethod == #Error ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3257 |
self showErrorMessageForClass:aClass. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3258 |
"/^ failBlock value |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3259 |
]. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3260 |
|
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3261 |
(newMethod == #CannotLoad or:[newMethod == #Error]) ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3262 |
failureReason := newMethod. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3263 |
newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3264 |
newMethod setPackage:newPackage. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3265 |
keptOldCode := false. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3266 |
install ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3267 |
"/ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3268 |
"/ be very careful with existing methods |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3269 |
"/ (otherwise, you could easily make your system unusable in systems which cannot load) |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3270 |
"/ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3271 |
(oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3272 |
failureReason == #Error ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3273 |
dialogText := |
2462
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3274 |
'STC-compilation of ''%1>>%2'' |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3275 |
to machine code failed . |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3276 |
|
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3277 |
Shall I use the old methods functionality |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3278 |
or instead create a dummy trap method for it ? |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3279 |
|
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3280 |
Hint: |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3281 |
if that method is needed by the system, you better leave the |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3282 |
original functionality in the system. |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3283 |
|
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3284 |
Close this warnBox to abort the compilation. |
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3285 |
' |
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3286 |
] ifFalse:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3287 |
dialogText := |
2462
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3288 |
'installation of binary code for ''%1>>%2'' |
1363 | 3289 |
is not possible or disabled. |
3290 |
||
3514 | 3291 |
Shall I use the old method''s functionality |
1363 | 3292 |
or instead create a dummy trap method for it ? |
3293 |
||
3294 |
Hint: |
|
3295 |
if that method is needed by the system, you better leave the |
|
3296 |
original functionality in the system. |
|
3297 |
||
3298 |
Close this warnBox to abort the compilation. |
|
3299 |
' |
|
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3300 |
]. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3301 |
answer := Dialog |
3514 | 3302 |
confirmWithCancel:(dialogText bindWith:aClass name allBold with:selector allBold) |
3303 |
labels:#('Cancel' 'Keep Old' 'Trap Code') |
|
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3304 |
default:2. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3305 |
answer isNil ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3306 |
^ failBlock value |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3307 |
]. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3308 |
answer == false ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3309 |
newMethod code:(oldMethod code). |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3310 |
keptOldCode := true. |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3311 |
]. |
2462
02ed895be692
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Stefan Vogel <sv@exept.de>
parents:
2428
diff
changeset
|
3312 |
]. |
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3313 |
aClass addSelector:selector withMethod:newMethod |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3314 |
]. |
3112 | 3315 |
(install or:[failureReason ~~ #CannotLoad]) ifTrue:[ |
3316 |
"when compiling with STC andn install is false, #CannotLoad is always returned" |
|
3317 |
self showErrorNotification:(keptOldCode |
|
3318 |
ifTrue:['not really compiled - method still shows previous behavior'] |
|
3319 |
ifFalse:['not compiled to machine code - created a stub instead.']) |
|
3320 |
]. |
|
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3321 |
]. |
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3322 |
^ newMethod |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3323 |
]. |
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3324 |
|
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3325 |
self hasNonOptionalPrimitiveCode ifTrue:[ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3326 |
"/ |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3327 |
"/ generate a trapping method, if primitive code is present |
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3328 |
"/ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3329 |
newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3330 |
install ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3331 |
aClass addSelector:selector withMethod:newMethod. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3332 |
]. |
2938 | 3333 |
self showErrorNotification:'not compiled to machine code - installed a stub instead.'. |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3334 |
^ newMethod |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3335 |
]. |
1363 | 3336 |
]. |
3337 |
||
3338 |
primNr := self primitiveNumber. |
|
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3339 |
(NewPrimitives or:[primNr isNil]) ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3340 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3341 |
produce symbolic code first |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3342 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3343 |
symbolicCodeArray := self genSymbolicCode. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3344 |
(symbolicCodeArray == #Error) ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3345 |
self showErrorNotification:'translation error'. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3346 |
^ failBlock value |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3347 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3348 |
|
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3349 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3350 |
take this, producing bytecode |
3071 | 3351 |
(machine code will be made by the VM when first called) |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3352 |
" |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3353 |
((self genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3354 |
self showErrorNotification:'relocation error - code must be simplified'. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3355 |
^ failBlock value |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3356 |
]. |
1363 | 3357 |
]. |
3358 |
||
3359 |
" |
|
3360 |
finally create the new method-object |
|
3361 |
" |
|
3362 |
newMethod := self createMethod. |
|
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3363 |
NewPrimitives ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3364 |
newMethod byteCode:(self code). |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3365 |
primNr isNil ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3366 |
self hasNonOptionalPrimitiveCode ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3367 |
primNr := 0. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3368 |
] |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3369 |
]. |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3370 |
primNr notNil ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3371 |
newMethod setPrimitiveNumber:primNr |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3372 |
] |
1363 | 3373 |
] ifFalse:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3374 |
primNr notNil ifTrue:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3375 |
newMethod code:(self checkForPrimitiveCode:primNr). |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3376 |
] ifFalse:[ |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3377 |
newMethod byteCode:(self code). |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3378 |
]. |
1363 | 3379 |
]. |
3380 |
||
3381 |
" |
|
3382 |
if there where any corrections, install the updated source |
|
3383 |
" |
|
3384 |
(newSource := self correctedSource) isNil ifTrue:[ |
|
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3385 |
newSource := sourceCodeString string. |
1363 | 3386 |
]. |
3387 |
(newSource includes:Character return) ifTrue:[ |
|
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3388 |
"/ see if it contains crlf's or only cr's |
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3389 |
newSource := self class stringWithSimpleCRs:newSource |
1363 | 3390 |
]. |
3178 | 3391 |
newMethod source:newSource string. |
3681 | 3392 |
(newMethod hasAnnotation: #'category:') ifTrue:[ |
3393 |
annotationCategory := (newMethod annotationAt:#'category:') argumentAt:1. |
|
3394 |
annotationCategory isString ifTrue:[ |
|
3395 |
newCategory := annotationCategory |
|
3396 |
]. |
|
3397 |
]. |
|
1363 | 3398 |
newMethod setCategory:newCategory. |
1730
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3399 |
newMethod setPackage:newPackage. |
f8121ec9a7dd
Keep package when recompiling an existant method and no explicit
Stefan Vogel <sv@exept.de>
parents:
1671
diff
changeset
|
3400 |
|
1363 | 3401 |
(self contextMustBeReturnable) ifTrue:[ |
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3402 |
newMethod contextMustBeReturnable:true |
1363 | 3403 |
]. |
3404 |
install ifTrue:[ |
|
1999 | 3405 |
installSelector := selector. |
3406 |
"/ when adding an extension, care for the current namespace |
|
3407 |
ns := self currentNameSpace. |
|
3408 |
(ns notNil and:[ns ~~ Smalltalk]) ifTrue:[ |
|
3409 |
ns ~~ aClass nameSpace ifTrue:[ |
|
3410 |
installSelector := self nameSpaceSelectorFor:(selector asSymbol). |
|
3411 |
] |
|
3412 |
]. |
|
3413 |
||
3414 |
aClass addSelector:installSelector withMethod:newMethod |
|
1363 | 3415 |
]. |
3416 |
||
3417 |
silencio ifFalse:[ |
|
1955
487f483ef4ce
the method does the change-file-update; NOT me
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
3418 |
Transcript showCR:(' compiled: ', aClass name,' ', selector) |
1363 | 3419 |
]. |
3420 |
||
3421 |
^ newMethod |
|
3422 |
||
1790 | 3423 |
"Created: / 29-10-1995 / 19:59:36 / cg" |
3424 |
"Modified: / 19-03-1999 / 08:31:09 / stefan" |
|
2536
62a35499ff1d
changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:ifFail:
Claus Gittinger <cg@exept.de>
parents:
2502
diff
changeset
|
3425 |
"Modified: / 05-07-2011 / 22:50:36 / cg" |
1363 | 3426 |
! |
3427 |
||
1778 | 3428 |
compile:methodText forClass:aBehavior install:doInstall |
3429 |
"compile a source-string for a method in classToCompileFor. |
|
3430 |
The install-argument controls if the method is to be installed into the |
|
3431 |
classes method-dictionary, or just to be compiled and a method object to be returned. |
|
3432 |
Returns the new method, #Error or nil." |
|
3433 |
||
1815 | 3434 |
^ self |
3281 | 3435 |
compile:methodText |
3436 |
forClass:aBehavior |
|
3437 |
inCategory:(self class defaultMethodCategory) |
|
3438 |
notifying:nil |
|
3439 |
install:doInstall |
|
3440 |
skipIfSame:false |
|
3441 |
silent:false |
|
3442 |
foldConstants:true |
|
3443 |
ifFail:[ #Error ] |
|
1778 | 3444 |
|
3445 |
"Created: / 17-07-2006 / 18:44:53 / cg" |
|
3446 |
! |
|
3447 |
||
3416 | 3448 |
compileTree:aTree forClass:aClass |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3449 |
"given an already parsed AST, generate code and return a method" |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3450 |
|
3416 | 3451 |
|newMethod| |
1790 | 3452 |
|
3453 |
self tree:aTree. |
|
3454 |
||
3455 |
newMethod := self createMethod. |
|
3456 |
newMethod byteCode:(self code). |
|
3457 |
||
3458 |
(self contextMustBeReturnable) ifTrue:[ |
|
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3459 |
newMethod contextMustBeReturnable:true |
1790 | 3460 |
]. |
3461 |
||
3462 |
^ newMethod |
|
3463 |
||
3464 |
"Modified: / 19-03-1999 / 08:31:09 / stefan" |
|
3465 |
"Created: / 06-08-2006 / 03:25:39 / cg" |
|
3466 |
! |
|
3467 |
||
3416 | 3468 |
compileTree:aMethodNode forClass:aClass ifFail:failBlock |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3469 |
"given an already parsed AST, generate code and return a method" |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3470 |
|
3416 | 3471 |
|newMethod symbolicCodeArray| |
1790 | 3472 |
|
3473 |
self tree:aMethodNode. |
|
3474 |
||
3475 |
selector := aMethodNode selector. |
|
3476 |
methodArgs := aMethodNode arguments ? #(). |
|
3477 |
methodArgNames := methodArgs collect:[:eachVar | eachVar name]. |
|
3478 |
methodVars := aMethodNode locals ? #(). |
|
3479 |
methodVarNames := methodVars collect:[:eachVar | eachVar name]. |
|
3480 |
||
3481 |
" |
|
3482 |
produce symbolic code first |
|
3483 |
" |
|
3484 |
symbolicCodeArray := self genSymbolicCode. |
|
3071 | 3485 |
(symbolicCodeArray == #Error) ifTrue:[ "/ no longer happens |
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3486 |
self showErrorNotification:'translation error'. |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3487 |
^ failBlock value |
1790 | 3488 |
]. |
3489 |
||
3490 |
" |
|
1815 | 3491 |
take this, producing bytecode |
1790 | 3492 |
(someone willin' to make machine code :-) |
3493 |
" |
|
3494 |
((self genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[ |
|
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3495 |
self showErrorNotification:'relocation error - code must be simplified'. |
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3496 |
^ failBlock value |
1790 | 3497 |
]. |
3498 |
||
3499 |
newMethod := self createMethod. |
|
3500 |
newMethod byteCode:(self code). |
|
3501 |
||
3502 |
(self contextMustBeReturnable) ifTrue:[ |
|
2091
18bcd32044c0
preparations for breakpointed lines
Claus Gittinger <cg@exept.de>
parents:
2084
diff
changeset
|
3503 |
newMethod contextMustBeReturnable:true |
1790 | 3504 |
]. |
3505 |
||
3506 |
^ newMethod |
|
3507 |
||
3508 |
"Modified: / 19-03-1999 / 08:31:09 / stefan" |
|
3509 |
"Created: / 06-08-2006 / 03:26:27 / cg" |
|
3510 |
"Modified: / 06-08-2006 / 15:14:26 / cg" |
|
3511 |
! |
|
3512 |
||
1363 | 3513 |
showErrorNotification:message |
2938 | 3514 |
|messageText| |
3515 |
||
3516 |
messageText := message. |
|
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3517 |
selector notNil ifTrue:[ |
2938 | 3518 |
messageText := selector ,' ', messageText. |
2936
cd787e6ed225
comment/format in: #showErrorNotification:
Stefan Vogel <sv@exept.de>
parents:
2868
diff
changeset
|
3519 |
]. |
2938 | 3520 |
|
3521 |
self class parseWarningSignal isHandled ifTrue:[ |
|
3522 |
self class parseWarningSignal new |
|
3523 |
errorMessage:messageText; |
|
3524 |
parameter:self; |
|
3525 |
raiseRequest. |
|
3526 |
] ifFalse:[ |
|
3527 |
Transcript show:'***'. |
|
3528 |
Transcript showCR:messageText. |
|
3529 |
]. |
|
1363 | 3530 |
! ! |
3531 |
||
3071 | 3532 |
!ByteCodeCompiler methodsFor:'error handling'! |
3533 |
||
3534 |
codeGeneratorError:aMessage |
|
3535 |
CompilationError raiseRequestWith:self errorString:aMessage. |
|
3451 | 3536 |
errorFlag := true. |
3071 | 3537 |
^ #Error |
3538 |
! ! |
|
3539 |
||
49 | 3540 |
!ByteCodeCompiler methodsFor:'machine code generation'! |
3541 |
||
97 | 3542 |
trappingStubMethodFor:aString inCategory:cat |
3543 |
"return a stub method which traps and reports an error whenever |
|
3544 |
called." |
|
3545 |
||
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
3546 |
|newMethod| |
97 | 3547 |
|
1094
745ec90c42c9
allow parametrizing the method class
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
3548 |
newMethod := self methodClass new:(litArray size). |
292
163651658aee
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
287
diff
changeset
|
3549 |
litArray notNil ifTrue:[ |
3648 | 3550 |
newMethod literals:litArray |
97 | 3551 |
]. |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3552 |
|
124 | 3553 |
newMethod makeUncompiled. |
594
11ae33ac9b34
finally replaced all sends of #numberOfMethodVars with #numerOfVars
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
3554 |
newMethod numberOfVars:(self numberOfMethodVars). |
3648 | 3555 |
newMethod numberOfArgs:(self numberOfMethodArgs). |
682 | 3556 |
newMethod source:aString string. |
1117
f03c007dadc6
methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents:
1113
diff
changeset
|
3557 |
newMethod setCategory:cat. |
97 | 3558 |
^ newMethod |
277
0b599e23a936
set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3559 |
|
831
9ad749e60f55
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
810
diff
changeset
|
3560 |
"Modified: / 1.8.1997 / 00:27:32 / cg" |
9ad749e60f55
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
810
diff
changeset
|
3561 |
"Modified: / 18.3.1999 / 18:12:33 / stefan" |
49 | 3562 |
! ! |
128
61eb0b356b89
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
3563 |
|
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3564 |
!ByteCodeCompiler methodsFor:'queries'! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3565 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3566 |
hasLineNumber:sel |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3567 |
"return true, if special send code needs lineNr" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3568 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3569 |
(sel == #==) ifTrue:[^ false]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3570 |
(sel == #~~) ifTrue:[^ false]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3571 |
(sel == #class) ifTrue:[^ false]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3572 |
(sel == #isNil) ifTrue:[^ false]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3573 |
(sel == #notNil) ifTrue:[^ false]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3574 |
^ true |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3575 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3576 |
|
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3577 |
isBuiltInSelector:sel forReceiver:receiver |
1815 | 3578 |
"return true, if selector sel is built-in. |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3579 |
(i.e. there is a single bytecode for it)" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3580 |
|
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3581 |
(sel == #value) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3582 |
(sel == #value:) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3583 |
(sel == #class) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3584 |
(sel == #size) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3585 |
(sel == #isNil) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3586 |
(sel == #notNil) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3587 |
(sel == #not) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3588 |
|
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3589 |
(sel == #new) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3590 |
(sel == #basicNew) ifTrue:[ |
1815 | 3591 |
"/ this one is critical - some redefine it |
3592 |
receiver isGlobal ifTrue:[ |
|
3593 |
(#('String' 'ByteArray' 'Array' |
|
3594 |
'Point' 'Rectangle' 'Object') |
|
3595 |
includes:receiver name) ifTrue:[^ true]. |
|
3596 |
]. |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3597 |
]. |
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3598 |
(sel == #basicNew:) ifTrue:[ |
1815 | 3599 |
"/ this one is critical - some redefine it |
3600 |
receiver isGlobal ifTrue:[ |
|
3601 |
(#('String' 'ByteArray' 'Array' |
|
3602 |
'Point' 'Rectangle' 'Object') |
|
3603 |
includes:receiver name) ifTrue:[^ true]. |
|
3604 |
]. |
|
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3605 |
]. |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3606 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3607 |
sel == #== ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3608 |
sel == #~~ ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3609 |
sel == #= ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3610 |
sel == #~= ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3611 |
sel == #+ ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3612 |
sel == #- ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3613 |
sel == #< ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3614 |
sel == #<= ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3615 |
sel == #> ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3616 |
sel == #>= ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3617 |
sel == #* ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3618 |
sel == #& ifTrue:[^ true]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3619 |
sel == #| ifTrue:[^ true]. |
1810
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3620 |
|
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3621 |
(sel == #at:) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3622 |
(sel == #at:put:) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3623 |
(sel == #bitAnd:) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3624 |
(sel == #bitOr:) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3625 |
(sel == #new:) ifTrue:[^ true]. |
977902a043fe
tuned commin literal detection code
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
3626 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3627 |
^ false |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3628 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3629 |
"Created: 17.4.1996 / 22:32:16 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3630 |
"Modified: 4.6.1997 / 12:23:30 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3631 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3632 |
|
2084
a30b2599d2a5
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2048
diff
changeset
|
3633 |
isCompiling |
a30b2599d2a5
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2048
diff
changeset
|
3634 |
"return true if compiling code as opposed to evaluating" |
a30b2599d2a5
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2048
diff
changeset
|
3635 |
|
a30b2599d2a5
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2048
diff
changeset
|
3636 |
^ true |
a30b2599d2a5
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2048
diff
changeset
|
3637 |
! |
a30b2599d2a5
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2048
diff
changeset
|
3638 |
|
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3639 |
numberOfTempVars |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3640 |
"return the number of additional temporary variables which |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3641 |
were created from inlined blocks (valid after parsing)" |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3642 |
|
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
3643 |
^ maxNumTemp ? 0 |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3644 |
|
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3645 |
"Created: 25.6.1997 / 13:54:29 / cg" |
558
e7ecd861b86f
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
556
diff
changeset
|
3646 |
"Modified: 25.6.1997 / 15:21:34 / cg" |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3647 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3648 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3649 |
specialGlobalCodeFor:aSymbol |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3650 |
"codeExtension for globals, |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3651 |
which can be accessed by specialGlobal opCode" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3652 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3653 |
|idx| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3654 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3655 |
idx := self specialGlobals identityIndexOf:aSymbol ifAbsent:nil. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3656 |
idx isNil ifTrue:[^ idx]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3657 |
^ idx - 1. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3658 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3659 |
"Modified: 4.6.1997 / 12:31:22 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3660 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3661 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3662 |
specialGlobals |
1815 | 3663 |
"list of globals which can be accessed by specialGlobal opCode; |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3664 |
adding any here requires a new VM (i.e. you cannot change it)" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3665 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3666 |
^ #( |
3661 | 3667 |
#Array "/ 0 |
3668 |
#String "/ 1 |
|
3669 |
#FloatArray "/ 2 |
|
3670 |
#DoubleArray "/ 3 |
|
3671 |
#Point "/ 4 |
|
3672 |
#Symbol "/ 5 |
|
3673 |
#Smalltalk "/ 6 |
|
3674 |
#Processor "/ 7 |
|
3675 |
#SmallInteger "/ 8 |
|
3676 |
#Character "/ 9 |
|
3677 |
#Float "/ 10 |
|
3678 |
#Process "/ 11 |
|
3679 |
#Set "/ 12 |
|
3680 |
#IdentitySet "/ 13 |
|
3681 |
#Dictionary "/ 14 |
|
3682 |
#IdentityDictionary "/ 15 |
|
3683 |
#Semaphore "/ 16 |
|
3684 |
#OrderedCollection "/ 17 |
|
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3685 |
) |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3686 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3687 |
"Created: 4.6.1997 / 12:17:47 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3688 |
"Modified: 4.6.1997 / 12:31:35 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3689 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3690 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3691 |
specialSendCodeFor:sel |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3692 |
"return the codeExtension for sends, |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3693 |
which can be performed by specialSend opCode" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3694 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3695 |
|idx| |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3696 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3697 |
idx := self specialSends identityIndexOf:sel ifAbsent:nil. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3698 |
idx isNil ifTrue:[^ idx]. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3699 |
^ idx - 1. |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3700 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3701 |
"Modified: 4.6.1997 / 12:31:08 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3702 |
! |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3703 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3704 |
specialSends |
1815 | 3705 |
"list of selectors which can be sent by specialSend opCode; |
1738
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3706 |
adding any here requires a new VM (i.e. you cannot change it)" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3707 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3708 |
^ #( |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3709 |
#top "/ 0 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3710 |
#bottom "/ 1 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3711 |
#left "/ 2 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3712 |
#right "/ 3 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3713 |
#x "/ 4 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3714 |
#y "/ 5 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3715 |
#width "/ 6 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3716 |
#height "/ 7 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3717 |
#origin "/ 8 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3718 |
#extent "/ 9 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3719 |
#asInteger "/ 10 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3720 |
#rounded "/ 11 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3721 |
#next "/ 12 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3722 |
#peek "/ 13 |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3723 |
) |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3724 |
|
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3725 |
"Created: 4.6.1997 / 12:20:28 / cg" |
48362e8eb2d4
hooks for instrumenting compiler
Claus Gittinger <cg@exept.de>
parents:
1730
diff
changeset
|
3726 |
"Modified: 4.6.1997 / 12:31:56 / cg" |
556
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3727 |
! ! |
4a3775ada5d2
preps to move variables of inlined blocks into outer context
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
3728 |
|
372
98da4d230a8d
prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
3729 |
!ByteCodeCompiler class methodsFor:'documentation'! |
148 | 3730 |
|
2735
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3731 |
version |
3648 | 3732 |
^ '$Header$' |
2735
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3733 |
! |
1989b1b9173a
added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
3734 |
|
2502 | 3735 |
version_CVS |
3648 | 3736 |
^ '$Header$' |
2337 | 3737 |
! |
3738 |
||
2502 | 3739 |
version_SVN |
3161 | 3740 |
^ '$ Id $' |
148 | 3741 |
! ! |
1324 | 3742 |
|
3043 | 3743 |
|
209
b858b6a6880f
compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
3744 |
ByteCodeCompiler initialize! |