author | Claus Gittinger <cg@exept.de> |
Sun, 03 May 2020 13:20:12 +0200 | |
changeset 25379 | 609d492f29a7 |
parent 25193 | d30e6d550796 |
permissions | -rw-r--r-- |
23415 | 1 |
"{ Encoding: utf8 }" |
2 |
||
8728 | 3 |
" |
4 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
6844 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
18351 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
6844 | 18 |
nil subclass:#ProtoObject |
19 |
instanceVariableNames:'' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
6912 | 22 |
category:'Kernel-Objects' |
6844 | 23 |
! |
24 |
||
25 |
!ProtoObject class methodsFor:'documentation'! |
|
26 |
||
8728 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
6844 | 41 |
documentation |
42 |
" |
|
43 |
a minimum object without much protocol; |
|
7659 | 44 |
Provides the minimum required to prevent inspectors from crashing, |
45 |
and debuggers from blocking. |
|
46 |
(i.e. instead of inheriting from nil, better inherit from this). |
|
47 |
||
6844 | 48 |
Named after a similar class found in Dolphin-Smalltalk. |
49 |
||
50 |
[author:] |
|
51 |
Claus Gittinger (not much authoring, though) |
|
52 |
" |
|
53 |
! ! |
|
54 |
||
21076 | 55 |
!ProtoObject class methodsFor:'helpers'! |
56 |
||
57 |
shallowCopyOf:anObject |
|
58 |
"return a copy of anObject with shared subobjects (a shallow copy) |
|
59 |
i.e. the copy shares referenced instvars with its original." |
|
60 |
||
61 |
%{ /* NOCONTEXT */ |
|
62 |
int ninsts, spc, sz; |
|
63 |
OBJ theCopy; |
|
64 |
OBJ cls = __qClass(anObject); |
|
65 |
int flags = __intVal(__ClassInstPtr(cls)->c_flags); |
|
66 |
||
67 |
/* |
|
68 |
* bail out for special objects .. |
|
69 |
*/ |
|
70 |
if (((flags & ~ARRAYMASK) == 0) |
|
71 |
&& ((flags & ARRAYMASK) != WKPOINTERARRAY)) { |
|
72 |
sz = __qSize(anObject); |
|
73 |
__PROTECT__(anObject); |
|
74 |
__qNew(theCopy, sz); /* OBJECT ALLOCATION */ |
|
75 |
__UNPROTECT__(anObject); |
|
76 |
if (theCopy) { |
|
77 |
cls = __qClass(anObject); |
|
78 |
spc = __qSpace(theCopy); |
|
79 |
||
80 |
theCopy->o_class = cls; __STORE_SPC(theCopy, cls, spc); |
|
81 |
||
82 |
sz = sz - OHDR_SIZE; |
|
83 |
if (sz) { |
|
84 |
char *src, *dst; |
|
85 |
||
86 |
src = (char *)(__InstPtr(anObject)->i_instvars); |
|
87 |
dst = (char *)(__InstPtr(theCopy)->i_instvars); |
|
88 |
#ifdef bcopy4 |
|
89 |
{ |
|
90 |
/* care for odd-number of longs */ |
|
91 |
int nW = sz >> 2; |
|
92 |
||
93 |
if (sz & 3) { |
|
94 |
nW++; |
|
95 |
} |
|
96 |
||
97 |
bcopy4(src, dst, nW); |
|
98 |
} |
|
99 |
#else |
|
100 |
bcopy(src, dst, sz); |
|
101 |
#endif |
|
102 |
||
103 |
flags &= ARRAYMASK; |
|
104 |
if (flags == POINTERARRAY) { |
|
105 |
ninsts = __BYTES2OBJS__(sz); |
|
106 |
} else { |
|
107 |
ninsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
108 |
} |
|
109 |
if (ninsts) { |
|
110 |
do { |
|
111 |
OBJ el; |
|
112 |
||
113 |
el = __InstPtr(theCopy)->i_instvars[ninsts-1]; |
|
114 |
__STORE_SPC(theCopy, el, spc); |
|
115 |
} while (--ninsts); |
|
116 |
} |
|
117 |
} |
|
118 |
RETURN (theCopy); |
|
119 |
} |
|
120 |
} |
|
121 |
%}. |
|
122 |
"/ fallBack for special objects & memoryAllocation failure case |
|
123 |
||
21079 | 124 |
^ self error:'ProtoObject>>#shallowCopyOf: failed' |
125 |
! ! |
|
126 |
||
21085 | 127 |
!ProtoObject methodsFor:'error handling'! |
128 |
||
129 |
doesNotUnderstand:aMessage |
|
130 |
"this message is sent by the runtime system (VM) when |
|
131 |
a message is not understood by some object (i.e. there |
|
132 |
is no method for that selector). The original message has |
|
133 |
been packed into aMessage (i.e. the receiver, selector and |
|
134 |
any arguments) and the original receiver is then sent the |
|
135 |
#doesNotUnderstand: message. |
|
136 |
Here, we raise another signal which usually enters the debugger. |
|
137 |
You can of course redefine #doesNotUnderstand: in your classes |
|
138 |
to implement message delegation, |
|
139 |
or handle the MessageNotUnderstood exception gracefully." |
|
140 |
||
141 |
<context: #return> |
|
142 |
||
143 |
^ MessageNotUnderstood raiseRequestWith:aMessage |
|
144 |
! ! |
|
145 |
||
146 |
!ProtoObject methodsFor:'inspecting'! |
|
21079 | 147 |
|
22385 | 148 |
basicInspect |
21079 | 149 |
"this method is required to allow inspection of the object" |
150 |
||
22385 | 151 |
^ (Object compiledMethodAt:#basicInspect) |
21079 | 152 |
valueWithReceiver:self |
153 |
arguments:nil |
|
22385 | 154 |
selector:#basicInspect |
155 |
||
156 |
"Created: / 28-11-2017 / 19:23:47 / stefan" |
|
157 |
! |
|
158 |
||
159 |
inspect |
|
160 |
"{ Pragma: +optSpace }" |
|
161 |
||
162 |
"launch an inspector on the receiver. |
|
163 |
this method (or better: inspectorClass) can be redefined in subclasses |
|
164 |
to start special inspectors." |
|
165 |
||
166 |
|cls| |
|
167 |
||
168 |
cls := self inspectorClass. |
|
169 |
cls isNil ifTrue:[ |
|
170 |
self basicInspect. |
|
171 |
^ self. |
|
172 |
]. |
|
173 |
cls openOn:self |
|
174 |
||
175 |
" |
|
176 |
ProtoObject new inspect |
|
177 |
" |
|
178 |
||
179 |
"Modified: / 29-11-2017 / 10:39:38 / stefan" |
|
180 |
! |
|
181 |
||
182 |
inspectorClass |
|
25182 | 183 |
^ Object new inspectorClass |
22385 | 184 |
|
185 |
"Created: / 29-11-2017 / 10:20:09 / stefan" |
|
23415 | 186 |
"Modified: / 10-10-2018 / 00:43:48 / Claus Gittinger" |
21079 | 187 |
! |
188 |
||
189 |
instVarAt:index |
|
190 |
"this method is required to allow inspection of the object" |
|
191 |
||
192 |
^ (Object compiledMethodAt:#instVarAt:) |
|
193 |
valueWithReceiver:self |
|
194 |
arguments:{index} |
|
195 |
selector:#instVarAt: |
|
21095 | 196 |
! |
197 |
||
21117 | 198 |
isKindOf:aBehavior |
199 |
"this method is required Behavior>>#allSubInstancesDo:" |
|
200 |
||
201 |
aBehavior == Object ifTrue:[^ true]. |
|
25193 | 202 |
aBehavior == self class ifTrue:[^ true]. |
21117 | 203 |
|
204 |
^ (Object compiledMethodAt:#isKindOf:) |
|
205 |
valueWithReceiver:self |
|
206 |
arguments:{aBehavior} |
|
207 |
selector:#isKindOf: |
|
25193 | 208 |
|
209 |
"Modified: / 21-01-2020 / 15:12:15 / Stefan Vogel" |
|
21117 | 210 |
! |
211 |
||
21113 | 212 |
perform:aSelector |
213 |
"this method is required to allow inspection of the object" |
|
214 |
||
215 |
^ self perform:aSelector withArguments:#(). |
|
216 |
! |
|
217 |
||
218 |
perform:aSelector with:arg1 |
|
219 |
"this method is required to allow inspection of the object" |
|
220 |
||
221 |
^ self perform:aSelector withArguments:{arg1}. |
|
222 |
! |
|
223 |
||
224 |
perform:aSelector with:arg1 with:arg2 |
|
225 |
"this method is required to allow inspection of the object" |
|
226 |
||
227 |
^ self perform:aSelector withArguments:{arg1. arg2}. |
|
228 |
! |
|
229 |
||
230 |
perform:aSelector with:arg1 with:arg2 with:arg3 |
|
231 |
"this method is required to allow inspection of the object" |
|
232 |
||
233 |
^ self perform:aSelector withArguments:{arg1. arg2. arg3}. |
|
234 |
! |
|
235 |
||
236 |
perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 |
|
237 |
"this method is required to allow inspection of the object" |
|
238 |
||
239 |
^ self perform:aSelector withArguments:{arg1. arg2. arg3. arg4}. |
|
240 |
! |
|
241 |
||
242 |
perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
243 |
"this method is required to allow inspection of the object" |
|
244 |
||
245 |
^ self perform:aSelector withArguments:{arg1. arg2. arg3. arg4. arg5}. |
|
246 |
! |
|
247 |
||
248 |
perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 |
|
249 |
"this method is required to allow inspection of the object" |
|
250 |
||
251 |
^ self perform:aSelector withArguments:{arg1. arg2. arg3. arg4. arg5. arg6}. |
|
252 |
! |
|
253 |
||
254 |
perform:aSelector withArguments:argArray |
|
255 |
"send the message aSelector with all args taken from argArray |
|
256 |
to the receiver. |
|
257 |
||
258 |
1-to-1 Copy from the same method in Object!!" |
|
259 |
||
260 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
|
261 |
||
262 |
%{ |
|
263 |
#ifdef __SCHTEAM__ |
|
264 |
return context.PERFORM_WITH_ARGUMENTS(self, aSelector, argArray); |
|
265 |
#else |
|
266 |
REGISTER OBJ *argP; |
|
267 |
int nargs; |
|
268 |
OBJ l; |
|
269 |
||
270 |
if (__isArrayLike(argArray)) { |
|
271 |
nargs = __arraySize(argArray); |
|
272 |
argP = __arrayVal(argArray); |
|
273 |
} else { |
|
274 |
if (__isNonNilObject(argArray)) { |
|
275 |
static struct inlineCache ilcSize = __ILC0(@line); |
|
276 |
int i; |
|
277 |
||
278 |
numberOfArgs = (*ilcSize.ilc_func)(argArray, @symbol(size), nil, &ilcSize); |
|
279 |
if (!__isSmallInteger(numberOfArgs)) |
|
280 |
goto bad; |
|
281 |
nargs = __intVal(numberOfArgs); |
|
282 |
argP = (OBJ *)(&a1); |
|
283 |
for (i=1; i <= nargs; i++) { |
|
284 |
*argP++ = __AT_(argArray, __mkSmallInteger(i)); |
|
285 |
} |
|
286 |
argP = (OBJ *)(&a1); |
|
287 |
} else { |
|
288 |
nargs = 0; |
|
289 |
} |
|
290 |
} |
|
291 |
switch (nargs) { |
|
292 |
case 0: |
|
293 |
if (InterruptPending == nil) { |
|
294 |
static OBJ last0_0 = nil; static struct inlineCache ilc0_0 = __ILCPERF0(@line); |
|
295 |
static OBJ last0_1 = nil; static struct inlineCache ilc0_1 = __ILCPERF0(@line); |
|
296 |
static OBJ last0_2 = nil; static struct inlineCache ilc0_2 = __ILCPERF0(@line); |
|
297 |
static OBJ last0_3 = nil; static struct inlineCache ilc0_3 = __ILCPERF0(@line); |
|
298 |
static int flip0 = 0; |
|
299 |
struct inlineCache *pIlc; |
|
300 |
||
301 |
if (aSelector == last0_0) { |
|
302 |
pIlc = &ilc0_0; |
|
303 |
} else if (aSelector == last0_1) { |
|
304 |
pIlc = &ilc0_1; |
|
305 |
} else if (aSelector == last0_2) { |
|
306 |
pIlc = &ilc0_2; |
|
307 |
} else if (aSelector == last0_3) { |
|
308 |
pIlc = &ilc0_3; |
|
309 |
} else { |
|
310 |
if (flip0 == 0) { |
|
311 |
pIlc = &ilc0_0; |
|
312 |
flip0 = 1; |
|
313 |
last0_0 = aSelector; |
|
314 |
} else if (flip0 == 1) { |
|
315 |
pIlc = &ilc0_1; |
|
316 |
flip0 = 2; |
|
317 |
last0_1 = aSelector; |
|
318 |
} else if (flip0 == 2) { |
|
319 |
pIlc = &ilc0_2; |
|
320 |
flip0 = 3; |
|
321 |
last0_2 = aSelector; |
|
322 |
} else { |
|
323 |
pIlc = &ilc0_3; |
|
324 |
flip0 = 0; |
|
325 |
last0_3 = aSelector; |
|
326 |
} |
|
327 |
||
328 |
pIlc->ilc_func = __SEND0ADDR__; |
|
329 |
if (pIlc->ilc_poly) { |
|
330 |
__flushPolyCache(pIlc->ilc_poly); |
|
331 |
pIlc->ilc_poly = 0; |
|
332 |
} |
|
333 |
} |
|
334 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc)); |
|
335 |
} else { |
|
336 |
static struct inlineCache ilc0 = __DUMMYILCSELF0(@line+1); |
|
337 |
RETURN (_SEND0(self, aSelector, nil, &ilc0)); |
|
338 |
} |
|
339 |
||
340 |
case 1: |
|
341 |
if (InterruptPending == nil) { |
|
342 |
static OBJ last1_0 = nil; static struct inlineCache ilc1_0 = __ILCPERF1(@line); |
|
343 |
static OBJ last1_1 = nil; static struct inlineCache ilc1_1 = __ILCPERF1(@line); |
|
344 |
static OBJ last1_2 = nil; static struct inlineCache ilc1_2 = __ILCPERF1(@line); |
|
345 |
static OBJ last1_3 = nil; static struct inlineCache ilc1_3 = __ILCPERF1(@line); |
|
346 |
static int flip1 = 0; |
|
347 |
struct inlineCache *pIlc; |
|
348 |
||
349 |
if (aSelector == last1_0) { |
|
350 |
pIlc = &ilc1_0; |
|
351 |
} else if (aSelector == last1_1) { |
|
352 |
pIlc = &ilc1_1; |
|
353 |
} else if (aSelector == last1_2) { |
|
354 |
pIlc = &ilc1_2; |
|
355 |
} else if (aSelector == last1_3) { |
|
356 |
pIlc = &ilc1_3; |
|
357 |
} else { |
|
358 |
if (flip1 == 0) { |
|
359 |
pIlc = &ilc1_0; |
|
360 |
flip1 = 1; |
|
361 |
last1_0 = aSelector; |
|
362 |
} else if (flip1 == 1) { |
|
363 |
pIlc = &ilc1_1; |
|
364 |
flip1 = 2; |
|
365 |
last1_1 = aSelector; |
|
366 |
} else if (flip1 == 2) { |
|
367 |
pIlc = &ilc1_2; |
|
368 |
flip1 = 3; |
|
369 |
last1_2 = aSelector; |
|
370 |
} else { |
|
371 |
pIlc = &ilc1_3; |
|
372 |
flip1 = 0; |
|
373 |
last1_3 = aSelector; |
|
374 |
} |
|
375 |
||
376 |
pIlc->ilc_func = __SEND1ADDR__; |
|
377 |
if (pIlc->ilc_poly) { |
|
378 |
__flushPolyCache(pIlc->ilc_poly); |
|
379 |
pIlc->ilc_poly = 0; |
|
380 |
} |
|
381 |
} |
|
382 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0])); |
|
383 |
} else { |
|
384 |
static struct inlineCache ilc1 = __DUMMYILCSELF1(@line+1); |
|
385 |
RETURN (_SEND1(self, aSelector, nil, &ilc1, argP[0])); |
|
386 |
} |
|
387 |
||
388 |
case 2: |
|
389 |
if (InterruptPending == nil) { |
|
390 |
static OBJ last2_0 = nil; static struct inlineCache ilc2_0 = __ILCPERF2(@line); |
|
391 |
static OBJ last2_1 = nil; static struct inlineCache ilc2_1 = __ILCPERF2(@line); |
|
392 |
static int flip2 = 0; |
|
393 |
struct inlineCache *pIlc; |
|
394 |
||
395 |
if (aSelector == last2_0) { |
|
396 |
pIlc = &ilc2_0; |
|
397 |
} else if (aSelector == last2_1) { |
|
398 |
pIlc = &ilc2_1; |
|
399 |
} else { |
|
400 |
if (flip2 == 0) { |
|
401 |
pIlc = &ilc2_0; |
|
402 |
flip2 = 1; |
|
403 |
last2_0 = aSelector; |
|
404 |
} else { |
|
405 |
pIlc = &ilc2_1; |
|
406 |
flip2 = 0; |
|
407 |
last2_1 = aSelector; |
|
408 |
} |
|
409 |
||
410 |
pIlc->ilc_func = __SEND2ADDR__; |
|
411 |
if (pIlc->ilc_poly) { |
|
412 |
__flushPolyCache(pIlc->ilc_poly); |
|
413 |
pIlc->ilc_poly = 0; |
|
414 |
} |
|
415 |
} |
|
416 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0], argP[1])); |
|
417 |
} else { |
|
418 |
static struct inlineCache ilc2 = __DUMMYILCSELF2(@line+1); |
|
419 |
RETURN (_SEND2(self, aSelector, nil, &ilc2, argP[0], argP[1])); |
|
420 |
} |
|
421 |
||
422 |
case 3: |
|
423 |
if (InterruptPending == nil) { |
|
424 |
static OBJ last3_0 = nil; static struct inlineCache ilc3_0 = __ILCPERF3(@line); |
|
425 |
static OBJ last3_1 = nil; static struct inlineCache ilc3_1 = __ILCPERF3(@line); |
|
426 |
static int flip3 = 0; |
|
427 |
struct inlineCache *pIlc; |
|
428 |
||
429 |
if (aSelector == last3_0) { |
|
430 |
pIlc = &ilc3_0; |
|
431 |
} else if (aSelector == last3_1) { |
|
432 |
pIlc = &ilc3_1; |
|
433 |
} else { |
|
434 |
if (flip3 == 0) { |
|
435 |
pIlc = &ilc3_0; |
|
436 |
flip3 = 1; |
|
437 |
last3_0 = aSelector; |
|
438 |
} else { |
|
439 |
pIlc = &ilc3_1; |
|
440 |
flip3 = 0; |
|
441 |
last3_1 = aSelector; |
|
442 |
} |
|
443 |
||
444 |
pIlc->ilc_func = __SEND3ADDR__; |
|
445 |
if (pIlc->ilc_poly) { |
|
446 |
__flushPolyCache(pIlc->ilc_poly); |
|
447 |
pIlc->ilc_poly = 0; |
|
448 |
} |
|
449 |
} |
|
450 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0], argP[1], argP[2])); |
|
451 |
} else { |
|
452 |
static struct inlineCache ilc3 = __DUMMYILCSELF3(@line+1); |
|
453 |
RETURN (_SEND3(self, aSelector, nil, &ilc3, argP[0], argP[1], argP[2])); |
|
454 |
} |
|
455 |
||
456 |
case 4: |
|
457 |
{ |
|
458 |
static OBJ last4 = nil; static struct inlineCache ilc4 = __ILCPERF4(@line); |
|
459 |
||
460 |
if ((InterruptPending != nil) || (aSelector != last4)) { |
|
461 |
ilc4.ilc_func = __SEND4ADDR__; |
|
462 |
if (ilc4.ilc_poly) { |
|
463 |
__flushPolyCache(ilc4.ilc_poly); |
|
464 |
ilc4.ilc_poly = 0; |
|
465 |
} |
|
466 |
last4 = aSelector; |
|
467 |
} |
|
468 |
RETURN ( (*ilc4.ilc_func)(self, aSelector, nil, &ilc4, |
|
469 |
argP[0], argP[1], argP[2], argP[3])); |
|
470 |
} |
|
471 |
||
472 |
case 5: |
|
473 |
{ |
|
474 |
static OBJ last5 = nil; static struct inlineCache ilc5 = __ILCPERF5(@line); |
|
475 |
||
476 |
if ((InterruptPending != nil) || (aSelector != last5)) { |
|
477 |
ilc5.ilc_func = __SEND5ADDR__; |
|
478 |
if (ilc5.ilc_poly) { |
|
479 |
__flushPolyCache(ilc5.ilc_poly); |
|
480 |
ilc5.ilc_poly = 0; |
|
481 |
} |
|
482 |
last5 = aSelector; |
|
483 |
} |
|
484 |
RETURN ( (*ilc5.ilc_func)(self, aSelector, nil, &ilc5, |
|
485 |
argP[0], argP[1], argP[2], argP[3], argP[4])); |
|
486 |
} |
|
487 |
||
488 |
case 6: |
|
489 |
{ |
|
490 |
static OBJ last6 = nil; static struct inlineCache ilc6 = __ILCPERF6(@line); |
|
491 |
||
492 |
if ((InterruptPending != nil) || (aSelector != last6)) { |
|
493 |
ilc6.ilc_func = __SEND6ADDR__; |
|
494 |
if (ilc6.ilc_poly) { |
|
495 |
__flushPolyCache(ilc6.ilc_poly); |
|
496 |
ilc6.ilc_poly = 0; |
|
497 |
} |
|
498 |
last6 = aSelector; |
|
499 |
} |
|
500 |
RETURN ( (*ilc6.ilc_func)(self, aSelector, nil, &ilc6, |
|
501 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
502 |
argP[5])); |
|
503 |
} |
|
504 |
||
505 |
case 7: |
|
506 |
{ |
|
507 |
static OBJ last7 = nil; static struct inlineCache ilc7 = __ILCPERF7(@line); |
|
508 |
||
509 |
if ((InterruptPending != nil) || (aSelector != last7)) { |
|
510 |
ilc7.ilc_func = __SEND7ADDR__; |
|
511 |
if (ilc7.ilc_poly) { |
|
512 |
__flushPolyCache(ilc7.ilc_poly); |
|
513 |
ilc7.ilc_poly = 0; |
|
514 |
} |
|
515 |
last7 = aSelector; |
|
516 |
} |
|
517 |
RETURN ( (*ilc7.ilc_func)(self, aSelector, nil, &ilc7, |
|
518 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
519 |
argP[5], argP[6])); |
|
520 |
} |
|
521 |
||
522 |
case 8: |
|
523 |
{ |
|
524 |
static OBJ last8 = nil; static struct inlineCache ilc8 = __ILCPERF8(@line); |
|
525 |
||
526 |
if ((InterruptPending != nil) || (aSelector != last8)) { |
|
527 |
ilc8.ilc_func = __SEND8ADDR__; |
|
528 |
if (ilc8.ilc_poly) { |
|
529 |
__flushPolyCache(ilc8.ilc_poly); |
|
530 |
ilc8.ilc_poly = 0; |
|
531 |
} |
|
532 |
last8 = aSelector; |
|
533 |
} |
|
534 |
RETURN ( (*ilc8.ilc_func)(self, aSelector, nil, &ilc8, |
|
535 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
536 |
argP[5], argP[6], argP[7])); |
|
537 |
} |
|
538 |
||
539 |
case 9: |
|
540 |
{ |
|
541 |
static OBJ last9 = nil; static struct inlineCache ilc9 = __ILCPERF9(@line); |
|
542 |
||
543 |
if ((InterruptPending != nil) || (aSelector != last9)) { |
|
544 |
ilc9.ilc_func = __SEND9ADDR__; |
|
545 |
if (ilc9.ilc_poly) { |
|
546 |
__flushPolyCache(ilc9.ilc_poly); |
|
547 |
ilc9.ilc_poly = 0; |
|
548 |
} |
|
549 |
last9 = aSelector; |
|
550 |
} |
|
551 |
RETURN ( (*ilc9.ilc_func)(self, aSelector, nil, &ilc9, |
|
552 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
553 |
argP[5], argP[6], argP[7], argP[8])); |
|
554 |
} |
|
555 |
||
556 |
case 10: |
|
557 |
{ |
|
558 |
static OBJ last10 = nil; static struct inlineCache ilc10 = __ILCPERF10(@line); |
|
559 |
||
560 |
if ((InterruptPending != nil) || (aSelector != last10)) { |
|
561 |
ilc10.ilc_func = __SEND10ADDR__; |
|
562 |
if (ilc10.ilc_poly) { |
|
563 |
__flushPolyCache(ilc10.ilc_poly); |
|
564 |
ilc10.ilc_poly = 0; |
|
565 |
} |
|
566 |
last10 = aSelector; |
|
567 |
} |
|
568 |
RETURN ( (*ilc10.ilc_func)(self, aSelector, nil, &ilc10, |
|
569 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
570 |
argP[5], argP[6], argP[7], argP[8], argP[9])); |
|
571 |
} |
|
572 |
||
573 |
case 11: |
|
574 |
{ |
|
575 |
static OBJ last11 = nil; static struct inlineCache ilc11 = __ILCPERF11(@line); |
|
576 |
||
577 |
if ((InterruptPending != nil) || (aSelector != last11)) { |
|
578 |
ilc11.ilc_func = __SEND11ADDR__; |
|
579 |
if (ilc11.ilc_poly) { |
|
580 |
__flushPolyCache(ilc11.ilc_poly); |
|
581 |
ilc11.ilc_poly = 0; |
|
582 |
} |
|
583 |
last11 = aSelector; |
|
584 |
} |
|
585 |
RETURN ( (*ilc11.ilc_func)(self, aSelector, nil, &ilc11, |
|
586 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
587 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
588 |
argP[10])); |
|
589 |
} |
|
590 |
||
591 |
case 12: |
|
592 |
{ |
|
593 |
static OBJ last12 = nil; static struct inlineCache ilc12 = __ILCPERF12(@line); |
|
594 |
||
595 |
if ((InterruptPending != nil) || (aSelector != last12)) { |
|
596 |
ilc12.ilc_func = __SEND12ADDR__; |
|
597 |
if (ilc12.ilc_poly) { |
|
598 |
__flushPolyCache(ilc12.ilc_poly); |
|
599 |
ilc12.ilc_poly = 0; |
|
600 |
} |
|
601 |
last12 = aSelector; |
|
602 |
} |
|
603 |
RETURN ( (*ilc12.ilc_func)(self, aSelector, nil, &ilc12, |
|
604 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
605 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
606 |
argP[10], argP[11])); |
|
607 |
} |
|
608 |
||
609 |
case 13: |
|
610 |
{ |
|
611 |
static OBJ last13 = nil; static struct inlineCache ilc13 = __ILCPERF13(@line); |
|
612 |
||
613 |
if ((InterruptPending != nil) || (aSelector != last13)) { |
|
614 |
ilc13.ilc_func = __SEND13ADDR__; |
|
615 |
if (ilc13.ilc_poly) { |
|
616 |
__flushPolyCache(ilc13.ilc_poly); |
|
617 |
ilc13.ilc_poly = 0; |
|
618 |
} |
|
619 |
last13 = aSelector; |
|
620 |
} |
|
621 |
RETURN ( (*ilc13.ilc_func)(self, aSelector, nil, &ilc13, |
|
622 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
623 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
624 |
argP[10], argP[11], argP[12])); |
|
625 |
} |
|
626 |
||
627 |
case 14: |
|
628 |
{ |
|
629 |
static OBJ last14 = nil; static struct inlineCache ilc14 = __ILCPERF14(@line); |
|
630 |
||
631 |
if ((InterruptPending != nil) || (aSelector != last14)) { |
|
632 |
ilc14.ilc_func = __SEND14ADDR__; |
|
633 |
if (ilc14.ilc_poly) { |
|
634 |
__flushPolyCache(ilc14.ilc_poly); |
|
635 |
ilc14.ilc_poly = 0; |
|
636 |
} |
|
637 |
last14 = aSelector; |
|
638 |
} |
|
639 |
RETURN ( (*ilc14.ilc_func)(self, aSelector, nil, &ilc14, |
|
640 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
641 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
642 |
argP[10], argP[11], argP[12], argP[13])); |
|
643 |
} |
|
644 |
||
645 |
case 15: |
|
646 |
{ |
|
647 |
static OBJ last15 = nil; static struct inlineCache ilc15 = __ILCPERF15(@line); |
|
648 |
||
649 |
if ((InterruptPending != nil) || (aSelector != last15)) { |
|
650 |
ilc15.ilc_func = __SEND15ADDR__; |
|
651 |
if (ilc15.ilc_poly) { |
|
652 |
__flushPolyCache(ilc15.ilc_poly); |
|
653 |
ilc15.ilc_poly = 0; |
|
654 |
} |
|
655 |
last15 = aSelector; |
|
656 |
} |
|
657 |
RETURN ( (*ilc15.ilc_func)(self, aSelector, nil, &ilc15, |
|
658 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
659 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
660 |
argP[10], argP[11], argP[12], argP[13], |
|
661 |
argP[14])); |
|
662 |
} |
|
663 |
} |
|
664 |
bad:; |
|
665 |
#endif |
|
666 |
%}. |
|
667 |
||
668 |
"/ arrive here, if bad number of arguments (too many) |
|
669 |
"/ ST/X (currently) only allows up to 15 method arguments |
|
670 |
||
671 |
^ self primitiveFailed |
|
672 |
! |
|
673 |
||
21095 | 674 |
referencesAny:anObject |
675 |
"this method is required to allow inspection of the object" |
|
676 |
||
677 |
^ (Object compiledMethodAt:#referencesAny:) |
|
678 |
valueWithReceiver:self |
|
679 |
arguments:{anObject} |
|
680 |
selector:#referencesAny |
|
681 |
! |
|
682 |
||
22001 | 683 |
referencesInstanceOf:anObject |
684 |
"this method is required to allow inspection of the object" |
|
685 |
||
686 |
^ false |
|
687 |
||
688 |
"Created: / 13-07-2017 / 12:12:45 / Maren" |
|
689 |
! |
|
690 |
||
21095 | 691 |
referencesObject:anObject |
692 |
"this method is required to allow inspection of the object" |
|
693 |
||
694 |
^ (Object compiledMethodAt:#referencesObject:) |
|
695 |
valueWithReceiver:self |
|
696 |
arguments:{anObject} |
|
697 |
selector:#referencesObject |
|
21076 | 698 |
! ! |
699 |
||
6844 | 700 |
!ProtoObject methodsFor:'queries'! |
701 |
||
22385 | 702 |
basicSize |
703 |
"this method is required to allow restore of the object" |
|
704 |
||
705 |
^ (Object compiledMethodAt:#basicSize) |
|
706 |
valueWithReceiver:self |
|
707 |
arguments:nil |
|
708 |
selector:#basicSize |
|
709 |
||
710 |
"Created: / 28-11-2017 / 19:30:09 / stefan" |
|
711 |
! |
|
712 |
||
6844 | 713 |
class |
19678 | 714 |
"return the receiver's class" |
6844 | 715 |
|
716 |
%{ /* NOCONTEXT */ |
|
717 |
||
718 |
RETURN ( __Class(self) ); |
|
719 |
%} |
|
720 |
||
721 |
" |
|
722 |
*** WARNING |
|
723 |
*** |
|
724 |
*** this method has been automatically created, |
|
725 |
*** since all nil-subclasses should respond to some minimum required |
|
726 |
*** protocol. |
|
727 |
*** |
|
728 |
*** Inspection and/or debugging of instances may not be possible, |
|
729 |
*** if you remove/change this method. |
|
730 |
" |
|
19678 | 731 |
|
732 |
"Modified (comment): / 30-04-2016 / 15:51:12 / cg" |
|
10589 | 733 |
! |
734 |
||
735 |
identityHash |
|
736 |
"return an Integer useful as a hash key for the receiver. |
|
737 |
This hash should return same values for the same object (i.e. use |
|
738 |
this to hash on identity of objects). |
|
739 |
||
740 |
We cannot use the Objects address (as other smalltalks do) since |
|
741 |
no object-table exists and the hashval must not change when objects |
|
742 |
are moved by the collector. Therefore we assign each object a unique |
|
743 |
Id in the object header itself as its hashed upon. |
|
744 |
(luckily we have 11 bits spare to do this - unluckily its only 11 bits). |
|
745 |
Time will show, if 11 bits are enough; if not, another entry in the |
|
746 |
object header will be needed, adding 4 bytes to every object. Alternatively, |
|
747 |
hashed-upon objects could add an instvar containing the hash value." |
|
748 |
||
749 |
%{ /* NOCONTEXT */ |
|
750 |
||
751 |
REGISTER unsigned INT hash; |
|
752 |
static unsigned nextHash = 0; |
|
753 |
||
754 |
if (__isNonNilObject(self)) { |
|
755 |
hash = __GET_HASH(self); |
|
756 |
if (hash == 0) { |
|
757 |
/* has no hash yet */ |
|
758 |
||
759 |
if (++nextHash > __MAX_HASH__) { |
|
760 |
nextHash = 1; |
|
761 |
} |
|
762 |
hash = nextHash; |
|
763 |
__SET_HASH(self, hash); |
|
764 |
} |
|
765 |
||
766 |
/* |
|
767 |
* now, we got 11 bits for hashing; |
|
768 |
* make it as large as possible; since most hashers use the returned |
|
769 |
* key and take it modulo some prime number, this will allow for |
|
770 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
771 |
*/ |
|
772 |
hash = __MAKE_HASH__(hash); |
|
773 |
RETURN ( __mkSmallInteger(hash) ); |
|
774 |
} |
|
775 |
%}. |
|
776 |
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger" |
|
777 |
||
778 |
"Created: / 31-05-2007 / 23:18:40 / cg" |
|
6844 | 779 |
! ! |
780 |
||
781 |
!ProtoObject methodsFor:'testing'! |
|
782 |
||
12571 | 783 |
ifNil:aBlock |
784 |
^ self |
|
785 |
! |
|
786 |
||
787 |
ifNotNil:aBlockOrValue |
|
22647 | 788 |
^ aBlockOrValue valueWithOptionalArgument:self |
21665 | 789 |
|
22647 | 790 |
"Modified: / 22-03-2018 / 11:39:11 / stefan" |
12571 | 791 |
! |
792 |
||
6844 | 793 |
isBehavior |
18351 | 794 |
"return true, if the receiver is describing another object's behavior. |
9222 | 795 |
False is returned here - the method is only redefined in Behavior." |
796 |
||
6844 | 797 |
^ false |
7661
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
798 |
! |
6844 | 799 |
|
7661
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
800 |
isBlock |
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
801 |
^ false |
7659 | 802 |
! |
803 |
||
21085 | 804 |
isBridgeProxy |
23024 | 805 |
"answer true, if I am a proxy object for a bridged remote object" |
806 |
||
807 |
"do not move this into the bridge-package; |
|
808 |
it is called by some others, to prevent remote messages from implements/respondsTo, etc. |
|
809 |
which are called from inspectors and debuggers" |
|
810 |
||
21085 | 811 |
^ false |
23024 | 812 |
|
813 |
"Modified (comment): / 25-05-2018 / 12:45:50 / Claus Gittinger" |
|
21085 | 814 |
! |
815 |
||
7659 | 816 |
isException |
817 |
^ false |
|
818 |
! |
|
819 |
||
820 |
isExceptionHandler |
|
821 |
^ false |
|
822 |
! |
|
823 |
||
824 |
isJavaObject |
|
23642 | 825 |
"return true if this is a JavaObject. |
826 |
false is returned here - the method is only redefined in JavaObject." |
|
827 |
||
7659 | 828 |
^ false |
23642 | 829 |
|
830 |
"Modified (comment): / 24-01-2019 / 12:48:30 / Claus Gittinger" |
|
10589 | 831 |
! |
832 |
||
833 |
isLazyValue |
|
834 |
^ false |
|
835 |
||
836 |
"Created: / 03-06-2007 / 14:02:12 / cg" |
|
10591 | 837 |
! |
838 |
||
839 |
isLiteral |
|
840 |
^ false |
|
841 |
||
842 |
"Created: / 04-06-2007 / 17:19:10 / cg" |
|
21075 | 843 |
! |
844 |
||
845 |
isNil |
|
846 |
^ false. |
|
847 |
! |
|
848 |
||
849 |
isProtoObject |
|
850 |
^ true |
|
24364 | 851 |
! |
852 |
||
853 |
isProxy |
|
854 |
"answer true, if I am a proxy for another (lazy loaded) object" |
|
855 |
||
856 |
"do not remove this; |
|
857 |
it is called by some others, to prevent blocking in inspectors and debuggers" |
|
858 |
||
859 |
^ false |
|
860 |
||
861 |
"Created: / 25-06-2019 / 17:29:01 / Claus Gittinger" |
|
6844 | 862 |
! ! |
863 |
||
23194 | 864 |
!ProtoObject methodsFor:'visiting'! |
865 |
||
866 |
acceptVisitor:aVisitor with:aParameter |
|
867 |
"double-dispatch via visitObject:with: into a Visitor. |
|
868 |
Subclasses redefine this to pass their type in the message name (i.e. visitXXX:)" |
|
869 |
||
870 |
^ aVisitor visitProtoObject:self with:aParameter |
|
871 |
||
872 |
"Created: / 04-07-2018 / 00:41:38 / Claus Gittinger" |
|
873 |
! ! |
|
874 |
||
6844 | 875 |
!ProtoObject class methodsFor:'documentation'! |
876 |
||
877 |
version |
|
19678 | 878 |
^ '$Header$' |
12571 | 879 |
! |
880 |
||
881 |
version_CVS |
|
19678 | 882 |
^ '$Header$' |
6844 | 883 |
! ! |
16158 | 884 |