--- a/Array.st Mon Apr 20 15:16:30 2015 +0200
+++ b/Array.st Mon Apr 20 16:04:23 2015 +0200
@@ -38,7 +38,7 @@
documentation
"
- Instances of Array store general objects;
+ Instances of Array store general objects;
an array's 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...)
@@ -59,7 +59,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
@@ -77,37 +77,37 @@
Also, a syntactic sugar piece allows for Array instances to be created dynamcially
at runtime with the brace syntax:
- { expr1 . expr2 . ... . expr-N }
+ { expr1 . expr2 . ... . expr-N }
where each expr-i evaluates to an element of the new array instance.
Notice that the expressions are separated by a period.
Semantically, this is equivalent to ``Array with:expr1 with:expr2 ... with:expr-N''
Examples:
- { 1 . 2 . 3 } -> a new 3 element array; similar to #( 1 2 3 ),
- but in contrast, a new array instance is created
- {
- { 'foo' . [ Transcript showCR:'foo' ] } .
- { 'bar' . [ Transcript showCR:'bar' ] }
- { 'baz' . [ Transcript showCR:'baz' ] }
- }
- -> a new 3 element array, consisting of 3 new
- 2-element array instances, consisting of a string
- and a block each
+ { 1 . 2 . 3 } -> a new 3 element array; similar to #( 1 2 3 ),
+ but in contrast, a new array instance is created
+ {
+ { 'foo' . [ Transcript showCR:'foo' ] } .
+ { 'bar' . [ Transcript showCR:'bar' ] }
+ { 'baz' . [ Transcript showCR:'baz' ] }
+ }
+ -> a new 3 element array, consisting of 3 new
+ 2-element array instances, consisting of a string
+ and a block each
[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 IntegerArray BitArray
- CharacterArray String
+ OrderedCollection
+ ByteArray FloatArray DoubleArray IntegerArray BitArray
+ CharacterArray String
"
! !
@@ -446,7 +446,7 @@
"could be an instance of a subclass..."
self class == Array ifTrue:[
- ^ self
+ ^ self
].
^ super asArray
@@ -467,7 +467,7 @@
"could be an instance of a subclass..."
self class == Array ifTrue:[
- ^ self copy
+ ^ self copy
].
^ super asArray
!
@@ -485,31 +485,31 @@
, aCollection
%{
if (__isArray(aCollection)) {
- if (__isArray(self)) {
- OBJ newArray;
- int mySize = __arraySize(self);
- int otherSize = __arraySize(aCollection);
- REGISTER OBJ src;
- int srcIdx, dstIdx;
- newArray = __ARRAY_NEW_INT(mySize+otherSize);
+ if (__isArray(self)) {
+ OBJ newArray;
+ int mySize = __arraySize(self);
+ int otherSize = __arraySize(aCollection);
+ REGISTER OBJ src;
+ int srcIdx, dstIdx;
+ newArray = __ARRAY_NEW_INT(mySize+otherSize);
- src = self;
- for (dstIdx=0; dstIdx<mySize; dstIdx++) {
- OBJ el = __ArrayInstPtr(src)->a_element[dstIdx];
+ src = self;
+ for (dstIdx=0; dstIdx<mySize; dstIdx++) {
+ OBJ el = __ArrayInstPtr(src)->a_element[dstIdx];
- __ArrayInstPtr(newArray)->a_element[dstIdx] = el;
- __STORE(newArray, el);
- }
+ __ArrayInstPtr(newArray)->a_element[dstIdx] = el;
+ __STORE(newArray, el);
+ }
- src = aCollection;
- for (srcIdx=0; srcIdx<otherSize; srcIdx++, dstIdx++) {
- OBJ el = __ArrayInstPtr(src)->a_element[srcIdx];
+ src = aCollection;
+ for (srcIdx=0; srcIdx<otherSize; srcIdx++, dstIdx++) {
+ OBJ el = __ArrayInstPtr(src)->a_element[srcIdx];
- __ArrayInstPtr(newArray)->a_element[dstIdx] = el;
- __STORE(newArray, el);
- }
- RETURN (newArray);
- }
+ __ArrayInstPtr(newArray)->a_element[dstIdx] = el;
+ __STORE(newArray, el);
+ }
+ RETURN (newArray);
+ }
}
%}.
^ super , aCollection
@@ -1742,50 +1742,50 @@
"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 position + 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 position + self maxPrint.
- self printElementsDo:[:element |
- firstOne ifFalse:[
- s space
- ] ifTrue:[
- firstOne := false
- ].
- (s position >= 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 position >= 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
]
"
@@ -1843,9 +1843,13 @@
"return the number of indexed elements in the receiver"
%{ /* NOCONTEXT */
+#ifdef __SCHTEAM__
+ return context._RETURN (STInteger._new(self.basicSize()));
+#else
REGISTER OBJ slf = self;
RETURN ( __mkSmallInteger(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) ));
+#endif
%}
!
@@ -1854,10 +1858,10 @@
receiver refers to aLiteral (i.e. a deep search)"
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
@@ -1900,9 +1904,13 @@
This method is the same as basicSize."
%{ /* NOCONTEXT */
+#ifdef __SCHTEAM__
+ return context._RETURN (STInteger._new(self.basicSize()));
+#else
REGISTER OBJ slf = self;
RETURN ( __mkSmallInteger(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) ));
+#endif
%}
! !
@@ -2633,10 +2641,9 @@
!Array class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.165 2015-02-03 13:54:47 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.166 2015-04-20 14:04:23 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.165 2015-02-03 13:54:47 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.166 2015-04-20 14:04:23 cg Exp $'
! !
-