--- a/Array.st Wed Jun 23 14:40:39 1999 +0200
+++ b/Array.st Wed Jun 23 14:41:21 1999 +0200
@@ -57,7 +57,7 @@
Literal arrays (i.e. array-constants) are entered in source as:
- #( element1 element2 ... element-n)
+ #( element1 element2 ... element-n)
where each element must be itself a literal constant.
Array, symbol and byteArray constants within an array can be written
@@ -73,19 +73,19 @@
#(two [3 3 3] (4 4 4)) -> 3 elements: a symbol, a byteArray and another array
[memory requirements:]
- OBJ-HEADER + (size * ptr-size)
+ OBJ-HEADER + (size * ptr-size)
[warning:]
- read the warning about 'growing fixed size collection'
- in ArrayedCollection's documentation
+ read the warning about 'growing fixed size collection'
+ in ArrayedCollection's documentation
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- OrderedCollection
- ByteArray FloatArray DoubleArray
- String
+ OrderedCollection
+ ByteArray FloatArray DoubleArray
+ String
"
! !
@@ -294,15 +294,15 @@
REGISTER OBJ cls;
if (__isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- slf = self;
+ indx = __intVal(index) - 1;
+ slf = self;
- nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
- if ((cls = __qClass(slf)) != Array)
- indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
- if ((unsigned)indx < (unsigned)nIndex) {
- RETURN ( __InstPtr(slf)->i_instvars[indx] );
- }
+ nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
+ if ((cls = __qClass(slf)) != Array)
+ indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
+ if ((unsigned)indx < (unsigned)nIndex) {
+ RETURN ( __InstPtr(slf)->i_instvars[indx] );
+ }
}
%}.
^ super at:index
@@ -324,17 +324,17 @@
REGISTER OBJ cls;
if (__isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- slf = self;
+ indx = __intVal(index) - 1;
+ slf = self;
- nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
- if ((cls = __qClass(slf)) != Array)
- indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
- if ((unsigned)indx < (unsigned)nIndex) {
- __InstPtr(slf)->i_instvars[indx] = anObject;
- __STORE(slf, anObject);
- RETURN ( anObject );
- }
+ nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
+ if ((cls = __qClass(slf)) != Array)
+ indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
+ if ((unsigned)indx < (unsigned)nIndex) {
+ __InstPtr(slf)->i_instvars[indx] = anObject;
+ __STORE(slf, anObject);
+ RETURN ( anObject );
+ }
}
%}.
^ super at:index put:anObject
@@ -354,15 +354,15 @@
REGISTER OBJ cls;
if (__isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- slf = self;
+ indx = __intVal(index) - 1;
+ slf = self;
- nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
- if ((cls = __qClass(slf)) != Array)
- indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
- if ((unsigned)indx < (unsigned)nIndex) {
- RETURN ( __InstPtr(slf)->i_instvars[indx] );
- }
+ nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
+ if ((cls = __qClass(slf)) != Array)
+ indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
+ if ((unsigned)indx < (unsigned)nIndex) {
+ RETURN ( __InstPtr(slf)->i_instvars[indx] );
+ }
}
%}.
^ super basicAt:index
@@ -381,17 +381,17 @@
REGISTER OBJ cls;
if (__isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- slf = self;
+ indx = __intVal(index) - 1;
+ slf = self;
- nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
- if ((cls = __qClass(slf)) != Array)
- indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
- if ((unsigned)indx < (unsigned)nIndex) {
- __InstPtr(slf)->i_instvars[indx] = anObject;
- __STORE(slf, anObject);
- RETURN ( anObject );
- }
+ nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
+ if ((cls = __qClass(slf)) != Array)
+ indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
+ if ((unsigned)indx < (unsigned)nIndex) {
+ __InstPtr(slf)->i_instvars[indx] = anObject;
+ __STORE(slf, anObject);
+ RETURN ( anObject );
+ }
}
%}.
^ super basicAt:index put:anObject
@@ -479,7 +479,7 @@
#ifdef UNROLL_LOOPS
while (nIndex >= 4) {
- OBJ element;
+ OBJ element;
element = srcP[0];
dstP[0] = element;
@@ -499,7 +499,7 @@
}
#endif
while (nIndex--) {
- OBJ element;
+ OBJ element;
element = *srcP++;
*dstP++ = element;
@@ -783,7 +783,7 @@
OBJ __aBlock = aBlock;
int n;
- index--; /* 0-based */
+ index--; /* 0-based */
n = indexHigh - index;
if (__isBlockLike(__aBlock)
@@ -930,25 +930,25 @@
goto continue7;
# ifdef UNROLL_LOOPS2
- interrupt0b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
- goto continue0b;
- interrupt1b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
- goto continue1b;
- interrupt2b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
- goto continue2b;
- interrupt3b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
- goto continue3b;
+ interrupt0b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
+ goto continue0b;
+ interrupt1b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
+ goto continue1b;
+ interrupt2b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
+ goto continue2b;
+ interrupt3b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
+ goto continue3b;
- interrupt0c:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
- goto continue0c;
- interrupt1c:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
- goto continue1c;
+ interrupt0c:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
+ goto continue0c;
+ interrupt1c:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
+ goto continue1c;
# endif /* UNROLL_LOOPS2 */
#endif /* UNROLL_LOOPS */
interruptX:
@@ -1457,142 +1457,142 @@
OBJ myClass;
if (
- (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __MKSMALLINT(0))
+ (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __MKSMALLINT(0))
&& __isNonNilObject(aCollection)
&& (((t = __qClass(aCollection)) == Array) || (t == myClass))
&& __bothSmallInteger(start, stop)
&& __isSmallInteger(repStart)
) {
- startIndex = __intVal(start) - 1;
- if (startIndex >= 0) {
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- stopIndex = __intVal(stop) - 1;
- count = stopIndex - startIndex + 1;
+ startIndex = __intVal(start) - 1;
+ if (startIndex >= 0) {
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ stopIndex = __intVal(stop) - 1;
+ count = stopIndex - startIndex + 1;
- if ((count > 0) && (stopIndex < nIndex)) {
- repStartIndex = __intVal(repStart) - 1;
- if (repStartIndex >= 0) {
- repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE);
- repStopIndex = repStartIndex + (stopIndex - startIndex);
- if (repStopIndex < repNIndex) {
- src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]);
- dst = &(__InstPtr(self)->i_instvars[startIndex]);
- if (aCollection == self) {
- /*
- * no need to check stores if copying
- * from myself
- */
+ if ((count > 0) && (stopIndex < nIndex)) {
+ repStartIndex = __intVal(repStart) - 1;
+ if (repStartIndex >= 0) {
+ repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE);
+ repStopIndex = repStartIndex + (stopIndex - startIndex);
+ if (repStopIndex < repNIndex) {
+ src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]);
+ dst = &(__InstPtr(self)->i_instvars[startIndex]);
+ if (aCollection == self) {
+ /*
+ * no need to check stores if copying
+ * from myself
+ */
- /*
- * take care of overlapping copy
- * do not depend on memset being smart enough
- * (some are not ;-)
- */
- if (src < dst) {
- /* must do a reverse copy */
- src += count;
- dst += count;
+ /*
+ * take care of overlapping copy
+ * do not depend on memset being smart enough
+ * (some are not ;-)
+ */
+ if (src < dst) {
+ /* must do a reverse copy */
+ src += count;
+ dst += count;
#if defined(UNROLL_LOOPS)
- while (count > 8) {
- dst[-1] = src[-1];
- dst[-2] = src[-2];
- dst[-3] = src[-3];
- dst[-4] = src[-4];
- dst[-5] = src[-5];
- dst[-6] = src[-6];
- dst[-7] = src[-7];
- dst[-8] = src[-8];
- dst -= 8; src -= 8;
- count -= 8;
- }
+ while (count > 8) {
+ dst[-1] = src[-1];
+ dst[-2] = src[-2];
+ dst[-3] = src[-3];
+ dst[-4] = src[-4];
+ dst[-5] = src[-5];
+ dst[-6] = src[-6];
+ dst[-7] = src[-7];
+ dst[-8] = src[-8];
+ dst -= 8; src -= 8;
+ count -= 8;
+ }
#endif
- while (count-- > 0) {
- *--dst = *--src;
- }
- RETURN ( self );
- }
+ while (count-- > 0) {
+ *--dst = *--src;
+ }
+ RETURN ( self );
+ }
#ifdef SOFTWARE_PIPELINE
- {
- OBJ t1;
+ {
+ OBJ t1;
- /*
- * the loop below fetches one longWord behind
- * this should not be a problem
- */
- t1 = src[0];
- count--;
- if (count) {
- dst++; src++;
- do {
- dst[-1] = t1;
- t1 = src[0];
- src++;
- dst++;
- } while (count--);
- } else {
- dst[0] = t1;
- }
- }
+ /*
+ * the loop below fetches one longWord behind
+ * this should not be a problem
+ */
+ t1 = src[0];
+ count--;
+ if (count) {
+ dst++; src++;
+ do {
+ dst[-1] = t1;
+ t1 = src[0];
+ src++;
+ dst++;
+ } while (count--);
+ } else {
+ dst[0] = t1;
+ }
+ }
#else
# ifdef bcopy4
- bcopy4(src, dst, count);
+ bcopy4(src, dst, count);
# else
# ifdef FAST_MEMCPY
- bcopy(src, dst, __OBJS2BYTES__(count));
+ bcopy(src, dst, __OBJS2BYTES__(count));
# else
# if defined(UNROLL_LOOPS)
- while (count >= 8) {
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- dst[4] = src[4];
- dst[5] = src[5];
- dst[6] = src[6];
- dst[7] = src[7];
- dst += 8; src += 8;
- count -= 8;
- }
+ while (count >= 8) {
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ dst[3] = src[3];
+ dst[4] = src[4];
+ dst[5] = src[5];
+ dst[6] = src[6];
+ dst[7] = src[7];
+ dst += 8; src += 8;
+ count -= 8;
+ }
# endif
- while (count--) {
- *dst++ = *src++;
- }
+ while (count--) {
+ *dst++ = *src++;
+ }
# endif
# endif
#endif
- } else {
- REGISTER int spc;
+ } else {
+ REGISTER int spc;
- spc = __qSpace(self);
+ spc = __qSpace(self);
#if defined(UNROLL_LOOPS)
- while (count >= 8) {
- t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc);
- t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc);
- t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc);
- t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc);
- t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc);
- t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc);
- t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc);
- t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc);
- count -= 8; src += 8; dst += 8;
- }
+ while (count >= 8) {
+ t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc);
+ t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc);
+ t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc);
+ t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc);
+ t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc);
+ t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc);
+ t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc);
+ t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc);
+ count -= 8; src += 8; dst += 8;
+ }
#endif
- while (count-- > 0) {
- t = *src++;
- *dst++ = t;
- __STORE_SPC(self, t, spc);
- }
- }
- RETURN ( self );
- }
- }
- }
+ while (count-- > 0) {
+ t = *src++;
+ *dst++ = t;
+ __STORE_SPC(self, t, spc);
+ }
+ }
+ RETURN ( self );
+ }
+ }
+ }
- if (count == 0) {
- RETURN ( self );
- }
- }
+ if (count == 0) {
+ RETURN ( self );
+ }
+ }
}
%}.
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
@@ -1673,7 +1673,7 @@
REGISTER OBJ slf = self;
if (__qClass(slf) == Array) {
- RETURN ( (__arraySize(slf) == 0) ? true : false);
+ RETURN ( (__arraySize(slf) == 0) ? true : false);
}
%}.
^ self size == 0
@@ -1709,7 +1709,7 @@
REGISTER OBJ slf = self;
if (__qClass(slf) == Array) {
- RETURN ( (__arraySize(slf) != 0) ? true : false);
+ RETURN ( (__arraySize(slf) != 0) ? true : false);
}
%}.
^ self size ~~ 0
@@ -1829,11 +1829,11 @@
* compare
* branch-on-equal found
*
- * otherwise (with return as if-statement), we get:
+ * otherwise (with ret as if-statement), we get:
* compare
* branch-on-not-equal skipLabel
- * move-to-return-register true
- * goto return-label
+ * move-to-ret-register true
+ * goto ret-label
* skipLabel
*
* therefore, WITH the so-much-blamed goto, we only branch
@@ -1999,114 +1999,114 @@
myClass = __qClass(self);
if ( __isSmallInteger(start) ) {
- index = __intVal(start) - 1;
- if (index >= 0) {
- nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- index += nInsts;
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ index = __intVal(start) - 1;
+ if (index >= 0) {
+ nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ index += nInsts;
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- e = anElement;
- if (e != nil) {
- /*
- * special kludge to search for a string;
- * this is so common, that its worth a special case
- */
+ e = anElement;
+ if (e != nil) {
+ /*
+ * special kludge to search for a string;
+ * this is so common, that its worth a special case
+ */
#define SPECIAL_STRING_OPT
#ifdef SPECIAL_STRING_OPT
- if (__isString(e)) {
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (__isNonNilObject(element)) {
- if (element == e) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- if (__qClass(element) == @global(String)) {
- if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- } else {
- if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- }
- RETURN (__MKSMALLINT(0));
- }
+ if (__isString(e)) {
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (__isNonNilObject(element)) {
+ if (element == e) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ if (__qClass(element) == @global(String)) {
+ if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ } else {
+ if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
+ }
#endif
- if (__isSmallInteger(e)) {
- /* search for a small number */
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element == e) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- if (!__isSmallInteger(element)) {
- if ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- RETURN (__MKSMALLINT(0));
- }
+ if (__isSmallInteger(e)) {
+ /* search for a small number */
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element == e) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ if (!__isSmallInteger(element)) {
+ if ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ RETURN (__MKSMALLINT(0));
+ }
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element != nil) {
- e = anElement;
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element != nil) {
+ e = anElement;
- if ((element == e)
- || ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true)) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- } else {
- OBJ slf = self;
+ if ((element == e)
+ || ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true)) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ } else {
+ OBJ slf = self;
- /*
- * search for nil - do an identity-search
- */
+ /*
+ * search for nil - do an identity-search
+ */
#if defined(UNROLL_LOOPS)
- {
- unsigned int i8;
+ {
+ unsigned int i8;
- while ((i8 = index + 8) < nIndex) {
- if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
- if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
- if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
- if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
- if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
- if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
- if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
- if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
- index = i8;
- }
- }
+ while ((i8 = index + 8) < nIndex) {
+ if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
+ if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
+ if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
+ if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
+ if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
+ if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
+ if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
+ if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
+ index = i8;
+ }
+ }
#endif
- while (index < nIndex) {
- if (__InstPtr(slf)->i_instvars[index++] == nil) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- }
- RETURN (__MKSMALLINT(0));
+ while (index < nIndex) {
+ if (__InstPtr(slf)->i_instvars[index++] == nil) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
}
%}.
^ super indexOf:anElement startingAt:start
@@ -2126,117 +2126,117 @@
myClass = __qClass(self);
if ( __bothSmallInteger(start, stop) ) {
- index = __intVal(start) - 1;
- if (index >= 0) {
- nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- index += nInsts;
- lastIndex = nInsts + __intVal(stop);
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- if (nIndex < lastIndex) {
- lastIndex = nIndex;
- }
+ index = __intVal(start) - 1;
+ if (index >= 0) {
+ nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ index += nInsts;
+ lastIndex = nInsts + __intVal(stop);
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ if (nIndex < lastIndex) {
+ lastIndex = nIndex;
+ }
- e = anElement;
+ e = anElement;
- if (e != nil) {
- /*
- * special kludge to search for a string;
- * this is so common, that its worth a special case
- */
+ if (e != nil) {
+ /*
+ * special kludge to search for a string;
+ * this is so common, that its worth a special case
+ */
#define SPECIAL_STRING_OPT
#ifdef SPECIAL_STRING_OPT
- if (__isString(e)) {
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (__isNonNilObject(e)) {
- if (element == e) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- if (__qClass(element) == @global(String)) {
- if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- } else {
- if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- }
- RETURN (__MKSMALLINT(0));
- }
+ if (__isString(e)) {
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (__isNonNilObject(e)) {
+ if (element == e) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ if (__qClass(element) == @global(String)) {
+ if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ } else {
+ if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
+ }
#endif
- if (__isSmallInteger(e)) {
- /* search for a small number */
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element == e) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- if (!__isSmallInteger(element)) {
- if ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- RETURN (__MKSMALLINT(0));
- }
+ if (__isSmallInteger(e)) {
+ /* search for a small number */
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element == e) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ if (!__isSmallInteger(element)) {
+ if ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ RETURN (__MKSMALLINT(0));
+ }
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element != nil) {
- e = anElement;
- if ((element == e)
- || ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true)) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- } else {
- OBJ slf = self;
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element != nil) {
+ e = anElement;
+ if ((element == e)
+ || ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true)) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ } else {
+ OBJ slf = self;
- /*
- * search for nil - do an identity-search
- */
+ /*
+ * search for nil - do an identity-search
+ */
#if defined(UNROLL_LOOPS)
- {
- unsigned int i8;
+ {
+ unsigned int i8;
- while ((i8 = index + 8) < lastIndex) {
- if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
- if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
- if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
- if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
- if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
- if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
- if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
- if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
- index = i8;
- }
- }
+ while ((i8 = index + 8) < lastIndex) {
+ if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
+ if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
+ if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
+ if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
+ if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
+ if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
+ if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
+ if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
+ index = i8;
+ }
+ }
#endif
- while (index < lastIndex) {
- if (__InstPtr(slf)->i_instvars[index++] == nil) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- }
- RETURN (__MKSMALLINT(0));
+ while (index < lastIndex) {
+ if (__InstPtr(slf)->i_instvars[index++] == nil) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
}
%}.
^ super indexOf:anElement startingAt:start endingAt:stop
@@ -2370,5 +2370,5 @@
!Array class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.114 1999-04-29 22:38:23 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.115 1999-06-23 12:41:21 cg Exp $'
! !