Array.st
branchjv
changeset 18011 deb0c3355881
parent 17976 50c2416f962a
parent 14657 6610eb2df25c
child 18017 7fef9e17913f
--- a/Array.st	Thu Dec 20 11:48:59 2012 +0000
+++ b/Array.st	Sat Jan 19 01:30:00 2013 +0000
@@ -36,24 +36,24 @@
 
 documentation
 "
-    Instances of Array store general objects; the arrays size is fixed, 
-    therefore add:/remove: are not allowed. 
-    (actually, #add: is implemented for compatibility with smalltalks which 
+    Instances of Array store general objects; the arrays size is fixed,
+    therefore add:/remove: are not allowed.
+    (actually, #add: is implemented for compatibility with smalltalks which
      provide it, but it is very slow and outputs an annoying warning message ...)
 
     Access to the individual elements is via an integer index,
     using the well-known access messages #at: and #at:put:.
 
     Since Arrays are used very often in the system (either directly or a data-container
-    of more complex collection classes), some methods have been tuned by reimplementing 
-    them as primitives. Also, the compiler inline-codes some operations 
+    of more complex collection classes), some methods have been tuned by reimplementing
+    them as primitives. Also, the compiler inline-codes some operations
     (especially: the above accessing messages).
 
-    Notice that Array is a built-in class 
-    (i.e. the VM knows about its representation). 
-    Therefore it is NOT possible to add named instance variables or change 
-    Arrays inheritance. 
-    However, subclassing is allowed of course 
+    Notice that Array is a built-in class
+    (i.e. the VM knows about its representation).
+    Therefore it is NOT possible to add named instance variables or change
+    Arrays inheritance.
+    However, subclassing is allowed of course
     - even with added named instance variables.
 
     Literal arrays (i.e. array-constants) are entered in source as:
@@ -120,27 +120,20 @@
 		__InstPtr(newobj)->o_class = self;
 		__qSTORE(newobj, self);
 
-#if defined(memset4) && defined(FAST_ARRAY_MEMSET4)
+#if (POINTER_SIZE == 4) && defined(memset4) && defined(FAST_ARRAY_MEMSET4)
 		memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
 #else
 # if !defined(NEGATIVE_ADDRESSES)
 		/*
 		 * knowing that nil is 0
 		 */
-#ifdef XXmips
-# undef FAST_ARRAY_MEMSET_DOUBLES_UNROLLED
-# undef FAST_ARRAY_MEMSET_LONGLONG_UNROLLED
-/* seems to be slightly faster */
-# define FAST_ARRAY_MEMSET
-#endif
+#  ifdef __sparc__
+#   define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED
+#  endif
 
-#ifdef __sparc__
-# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED
-#endif
-
-#ifdef __VMS__
-# define FAST_ARRAY_MEMSET_LONGLONG_UNROLLED
-#endif
+#  ifdef __VMS__
+#   define FAST_ARRAY_MEMSET_LONGLONG_UNROLLED
+#  endif
 
 #  if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED)
 		op = __InstPtr(newobj)->i_instvars;
@@ -161,7 +154,7 @@
 		    nInstVars--;
 		}
 #  else
-#   if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED)
+#   if (POINTER_SIZE == 4) && defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED)
 #    ifdef INT64
 #     define LONGLONG INT64
 #    else
@@ -190,7 +183,7 @@
 		memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
 #    else
 		op = __InstPtr(newobj)->i_instvars;
-#     if defined(INT64)
+#     if (POINTER_SIZE == 4) && defined(INT64)
 		while (nInstVars > 1) {
 		    *((INT64 *)op) = 0;
 		    nInstVars -= 2;
@@ -248,8 +241,8 @@
     "
      memory allocation failed.
      When we arrive here, there was no memory, even after
-     a garbage collect. 
-     This means, that the VM wanted to get some more memory from the 
+     a garbage collect.
+     This means, that the VM wanted to get some more memory from the
      Operatingsystem, which was not kind enough to give it.
      Bad luck - you should increase the swap space on your machine.
     "
@@ -283,7 +276,7 @@
 at:index
     "return the indexed instance variable with index, anInteger.
      Reimplemented here to avoid the additional at:->basicAt: send
-     (which we can do here, since when arriving here, #at: is obviously not 
+     (which we can do here, since when arriving here, #at: is obviously not
       redefined in a subclass).
      This method is the same as basicAt:."
 
@@ -450,7 +443,7 @@
 
 copyWith:something
     "return a new collection containing the receivers elements
-     and the single new element, newElement. 
+     and the single new element, newElement.
      This is different from concatentation, which expects another collection
      as argument, but equivalent to copy-and-addLast.
      Reimplemented for speed if receiver is an Array.
@@ -465,59 +458,59 @@
     REGISTER int spc;
 
     if (__qClass(self) == Array) {
-        sz = __qSize(self) + sizeof(OBJ);
-        __PROTECT2__(something, self);
-        __qAlignedNew(nObj, sz);        /* OBJECT ALLOCATION */
-        __UNPROTECT2__(self, something);
+	sz = __qSize(self) + sizeof(OBJ);
+	__PROTECT2__(something, self);
+	__qAlignedNew(nObj, sz);        /* OBJECT ALLOCATION */
+	__UNPROTECT2__(self, something);
 
-        if (nObj) {
-            __InstPtr(nObj)->o_class = Array;
-            __qSTORE(nObj, Array);
+	if (nObj) {
+	    __InstPtr(nObj)->o_class = Array;
+	    __qSTORE(nObj, Array);
 
-            nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
-            /* 
-             * sorry: 
-             *   cannot use bcopy, since we must take care of stores ... 
-             *   could check for: notRemembered + inOld + notLifoRem
-             *                  + not incrGCRunning
-             * but: copyWith is not heavily used by real programmers ...
-             */
-            spc = __qSpace(nObj);
-            srcP = __arrayVal(self);
-            dstP = __arrayVal(nObj);
+	    nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
+	    /*
+	     * sorry:
+	     *   cannot use bcopy, since we must take care of stores ...
+	     *   could check for: notRemembered + inOld + notLifoRem
+	     *                  + not incrGCRunning
+	     * but: copyWith is not heavily used by real programmers ...
+	     */
+	    spc = __qSpace(nObj);
+	    srcP = __arrayVal(self);
+	    dstP = __arrayVal(nObj);
 
 #ifdef __UNROLL_LOOPS__
-            while (nIndex >= 4) {
-                OBJ element;
+	    while (nIndex >= 4) {
+		OBJ element;
 
-                element = srcP[0];
-                dstP[0] = element;
-                __STORE_SPC(nObj, element, spc);
-                element = srcP[1];
-                dstP[1] = element;
-                __STORE_SPC(nObj, element, spc);
-                element = srcP[2];
-                dstP[2] = element;
-                __STORE_SPC(nObj, element, spc);
-                element = srcP[3];
-                dstP[3] = element;
-                __STORE_SPC(nObj, element, spc);
-                srcP += 4;
-                dstP += 4;
-                nIndex -= 4;
-            }
+		element = srcP[0];
+		dstP[0] = element;
+		__STORE_SPC(nObj, element, spc);
+		element = srcP[1];
+		dstP[1] = element;
+		__STORE_SPC(nObj, element, spc);
+		element = srcP[2];
+		dstP[2] = element;
+		__STORE_SPC(nObj, element, spc);
+		element = srcP[3];
+		dstP[3] = element;
+		__STORE_SPC(nObj, element, spc);
+		srcP += 4;
+		dstP += 4;
+		nIndex -= 4;
+	    }
 #endif
-            while (nIndex--) {
-                OBJ element;
+	    while (nIndex--) {
+		OBJ element;
 
-                element = *srcP++;
-                *dstP++ = element;
-                __STORE_SPC(nObj, element, spc);
-            }
-            *dstP = something;
-            __STORE_SPC(nObj, something, spc);
-            RETURN ( nObj );
-        }
+		element = *srcP++;
+		*dstP++ = element;
+		__STORE_SPC(nObj, element, spc);
+	    }
+	    *dstP = something;
+	    __STORE_SPC(nObj, something, spc);
+	    RETURN ( nObj );
+	}
     }
 %}.
     ^ super copyWith:something
@@ -534,11 +527,11 @@
 
     stop := self size.
     1 to:stop do:[:idx |
-        |each|
-        each := self at:idx.
-        each notNil ifTrue:[
-            aCollection add:each.
-        ].
+	|each|
+	each := self at:idx.
+	each notNil ifTrue:[
+	    aCollection add:each.
+	].
     ].
     ^ aCollection
 
@@ -556,7 +549,7 @@
 
     stop := self size.
     1 to:stop do:[:idx |
-        aCollection add:(self at:idx)
+	aCollection add:(self at:idx)
     ].
     ^ aCollection
 !
@@ -746,9 +739,9 @@
 			__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
 #endif
 		    } else {
-			(*val.ilc_func)(aBlock, 
-					    @symbol(value:), 
-					    nil, &val, 
+			(*val.ilc_func)(aBlock,
+					    @symbol(value:),
+					    nil, &val,
 					    __InstPtr(self)->i_instvars[index]);
 		    }
 		}
@@ -765,15 +758,15 @@
 	 */
 	for (; index < nIndex; index++) {
 	    if (InterruptPending != nil) __interruptL(@line);
-
-	    (*val.ilc_func)(aBlock, 
-				@symbol(value:), 
-				nil, &val, 
+	    // console_printf("el%d -> %"_lx_"\n", index, (long)(__InstPtr(self)->i_instvars[index]));
+	    (*val.ilc_func)(aBlock,
+				@symbol(value:),
+				nil, &val,
 				__InstPtr(self)->i_instvars[index]);
 	}
 	RETURN ( self );
     }
-    /* 
+    /*
      * I am something, not handled here
      */
 %}.
@@ -1024,9 +1017,9 @@
 			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, el);
 #endif
 			} else {
-			    (*val.ilc_func)(aBlock, 
-					    @symbol(value:), 
-					    nil, &val, 
+			    (*val.ilc_func)(aBlock,
+					    @symbol(value:),
+					    nil, &val,
 					    el);
 			}
 		    }
@@ -1046,9 +1039,9 @@
 	    while (n > 0) {
 		if (InterruptPending != nil) __interruptL(@line);
 
-		(*val.ilc_func)(aBlock, 
-				@symbol(value:), 
-				nil, &val, 
+		(*val.ilc_func)(aBlock,
+				@symbol(value:),
+				nil, &val,
 				__InstPtr(self)->i_instvars[index]);
 		n--;
 		index++;
@@ -1113,9 +1106,9 @@
 			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
 #endif
 			} else {
-			    (*val.ilc_func)(aBlock, 
-					    @symbol(value:), 
-					    nil, &val, 
+			    (*val.ilc_func)(aBlock,
+					    @symbol(value:),
+					    nil, &val,
 					    __InstPtr(self)->i_instvars[index]);
 			}
 		    }
@@ -1133,9 +1126,9 @@
 	    for (index=indexHigh; index >= indexLow; index--) {
 		if (InterruptPending != nil) __interruptL(@line);
 
-		(*val.ilc_func)(aBlock, 
-				@symbol(value:), 
-				nil, &val, 
+		(*val.ilc_func)(aBlock,
+				@symbol(value:),
+				nil, &val,
 				__InstPtr(self)->i_instvars[index]);
 	    }
 	    RETURN ( self );
@@ -1202,7 +1195,7 @@
 			    RETURN (self);
 
 		interruptX:
-			    __interruptL(@line); 
+			    __interruptL(@line);
 			    el = __InstPtr(self)->i_instvars[index];
 			    goto continueX;
 			}
@@ -1251,9 +1244,9 @@
 			    __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __mkSmallInteger(index), el);
 #endif
 			} else {
-			    (*val2.ilc_func)(aBlock, 
-						@symbol(value:value:), 
-						nil, &val2, 
+			    (*val2.ilc_func)(aBlock,
+						@symbol(value:value:),
+						nil, &val2,
 						__mkSmallInteger(index),
 						el);
 			}
@@ -1276,9 +1269,9 @@
 
 		el = __InstPtr(self)->i_instvars[index];
 		index++;
-		(*val2.ilc_func)(aBlock, 
-				    @symbol(value:value:), 
-				    nil, &val2, 
+		(*val2.ilc_func)(aBlock,
+				    @symbol(value:value:),
+				    nil, &val2,
 				    __mkSmallInteger(index),
 				    el);
 	    }
@@ -1289,35 +1282,35 @@
     ^ super keysAndValuesDo:aBlock
 !
 
-modifyingTraverse:aBlock 
-    "Evaluate aBlock for every element that is not an Array, 
+modifyingTraverse:aBlock
+    "Evaluate aBlock for every element that is not an Array,
      and recursively traverse Arrays.
 
      aBlock may return the original element or a new element.
      If a new element is returned, the element is changed to the new element."
-    
-    self 
-        keysAndValuesDo:[:eachIndex :eachElement | 
-            eachElement isArray ifTrue:[
-                eachElement modifyingTraverse:aBlock
-            ] ifFalse:[
-                |newElement|
 
-                newElement := aBlock value:eachElement.
-                newElement ~~ eachElement ifTrue:[
-                    self at:eachIndex put:newElement.
-                ].
-            ]
-        ].
+    self
+	keysAndValuesDo:[:eachIndex :eachElement |
+	    eachElement isArray ifTrue:[
+		eachElement modifyingTraverse:aBlock
+	    ] ifFalse:[
+		|newElement|
+
+		newElement := aBlock value:eachElement.
+		newElement ~~ eachElement ifTrue:[
+		    self at:eachIndex put:newElement.
+		].
+	    ]
+	].
 
     "
      example: replace all elements which are 10 with: 'changed'
 
-     #(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) copy 
-         modifyingTraverse:[:el |
-            el = 10 ifTrue:['changed'] ifFalse:[el]
-         ];
-         inspect
+     #(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) copy
+	 modifyingTraverse:[:el |
+	    el = 10 ifTrue:['changed'] ifFalse:[el]
+	 ];
+	 inspect
     "
 !
 
@@ -1374,9 +1367,9 @@
 			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
 #endif
 			} else {
-			    (*val.ilc_func)(aBlock, 
-					    @symbol(value:), 
-					    nil, &val, 
+			    (*val.ilc_func)(aBlock,
+					    @symbol(value:),
+					    nil, &val,
 					    __InstPtr(self)->i_instvars[index]);
 			}
 		    }
@@ -1394,9 +1387,9 @@
 	    for (index=nIndex-1; index >= endIndex; index--) {
 		if (InterruptPending != nil) __interruptL(@line);
 
-		(*val.ilc_func)(aBlock, 
-				@symbol(value:), 
-				nil, &val, 
+		(*val.ilc_func)(aBlock,
+				@symbol(value:),
+				nil, &val,
 				__InstPtr(self)->i_instvars[index]);
 	    }
 	    RETURN ( self );
@@ -1407,7 +1400,7 @@
 !
 
 traverse:aBlock
-    "Evaluate aBlock for every element that is not an Array, 
+    "Evaluate aBlock for every element that is not an Array,
      and recursively traverse Arrays.
      Implemented here to support better search for selectors in
      literal arrays - might be a good idea to move it up in the collection
@@ -1426,12 +1419,12 @@
 
      s := WriteStream on:Array new.
      #(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | s nextPut:el].
-     s contents 
+     s contents
     "
     "
      example: deep search
 
-     #(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | 
+     #(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el |
 	el == 10 ifTrue:[Transcript showCR:'found']
      ]
     "
@@ -1470,7 +1463,7 @@
 # ifdef FAST_MEMSET
 		if ((INT)anObject == 0) {
 		    memset(dst, 0, __OBJS2BYTES__(endIndex-index+1));
-		} else 
+		} else
 # endif
 		{
 # ifdef __UNROLL_LOOPS__
@@ -1517,7 +1510,7 @@
     REGISTER OBJ t;
     REGISTER int count;
     OBJ myClass;
-    
+
     if (
 	(__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0))
      && __isNonNilObject(aCollection)
@@ -1540,12 +1533,12 @@
 			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 ;-)
@@ -1577,7 +1570,7 @@
 			    {
 				OBJ t1;
 
-				/* 
+				/*
 				 * the loop below fetches one longWord behind
 				 * this should not be a problem
 				 */
@@ -1666,7 +1659,7 @@
 
 displayStringName
     self class == Array ifTrue:[
-        ^ '#'
+	^ '#'
     ].
     ^ super displayStringName.
 !
@@ -1675,55 +1668,55 @@
     "append a printed representation of the receiver to aStream"
 
     self isLiteral ifTrue:[
-        |limit firstOne s|
+	|limit firstOne s|
 
-        thisContext isRecursive ifTrue:[
-            'Array [error]: printOn: of self referencing collection.' errorPrintCR.
-            aStream nextPutAll:'#("recursive")'.
-            ^ self
-        ].
+	thisContext isRecursive ifTrue:[
+	    'Array [error]: printOn: of self referencing collection.' errorPrintCR.
+	    aStream nextPutAll:'#("recursive")'.
+	    ^ self
+	].
 
-        aStream nextPutAll:'#('.
-        firstOne := true.
+	aStream nextPutAll:'#('.
+	firstOne := true.
 
-        "
-         if aStream is not positionable, create an temporary positionable stream
-         (needed for limit calculation)
-        "
-        aStream isPositionable ifTrue:[
-            s := aStream.
-        ] ifFalse:[
-            s := WriteStream on:(String uninitializedNew:50).
-        ].
-        limit := s position1Based + self maxPrint.
+	"
+	 if aStream is not positionable, create an temporary positionable stream
+	 (needed for limit calculation)
+	"
+	aStream isPositionable ifTrue:[
+	    s := aStream.
+	] ifFalse:[
+	    s := WriteStream on:(String uninitializedNew:50).
+	].
+	limit := s position1Based + self maxPrint.
 
-        self printElementsDo:[:element |
-            firstOne ifFalse:[
-                s space
-            ] ifTrue:[
-                firstOne := false
-            ].
-            (s position1Based >= limit) ifTrue:[
-                s ~~ aStream ifTrue:[
-                    aStream nextPutAll:(s contents).
-                ].
-                aStream nextPutAll:'...etc...)'.
-                ^ self
-            ] ifFalse:[
-                element printOn:s.
-            ].
-        ].
-        s ~~ aStream ifTrue:[
-            aStream nextPutAll:(s contents).
-        ].
-        aStream nextPut:$)
+	self printElementsDo:[:element |
+	    firstOne ifFalse:[
+		s space
+	    ] ifTrue:[
+		firstOne := false
+	    ].
+	    (s position1Based >= limit) ifTrue:[
+		s ~~ aStream ifTrue:[
+		    aStream nextPutAll:(s contents).
+		].
+		aStream nextPutAll:'...etc...)'.
+		^ self
+	    ] ifFalse:[
+		element printOn:s.
+	    ].
+	].
+	s ~~ aStream ifTrue:[
+	    aStream nextPutAll:(s contents).
+	].
+	aStream nextPut:$)
     ] ifFalse:[
-        super printOn:aStream
+	super printOn:aStream
     ]
 
     "
-     #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString 
-     #(1 2 $a [1 2 3] true false nil #true #false #nil) printString 
+     #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString
+     #(1 2 $a [1 2 3] true false nil #true #false #nil) printString
     "
 
     "Created: 20.11.1995 / 11:16:58 / cg"
@@ -1733,18 +1726,18 @@
     "Store as element of an array. Omit the leading '#'"
 
     self isLiteral ifTrue:[
-        aStream nextPut:$(.
-        self 
-            do:[:element | element storeArrayElementOn:aStream]
-            separatedBy:[aStream space].
-        aStream nextPut:$).
-        ^ self.
+	aStream nextPut:$(.
+	self
+	    do:[:element | element storeArrayElementOn:aStream]
+	    separatedBy:[aStream space].
+	aStream nextPut:$).
+	^ self.
     ].
     super storeArrayElementOn:aStream
 
     "
-     #(1 2 3 4 5) storeOn:Transcript   
-     #(1 2 3 4 5) storeArrayElementOn:Transcript   
+     #(1 2 3 4 5) storeOn:Transcript
+     #(1 2 3 4 5) storeArrayElementOn:Transcript
     "
 !
 
@@ -1754,17 +1747,17 @@
      Redefined to output a somewhat more user friendly string."
 
     self isLiteral ifTrue:[
-        aStream nextPutAll:'#('.
-        self do:[:element | element storeArrayElementOn:aStream]
-             separatedBy:[aStream space].
-        aStream nextPut:$)
+	aStream nextPutAll:'#('.
+	self do:[:element | element storeArrayElementOn:aStream]
+	     separatedBy:[aStream space].
+	aStream nextPut:$)
     ] ifFalse:[
-        super storeOn:aStream
+	super storeOn:aStream
     ]
 
     "
-     #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') storeString 
-     #(1 2 $a [1 2 3] true false nil #true #false #nil) storeString 
+     #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') storeString
+     #(1 2 $a [1 2 3] true false nil #true #false #nil) storeString
     "
 
     "Created: 20.11.1995 / 11:16:58 / cg"
@@ -1786,7 +1779,7 @@
     "return true if the receiver or recursively any array element in the
      receiver referes to aLiteral (i.e. a deep search)"
 
-    self do: [ :el | 
+    self do: [ :el |
 	el == aLiteral ifTrue:[^true].
 	el class == Array ifTrue:[
 	    (el refersToLiteral: aLiteral) ifTrue: [^true]
@@ -1795,9 +1788,9 @@
     ^ false
 
     "
-     #(1 2 3) refersToLiteral:#foo  
-     #(1 2 3 foo bar baz) refersToLiteral:#foo 
-     #(1 2 3 (((bar foo))) bar baz) refersToLiteral:#foo  
+     #(1 2 3) refersToLiteral:#foo
+     #(1 2 3 foo bar baz) refersToLiteral:#foo
+     #(1 2 3 (((bar foo))) bar baz) refersToLiteral:#foo
     "
 
     "Modified: / 18.8.2000 / 21:18:14 / cg"
@@ -1807,18 +1800,18 @@
     "return true if the receiver or recursively any array element in the
      receiver is symbolic and matches aMatchPattern (i.e. a deep search)"
 
-    self do:[ :el | 
-        (el isSymbol and:[ aMatchPattern match: el]) ifTrue:[^true].
-        el class == Array ifTrue:[
-            (el refersToLiteralMatching: aMatchPattern) ifTrue: [^true]
-        ]
+    self do:[ :el |
+	(el isSymbol and:[ aMatchPattern match: el]) ifTrue:[^true].
+	el class == Array ifTrue:[
+	    (el refersToLiteralMatching: aMatchPattern) ifTrue: [^true]
+	]
     ].
     ^ false
 
     "
-     #(1 2 3) refersToLiteralMatching:#foo  
-     #(1 2 3 foo bar baz) refersToLiteralMatching:#foo 
-     #(1 2 3 (((bar foo))) bar baz) refersToLiteralMatching:#foo  
+     #(1 2 3) refersToLiteralMatching:#foo
+     #(1 2 3 foo bar baz) refersToLiteralMatching:#foo
+     #(1 2 3 (((bar foo))) bar baz) refersToLiteralMatching:#foo
     "
 
     "Modified: / 18-08-2000 / 21:18:14 / cg"
@@ -1841,8 +1834,8 @@
 
 !Array methodsFor:'searching'!
 
-identityIndexOf:anElement or:alternative 
-    "search the array for anElement or alternative; 
+identityIndexOf:anElement or:alternative
+    "search the array for anElement or alternative;
      return the index of anElement if found, or the index of anAlternative,
      if not found. If anAlternative is also not found, return 0.
      This is a special interface for high-speed searching in an array
@@ -1863,7 +1856,7 @@
     nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
     index += nInsts;
     nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
-    el1 = anElement; el2 = alternative; 
+    el1 = anElement; el2 = alternative;
     op = & (__InstPtr(self)->i_instvars[index]);
     while (index++ < nIndex) {
 	if ((o = *op++) == el1) {
@@ -1883,11 +1876,11 @@
      #(1 2 3 4 5 6 7 8 9) identityIndexOf:3 or:5
      #(1 2 0 4 5 6 7 8 9) identityIndexOf:3 or:5
      #(1 2 0 4 5 6 7 3 9) identityIndexOf:3 or:5
-     #(1 2 3 4 5 nil 7 3 9) identityIndexOf:3 or:nil 
-     #(1 2 nil 4 5 6 7 3 9) identityIndexOf:3 or:nil  
-     #(1 2 nil 4 5 6 7 8 9) identityIndexOf:3 or:nil 
-     #() identityIndexOf:3 or:nil        
-     #(1 2) identityIndexOf:3 or:nil 
+     #(1 2 3 4 5 nil 7 3 9) identityIndexOf:3 or:nil
+     #(1 2 nil 4 5 6 7 3 9) identityIndexOf:3 or:nil
+     #(1 2 nil 4 5 6 7 8 9) identityIndexOf:3 or:nil
+     #() identityIndexOf:3 or:nil
+     #(1 2) identityIndexOf:3 or:nil
     "
 !
 
@@ -1919,7 +1912,7 @@
 		p = memsrch4(op, (INT)el, (nIndex - index));
 		if (p) {
 		    index += (p - op + 1);
-		    RETURN ( __mkSmallInteger(index) ); 
+		    RETURN ( __mkSmallInteger(index) );
 		}
 	    }
 #else
@@ -1946,7 +1939,7 @@
 		 */
 
 		unsigned int i8;
-                
+
 		while ((i8 = index + 8) < nIndex) {
 		    if (op[0] == el) goto found1;
 		    if (op[1] == el) goto found2;
@@ -1997,7 +1990,7 @@
 !
 
 identityIndexOf:anElement startingAt:start endingAt:stop
-    "search the array for anElement in the range start..stop; 
+    "search the array for anElement in the range start..stop;
      return the index if found, 0 otherwise.
      - reimplemented for speed when searching in OrderedCollections"
 
@@ -2030,7 +2023,7 @@
 		p = memsrch4(op, (INT)el, (lastIndex - index));
 		if (p) {
 		    index += (p - op + 1);
-		    RETURN ( __mkSmallInteger(index) ); 
+		    RETURN ( __mkSmallInteger(index) );
 		}
 	    }
 #else
@@ -2104,127 +2097,127 @@
 
     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 (__isStringLike(e)) {
-                    while (index < nIndex) {
-                        element = __InstPtr(self)->i_instvars[index++];
-                        if (__isNonNilObject(element)) {
-                            if (element == e) {
-                                RETURN ( __mkSmallInteger(index - nInsts) );
-                            }
-                            if (__qClass(element) == @global(String)) {
-                                if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
-                                    RETURN ( __mkSmallInteger(index - nInsts) );
-                                }
-                            } else {
-                                if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
-                                    RETURN ( __mkSmallInteger(index - nInsts) );
-                                }
-                                /*
-                                 * send of #= could have lead to a GC - refetch e
-                                 */
-                                e = anElement;
-                            }
-                        }
-                    }
-                    RETURN (__mkSmallInteger(0));
-                }
+		if (__isStringLike(e)) {
+		    while (index < nIndex) {
+			element = __InstPtr(self)->i_instvars[index++];
+			if (__isNonNilObject(element)) {
+			    if (element == e) {
+				RETURN ( __mkSmallInteger(index - nInsts) );
+			    }
+			    if (__qClass(element) == @global(String)) {
+				if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
+				    RETURN ( __mkSmallInteger(index - nInsts) );
+				}
+			    } else {
+				if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
+				    RETURN ( __mkSmallInteger(index - nInsts) );
+				}
+				/*
+				 * send of #= could have lead to a GC - refetch e
+				 */
+				e = anElement;
+			    }
+			}
+		    }
+		    RETURN (__mkSmallInteger(0));
+		}
 #endif
 #ifdef MAKES_IT_SLOWER_BUT_WHY
-                if (__isSmallInteger(e)) {
-                    /* search for a small number */
-                    while (index < nIndex) {
-                        element = __InstPtr(self)->i_instvars[index++];
-                        if (element == e) {
-                            RETURN ( __mkSmallInteger(index - nInsts) );
-                        }
-                        if (!__isSmallInteger(element)) {
-                            if (element != nil) {
-                                if ((*eq.ilc_func)(e,
-                                                   @symbol(=), 
-                                                   nil,&eq,
-                                                   element) == true) {
-                                    RETURN ( __mkSmallInteger(index - nInsts) );
-                                }
-                                /*
-                                 * send of #= could have lead to a GC - refetch e
-                                 */
-                                e = anElement;
-                            }
-                        }
-                    }
-                    RETURN (__mkSmallInteger(0));
-                }
+		if (__isSmallInteger(e)) {
+		    /* search for a small number */
+		    while (index < nIndex) {
+			element = __InstPtr(self)->i_instvars[index++];
+			if (element == e) {
+			    RETURN ( __mkSmallInteger(index - nInsts) );
+			}
+			if (!__isSmallInteger(element)) {
+			    if (element != nil) {
+				if ((*eq.ilc_func)(e,
+						   @symbol(=),
+						   nil,&eq,
+						   element) == true) {
+				    RETURN ( __mkSmallInteger(index - nInsts) );
+				}
+				/*
+				 * send of #= could have lead to a GC - refetch e
+				 */
+				e = anElement;
+			    }
+			}
+		    }
+		    RETURN (__mkSmallInteger(0));
+		}
 #endif /* MAKES_IT_SLOWER_BUT_WHY */
 
-                while (index < nIndex) {
-                    element = __InstPtr(self)->i_instvars[index++];
-                    if (element != nil) {
-                        if ((element == e) 
-                         || ((*eq.ilc_func)(e,
-                                            @symbol(=), 
-                                            nil,&eq,
-                                            element) == true)) {
-                            RETURN ( __mkSmallInteger(index - nInsts) );
-                        }
-                        /*
-                         * send of #= could have lead to a GC - refetch e
-                         */
-                        e = anElement;
-                    }
-                }
-            } else {
-                OBJ slf = self;
+		while (index < nIndex) {
+		    element = __InstPtr(self)->i_instvars[index++];
+		    if (element != nil) {
+			if ((element == e)
+			 || ((*eq.ilc_func)(e,
+					    @symbol(=),
+					    nil,&eq,
+					    element) == true)) {
+			    RETURN ( __mkSmallInteger(index - nInsts) );
+			}
+			/*
+			 * send of #= could have lead to a GC - refetch e
+			 */
+			e = anElement;
+		    }
+		}
+	    } else {
+		OBJ slf = self;
 
-                /* 
-                 * search for nil - do an identity-search
-                 */
+		/*
+		 * search for nil - do an identity-search
+		 */
 #ifdef __UNROLL_LOOPS__
-                {
-                    unsigned int i8;
+		{
+		    unsigned int i8;
 
-                    while ((i8 = index + 8) < nIndex) {
-                        if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
-                        if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
-                        if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
-                        if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
-                        if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
-                        if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
-                        if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
-                        if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
-                        index = i8;
-                    }
-                }
+		    while ((i8 = index + 8) < nIndex) {
+			if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
+			if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
+			if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
+			if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
+			if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
+			if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
+			if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
+			if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
+			index = i8;
+		    }
+		}
 #endif
 
-                while (index < nIndex) {
-                    if (__InstPtr(slf)->i_instvars[index++] == nil) {
-                        RETURN ( __mkSmallInteger(index - nInsts) );
-                    }
-                }
-            }
-        }
-        RETURN (__mkSmallInteger(0));
+		while (index < nIndex) {
+		    if (__InstPtr(slf)->i_instvars[index++] == nil) {
+			RETURN ( __mkSmallInteger(index - nInsts) );
+		    }
+		}
+	    }
+	}
+	RETURN (__mkSmallInteger(0));
     }
 %}.
     ^ super indexOf:anElement startingAt:start
 !
 
 indexOf:anElement startingAt:start endingAt:stop
-    "search the array for anElement in the range start..stop; 
+    "search the array for anElement in the range start..stop;
      Return the index if found, 0 otherwise.
      - reimplemented for speed when searching in OrderedCollections"
 
@@ -2238,117 +2231,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 (__isStringLike(e)) {
-                    while (index < lastIndex) {
-                        element = __InstPtr(self)->i_instvars[index++];
-                        if (__isNonNilObject(element)) {
-                            if (element == e) {
-                                RETURN ( __mkSmallInteger(index - nInsts) );
-                            }
-                            if (__qClass(element) == @global(String)) {
-                                if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
-                                    RETURN ( __mkSmallInteger(index - nInsts) );
-                                }
-                            } else {
-                                if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
-                                    RETURN ( __mkSmallInteger(index - nInsts) );
-                                }
-                                /*
-                                 * send of #= could have lead to a GC - refetch e
-                                 */
-                                e = anElement;
-                            }
-                        }
-                    }
-                    RETURN (__mkSmallInteger(0));
-                }
+		if (__isStringLike(e)) {
+		    while (index < lastIndex) {
+			element = __InstPtr(self)->i_instvars[index++];
+			if (__isNonNilObject(element)) {
+			    if (element == e) {
+				RETURN ( __mkSmallInteger(index - nInsts) );
+			    }
+			    if (__qClass(element) == @global(String)) {
+				if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
+				    RETURN ( __mkSmallInteger(index - nInsts) );
+				}
+			    } else {
+				if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
+				    RETURN ( __mkSmallInteger(index - nInsts) );
+				}
+				/*
+				 * send of #= could have lead to a GC - refetch e
+				 */
+				e = anElement;
+			    }
+			}
+		    }
+		    RETURN (__mkSmallInteger(0));
+		}
 #endif
-                if (__isSmallInteger(e)) {
-                    /* search for a small number */
-                    while (index < lastIndex) {
-                        element = __InstPtr(self)->i_instvars[index++];
-                        if (element == e) {
-                            RETURN ( __mkSmallInteger(index - nInsts) );
-                        }
-                        if (!__isSmallInteger(element)) {
-                            if ((*eq.ilc_func)(e,
-                                                @symbol(=), 
-                                                nil,&eq,
-                                                element) == true) {
-                                RETURN ( __mkSmallInteger(index - nInsts) );
-                            }
-                            /*
-                             * send of #= could have lead to a GC - refetch e
-                             */
-                            e = anElement;
-                        }
-                    }
-                    RETURN (__mkSmallInteger(0));
-                }
+		if (__isSmallInteger(e)) {
+		    /* search for a small number */
+		    while (index < lastIndex) {
+			element = __InstPtr(self)->i_instvars[index++];
+			if (element == e) {
+			    RETURN ( __mkSmallInteger(index - nInsts) );
+			}
+			if (!__isSmallInteger(element)) {
+			    if ((*eq.ilc_func)(e,
+						@symbol(=),
+						nil,&eq,
+						element) == true) {
+				RETURN ( __mkSmallInteger(index - nInsts) );
+			    }
+			    /*
+			     * send of #= could have lead to a GC - refetch e
+			     */
+			    e = anElement;
+			}
+		    }
+		    RETURN (__mkSmallInteger(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 ( __mkSmallInteger(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 ( __mkSmallInteger(index - nInsts) );
+			}
+		    }
+		}
+	    } else {
+		OBJ slf = self;
 
-                /* 
-                 * search for nil - do an identity-search
-                 */
+		/*
+		 * search for nil - do an identity-search
+		 */
 #ifdef __UNROLL_LOOPS__
-                {
-                    unsigned int i8;
+		{
+		    unsigned int i8;
 
-                    while ((i8 = index + 8) < lastIndex) {
-                        if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
-                        if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
-                        if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
-                        if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
-                        if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
-                        if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
-                        if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
-                        if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
-                        index = i8;
-                    }
-                }
+		    while ((i8 = index + 8) < lastIndex) {
+			if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
+			if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
+			if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
+			if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
+			if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
+			if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
+			if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
+			if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
+			index = i8;
+		    }
+		}
 #endif
-                while (index < lastIndex) {
-                    if (__InstPtr(slf)->i_instvars[index++] == nil) {
-                        RETURN ( __mkSmallInteger(index - nInsts) );
-                    }
-                }
-            }
-        }
-        RETURN (__mkSmallInteger(0));
+		while (index < lastIndex) {
+		    if (__InstPtr(slf)->i_instvars[index++] == nil) {
+			RETURN ( __mkSmallInteger(index - nInsts) );
+		    }
+		}
+	    }
+	}
+	RETURN (__mkSmallInteger(0));
     }
 %}.
     ^ super indexOf:anElement startingAt:start endingAt:stop
@@ -2363,7 +2356,7 @@
     |element|
 
 %{  /* NOCONTEXT */
-    /* 
+    /*
      * first, do a quick check using ==
      * this does not need a context or message send.
      * In many cases this will already find a match.
@@ -2459,11 +2452,11 @@
     unsigned int nIndex;
     static struct inlineCache eq = _ILC1;
 
-    /* 
+    /*
      * then do a slow(er) check using =
      */
 
-    /* 
+    /*
      * sorry: cannot access the stuff from above ...
      */
     nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
@@ -2525,7 +2518,7 @@
      (i.e. can be used in constant arrays)"
 
     "/ no, simply returning true here is a mistake:
-    "/ it could be a subclass of Array 
+    "/ it could be a subclass of Array
     "/ (of which the compiler does not know at all ...)
 
     self class == Array ifFalse:[^ false].
@@ -2566,16 +2559,9 @@
 !Array class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.152 2012/10/10 16:30:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.155 2013-01-16 10:30:10 cg Exp $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/Array.st,v 1.152 2012/10/10 16:30:53 cg Exp §'
-!
-
-version_SVN
-    ^ '$Id: Array.st 10858 2012-10-29 22:07:56Z vranyj1 $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.155 2013-01-16 10:30:10 cg Exp $'
 ! !
-
-
-