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