--- a/Array.st Mon Jan 20 17:12:35 1997 +0100
+++ b/Array.st Mon Jan 20 20:25:15 1997 +0100
@@ -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,16 +73,16 @@
#(two [3 3 3] (4 4 4)) -> 3 elements: a symbol, a byteArray and another array
[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
"
! !
@@ -307,20 +307,20 @@
REGISTER OBJ cls;
if (__isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- slf = self;
+ indx = __intVal(index) - 1;
+ slf = self;
- /* thanks to Patterson/Hennesey - this can be done with a single
- * compare ...
- */
- 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 );
- }
+ /* thanks to Patterson/Hennesey - this can be done with a single
+ * compare ...
+ */
+ 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
@@ -371,21 +371,21 @@
REGISTER OBJ cls;
if (__isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- slf = self;
+ indx = __intVal(index) - 1;
+ slf = self;
- /*
- * thanks to Patterson/Hennesey - this can be done with a single
- * compare ...
- */
- 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 );
- }
+ /*
+ * thanks to Patterson/Hennesey - this can be done with a single
+ * compare ...
+ */
+ 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
@@ -424,7 +424,7 @@
"could be an instance of a subclass..."
self class == Array ifTrue:[
- ^ self
+ ^ self
].
^ super asArray
@@ -536,44 +536,44 @@
myClass = __qClass(self);
if (((INT)( __ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY)) {
- index = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- nIndex = index + __intVal(sz);
- if (nIndex <= actualSize) {
+ index = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ nIndex = index + __intVal(sz);
+ if (nIndex <= actualSize) {
- if (__isBlockLike(aBlock)
- && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) {
+ if (__isBlockLike(aBlock)
+ && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) {
{
- /*
- * the most common case: a static compiled block, with home on the stack ...
- */
- REGISTER OBJFUNC codeVal;
+ /*
+ * the most common case: a static compiled block, with home on the stack ...
+ */
+ REGISTER OBJFUNC codeVal;
if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
#ifdef NEW_BLOCK_CALL
-# define BLOCK_ARG aBlock
+# define BLOCK_ARG aBlock
#else
-# define BLOCK_ARG rHome
- REGISTER OBJ rHome;
+# define BLOCK_ARG rHome
+ REGISTER OBJ rHome;
- rHome = __BlockInstPtr(aBlock)->b_home;
- if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
+ rHome = __BlockInstPtr(aBlock)->b_home;
+ if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
#endif
- {
+ {
for (; index < nIndex; index++) {
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
}
RETURN (self);
- }
+ }
}
}
- /*
- * sorry, must check code-pointer in the loop
- * it could be recompiled or flushed
- */
+ /*
+ * sorry, must check code-pointer in the loop
+ * it could be recompiled or flushed
+ */
# undef BLOCK_ARG
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
@@ -583,15 +583,15 @@
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home)
#endif
- for (; index < nIndex; index++) {
+ for (; index < nIndex; index++) {
REGISTER OBJFUNC codeVal;
if (InterruptPending != nil) __interruptL(@line);
if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
} else {
- if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
+ if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
/*
* arg is a compiled block with bytecode -
* directly call interpreter without going through Block>>value
@@ -601,32 +601,32 @@
#else
__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
#endif
- } else {
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
+ } else {
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
}
}
-# undef BLOCK_ARG
-# undef IBLOCK_ARG
+# undef BLOCK_ARG
+# undef IBLOCK_ARG
- RETURN (self );
- }
+ RETURN (self );
+ }
- /*
- * not a block - send it #value:
- */
- for (; index < nIndex; index++) {
- if (InterruptPending != nil) __interruptL(@line);
+ /*
+ * not a block - send it #value:
+ */
+ for (; index < nIndex; index++) {
+ if (InterruptPending != nil) __interruptL(@line);
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
RETURN ( self );
}
}
@@ -673,37 +673,37 @@
if (__isBlockLike(aBlock)
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) {
- {
- /*
- * the most common case: a static compiled block, with home on the stack ...
- */
- REGISTER OBJFUNC codeVal;
+ {
+ /*
+ * the most common case: a static compiled block, with home on the stack ...
+ */
+ REGISTER OBJFUNC codeVal;
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
#else
# define BLOCK_ARG rHome
- REGISTER OBJ rHome;
+ REGISTER OBJ rHome;
- rHome = __BlockInstPtr(aBlock)->b_home;
- if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
+ rHome = __BlockInstPtr(aBlock)->b_home;
+ if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
#endif
- {
+ {
for (index=indexLow; index <= indexHigh; index++) {
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
- }
- RETURN (self);
- }
- }
- }
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ }
+ RETURN (self);
+ }
+ }
+ }
- /*
- * sorry, must check code-pointer in the loop
- * it could be recompiled or flushed
- */
+ /*
+ * sorry, must check code-pointer in the loop
+ * it could be recompiled or flushed
+ */
# undef BLOCK_ARG
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
@@ -714,50 +714,50 @@
#endif
for (index=indexLow; index <= indexHigh; index++) {
- REGISTER OBJFUNC codeVal;
+ REGISTER OBJFUNC codeVal;
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
- } else {
- if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
- /*
- * arg is a compiled block with bytecode -
- * directly call interpreter without going through Block>>value
- */
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ } else {
+ if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
+ /*
+ * arg is a compiled block with bytecode -
+ * directly call interpreter without going through Block>>value
+ */
#ifdef PASS_ARG_POINTER
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
#else
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
#endif
- } else {
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
- }
- }
+ } else {
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
+ }
+ }
-# undef BLOCK_ARG
-# undef IBLOCK_ARG
+# undef BLOCK_ARG
+# undef IBLOCK_ARG
- RETURN (self );
- }
+ RETURN (self );
+ }
- /*
- * not a block - send it #value:
- */
+ /*
+ * not a block - send it #value:
+ */
for (index=indexLow; index <= indexHigh; index++) {
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
- RETURN ( self );
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
+ RETURN ( self );
}
}
%}.
@@ -789,37 +789,37 @@
if (__isBlockLike(aBlock)
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) {
- {
- /*
- * the most common case: a static compiled block, with home on the stack ...
- */
- REGISTER OBJFUNC codeVal;
+ {
+ /*
+ * the most common case: a static compiled block, with home on the stack ...
+ */
+ REGISTER OBJFUNC codeVal;
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
#else
# define BLOCK_ARG rHome
- REGISTER OBJ rHome;
+ REGISTER OBJ rHome;
- rHome = __BlockInstPtr(aBlock)->b_home;
- if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
+ rHome = __BlockInstPtr(aBlock)->b_home;
+ if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
#endif
- {
- for (index=indexHigh; index >= indexLow; index--) {
- if (InterruptPending != nil) __interruptL(@line);
+ {
+ for (index=indexHigh; index >= indexLow; index--) {
+ if (InterruptPending != nil) __interruptL(@line);
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
- }
- RETURN (self);
- }
- }
- }
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ }
+ RETURN (self);
+ }
+ }
+ }
- /*
- * sorry, must check code-pointer in the loop
- * it could be recompiled or flushed
- */
+ /*
+ * sorry, must check code-pointer in the loop
+ * it could be recompiled or flushed
+ */
# undef BLOCK_ARG
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
@@ -830,51 +830,51 @@
#endif
for (index=indexHigh; index >= indexLow; index--) {
- REGISTER OBJFUNC codeVal;
+ REGISTER OBJFUNC codeVal;
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
- } else {
- if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
- /*
- * arg is a compiled block with bytecode -
- * directly call interpreter without going through Block>>value
- */
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ } else {
+ if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
+ /*
+ * arg is a compiled block with bytecode -
+ * directly call interpreter without going through Block>>value
+ */
#ifdef PASS_ARG_POINTER
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
#else
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
#endif
- } else {
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
- }
- }
+ } else {
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
+ }
+ }
-# undef BLOCK_ARG
-# undef IBLOCK_ARG
+# undef BLOCK_ARG
+# undef IBLOCK_ARG
- RETURN (self );
- }
+ RETURN (self );
+ }
- /*
- * not a block - send it #value:
- */
+ /*
+ * not a block - send it #value:
+ */
for (index=indexHigh; index >= indexLow; index--) {
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
- RETURN ( self );
- }
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
+ RETURN ( self );
+ }
}
%}.
^ super from:start to:stop reverseDo:aBlock
@@ -899,46 +899,46 @@
myClass = __qClass(self);
if (((INT)( __ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY)) {
- index = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ index = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- nIndex = index + __intVal(sz);
+ actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ nIndex = index + __intVal(sz);
- if (nIndex <= actualSize) {
- if (__isBlockLike(aBlock)
- && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) {
- {
- /*
- * the most common case: a static compiled block, with home on the stack ...
- */
- REGISTER OBJFUNC codeVal;
+ if (nIndex <= actualSize) {
+ if (__isBlockLike(aBlock)
+ && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) {
+ {
+ /*
+ * the most common case: a static compiled block, with home on the stack ...
+ */
+ REGISTER OBJFUNC codeVal;
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
#else
# define BLOCK_ARG rHome
- REGISTER OBJ rHome;
+ REGISTER OBJ rHome;
- rHome = __BlockInstPtr(aBlock)->b_home;
- if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
+ rHome = __BlockInstPtr(aBlock)->b_home;
+ if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
#endif
- {
- while (index < nIndex) {
+ {
+ while (index < nIndex) {
index++;
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
- }
- RETURN (self);
- }
- }
- }
+ (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
+ }
+ RETURN (self);
+ }
+ }
+ }
- /*
- * sorry, must check code-pointer in the loop
- * it could be recompiled or flushed
- */
+ /*
+ * sorry, must check code-pointer in the loop
+ * it could be recompiled or flushed
+ */
# undef BLOCK_ARG
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
@@ -948,20 +948,20 @@
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home)
#endif
- while (index < nIndex) {
- REGISTER OBJFUNC codeVal;
+ while (index < nIndex) {
+ REGISTER OBJFUNC codeVal;
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
index++;
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
- (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
- } else {
- if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
- /*
- * arg is a compiled block with bytecode -
- * directly call interpreter without going through Block>>value
- */
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
+ } else {
+ if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
+ /*
+ * arg is a compiled block with bytecode -
+ * directly call interpreter without going through Block>>value
+ */
#ifdef PASS_ARG_POINTER
{
OBJ t[2];
@@ -969,41 +969,41 @@
t[0] = __MKSMALLINT(index);
t[1] = __InstPtr(self)->i_instvars[index-1];
- __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t);
+ __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t);
}
#else
- __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
+ __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
#endif
- } else {
- (*val2.ilc_func)(aBlock,
- @symbol(value:value:),
- nil, &val2,
+ } else {
+ (*val2.ilc_func)(aBlock,
+ @symbol(value:value:),
+ nil, &val2,
__MKSMALLINT(index),
- __InstPtr(self)->i_instvars[index-1]);
- }
- }
- }
+ __InstPtr(self)->i_instvars[index-1]);
+ }
+ }
+ }
-# undef BLOCK_ARG
-# undef IBLOCK_ARG
+# undef BLOCK_ARG
+# undef IBLOCK_ARG
- RETURN (self );
- }
+ RETURN (self );
+ }
- /*
- * not a block - send it #value:
- */
- while (index < nIndex) {
- if (InterruptPending != nil) __interruptL(@line);
+ /*
+ * not a block - send it #value:
+ */
+ while (index < nIndex) {
+ if (InterruptPending != nil) __interruptL(@line);
index++;
- (*val2.ilc_func)(aBlock,
- @symbol(value:value:),
- nil, &val2,
+ (*val2.ilc_func)(aBlock,
+ @symbol(value:value:),
+ nil, &val2,
__MKSMALLINT(index),
- __InstPtr(self)->i_instvars[index-1]);
- }
- RETURN ( self );
+ __InstPtr(self)->i_instvars[index-1]);
+ }
+ RETURN ( self );
}
}
%}.
@@ -1028,44 +1028,44 @@
myClass = __qClass(self);
if (((INT)( __ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY)) {
- endIndex = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- nIndex = endIndex + __intVal(sz);
+ endIndex = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ nIndex = endIndex + __intVal(sz);
- if (nIndex <= actualSize) {
- if (__isBlockLike(aBlock)
- && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) {
- {
- /*
- * the most common case: a static compiled block, with home on the stack ...
- */
- REGISTER OBJFUNC codeVal;
+ if (nIndex <= actualSize) {
+ if (__isBlockLike(aBlock)
+ && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) {
+ {
+ /*
+ * the most common case: a static compiled block, with home on the stack ...
+ */
+ REGISTER OBJFUNC codeVal;
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
#else
# define BLOCK_ARG rHome
- REGISTER OBJ rHome;
+ REGISTER OBJ rHome;
- rHome = __BlockInstPtr(aBlock)->b_home;
- if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
+ rHome = __BlockInstPtr(aBlock)->b_home;
+ if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
#endif
- {
- for (index=nIndex-1; index >= endIndex; index--) {
- if (InterruptPending != nil) __interruptL(@line);
+ {
+ for (index=nIndex-1; index >= endIndex; index--) {
+ if (InterruptPending != nil) __interruptL(@line);
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
- }
- RETURN (self);
- }
- }
- }
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ }
+ RETURN (self);
+ }
+ }
+ }
- /*
- * sorry, must check code-pointer in the loop
- * it could be recompiled or flushed
- */
+ /*
+ * sorry, must check code-pointer in the loop
+ * it could be recompiled or flushed
+ */
# undef BLOCK_ARG
#ifdef NEW_BLOCK_CALL
# define BLOCK_ARG aBlock
@@ -1075,51 +1075,51 @@
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home)
#endif
- for (index=nIndex-1; index >= endIndex; index--) {
- REGISTER OBJFUNC codeVal;
+ for (index=nIndex-1; index >= endIndex; index--) {
+ REGISTER OBJFUNC codeVal;
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
- (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
- } else {
- if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
- /*
- * arg is a compiled block with bytecode -
- * directly call interpreter without going through Block>>value
- */
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
+ } else {
+ if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
+ /*
+ * arg is a compiled block with bytecode -
+ * directly call interpreter without going through Block>>value
+ */
#ifdef PASS_ARG_POINTER
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
#else
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
#endif
- } else {
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
- }
- }
+ } else {
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
+ }
+ }
-# undef BLOCK_ARG
-# undef IBLOCK_ARG
+# undef BLOCK_ARG
+# undef IBLOCK_ARG
- RETURN (self );
- }
+ RETURN (self );
+ }
- /*
- * not a block - send it #value:
- */
+ /*
+ * not a block - send it #value:
+ */
for (index=nIndex-1; index >= endIndex; index--) {
- if (InterruptPending != nil) __interruptL(@line);
+ if (InterruptPending != nil) __interruptL(@line);
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- }
- RETURN ( self );
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ }
+ RETURN ( self );
}
}
%}.
@@ -1135,9 +1135,9 @@
as well."
self do: [:el |
- el isArray
- ifTrue: [el traverse: aBlock]
- ifFalse: [aBlock value: el]]
+ el isArray
+ ifTrue: [el traverse: aBlock]
+ ifFalse: [aBlock value: el]]
"
example: flattening an Array:
@@ -1152,7 +1152,7 @@
example: deep search
#(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el |
- el == 10 ifTrue:[Transcript showCR:'found']
+ el == 10 ifTrue:[Transcript showCR:'found']
]
"
@@ -1245,83 +1245,83 @@
&& __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;
- /*
- * 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 {
+ /*
+ * 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) {
@@ -1337,40 +1337,40 @@
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 >= 4) {
- 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);
- count -= 4; src += 4; dst += 4;
- }
+ while (count >= 4) {
+ 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);
+ count -= 4; src += 4; dst += 4;
+ }
#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
@@ -1386,23 +1386,23 @@
|s sz|
(self isLiteral) ifTrue:[
- s := WriteStream on:String new.
- s writeLimit:5000.
+ s := WriteStream on:String new.
+ s writeLimit:5000.
- WriteStream writeErrorSignal handle:[:ex |
- s writeLimit:nil.
- s nextPutAll:' ...'
- ] do:[
- s nextPutAll:'#('.
- sz := self size.
- self keysAndValuesDo:[:idx :element |
- s nextPutAll:element displayString.
- idx ~~ sz ifTrue:[s space]
- ].
- ].
- s writeLimit:nil.
- s nextPutAll:')'.
- ^ s contents
+ WriteStream writeErrorSignal handle:[:ex |
+ s writeLimit:nil.
+ s nextPutAll:' ...'
+ ] do:[
+ s nextPutAll:'#('.
+ sz := self size.
+ self keysAndValuesDo:[:idx :element |
+ s nextPutAll:element displayString.
+ idx ~~ sz ifTrue:[s space]
+ ].
+ ].
+ s writeLimit:nil.
+ s nextPutAll:')'.
+ ^ s contents
].
^ super displayString
@@ -1421,11 +1421,11 @@
Redefined to output a somewhat more user friendly string."
self isLiteral ifTrue:[
- aStream nextPutAll:'#('.
- self do:[:element | element storeOn:aStream. aStream space].
- aStream nextPutAll:')'
+ aStream nextPutAll:'#('.
+ self do:[:element | element storeOn:aStream. aStream space].
+ aStream nextPutAll:')'
] ifFalse:[
- super storeOn:aStream
+ super storeOn:aStream
]
"
@@ -1460,7 +1460,7 @@
"/
thisContext isRecursive ifTrue:[^ false].
self do:[:element |
- element isLiteral ifFalse:[^ false]
+ element isLiteral ifFalse:[^ false]
].
^ true
@@ -1472,10 +1472,10 @@
receiver referes to aLiteral"
self do: [ :el |
- el == aLiteral ifTrue:[^true].
- el class == Array ifTrue:[
- (el refersToLiteral: aLiteral) ifTrue: [^true]
- ]
+ el == aLiteral ifTrue:[^true].
+ el class == Array ifTrue:[
+ (el refersToLiteral: aLiteral) ifTrue: [^true]
+ ]
].
^ false
@@ -1552,56 +1552,56 @@
int nInsts;
if (__isSmallInteger(start)) {
- index = __intVal(start) - 1;
- if (index >= 0) {
- nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
- index += nInsts;
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- el = anElement;
- op = & (__InstPtr(self)->i_instvars[index]);
+ index = __intVal(start) - 1;
+ if (index >= 0) {
+ nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
+ index += nInsts;
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ el = anElement;
+ op = & (__InstPtr(self)->i_instvars[index]);
- /*
- * dont argue about those gotos below - they speed up that thing by 30%;
- * its better to exit the loops below with a goto,
- * since the generated code will then be:
- * compare
- * branch-on-equal found
- *
- * otherwise, we get:
- * compare
- * branch-on-not-equal skipLabel
- * move-to-return-register true
- * goto return-label
- * skipLabel
- *
- * therefore, WITH the so-much-blamed goto, we only branch
- * when found; without the goto, we branch always.
- * Pipelined CPUs do usually not like taken branches.
- */
+ /*
+ * dont argue about those gotos below - they speed up that thing by 30%;
+ * its better to exit the loops below with a goto,
+ * since the generated code will then be:
+ * compare
+ * branch-on-equal found
+ *
+ * otherwise, we get:
+ * compare
+ * branch-on-not-equal skipLabel
+ * move-to-return-register true
+ * goto return-label
+ * skipLabel
+ *
+ * therefore, WITH the so-much-blamed goto, we only branch
+ * when found; without the goto, we branch always.
+ * Pipelined CPUs do usually not like taken branches.
+ */
#if defined(UNROLL_LOOPS)
- {
- unsigned int i8;
+ {
+ unsigned int i8;
- while ((i8 = index + 8) < nIndex) {
- if (op[0] == el) goto found1;
- if (op[1] == el) goto found2;
- if (op[2] == el) goto found3;
- if (op[3] == el) goto found4;
- if (op[4] == el) goto found5;
- if (op[5] == el) goto found6;
- if (op[6] == el) goto found7;
- if (op[7] == el) goto found8;
- index = i8;
- op += 8;
- }
- }
+ while ((i8 = index + 8) < nIndex) {
+ if (op[0] == el) goto found1;
+ if (op[1] == el) goto found2;
+ if (op[2] == el) goto found3;
+ if (op[3] == el) goto found4;
+ if (op[4] == el) goto found5;
+ if (op[5] == el) goto found6;
+ if (op[6] == el) goto found7;
+ if (op[7] == el) goto found8;
+ index = i8;
+ op += 8;
+ }
+ }
#endif
- while (index++ < nIndex) {
- if (*op++ == el) goto found0;
- }
- }
- RETURN ( __MKSMALLINT(0) );
+ while (index++ < nIndex) {
+ if (*op++ == el) goto found0;
+ }
+ }
+ RETURN ( __MKSMALLINT(0) );
found0:
RETURN ( __MKSMALLINT(index - nInsts) );
@@ -1644,59 +1644,59 @@
int nInsts;
if (__bothSmallInteger(start, stop)) {
- index = __intVal(start) - 1;
- if (index >= 0) {
- nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
- index += nInsts;
- lastIndex = nInsts + __intVal(stop);
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- if (nIndex < lastIndex) {
- lastIndex = nIndex;
- }
- el = anElement;
- op = & (__InstPtr(self)->i_instvars[index]);
+ index = __intVal(start) - 1;
+ if (index >= 0) {
+ nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
+ index += nInsts;
+ lastIndex = nInsts + __intVal(stop);
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ if (nIndex < lastIndex) {
+ lastIndex = nIndex;
+ }
+ el = anElement;
+ op = & (__InstPtr(self)->i_instvars[index]);
#if defined(UNROLL_LOOPS)
- {
- unsigned int i8;
+ {
+ unsigned int i8;
- while ((i8 = index + 8) < lastIndex) {
- if (op[0] == el) goto found1;
- if (op[1] == el) goto found2;
- if (op[2] == el) goto found3;
- if (op[3] == el) goto found4;
- if (op[4] == el) goto found5;
- if (op[5] == el) goto found6;
- if (op[6] == el) goto found7;
- if (op[7] == el) goto found8;
- index = i8;
- op += 8;
- }
- }
+ while ((i8 = index + 8) < lastIndex) {
+ if (op[0] == el) goto found1;
+ if (op[1] == el) goto found2;
+ if (op[2] == el) goto found3;
+ if (op[3] == el) goto found4;
+ if (op[4] == el) goto found5;
+ if (op[5] == el) goto found6;
+ if (op[6] == el) goto found7;
+ if (op[7] == el) goto found8;
+ index = i8;
+ op += 8;
+ }
+ }
#endif
- while (index++ < lastIndex) {
- if (*op++ == el) goto found0;
- }
- }
- RETURN ( __MKSMALLINT(0) );
+ while (index++ < lastIndex) {
+ if (*op++ == el) goto found0;
+ }
+ }
+ RETURN ( __MKSMALLINT(0) );
found0:
- RETURN ( __MKSMALLINT(index - nInsts) );
+ RETURN ( __MKSMALLINT(index - nInsts) );
found1:
- RETURN ( __MKSMALLINT(index + 1 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 1 - nInsts) );
found2:
- RETURN ( __MKSMALLINT(index + 2 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 2 - nInsts) );
found3:
- RETURN ( __MKSMALLINT(index + 3 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 3 - nInsts) );
found4:
- RETURN ( __MKSMALLINT(index + 4 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 4 - nInsts) );
found5:
- RETURN ( __MKSMALLINT(index + 5 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 5 - nInsts) );
found6:
- RETURN ( __MKSMALLINT(index + 6 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 6 - nInsts) );
found7:
- RETURN ( __MKSMALLINT(index + 7 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 7 - nInsts) );
found8:
- RETURN ( __MKSMALLINT(index + 8 - nInsts) );
+ RETURN ( __MKSMALLINT(index + 8 - nInsts) );
}
%}.
@@ -1831,81 +1831,81 @@
if ( (((INT)( __ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY))
&& __isSmallInteger(start)
) {
- index = __intVal(start) - 1;
- if (index >= 0) {
- nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- index += nInsts;
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- if (anElement != nil) {
+ index = __intVal(start) - 1;
+ if (index >= 0) {
+ nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ index += nInsts;
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ if (anElement != 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(anElement)) {
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (__isNonNilObject(element)) {
- if (element == anElement) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- if (__qClass(element) == @global(String)) {
- if (strcmp(__stringVal(anElement), __stringVal(element)) == 0) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- } else {
- if ((*eq.ilc_func)(anElement, @symbol(=), nil,&eq, element) == true) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- }
- RETURN (__MKSMALLINT(0));
- }
+ if (__isString(anElement)) {
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (__isNonNilObject(element)) {
+ if (element == anElement) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ if (__qClass(element) == @global(String)) {
+ if (strcmp(__stringVal(anElement), __stringVal(element)) == 0) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ } else {
+ if ((*eq.ilc_func)(anElement, @symbol(=), nil,&eq, element) == true) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
+ }
#endif
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element != nil) {
- if ((element == anElement)
- || ((*eq.ilc_func)(anElement,
- @symbol(=),
- nil,&eq,
- element) == true)) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- } else {
- /*
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element != nil) {
+ if ((element == anElement)
+ || ((*eq.ilc_func)(anElement,
+ @symbol(=),
+ nil,&eq,
+ element) == true)) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ } else {
+ /*
* search for nil - do an identity-search
*/
#if defined(UNROLL_LOOPS)
- {
- unsigned int i8;
+ {
+ unsigned int i8;
- while ((i8 = index + 8) < nIndex) {
- if (__InstPtr(self)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
- if (__InstPtr(self)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
- if (__InstPtr(self)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
- if (__InstPtr(self)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
- if (__InstPtr(self)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
- if (__InstPtr(self)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
- if (__InstPtr(self)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
- if (__InstPtr(self)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
- index = i8;
- }
- }
+ while ((i8 = index + 8) < nIndex) {
+ if (__InstPtr(self)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
+ if (__InstPtr(self)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
+ if (__InstPtr(self)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
+ if (__InstPtr(self)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
+ if (__InstPtr(self)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
+ if (__InstPtr(self)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
+ if (__InstPtr(self)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
+ if (__InstPtr(self)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
+ index = i8;
+ }
+ }
#endif
- while (index < nIndex) {
- if (__InstPtr(self)->i_instvars[index++] == nil) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- }
- RETURN (__MKSMALLINT(0));
+ while (index < nIndex) {
+ if (__InstPtr(self)->i_instvars[index++] == nil) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
}
%}.
^ super indexOf:anElement startingAt:start
@@ -1928,110 +1928,110 @@
(((INT)( __ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY))
&& __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;
+ }
- if (anElement != nil) {
+ if (anElement != nil) {
/*
* special kludge to search for a string;
* this is so common, that its worth a special case
*/
#ifdef SPECIAL_STRING_OPT
- if (__isString(anElement)) {
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (__isNonNilObject(element)) {
- if (element == anElement) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- if (__qClass(element) == @global(String)) {
- if (strcmp(__stringVal(anElement), __stringVal(element)) == 0) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- } else {
- if ((*eq.ilc_func)(anElement, @symbol(=), nil,&eq, element) == true) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- }
- RETURN (__MKSMALLINT(0));
- }
+ if (__isString(anElement)) {
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (__isNonNilObject(element)) {
+ if (element == anElement) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ if (__qClass(element) == @global(String)) {
+ if (strcmp(__stringVal(anElement), __stringVal(element)) == 0) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ } else {
+ if ((*eq.ilc_func)(anElement, @symbol(=), nil,&eq, element) == true) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
+ }
#endif
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element != nil) {
- if ((element == anElement)
- || ((*eq.ilc_func)(anElement,
- @symbol(=),
- nil,&eq,
- element) == true)) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- } else {
- if (__isSmallInteger(anElement)) {
- /* search for a small number */
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element == anElement) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- if (!__isSmallInteger(element)) {
- if ((*eq.ilc_func)(anElement,
- @symbol(=),
- nil,&eq,
- element) == true) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- } else {
- /*
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element != nil) {
+ if ((element == anElement)
+ || ((*eq.ilc_func)(anElement,
+ @symbol(=),
+ nil,&eq,
+ element) == true)) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ } else {
+ if (__isSmallInteger(anElement)) {
+ /* search for a small number */
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element == anElement) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ if (!__isSmallInteger(element)) {
+ if ((*eq.ilc_func)(anElement,
+ @symbol(=),
+ nil,&eq,
+ element) == true) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ } else {
+ /*
* search for nil - do an identity-search
*/
#if defined(UNROLL_LOOPS)
- {
- unsigned int i8;
+ {
+ unsigned int i8;
- while ((i8 = index + 8) < lastIndex) {
- if (__InstPtr(self)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
- if (__InstPtr(self)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
- if (__InstPtr(self)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
- if (__InstPtr(self)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
- if (__InstPtr(self)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
- if (__InstPtr(self)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
- if (__InstPtr(self)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
- if (__InstPtr(self)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
- index = i8;
- }
- }
+ while ((i8 = index + 8) < lastIndex) {
+ if (__InstPtr(self)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); }
+ if (__InstPtr(self)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); }
+ if (__InstPtr(self)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); }
+ if (__InstPtr(self)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); }
+ if (__InstPtr(self)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); }
+ if (__InstPtr(self)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); }
+ if (__InstPtr(self)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); }
+ if (__InstPtr(self)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); }
+ index = i8;
+ }
+ }
#endif
- while (index < lastIndex) {
- if (__InstPtr(self)->i_instvars[index++] == nil) {
- RETURN ( __MKSMALLINT(index - nInsts) );
- }
- }
- }
- }
- }
- RETURN (__MKSMALLINT(0));
+ while (index < lastIndex) {
+ if (__InstPtr(self)->i_instvars[index++] == nil) {
+ RETURN ( __MKSMALLINT(index - nInsts) );
+ }
+ }
+ }
+ }
+ }
+ RETURN (__MKSMALLINT(0));
}
%}.
- ^ super indexOf:anElement startingAt:start
+ ^ super indexOf:anElement startingAt:start endingAt:stop
! !
!Array class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.81 1997-01-20 16:12:35 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.82 1997-01-20 19:25:15 cg Exp $'
! !