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