author | Claus Gittinger <cg@exept.de> |
Tue, 26 Mar 1996 17:08:34 +0100 | |
changeset 1123 | 4e79c452592f |
parent 1083 | fadaedfa28f8 |
child 1133 | 961f2b095c22 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
155 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
ArrayedCollection variableSubclass:#Array |
|
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
14 |
instanceVariableNames:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
15 |
classVariableNames:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
16 |
poolDictionaries:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
17 |
category:'Collections-Arrayed' |
1 | 18 |
! |
19 |
||
77 | 20 |
!Array class methodsFor:'documentation'! |
21 |
||
554 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
77 | 36 |
documentation |
37 |
" |
|
155 | 38 |
Instances of Array store general objects; the arrays size is fixed, |
39 |
therefore add:/remove: are not allowed. |
|
399 | 40 |
(actually, #add: is implemented for compatibility with smalltalks which |
41 |
provide it, but it outputs an annoying warning message ...) |
|
42 |
||
155 | 43 |
Access to the individual elements is via an integer index. |
44 |
Since Arrays are used very often in the system, some methods have been tuned by |
|
399 | 45 |
reimplementing them as primitives. |
92 | 46 |
|
47 |
Notice that Array is a built-in class (i.e. the VM knows about its |
|
48 |
representation). Therefore it is NOT possible to add named instance |
|
577 | 49 |
variables or change Arrays inheritance. |
50 |
Subclassing is allowed - even with added instance variables - of course. |
|
92 | 51 |
|
52 |
Literal arrays (i.e. array-constants) are entered in source as: |
|
155 | 53 |
#( element1 element2 ... element-n) |
399 | 54 |
where each element must be itself a constant. In addition, true, false and nil |
55 |
are also allowed as array-literal. |
|
56 |
||
92 | 57 |
Examples: |
155 | 58 |
#(1 2 3) |
59 |
#('foo' 2 (1 2) 4) |
|
60 |
#('foo' #(1 2)) |
|
399 | 61 |
#('foo' nil true #true) |
62 |
#('one' two [3 3 3] (4 4 4)) |
|
77 | 63 |
" |
626 | 64 |
! ! |
3 | 65 |
|
249 | 66 |
!Array class methodsFor:'instance creation'! |
67 |
||
68 |
basicNew:anInteger |
|
69 |
"return an instance of myself with anInteger indexed variables. |
|
70 |
Since Array-creation is so common (all other collections use them), |
|
71 |
it seems worth to have a specially tuned version here." |
|
72 |
||
73 |
%{ /* NOCONTEXT */ |
|
74 |
||
75 |
OBJ newobj; |
|
76 |
unsigned INT instsize, nInstVars; |
|
77 |
INT nindexedinstvars; |
|
78 |
REGISTER OBJ *op; |
|
79 |
||
80 |
if (__isSmallInteger(anInteger)) { |
|
81 |
nindexedinstvars = _intVal(anInteger); |
|
82 |
if (nindexedinstvars >= 0) { |
|
83 |
nInstVars = _intVal(_ClassInstPtr(self)->c_ninstvars); |
|
84 |
||
85 |
nInstVars += nindexedinstvars; |
|
86 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
835 | 87 |
if (__CanDoQuickAlignedNew(instsize)) { |
357 | 88 |
/* |
89 |
* the most common case |
|
90 |
*/ |
|
835 | 91 |
__qCheckedAlignedNew(newobj, instsize); |
357 | 92 |
ok: ; |
249 | 93 |
_InstPtr(newobj)->o_class = self; |
369 | 94 |
__qSTORE(newobj, self); |
95 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
96 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) |
249 | 97 |
memset4(_InstPtr(newobj)->i_instvars, nil, nInstVars); |
98 |
#else |
|
99 |
# if !defined(NEGATIVE_ADDRESSES) |
|
100 |
/* |
|
101 |
* knowing that nil is 0 |
|
102 |
*/ |
|
360 | 103 |
#ifdef XXmips |
249 | 104 |
# undef FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
105 |
# undef FAST_ARRAY_MEMSET_LONGLONG_UNROLLED |
|
106 |
/* seems to be slightly faster */ |
|
107 |
# define FAST_ARRAY_MEMSET |
|
108 |
#endif |
|
109 |
#ifdef sparc |
|
110 |
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
|
111 |
#endif |
|
112 |
||
113 |
# if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED) |
|
114 |
op = _InstPtr(newobj)->i_instvars; |
|
115 |
if (nInstVars > 8) { |
|
116 |
*op++ = nil; /* for alignment */ |
|
117 |
nInstVars--; |
|
118 |
while (nInstVars >= 8) { |
|
119 |
*(double *)op = 0.0; |
|
120 |
((double *)op)[1] = 0.0; |
|
121 |
((double *)op)[2] = 0.0; |
|
122 |
((double *)op)[3] = 0.0; |
|
123 |
op += 8; |
|
124 |
nInstVars -= 8; |
|
125 |
} |
|
126 |
} |
|
127 |
while (nInstVars) { |
|
128 |
*op++ = 0; |
|
129 |
nInstVars--; |
|
130 |
} |
|
131 |
# else |
|
132 |
# if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED) |
|
133 |
op = _InstPtr(newobj)->i_instvars; |
|
134 |
if (nInstVars > 8) { |
|
135 |
*op++ = nil; /* for alignment */ |
|
136 |
nInstVars--; |
|
137 |
while (nInstVars >= 8) { |
|
138 |
*(long long *)op = 0; |
|
139 |
((long long *)op)[1] = 0; |
|
140 |
((long long *)op)[2] = 0; |
|
141 |
((long long *)op)[3] = 0; |
|
142 |
op += 8; |
|
143 |
nInstVars -= 8; |
|
144 |
} |
|
145 |
} |
|
146 |
while (nInstVars) { |
|
147 |
*op++ = 0; |
|
148 |
nInstVars--; |
|
149 |
} |
|
150 |
# else |
|
151 |
# if defined(FAST_ARRAY_MEMSET) |
|
152 |
memset(_InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
|
153 |
# else |
|
154 |
op = _InstPtr(newobj)->i_instvars; |
|
155 |
while (nInstVars--) |
|
156 |
*op++ = nil; |
|
157 |
# endif |
|
158 |
# endif |
|
159 |
# endif |
|
160 |
# else |
|
161 |
op = _InstPtr(newobj)->i_instvars; |
|
162 |
while (nInstVars--) |
|
163 |
*op++ = nil; |
|
164 |
# endif |
|
165 |
#endif |
|
166 |
RETURN ( newobj ); |
|
357 | 167 |
} else { |
168 |
/* |
|
169 |
* a GC will happen ... |
|
170 |
* have to protect all context stuff |
|
171 |
* (especially for self, but also for backtrace in case of |
|
172 |
* allocation failure) |
|
173 |
*/ |
|
834 | 174 |
__PROTECT_CONTEXT__ |
951
2dd898849a8a
directly call __new if quick allocation fails;
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
175 |
newobj = __new(instsize); |
834 | 176 |
__UNPROTECT_CONTEXT__ |
357 | 177 |
if (newobj != nil) { |
178 |
goto ok; |
|
179 |
} |
|
249 | 180 |
} |
181 |
} |
|
182 |
} |
|
183 |
%}. |
|
184 |
" |
|
185 |
arrive here if something went wrong ... |
|
186 |
figure out what it was |
|
187 |
" |
|
188 |
(anInteger isMemberOf:SmallInteger) ifFalse:[ |
|
189 |
" |
|
190 |
the argument is either not an integer, |
|
191 |
or a LargeInteger (which means that its definitely too big) |
|
192 |
" |
|
193 |
self error:'argument to new: must be Integer'. |
|
194 |
^ nil |
|
195 |
]. |
|
196 |
(anInteger < 0) ifTrue:[ |
|
197 |
" |
|
198 |
the argument is negative, |
|
199 |
" |
|
200 |
self error:'bad (negative) argument to new:'. |
|
201 |
^ nil |
|
202 |
]. |
|
203 |
" |
|
204 |
memory allocation failed. |
|
205 |
When we arrive here, there was no memory, even after |
|
206 |
a garbage collect. |
|
207 |
This means, that the VM wanted to get some more memory from the |
|
208 |
Operatingsystem, which was not kind enough to give it. |
|
209 |
Bad luck - you should increase the swap space on your machine. |
|
210 |
" |
|
211 |
^ ObjectMemory allocationFailureSignal raise. |
|
549 | 212 |
! |
213 |
||
214 |
new:anInteger |
|
215 |
"return an instance of myself with anInteger indexed variables. |
|
216 |
Since this is often called, its worth giving it an extra ilc-slot. |
|
217 |
Future versions of stc will do this automatically." |
|
218 |
||
219 |
^ self basicNew:anInteger |
|
360 | 220 |
! ! |
221 |
||
543 | 222 |
!Array class methodsFor:'queries'! |
345 | 223 |
|
543 | 224 |
isBuiltInClass |
225 |
"this class is known by the run-time-system" |
|
345 | 226 |
|
543 | 227 |
^ self == Array |
249 | 228 |
! ! |
229 |
||
1 | 230 |
!Array methodsFor:'accessing'! |
231 |
||
554 | 232 |
at:index |
233 |
"return the indexed instance variable with index, anInteger. |
|
234 |
Reimplemented here to avoid the additional at:->basicAt: send |
|
235 |
(which we can do here, since at: is obviously not redefined in a subclass). |
|
577 | 236 |
This method is the same as basicAt:." |
543 | 237 |
|
238 |
%{ /* NOCONTEXT */ |
|
239 |
||
554 | 240 |
REGISTER int indx; |
241 |
REGISTER unsigned int nIndex; |
|
242 |
OBJ cls; |
|
243 |
||
244 |
if (__isSmallInteger(index)) { |
|
245 |
indx = _intVal(index) - 1; |
|
246 |
if (indx >= 0) { |
|
247 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
248 |
if ((cls = __qClass(self)) != Array) |
|
249 |
indx += _intVal(_ClassInstPtr(cls)->c_ninstvars); |
|
250 |
if (indx < nIndex) { |
|
251 |
RETURN ( _InstPtr(self)->i_instvars[indx] ); |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
%}. |
|
256 |
^ super at:index |
|
543 | 257 |
! |
258 |
||
554 | 259 |
at:index put:anObject |
260 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
261 |
Reimplemented here to avoid the additional at:put:->basicAt:put: send |
|
262 |
(which we can do here, since at: is obviously not redefined in a subclass). |
|
577 | 263 |
This method is the same as basicAt:put:." |
549 | 264 |
|
265 |
%{ /* NOCONTEXT */ |
|
266 |
||
554 | 267 |
REGISTER int indx; |
268 |
REGISTER unsigned int nIndex; |
|
269 |
OBJ cls; |
|
270 |
||
271 |
if (__isSmallInteger(index)) { |
|
272 |
indx = _intVal(index) - 1; |
|
273 |
if (indx >= 0) { |
|
274 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
275 |
if ((cls = __qClass(self)) != Array) |
|
276 |
indx += _intVal(_ClassInstPtr(cls)->c_ninstvars); |
|
277 |
if (indx < nIndex) { |
|
278 |
_InstPtr(self)->i_instvars[indx] = anObject; |
|
279 |
__STORE(self, anObject); |
|
280 |
RETURN ( anObject ); |
|
281 |
} |
|
282 |
} |
|
283 |
} |
|
284 |
%}. |
|
285 |
^ super at:index put:anObject |
|
549 | 286 |
! |
287 |
||
288 |
basicAt:index |
|
289 |
"return the indexed instance variable with index, anInteger |
|
290 |
- added here for speed" |
|
291 |
||
292 |
%{ /* NOCONTEXT */ |
|
293 |
||
294 |
REGISTER int indx; |
|
295 |
REGISTER unsigned int nIndex; |
|
296 |
OBJ cls; |
|
297 |
||
298 |
if (__isSmallInteger(index)) { |
|
299 |
indx = _intVal(index) - 1; |
|
300 |
if (indx >= 0) { |
|
301 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
302 |
if ((cls = __qClass(self)) != Array) |
|
303 |
indx += _intVal(_ClassInstPtr(cls)->c_ninstvars); |
|
304 |
if (indx < nIndex) { |
|
305 |
RETURN ( _InstPtr(self)->i_instvars[indx] ); |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
%} |
|
310 |
. |
|
311 |
^ super basicAt:index |
|
312 |
! |
|
313 |
||
77 | 314 |
basicAt:index put:anObject |
1 | 315 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
316 |
- added here for speed" |
|
317 |
||
318 |
%{ /* NOCONTEXT */ |
|
319 |
||
320 |
REGISTER int indx; |
|
92 | 321 |
REGISTER unsigned int nIndex; |
11 | 322 |
OBJ cls; |
1 | 323 |
|
249 | 324 |
if (__isSmallInteger(index)) { |
155 | 325 |
indx = _intVal(index) - 1; |
326 |
if (indx >= 0) { |
|
328 | 327 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
328 |
if ((cls = __qClass(self)) != Array) |
|
155 | 329 |
indx += _intVal(_ClassInstPtr(cls)->c_ninstvars); |
330 |
if (indx < nIndex) { |
|
331 |
_InstPtr(self)->i_instvars[indx] = anObject; |
|
332 |
__STORE(self, anObject); |
|
333 |
RETURN ( anObject ); |
|
334 |
} |
|
335 |
} |
|
1 | 336 |
} |
337 |
%} |
|
338 |
. |
|
77 | 339 |
^ super basicAt:index put:anObject |
551 | 340 |
! |
341 |
||
554 | 342 |
basicSize |
343 |
"return the number of indexed elements in the receiver" |
|
551 | 344 |
|
345 |
%{ /* NOCONTEXT */ |
|
346 |
||
554 | 347 |
RETURN ( __MKSMALLINT(_arraySize(self) - _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars) )); |
348 |
%} |
|
551 | 349 |
! |
350 |
||
554 | 351 |
size |
352 |
"return the number of indexed elements in the receiver. |
|
353 |
Reimplemented here to avoid the additional size->basicSize send |
|
354 |
(which we can do here, since size is obviously not redefined in a subclass). |
|
355 |
This method is the same as basicSize." |
|
551 | 356 |
|
357 |
%{ /* NOCONTEXT */ |
|
358 |
||
554 | 359 |
RETURN ( __MKSMALLINT(_arraySize(self) - _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars) )); |
360 |
%} |
|
1 | 361 |
! ! |
362 |
||
11 | 363 |
!Array methodsFor:'converting'! |
364 |
||
365 |
asArray |
|
366 |
"return the receiver as an array" |
|
367 |
||
368 |
"could be an instance of a subclass..." |
|
369 |
self class == Array ifTrue:[ |
|
155 | 370 |
^ self |
11 | 371 |
]. |
372 |
^ super asArray |
|
373 |
! ! |
|
374 |
||
1 | 375 |
!Array methodsFor:'copying'! |
376 |
||
377 |
copyWith:something |
|
220 | 378 |
"return a new collection containing the receivers elements |
379 |
and the single new element, newElement. |
|
380 |
This is different from concatentation, which expects another collection |
|
381 |
as argument, but equivalent to copy-and-addLast. |
|
370 | 382 |
Reimplemented for speed if receiver is an Array. |
383 |
(since the inherited copyWith uses replaceFromTo:, which is also |
|
384 |
tuned, it is questionable, if we need this)" |
|
385 |
||
386 |
%{ /* NOCONTEXT */ |
|
11 | 387 |
OBJ nObj, element; |
92 | 388 |
unsigned int sz; |
389 |
unsigned int nIndex; |
|
11 | 390 |
REGISTER OBJ *srcP, *dstP; |
293 | 391 |
REGISTER int spc; |
1 | 392 |
|
328 | 393 |
if (__qClass(self) == Array) { |
394 |
sz = __qSize(self) + sizeof(OBJ); |
|
834 | 395 |
__PROTECT__(something); |
396 |
__PROTECT__(self); |
|
835 | 397 |
__qAlignedNew(nObj, sz, __context); |
834 | 398 |
__UNPROTECT__(self); |
399 |
__UNPROTECT__(something); |
|
92 | 400 |
|
155 | 401 |
if (nObj) { |
402 |
_InstPtr(nObj)->o_class = Array; |
|
1 | 403 |
|
155 | 404 |
nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ)); |
370 | 405 |
/* |
406 |
* sorry: |
|
407 |
* cannot use bcopy, since we must take care of stores ... |
|
408 |
* could check for: notRemembered + inOld + notLifoRem |
|
409 |
* + not incrGCRunning |
|
410 |
* but copyWith: is not heavily used by real programmers ... |
|
411 |
*/ |
|
412 |
spc = __qSpace(nObj); |
|
155 | 413 |
srcP = _ArrayInstPtr(self)->a_element; |
414 |
dstP = _ArrayInstPtr(nObj)->a_element; |
|
393 | 415 |
#ifdef UNROLL_LOOPS |
416 |
while (nIndex >= 4) { |
|
417 |
element = srcP[0]; |
|
418 |
dstP[0] = element; |
|
419 |
__STORE_SPC(nObj, element, spc); |
|
420 |
element = srcP[1]; |
|
421 |
dstP[1] = element; |
|
422 |
__STORE_SPC(nObj, element, spc); |
|
423 |
element = srcP[2]; |
|
424 |
dstP[2] = element; |
|
425 |
__STORE_SPC(nObj, element, spc); |
|
426 |
element = srcP[3]; |
|
427 |
dstP[3] = element; |
|
428 |
__STORE_SPC(nObj, element, spc); |
|
429 |
srcP += 4; |
|
430 |
dstP += 4; |
|
431 |
nIndex -= 4; |
|
432 |
} |
|
433 |
#endif |
|
155 | 434 |
while (nIndex--) { |
435 |
element = *srcP++; |
|
436 |
*dstP++ = element; |
|
293 | 437 |
__STORE_SPC(nObj, element, spc); |
155 | 438 |
} |
439 |
*dstP = something; |
|
293 | 440 |
__STORE_SPC(nObj, something, spc); |
155 | 441 |
RETURN ( nObj ); |
442 |
} |
|
1 | 443 |
} |
444 |
%} |
|
445 |
. |
|
446 |
^ super copyWith:something |
|
447 |
! ! |
|
448 |
||
216 | 449 |
!Array methodsFor:'enumerating'! |
1 | 450 |
|
554 | 451 |
addAllTo:aCollection |
452 |
"add all elements of the receiver to aCollection. |
|
453 |
return aCollection." |
|
454 |
||
455 |
|stop "{ Class: SmallInteger }"| |
|
456 |
||
457 |
stop := self size. |
|
458 |
1 to:stop do:[:idx | |
|
459 |
aCollection add:(self at:idx) |
|
460 |
]. |
|
461 |
^ aCollection |
|
462 |
! |
|
463 |
||
464 |
do:aBlock |
|
465 |
"evaluate the argument, aBlock for each element in the collection. |
|
466 |
- reimplemented for speed" |
|
467 |
||
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
468 |
|home sz "{ Class: SmallInteger }"| |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
469 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
470 |
sz := self size. |
554 | 471 |
%{ |
472 |
REGISTER OBJFUNC codeVal; |
|
473 |
REGISTER int index; |
|
474 |
unsigned int nIndex; |
|
475 |
static struct inlineCache val = _ILC1; |
|
476 |
REGISTER OBJ rHome; |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
477 |
int actualSize; |
554 | 478 |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
479 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
480 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
481 |
nIndex = index + __intVal(sz); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
482 |
if (nIndex <= actualSize) { |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
483 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
484 |
if (__isBlockLike(aBlock) |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
485 |
&& ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
486 |
&& (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
554 | 487 |
#ifdef NEW_BLOCK_CALL |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
488 |
for (; index < nIndex; index++) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
489 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 490 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
491 |
(*codeVal)(aBlock, CON_COMMA _InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
492 |
} |
554 | 493 |
#else |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
494 |
home = _BlockInstPtr(aBlock)->b_home; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
495 |
rHome = home; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
496 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
497 |
/* |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
498 |
* home will not move - keep in a fast register |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
499 |
*/ |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
500 |
# if defined(UNROLL_LOOPS) |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
501 |
{ |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
502 |
int i4; |
554 | 503 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
504 |
while ((i4 = index+4) < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
505 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
506 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
507 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
508 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index+1]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
509 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
510 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index+2]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
511 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
512 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index+3]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
513 |
index = i4; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
514 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
515 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
516 |
# endif |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
517 |
for (; index < nIndex; index++) { |
554 | 518 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
519 |
|
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
520 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
521 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
522 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
523 |
for (; index < nIndex; index++) { |
554 | 524 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
525 |
||
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
526 |
(*codeVal)(home, CON_COMMA _InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
527 |
} |
554 | 528 |
} |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
529 |
#endif |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
530 |
} else { |
554 | 531 |
for (; index < nIndex; index++) { |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
532 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 533 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
534 |
(*val.ilc_func)(aBlock, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
535 |
@symbol(value:), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
536 |
CON_COMMA nil, &val, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
537 |
_InstPtr(self)->i_instvars[index]); |
554 | 538 |
} |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
539 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
540 |
RETURN (self ); |
554 | 541 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
542 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
543 |
^ super do:aBlock |
554 | 544 |
! |
545 |
||
1 | 546 |
from:start to:stop do:aBlock |
547 |
"evaluate the argument, aBlock for the elements starting at index start |
|
548 |
up to (and including) stop in the collection. |
|
549 |
- reimplemented for speed" |
|
550 |
||
302 | 551 |
|home| |
1 | 552 |
%{ |
553 |
REGISTER OBJFUNC codeVal; |
|
554 |
REGISTER int index; |
|
2 | 555 |
REGISTER OBJ rHome; |
1 | 556 |
int nIndex, nInsts; |
557 |
static struct inlineCache val = _ILC1; |
|
558 |
int indexLow, indexHigh; |
|
559 |
||
249 | 560 |
if (__bothSmallInteger(start, stop)) { |
155 | 561 |
indexLow = _intVal(start); |
562 |
if (indexLow > 0) { |
|
563 |
indexHigh = _intVal(stop); |
|
328 | 564 |
if (__qClass(self) != Array) { |
565 |
nInsts = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
|
155 | 566 |
indexLow += nInsts; |
567 |
indexHigh += nInsts; |
|
568 |
} |
|
328 | 569 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
155 | 570 |
if (indexHigh <= nIndex) { |
571 |
indexLow--; |
|
572 |
indexHigh--; |
|
573 |
if (__isBlockLike(aBlock) |
|
574 |
&& ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
|
345 | 575 |
&& (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
11 | 576 |
#ifdef NEW_BLOCK_CALL |
155 | 577 |
for (index=indexLow; index <= indexHigh; index++) { |
421 | 578 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 579 |
(*codeVal)(aBlock, CON_COMMA _InstPtr(self)->i_instvars[index]); |
580 |
} |
|
11 | 581 |
#else |
155 | 582 |
home = _BlockInstPtr(aBlock)->b_home; |
583 |
rHome = home; |
|
325 | 584 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
370 | 585 |
index = indexLow; |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
586 |
# if defined(UNROLL_LOOPS) |
379 | 587 |
{ |
588 |
int i4; |
|
370 | 589 |
|
379 | 590 |
while ((i4 = index+4) <= indexHigh) { |
421 | 591 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
379 | 592 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index]); |
421 | 593 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
379 | 594 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index+1]); |
421 | 595 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
379 | 596 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index+2]); |
421 | 597 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
379 | 598 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index+3]); |
370 | 599 |
index = i4; |
600 |
} |
|
601 |
} |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
602 |
# endif |
370 | 603 |
for (; index <= indexHigh; index++) { |
421 | 604 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 605 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index]); |
606 |
} |
|
607 |
} else { |
|
608 |
for (index=indexLow; index <= indexHigh; index++) { |
|
421 | 609 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 610 |
(*codeVal)(home, CON_COMMA _InstPtr(self)->i_instvars[index]); |
611 |
} |
|
612 |
} |
|
11 | 613 |
#endif |
155 | 614 |
} else { |
615 |
for (index=indexLow; index <= indexHigh; index++) { |
|
421 | 616 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 617 |
(*val.ilc_func) (aBlock, |
618 |
@symbol(value:), |
|
619 |
CON_COMMA nil, &val, |
|
302 | 620 |
_InstPtr(self)->i_instvars[index]); |
155 | 621 |
} |
622 |
} |
|
623 |
} |
|
624 |
RETURN ( self ); |
|
625 |
} |
|
1 | 626 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
627 |
%}. |
1 | 628 |
^ super from:start to:stop do:aBlock |
629 |
! |
|
630 |
||
42 | 631 |
from:start to:stop reverseDo:aBlock |
632 |
"evaluate the argument, aBlock for the elements starting at index start |
|
633 |
up to (and including) stop in the collection. Step in reverse order. |
|
634 |
- reimplemented for speed" |
|
635 |
||
302 | 636 |
|home| |
42 | 637 |
%{ |
638 |
REGISTER OBJFUNC codeVal; |
|
639 |
REGISTER int index; |
|
640 |
REGISTER OBJ rHome; |
|
586
cab695f942a6
weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents:
577
diff
changeset
|
641 |
int nIndex; |
42 | 642 |
static struct inlineCache val = _ILC1; |
643 |
int indexLow, indexHigh; |
|
644 |
||
586
cab695f942a6
weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents:
577
diff
changeset
|
645 |
if (__bothSmallInteger(start, stop) |
cab695f942a6
weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents:
577
diff
changeset
|
646 |
&& (__qClass(self) == Array)) { |
155 | 647 |
indexLow = _intVal(start); |
648 |
if (indexLow > 0) { |
|
649 |
indexHigh = _intVal(stop); |
|
328 | 650 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
155 | 651 |
if (indexHigh <= nIndex) { |
652 |
indexLow--; |
|
653 |
indexHigh--; |
|
654 |
if (__isBlockLike(aBlock) |
|
655 |
&& ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
|
345 | 656 |
&& (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
42 | 657 |
#ifdef NEW_BLOCK_CALL |
155 | 658 |
for (index=indexHigh; index >= indexLow; index--) { |
421 | 659 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 660 |
(*codeVal)(aBlock, CON_COMMA _InstPtr(self)->i_instvars[index]); |
661 |
} |
|
42 | 662 |
#else |
155 | 663 |
home = _BlockInstPtr(aBlock)->b_home; |
664 |
rHome = home; |
|
325 | 665 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
155 | 666 |
for (index=indexHigh; index >= indexLow; index--) { |
421 | 667 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 668 |
(*codeVal)(rHome, CON_COMMA _InstPtr(self)->i_instvars[index]); |
669 |
} |
|
670 |
} else { |
|
671 |
for (index=indexHigh; index >= indexLow; index--) { |
|
421 | 672 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 673 |
(*codeVal)(home, CON_COMMA _InstPtr(self)->i_instvars[index]); |
674 |
} |
|
675 |
} |
|
42 | 676 |
#endif |
155 | 677 |
} else { |
678 |
for (index=indexHigh; index >= indexLow; index--) { |
|
421 | 679 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 680 |
(*val.ilc_func) (aBlock, |
681 |
@symbol(value:), |
|
682 |
CON_COMMA nil, &val, |
|
302 | 683 |
_InstPtr(self)->i_instvars[index]); |
155 | 684 |
} |
685 |
} |
|
686 |
} |
|
687 |
RETURN ( self ); |
|
688 |
} |
|
42 | 689 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
690 |
%}. |
42 | 691 |
^ super from:start to:stop reverseDo:aBlock |
692 |
! |
|
693 |
||
554 | 694 |
keysAndValuesDo:aBlock |
695 |
"evaluate the argument, aBlock for each element in the collection. |
|
696 |
Pass both index and element to the block. |
|
697 |
- reimplemented for speed" |
|
698 |
||
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
699 |
|home sz "{ Class: SmallInteger }" | |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
700 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
701 |
sz := self size. |
554 | 702 |
%{ |
703 |
REGISTER OBJFUNC codeVal; |
|
704 |
REGISTER int index; |
|
705 |
unsigned int nIndex; |
|
706 |
static struct inlineCache val2 = _ILC2; |
|
707 |
REGISTER OBJ rHome; |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
708 |
int actualSize; |
554 | 709 |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
710 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
711 |
|
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
712 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
713 |
nIndex = index + __intVal(sz); |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
714 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
715 |
if (nIndex <= actualSize) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
716 |
if (__isBlockLike(aBlock) |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
717 |
&& ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
718 |
&& (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) { |
554 | 719 |
#ifdef NEW_BLOCK_CALL |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
720 |
for (; index < nIndex; index++) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
721 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 722 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
723 |
(*codeVal)(aBlock, CON_COMMA __MKSMALLINT(index+1), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
724 |
_InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
725 |
} |
554 | 726 |
#else |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
727 |
home = _BlockInstPtr(aBlock)->b_home; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
728 |
rHome = home; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
729 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
730 |
/* |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
731 |
* home will not move - keep in a fast register |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
732 |
*/ |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
733 |
while (index < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
734 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 735 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
736 |
index++; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
737 |
(*codeVal)(rHome, CON_COMMA __MKSMALLINT(index), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
738 |
_InstPtr(self)->i_instvars[index-1]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
739 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
740 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
741 |
while (index < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
742 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 743 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
744 |
index++; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
745 |
(*codeVal)(home, CON_COMMA __MKSMALLINT(index), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
746 |
_InstPtr(self)->i_instvars[index-1]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
747 |
} |
554 | 748 |
} |
749 |
#endif |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
750 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
751 |
while (index < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
752 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 753 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
754 |
index++; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
755 |
(*val2.ilc_func)(aBlock, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
756 |
@symbol(value:value:), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
757 |
CON_COMMA nil, &val2, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
758 |
__MKSMALLINT(index), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
759 |
_InstPtr(self)->i_instvars[index-1]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
760 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
761 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
762 |
RETURN (self); |
554 | 763 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
764 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
765 |
^ super keysAndValuesDo:aBlock |
554 | 766 |
! |
767 |
||
543 | 768 |
reverseDo:aBlock |
769 |
"evaluate the argument, aBlock for each element in the collection in reverse order. |
|
770 |
- reimplemented for speed" |
|
1 | 771 |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
772 |
|home sz "{ Class: SmallInteger }" | |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
773 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
774 |
sz := self size. |
1 | 775 |
%{ |
776 |
REGISTER OBJFUNC codeVal; |
|
777 |
REGISTER int index; |
|
543 | 778 |
unsigned int nIndex; |
779 |
int endIndex; |
|
1 | 780 |
static struct inlineCache val = _ILC1; |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
781 |
int actualSize; |
1 | 782 |
|
543 | 783 |
endIndex = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
784 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
785 |
nIndex = endIndex + __intVal(sz); |
543 | 786 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
787 |
if (nIndex <= actualSize) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
788 |
if (__isBlockLike(aBlock) |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
789 |
&& ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
790 |
&& (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
11 | 791 |
#ifdef NEW_BLOCK_CALL |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
792 |
for (index=nIndex-1; index >= endIndex; index--) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
793 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
794 |
(*codeVal)(aBlock, CON_COMMA _InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
795 |
} |
11 | 796 |
#else |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
797 |
home = _BlockInstPtr(aBlock)->b_home; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
798 |
for (index=nIndex-1; index >= endIndex; index--) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
799 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
800 |
(*codeVal)(home, CON_COMMA _InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
801 |
} |
11 | 802 |
#endif |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
803 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
804 |
for (index=nIndex-1; index >= endIndex; index--) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
805 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
806 |
(*val.ilc_func)(aBlock, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
807 |
@symbol(value:), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
808 |
CON_COMMA nil, &val, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
809 |
_InstPtr(self)->i_instvars[index]); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
810 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
811 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
812 |
RETURN (self); |
1 | 813 |
} |
543 | 814 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
815 |
^ super reverseDo:aBlock |
11 | 816 |
! |
817 |
||
328 | 818 |
traverse:aBlock |
819 |
"Evaluate aBlock for every element that is not an Array, |
|
1123 | 820 |
and recursively traverse Arrays. |
328 | 821 |
Implemented here to support better search for selectors in |
822 |
literal arrays - might be a good idea to move it up in the collection |
|
823 |
hierarchy, since this may be a useful method for other collections |
|
824 |
as well." |
|
825 |
||
826 |
self do: [:el | |
|
1123 | 827 |
el isArray |
828 |
ifTrue: [el traverse: aBlock] |
|
829 |
ifFalse: [aBlock value: el]] |
|
328 | 830 |
|
831 |
" |
|
832 |
example: flattening an Array: |
|
833 |
||
834 |
|s| |
|
835 |
||
836 |
s := WriteStream on:Array new. |
|
837 |
#(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | s nextPut:el]. |
|
838 |
s contents |
|
839 |
" |
|
1123 | 840 |
" |
841 |
example: deep search |
|
842 |
||
843 |
#(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | |
|
844 |
el == 10 ifTrue:[Transcript showCr:'found'] |
|
845 |
] |
|
846 |
" |
|
847 |
||
848 |
"Modified: 26.3.1996 / 17:08:10 / cg" |
|
543 | 849 |
! ! |
850 |
||
851 |
!Array methodsFor:'filling & replacing'! |
|
852 |
||
554 | 853 |
from:index1 to:index2 put:anObject |
854 |
"reimplemented for speed if receiver is an Array" |
|
855 |
||
856 |
%{ /* NOCONTEXT */ |
|
857 |
||
858 |
REGISTER int index; |
|
859 |
unsigned int nIndex; |
|
860 |
unsigned int endIndex; |
|
861 |
REGISTER OBJ *dst; |
|
862 |
||
863 |
if ((__qClass(self) == Array) |
|
864 |
&& __bothSmallInteger(index1, index2)) { |
|
865 |
index = _intVal(index1) - 1; |
|
866 |
if (index >= 0) { |
|
867 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
868 |
endIndex = _intVal(index2) - 1; |
|
951
2dd898849a8a
directly call __new if quick allocation fails;
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
869 |
if ((endIndex >= index) && (endIndex < nIndex)) { |
554 | 870 |
dst = &(_InstPtr(self)->i_instvars[index]); |
871 |
#ifdef memset4 |
|
872 |
memset4(dst, anObject, (endIndex-index+1)); |
|
873 |
__STORE(self, anObject); |
|
874 |
#else |
|
875 |
if ((INT)anObject == 0) { |
|
876 |
memset(dst, 0, __OBJS2BYTES__(endIndex-index+1)); |
|
877 |
} else { |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
878 |
# if defined(UNROLL_LOOPS) |
554 | 879 |
{ |
880 |
int i8; |
|
881 |
||
882 |
while ((i8 = index + 8) <= endIndex) { |
|
883 |
dst[0] = anObject; |
|
884 |
dst[1] = anObject; |
|
885 |
dst[2] = anObject; |
|
886 |
dst[3] = anObject; |
|
887 |
dst[4] = anObject; |
|
888 |
dst[5] = anObject; |
|
889 |
dst[6] = anObject; |
|
890 |
dst[7] = anObject; |
|
891 |
dst += 8; |
|
892 |
index = i8; |
|
893 |
} |
|
894 |
} |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
895 |
# endif |
554 | 896 |
for (; index <= endIndex; index++) { |
897 |
*dst++ = anObject; |
|
898 |
} |
|
899 |
__STORE(self, anObject); |
|
900 |
} |
|
901 |
#endif |
|
902 |
RETURN ( self ); |
|
903 |
} |
|
904 |
} |
|
905 |
} |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
906 |
%}. |
554 | 907 |
^ super from:index1 to:index2 put:anObject |
908 |
! |
|
909 |
||
543 | 910 |
replaceFrom:start to:stop with:aCollection startingAt:repStart |
911 |
"reimplemented for speed if both receiver and aCollection are Arrays" |
|
912 |
||
913 |
%{ /* NOCONTEXT */ |
|
914 |
||
915 |
unsigned int nIndex; |
|
916 |
unsigned int repNIndex; |
|
917 |
int startIndex, stopIndex; |
|
918 |
REGISTER OBJ *src; |
|
919 |
REGISTER OBJ *dst; |
|
920 |
int repStopIndex; |
|
921 |
REGISTER int repStartIndex; |
|
922 |
REGISTER OBJ t; |
|
923 |
REGISTER int count; |
|
924 |
||
925 |
||
926 |
if ((_ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) |
|
927 |
&& (((t = __Class(aCollection)) == Array) || (t == __qClass(self))) |
|
928 |
&& __bothSmallInteger(start, stop) |
|
929 |
&& __isSmallInteger(repStart)) { |
|
930 |
startIndex = _intVal(start) - 1; |
|
931 |
if (startIndex >= 0) { |
|
932 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
933 |
stopIndex = _intVal(stop) - 1; |
|
934 |
count = stopIndex - startIndex + 1; |
|
935 |
if (count == 0) { |
|
936 |
RETURN ( self ); |
|
937 |
} |
|
938 |
if ((count > 0) && (stopIndex < nIndex)) { |
|
939 |
repStartIndex = _intVal(repStart) - 1; |
|
940 |
if (repStartIndex >= 0) { |
|
941 |
repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); |
|
942 |
repStopIndex = repStartIndex + (stopIndex - startIndex); |
|
943 |
if (repStopIndex < repNIndex) { |
|
944 |
src = &(_InstPtr(aCollection)->i_instvars[repStartIndex]); |
|
945 |
dst = &(_InstPtr(self)->i_instvars[startIndex]); |
|
946 |
if (aCollection == self) { |
|
947 |
/* |
|
948 |
* no need to check stores if copying |
|
949 |
* from myself |
|
950 |
*/ |
|
951 |
/* |
|
952 |
* take care of overlapping copy |
|
953 |
* do not depend on memset being smart enough |
|
954 |
* (some are not ;-) |
|
955 |
*/ |
|
956 |
if (src < dst) { |
|
957 |
/* must do a reverse copy */ |
|
958 |
src += count; |
|
959 |
dst += count; |
|
960 |
#if defined(UNROLL_LOOPS) |
|
961 |
while (count > 8) { |
|
962 |
dst[-1] = src[-1]; |
|
963 |
dst[-2] = src[-2]; |
|
964 |
dst[-3] = src[-3]; |
|
965 |
dst[-4] = src[-4]; |
|
966 |
dst[-5] = src[-5]; |
|
967 |
dst[-6] = src[-6]; |
|
968 |
dst[-7] = src[-7]; |
|
969 |
dst[-8] = src[-8]; |
|
970 |
dst -= 8; src -= 8; |
|
971 |
count -= 8; |
|
972 |
} |
|
973 |
#endif |
|
974 |
while (count-- > 0) { |
|
975 |
*--dst = *--src; |
|
976 |
} |
|
977 |
RETURN ( self ); |
|
978 |
} |
|
979 |
#ifdef bcopy4 |
|
980 |
bcopy4(src, dst, count); |
|
981 |
#else |
|
982 |
# ifdef FAST_MEMCPY |
|
983 |
bcopy(src, dst, __OBJS2BYTES__(count)); |
|
984 |
# else |
|
985 |
while (count--) { |
|
986 |
*dst++ = *src++; |
|
987 |
} |
|
988 |
# endif |
|
989 |
#endif |
|
990 |
} else { |
|
991 |
REGISTER int spc; |
|
992 |
||
993 |
spc = __qSpace(self); |
|
994 |
#if defined(UNROLL_LOOPS) |
|
995 |
while (count >= 4) { |
|
996 |
t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); |
|
997 |
t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); |
|
998 |
t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); |
|
999 |
t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); |
|
1000 |
count -= 4; src += 4; dst += 4; |
|
1001 |
} |
|
1002 |
#endif |
|
1003 |
while (count-- > 0) { |
|
1004 |
t = *src++; |
|
1005 |
*dst++ = t; |
|
1006 |
__STORE_SPC(self, t, spc); |
|
1007 |
} |
|
1008 |
} |
|
1009 |
RETURN ( self ); |
|
1010 |
} |
|
1011 |
} |
|
1012 |
} |
|
1013 |
} |
|
1014 |
} |
|
1015 |
%}. |
|
1016 |
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
|
1017 |
! ! |
|
1018 |
||
1019 |
!Array methodsFor:'printing & storing'! |
|
1020 |
||
1021 |
displayString |
|
1022 |
"return a printed representation of the receiver for displaying" |
|
1023 |
||
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1024 |
|s sz| |
543 | 1025 |
|
1026 |
(self isLiteral) ifTrue:[ |
|
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1027 |
s := WriteStream on:String new. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1028 |
s nextPutAll:'#('. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1029 |
sz := self size. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1030 |
self keysAndValuesDo:[:idx :element | |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1031 |
s nextPutAll:element displayString. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1032 |
idx ~~ sz ifTrue:[s space] |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1033 |
]. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1034 |
s nextPutAll:')'. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1035 |
^ s contents |
543 | 1036 |
]. |
1037 |
^ super displayString |
|
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1038 |
|
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1039 |
" |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1040 |
#(1 2 3 4) displayString |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1041 |
#(1 2 3 4) printString |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1042 |
" |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1043 |
|
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1044 |
"Modified: 7.3.1996 / 15:10:28 / cg" |
543 | 1045 |
! |
1046 |
||
1047 |
storeOn:aStream |
|
1048 |
"append a printed representation of the receiver to aStream, |
|
1049 |
which allows reconstructing it via readFrom:. |
|
1050 |
Redefined to output a somewhat more user friendly string." |
|
1051 |
||
1052 |
self isLiteral ifTrue:[ |
|
588 | 1053 |
aStream nextPutAll:'#('. |
1054 |
self do:[:element | element storeOn:aStream. aStream space]. |
|
1055 |
aStream nextPutAll:')' |
|
543 | 1056 |
] ifFalse:[ |
588 | 1057 |
super storeOn:aStream |
543 | 1058 |
] |
1059 |
||
1060 |
" |
|
1061 |
#(1 2 $a 'hello') storeString |
|
588 | 1062 |
#(1 2 $a [1 2 3]) storeString |
543 | 1063 |
" |
588 | 1064 |
|
1065 |
"Created: 20.11.1995 / 11:16:58 / cg" |
|
543 | 1066 |
! ! |
1067 |
||
1068 |
!Array methodsFor:'queries'! |
|
1069 |
||
1070 |
isArray |
|
1071 |
"return true, if the receiver is some kind of array (or weakArray etc). |
|
1072 |
true is returned here" |
|
1073 |
||
1074 |
^ true |
|
1075 |
! |
|
1076 |
||
1077 |
isLiteral |
|
1078 |
"return true, if the receiver can be used as a literal |
|
1079 |
(i.e. can be used in constant arrays)" |
|
1080 |
||
1081 |
"no, subclasses of array are not" |
|
1082 |
self class == Array ifFalse:[^ false]. |
|
1083 |
||
1084 |
thisContext isRecursive ifTrue:[^ false]. |
|
1085 |
||
1086 |
self do:[:element | |
|
1087 |
element isLiteral ifFalse:[^ false] |
|
1088 |
]. |
|
1089 |
^ true |
|
328 | 1090 |
! |
1091 |
||
543 | 1092 |
refersToLiteral: aLiteral |
1093 |
self do: [ :el | |
|
1094 |
el == aLiteral ifTrue:[^true]. |
|
1095 |
el class == Array ifTrue:[ |
|
1096 |
(el refersToLiteral: aLiteral) ifTrue: [^true] |
|
1097 |
] |
|
1098 |
]. |
|
1099 |
^ false |
|
1100 |
||
1101 |
" |
|
1102 |
#(1 2 3) refersToLiteral:#foo |
|
1103 |
#(1 2 3 foo bar baz) refersToLiteral:#foo |
|
1104 |
#(1 2 3 (((bar foo))) bar baz) refersToLiteral:#foo |
|
1105 |
" |
|
1106 |
! ! |
|
1107 |
||
1108 |
!Array methodsFor:'testing'! |
|
1109 |
||
554 | 1110 |
identityIndexOf:anElement or:alternative |
1111 |
"search the array for anElement or alternative; |
|
1112 |
return the index of anElement if found, or the index of anAlternative, |
|
1113 |
if not found. If anAlternative is also not found, return 0. |
|
1114 |
This is a special interface for high-speed searching in an array |
|
1115 |
and at the same time searching for an empty slot. |
|
1116 |
Do not use this method for your application classes, since it is |
|
1117 |
not portable (i.e. other smalltalks do not offer this)" |
|
1118 |
||
1119 |
%{ /* NOCONTEXT */ |
|
1120 |
||
1121 |
REGISTER int index; |
|
1122 |
REGISTER OBJ o, el1, el2; |
|
1123 |
REGISTER OBJ *op; |
|
1124 |
REGISTER unsigned int nIndex; |
|
1125 |
int altIndex = 0; |
|
1126 |
int nInsts; |
|
1127 |
||
1128 |
index = 0; |
|
1129 |
nInsts = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
|
1130 |
index += nInsts; |
|
1131 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1132 |
el1 = anElement; el2 = alternative; |
|
1133 |
op = & (_InstPtr(self)->i_instvars[index]); |
|
1134 |
while (index++ < nIndex) { |
|
1135 |
if ((o = *op++) == el1) { |
|
1136 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1137 |
} |
|
1138 |
if (o == el2) { |
|
1139 |
if (altIndex == 0) { |
|
1140 |
altIndex = index; |
|
1141 |
} |
|
1142 |
} |
|
1143 |
} |
|
1144 |
RETURN ( __MKSMALLINT(altIndex) ); |
|
1145 |
%} |
|
1146 |
||
1147 |
" |
|
1148 |
#(1 2 3 4 5 6 7 8 9) identityIndexOf:3 or:5 |
|
1149 |
#(1 2 0 4 5 6 7 8 9) identityIndexOf:3 or:5 |
|
1150 |
#(1 2 0 4 5 6 7 3 9) identityIndexOf:3 or:5 |
|
1151 |
#(1 2 3 4 5 nil 7 3 9) identityIndexOf:3 or:nil |
|
1152 |
#(1 2 nil 4 5 6 7 3 9) identityIndexOf:3 or:nil |
|
1153 |
#(1 2 nil 4 5 6 7 8 9) identityIndexOf:3 or:nil |
|
1154 |
#() identityIndexOf:3 or:nil |
|
1155 |
#(1 2) identityIndexOf:3 or:nil |
|
1156 |
" |
|
1157 |
! |
|
1158 |
||
543 | 1159 |
identityIndexOf:anElement startingAt:start |
1160 |
"search the array for anElement; return index if found, 0 otherwise |
|
1161 |
- reimplemented for speed" |
|
1162 |
||
1163 |
%{ /* NOCONTEXT */ |
|
1164 |
||
1165 |
REGISTER int index; |
|
1166 |
REGISTER OBJ el; |
|
1167 |
REGISTER OBJ *op; |
|
1168 |
REGISTER unsigned int nIndex; |
|
1169 |
int nInsts; |
|
1170 |
||
1171 |
if (__isSmallInteger(start)) { |
|
1172 |
index = _intVal(start) - 1; |
|
1173 |
if (index >= 0) { |
|
1174 |
nInsts = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
|
1175 |
index += nInsts; |
|
1176 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1177 |
el = anElement; |
|
1178 |
op = & (_InstPtr(self)->i_instvars[index]); |
|
1179 |
#if defined(UNROLL_LOOPS) |
|
1180 |
{ |
|
1181 |
unsigned int i8; |
|
11 | 1182 |
|
543 | 1183 |
while ((i8 = index + 8) < nIndex) { |
1184 |
if (op[0] == el) { RETURN ( __MKSMALLINT(index + 1 - nInsts) ); } |
|
1185 |
if (op[1] == el) { RETURN ( __MKSMALLINT(index + 2 - nInsts) ); } |
|
1186 |
if (op[2] == el) { RETURN ( __MKSMALLINT(index + 3 - nInsts) ); } |
|
1187 |
if (op[3] == el) { RETURN ( __MKSMALLINT(index + 4 - nInsts) ); } |
|
1188 |
if (op[4] == el) { RETURN ( __MKSMALLINT(index + 5 - nInsts) ); } |
|
1189 |
if (op[5] == el) { RETURN ( __MKSMALLINT(index + 6 - nInsts) ); } |
|
1190 |
if (op[6] == el) { RETURN ( __MKSMALLINT(index + 7 - nInsts) ); } |
|
1191 |
if (op[7] == el) { RETURN ( __MKSMALLINT(index + 8 - nInsts) ); } |
|
1192 |
index = i8; |
|
1193 |
op += 8; |
|
1194 |
} |
|
1195 |
} |
|
1196 |
#endif |
|
1197 |
while (index++ < nIndex) { |
|
1198 |
if (*op++ == el) { |
|
1199 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1200 |
} |
|
1201 |
} |
|
1202 |
RETURN ( __MKSMALLINT(0) ); |
|
1203 |
} |
|
1204 |
} |
|
1205 |
%}. |
|
1206 |
^ super identityIndexOf:anElement startingAt:start |
|
1207 |
! |
|
1208 |
||
1209 |
includes:anObject |
|
1210 |
"return true, if the argument, anObject is contained in the array |
|
1211 |
- reimplemented for speed" |
|
1212 |
||
1213 |
|element| |
|
1214 |
||
1215 |
%{ /* NOCONTEXT */ |
|
1216 |
||
1217 |
/* |
|
1218 |
* first, do a quick check using == |
|
1219 |
* this does not need a context or message send. |
|
1220 |
* In many cases this will already find a match. |
|
1221 |
*/ |
|
1222 |
REGISTER int index; |
|
1223 |
REGISTER OBJ o; |
|
1224 |
unsigned int nIndex; |
|
1225 |
||
1226 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1227 |
index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
|
1228 |
||
1229 |
/* |
|
1230 |
* however, the search is limited to the first 1000 |
|
1231 |
* elements, since otherwise, we may spend too much time |
|
1232 |
* searching for identity if an equal value is found early |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1233 |
* (except if searching for nil - there is no need for equal compare ...) |
543 | 1234 |
*/ |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1235 |
if (nIndex > 1000) { |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1236 |
if (o != nil) |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1237 |
nIndex = 1000; |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1238 |
} |
543 | 1239 |
|
1240 |
o = anObject; |
|
1241 |
#if defined(UNROLL_LOOPS) |
|
1242 |
{ |
|
1243 |
unsigned int i8; |
|
1244 |
||
1245 |
while ((i8 = index + 8) < nIndex) { |
|
1246 |
if (_InstPtr(self)->i_instvars[index] == o) { RETURN ( true ); } |
|
1247 |
if (_InstPtr(self)->i_instvars[index+1] == o) { RETURN ( true ); } |
|
1248 |
if (_InstPtr(self)->i_instvars[index+2] == o) { RETURN ( true ); } |
|
1249 |
if (_InstPtr(self)->i_instvars[index+3] == o) { RETURN ( true ); } |
|
1250 |
if (_InstPtr(self)->i_instvars[index+4] == o) { RETURN ( true ); } |
|
1251 |
if (_InstPtr(self)->i_instvars[index+5] == o) { RETURN ( true ); } |
|
1252 |
if (_InstPtr(self)->i_instvars[index+6] == o) { RETURN ( true ); } |
|
1253 |
if (_InstPtr(self)->i_instvars[index+7] == o) { RETURN ( true ); } |
|
1254 |
index = i8; |
|
1255 |
} |
|
1256 |
} |
|
1257 |
#endif |
|
1258 |
while (index < nIndex) { |
|
1259 |
if (_InstPtr(self)->i_instvars[index++] == o) { |
|
1260 |
RETURN ( true ); |
|
1261 |
} |
|
1262 |
} |
|
1263 |
if (o == nil) { |
|
1264 |
RETURN ( false ); |
|
1265 |
} |
|
1266 |
%} |
|
1267 |
. |
|
1268 |
%{ |
|
1269 |
/* |
|
1270 |
* then do a slow(er) check using = |
|
1271 |
*/ |
|
1272 |
REGISTER int index; |
|
1273 |
unsigned int nIndex; |
|
1274 |
static struct inlineCache eq = _ILC1; |
|
11 | 1275 |
|
543 | 1276 |
/* |
1277 |
* sorry: cannot access the stuff from above ... |
|
1278 |
*/ |
|
1279 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1280 |
index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
|
1281 |
||
1282 |
while (index < nIndex) { |
|
1283 |
element = _InstPtr(self)->i_instvars[index++]; |
|
1284 |
if (element != nil) { |
|
1285 |
if ((*eq.ilc_func)(anObject, |
|
1286 |
@symbol(=), |
|
1287 |
CON_COMMA nil,&eq, |
|
1288 |
element)==true) { |
|
1289 |
RETURN ( true ); |
|
1290 |
} |
|
1291 |
} |
|
1292 |
} |
|
1293 |
%}. |
|
1294 |
^ false |
|
1295 |
! |
|
1296 |
||
554 | 1297 |
indexOf:anElement startingAt:start |
1298 |
"search the array for anElement; return index if found, 0 otherwise |
|
1299 |
- reimplemented for speed" |
|
543 | 1300 |
|
554 | 1301 |
|element| |
1302 |
%{ |
|
543 | 1303 |
REGISTER int index; |
554 | 1304 |
unsigned int nIndex, nInsts; |
1305 |
static struct inlineCache eq = _ILC1; |
|
543 | 1306 |
|
554 | 1307 |
if (__isSmallInteger(start)) { |
1308 |
index = _intVal(start) - 1; |
|
1309 |
if (index >= 0) { |
|
1310 |
nInsts = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
|
1311 |
index += nInsts; |
|
1312 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1313 |
if (anElement != nil) { |
|
825
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1314 |
#define SPECIAL_STRING_OPT |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1315 |
#ifdef SPECIAL_STRING_OPT |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1316 |
if (__isString(anElement)) { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1317 |
while (index < nIndex) { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1318 |
element = _InstPtr(self)->i_instvars[index++]; |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1319 |
if (__isNonNilObject(element)) { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1320 |
if (element == anElement) { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1321 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1322 |
} |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1323 |
if (__qClass(element) == @global(String)) { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1324 |
if (strcmp(__stringVal(anElement), __stringVal(element)) == 0) { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1325 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1326 |
} |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1327 |
} else { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1328 |
if ((*eq.ilc_func)(anElement, @symbol(=), CON_COMMA nil,&eq, element) == true) { |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1329 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1330 |
} |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1331 |
} |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1332 |
} |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1333 |
} |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1334 |
RETURN (__MKSMALLINT(0)); |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1335 |
} |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1336 |
#endif |
554 | 1337 |
while (index < nIndex) { |
1338 |
element = _InstPtr(self)->i_instvars[index++]; |
|
1339 |
if (element != nil) { |
|
1340 |
if ((element == anElement) |
|
1341 |
|| ((*eq.ilc_func)(anElement, |
|
1342 |
@symbol(=), |
|
1343 |
CON_COMMA nil,&eq, |
|
1344 |
element) == true)) { |
|
1345 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1346 |
} |
|
1347 |
} |
|
1348 |
} |
|
1349 |
} else { |
|
1350 |
/* search for nil */ |
|
1351 |
#if defined(UNROLL_LOOPS) |
|
1352 |
{ |
|
1353 |
unsigned int i8; |
|
1354 |
||
1355 |
while ((i8 = index + 8) < nIndex) { |
|
1356 |
if (_InstPtr(self)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
|
1357 |
if (_InstPtr(self)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
|
1358 |
if (_InstPtr(self)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
|
1359 |
if (_InstPtr(self)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
|
1360 |
if (_InstPtr(self)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
|
1361 |
if (_InstPtr(self)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
|
1362 |
if (_InstPtr(self)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
|
1363 |
if (_InstPtr(self)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
|
1364 |
index = i8; |
|
1365 |
} |
|
1366 |
} |
|
1367 |
#endif |
|
1368 |
||
1369 |
while (index < nIndex) { |
|
1370 |
if (_InstPtr(self)->i_instvars[index++] == nil) { |
|
1371 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1372 |
} |
|
1373 |
} |
|
543 | 1374 |
} |
1375 |
} |
|
1376 |
} |
|
554 | 1377 |
%}. |
1378 |
^ 0 |
|
1 | 1379 |
! ! |
543 | 1380 |
|
626 | 1381 |
!Array class methodsFor:'documentation'! |
1382 |
||
1383 |
version |
|
1123 | 1384 |
^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.58 1996-03-26 16:08:34 cg Exp $'! ! |