211 coll = __INST(collection); |
211 coll = __INST(collection); |
212 p = __INST(position); |
212 p = __INST(position); |
213 l = __INST(readLimit); |
213 l = __INST(readLimit); |
214 |
214 |
215 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
215 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
216 |
216 pos = __intVal(p); |
217 pos = __intVal(p); |
217 if (pos >= 0 && pos < __intVal(l)) { |
218 if (pos >= 0 && pos < __intVal(l)) { |
218 OBJ cls, ret; |
219 OBJ cls, ret; |
219 |
220 |
220 cls = __qClass(coll); |
221 cls = __qClass(coll); |
221 if (cls == @global(String) || cls == @global(ImmutableString) || cls == @global(Symbol)) { |
222 if (cls == @global(String)) { |
222 if (pos < __stringSize(coll)) { |
223 if (pos < __stringSize(coll)) { |
223 ch = __stringVal(coll)[pos]; |
224 ch = __stringVal(coll)[pos]; |
224 ret = __MKCHARACTER(ch); |
225 ret = __MKCHARACTER(ch); |
225 __INST(position) = __mkSmallInteger(pos+1); |
226 __INST(position) = __mkSmallInteger(pos+1); |
226 RETURN ( ret ); |
227 RETURN ( ret ); |
227 } |
228 } |
228 } else if (cls == @global(ByteArray)) { |
229 } else if (cls == @global(ByteArray)) { |
229 if (pos < __byteArraySize(coll)) { |
230 if (pos < __byteArraySize(coll)) { |
230 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
231 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
231 ret = __mkSmallInteger(ch); |
232 ret = __mkSmallInteger(ch); |
232 __INST(position) = __mkSmallInteger(pos+1); |
233 __INST(position) = __mkSmallInteger(pos+1); |
233 RETURN ( ret ); |
234 RETURN ( ret ); |
234 } |
235 } |
235 } else if (cls == @global(Unicode16String)) { |
236 } else if (cls == @global(Unicode16String)) { |
236 if (pos < __unicode16StringSize(coll)) { |
237 if (pos < __unicode16StringSize(coll)) { |
237 ch = __unicode16StringVal(coll)[pos]; |
238 ch = __Unicode16StringInstPtr(coll)->s_element[pos]; |
238 ret = __MKUCHARACTER(ch); |
239 ret = __MKUCHARACTER(ch); |
239 __INST(position) = __mkSmallInteger(pos+1); |
240 __INST(position) = __mkSmallInteger(pos+1); |
240 RETURN ( ret ); |
241 RETURN ( ret ); |
241 } |
242 } |
242 } else if (cls == @global(Array)) { |
243 } else if (cls == @global(Array)) { |
243 if (pos < __arraySize(coll)) { |
244 if (pos < __arraySize(coll)) { |
244 ret = __ArrayInstPtr(coll)->a_element[pos]; |
245 ret = __ArrayInstPtr(coll)->a_element[pos]; |
245 __INST(position) = __mkSmallInteger(pos+1); |
246 __INST(position) = __mkSmallInteger(pos+1); |
246 RETURN ( ret ); |
247 RETURN ( ret ); |
247 } |
248 } |
248 } |
249 } |
249 } |
250 } |
|
251 } |
250 } |
252 %}. |
251 %}. |
253 (position >= readLimit) ifTrue:[^ self pastEndRead]. |
252 (position >= readLimit) ifTrue:[^ self pastEndRead]. |
254 position := position + 1. |
253 position := position + 1. |
255 ret := collection at:position. |
254 ret := collection at:position. |
384 coll = __INST(collection); |
383 coll = __INST(collection); |
385 p = __INST(position); |
384 p = __INST(position); |
386 l = __INST(readLimit); |
385 l = __INST(readLimit); |
387 |
386 |
388 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
387 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
389 |
388 pos = __intVal(p); |
390 pos = __intVal(p); |
389 if (pos >= 0 && pos < __intVal(l)) { |
391 if (pos >= 0 && pos < __intVal(l)) { |
390 OBJ cls, ret; |
392 OBJ cls, ret; |
391 |
393 |
392 cls = __qClass(coll); |
394 cls = __qClass(coll); |
393 if (cls == @global(String) || cls == @global(ImmutableString) || cls == @global(Symbol)) { |
395 if (cls == @global(String)) { |
394 if (pos < __stringSize(coll)) { |
396 if (pos < __stringSize(coll)) { |
395 ch = __stringVal(coll)[pos]; |
397 ch = __stringVal(coll)[pos]; |
396 ret = __mkSmallInteger(ch); |
398 ret = __mkSmallInteger(ch); |
397 __INST(position) = __mkSmallInteger(pos+1); |
399 __INST(position) = __mkSmallInteger(pos+1); |
398 RETURN ( ret ); |
400 RETURN ( ret ); |
399 } |
401 } |
400 } else if (cls == @global(ByteArray)) { |
402 } else if (cls == @global(ByteArray)) { |
401 if (pos < __byteArraySize(coll)) { |
403 if (pos < __byteArraySize(coll)) { |
402 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
404 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
403 ret = __mkSmallInteger(ch); |
405 ret = __mkSmallInteger(ch); |
404 __INST(position) = __mkSmallInteger(pos+1); |
406 __INST(position) = __mkSmallInteger(pos+1); |
405 RETURN ( ret ); |
407 RETURN ( ret ); |
406 } |
408 } |
407 } else if (cls == @global(Array)) { |
409 } else if (cls == @global(Array)) { |
408 if (pos < __arraySize(coll)) { |
410 if (pos < __arraySize(coll)) { |
409 ret = __ArrayInstPtr(coll)->a_element[pos]; |
411 ret = __ArrayInstPtr(coll)->a_element[pos]; |
410 if (!__isSmallInteger(ret) || __intVal(ret) > 255) goto out; |
412 if (!__isSmallInteger(ret) || __intVal(ret) > 255) goto out; |
411 __INST(position) = __mkSmallInteger(pos+1); |
413 __INST(position) = __mkSmallInteger(pos+1); |
412 RETURN ( ret ); |
414 RETURN ( ret ); |
413 } |
415 } |
414 } |
416 } |
415 } |
417 } |
|
418 } |
416 } |
419 out:; |
417 out:; |
420 %}. |
418 %}. |
421 (position >= readLimit) ifTrue:[^ self pastEndRead]. |
419 (position >= readLimit) ifTrue:[^ self pastEndRead]. |
422 ret := (collection at:(position + 1)) asInteger. |
420 ret := (collection at:(position + 1)) asInteger. |
423 ret > 255 ifTrue:[ |
421 ret > 255 ifTrue:[ |
424 ret := ConversionError |
422 ret := ConversionError |
425 raiseRequestWith:self |
423 raiseRequestWith:self |
426 errorString:' - #nextByte trying to read a non-byte'. |
424 errorString:' - #nextByte trying to read a non-byte'. |
427 ]. |
425 ]. |
428 position := position + 1. |
426 position := position + 1. |
429 ^ ret |
427 ^ ret |
430 ! |
428 ! |
431 |
429 |
508 coll = __INST(collection); |
506 coll = __INST(collection); |
509 p = __INST(position); |
507 p = __INST(position); |
510 l = __INST(readLimit); |
508 l = __INST(readLimit); |
511 |
509 |
512 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
510 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
513 pos = __intVal(p); |
511 pos = __intVal(p); |
514 if (pos >= 0) { |
512 if (pos >= 0) { |
515 OBJ cls, ret; |
513 OBJ cls, ret; |
516 |
514 |
517 if (pos >= __intVal(l)) { |
515 if (pos >= __intVal(l)) { |
518 RETURN(nil); |
516 RETURN(nil); |
519 } |
517 } |
520 |
518 |
521 cls = __qClass(coll); |
519 cls = __qClass(coll); |
522 if (cls == @global(String)) { |
520 if (cls == @global(String) || cls == @global(ImmutableString) || cls == @global(Symbol)) { |
523 if (pos < __stringSize(coll)) { |
521 if (pos < __stringSize(coll)) { |
524 ch = __stringVal(coll)[pos]; |
522 ch = __stringVal(coll)[pos]; |
525 ret = __MKCHARACTER(ch); |
523 ret = __MKCHARACTER(ch); |
526 __INST(position) = __mkSmallInteger(pos + 1); |
524 __INST(position) = __mkSmallInteger(pos + 1); |
527 RETURN ( ret ); |
525 RETURN ( ret ); |
528 } |
526 } |
529 } else if (cls == @global(ByteArray)) { |
527 } else if (cls == @global(ByteArray)) { |
530 if (pos < __byteArraySize(coll)) { |
528 if (pos < __byteArraySize(coll)) { |
531 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
529 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
532 ret = __mkSmallInteger(ch); |
530 ret = __mkSmallInteger(ch); |
533 __INST(position) = __mkSmallInteger(pos + 1); |
531 __INST(position) = __mkSmallInteger(pos + 1); |
534 RETURN ( ret ); |
532 RETURN ( ret ); |
535 } |
533 } |
536 } else if (cls == @global(Unicode16String)) { |
534 } else if (cls == @global(Unicode16String)) { |
537 if (pos < __unicode16StringSize(coll)) { |
535 if (pos < __unicode16StringSize(coll)) { |
538 ch = __Unicode16StringInstPtr(coll)->s_element[pos]; |
536 ch = __unicode16StringVal(coll)[pos]; |
539 ret = __MKUCHARACTER(ch); |
537 ret = __MKUCHARACTER(ch); |
540 __INST(position) = __mkSmallInteger(pos + 1); |
538 __INST(position) = __mkSmallInteger(pos + 1); |
541 RETURN ( ret ); |
539 RETURN ( ret ); |
542 } |
540 } |
543 } else if (cls == @global(Array)) { |
541 } else if (cls == @global(Array)) { |
544 if (pos < __arraySize(coll)) { |
542 if (pos < __arraySize(coll)) { |
545 ret = __ArrayInstPtr(coll)->a_element[pos]; |
543 ret = __ArrayInstPtr(coll)->a_element[pos]; |
546 __INST(position) = __mkSmallInteger(pos + 1); |
544 __INST(position) = __mkSmallInteger(pos + 1); |
547 RETURN ( ret ); |
545 RETURN ( ret ); |
548 } |
546 } |
549 } |
547 } |
550 } |
548 } |
551 } |
549 } |
552 %}. |
550 %}. |
553 position := position + 1. |
551 position := position + 1. |
554 ret := collection at:position. |
552 ret := collection at:position. |
555 ^ ret |
553 ^ ret |
602 p = __INST(position); |
600 p = __INST(position); |
603 l = __INST(readLimit); |
601 l = __INST(readLimit); |
604 |
602 |
605 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
603 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
606 |
604 |
607 pos = __intVal(p); |
605 pos = __intVal(p); |
608 if ((pos < __intVal(l)) && (pos >= 0)) { |
606 if ((pos < __intVal(l)) && (pos >= 0)) { |
609 cls = __qClass(coll); |
607 cls = __qClass(coll); |
610 if (cls == @global(String)) { |
608 if (cls == @global(String) || cls == @global(ImmutableString) || cls == @global(Symbol)) { |
611 if (pos < __stringSize(coll)) { |
609 if (pos < __stringSize(coll)) { |
612 ch = __stringVal(coll)[pos]; |
610 ch = __stringVal(coll)[pos]; |
613 RETURN ( __MKCHARACTER(ch) ); |
611 RETURN ( __MKCHARACTER(ch) ); |
614 } |
612 } |
615 } else if (cls == @global(ByteArray)) { |
613 } else if (cls == @global(ByteArray)) { |
616 if (pos < __byteArraySize(coll)) { |
614 if (pos < __byteArraySize(coll)) { |
617 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
615 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
618 RETURN ( __mkSmallInteger(ch) ); |
616 RETURN ( __mkSmallInteger(ch) ); |
619 } |
617 } |
620 } else if (cls == @global(Array)) { |
618 } else if (cls == @global(Unicode16String)) { |
621 if (pos < __arraySize(coll)) { |
619 if (pos < __unicode16StringSize(coll)) { |
622 RETURN ( __ArrayInstPtr(coll)->a_element[pos]); |
620 ch = __unicode16StringVal(coll)[pos]; |
623 } |
621 RETURN(__MKUCHARACTER(ch)); |
624 } |
622 } |
625 } |
623 } else if (cls == @global(Array)) { |
|
624 if (pos < __arraySize(coll)) { |
|
625 RETURN ( __ArrayInstPtr(coll)->a_element[pos]); |
|
626 } |
|
627 } |
|
628 } |
626 } |
629 } |
627 %}. |
630 %}. |
628 (position >= readLimit) ifTrue:[^ self pastEndRead]. |
631 (position >= readLimit) ifTrue:[^ self pastEndRead]. |
629 ^ collection at:(position + 1) |
632 ^ collection at:(position + 1) |
630 ! |
633 ! |
646 coll = __INST(collection); |
649 coll = __INST(collection); |
647 p = __INST(position); |
650 p = __INST(position); |
648 l = __INST(readLimit); |
651 l = __INST(readLimit); |
649 |
652 |
650 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
653 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
651 |
654 pos = __intVal(p); |
652 pos = __intVal(p); |
655 if ((pos < __intVal(l)) && (pos >= 0)) { |
653 if ((pos < __intVal(l)) && (pos >= 0)) { |
656 cls = __qClass(coll); |
654 cls = __qClass(coll); |
657 if (cls == @global(String) || cls == @global(ImmutableString) || cls == @global(Symbol)) { |
655 if (cls == @global(String)) { |
658 if (pos < __stringSize(coll)) { |
656 if (pos < __stringSize(coll)) { |
659 ch = __stringVal(coll)[pos]; |
657 ch = __stringVal(coll)[pos]; |
660 RETURN ( __MKCHARACTER(ch) ); |
658 RETURN ( __MKCHARACTER(ch) ); |
661 } |
659 } |
662 RETURN ( nil ); |
660 RETURN ( nil ); |
663 } else if (cls == @global(ByteArray)) { |
661 } else if (cls == @global(ByteArray)) { |
664 if (pos < __byteArraySize(coll)) { |
662 if (pos < __byteArraySize(coll)) { |
665 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
663 ch = __ByteArrayInstPtr(coll)->ba_element[pos]; |
666 RETURN ( __mkSmallInteger(ch) ); |
664 RETURN ( __mkSmallInteger(ch) ); |
667 } |
665 } |
668 RETURN ( nil ); |
666 RETURN ( nil ); |
669 } else if (cls == @global(Unicode16String)) { |
667 } else if (cls == @global(Array)) { |
670 if (pos < __unicode16StringSize(coll)) { |
668 if (pos < __arraySize(coll)) { |
671 ch = __unicode16StringVal(coll)[pos]; |
669 RETURN ( __ArrayInstPtr(coll)->a_element[pos]); |
672 RETURN(__MKUCHARACTER(ch)); |
670 } |
673 } |
671 RETURN ( nil ); |
674 RETURN ( nil ); |
672 } |
675 } else if (cls == @global(Array)) { |
673 } |
676 if (pos < __arraySize(coll)) { |
|
677 RETURN ( __ArrayInstPtr(coll)->a_element[pos]); |
|
678 } |
|
679 RETURN ( nil ); |
|
680 } |
|
681 } |
674 } |
682 } |
675 %}. |
683 %}. |
676 (position >= readLimit) ifTrue:[^ nil]. |
684 (position >= readLimit) ifTrue:[^ nil]. |
677 ^ collection at:(position + 1) |
685 ^ collection at:(position + 1) |
678 ! |
686 ! |