author | Claus Gittinger <cg@exept.de> |
Thu, 17 Aug 2000 19:27:04 +0200 | |
changeset 5531 | 27f62fc8193f |
parent 5511 | cb9c0607c8c7 |
child 5537 | 05d01dd462f6 |
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 |
||
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
13 |
"{ Package: 'stx:libbasic' }" |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
14 |
|
1 | 15 |
ArrayedCollection variableSubclass:#Array |
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
16 |
instanceVariableNames:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
17 |
classVariableNames:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
18 |
poolDictionaries:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
19 |
category:'Collections-Arrayed' |
1 | 20 |
! |
21 |
||
1903 | 22 |
!Array class methodsFor:'documentation'! |
77 | 23 |
|
554 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
77 | 38 |
documentation |
39 |
" |
|
155 | 40 |
Instances of Array store general objects; the arrays size is fixed, |
41 |
therefore add:/remove: are not allowed. |
|
399 | 42 |
(actually, #add: is implemented for compatibility with smalltalks which |
1266 | 43 |
provide it, but it is very slow and outputs an annoying warning message ...) |
44 |
||
45 |
Access to the individual elements is via an integer index, |
|
46 |
using the well-known access messages #at: and #at:put:. |
|
399 | 47 |
|
1903 | 48 |
Since Arrays are used very often in the system (either directly or a data-container |
49 |
of more complex collection classes), some methods have been tuned by reimplementing |
|
50 |
them as primitives. Also, the compiler inline-codes some operations |
|
51 |
(especially: the above accessing messages). |
|
92 | 52 |
|
1266 | 53 |
Notice that Array is a built-in class |
54 |
(i.e. the VM knows about its representation). |
|
55 |
Therefore it is NOT possible to add named instance variables or change |
|
56 |
Arrays inheritance. |
|
57 |
However, subclassing is allowed of course |
|
58 |
- even with added named instance variables. |
|
92 | 59 |
|
60 |
Literal arrays (i.e. array-constants) are entered in source as: |
|
1266 | 61 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
62 |
#( element1 element2 ... element-n) |
1266 | 63 |
|
64 |
where each element must be itself a literal constant. |
|
65 |
Array, symbol and byteArray constants within an array can be written |
|
66 |
without the initial #-character. |
|
67 |
In addition, true, false and nil are also allowed as array-literal. |
|
399 | 68 |
|
92 | 69 |
Examples: |
1266 | 70 |
#(1 2 3) -> 3 elements: 1, 2 and 3 |
71 |
#('foo' 2 (1 2)) -> 3 elements: a String, 2 and anotherArray |
|
72 |
#('foo' #(1 2) #foo) -> 3 elements: a String, another array and a symbol |
|
73 |
#('foo' (1 2) foo) -> same as above |
|
74 |
#(nil true #true) -> 3 elements: nil, true and a symbol (watch out) |
|
75 |
#(two [3 3 3] (4 4 4)) -> 3 elements: a symbol, a byteArray and another array |
|
1276 | 76 |
|
4062 | 77 |
[memory requirements:] |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
78 |
OBJ-HEADER + (size * ptr-size) |
4062 | 79 |
|
2145 | 80 |
[warning:] |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
81 |
read the warning about 'growing fixed size collection' |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
82 |
in ArrayedCollection's documentation |
1276 | 83 |
|
1290 | 84 |
[author:] |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
85 |
Claus Gittinger |
1290 | 86 |
|
1276 | 87 |
[see also:] |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
88 |
OrderedCollection |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
89 |
ByteArray FloatArray DoubleArray |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
90 |
String |
77 | 91 |
" |
626 | 92 |
! ! |
3 | 93 |
|
1903 | 94 |
!Array class methodsFor:'instance creation'! |
249 | 95 |
|
96 |
basicNew:anInteger |
|
97 |
"return an instance of myself with anInteger indexed variables. |
|
98 |
Since Array-creation is so common (all other collections use them), |
|
99 |
it seems worth to have a specially tuned version here." |
|
100 |
||
101 |
%{ /* NOCONTEXT */ |
|
102 |
||
103 |
OBJ newobj; |
|
104 |
unsigned INT instsize, nInstVars; |
|
105 |
INT nindexedinstvars; |
|
106 |
REGISTER OBJ *op; |
|
107 |
||
108 |
if (__isSmallInteger(anInteger)) { |
|
1133 | 109 |
nindexedinstvars = __intVal(anInteger); |
249 | 110 |
if (nindexedinstvars >= 0) { |
1133 | 111 |
nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars); |
249 | 112 |
|
113 |
nInstVars += nindexedinstvars; |
|
114 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
2915 | 115 |
if (__CanDoQuickAlignedNew(instsize)) { /* OBJECT ALLOCATION */ |
357 | 116 |
/* |
117 |
* the most common case |
|
118 |
*/ |
|
835 | 119 |
__qCheckedAlignedNew(newobj, instsize); |
357 | 120 |
ok: ; |
1133 | 121 |
__InstPtr(newobj)->o_class = self; |
369 | 122 |
__qSTORE(newobj, self); |
123 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
124 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) |
1133 | 125 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
249 | 126 |
#else |
127 |
# if !defined(NEGATIVE_ADDRESSES) |
|
128 |
/* |
|
129 |
* knowing that nil is 0 |
|
130 |
*/ |
|
360 | 131 |
#ifdef XXmips |
249 | 132 |
# undef FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
133 |
# undef FAST_ARRAY_MEMSET_LONGLONG_UNROLLED |
|
134 |
/* seems to be slightly faster */ |
|
135 |
# define FAST_ARRAY_MEMSET |
|
136 |
#endif |
|
2979 | 137 |
|
249 | 138 |
#ifdef sparc |
139 |
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
|
140 |
#endif |
|
141 |
||
2979 | 142 |
#ifdef __VMS__ |
143 |
# define FAST_ARRAY_MEMSET_LONGLONG_UNROLLED |
|
144 |
#endif |
|
145 |
||
249 | 146 |
# if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED) |
1133 | 147 |
op = __InstPtr(newobj)->i_instvars; |
249 | 148 |
if (nInstVars > 8) { |
149 |
*op++ = nil; /* for alignment */ |
|
150 |
nInstVars--; |
|
151 |
while (nInstVars >= 8) { |
|
152 |
*(double *)op = 0.0; |
|
153 |
((double *)op)[1] = 0.0; |
|
154 |
((double *)op)[2] = 0.0; |
|
155 |
((double *)op)[3] = 0.0; |
|
156 |
op += 8; |
|
157 |
nInstVars -= 8; |
|
158 |
} |
|
159 |
} |
|
160 |
while (nInstVars) { |
|
161 |
*op++ = 0; |
|
162 |
nInstVars--; |
|
163 |
} |
|
164 |
# else |
|
165 |
# if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED) |
|
2979 | 166 |
# ifdef INT64 |
167 |
# define LONGLONG INT64 |
|
168 |
# else |
|
169 |
# define LONGLONG long long |
|
170 |
# endif |
|
171 |
||
1133 | 172 |
op = __InstPtr(newobj)->i_instvars; |
249 | 173 |
if (nInstVars > 8) { |
174 |
*op++ = nil; /* for alignment */ |
|
175 |
nInstVars--; |
|
176 |
while (nInstVars >= 8) { |
|
2979 | 177 |
*(LONGLONG *)op = 0; |
178 |
((LONGLONG *)op)[1] = 0; |
|
179 |
((LONGLONG *)op)[2] = 0; |
|
180 |
((LONGLONG *)op)[3] = 0; |
|
249 | 181 |
op += 8; |
182 |
nInstVars -= 8; |
|
183 |
} |
|
184 |
} |
|
185 |
while (nInstVars) { |
|
186 |
*op++ = 0; |
|
187 |
nInstVars--; |
|
188 |
} |
|
189 |
# else |
|
190 |
# if defined(FAST_ARRAY_MEMSET) |
|
1133 | 191 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
249 | 192 |
# else |
1133 | 193 |
op = __InstPtr(newobj)->i_instvars; |
2950 | 194 |
# if defined(INT64) |
195 |
while (nInstVars > 1) { |
|
196 |
*((INT64 *)op) = 0; |
|
197 |
nInstVars -= 2; |
|
198 |
op += 2; |
|
199 |
} |
|
200 |
# endif |
|
249 | 201 |
while (nInstVars--) |
202 |
*op++ = nil; |
|
203 |
# endif |
|
204 |
# endif |
|
205 |
# endif |
|
206 |
# else |
|
1133 | 207 |
op = __InstPtr(newobj)->i_instvars; |
249 | 208 |
while (nInstVars--) |
209 |
*op++ = nil; |
|
210 |
# endif |
|
211 |
#endif |
|
212 |
RETURN ( newobj ); |
|
357 | 213 |
} else { |
214 |
/* |
|
215 |
* a GC will happen ... |
|
216 |
* have to protect all context stuff |
|
217 |
* (especially for self, but also for backtrace in case of |
|
218 |
* allocation failure) |
|
219 |
*/ |
|
834 | 220 |
__PROTECT_CONTEXT__ |
3979
46a2da9b917d
renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents:
3730
diff
changeset
|
221 |
newobj = __STX___new(instsize); |
834 | 222 |
__UNPROTECT_CONTEXT__ |
357 | 223 |
if (newobj != nil) { |
224 |
goto ok; |
|
225 |
} |
|
249 | 226 |
} |
227 |
} |
|
228 |
} |
|
229 |
%}. |
|
230 |
" |
|
231 |
arrive here if something went wrong ... |
|
232 |
figure out what it was |
|
233 |
" |
|
234 |
(anInteger isMemberOf:SmallInteger) ifFalse:[ |
|
235 |
" |
|
236 |
the argument is either not an integer, |
|
237 |
or a LargeInteger (which means that its definitely too big) |
|
238 |
" |
|
239 |
self error:'argument to new: must be Integer'. |
|
240 |
^ nil |
|
241 |
]. |
|
242 |
(anInteger < 0) ifTrue:[ |
|
243 |
" |
|
244 |
the argument is negative, |
|
245 |
" |
|
246 |
self error:'bad (negative) argument to new:'. |
|
247 |
^ nil |
|
248 |
]. |
|
249 |
" |
|
250 |
memory allocation failed. |
|
251 |
When we arrive here, there was no memory, even after |
|
252 |
a garbage collect. |
|
253 |
This means, that the VM wanted to get some more memory from the |
|
254 |
Operatingsystem, which was not kind enough to give it. |
|
255 |
Bad luck - you should increase the swap space on your machine. |
|
256 |
" |
|
257 |
^ ObjectMemory allocationFailureSignal raise. |
|
549 | 258 |
! |
259 |
||
260 |
new:anInteger |
|
261 |
"return an instance of myself with anInteger indexed variables. |
|
1266 | 262 |
Redefined here to save a few cycles when executed. |
263 |
(Since this is often called, its worth giving it an extra ilc-slot. |
|
264 |
Future versions of stc will do this automatically.)" |
|
549 | 265 |
|
266 |
^ self basicNew:anInteger |
|
1266 | 267 |
|
268 |
"Modified: 23.4.1996 / 15:52:15 / cg" |
|
360 | 269 |
! ! |
270 |
||
1903 | 271 |
!Array class methodsFor:'queries'! |
345 | 272 |
|
543 | 273 |
isBuiltInClass |
1266 | 274 |
"return true if this class is known by the run-time-system. |
275 |
Here, true is returned for myself, false for subclasses." |
|
345 | 276 |
|
543 | 277 |
^ self == Array |
1243 | 278 |
|
1266 | 279 |
"Modified: 23.4.1996 / 15:55:06 / cg" |
249 | 280 |
! ! |
281 |
||
1 | 282 |
!Array methodsFor:'accessing'! |
283 |
||
554 | 284 |
at:index |
285 |
"return the indexed instance variable with index, anInteger. |
|
286 |
Reimplemented here to avoid the additional at:->basicAt: send |
|
1730 | 287 |
(which we can do here, since when arriving here, #at: is obviously not |
288 |
redefined in a subclass). |
|
577 | 289 |
This method is the same as basicAt:." |
543 | 290 |
|
291 |
%{ /* NOCONTEXT */ |
|
292 |
||
554 | 293 |
REGISTER int indx; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
294 |
REGISTER OBJ slf; |
554 | 295 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
296 |
REGISTER OBJ cls; |
554 | 297 |
|
298 |
if (__isSmallInteger(index)) { |
|
4474 | 299 |
indx = __intVal(index) - 1; |
300 |
slf = self; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
301 |
|
4474 | 302 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
303 |
if ((cls = __qClass(slf)) != Array) { |
|
304 |
if (indx < 0) goto badIndex; |
|
305 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
306 |
} |
|
307 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
308 |
RETURN ( __InstPtr(slf)->i_instvars[indx] ); |
|
309 |
} |
|
554 | 310 |
} |
4385
dbe7d1e8c54c
oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents:
4309
diff
changeset
|
311 |
badIndex: ; |
554 | 312 |
%}. |
4474 | 313 |
"/ ^ super at:index |
314 |
^ super basicAt:index "/ knowing that super-#at: does #basicAt: |
|
543 | 315 |
! |
316 |
||
554 | 317 |
at:index put:anObject |
318 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
1219 | 319 |
Returns anObject (sigh). |
554 | 320 |
Reimplemented here to avoid the additional at:put:->basicAt:put: send |
1730 | 321 |
(which we can do here, since when arriving here, #atput:: is obviously not |
322 |
redefined in a subclass). |
|
577 | 323 |
This method is the same as basicAt:put:." |
549 | 324 |
|
325 |
%{ /* NOCONTEXT */ |
|
326 |
||
554 | 327 |
REGISTER int indx; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
328 |
REGISTER OBJ slf; |
554 | 329 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
330 |
REGISTER OBJ cls; |
554 | 331 |
|
332 |
if (__isSmallInteger(index)) { |
|
4474 | 333 |
indx = __intVal(index) - 1; |
334 |
slf = self; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
335 |
|
4474 | 336 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
337 |
if ((cls = __qClass(slf)) != Array) { |
|
338 |
if (indx < 0) goto badIndex; |
|
339 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
340 |
} |
|
341 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
342 |
__InstPtr(slf)->i_instvars[indx] = anObject; |
|
343 |
__STORE(slf, anObject); |
|
344 |
RETURN ( anObject ); |
|
345 |
} |
|
554 | 346 |
} |
4385
dbe7d1e8c54c
oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents:
4309
diff
changeset
|
347 |
badIndex: ; |
554 | 348 |
%}. |
4474 | 349 |
"/ ^ super at:index put:anObject |
350 |
^ super basicAt:index put:anObject "/ knowing that super-#at:put: does #basicAt:put: |
|
1219 | 351 |
|
352 |
"Modified: 19.4.1996 / 11:16:42 / cg" |
|
549 | 353 |
! |
354 |
||
355 |
basicAt:index |
|
356 |
"return the indexed instance variable with index, anInteger |
|
357 |
- added here for speed" |
|
358 |
||
359 |
%{ /* NOCONTEXT */ |
|
360 |
||
361 |
REGISTER int indx; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
362 |
REGISTER OBJ slf; |
549 | 363 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
364 |
REGISTER OBJ cls; |
549 | 365 |
|
366 |
if (__isSmallInteger(index)) { |
|
4474 | 367 |
indx = __intVal(index) - 1; |
368 |
slf = self; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
369 |
|
4474 | 370 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
371 |
if ((cls = __qClass(slf)) != Array) { |
|
372 |
if (indx < 0) goto badIndex; |
|
373 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
374 |
} |
|
375 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
376 |
RETURN ( __InstPtr(slf)->i_instvars[indx] ); |
|
377 |
} |
|
549 | 378 |
} |
4385
dbe7d1e8c54c
oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents:
4309
diff
changeset
|
379 |
badIndex: ; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
380 |
%}. |
549 | 381 |
^ super basicAt:index |
382 |
! |
|
383 |
||
77 | 384 |
basicAt:index put:anObject |
1 | 385 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
1219 | 386 |
Returns anObject (sigh). |
1 | 387 |
- added here for speed" |
388 |
||
389 |
%{ /* NOCONTEXT */ |
|
390 |
||
391 |
REGISTER int indx; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
392 |
REGISTER OBJ slf; |
92 | 393 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
394 |
REGISTER OBJ cls; |
1 | 395 |
|
249 | 396 |
if (__isSmallInteger(index)) { |
4474 | 397 |
indx = __intVal(index) - 1; |
398 |
slf = self; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
399 |
|
4474 | 400 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
401 |
if ((cls = __qClass(slf)) != Array) { |
|
402 |
if (indx < 0) goto badIndex; |
|
403 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
404 |
} |
|
405 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
406 |
__InstPtr(slf)->i_instvars[indx] = anObject; |
|
407 |
__STORE(slf, anObject); |
|
408 |
RETURN ( anObject ); |
|
409 |
} |
|
1 | 410 |
} |
4385
dbe7d1e8c54c
oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents:
4309
diff
changeset
|
411 |
badIndex: ; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
412 |
%}. |
77 | 413 |
^ super basicAt:index put:anObject |
1219 | 414 |
|
415 |
"Modified: 19.4.1996 / 11:14:26 / cg" |
|
551 | 416 |
! |
417 |
||
554 | 418 |
basicSize |
419 |
"return the number of indexed elements in the receiver" |
|
551 | 420 |
|
421 |
%{ /* NOCONTEXT */ |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
422 |
REGISTER OBJ slf = self; |
551 | 423 |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
424 |
RETURN ( __MKSMALLINT(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) )); |
554 | 425 |
%} |
551 | 426 |
! |
427 |
||
554 | 428 |
size |
429 |
"return the number of indexed elements in the receiver. |
|
430 |
Reimplemented here to avoid the additional size->basicSize send |
|
1730 | 431 |
(which we can do here, since when arriving here, #size is obviously not |
432 |
redefined in a subclass). |
|
554 | 433 |
This method is the same as basicSize." |
551 | 434 |
|
435 |
%{ /* NOCONTEXT */ |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
436 |
REGISTER OBJ slf = self; |
551 | 437 |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
438 |
RETURN ( __MKSMALLINT(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) )); |
554 | 439 |
%} |
1 | 440 |
! ! |
441 |
||
11 | 442 |
!Array methodsFor:'converting'! |
443 |
||
444 |
asArray |
|
5531 | 445 |
"return the receiver as an array - thats the receiver itself." |
11 | 446 |
|
447 |
"could be an instance of a subclass..." |
|
448 |
self class == Array ifTrue:[ |
|
5531 | 449 |
^ self |
11 | 450 |
]. |
451 |
^ super asArray |
|
1243 | 452 |
|
453 |
"Modified: 22.4.1996 / 12:42:09 / cg" |
|
11 | 454 |
! ! |
455 |
||
1 | 456 |
!Array methodsFor:'copying'! |
457 |
||
458 |
copyWith:something |
|
220 | 459 |
"return a new collection containing the receivers elements |
460 |
and the single new element, newElement. |
|
461 |
This is different from concatentation, which expects another collection |
|
462 |
as argument, but equivalent to copy-and-addLast. |
|
370 | 463 |
Reimplemented for speed if receiver is an Array. |
464 |
(since the inherited copyWith uses replaceFromTo:, which is also |
|
465 |
tuned, it is questionable, if we need this)" |
|
466 |
||
467 |
%{ /* NOCONTEXT */ |
|
4122 | 468 |
OBJ nObj; |
92 | 469 |
unsigned int sz; |
470 |
unsigned int nIndex; |
|
11 | 471 |
REGISTER OBJ *srcP, *dstP; |
293 | 472 |
REGISTER int spc; |
1 | 473 |
|
328 | 474 |
if (__qClass(self) == Array) { |
475 |
sz = __qSize(self) + sizeof(OBJ); |
|
1399 | 476 |
__PROTECT2__(something, self); |
2915 | 477 |
__qAlignedNew(nObj, sz); /* OBJECT ALLOCATION */ |
1399 | 478 |
__UNPROTECT2__(self, something); |
92 | 479 |
|
155 | 480 |
if (nObj) { |
1133 | 481 |
__InstPtr(nObj)->o_class = Array; |
3730
375237229a8e
replaceFrom... - unrolled 8 times;
Claus Gittinger <cg@exept.de>
parents:
3500
diff
changeset
|
482 |
__STORE(nObj, Array); |
1 | 483 |
|
155 | 484 |
nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ)); |
370 | 485 |
/* |
486 |
* sorry: |
|
4122 | 487 |
* cannot use bcopy, since we must take care of stores ... |
488 |
* could check for: notRemembered + inOld + notLifoRem |
|
370 | 489 |
* + not incrGCRunning |
4122 | 490 |
* but: copyWith is not heavily used by real programmers ... |
370 | 491 |
*/ |
492 |
spc = __qSpace(nObj); |
|
1133 | 493 |
srcP = __ArrayInstPtr(self)->a_element; |
494 |
dstP = __ArrayInstPtr(nObj)->a_element; |
|
1903 | 495 |
|
393 | 496 |
#ifdef UNROLL_LOOPS |
497 |
while (nIndex >= 4) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
498 |
OBJ element; |
4122 | 499 |
|
393 | 500 |
element = srcP[0]; |
501 |
dstP[0] = element; |
|
502 |
__STORE_SPC(nObj, element, spc); |
|
503 |
element = srcP[1]; |
|
504 |
dstP[1] = element; |
|
505 |
__STORE_SPC(nObj, element, spc); |
|
506 |
element = srcP[2]; |
|
507 |
dstP[2] = element; |
|
508 |
__STORE_SPC(nObj, element, spc); |
|
509 |
element = srcP[3]; |
|
510 |
dstP[3] = element; |
|
511 |
__STORE_SPC(nObj, element, spc); |
|
512 |
srcP += 4; |
|
513 |
dstP += 4; |
|
514 |
nIndex -= 4; |
|
515 |
} |
|
516 |
#endif |
|
155 | 517 |
while (nIndex--) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
518 |
OBJ element; |
4122 | 519 |
|
155 | 520 |
element = *srcP++; |
521 |
*dstP++ = element; |
|
293 | 522 |
__STORE_SPC(nObj, element, spc); |
155 | 523 |
} |
524 |
*dstP = something; |
|
293 | 525 |
__STORE_SPC(nObj, something, spc); |
155 | 526 |
RETURN ( nObj ); |
527 |
} |
|
1 | 528 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
529 |
%}. |
1 | 530 |
^ super copyWith:something |
531 |
! ! |
|
532 |
||
216 | 533 |
!Array methodsFor:'enumerating'! |
1 | 534 |
|
554 | 535 |
addAllTo:aCollection |
536 |
"add all elements of the receiver to aCollection. |
|
537 |
return aCollection." |
|
538 |
||
539 |
|stop "{ Class: SmallInteger }"| |
|
540 |
||
541 |
stop := self size. |
|
542 |
1 to:stop do:[:idx | |
|
543 |
aCollection add:(self at:idx) |
|
544 |
]. |
|
545 |
^ aCollection |
|
546 |
! |
|
547 |
||
548 |
do:aBlock |
|
549 |
"evaluate the argument, aBlock for each element in the collection. |
|
4122 | 550 |
- reimplemented for speed, since this is used by many higher |
551 |
level collections" |
|
554 | 552 |
|
2202 | 553 |
| sz "{ Class: SmallInteger }"| |
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
|
554 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
555 |
sz := self size. |
554 | 556 |
%{ |
557 |
REGISTER OBJFUNC codeVal; |
|
558 |
REGISTER int index; |
|
559 |
unsigned int nIndex; |
|
560 |
static struct inlineCache val = _ILC1; |
|
561 |
REGISTER OBJ rHome; |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
562 |
int actualSize; |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
563 |
|
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
564 |
{ |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
565 |
OBJ mySelf = self; |
554 | 566 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
567 |
index = __intVal(__ClassInstPtr(__qClass(mySelf))->c_ninstvars); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
568 |
actualSize = __BYTES2OBJS__(__qSize(mySelf) - OHDR_SIZE); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
569 |
} |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
570 |
|
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
571 |
nIndex = index + __intVal(sz); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
572 |
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
|
573 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
574 |
if (__isBlockLike(aBlock) |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
575 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
576 |
{ |
2915 | 577 |
/* |
578 |
* the most common case: a static compiled block, with home on the stack ... |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
579 |
*/ |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
580 |
REGISTER OBJFUNC codeVal; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
581 |
|
2915 | 582 |
if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
2678 | 583 |
#ifdef PARANOIA |
2915 | 584 |
&& (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) |
2678 | 585 |
#endif |
586 |
) { |
|
2254 | 587 |
|
554 | 588 |
#ifdef NEW_BLOCK_CALL |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
589 |
# define BLOCK_ARG aBlock |
554 | 590 |
#else |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
591 |
# define BLOCK_ARG rHome |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
592 |
REGISTER OBJ rHome; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
593 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
594 |
rHome = __BlockInstPtr(aBlock)->b_home; |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
595 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
596 |
#endif |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
597 |
{ |
2216 | 598 |
|
2878 | 599 |
/* |
600 |
* boy; what an ugly looking piece of code ... |
|
601 |
* however, this software pipelined thing has no taken conditional |
|
602 |
* branches in the normal case and is almost twice as fast to even |
|
603 |
* what an unrolling optimizing compiler produces from the loop below ... |
|
604 |
* notice, that those gotos expand to forward branches (which are predicted |
|
605 |
* as NOT taken by most machines ... which is exactly what we want) |
|
606 |
*/ |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
607 |
REGISTER OBJ el; |
3484 | 608 |
#if defined(UNROLL_LOOPS) |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
609 |
|
2216 | 610 |
{ |
611 |
int i8; |
|
612 |
||
613 |
while ((i8 = index+8) < nIndex) { |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
614 |
el = __InstPtr(self)->i_instvars[index]; |
2216 | 615 |
if (InterruptPending != nil) goto interrupt0; |
616 |
continue0: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
617 |
(*codeVal)(BLOCK_ARG, el); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
618 |
el = __InstPtr(self)->i_instvars[index+1]; |
2216 | 619 |
if (InterruptPending != nil) goto interrupt1; |
620 |
continue1: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
621 |
(*codeVal)(BLOCK_ARG, el); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
622 |
el = __InstPtr(self)->i_instvars[index+2]; |
2216 | 623 |
if (InterruptPending != nil) goto interrupt2; |
624 |
continue2: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
625 |
(*codeVal)(BLOCK_ARG, el); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
626 |
el = __InstPtr(self)->i_instvars[index+3]; |
2216 | 627 |
if (InterruptPending != nil) goto interrupt3; |
628 |
continue3: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
629 |
(*codeVal)(BLOCK_ARG, el); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
630 |
el = __InstPtr(self)->i_instvars[index+4]; |
2216 | 631 |
if (InterruptPending != nil) goto interrupt4; |
632 |
continue4: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
633 |
(*codeVal)(BLOCK_ARG, el); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
634 |
el = __InstPtr(self)->i_instvars[index+5]; |
2216 | 635 |
if (InterruptPending != nil) goto interrupt5; |
636 |
continue5: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
637 |
(*codeVal)(BLOCK_ARG, el); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
638 |
el = __InstPtr(self)->i_instvars[index+6]; |
2216 | 639 |
if (InterruptPending != nil) goto interrupt6; |
640 |
continue6: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
641 |
(*codeVal)(BLOCK_ARG, el); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
642 |
el = __InstPtr(self)->i_instvars[index+7]; |
2216 | 643 |
if (InterruptPending != nil) goto interrupt7; |
644 |
continue7: |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
645 |
(*codeVal)(BLOCK_ARG, el); |
2216 | 646 |
index = i8; |
647 |
} |
|
648 |
} |
|
3484 | 649 |
#endif /* UNROLL_LOOPS */ |
2216 | 650 |
|
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
651 |
for (; index < nIndex; index++) { |
2217 | 652 |
el = __InstPtr(self)->i_instvars[index]; |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
653 |
if (InterruptPending != nil) goto interruptX; |
2915 | 654 |
continueX: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
655 |
(*codeVal)(BLOCK_ARG, el); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
656 |
} |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
657 |
RETURN (self); |
2216 | 658 |
|
3484 | 659 |
#if defined(UNROLL_LOOPS) |
2216 | 660 |
interrupt0: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
661 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
662 |
el = __InstPtr(self)->i_instvars[index]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
663 |
goto continue0; |
2216 | 664 |
interrupt1: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
665 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
666 |
el = __InstPtr(self)->i_instvars[index+1]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
667 |
goto continue1; |
2216 | 668 |
interrupt2: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
669 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
670 |
el = __InstPtr(self)->i_instvars[index+2]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
671 |
goto continue2; |
2216 | 672 |
interrupt3: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
673 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
674 |
el = __InstPtr(self)->i_instvars[index+3]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
675 |
goto continue3; |
2216 | 676 |
interrupt4: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
677 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
678 |
el = __InstPtr(self)->i_instvars[index+4]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
679 |
goto continue4; |
2216 | 680 |
interrupt5: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
681 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
682 |
el = __InstPtr(self)->i_instvars[index+5]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
683 |
goto continue5; |
2216 | 684 |
interrupt6: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
685 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
686 |
el = __InstPtr(self)->i_instvars[index+6]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
687 |
goto continue6; |
2216 | 688 |
interrupt7: |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
689 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
690 |
el = __InstPtr(self)->i_instvars[index+7]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
691 |
goto continue7; |
3500 | 692 |
#endif /* UNROLL_LOOPS */ |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
693 |
interruptX: |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
694 |
__interruptL(@line); |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
695 |
el = __InstPtr(self)->i_instvars[index]; |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
696 |
goto continueX; |
3500 | 697 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
698 |
} |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
699 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
700 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
701 |
/* |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
702 |
* sorry, must check code-pointer in the loop |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
703 |
* it could be recompiled or flushed |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
704 |
*/ |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
705 |
# undef BLOCK_ARG |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
706 |
#ifdef NEW_BLOCK_CALL |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
707 |
# define BLOCK_ARG aBlock |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
708 |
# define IBLOCK_ARG nil |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
709 |
#else |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
710 |
# define BLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
711 |
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
712 |
#endif |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
713 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
714 |
for (; index < nIndex; index++) { |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
715 |
REGISTER OBJFUNC codeVal; |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
716 |
|
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
717 |
if (InterruptPending != nil) __interruptL(@line); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
718 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
719 |
if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) { |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
720 |
(*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
721 |
} else { |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
722 |
if (__BlockInstPtr(aBlock)->b_bytecodes != nil) { |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
723 |
/* |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
724 |
* arg is a compiled block with bytecode - |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
725 |
* directly call interpreter without going through Block>>value |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
726 |
*/ |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
727 |
#ifdef PASS_ARG_POINTER |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
728 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index])); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
729 |
#else |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
730 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
731 |
#endif |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
732 |
} else { |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
733 |
(*val.ilc_func)(aBlock, |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
734 |
@symbol(value:), |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
735 |
nil, &val, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
736 |
__InstPtr(self)->i_instvars[index]); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
737 |
} |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
738 |
} |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
739 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
740 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
741 |
# undef BLOCK_ARG |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
742 |
# undef IBLOCK_ARG |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
743 |
|
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
744 |
RETURN (self ); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
745 |
} |
554 | 746 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
747 |
/* |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
748 |
* not a block - send it #value: |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
749 |
*/ |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
750 |
for (; index < nIndex; index++) { |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
751 |
if (InterruptPending != nil) __interruptL(@line); |
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
752 |
|
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
753 |
(*val.ilc_func)(aBlock, |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
754 |
@symbol(value:), |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
755 |
nil, &val, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
756 |
__InstPtr(self)->i_instvars[index]); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
757 |
} |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
758 |
RETURN ( self ); |
554 | 759 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
760 |
/* |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
761 |
* I am something, not handled here |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
762 |
*/ |
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
|
763 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
764 |
^ super do:aBlock |
554 | 765 |
! |
766 |
||
1 | 767 |
from:start to:stop do:aBlock |
768 |
"evaluate the argument, aBlock for the elements starting at index start |
|
769 |
up to (and including) stop in the collection. |
|
4122 | 770 |
- reimplemented for speed, since this is used by many higher |
771 |
level collections" |
|
1 | 772 |
|
773 |
%{ |
|
774 |
REGISTER OBJFUNC codeVal; |
|
775 |
REGISTER int index; |
|
2 | 776 |
REGISTER OBJ rHome; |
2052 | 777 |
OBJ slf; |
1 | 778 |
int nIndex, nInsts; |
779 |
static struct inlineCache val = _ILC1; |
|
3484 | 780 |
int indexHigh; |
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
781 |
OBJ myClass; |
1 | 782 |
|
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
783 |
slf = self; |
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
784 |
myClass = __qClass(slf); |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
785 |
|
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
786 |
if ( __bothSmallInteger(start, stop) |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
787 |
&& ((index = __intVal(start)) > 0) ) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
788 |
indexHigh = __intVal(stop); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
789 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
790 |
if (myClass != @global(Array)) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
791 |
nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
792 |
index += nInsts; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
793 |
indexHigh += nInsts; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
794 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
795 |
if (indexHigh <= nIndex) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
796 |
OBJ __aBlock = aBlock; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
797 |
int n; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
798 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
799 |
index--; /* 0-based */ |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
800 |
n = indexHigh - index; |
3484 | 801 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
802 |
if (__isBlockLike(__aBlock) |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
803 |
&& (__BlockInstPtr(__aBlock)->b_nargs == __MKSMALLINT(1))) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
804 |
{ |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
805 |
/* |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
806 |
* the most common case: a static compiled block, with home on the stack ... |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
807 |
*/ |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
808 |
REGISTER OBJFUNC codeVal; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
809 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
810 |
if (((codeVal = __BlockInstPtr(__aBlock)->b_code) != (OBJFUNC)nil) |
2678 | 811 |
#ifdef PARANOIA |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
812 |
&& (! ((INT)(__BlockInstPtr(__aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) |
2678 | 813 |
#endif |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
814 |
) { |
11 | 815 |
#ifdef NEW_BLOCK_CALL |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
816 |
# define BLOCK_ARG aBlock |
11 | 817 |
#else |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
818 |
# define BLOCK_ARG rHome |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
819 |
REGISTER OBJ rHome; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
820 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
821 |
rHome = __BlockInstPtr(__aBlock)->b_home; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
822 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
823 |
#endif |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
824 |
{ |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
825 |
REGISTER OBJ el; |
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
826 |
|
3484 | 827 |
#if defined(UNROLL_LOOPS) |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
828 |
/* |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
829 |
* boy; what an ugly looking piece of code ... |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
830 |
* however, this software pipelined thing has no taken conditional |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
831 |
* branches in the normal case and is almost twice as fast to even |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
832 |
* what an unrolling optimizing compiler produces from the loop below ... |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
833 |
* notice, that those gotos expand to forward branches (which are predicted |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
834 |
* as NOT taken by most machines ... which is exactly what we want) |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
835 |
*/ |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
836 |
{ |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
837 |
while ( n >= 8) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
838 |
el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
839 |
if (InterruptPending != nil) goto interrupt0; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
840 |
continue0: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
841 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
842 |
el = __InstPtr(self)->i_instvars[index+1]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
843 |
if (InterruptPending != nil) goto interrupt1; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
844 |
continue1: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
845 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
846 |
el = __InstPtr(self)->i_instvars[index+2]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
847 |
if (InterruptPending != nil) goto interrupt2; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
848 |
continue2: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
849 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
850 |
el = __InstPtr(self)->i_instvars[index+3]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
851 |
if (InterruptPending != nil) goto interrupt3; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
852 |
continue3: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
853 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
854 |
el = __InstPtr(self)->i_instvars[index+4]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
855 |
if (InterruptPending != nil) goto interrupt4; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
856 |
continue4: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
857 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
858 |
el = __InstPtr(self)->i_instvars[index+5]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
859 |
if (InterruptPending != nil) goto interrupt5; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
860 |
continue5: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
861 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
862 |
el = __InstPtr(self)->i_instvars[index+6]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
863 |
if (InterruptPending != nil) goto interrupt6; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
864 |
continue6: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
865 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
866 |
el = __InstPtr(self)->i_instvars[index+7]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
867 |
if (InterruptPending != nil) goto interrupt7; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
868 |
continue7: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
869 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
870 |
n -= 8; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
871 |
index += 8; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
872 |
} |
3485 | 873 |
# ifdef UNROLL_LOOPS2 /* this makes small loops slower */ |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
874 |
if (n >= 4) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
875 |
el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
876 |
if (InterruptPending != nil) goto interrupt0b; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
877 |
continue0b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
878 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
879 |
el = __InstPtr(self)->i_instvars[index+1]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
880 |
if (InterruptPending != nil) goto interrupt1b; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
881 |
continue1b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
882 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
883 |
el = __InstPtr(self)->i_instvars[index+2]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
884 |
if (InterruptPending != nil) goto interrupt2b; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
885 |
continue2b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
886 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
887 |
el = __InstPtr(self)->i_instvars[index+3]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
888 |
if (InterruptPending != nil) goto interrupt3b; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
889 |
continue3b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
890 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
891 |
n -= 4; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
892 |
index += 4; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
893 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
894 |
if (n >= 2) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
895 |
el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
896 |
if (InterruptPending != nil) goto interrupt0c; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
897 |
continue0c: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
898 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
899 |
el = __InstPtr(self)->i_instvars[index+1]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
900 |
if (InterruptPending != nil) goto interrupt1c; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
901 |
continue1c: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
902 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
903 |
n -= 2; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
904 |
index += 2; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
905 |
} |
3485 | 906 |
# endif /* UNROLL_LOOPS2 */ |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
907 |
} |
3500 | 908 |
#endif /* UNROLL_LOOPS */ |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
909 |
while (n > 0) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
910 |
el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
911 |
if (InterruptPending != nil) goto interruptX; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
912 |
continueX: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
913 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
914 |
n--; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
915 |
index++; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
916 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
917 |
RETURN (self); |
2216 | 918 |
|
3484 | 919 |
#if defined(UNROLL_LOOPS) |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
920 |
interrupt0: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
921 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
922 |
goto continue0; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
923 |
interrupt1: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
924 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+1]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
925 |
goto continue1; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
926 |
interrupt2: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
927 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+2]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
928 |
goto continue2; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
929 |
interrupt3: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
930 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+3]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
931 |
goto continue3; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
932 |
interrupt4: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
933 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+4]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
934 |
goto continue4; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
935 |
interrupt5: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
936 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+5]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
937 |
goto continue5; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
938 |
interrupt6: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
939 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+6]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
940 |
goto continue6; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
941 |
interrupt7: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
942 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+7]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
943 |
goto continue7; |
3484 | 944 |
|
3485 | 945 |
# ifdef UNROLL_LOOPS2 |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
946 |
interrupt0b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
947 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
948 |
goto continue0b; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
949 |
interrupt1b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
950 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+1]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
951 |
goto continue1b; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
952 |
interrupt2b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
953 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+2]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
954 |
goto continue2b; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
955 |
interrupt3b: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
956 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+3]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
957 |
goto continue3b; |
3484 | 958 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
959 |
interrupt0c: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
960 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
961 |
goto continue0c; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
962 |
interrupt1c: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
963 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index+1]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
964 |
goto continue1c; |
3485 | 965 |
# endif /* UNROLL_LOOPS2 */ |
966 |
#endif /* UNROLL_LOOPS */ |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
967 |
interruptX: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
968 |
__interruptL(@line); el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
969 |
goto continueX; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
970 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
971 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
972 |
} |
370 | 973 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
974 |
/* |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
975 |
* sorry, must check code-pointer in the loop |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
976 |
* it could be recompiled or flushed |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
977 |
*/ |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
978 |
# undef BLOCK_ARG |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
979 |
#ifdef NEW_BLOCK_CALL |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
980 |
# define BLOCK_ARG aBlock |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
981 |
# define IBLOCK_ARG nil |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
982 |
#else |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
983 |
# define BLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
984 |
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
11 | 985 |
#endif |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
986 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
987 |
while (n > 0) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
988 |
REGISTER OBJFUNC codeVal; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
989 |
OBJ el; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
990 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
991 |
el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
992 |
if (InterruptPending != nil) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
993 |
__interruptL(@line); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
994 |
el = __InstPtr(self)->i_instvars[index]; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
995 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
996 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
997 |
if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
998 |
(*codeVal)(BLOCK_ARG, el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
999 |
} else { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1000 |
if (__BlockInstPtr(aBlock)->b_bytecodes != nil) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1001 |
/* |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1002 |
* arg is a compiled block with bytecode - |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1003 |
* directly call interpreter without going through Block>>value |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1004 |
*/ |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1005 |
#ifdef PASS_ARG_POINTER |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1006 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &el); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1007 |
#else |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1008 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, el); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1009 |
#endif |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1010 |
} else { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1011 |
(*val.ilc_func)(aBlock, |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1012 |
@symbol(value:), |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1013 |
nil, &val, |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1014 |
el); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1015 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1016 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1017 |
n--; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1018 |
index++; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1019 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1020 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1021 |
# undef BLOCK_ARG |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1022 |
# undef IBLOCK_ARG |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1023 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1024 |
RETURN (self ); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1025 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1026 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1027 |
/* |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1028 |
* not a block - send it #value: |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1029 |
*/ |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1030 |
while (n > 0) { |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1031 |
if (InterruptPending != nil) __interruptL(@line); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1032 |
|
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1033 |
(*val.ilc_func)(aBlock, |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1034 |
@symbol(value:), |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1035 |
nil, &val, |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1036 |
__InstPtr(self)->i_instvars[index]); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1037 |
n--; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1038 |
index++; |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1039 |
} |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1040 |
RETURN ( self ); |
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1041 |
} |
1 | 1042 |
} |
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
|
1043 |
%}. |
1 | 1044 |
^ super from:start to:stop do:aBlock |
5347
21b418ac4cc3
oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents:
5049
diff
changeset
|
1045 |
|
1 | 1046 |
! |
1047 |
||
42 | 1048 |
from:start to:stop reverseDo:aBlock |
1049 |
"evaluate the argument, aBlock for the elements starting at index start |
|
1050 |
up to (and including) stop in the collection. Step in reverse order. |
|
1051 |
- reimplemented for speed" |
|
1052 |
||
1053 |
%{ |
|
1054 |
REGISTER OBJFUNC codeVal; |
|
1055 |
REGISTER int index; |
|
1056 |
REGISTER OBJ rHome; |
|
586
cab695f942a6
weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents:
577
diff
changeset
|
1057 |
int nIndex; |
42 | 1058 |
static struct inlineCache val = _ILC1; |
1059 |
int indexLow, indexHigh; |
|
1060 |
||
586
cab695f942a6
weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents:
577
diff
changeset
|
1061 |
if (__bothSmallInteger(start, stop) |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1062 |
&& (__qClass(self) == @global(Array)) |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1063 |
&& ((indexLow = __intVal(start)) > 0)) { |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1064 |
indexHigh = __intVal(stop); |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1065 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1066 |
if (indexHigh <= nIndex) { |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1067 |
indexLow--; |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1068 |
indexHigh--; |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1069 |
|
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1070 |
if (__isBlockLike(aBlock) |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1071 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1072 |
# undef BLOCK_ARG |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1073 |
#ifdef NEW_BLOCK_CALL |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1074 |
# define BLOCK_ARG aBlock |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1075 |
# define IBLOCK_ARG nil |
42 | 1076 |
#else |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1077 |
# define BLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1078 |
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1079 |
#endif |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1080 |
|
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1081 |
for (index=indexHigh; index >= indexLow; index--) { |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1082 |
REGISTER OBJFUNC codeVal; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1083 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1084 |
if (InterruptPending != nil) __interruptL(@line); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1085 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1086 |
if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1087 |
(*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1088 |
} else { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1089 |
if (__BlockInstPtr(aBlock)->b_bytecodes != nil) { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1090 |
/* |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1091 |
* arg is a compiled block with bytecode - |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1092 |
* directly call interpreter without going through Block>>value |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1093 |
*/ |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1094 |
#ifdef PASS_ARG_POINTER |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1095 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index])); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1096 |
#else |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1097 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]); |
42 | 1098 |
#endif |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1099 |
} else { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1100 |
(*val.ilc_func)(aBlock, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1101 |
@symbol(value:), |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1102 |
nil, &val, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1103 |
__InstPtr(self)->i_instvars[index]); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1104 |
} |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1105 |
} |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1106 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1107 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1108 |
# undef BLOCK_ARG |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1109 |
# undef IBLOCK_ARG |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1110 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1111 |
RETURN (self ); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1112 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1113 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1114 |
/* |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1115 |
* not a block - send it #value: |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1116 |
*/ |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1117 |
for (index=indexHigh; index >= indexLow; index--) { |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1118 |
if (InterruptPending != nil) __interruptL(@line); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1119 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1120 |
(*val.ilc_func)(aBlock, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1121 |
@symbol(value:), |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1122 |
nil, &val, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1123 |
__InstPtr(self)->i_instvars[index]); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1124 |
} |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1125 |
RETURN ( self ); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1126 |
} |
42 | 1127 |
} |
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
|
1128 |
%}. |
42 | 1129 |
^ super from:start to:stop reverseDo:aBlock |
1130 |
! |
|
1131 |
||
554 | 1132 |
keysAndValuesDo:aBlock |
1133 |
"evaluate the argument, aBlock for each element in the collection. |
|
1134 |
Pass both index and element to the block. |
|
1135 |
- reimplemented for speed" |
|
1136 |
||
1137 |
%{ |
|
1138 |
REGISTER OBJFUNC codeVal; |
|
1139 |
REGISTER int index; |
|
1140 |
static struct inlineCache val2 = _ILC2; |
|
1141 |
REGISTER OBJ rHome; |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1142 |
int actualSize; |
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
1143 |
OBJ myClass; |
554 | 1144 |
|
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
1145 |
myClass = __qClass(self); |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1146 |
if ((__ClassInstPtr(myClass)->c_ninstvars) == __MKSMALLINT(0)) { |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1147 |
|
2915 | 1148 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
1149 |
index = 0; |
|
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
|
1150 |
|
2915 | 1151 |
if (index < actualSize) { |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1152 |
if (__isBlockLike(aBlock) |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1153 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) { |
2915 | 1154 |
{ |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1155 |
/* |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1156 |
* the most common case: a static compiled block, with home on the stack ... |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1157 |
*/ |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1158 |
REGISTER OBJFUNC codeVal; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1159 |
|
2915 | 1160 |
if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
2678 | 1161 |
#ifdef PARANOIA |
2915 | 1162 |
&& (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) |
2678 | 1163 |
#endif |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1164 |
) { |
2254 | 1165 |
|
554 | 1166 |
#ifdef NEW_BLOCK_CALL |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1167 |
# define BLOCK_ARG aBlock |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1168 |
#else |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1169 |
# define BLOCK_ARG rHome |
2915 | 1170 |
REGISTER OBJ rHome; |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1171 |
|
2915 | 1172 |
rHome = __BlockInstPtr(aBlock)->b_home; |
1173 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) |
|
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1174 |
#endif |
2915 | 1175 |
{ |
2878 | 1176 |
OBJ el; |
1177 |
||
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1178 |
while (index < actualSize) { |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1179 |
|
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1180 |
el = __InstPtr(self)->i_instvars[index]; |
2915 | 1181 |
if (InterruptPending != nil) goto interruptX; |
2878 | 1182 |
continueX: |
2915 | 1183 |
index++; |
1184 |
(*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el); |
|
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1185 |
} |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1186 |
RETURN (self); |
2878 | 1187 |
|
1188 |
interruptX: |
|
1189 |
__interruptL(@line); |
|
1190 |
el = __InstPtr(self)->i_instvars[index]; |
|
1191 |
goto continueX; |
|
2915 | 1192 |
} |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1193 |
} |
2915 | 1194 |
} |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1195 |
|
2915 | 1196 |
/* |
1197 |
* sorry, must check code-pointer in the loop |
|
1198 |
* it could be recompiled or flushed |
|
1199 |
*/ |
|
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1200 |
# undef BLOCK_ARG |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1201 |
#ifdef NEW_BLOCK_CALL |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1202 |
# define BLOCK_ARG aBlock |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1203 |
# define IBLOCK_ARG nil |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1204 |
#else |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1205 |
# define BLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1206 |
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1207 |
#endif |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1208 |
|
2915 | 1209 |
while (index < actualSize) { |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1210 |
REGISTER OBJFUNC codeVal; |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1211 |
OBJ el; |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1212 |
|
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1213 |
if (InterruptPending != nil) __interruptL(@line); |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1214 |
|
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1215 |
el = __InstPtr(self)->i_instvars[index]; |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1216 |
index++; |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1217 |
if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) { |
2915 | 1218 |
(*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el); |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1219 |
} else { |
2915 | 1220 |
if (__BlockInstPtr(aBlock)->b_bytecodes != nil) { |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1221 |
/* |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1222 |
* arg is a compiled block with bytecode - |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1223 |
* directly call interpreter without going through Block>>value |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1224 |
*/ |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1225 |
#ifdef PASS_ARG_POINTER |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1226 |
{ |
2915 | 1227 |
OBJ t[2]; |
554 | 1228 |
|
2915 | 1229 |
t[0] = __MKSMALLINT(index); |
1230 |
t[1] = el; |
|
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1231 |
|
2915 | 1232 |
__interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t); |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1233 |
} |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1234 |
#else |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1235 |
__interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __MKSMALLINT(index), el); |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1236 |
#endif |
2915 | 1237 |
} else { |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1238 |
(*val2.ilc_func)(aBlock, |
2915 | 1239 |
@symbol(value:value:), |
1240 |
nil, &val2, |
|
1241 |
__MKSMALLINT(index), |
|
1242 |
el); |
|
1243 |
} |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1244 |
} |
2915 | 1245 |
} |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1246 |
|
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1247 |
# undef BLOCK_ARG |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1248 |
# undef IBLOCK_ARG |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1249 |
|
2915 | 1250 |
RETURN (self ); |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
1251 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1252 |
|
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
1253 |
/* |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1254 |
* not a block - send it #value: |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
1255 |
*/ |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1256 |
while (index < actualSize) { |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1257 |
OBJ el; |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
1258 |
|
2915 | 1259 |
if (InterruptPending != nil) __interruptL(@line); |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
1260 |
|
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1261 |
el = __InstPtr(self)->i_instvars[index]; |
2915 | 1262 |
index++; |
1263 |
(*val2.ilc_func)(aBlock, |
|
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1264 |
@symbol(value:value:), |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1265 |
nil, &val2, |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1266 |
__MKSMALLINT(index), |
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1267 |
el); |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1268 |
} |
2842
1cda44a3660e
oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents:
2821
diff
changeset
|
1269 |
RETURN ( self ); |
2915 | 1270 |
} |
554 | 1271 |
} |
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
|
1272 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1273 |
^ super keysAndValuesDo:aBlock |
554 | 1274 |
! |
1275 |
||
543 | 1276 |
reverseDo:aBlock |
1277 |
"evaluate the argument, aBlock for each element in the collection in reverse order. |
|
1278 |
- reimplemented for speed" |
|
1 | 1279 |
|
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
|
1280 |
|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
|
1281 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1282 |
sz := self size. |
1 | 1283 |
%{ |
1284 |
REGISTER OBJFUNC codeVal; |
|
1285 |
REGISTER int index; |
|
543 | 1286 |
unsigned int nIndex; |
1287 |
int endIndex; |
|
1 | 1288 |
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
|
1289 |
int actualSize; |
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
1290 |
OBJ myClass; |
1 | 1291 |
|
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
1292 |
myClass = __qClass(self); |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
1293 |
{ |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1294 |
endIndex = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1295 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1296 |
nIndex = endIndex + __intVal(sz); |
543 | 1297 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1298 |
if (nIndex <= actualSize) { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1299 |
if (__isBlockLike(aBlock) |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1300 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1301 |
# undef BLOCK_ARG |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1302 |
#ifdef NEW_BLOCK_CALL |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1303 |
# define BLOCK_ARG aBlock |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1304 |
# define IBLOCK_ARG nil |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1305 |
#else |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1306 |
# define BLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1307 |
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home) |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1308 |
#endif |
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1309 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1310 |
for (index=nIndex-1; index >= endIndex; index--) { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1311 |
REGISTER OBJFUNC codeVal; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1312 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1313 |
if (InterruptPending != nil) __interruptL(@line); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1314 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1315 |
if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1316 |
(*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1317 |
} else { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1318 |
if (__BlockInstPtr(aBlock)->b_bytecodes != nil) { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1319 |
/* |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1320 |
* arg is a compiled block with bytecode - |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1321 |
* directly call interpreter without going through Block>>value |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1322 |
*/ |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1323 |
#ifdef PASS_ARG_POINTER |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1324 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index])); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1325 |
#else |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1326 |
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]); |
11 | 1327 |
#endif |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1328 |
} else { |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1329 |
(*val.ilc_func)(aBlock, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1330 |
@symbol(value:), |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1331 |
nil, &val, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1332 |
__InstPtr(self)->i_instvars[index]); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1333 |
} |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1334 |
} |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1335 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1336 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1337 |
# undef BLOCK_ARG |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1338 |
# undef IBLOCK_ARG |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1339 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1340 |
RETURN (self ); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1341 |
} |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1342 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1343 |
/* |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1344 |
* not a block - send it #value: |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1345 |
*/ |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1346 |
for (index=nIndex-1; index >= endIndex; index--) { |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1347 |
if (InterruptPending != nil) __interruptL(@line); |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1348 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1349 |
(*val.ilc_func)(aBlock, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1350 |
@symbol(value:), |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1351 |
nil, &val, |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1352 |
__InstPtr(self)->i_instvars[index]); |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1353 |
} |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1354 |
RETURN ( self ); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1355 |
} |
1 | 1356 |
} |
543 | 1357 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1358 |
^ super reverseDo:aBlock |
11 | 1359 |
! |
1360 |
||
328 | 1361 |
traverse:aBlock |
1362 |
"Evaluate aBlock for every element that is not an Array, |
|
1123 | 1363 |
and recursively traverse Arrays. |
328 | 1364 |
Implemented here to support better search for selectors in |
1365 |
literal arrays - might be a good idea to move it up in the collection |
|
1366 |
hierarchy, since this may be a useful method for other collections |
|
1367 |
as well." |
|
1368 |
||
1369 |
self do: [:el | |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1370 |
el isArray |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1371 |
ifTrue: [el traverse: aBlock] |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1372 |
ifFalse: [aBlock value: el]] |
328 | 1373 |
|
1374 |
" |
|
1375 |
example: flattening an Array: |
|
1376 |
||
1377 |
|s| |
|
1378 |
||
1379 |
s := WriteStream on:Array new. |
|
1380 |
#(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | s nextPut:el]. |
|
1381 |
s contents |
|
1382 |
" |
|
1123 | 1383 |
" |
1384 |
example: deep search |
|
1385 |
||
1386 |
#(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1387 |
el == 10 ifTrue:[Transcript showCR:'found'] |
1123 | 1388 |
] |
1389 |
" |
|
1390 |
||
1391 |
"Modified: 26.3.1996 / 17:08:10 / cg" |
|
543 | 1392 |
! ! |
1393 |
||
1394 |
!Array methodsFor:'filling & replacing'! |
|
1395 |
||
554 | 1396 |
from:index1 to:index2 put:anObject |
1397 |
"reimplemented for speed if receiver is an Array" |
|
1398 |
||
1399 |
%{ /* NOCONTEXT */ |
|
1400 |
||
1401 |
REGISTER int index; |
|
1402 |
unsigned int nIndex; |
|
1403 |
unsigned int endIndex; |
|
1404 |
REGISTER OBJ *dst; |
|
1405 |
||
1406 |
if ((__qClass(self) == Array) |
|
1407 |
&& __bothSmallInteger(index1, index2)) { |
|
1133 | 1408 |
index = __intVal(index1) - 1; |
554 | 1409 |
if (index >= 0) { |
1410 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1133 | 1411 |
endIndex = __intVal(index2) - 1; |
2185
790f4c380343
care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
1412 |
|
951
2dd898849a8a
directly call __new if quick allocation fails;
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
1413 |
if ((endIndex >= index) && (endIndex < nIndex)) { |
1133 | 1414 |
dst = &(__InstPtr(self)->i_instvars[index]); |
554 | 1415 |
#ifdef memset4 |
2865 | 1416 |
{ |
1417 |
int n4 = endIndex-index+1; |
|
1418 |
||
1419 |
memset4(dst, anObject, n4); |
|
1420 |
} |
|
554 | 1421 |
#else |
2865 | 1422 |
# ifdef FAST_MEMSET |
554 | 1423 |
if ((INT)anObject == 0) { |
1424 |
memset(dst, 0, __OBJS2BYTES__(endIndex-index+1)); |
|
2865 | 1425 |
} else |
1426 |
# endif |
|
1427 |
{ |
|
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
|
1428 |
# if defined(UNROLL_LOOPS) |
554 | 1429 |
{ |
1430 |
int i8; |
|
1431 |
||
1432 |
while ((i8 = index + 8) <= endIndex) { |
|
3041 | 1433 |
dst[3] = dst[2] = dst[1] = dst[0] = anObject; |
1434 |
dst[7] = dst[6] = dst[5] = dst[4] = anObject; |
|
554 | 1435 |
dst += 8; |
1436 |
index = i8; |
|
1437 |
} |
|
1438 |
} |
|
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
|
1439 |
# endif |
554 | 1440 |
for (; index <= endIndex; index++) { |
1441 |
*dst++ = anObject; |
|
1442 |
} |
|
1443 |
} |
|
1444 |
#endif |
|
3730
375237229a8e
replaceFrom... - unrolled 8 times;
Claus Gittinger <cg@exept.de>
parents:
3500
diff
changeset
|
1445 |
__STORE(self, anObject); |
554 | 1446 |
RETURN ( self ); |
1447 |
} |
|
1448 |
} |
|
1449 |
} |
|
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
|
1450 |
%}. |
554 | 1451 |
^ super from:index1 to:index2 put:anObject |
1452 |
! |
|
1453 |
||
543 | 1454 |
replaceFrom:start to:stop with:aCollection startingAt:repStart |
1168 | 1455 |
"replace elements in the receiver between index start and stop, |
1456 |
with elements taken from replacementCollection starting at repStart. |
|
3234 | 1457 |
Return the receiver. |
1168 | 1458 |
Reimplemented for speed if both receiver and aCollection are Arrays" |
543 | 1459 |
|
1460 |
%{ /* NOCONTEXT */ |
|
1461 |
||
1462 |
unsigned int nIndex; |
|
1463 |
unsigned int repNIndex; |
|
1464 |
int startIndex, stopIndex; |
|
1465 |
REGISTER OBJ *src; |
|
1466 |
REGISTER OBJ *dst; |
|
1467 |
int repStopIndex; |
|
1468 |
REGISTER int repStartIndex; |
|
1469 |
REGISTER OBJ t; |
|
1470 |
REGISTER int count; |
|
1903 | 1471 |
OBJ myClass; |
543 | 1472 |
|
2210 | 1473 |
if ( |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1474 |
(__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __MKSMALLINT(0)) |
1903 | 1475 |
&& __isNonNilObject(aCollection) |
1476 |
&& (((t = __qClass(aCollection)) == Array) || (t == myClass)) |
|
543 | 1477 |
&& __bothSmallInteger(start, stop) |
2210 | 1478 |
&& __isSmallInteger(repStart) |
1479 |
) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1480 |
startIndex = __intVal(start) - 1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1481 |
if (startIndex >= 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1482 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1483 |
stopIndex = __intVal(stop) - 1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1484 |
count = stopIndex - startIndex + 1; |
1903 | 1485 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1486 |
if ((count > 0) && (stopIndex < nIndex)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1487 |
repStartIndex = __intVal(repStart) - 1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1488 |
if (repStartIndex >= 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1489 |
repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1490 |
repStopIndex = repStartIndex + (stopIndex - startIndex); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1491 |
if (repStopIndex < repNIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1492 |
src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1493 |
dst = &(__InstPtr(self)->i_instvars[startIndex]); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1494 |
if (aCollection == self) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1495 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1496 |
* no need to check stores if copying |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1497 |
* from myself |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1498 |
*/ |
1903 | 1499 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1500 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1501 |
* take care of overlapping copy |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1502 |
* do not depend on memset being smart enough |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1503 |
* (some are not ;-) |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1504 |
*/ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1505 |
if (src < dst) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1506 |
/* must do a reverse copy */ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1507 |
src += count; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1508 |
dst += count; |
543 | 1509 |
#if defined(UNROLL_LOOPS) |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1510 |
while (count > 8) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1511 |
dst[-1] = src[-1]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1512 |
dst[-2] = src[-2]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1513 |
dst[-3] = src[-3]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1514 |
dst[-4] = src[-4]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1515 |
dst[-5] = src[-5]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1516 |
dst[-6] = src[-6]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1517 |
dst[-7] = src[-7]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1518 |
dst[-8] = src[-8]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1519 |
dst -= 8; src -= 8; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1520 |
count -= 8; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1521 |
} |
543 | 1522 |
#endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1523 |
while (count-- > 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1524 |
*--dst = *--src; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1525 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1526 |
RETURN ( self ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1527 |
} |
1903 | 1528 |
#ifdef SOFTWARE_PIPELINE |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1529 |
{ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1530 |
OBJ t1; |
1903 | 1531 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1532 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1533 |
* the loop below fetches one longWord behind |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1534 |
* this should not be a problem |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1535 |
*/ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1536 |
t1 = src[0]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1537 |
count--; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1538 |
if (count) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1539 |
dst++; src++; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1540 |
do { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1541 |
dst[-1] = t1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1542 |
t1 = src[0]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1543 |
src++; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1544 |
dst++; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1545 |
} while (count--); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1546 |
} else { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1547 |
dst[0] = t1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1548 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1549 |
} |
543 | 1550 |
#else |
1903 | 1551 |
|
1552 |
# ifdef bcopy4 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1553 |
bcopy4(src, dst, count); |
1903 | 1554 |
# else |
1555 |
# ifdef FAST_MEMCPY |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1556 |
bcopy(src, dst, __OBJS2BYTES__(count)); |
1903 | 1557 |
# else |
1558 |
# if defined(UNROLL_LOOPS) |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1559 |
while (count >= 8) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1560 |
dst[0] = src[0]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1561 |
dst[1] = src[1]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1562 |
dst[2] = src[2]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1563 |
dst[3] = src[3]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1564 |
dst[4] = src[4]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1565 |
dst[5] = src[5]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1566 |
dst[6] = src[6]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1567 |
dst[7] = src[7]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1568 |
dst += 8; src += 8; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1569 |
count -= 8; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1570 |
} |
1903 | 1571 |
# endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1572 |
while (count--) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1573 |
*dst++ = *src++; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1574 |
} |
1903 | 1575 |
# endif |
543 | 1576 |
# endif |
1577 |
#endif |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1578 |
} else { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1579 |
REGISTER int spc; |
543 | 1580 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1581 |
spc = __qSpace(self); |
543 | 1582 |
#if defined(UNROLL_LOOPS) |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1583 |
while (count >= 8) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1584 |
t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1585 |
t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1586 |
t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1587 |
t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1588 |
t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1589 |
t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1590 |
t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1591 |
t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1592 |
count -= 8; src += 8; dst += 8; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1593 |
} |
543 | 1594 |
#endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1595 |
while (count-- > 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1596 |
t = *src++; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1597 |
*dst++ = t; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1598 |
__STORE_SPC(self, t, spc); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1599 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1600 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1601 |
RETURN ( self ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1602 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1603 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1604 |
} |
1903 | 1605 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1606 |
if (count == 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1607 |
RETURN ( self ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1608 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1609 |
} |
543 | 1610 |
} |
1611 |
%}. |
|
1612 |
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
|
1168 | 1613 |
|
1614 |
"Modified: 13.4.1996 / 12:17:13 / cg" |
|
543 | 1615 |
! ! |
1616 |
||
1617 |
!Array methodsFor:'printing & storing'! |
|
1618 |
||
1619 |
displayString |
|
1620 |
"return a printed representation of the receiver for displaying" |
|
1621 |
||
2915 | 1622 |
|s| |
543 | 1623 |
|
1624 |
(self isLiteral) ifTrue:[ |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1625 |
s := WriteStream on:String new. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1626 |
s writeLimit:5000. |
1498
5083a52b1718
limit displayString to 5000 characters
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
1627 |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1628 |
WriteStream writeErrorSignal handle:[:ex | |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1629 |
s writeLimit:nil. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1630 |
s nextPutAll:' ...' |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1631 |
] do:[ |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1632 |
s nextPutAll:'#('. |
2915 | 1633 |
self |
1634 |
do:[:each | s nextPutAll:each displayString.] |
|
1635 |
separatedBy:[s space] |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1636 |
]. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1637 |
s writeLimit:nil. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1638 |
s nextPutAll:')'. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1639 |
^ s contents |
543 | 1640 |
]. |
1641 |
^ super displayString |
|
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1642 |
|
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1643 |
" |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1644 |
#(1 2 3 4) displayString |
2915 | 1645 |
#(1 2 3 4) printString |
1498
5083a52b1718
limit displayString to 5000 characters
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
1646 |
(Array new:10000) displayString |
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1647 |
" |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1648 |
|
2915 | 1649 |
"Modified: 12.9.1997 / 22:03:18 / cg" |
543 | 1650 |
! |
1651 |
||
1652 |
storeOn:aStream |
|
1653 |
"append a printed representation of the receiver to aStream, |
|
1654 |
which allows reconstructing it via readFrom:. |
|
1655 |
Redefined to output a somewhat more user friendly string." |
|
1656 |
||
1657 |
self isLiteral ifTrue:[ |
|
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1658 |
aStream nextPutAll:'#('. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1659 |
self do:[:element | element storeOn:aStream. aStream space]. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1660 |
aStream nextPutAll:')' |
543 | 1661 |
] ifFalse:[ |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1662 |
super storeOn:aStream |
543 | 1663 |
] |
1664 |
||
1665 |
" |
|
1666 |
#(1 2 $a 'hello') storeString |
|
588 | 1667 |
#(1 2 $a [1 2 3]) storeString |
543 | 1668 |
" |
588 | 1669 |
|
1670 |
"Created: 20.11.1995 / 11:16:58 / cg" |
|
543 | 1671 |
! ! |
1672 |
||
1673 |
!Array methodsFor:'queries'! |
|
1674 |
||
1675 |
isArray |
|
1676 |
"return true, if the receiver is some kind of array (or weakArray etc). |
|
5511 | 1677 |
true is returned here." |
543 | 1678 |
|
1679 |
^ true |
|
1680 |
! |
|
1681 |
||
3226
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1682 |
isEmpty |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1683 |
"return true if the receiver contains no elements. |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1684 |
Reimplemented here for performance." |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1685 |
|
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1686 |
%{ /* NOCONTEXT */ |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1687 |
REGISTER OBJ slf = self; |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1688 |
|
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1689 |
if (__qClass(slf) == Array) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1690 |
RETURN ( (__arraySize(slf) == 0) ? true : false); |
3226
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1691 |
} |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1692 |
%}. |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1693 |
^ self size == 0 |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1694 |
! |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1695 |
|
543 | 1696 |
isLiteral |
4661 | 1697 |
"return true, if the receiver can be used as a literal constant in ST syntax |
543 | 1698 |
(i.e. can be used in constant arrays)" |
1699 |
||
1244 | 1700 |
"/ no, simply returning true here is a mistake: |
1701 |
"/ it could be a subclass of Array |
|
1702 |
"/ (of which the compiler does not know at all ...) |
|
1703 |
||
543 | 1704 |
self class == Array ifFalse:[^ false]. |
1705 |
||
1244 | 1706 |
"/ |
1707 |
"/ care for recursive arrays ... |
|
1708 |
"/ |
|
543 | 1709 |
thisContext isRecursive ifTrue:[^ false]. |
1710 |
self do:[:element | |
|
4661 | 1711 |
element isLiteral ifFalse:[^ false] |
543 | 1712 |
]. |
1713 |
^ true |
|
1244 | 1714 |
|
1715 |
"Modified: 22.4.1996 / 12:55:19 / cg" |
|
328 | 1716 |
! |
1717 |
||
3226
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1718 |
notEmpty |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1719 |
"return true if the receiver contains elements. |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1720 |
Reimplemented here for performance." |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1721 |
|
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1722 |
%{ /* NOCONTEXT */ |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1723 |
REGISTER OBJ slf = self; |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1724 |
|
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1725 |
if (__qClass(slf) == Array) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
1726 |
RETURN ( (__arraySize(slf) != 0) ? true : false); |
3226
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1727 |
} |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1728 |
%}. |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1729 |
^ self size ~~ 0 |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1730 |
! |
34a51a534ed5
added tuned versions of isEmpty & notEmpty
Claus Gittinger <cg@exept.de>
parents:
3088
diff
changeset
|
1731 |
|
1243 | 1732 |
refersToLiteral:aLiteral |
1733 |
"return true if the receiver or recursively any array element in the |
|
1734 |
receiver referes to aLiteral" |
|
1735 |
||
543 | 1736 |
self do: [ :el | |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1737 |
el == aLiteral ifTrue:[^true]. |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1738 |
el class == Array ifTrue:[ |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1739 |
(el refersToLiteral: aLiteral) ifTrue: [^true] |
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
1740 |
] |
543 | 1741 |
]. |
1742 |
^ false |
|
1743 |
||
1744 |
" |
|
1745 |
#(1 2 3) refersToLiteral:#foo |
|
1746 |
#(1 2 3 foo bar baz) refersToLiteral:#foo |
|
1747 |
#(1 2 3 (((bar foo))) bar baz) refersToLiteral:#foo |
|
1748 |
" |
|
1243 | 1749 |
|
1750 |
"Modified: 22.4.1996 / 12:41:46 / cg" |
|
543 | 1751 |
! ! |
1752 |
||
3088 | 1753 |
!Array methodsFor:'searching'! |
543 | 1754 |
|
554 | 1755 |
identityIndexOf:anElement or:alternative |
1756 |
"search the array for anElement or alternative; |
|
1757 |
return the index of anElement if found, or the index of anAlternative, |
|
1758 |
if not found. If anAlternative is also not found, return 0. |
|
1759 |
This is a special interface for high-speed searching in an array |
|
1760 |
and at the same time searching for an empty slot. |
|
1761 |
Do not use this method for your application classes, since it is |
|
1762 |
not portable (i.e. other smalltalks do not offer this)" |
|
1763 |
||
1764 |
%{ /* NOCONTEXT */ |
|
1765 |
||
1766 |
REGISTER int index; |
|
1767 |
REGISTER OBJ o, el1, el2; |
|
1768 |
REGISTER OBJ *op; |
|
1769 |
REGISTER unsigned int nIndex; |
|
1770 |
int altIndex = 0; |
|
1771 |
int nInsts; |
|
1772 |
||
1773 |
index = 0; |
|
1133 | 1774 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
554 | 1775 |
index += nInsts; |
1776 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1777 |
el1 = anElement; el2 = alternative; |
|
1133 | 1778 |
op = & (__InstPtr(self)->i_instvars[index]); |
554 | 1779 |
while (index++ < nIndex) { |
5403 | 1780 |
if ((o = *op++) == el1) { |
1781 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1782 |
} |
|
1783 |
if (o == el2) { |
|
1784 |
if (altIndex == 0) { |
|
1785 |
altIndex = index; |
|
1786 |
} |
|
1787 |
} |
|
554 | 1788 |
} |
1789 |
RETURN ( __MKSMALLINT(altIndex) ); |
|
5403 | 1790 |
%}. |
1791 |
^ super identityIndexOf:anElement or:alternative |
|
554 | 1792 |
|
1793 |
" |
|
1794 |
#(1 2 3 4 5 6 7 8 9) identityIndexOf:3 or:5 |
|
1795 |
#(1 2 0 4 5 6 7 8 9) identityIndexOf:3 or:5 |
|
1796 |
#(1 2 0 4 5 6 7 3 9) identityIndexOf:3 or:5 |
|
1797 |
#(1 2 3 4 5 nil 7 3 9) identityIndexOf:3 or:nil |
|
1798 |
#(1 2 nil 4 5 6 7 3 9) identityIndexOf:3 or:nil |
|
1799 |
#(1 2 nil 4 5 6 7 8 9) identityIndexOf:3 or:nil |
|
1800 |
#() identityIndexOf:3 or:nil |
|
1801 |
#(1 2) identityIndexOf:3 or:nil |
|
1802 |
" |
|
1803 |
! |
|
1804 |
||
543 | 1805 |
identityIndexOf:anElement startingAt:start |
1806 |
"search the array for anElement; return index if found, 0 otherwise |
|
1807 |
- reimplemented for speed" |
|
1808 |
||
1809 |
%{ /* NOCONTEXT */ |
|
1810 |
||
1811 |
REGISTER int index; |
|
1812 |
REGISTER OBJ el; |
|
1813 |
REGISTER OBJ *op; |
|
1814 |
REGISTER unsigned int nIndex; |
|
1815 |
int nInsts; |
|
1816 |
||
1817 |
if (__isSmallInteger(start)) { |
|
5403 | 1818 |
index = __intVal(start) - 1; |
1819 |
if (index >= 0) { |
|
1820 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
|
1821 |
index += nInsts; |
|
1822 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1823 |
el = anElement; |
|
1824 |
op = & (__InstPtr(self)->i_instvars[index]); |
|
1903 | 1825 |
|
2213 | 1826 |
#if defined(memsrch4) |
5403 | 1827 |
if (index < nIndex) { |
1828 |
OBJ *p; |
|
2213 | 1829 |
|
5403 | 1830 |
p = memsrch4(op, (INT)el, (nIndex - index)); |
1831 |
if (p) { |
|
1832 |
index += (p - op + 1); |
|
1833 |
RETURN ( __MKSMALLINT(index) ); |
|
1834 |
} |
|
1835 |
} |
|
2213 | 1836 |
#else |
2216 | 1837 |
|
2213 | 1838 |
# if defined(UNROLL_LOOPS) |
5403 | 1839 |
{ |
1840 |
/* |
|
1841 |
* dont argue about those gotos below - they speed up that thing by 30%; |
|
1842 |
* its better to exit the loops below with a goto, |
|
1843 |
* since the generated code will then be: |
|
1844 |
* compare |
|
1845 |
* branch-on-equal found |
|
1846 |
* |
|
1847 |
* otherwise (with ret as if-statement), we get: |
|
1848 |
* compare |
|
1849 |
* branch-on-not-equal skipLabel |
|
1850 |
* move-to-ret-register true |
|
1851 |
* goto ret-label |
|
1852 |
* skipLabel |
|
1853 |
* |
|
1854 |
* therefore, WITH the so-much-blamed goto, we only branch |
|
1855 |
* when found; without the goto, we branch always. |
|
1856 |
* Pipelined CPUs do usually not like taken branches. |
|
1857 |
*/ |
|
2216 | 1858 |
|
5403 | 1859 |
unsigned int i8; |
2216 | 1860 |
|
5403 | 1861 |
while ((i8 = index + 8) < nIndex) { |
1862 |
if (op[0] == el) goto found1; |
|
1863 |
if (op[1] == el) goto found2; |
|
1864 |
if (op[2] == el) goto found3; |
|
1865 |
if (op[3] == el) goto found4; |
|
1866 |
if (op[4] == el) goto found5; |
|
1867 |
if (op[5] == el) goto found6; |
|
1868 |
if (op[6] == el) goto found7; |
|
1869 |
if (op[7] == el) goto found8; |
|
1870 |
index = i8; |
|
1871 |
op += 8; |
|
1872 |
} |
|
1873 |
if (0) { |
|
1874 |
found1: |
|
1875 |
RETURN ( __MKSMALLINT(index + 1 - nInsts) ); |
|
1876 |
found2: |
|
1877 |
RETURN ( __MKSMALLINT(index + 2 - nInsts) ); |
|
1878 |
found3: |
|
1879 |
RETURN ( __MKSMALLINT(index + 3 - nInsts) ); |
|
1880 |
found4: |
|
1881 |
RETURN ( __MKSMALLINT(index + 4 - nInsts) ); |
|
1882 |
found5: |
|
1883 |
RETURN ( __MKSMALLINT(index + 5 - nInsts) ); |
|
1884 |
found6: |
|
1885 |
RETURN ( __MKSMALLINT(index + 6 - nInsts) ); |
|
1886 |
found7: |
|
1887 |
RETURN ( __MKSMALLINT(index + 7 - nInsts) ); |
|
1888 |
found8: |
|
1889 |
RETURN ( __MKSMALLINT(index + 8 - nInsts) ); |
|
1890 |
} |
|
1891 |
} |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1892 |
# endif /* UNROLLED_LOOPS */ |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1893 |
|
5403 | 1894 |
while (index++ < nIndex) { |
1895 |
if (*op++ == el) goto found0; |
|
1896 |
} |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1897 |
|
5403 | 1898 |
if (0) { |
1899 |
found0: |
|
1900 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1901 |
} |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1902 |
#endif /* no memsrch */ |
5403 | 1903 |
} |
1904 |
RETURN ( __MKSMALLINT(0) ); |
|
543 | 1905 |
} |
1906 |
%}. |
|
5403 | 1907 |
^ super identityIndexOf:anElement startingAt:start |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1908 |
! |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1909 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1910 |
identityIndexOf:anElement startingAt:start endingAt:stop |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1911 |
"search the array for anElement in the range start..stop; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1912 |
return the index if found, 0 otherwise. |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1913 |
- reimplemented for speed when searching in OrderedCollections" |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1914 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1915 |
%{ /* NOCONTEXT */ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1916 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1917 |
REGISTER int index; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1918 |
REGISTER OBJ el; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1919 |
REGISTER OBJ *op; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1920 |
REGISTER unsigned int lastIndex; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1921 |
unsigned int nIndex; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1922 |
int nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1923 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1924 |
if (__bothSmallInteger(start, stop)) { |
5403 | 1925 |
index = __intVal(start) - 1; |
1926 |
if (index >= 0) { |
|
1927 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
|
1928 |
index += nInsts; |
|
1929 |
lastIndex = nInsts + __intVal(stop); |
|
1930 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1931 |
if (nIndex < lastIndex) { |
|
1932 |
lastIndex = nIndex; |
|
1933 |
} |
|
1934 |
el = anElement; |
|
1935 |
op = & (__InstPtr(self)->i_instvars[index]); |
|
2213 | 1936 |
|
1937 |
#if defined(memsrch4) |
|
5403 | 1938 |
if (index < lastIndex) { |
1939 |
OBJ *p; |
|
2216 | 1940 |
|
5403 | 1941 |
p = memsrch4(op, (INT)el, (lastIndex - index)); |
1942 |
if (p) { |
|
1943 |
index += (p - op + 1); |
|
1944 |
RETURN ( __MKSMALLINT(index) ); |
|
1945 |
} |
|
1946 |
} |
|
2216 | 1947 |
#else |
2213 | 1948 |
|
1949 |
# if defined(UNROLL_LOOPS) |
|
5403 | 1950 |
{ |
1951 |
unsigned int i8; |
|
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1952 |
|
5403 | 1953 |
while ((i8 = index + 8) < lastIndex) { |
1954 |
if (op[0] == el) goto found1; |
|
1955 |
if (op[1] == el) goto found2; |
|
1956 |
if (op[2] == el) goto found3; |
|
1957 |
if (op[3] == el) goto found4; |
|
1958 |
if (op[4] == el) goto found5; |
|
1959 |
if (op[5] == el) goto found6; |
|
1960 |
if (op[6] == el) goto found7; |
|
1961 |
if (op[7] == el) goto found8; |
|
1962 |
index = i8; |
|
1963 |
op += 8; |
|
1964 |
} |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1965 |
|
5403 | 1966 |
if (0) { |
1967 |
found1: |
|
1968 |
RETURN ( __MKSMALLINT(index + 1 - nInsts) ); |
|
1969 |
found2: |
|
1970 |
RETURN ( __MKSMALLINT(index + 2 - nInsts) ); |
|
1971 |
found3: |
|
1972 |
RETURN ( __MKSMALLINT(index + 3 - nInsts) ); |
|
1973 |
found4: |
|
1974 |
RETURN ( __MKSMALLINT(index + 4 - nInsts) ); |
|
1975 |
found5: |
|
1976 |
RETURN ( __MKSMALLINT(index + 5 - nInsts) ); |
|
1977 |
found6: |
|
1978 |
RETURN ( __MKSMALLINT(index + 6 - nInsts) ); |
|
1979 |
found7: |
|
1980 |
RETURN ( __MKSMALLINT(index + 7 - nInsts) ); |
|
1981 |
found8: |
|
1982 |
RETURN ( __MKSMALLINT(index + 8 - nInsts) ); |
|
1983 |
} |
|
1984 |
} |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1985 |
# endif /* UNROLL_LOOPS */ |
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1986 |
|
5403 | 1987 |
while (index++ < lastIndex) { |
1988 |
if (*op++ == el) goto found0; |
|
1989 |
} |
|
2715
48beff18cec0
software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents:
2683
diff
changeset
|
1990 |
|
5403 | 1991 |
if (0) { |
1992 |
found0: |
|
1993 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1994 |
} |
|
2213 | 1995 |
#endif |
5403 | 1996 |
} |
1997 |
RETURN ( __MKSMALLINT(0) ); |
|
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1998 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1999 |
%}. |
5403 | 2000 |
^ super identityIndexOf:anElement startingAt:start endingAt:stop |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2001 |
|
543 | 2002 |
! |
2003 |
||
554 | 2004 |
indexOf:anElement startingAt:start |
2005 |
"search the array for anElement; return index if found, 0 otherwise |
|
2006 |
- reimplemented for speed" |
|
543 | 2007 |
|
554 | 2008 |
|element| |
2009 |
%{ |
|
543 | 2010 |
REGISTER int index; |
554 | 2011 |
unsigned int nIndex, nInsts; |
2012 |
static struct inlineCache eq = _ILC1; |
|
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2013 |
OBJ myClass, e; |
543 | 2014 |
|
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
2015 |
myClass = __qClass(self); |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
2016 |
if ( __isSmallInteger(start) ) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2017 |
index = __intVal(start) - 1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2018 |
if (index >= 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2019 |
nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2020 |
index += nInsts; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2021 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2022 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2023 |
e = anElement; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2024 |
if (e != nil) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2025 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2026 |
* special kludge to search for a string; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2027 |
* this is so common, that its worth a special case |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2028 |
*/ |
825
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
2029 |
#define SPECIAL_STRING_OPT |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
2030 |
#ifdef SPECIAL_STRING_OPT |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2031 |
if (__isString(e)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2032 |
while (index < nIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2033 |
element = __InstPtr(self)->i_instvars[index++]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2034 |
if (__isNonNilObject(element)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2035 |
if (element == e) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2036 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2037 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2038 |
if (__qClass(element) == @global(String)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2039 |
if (strcmp(__stringVal(e), __stringVal(element)) == 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2040 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2041 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2042 |
} else { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2043 |
if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2044 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2045 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2046 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2047 |
* send of #= could have lead to a GC - refetch e |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2048 |
*/ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2049 |
e = anElement; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2050 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2051 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2052 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2053 |
RETURN (__MKSMALLINT(0)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2054 |
} |
825
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
2055 |
#endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2056 |
if (__isSmallInteger(e)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2057 |
/* search for a small number */ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2058 |
while (index < nIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2059 |
element = __InstPtr(self)->i_instvars[index++]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2060 |
if (element == e) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2061 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2062 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2063 |
if (!__isSmallInteger(element)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2064 |
if ((*eq.ilc_func)(e, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2065 |
@symbol(=), |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2066 |
nil,&eq, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2067 |
element) == true) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2068 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2069 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2070 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2071 |
* send of #= could have lead to a GC - refetch e |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2072 |
*/ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2073 |
e = anElement; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2074 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2075 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2076 |
RETURN (__MKSMALLINT(0)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2077 |
} |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2078 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2079 |
while (index < nIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2080 |
element = __InstPtr(self)->i_instvars[index++]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2081 |
if (element != nil) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2082 |
e = anElement; |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2083 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2084 |
if ((element == e) |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2085 |
|| ((*eq.ilc_func)(e, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2086 |
@symbol(=), |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2087 |
nil,&eq, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2088 |
element) == true)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2089 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2090 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2091 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2092 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2093 |
} else { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2094 |
OBJ slf = self; |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2095 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2096 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2097 |
* search for nil - do an identity-search |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2098 |
*/ |
554 | 2099 |
#if defined(UNROLL_LOOPS) |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2100 |
{ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2101 |
unsigned int i8; |
554 | 2102 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2103 |
while ((i8 = index + 8) < nIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2104 |
if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2105 |
if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2106 |
if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2107 |
if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2108 |
if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2109 |
if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2110 |
if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2111 |
if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2112 |
index = i8; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2113 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2114 |
} |
554 | 2115 |
#endif |
2116 |
||
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2117 |
while (index < nIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2118 |
if (__InstPtr(slf)->i_instvars[index++] == nil) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2119 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2120 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2121 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2122 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2123 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2124 |
RETURN (__MKSMALLINT(0)); |
543 | 2125 |
} |
554 | 2126 |
%}. |
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
2127 |
^ super indexOf:anElement startingAt:start |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2128 |
! |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2129 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2130 |
indexOf:anElement startingAt:start endingAt:stop |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2131 |
"search the array for anElement in the range start..stop; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2132 |
Return the index if found, 0 otherwise. |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2133 |
- reimplemented for speed when searching in OrderedCollections" |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2134 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2135 |
|element| |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2136 |
%{ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2137 |
REGISTER int index; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2138 |
unsigned int lastIndex, nIndex, nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2139 |
static struct inlineCache eq = _ILC1; |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2140 |
OBJ myClass, e; |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2141 |
|
2184
f25db3e10530
no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
2142 |
myClass = __qClass(self); |
2357
061dadc13df1
removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents:
2318
diff
changeset
|
2143 |
if ( __bothSmallInteger(start, stop) ) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2144 |
index = __intVal(start) - 1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2145 |
if (index >= 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2146 |
nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2147 |
index += nInsts; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2148 |
lastIndex = nInsts + __intVal(stop); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2149 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2150 |
if (nIndex < lastIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2151 |
lastIndex = nIndex; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2152 |
} |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2153 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2154 |
e = anElement; |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2155 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2156 |
if (e != nil) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2157 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2158 |
* special kludge to search for a string; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2159 |
* this is so common, that its worth a special case |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2160 |
*/ |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2161 |
#define SPECIAL_STRING_OPT |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2162 |
#ifdef SPECIAL_STRING_OPT |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2163 |
if (__isString(e)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2164 |
while (index < lastIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2165 |
element = __InstPtr(self)->i_instvars[index++]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2166 |
if (__isNonNilObject(e)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2167 |
if (element == e) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2168 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2169 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2170 |
if (__qClass(element) == @global(String)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2171 |
if (strcmp(__stringVal(e), __stringVal(element)) == 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2172 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2173 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2174 |
} else { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2175 |
if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2176 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2177 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2178 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2179 |
* send of #= could have lead to a GC - refetch e |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2180 |
*/ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2181 |
e = anElement; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2182 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2183 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2184 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2185 |
RETURN (__MKSMALLINT(0)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2186 |
} |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2187 |
#endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2188 |
if (__isSmallInteger(e)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2189 |
/* search for a small number */ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2190 |
while (index < lastIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2191 |
element = __InstPtr(self)->i_instvars[index++]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2192 |
if (element == e) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2193 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2194 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2195 |
if (!__isSmallInteger(element)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2196 |
if ((*eq.ilc_func)(e, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2197 |
@symbol(=), |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2198 |
nil,&eq, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2199 |
element) == true) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2200 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2201 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2202 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2203 |
* send of #= could have lead to a GC - refetch e |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2204 |
*/ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2205 |
e = anElement; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2206 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2207 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2208 |
RETURN (__MKSMALLINT(0)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2209 |
} |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2210 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2211 |
while (index < lastIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2212 |
element = __InstPtr(self)->i_instvars[index++]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2213 |
if (element != nil) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2214 |
e = anElement; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2215 |
if ((element == e) |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2216 |
|| ((*eq.ilc_func)(e, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2217 |
@symbol(=), |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2218 |
nil,&eq, |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2219 |
element) == true)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2220 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2221 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2222 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2223 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2224 |
} else { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2225 |
OBJ slf = self; |
4130
662554f2a37c
avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents:
4122
diff
changeset
|
2226 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2227 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2228 |
* search for nil - do an identity-search |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2229 |
*/ |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2230 |
#if defined(UNROLL_LOOPS) |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2231 |
{ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2232 |
unsigned int i8; |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2233 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2234 |
while ((i8 = index + 8) < lastIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2235 |
if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2236 |
if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2237 |
if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2238 |
if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2239 |
if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2240 |
if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2241 |
if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2242 |
if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2243 |
index = i8; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2244 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2245 |
} |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2246 |
#endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2247 |
while (index < lastIndex) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2248 |
if (__InstPtr(slf)->i_instvars[index++] == nil) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2249 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2250 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2251 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2252 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2253 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4130
diff
changeset
|
2254 |
RETURN (__MKSMALLINT(0)); |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2255 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
2256 |
%}. |
2211
289095fe875a
oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents:
2210
diff
changeset
|
2257 |
^ super indexOf:anElement startingAt:start endingAt:stop |
1 | 2258 |
! ! |
543 | 2259 |
|
3088 | 2260 |
!Array methodsFor:'testing'! |
2261 |
||
2262 |
includes:anObject |
|
2263 |
"return true, if the argument, anObject is contained in the array |
|
2264 |
- reimplemented for speed" |
|
2265 |
||
2266 |
|element| |
|
2267 |
||
2268 |
%{ /* NOCONTEXT */ |
|
2269 |
/* |
|
2270 |
* first, do a quick check using == |
|
2271 |
* this does not need a context or message send. |
|
2272 |
* In many cases this will already find a match. |
|
2273 |
*/ |
|
2274 |
REGISTER int index; |
|
2275 |
REGISTER OBJ o; |
|
2276 |
unsigned int nIndex; |
|
2277 |
||
2278 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
2279 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
|
2280 |
||
4309 | 2281 |
o = anObject; |
2282 |
||
3088 | 2283 |
/* |
2284 |
* however, the search is limited to the first 500 |
|
2285 |
* elements, since otherwise, we may spend too much time |
|
2286 |
* searching for identity if an equal value is found early |
|
2287 |
* (except if searching for nil - there is no need for equal compare ...) |
|
2288 |
*/ |
|
2289 |
if (nIndex > 500) { |
|
5403 | 2290 |
if (o != nil) |
2291 |
nIndex = 500; |
|
3088 | 2292 |
} |
2293 |
||
2294 |
# ifdef memsrch4 |
|
2295 |
if (index < nIndex) { |
|
5403 | 2296 |
OBJ *p; |
3088 | 2297 |
|
5403 | 2298 |
p = memsrch4(&(__InstPtr(self)->i_instvars[index]), (INT)o, (nIndex - index)); |
2299 |
if (p) { |
|
2300 |
RETURN ( true ); |
|
2301 |
} |
|
3088 | 2302 |
} |
2303 |
||
2304 |
# else |
|
2305 |
/* |
|
2306 |
* dont argue those gotos below - they speed up that thing by 30% |
|
2307 |
* its better to exit the loops below with a goto, |
|
2308 |
* since the generated code will then be: |
|
2309 |
* compare |
|
2310 |
* branch-on-equal found |
|
2311 |
* |
|
2312 |
* otherwise, we get: |
|
2313 |
* compare |
|
2314 |
* branch-on-not-equal skipLabel |
|
2315 |
* move-to-return-register true |
|
2316 |
* goto return-label |
|
2317 |
* skipLabel |
|
2318 |
* |
|
2319 |
* therefore, WITH the so-much-blamed goto, we only branch |
|
2320 |
* when found; without the goto, we branch always. |
|
2321 |
* Pipelined CPUs do usually not like taken branches. |
|
2322 |
* also, all branches are forward, which are usually predicted |
|
2323 |
* as not taken. |
|
2324 |
*/ |
|
2325 |
# if defined(UNROLL_LOOPS) |
|
2326 |
{ |
|
5403 | 2327 |
unsigned int i8; |
2328 |
REGISTER OBJ slf = self; |
|
3088 | 2329 |
|
5403 | 2330 |
while ((i8 = index + 8) < nIndex) { |
2331 |
if (__InstPtr(slf)->i_instvars[index] == o) goto found; |
|
2332 |
if (__InstPtr(slf)->i_instvars[index+1] == o) goto found; |
|
2333 |
if (__InstPtr(slf)->i_instvars[index+2] == o) goto found; |
|
2334 |
if (__InstPtr(slf)->i_instvars[index+3] == o) goto found; |
|
2335 |
if (__InstPtr(slf)->i_instvars[index+4] == o) goto found; |
|
2336 |
if (__InstPtr(slf)->i_instvars[index+5] == o) goto found; |
|
2337 |
if (__InstPtr(slf)->i_instvars[index+6] == o) goto found; |
|
2338 |
if (__InstPtr(slf)->i_instvars[index+7] == o) goto found; |
|
2339 |
index = i8; |
|
2340 |
} |
|
3088 | 2341 |
} |
2342 |
# endif /* UNROLL_LOOPS */ |
|
2343 |
||
2344 |
while (index < nIndex) { |
|
5403 | 2345 |
if (__InstPtr(self)->i_instvars[index++] == o) goto found; |
3088 | 2346 |
} |
2347 |
if (0) { |
|
5403 | 2348 |
found: |
2349 |
RETURN (true); |
|
3088 | 2350 |
} |
2351 |
||
2352 |
# endif /* no memsrch */ |
|
2353 |
||
2354 |
if (o == nil) { |
|
5403 | 2355 |
RETURN ( false ); |
3088 | 2356 |
} |
5403 | 2357 |
%}. |
2358 |
||
2359 |
%{ |
|
2360 |
REGISTER int index; |
|
2361 |
REGISTER OBJ o; |
|
2362 |
unsigned int nIndex; |
|
2363 |
static struct inlineCache eq = _ILC1; |
|
3088 | 2364 |
|
2365 |
/* |
|
2366 |
* then do a slow(er) check using = |
|
2367 |
*/ |
|
2368 |
||
2369 |
/* |
|
2370 |
* sorry: cannot access the stuff from above ... |
|
2371 |
*/ |
|
2372 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
2373 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
|
2374 |
||
2375 |
while (index < nIndex) { |
|
5403 | 2376 |
element = __InstPtr(self)->i_instvars[index++]; |
2377 |
if (element != nil) { |
|
2378 |
if ((*eq.ilc_func)(anObject, |
|
2379 |
@symbol(=), |
|
2380 |
nil,&eq, |
|
2381 |
element)==true) { |
|
2382 |
RETURN ( true ); |
|
2383 |
} |
|
2384 |
} |
|
3088 | 2385 |
} |
5403 | 2386 |
RETURN (false); |
3088 | 2387 |
%}. |
5403 | 2388 |
^ super includes:anObject |
5049 | 2389 |
! |
2390 |
||
2391 |
includesIdentical:anObject |
|
2392 |
"return true, if the argument, anObject is contained in the array |
|
2393 |
uses #== (instead of #=) when comparing; i.e. the search is for |
|
2394 |
the object, not some object being equal." |
|
2395 |
||
2396 |
^ (self identityIndexOf:anObject) ~~ 0 |
|
2397 |
||
2398 |
" |
|
2399 |
#(1 2 3 4 5) includes:3.0 |
|
2400 |
||
2401 |
#(1 2 3 4 5) includesIdentical:3.0 |
|
2402 |
" |
|
3088 | 2403 |
! ! |
2404 |
||
4681 | 2405 |
!Array methodsFor:'tracing'! |
2406 |
||
2407 |
traceInto:aRequestor level:level from:referrer |
|
2408 |
"double dispatch into tracer, passing my type implicitely in the selector" |
|
2409 |
||
2410 |
^ aRequestor traceArray:self level:level from:referrer |
|
2411 |
||
2412 |
||
2413 |
! ! |
|
2414 |
||
1903 | 2415 |
!Array class methodsFor:'documentation'! |
626 | 2416 |
|
2417 |
version |
|
5531 | 2418 |
^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.125 2000-08-17 17:27:04 cg Exp $' |
1244 | 2419 |
! ! |