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