284 |
284 |
285 do:aBlock |
285 do:aBlock |
286 "evaluate the argument, aBlock for each element in the collection. |
286 "evaluate the argument, aBlock for each element in the collection. |
287 - reimplemented for IGC readBarrier. You dont have to understand this." |
287 - reimplemented for IGC readBarrier. You dont have to understand this." |
288 |
288 |
289 |home| |
289 |home element| |
290 %{ |
290 %{ |
291 REGISTER OBJFUNC codeVal; |
291 REGISTER OBJFUNC codeVal; |
292 REGISTER int index; |
292 REGISTER int index; |
293 unsigned int nIndex; |
293 unsigned int nIndex; |
294 static struct inlineCache val = _ILC1; |
294 static struct inlineCache val = _ILC1; |
295 REGISTER OBJ rHome; |
295 REGISTER OBJ rHome; |
296 OBJ el; |
|
297 extern OBJ __WEAK_READ__(); |
296 extern OBJ __WEAK_READ__(); |
298 |
297 |
299 index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
298 index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
300 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
299 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
301 if (__isBlockLike(aBlock) |
300 if (__isBlockLike(aBlock) |
302 && ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
301 && ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
303 && (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
302 && (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
304 #ifdef NEW_BLOCK_CALL |
303 #ifdef NEW_BLOCK_CALL |
305 for (; index < nIndex; index++) { |
304 for (; index < nIndex; index++) { |
306 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
305 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
307 el = _InstPtr(self)->i_instvars[index]; |
306 element = _InstPtr(self)->i_instvars[index]; |
308 if (el != nil) el = __WEAK_READ__(self, el); |
307 if (element != nil) element = __WEAK_READ__(self, element); |
309 (*codeVal)(aBlock, CON_COMMA el); |
308 (*codeVal)(aBlock, CON_COMMA element); |
310 } |
309 } |
311 #else |
310 #else |
312 home = _BlockInstPtr(aBlock)->b_home; |
311 home = _BlockInstPtr(aBlock)->b_home; |
313 rHome = home; |
312 rHome = home; |
314 if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
313 if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
316 * home will not move - keep in a fast register |
315 * home will not move - keep in a fast register |
317 */ |
316 */ |
318 for (; index < nIndex; index++) { |
317 for (; index < nIndex; index++) { |
319 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
318 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
320 |
319 |
321 el = _InstPtr(self)->i_instvars[index]; |
320 element = _InstPtr(self)->i_instvars[index]; |
322 if (el != nil) el = __WEAK_READ__(self, el); |
321 if (element != nil) element = __WEAK_READ__(self, element); |
323 (*codeVal)(rHome, CON_COMMA el); |
322 (*codeVal)(rHome, CON_COMMA element); |
324 } |
323 } |
325 } else { |
324 } else { |
326 for (; index < nIndex; index++) { |
325 for (; index < nIndex; index++) { |
327 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
326 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
328 |
327 |
329 el = _InstPtr(self)->i_instvars[index]; |
328 element = _InstPtr(self)->i_instvars[index]; |
330 if (el != nil) el = __WEAK_READ__(self, el); |
329 if (element != nil) element = __WEAK_READ__(self, element); |
331 (*codeVal)(home, CON_COMMA el); |
330 (*codeVal)(home, CON_COMMA element); |
332 } |
331 } |
333 } |
332 } |
334 #endif |
333 #endif |
335 } else { |
334 } else { |
336 for (; index < nIndex; index++) { |
335 for (; index < nIndex; index++) { |
337 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
336 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
338 |
337 |
339 el = _InstPtr(self)->i_instvars[index]; |
338 element = _InstPtr(self)->i_instvars[index]; |
340 if (el != nil) el = __WEAK_READ__(self, el); |
339 if (element != nil) element = __WEAK_READ__(self, element); |
341 (*val.ilc_func)(aBlock, |
340 (*val.ilc_func)(aBlock, |
342 @symbol(value:), |
341 @symbol(value:), |
343 CON_COMMA nil, &val, |
342 CON_COMMA nil, &val, |
344 el); |
343 element); |
345 } |
344 } |
346 } |
345 } |
347 %} |
346 %}. |
348 . |
|
349 ^ self |
347 ^ self |
350 ! |
348 ! |
351 |
349 |
352 from:start to:stop do:aBlock |
350 from:start to:stop do:aBlock |
353 "evaluate the argument, aBlock for the elements starting at index start |
351 "evaluate the argument, aBlock for the elements starting at index start |
354 up to (and including) stop in the collection. |
352 up to (and including) stop in the collection. |
355 - reimplemented for IGC readBarrier. You dont have to understand this." |
353 - reimplemented for IGC readBarrier. You dont have to understand this." |
356 |
354 |
357 |home| |
355 |home element| |
358 %{ |
356 %{ |
359 REGISTER OBJFUNC codeVal; |
357 REGISTER OBJFUNC codeVal; |
360 REGISTER int index; |
358 REGISTER int index; |
361 REGISTER OBJ rHome; |
359 REGISTER OBJ rHome; |
362 int nIndex, nInsts; |
360 int nIndex, nInsts; |
363 static struct inlineCache val = _ILC1; |
361 static struct inlineCache val = _ILC1; |
364 int indexLow, indexHigh; |
362 int indexLow, indexHigh; |
365 OBJ el; |
|
366 extern OBJ __WEAK_READ__(); |
363 extern OBJ __WEAK_READ__(); |
367 |
364 |
368 if (__bothSmallInteger(start, stop)) { |
365 if (__bothSmallInteger(start, stop)) { |
369 indexLow = _intVal(start); |
366 indexLow = _intVal(start); |
370 if (indexLow > 0) { |
367 if (indexLow > 0) { |
380 && ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
377 && ((codeVal = _BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
381 && (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
378 && (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
382 #ifdef NEW_BLOCK_CALL |
379 #ifdef NEW_BLOCK_CALL |
383 for (index=indexLow; index <= indexHigh; index++) { |
380 for (index=indexLow; index <= indexHigh; index++) { |
384 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
381 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
385 el = _InstPtr(self)->i_instvars[index]; |
382 element = _InstPtr(self)->i_instvars[index]; |
386 if (el != nil) el = __WEAK_READ__(self, el); |
383 if (element != nil) element = __WEAK_READ__(self, element); |
387 (*codeVal)(aBlock, CON_COMMA el); |
384 (*codeVal)(aBlock, CON_COMMA element); |
388 } |
385 } |
389 #else |
386 #else |
390 home = _BlockInstPtr(aBlock)->b_home; |
387 home = _BlockInstPtr(aBlock)->b_home; |
391 rHome = home; |
388 rHome = home; |
392 if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
389 if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
393 index = indexLow; |
390 index = indexLow; |
394 for (; index <= indexHigh; index++) { |
391 for (; index <= indexHigh; index++) { |
395 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
392 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
396 el = _InstPtr(self)->i_instvars[index]; |
393 element = _InstPtr(self)->i_instvars[index]; |
397 if (el != nil) el = __WEAK_READ__(self, el); |
394 if (element != nil) element = __WEAK_READ__(self, element); |
398 (*codeVal)(rHome, CON_COMMA el); |
395 (*codeVal)(rHome, CON_COMMA element); |
399 } |
396 } |
400 } else { |
397 } else { |
401 for (index=indexLow; index <= indexHigh; index++) { |
398 for (index=indexLow; index <= indexHigh; index++) { |
402 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
399 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
403 el = _InstPtr(self)->i_instvars[index]; |
400 element = _InstPtr(self)->i_instvars[index]; |
404 if (el != nil) el = __WEAK_READ__(self, el); |
401 if (element != nil) element = __WEAK_READ__(self, element); |
405 (*codeVal)(home, CON_COMMA el); |
402 (*codeVal)(home, CON_COMMA element); |
406 } |
403 } |
407 } |
404 } |
408 #endif |
405 #endif |
409 } else { |
406 } else { |
410 for (index=indexLow; index <= indexHigh; index++) { |
407 for (index=indexLow; index <= indexHigh; index++) { |
411 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
408 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
412 el = _InstPtr(self)->i_instvars[index]; |
409 element = _InstPtr(self)->i_instvars[index]; |
413 if (el != nil) el = __WEAK_READ__(self, el); |
410 if (element != nil) element = __WEAK_READ__(self, element); |
414 (*val.ilc_func) (aBlock, |
411 (*val.ilc_func) (aBlock, |
415 @symbol(value:), |
412 @symbol(value:), |
416 CON_COMMA nil, &val, |
413 CON_COMMA nil, &val, |
417 el); |
414 element); |
418 } |
415 } |
419 } |
416 } |
420 } |
417 } |
421 RETURN ( self ); |
418 RETURN ( self ); |
422 } |
419 } |
429 keysAndValuesDo:aBlock |
426 keysAndValuesDo:aBlock |
430 "evaluate the argument, aBlock for each element in the collection. |
427 "evaluate the argument, aBlock for each element in the collection. |
431 Pass both index and element to the block. |
428 Pass both index and element to the block. |
432 - reimplemented for speed" |
429 - reimplemented for speed" |
433 |
430 |
434 |home| |
431 |home element| |
435 %{ |
432 %{ |
436 REGISTER OBJFUNC codeVal; |
433 REGISTER OBJFUNC codeVal; |
437 REGISTER int index; |
434 REGISTER int index; |
438 unsigned int nIndex; |
435 unsigned int nIndex; |
439 static struct inlineCache val2 = _ILC2; |
436 static struct inlineCache val2 = _ILC2; |
440 REGISTER OBJ rHome; |
437 REGISTER OBJ rHome; |
441 OBJ el; |
|
442 extern OBJ __WEAK_READ__(); |
438 extern OBJ __WEAK_READ__(); |
443 |
439 |
444 index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
440 index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
445 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
441 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
446 if (__isBlockLike(aBlock) |
442 if (__isBlockLike(aBlock) |
448 && (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) { |
444 && (_BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) { |
449 #ifdef NEW_BLOCK_CALL |
445 #ifdef NEW_BLOCK_CALL |
450 for (; index < nIndex; index++) { |
446 for (; index < nIndex; index++) { |
451 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
447 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
452 |
448 |
453 el = _InstPtr(self)->i_instvars[index]; |
449 element = _InstPtr(self)->i_instvars[index]; |
454 if (el != nil) el = __WEAK_READ__(self, el); |
450 if (element != nil) element = __WEAK_READ__(self, element); |
455 (*codeVal)(aBlock, CON_COMMA __MKSMALLINT(index+1), el); |
451 (*codeVal)(aBlock, CON_COMMA __MKSMALLINT(index+1), element); |
456 } |
452 } |
457 #else |
453 #else |
458 home = _BlockInstPtr(aBlock)->b_home; |
454 home = _BlockInstPtr(aBlock)->b_home; |
459 rHome = home; |
455 rHome = home; |
460 if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
456 if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
462 * home will not move - keep in a fast register |
458 * home will not move - keep in a fast register |
463 */ |
459 */ |
464 while (index < nIndex) { |
460 while (index < nIndex) { |
465 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
461 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
466 |
462 |
467 el = _InstPtr(self)->i_instvars[index]; |
463 element = _InstPtr(self)->i_instvars[index]; |
468 if (el != nil) el = __WEAK_READ__(self, el); |
464 if (element != nil) element = __WEAK_READ__(self, element); |
469 index++; |
465 index++; |
470 (*codeVal)(rHome, CON_COMMA __MKSMALLINT(index), el); |
466 (*codeVal)(rHome, CON_COMMA __MKSMALLINT(index), element); |
471 } |
467 } |
472 } else { |
468 } else { |
473 while (index < nIndex) { |
469 while (index < nIndex) { |
474 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
470 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
475 |
471 |
476 el = _InstPtr(self)->i_instvars[index]; |
472 element = _InstPtr(self)->i_instvars[index]; |
477 if (el != nil) el = __WEAK_READ__(self, el); |
473 if (element != nil) element = __WEAK_READ__(self, element); |
478 index++; |
474 index++; |
479 (*codeVal)(home, CON_COMMA __MKSMALLINT(index), el); |
475 (*codeVal)(home, CON_COMMA __MKSMALLINT(index), element); |
480 } |
476 } |
481 } |
477 } |
482 #endif |
478 #endif |
483 } else { |
479 } else { |
484 while (index < nIndex) { |
480 while (index < nIndex) { |
485 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
481 if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
486 |
482 |
487 el = _InstPtr(self)->i_instvars[index]; |
483 element = _InstPtr(self)->i_instvars[index]; |
488 if (el != nil) el = __WEAK_READ__(self, el); |
484 if (element != nil) element = __WEAK_READ__(self, element); |
489 index++; |
485 index++; |
490 (*val2.ilc_func)(aBlock, |
486 (*val2.ilc_func)(aBlock, |
491 @symbol(value:value:), |
487 @symbol(value:value:), |
492 CON_COMMA nil, &val2, |
488 CON_COMMA nil, &val2, |
493 __MKSMALLINT(index), |
489 __MKSMALLINT(index), |
494 el); |
490 element); |
495 } |
491 } |
496 } |
492 } |
497 %}. |
493 %}. |
498 ^ self |
494 ^ self |
499 ! |
495 ! |
500 |
496 |
501 nonNilElementsDo:aBlock |
497 nonNilElementsDo:aBlock |
502 "evaluate the argument, aBlock for each non-nil element" |
498 "evaluate the argument, aBlock for each non-nil element" |
503 |
499 |
504 |home| |
500 |home element| |
505 %{ |
501 %{ |
506 REGISTER OBJFUNC codeVal; |
502 REGISTER OBJFUNC codeVal; |
507 REGISTER int index; |
503 REGISTER int index; |
508 int nIndex; |
504 int nIndex; |
509 static struct inlineCache val = _ILC1; |
505 static struct inlineCache val = _ILC1; |
510 REGISTER OBJ rHome; |
506 REGISTER OBJ rHome; |
511 REGISTER OBJ element; |
|
512 extern OBJ __WEAK_READ__(); |
507 extern OBJ __WEAK_READ__(); |
513 |
508 |
514 index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
509 index = _intVal(_ClassInstPtr(__qClass(self))->c_ninstvars); |
515 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
510 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
516 if (__isBlockLike(aBlock) |
511 if (__isBlockLike(aBlock) |