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