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