Array.st
author Stefan Vogel <sv@exept.de>
Wed, 21 Nov 2007 11:10:11 +0100
changeset 10796 08a9ee8cf317
parent 10089 833fffc641ef
child 11167 883813e7d746
permissions -rw-r--r--
Do not add nil elements to a Set in #asSet and #asIdentitySet
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
155
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
5347
21b418ac4cc3 oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents: 5049
diff changeset
    12
"{ Package: 'stx:libbasic' }"
21b418ac4cc3 oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents: 5049
diff changeset
    13
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    14
ArrayedCollection variableSubclass:#Array
1083
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
    15
	instanceVariableNames:''
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
    16
	classVariableNames:''
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
    17
	poolDictionaries:''
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
    18
	category:'Collections-Arrayed'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
    21
!Array class methodsFor:'documentation'!
77
6c38ca59927f *** empty log message ***
claus
parents: 47
diff changeset
    22
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    23
copyright
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    24
"
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    25
 COPYRIGHT (c) 1989 by Claus Gittinger
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    26
	      All Rights Reserved
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    27
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    28
 This software is furnished under a license and may be used
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    29
 only in accordance with the terms of that license and with the
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    31
 be provided or otherwise made available to, or used by, any
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    32
 other person.  No title to or ownership of the software is
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    33
 hereby transferred.
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    34
"
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    35
!
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    36
77
6c38ca59927f *** empty log message ***
claus
parents: 47
diff changeset
    37
documentation
6c38ca59927f *** empty log message ***
claus
parents: 47
diff changeset
    38
"
155
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    39
    Instances of Array store general objects; the arrays size is fixed, 
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    40
    therefore add:/remove: are not allowed. 
399
claus
parents: 393
diff changeset
    41
    (actually, #add: is implemented for compatibility with smalltalks which 
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    42
     provide it, but it is very slow and outputs an annoying warning message ...)
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    43
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    44
    Access to the individual elements is via an integer index,
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    45
    using the well-known access messages #at: and #at:put:.
399
claus
parents: 393
diff changeset
    46
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
    47
    Since Arrays are used very often in the system (either directly or a data-container
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
    48
    of more complex collection classes), some methods have been tuned by reimplementing 
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
    49
    them as primitives. Also, the compiler inline-codes some operations 
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
    50
    (especially: the above accessing messages).
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    51
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    52
    Notice that Array is a built-in class 
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    53
    (i.e. the VM knows about its representation). 
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    54
    Therefore it is NOT possible to add named instance variables or change 
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    55
    Arrays inheritance. 
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    56
    However, subclassing is allowed of course 
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    57
    - even with added named instance variables.
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    58
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    59
    Literal arrays (i.e. array-constants) are entered in source as:
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    60
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    61
	#( element1 element2 ... element-n)
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    62
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    63
    where each element must be itself a literal constant.
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    64
    Array, symbol and byteArray constants within an array can be written
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    65
    without the initial #-character.
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    66
    In addition, true, false and nil are also allowed as array-literal.
399
claus
parents: 393
diff changeset
    67
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    68
    Examples:
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    69
      #(1 2 3)                -> 3 elements: 1, 2 and 3
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    70
      #('foo' 2 (1 2))        -> 3 elements: a String, 2 and anotherArray
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    71
      #('foo' #(1 2) #foo)    -> 3 elements: a String, another array and a symbol
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    72
      #('foo' (1 2) foo)      -> same as above
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    73
      #(nil true #true)       -> 3 elements: nil, true and a symbol (watch out)
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
    74
      #(two [3 3 3] (4 4 4))  -> 3 elements: a symbol, a byteArray and another array
1276
21649f929b32 commentary
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
    75
4062
4959de96b06f documentation
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
    76
    [memory requirements:]
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    77
	OBJ-HEADER + (size * ptr-size)
4062
4959de96b06f documentation
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
    78
2145
d243ffafeae3 more docu
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
    79
    [warning:]
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    80
	read the warning about 'growing fixed size collection'
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    81
	in ArrayedCollection's documentation
1276
21649f929b32 commentary
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
    82
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
    83
    [author:]
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    84
	Claus Gittinger
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
    85
1276
21649f929b32 commentary
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
    86
    [see also:]
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    87
	OrderedCollection
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    88
	ByteArray FloatArray DoubleArray
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
    89
	String
77
6c38ca59927f *** empty log message ***
claus
parents: 47
diff changeset
    90
"
626
f359cb7eba58 version at the end
Claus Gittinger <cg@exept.de>
parents: 588
diff changeset
    91
! !
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    92
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
    93
!Array class methodsFor:'instance creation'!
249
claus
parents: 220
diff changeset
    94
claus
parents: 220
diff changeset
    95
basicNew:anInteger
claus
parents: 220
diff changeset
    96
    "return an instance of myself with anInteger indexed variables.
claus
parents: 220
diff changeset
    97
     Since Array-creation is so common (all other collections use them),
claus
parents: 220
diff changeset
    98
     it seems worth to have a specially tuned version here."
claus
parents: 220
diff changeset
    99
claus
parents: 220
diff changeset
   100
%{  /* NOCONTEXT */
claus
parents: 220
diff changeset
   101
claus
parents: 220
diff changeset
   102
    OBJ newobj;
claus
parents: 220
diff changeset
   103
    unsigned INT instsize, nInstVars;
claus
parents: 220
diff changeset
   104
    INT nindexedinstvars;
claus
parents: 220
diff changeset
   105
    REGISTER OBJ *op;
claus
parents: 220
diff changeset
   106
claus
parents: 220
diff changeset
   107
    if (__isSmallInteger(anInteger)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   108
	nindexedinstvars = __intVal(anInteger);
249
claus
parents: 220
diff changeset
   109
	if (nindexedinstvars >= 0) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   110
	    nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
249
claus
parents: 220
diff changeset
   111
claus
parents: 220
diff changeset
   112
	    nInstVars += nindexedinstvars;
claus
parents: 220
diff changeset
   113
	    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   114
	    if (__CanDoQuickAlignedNew(instsize)) {     /* OBJECT ALLOCATION */
357
claus
parents: 356
diff changeset
   115
		/*
claus
parents: 356
diff changeset
   116
		 * the most common case
claus
parents: 356
diff changeset
   117
		 */
835
8bd6f4aa8130 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
   118
		__qCheckedAlignedNew(newobj, instsize);
357
claus
parents: 356
diff changeset
   119
	ok: ;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   120
		__InstPtr(newobj)->o_class = self;
369
claus
parents: 365
diff changeset
   121
		__qSTORE(newobj, self);
claus
parents: 365
diff changeset
   122
788
e80f1c42b87b dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
   123
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   124
		memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
249
claus
parents: 220
diff changeset
   125
#else
claus
parents: 220
diff changeset
   126
# if !defined(NEGATIVE_ADDRESSES)
claus
parents: 220
diff changeset
   127
		/*
claus
parents: 220
diff changeset
   128
		 * knowing that nil is 0
claus
parents: 220
diff changeset
   129
		 */
360
claus
parents: 359
diff changeset
   130
#ifdef XXmips
249
claus
parents: 220
diff changeset
   131
# undef FAST_ARRAY_MEMSET_DOUBLES_UNROLLED
claus
parents: 220
diff changeset
   132
# undef FAST_ARRAY_MEMSET_LONGLONG_UNROLLED
claus
parents: 220
diff changeset
   133
/* seems to be slightly faster */
claus
parents: 220
diff changeset
   134
# define FAST_ARRAY_MEMSET
claus
parents: 220
diff changeset
   135
#endif
2979
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   136
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8625
diff changeset
   137
#ifdef __sparc__
249
claus
parents: 220
diff changeset
   138
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED
claus
parents: 220
diff changeset
   139
#endif
claus
parents: 220
diff changeset
   140
2979
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   141
#ifdef __VMS__
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   142
# define FAST_ARRAY_MEMSET_LONGLONG_UNROLLED
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   143
#endif
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   144
249
claus
parents: 220
diff changeset
   145
#  if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   146
		op = __InstPtr(newobj)->i_instvars;
249
claus
parents: 220
diff changeset
   147
		if (nInstVars > 8) {
claus
parents: 220
diff changeset
   148
		    *op++ = nil;    /* for alignment */
claus
parents: 220
diff changeset
   149
		    nInstVars--;
claus
parents: 220
diff changeset
   150
		    while (nInstVars >= 8) {
claus
parents: 220
diff changeset
   151
			*(double *)op = 0.0;
claus
parents: 220
diff changeset
   152
			((double *)op)[1] = 0.0;
claus
parents: 220
diff changeset
   153
			((double *)op)[2] = 0.0;
claus
parents: 220
diff changeset
   154
			((double *)op)[3] = 0.0;
claus
parents: 220
diff changeset
   155
			op += 8;
claus
parents: 220
diff changeset
   156
			nInstVars -= 8;
claus
parents: 220
diff changeset
   157
		    }
claus
parents: 220
diff changeset
   158
		}
claus
parents: 220
diff changeset
   159
		while (nInstVars) {
claus
parents: 220
diff changeset
   160
		    *op++ = 0;
claus
parents: 220
diff changeset
   161
		    nInstVars--;
claus
parents: 220
diff changeset
   162
		}
claus
parents: 220
diff changeset
   163
#  else
claus
parents: 220
diff changeset
   164
#   if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED)
2979
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   165
#    ifdef INT64
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   166
#     define LONGLONG INT64
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   167
#    else
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   168
#     define LONGLONG long long
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   169
#   endif
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   170
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   171
		op = __InstPtr(newobj)->i_instvars;
249
claus
parents: 220
diff changeset
   172
		if (nInstVars > 8) {
claus
parents: 220
diff changeset
   173
		    *op++ = nil;    /* for alignment */
claus
parents: 220
diff changeset
   174
		    nInstVars--;
claus
parents: 220
diff changeset
   175
		    while (nInstVars >= 8) {
2979
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   176
			*(LONGLONG *)op = 0;
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   177
			((LONGLONG *)op)[1] = 0;
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   178
			((LONGLONG *)op)[2] = 0;
6bb06c5e49d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
   179
			((LONGLONG *)op)[3] = 0;
249
claus
parents: 220
diff changeset
   180
			op += 8;
claus
parents: 220
diff changeset
   181
			nInstVars -= 8;
claus
parents: 220
diff changeset
   182
		    }
claus
parents: 220
diff changeset
   183
		}
claus
parents: 220
diff changeset
   184
		while (nInstVars) {
claus
parents: 220
diff changeset
   185
		    *op++ = 0;
claus
parents: 220
diff changeset
   186
		    nInstVars--;
claus
parents: 220
diff changeset
   187
		}
claus
parents: 220
diff changeset
   188
#   else
claus
parents: 220
diff changeset
   189
#    if defined(FAST_ARRAY_MEMSET)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   190
		memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
249
claus
parents: 220
diff changeset
   191
#    else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   192
		op = __InstPtr(newobj)->i_instvars;
2950
d5fae0fb75d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2915
diff changeset
   193
#     if defined(INT64)
d5fae0fb75d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2915
diff changeset
   194
		while (nInstVars > 1) {
d5fae0fb75d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2915
diff changeset
   195
		    *((INT64 *)op) = 0;
d5fae0fb75d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2915
diff changeset
   196
		    nInstVars -= 2;
d5fae0fb75d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2915
diff changeset
   197
		    op += 2;
d5fae0fb75d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2915
diff changeset
   198
		}
d5fae0fb75d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2915
diff changeset
   199
#     endif
249
claus
parents: 220
diff changeset
   200
		while (nInstVars--)
claus
parents: 220
diff changeset
   201
		    *op++ = nil;
claus
parents: 220
diff changeset
   202
#    endif
claus
parents: 220
diff changeset
   203
#   endif
claus
parents: 220
diff changeset
   204
#  endif
claus
parents: 220
diff changeset
   205
# else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
   206
		op = __InstPtr(newobj)->i_instvars;
249
claus
parents: 220
diff changeset
   207
		while (nInstVars--)
claus
parents: 220
diff changeset
   208
		    *op++ = nil;
claus
parents: 220
diff changeset
   209
# endif
claus
parents: 220
diff changeset
   210
#endif
claus
parents: 220
diff changeset
   211
		RETURN ( newobj );
357
claus
parents: 356
diff changeset
   212
	    } else {
claus
parents: 356
diff changeset
   213
		/*
claus
parents: 356
diff changeset
   214
		 * a GC will happen ...
claus
parents: 356
diff changeset
   215
		 * have to protect all context stuff
claus
parents: 356
diff changeset
   216
		 * (especially for self, but also for backtrace in case of
claus
parents: 356
diff changeset
   217
		 *  allocation failure)
claus
parents: 356
diff changeset
   218
		 */
834
c68ed1088b42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   219
		__PROTECT_CONTEXT__
3979
46a2da9b917d renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3730
diff changeset
   220
		newobj = __STX___new(instsize);
834
c68ed1088b42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   221
		__UNPROTECT_CONTEXT__
357
claus
parents: 356
diff changeset
   222
		if (newobj != nil) {
claus
parents: 356
diff changeset
   223
		    goto ok;
claus
parents: 356
diff changeset
   224
		}
249
claus
parents: 220
diff changeset
   225
	    }
claus
parents: 220
diff changeset
   226
	}
claus
parents: 220
diff changeset
   227
    }
claus
parents: 220
diff changeset
   228
%}.
claus
parents: 220
diff changeset
   229
    "
claus
parents: 220
diff changeset
   230
     arrive here if something went wrong ...
claus
parents: 220
diff changeset
   231
     figure out what it was
claus
parents: 220
diff changeset
   232
    "
claus
parents: 220
diff changeset
   233
    (anInteger isMemberOf:SmallInteger) ifFalse:[
claus
parents: 220
diff changeset
   234
	"
claus
parents: 220
diff changeset
   235
	 the argument is either not an integer,
claus
parents: 220
diff changeset
   236
	 or a LargeInteger (which means that its definitely too big)
claus
parents: 220
diff changeset
   237
	"
claus
parents: 220
diff changeset
   238
	self error:'argument to new: must be Integer'.
claus
parents: 220
diff changeset
   239
	^ nil
claus
parents: 220
diff changeset
   240
    ].
claus
parents: 220
diff changeset
   241
    (anInteger < 0) ifTrue:[
claus
parents: 220
diff changeset
   242
	"
claus
parents: 220
diff changeset
   243
	 the argument is negative,
claus
parents: 220
diff changeset
   244
	"
claus
parents: 220
diff changeset
   245
	self error:'bad (negative) argument to new:'.
claus
parents: 220
diff changeset
   246
	^ nil
claus
parents: 220
diff changeset
   247
    ].
claus
parents: 220
diff changeset
   248
    "
claus
parents: 220
diff changeset
   249
     memory allocation failed.
claus
parents: 220
diff changeset
   250
     When we arrive here, there was no memory, even after
claus
parents: 220
diff changeset
   251
     a garbage collect. 
claus
parents: 220
diff changeset
   252
     This means, that the VM wanted to get some more memory from the 
claus
parents: 220
diff changeset
   253
     Operatingsystem, which was not kind enough to give it.
claus
parents: 220
diff changeset
   254
     Bad luck - you should increase the swap space on your machine.
claus
parents: 220
diff changeset
   255
    "
claus
parents: 220
diff changeset
   256
    ^ ObjectMemory allocationFailureSignal raise.
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   257
!
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   258
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   259
new:anInteger
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   260
    "return an instance of myself with anInteger indexed variables.
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   261
     Redefined here to save a few cycles when executed.
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   262
     (Since this is often called, its worth giving it an extra ilc-slot.
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   263
      Future versions of stc will do this automatically.)"
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   264
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   265
    ^ self basicNew:anInteger
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   267
    "Modified: 23.4.1996 / 15:52:15 / cg"
360
claus
parents: 359
diff changeset
   268
! !
claus
parents: 359
diff changeset
   269
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
   270
!Array class methodsFor:'queries'!
345
claus
parents: 328
diff changeset
   271
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   272
isBuiltInClass
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   273
    "return true if this class is known by the run-time-system.
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   274
     Here, true is returned for myself, false for subclasses."
345
claus
parents: 328
diff changeset
   275
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   276
    ^ self == Array
1243
955b7f55f7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   277
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   278
    "Modified: 23.4.1996 / 15:55:06 / cg"
249
claus
parents: 220
diff changeset
   279
! !
claus
parents: 220
diff changeset
   280
10796
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   281
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   282
!Array methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   283
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   284
at:index
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   285
    "return the indexed instance variable with index, anInteger.
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   286
     Reimplemented here to avoid the additional at:->basicAt: send
1730
e668db8cbae0 comment
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   287
     (which we can do here, since when arriving here, #at: is obviously not 
e668db8cbae0 comment
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   288
      redefined in a subclass).
577
106bfaa8db3c commentary
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   289
     This method is the same as basicAt:."
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   290
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   291
%{  /* NOCONTEXT */
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   292
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   293
    REGISTER int indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   294
    REGISTER OBJ slf;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   295
    REGISTER unsigned int nIndex;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   296
    REGISTER OBJ cls;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   297
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   298
    if (__isSmallInteger(index)) {
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   299
	indx = __intVal(index) - 1;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   300
	slf = self;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   301
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   302
	nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   303
	if ((cls = __qClass(slf)) != Array) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   304
	    if (indx < 0) goto badIndex;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   305
	    indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   306
	}
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   307
	if ((unsigned)indx < (unsigned)nIndex) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   308
	    RETURN ( __InstPtr(slf)->i_instvars[indx] );
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   309
	}
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   310
    }
4385
dbe7d1e8c54c oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   311
badIndex: ;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   312
%}.
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   313
"/    ^ super at:index
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   314
    ^ super basicAt:index   "/ knowing that super-#at: does #basicAt:
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   315
!
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   316
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   317
at:index put:anObject
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   318
    "store the 2nd arg, anObject as indexed instvar with index, anInteger.
1219
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   319
     Returns anObject (sigh).
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   320
     Reimplemented here to avoid the additional at:put:->basicAt:put: send
1730
e668db8cbae0 comment
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   321
     (which we can do here, since when arriving here, #atput:: is obviously not
e668db8cbae0 comment
Claus Gittinger <cg@exept.de>
parents: 1695
diff changeset
   322
      redefined in a subclass).
577
106bfaa8db3c commentary
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   323
     This method is the same as basicAt:put:."
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   324
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   325
%{  /* NOCONTEXT */
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   326
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   327
    REGISTER int indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   328
    REGISTER OBJ slf;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   329
    REGISTER unsigned int nIndex;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   330
    REGISTER OBJ cls;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   331
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   332
    if (__isSmallInteger(index)) {
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   333
	indx = __intVal(index) - 1;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   334
	slf = self;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   335
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   336
	nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   337
	if ((cls = __qClass(slf)) != Array) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   338
	    if (indx < 0) goto badIndex;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   339
	    indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   340
	}
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   341
	if ((unsigned)indx < (unsigned)nIndex) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   342
	    __InstPtr(slf)->i_instvars[indx] = anObject;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   343
	    __STORE(slf, anObject);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   344
	    RETURN ( anObject );
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   345
	}
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   346
    }
4385
dbe7d1e8c54c oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   347
badIndex: ;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   348
%}.
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   349
"/    ^ super at:index put:anObject
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   350
    ^ super basicAt:index put:anObject  "/ knowing that super-#at:put: does #basicAt:put:
1219
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   351
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   352
    "Modified: 19.4.1996 / 11:16:42 / cg"
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   353
!
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   354
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   355
basicAt:index
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   356
    "return the indexed instance variable with index, anInteger
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   357
     - added here for speed"
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   358
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   359
%{  /* NOCONTEXT */
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   360
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   361
    REGISTER int indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   362
    REGISTER OBJ slf;
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   363
    REGISTER unsigned int nIndex;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   364
    REGISTER OBJ cls;
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   365
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   366
    if (__isSmallInteger(index)) {
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   367
	indx = __intVal(index) - 1;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   368
	slf = self;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   369
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   370
	nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   371
	if ((cls = __qClass(slf)) != Array) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   372
	    if (indx < 0) goto badIndex;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   373
	    indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   374
	}
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   375
	if ((unsigned)indx < (unsigned)nIndex) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   376
	    RETURN ( __InstPtr(slf)->i_instvars[indx] );
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   377
	}
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   378
    }
4385
dbe7d1e8c54c oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   379
badIndex: ;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   380
%}.
549
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   381
    ^ super basicAt:index
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   382
!
2a8e44b511c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 543
diff changeset
   383
77
6c38ca59927f *** empty log message ***
claus
parents: 47
diff changeset
   384
basicAt:index put:anObject
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   385
    "store the 2nd arg, anObject as indexed instvar with index, anInteger.
1219
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   386
     Returns anObject (sigh).
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   387
     - added here for speed"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   388
a27a279701f8 Initial revision
claus
parents:
diff changeset
   389
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   390
a27a279701f8 Initial revision
claus
parents:
diff changeset
   391
    REGISTER int indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   392
    REGISTER OBJ slf;
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   393
    REGISTER unsigned int nIndex;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   394
    REGISTER OBJ cls;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   395
249
claus
parents: 220
diff changeset
   396
    if (__isSmallInteger(index)) {
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   397
	indx = __intVal(index) - 1;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   398
	slf = self;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   399
4474
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   400
	nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   401
	if ((cls = __qClass(slf)) != Array) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   402
	    if (indx < 0) goto badIndex;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   403
	    indx += __intVal(__ClassInstPtr(cls)->c_ninstvars);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   404
	}
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   405
	if ((unsigned)indx < (unsigned)nIndex) {
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   406
	    __InstPtr(slf)->i_instvars[indx] = anObject;
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   407
	    __STORE(slf, anObject);
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   408
	    RETURN ( anObject );
d34823aa554e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   409
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   410
    }
4385
dbe7d1e8c54c oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   411
badIndex: ;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   412
%}.
77
6c38ca59927f *** empty log message ***
claus
parents: 47
diff changeset
   413
    ^ super basicAt:index put:anObject
1219
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   414
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   415
    "Modified: 19.4.1996 / 11:14:26 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   416
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   417
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   418
!Array methodsFor:'converting'!
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   419
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   420
asArray
5531
27f62fc8193f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5511
diff changeset
   421
    "return the receiver as an array - thats the receiver itself."
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   422
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   423
    "could be an instance of a subclass..."
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   424
    self class == Array ifTrue:[
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   425
	^ self
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   426
    ].
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   427
    ^ super asArray
1243
955b7f55f7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   428
955b7f55f7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   429
    "Modified: 22.4.1996 / 12:42:09 / cg"
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   430
! !
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   431
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   432
!Array methodsFor:'copying'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   433
a27a279701f8 Initial revision
claus
parents:
diff changeset
   434
copyWith:something
220
9079bd965dd7 keysAndValuesDo: fix
claus
parents: 219
diff changeset
   435
    "return a new collection containing the receivers elements
9079bd965dd7 keysAndValuesDo: fix
claus
parents: 219
diff changeset
   436
     and the single new element, newElement. 
9079bd965dd7 keysAndValuesDo: fix
claus
parents: 219
diff changeset
   437
     This is different from concatentation, which expects another collection
9079bd965dd7 keysAndValuesDo: fix
claus
parents: 219
diff changeset
   438
     as argument, but equivalent to copy-and-addLast.
370
claus
parents: 369
diff changeset
   439
     Reimplemented for speed if receiver is an Array.
claus
parents: 369
diff changeset
   440
     (since the inherited copyWith uses replaceFromTo:, which is also
claus
parents: 369
diff changeset
   441
      tuned, it is questionable, if we need this)"
claus
parents: 369
diff changeset
   442
claus
parents: 369
diff changeset
   443
%{  /* NOCONTEXT */
4122
7e3b6b267c06 comment
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   444
    OBJ nObj;
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   445
    unsigned int sz;
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   446
    unsigned int nIndex;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   447
    REGISTER OBJ *srcP, *dstP;
293
31df3850e98c *** empty log message ***
claus
parents: 287
diff changeset
   448
    REGISTER int spc;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   449
328
claus
parents: 325
diff changeset
   450
    if (__qClass(self) == Array) {
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   451
        sz = __qSize(self) + sizeof(OBJ);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   452
        __PROTECT2__(something, self);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   453
        __qAlignedNew(nObj, sz);        /* OBJECT ALLOCATION */
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   454
        __UNPROTECT2__(self, something);
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   455
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   456
        if (nObj) {
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   457
            __InstPtr(nObj)->o_class = Array;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   458
            __qSTORE(nObj, Array);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   459
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   460
            nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   461
            /* 
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   462
             * sorry: 
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   463
             *   cannot use bcopy, since we must take care of stores ... 
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   464
             *   could check for: notRemembered + inOld + notLifoRem
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   465
             *                  + not incrGCRunning
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   466
             * but: copyWith is not heavily used by real programmers ...
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   467
             */
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   468
            spc = __qSpace(nObj);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   469
            srcP = __arrayVal(self);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   470
            dstP = __arrayVal(nObj);
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
   471
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   472
#ifdef __UNROLL_LOOPS__
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   473
            while (nIndex >= 4) {
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   474
                OBJ element;
4122
7e3b6b267c06 comment
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   475
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   476
                element = srcP[0];
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   477
                dstP[0] = element;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   478
                __STORE_SPC(nObj, element, spc);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   479
                element = srcP[1];
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   480
                dstP[1] = element;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   481
                __STORE_SPC(nObj, element, spc);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   482
                element = srcP[2];
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   483
                dstP[2] = element;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   484
                __STORE_SPC(nObj, element, spc);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   485
                element = srcP[3];
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   486
                dstP[3] = element;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   487
                __STORE_SPC(nObj, element, spc);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   488
                srcP += 4;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   489
                dstP += 4;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   490
                nIndex -= 4;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   491
            }
393
claus
parents: 388
diff changeset
   492
#endif
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   493
            while (nIndex--) {
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   494
                OBJ element;
4122
7e3b6b267c06 comment
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   495
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   496
                element = *srcP++;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   497
                *dstP++ = element;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   498
                __STORE_SPC(nObj, element, spc);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   499
            }
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   500
            *dstP = something;
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   501
            __STORE_SPC(nObj, something, spc);
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   502
            RETURN ( nObj );
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7600
diff changeset
   503
        }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   504
    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   505
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   506
    ^ super copyWith:something
a27a279701f8 Initial revision
claus
parents:
diff changeset
   507
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   508
216
a8abff749575 *** empty log message ***
claus
parents: 155
diff changeset
   509
!Array methodsFor:'enumerating'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   510
10796
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   511
addAllNonNilElementsTo:aCollection
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   512
    "add all nonNil elements of the receiver to aCollection.
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   513
     Return aCollection.
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   514
     Redefined here for slightly more speed."
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   515
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   516
    |stop "{ Class: SmallInteger }"|
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   517
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   518
    stop := self size.
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   519
    1 to:stop do:[:idx |
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   520
        |each|
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   521
        each := self at:idx.
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   522
        each notNil ifTrue:[
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   523
            aCollection add:each.
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   524
        ].
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   525
    ].
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   526
    ^ aCollection
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   527
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   528
    "
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   529
     #(1 2 3 4 5 1 2 3 symbol 'string' nil) addAllNonNilElementsTo:Set new
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   530
    "
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   531
!
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
   532
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   533
addAllTo:aCollection
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   534
    "add all elements of the receiver to aCollection.
8603
9187c6f1a291 comment
Claus Gittinger <cg@exept.de>
parents: 8442
diff changeset
   535
     Return aCollection.
9187c6f1a291 comment
Claus Gittinger <cg@exept.de>
parents: 8442
diff changeset
   536
     Redefined here for slightly more speed."
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   537
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   538
    |stop "{ Class: SmallInteger }"|
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   539
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   540
    stop := self size.
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   541
    1 to:stop do:[:idx |
8603
9187c6f1a291 comment
Claus Gittinger <cg@exept.de>
parents: 8442
diff changeset
   542
        aCollection add:(self at:idx)
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   543
    ].
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   544
    ^ aCollection
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   545
!
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   546
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   547
do:aBlock
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   548
    "evaluate the argument, aBlock for each element in the collection.
4122
7e3b6b267c06 comment
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   549
     - reimplemented for speed, since this is used by many higher
7e3b6b267c06 comment
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   550
       level collections"
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   551
2202
Claus Gittinger <cg@exept.de>
parents: 2185
diff changeset
   552
    | sz "{ Class: SmallInteger }"|
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   553
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   554
    sz := self size.
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   555
%{
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   556
    REGISTER OBJFUNC codeVal;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   557
    REGISTER int index;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   558
    unsigned int nIndex;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   559
    static struct inlineCache val = _ILC1;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   560
    REGISTER OBJ rHome;
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   561
    int actualSize;
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   562
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   563
    {
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   564
	OBJ mySelf = self;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   565
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   566
	index = __intVal(__ClassInstPtr(__qClass(mySelf))->c_ninstvars);
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   567
	actualSize = __BYTES2OBJS__(__qSize(mySelf) - OHDR_SIZE);
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   568
    }
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   569
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   570
    nIndex = index + __intVal(sz);
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   571
    if (nIndex <= actualSize) {
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   572
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   573
	if (__isBlockLike(aBlock)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
   574
	 && (__BlockInstPtr(aBlock)->b_nargs == __mkSmallInteger(1))) {
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   575
	    {
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   576
		/*
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   577
		 * the most common case: a static compiled block, with home on the stack ...
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   578
		 */
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   579
		REGISTER OBJFUNC codeVal;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   580
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   581
		if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil)
2678
37eec0043bdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
   582
#ifdef PARANOIA
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   583
		 && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC)))
2678
37eec0043bdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
   584
#endif
37eec0043bdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
   585
		) {
2254
5e3cb9e7e682 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   586
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   587
#ifdef NEW_BLOCK_CALL
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   588
#                   define BLOCK_ARG        aBlock
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   589
#else
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   590
#                   define BLOCK_ARG        rHome
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   591
		    REGISTER OBJ rHome;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   592
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   593
		    rHome = __BlockInstPtr(aBlock)->b_home;
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   594
		    if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   595
#endif
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   596
		    {
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   597
2878
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   598
			    /*
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   599
			     * boy; what an ugly looking piece of code ...
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   600
			     * however, this software pipelined thing has no taken conditional
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   601
			     * branches in the normal case and is almost twice as fast to even
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   602
			     * what an unrolling optimizing compiler produces from the loop below ...
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   603
			     * notice, that those gotos expand to forward branches (which are predicted
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   604
			     * as NOT taken by most machines ... which is exactly what we want)
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
   605
			     */
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   606
			    REGISTER OBJ el;
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   607
#ifdef __UNROLL_LOOPS__
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   608
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   609
			    {
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   610
				int i8;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   611
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   612
				while ((i8 = index+8) < nIndex) {
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   613
				    el = __InstPtr(self)->i_instvars[index];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   614
				    if (InterruptPending != nil) goto interrupt0;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   615
		continue0:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   616
				    (*codeVal)(BLOCK_ARG, el);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   617
				    el = __InstPtr(self)->i_instvars[index+1];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   618
				    if (InterruptPending != nil) goto interrupt1;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   619
		continue1:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   620
				    (*codeVal)(BLOCK_ARG, el);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   621
				    el = __InstPtr(self)->i_instvars[index+2];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   622
				    if (InterruptPending != nil) goto interrupt2;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   623
		continue2:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   624
				    (*codeVal)(BLOCK_ARG, el);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   625
				    el = __InstPtr(self)->i_instvars[index+3];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   626
				    if (InterruptPending != nil) goto interrupt3;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   627
		continue3:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   628
				    (*codeVal)(BLOCK_ARG, el);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   629
				    el = __InstPtr(self)->i_instvars[index+4];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   630
				    if (InterruptPending != nil) goto interrupt4;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   631
		continue4:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   632
				    (*codeVal)(BLOCK_ARG, el);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   633
				    el = __InstPtr(self)->i_instvars[index+5];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   634
				    if (InterruptPending != nil) goto interrupt5;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   635
		continue5:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   636
				    (*codeVal)(BLOCK_ARG, el);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   637
				    el = __InstPtr(self)->i_instvars[index+6];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   638
				    if (InterruptPending != nil) goto interrupt6;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   639
		continue6:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   640
				    (*codeVal)(BLOCK_ARG, el);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   641
				    el = __InstPtr(self)->i_instvars[index+7];
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   642
				    if (InterruptPending != nil) goto interrupt7;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   643
		continue7:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   644
				    (*codeVal)(BLOCK_ARG, el);
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   645
				    index = i8;
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   646
				}
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   647
			    }
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   648
#endif /* __UNROLL_LOOPS__ */
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   649
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   650
			    for (; index < nIndex; index++) {
2217
Claus Gittinger <cg@exept.de>
parents: 2216
diff changeset
   651
				el = __InstPtr(self)->i_instvars[index];
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   652
				if (InterruptPending != nil) goto interruptX;
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   653
		continueX:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   654
				(*codeVal)(BLOCK_ARG, el);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   655
			    }
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   656
			    RETURN (self);
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   657
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   658
#ifdef __UNROLL_LOOPS__
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   659
		interrupt0:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   660
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   661
			    el = __InstPtr(self)->i_instvars[index];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   662
			    goto continue0;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   663
		interrupt1:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   664
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   665
			    el = __InstPtr(self)->i_instvars[index+1];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   666
			    goto continue1;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   667
		interrupt2:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   668
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   669
			    el = __InstPtr(self)->i_instvars[index+2];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   670
			    goto continue2;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   671
		interrupt3:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   672
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   673
			    el = __InstPtr(self)->i_instvars[index+3];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   674
			    goto continue3;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   675
		interrupt4:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   676
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   677
			    el = __InstPtr(self)->i_instvars[index+4];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   678
			    goto continue4;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   679
		interrupt5:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   680
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   681
			    el = __InstPtr(self)->i_instvars[index+5];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   682
			    goto continue5;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   683
		interrupt6:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   684
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   685
			    el = __InstPtr(self)->i_instvars[index+6];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   686
			    goto continue6;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   687
		interrupt7:
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   688
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   689
			    el = __InstPtr(self)->i_instvars[index+7];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   690
			    goto continue7;
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   691
#endif /* __UNROLL_LOOPS__ */
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   692
		interruptX:
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   693
			    __interruptL(@line);
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   694
			    el = __InstPtr(self)->i_instvars[index];
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   695
			    goto continueX;
3500
90eb689740cc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3485
diff changeset
   696
		    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   697
		}
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   698
	    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   699
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   700
	    /*
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   701
	     * sorry, must check code-pointer in the loop
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   702
	     * it could be recompiled or flushed
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   703
	     */
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   704
#           undef BLOCK_ARG
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   705
#ifdef NEW_BLOCK_CALL
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   706
#           define BLOCK_ARG        aBlock
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   707
#           define IBLOCK_ARG       nil
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   708
#else
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   709
#           define BLOCK_ARG        (__BlockInstPtr(aBlock)->b_home)
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   710
#           define IBLOCK_ARG       (__BlockInstPtr(aBlock)->b_home)
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   711
#endif
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   712
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   713
	    for (; index < nIndex; index++) {
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   714
		REGISTER OBJFUNC codeVal;
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   715
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   716
		if (InterruptPending != nil) __interruptL(@line);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   717
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   718
		if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   719
		    (*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   720
		} else {
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   721
		    if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   722
			/*
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   723
			 * arg is a compiled block with bytecode -
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   724
			 * directly call interpreter without going through Block>>value
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   725
			 */
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   726
#ifdef PASS_ARG_POINTER
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   727
			__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   728
#else
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   729
			__interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   730
#endif
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   731
		    } else {
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   732
			(*val.ilc_func)(aBlock, 
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   733
					    @symbol(value:), 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   734
					    nil, &val, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   735
					    __InstPtr(self)->i_instvars[index]);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   736
		    }
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   737
		}
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   738
	    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   739
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   740
#           undef BLOCK_ARG
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   741
#           undef IBLOCK_ARG
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   742
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   743
	    RETURN (self );
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   744
	}
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   745
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   746
	/*
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   747
	 * not a block - send it #value:
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   748
	 */
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   749
	for (; index < nIndex; index++) {
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   750
	    if (InterruptPending != nil) __interruptL(@line);
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   751
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   752
	    (*val.ilc_func)(aBlock, 
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   753
				@symbol(value:), 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   754
				nil, &val, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   755
				__InstPtr(self)->i_instvars[index]);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   756
	}
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   757
	RETURN ( self );
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   758
    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   759
    /* 
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
   760
     * I am something, not handled here
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   761
     */
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   762
%}.
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   763
    ^ super do:aBlock
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   764
!
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   765
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   766
from:start to:stop do:aBlock
a27a279701f8 Initial revision
claus
parents:
diff changeset
   767
    "evaluate the argument, aBlock for the elements starting at index start
a27a279701f8 Initial revision
claus
parents:
diff changeset
   768
     up to (and including) stop in the collection.
4122
7e3b6b267c06 comment
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   769
     - reimplemented for speed, since this is used by many higher
7e3b6b267c06 comment
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   770
       level collections"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   771
a27a279701f8 Initial revision
claus
parents:
diff changeset
   772
%{
a27a279701f8 Initial revision
claus
parents:
diff changeset
   773
    REGISTER OBJFUNC codeVal;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   774
    REGISTER int index;
2
claus
parents: 1
diff changeset
   775
    REGISTER OBJ rHome;
2052
9fdab6cbecfa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
   776
    OBJ slf;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   777
    int nIndex, nInsts;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   778
    static struct inlineCache val = _ILC1;
3484
79a08dfa50c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
   779
    int indexHigh;
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
   780
    OBJ myClass;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   781
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
   782
    slf = self;
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
   783
    myClass = __qClass(slf);
5347
21b418ac4cc3 oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents: 5049
diff changeset
   784
21b418ac4cc3 oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents: 5049
diff changeset
   785
    if ( __bothSmallInteger(start, stop)
21b418ac4cc3 oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents: 5049
diff changeset
   786
     && ((index = __intVal(start)) > 0) ) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   787
	indexHigh = __intVal(stop);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   788
	nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   789
	if (myClass != @global(Array)) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   790
	    nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   791
	    index += nInsts;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   792
	    indexHigh += nInsts;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   793
	}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   794
	if (indexHigh <= nIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   795
	    OBJ __aBlock = aBlock;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   796
	    int n;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   797
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   798
	    index--;                            /* 0-based */
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   799
	    n = indexHigh - index;
3484
79a08dfa50c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
   800
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   801
	    if (__isBlockLike(__aBlock)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
   802
	     && (__BlockInstPtr(__aBlock)->b_nargs == __mkSmallInteger(1))) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   803
		{
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   804
		    /*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   805
		     * the most common case: a static compiled block, with home on the stack ...
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   806
		     */
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   807
		    REGISTER OBJFUNC codeVal;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   808
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   809
		    if (((codeVal = __BlockInstPtr(__aBlock)->b_code) != (OBJFUNC)nil)
2678
37eec0043bdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
   810
#ifdef PARANOIA
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   811
		     && (! ((INT)(__BlockInstPtr(__aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC)))
2678
37eec0043bdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
   812
#endif
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   813
		    ) {
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   814
#ifdef NEW_BLOCK_CALL
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   815
#                       define BLOCK_ARG        aBlock
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   816
#else
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   817
#                       define BLOCK_ARG        rHome
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   818
			REGISTER OBJ rHome;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   819
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   820
			rHome = __BlockInstPtr(__aBlock)->b_home;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   821
			if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   822
#endif
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   823
			{
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   824
			    REGISTER OBJ el;
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
   825
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   826
#ifdef __UNROLL_LOOPS__
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   827
			    /*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   828
			     * boy; what an ugly looking piece of code ...
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   829
			     * however, this software pipelined thing has no taken conditional
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   830
			     * branches in the normal case and is almost twice as fast to even
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   831
			     * what an unrolling optimizing compiler produces from the loop below ...
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   832
			     * notice, that those gotos expand to forward branches (which are predicted
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   833
			     * as NOT taken by most machines ... which is exactly what we want)
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   834
			     */
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   835
			    {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   836
				while ( n >= 8) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   837
				    el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   838
				    if (InterruptPending != nil) goto interrupt0;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   839
		continue0:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   840
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   841
				    el = __InstPtr(self)->i_instvars[index+1];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   842
				    if (InterruptPending != nil) goto interrupt1;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   843
		continue1:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   844
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   845
				    el = __InstPtr(self)->i_instvars[index+2];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   846
				    if (InterruptPending != nil) goto interrupt2;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   847
		continue2:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   848
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   849
				    el = __InstPtr(self)->i_instvars[index+3];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   850
				    if (InterruptPending != nil) goto interrupt3;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   851
		continue3:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   852
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   853
				    el = __InstPtr(self)->i_instvars[index+4];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   854
				    if (InterruptPending != nil) goto interrupt4;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   855
		continue4:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   856
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   857
				    el = __InstPtr(self)->i_instvars[index+5];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   858
				    if (InterruptPending != nil) goto interrupt5;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   859
		continue5:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   860
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   861
				    el = __InstPtr(self)->i_instvars[index+6];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   862
				    if (InterruptPending != nil) goto interrupt6;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   863
		continue6:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   864
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   865
				    el = __InstPtr(self)->i_instvars[index+7];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   866
				    if (InterruptPending != nil) goto interrupt7;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   867
		continue7:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   868
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   869
				    n -= 8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   870
				    index += 8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   871
				}
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   872
# ifdef __UNROLL_LOOPS2__ /* this makes small loops slower */
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   873
				if (n >= 4) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   874
				    el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   875
				    if (InterruptPending != nil) goto interrupt0b;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   876
		continue0b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   877
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   878
				    el = __InstPtr(self)->i_instvars[index+1];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   879
				    if (InterruptPending != nil) goto interrupt1b;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   880
		continue1b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   881
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   882
				    el = __InstPtr(self)->i_instvars[index+2];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   883
				    if (InterruptPending != nil) goto interrupt2b;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   884
		continue2b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   885
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   886
				    el = __InstPtr(self)->i_instvars[index+3];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   887
				    if (InterruptPending != nil) goto interrupt3b;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   888
		continue3b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   889
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   890
				    n -= 4;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   891
				    index += 4;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   892
				}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   893
				if (n >= 2) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   894
				    el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   895
				    if (InterruptPending != nil) goto interrupt0c;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   896
		continue0c:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   897
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   898
				    el = __InstPtr(self)->i_instvars[index+1];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   899
				    if (InterruptPending != nil) goto interrupt1c;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   900
		continue1c:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   901
				    (*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   902
				    n -= 2;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   903
				    index += 2;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   904
				}
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   905
# endif /* __UNROLL_LOOPS2__ */
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   906
			    }
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   907
#endif /* __UNROLL_LOOPS__ */
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   908
			    while (n > 0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   909
				el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   910
				if (InterruptPending != nil) goto interruptX;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   911
		continueX:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   912
				(*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   913
				n--;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   914
				index++;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   915
			    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   916
			    RETURN (self);
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
   917
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   918
#ifdef __UNROLL_LOOPS__
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   919
		interrupt0:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   920
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   921
			    goto continue0;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   922
		interrupt1:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   923
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   924
			    goto continue1;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   925
		interrupt2:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   926
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   927
			    goto continue2;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   928
		interrupt3:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   929
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   930
			    goto continue3;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   931
		interrupt4:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   932
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+4];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   933
			    goto continue4;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   934
		interrupt5:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   935
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+5];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   936
			    goto continue5;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   937
		interrupt6:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   938
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+6];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   939
			    goto continue6;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   940
		interrupt7:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   941
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+7];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   942
			    goto continue7;
3484
79a08dfa50c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
   943
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   944
# ifdef __UNROLL_LOOPS2__
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   945
		interrupt0b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   946
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   947
			    goto continue0b;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   948
		interrupt1b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   949
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   950
			    goto continue1b;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   951
		interrupt2b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   952
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   953
			    goto continue2b;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   954
		interrupt3b:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   955
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   956
			    goto continue3b;
3484
79a08dfa50c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
   957
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   958
		interrupt0c:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   959
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   960
			    goto continue0c;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   961
		interrupt1c:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   962
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   963
			    goto continue1c;
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   964
# endif /* __UNROLL_LOOPS2__ */
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   965
#endif /* __UNROLL_LOOPS__ */
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   966
		interruptX:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   967
			    __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   968
			    goto continueX;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   969
			}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   970
		    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   971
		}
370
claus
parents: 369
diff changeset
   972
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   973
		/*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   974
		 * sorry, must check code-pointer in the loop
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   975
		 * it could be recompiled or flushed
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   976
		 */
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   977
#               undef BLOCK_ARG
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   978
#ifdef NEW_BLOCK_CALL
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   979
#               define BLOCK_ARG        aBlock
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   980
#               define IBLOCK_ARG       nil
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   981
#else
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   982
#               define BLOCK_ARG        (__BlockInstPtr(aBlock)->b_home)
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   983
#               define IBLOCK_ARG       (__BlockInstPtr(aBlock)->b_home)
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   984
#endif
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   985
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   986
		while (n > 0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   987
		    REGISTER OBJFUNC codeVal;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   988
		    OBJ el;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   989
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   990
		    el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   991
		    if (InterruptPending != nil) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   992
			__interruptL(@line);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   993
			el = __InstPtr(self)->i_instvars[index];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   994
		    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   995
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   996
		    if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   997
			(*codeVal)(BLOCK_ARG, el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   998
		    } else {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
   999
			if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1000
			    /*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1001
			     * arg is a compiled block with bytecode -
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1002
			     * directly call interpreter without going through Block>>value
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1003
			     */
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1004
#ifdef PASS_ARG_POINTER
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1005
			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &el);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1006
#else
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1007
			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, el);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1008
#endif
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1009
			} else {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1010
			    (*val.ilc_func)(aBlock, 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1011
					    @symbol(value:), 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1012
					    nil, &val, 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1013
					    el);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1014
			}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1015
		    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1016
		    n--;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1017
		    index++;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1018
		}
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1019
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1020
#               undef BLOCK_ARG
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1021
#               undef IBLOCK_ARG
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1022
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1023
		RETURN (self );
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1024
	    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1025
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1026
	    /*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1027
	     * not a block - send it #value:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1028
	     */
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1029
	    while (n > 0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1030
		if (InterruptPending != nil) __interruptL(@line);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1031
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1032
		(*val.ilc_func)(aBlock, 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1033
				@symbol(value:), 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1034
				nil, &val, 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1035
				__InstPtr(self)->i_instvars[index]);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1036
		n--;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1037
		index++;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1038
	    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1039
	    RETURN ( self );
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1040
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1041
    }
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1042
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1043
    ^ super from:start to:stop do:aBlock
5347
21b418ac4cc3 oops: from:to:do: failed badly when stopIndex was < startIndex.
Claus Gittinger <cg@exept.de>
parents: 5049
diff changeset
  1044
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1045
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1046
42
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1047
from:start to:stop reverseDo:aBlock
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1048
    "evaluate the argument, aBlock for the elements starting at index start
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1049
     up to (and including) stop in the collection. Step in reverse order.
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1050
     - reimplemented for speed"
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1051
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1052
%{
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1053
    REGISTER OBJFUNC codeVal;
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1054
    REGISTER int index;
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1055
    REGISTER OBJ rHome;
586
cab695f942a6 weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
  1056
    int nIndex;
42
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1057
    static struct inlineCache val = _ILC1;
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1058
    int indexLow, indexHigh;
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1059
586
cab695f942a6 weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
  1060
    if (__bothSmallInteger(start, stop)
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1061
     && (__qClass(self) == @global(Array))
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1062
     && ((indexLow = __intVal(start)) > 0)) {
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1063
	indexHigh = __intVal(stop);
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1064
	nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1065
	if (indexHigh <= nIndex) {
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1066
	    indexLow--;
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1067
	    indexHigh--;
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1068
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1069
	    if (__isBlockLike(aBlock)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1070
	     && (__BlockInstPtr(aBlock)->b_nargs == __mkSmallInteger(1))) {
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1071
#               undef BLOCK_ARG
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1072
#ifdef NEW_BLOCK_CALL
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1073
#               define BLOCK_ARG        aBlock
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1074
#               define IBLOCK_ARG       nil
42
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1075
#else
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1076
#               define BLOCK_ARG        (__BlockInstPtr(aBlock)->b_home)
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1077
#               define IBLOCK_ARG       (__BlockInstPtr(aBlock)->b_home)
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1078
#endif
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1079
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1080
		for (index=indexHigh; index >= indexLow; index--) {
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1081
		    REGISTER OBJFUNC codeVal;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1082
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1083
		    if (InterruptPending != nil) __interruptL(@line);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1084
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1085
		    if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1086
			(*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1087
		    } else {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1088
			if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1089
			    /*
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1090
			     * arg is a compiled block with bytecode -
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1091
			     * directly call interpreter without going through Block>>value
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1092
			     */
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1093
#ifdef PASS_ARG_POINTER
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1094
			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1095
#else
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1096
			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
42
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1097
#endif
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1098
			} else {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1099
			    (*val.ilc_func)(aBlock, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1100
					    @symbol(value:), 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1101
					    nil, &val, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1102
					    __InstPtr(self)->i_instvars[index]);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1103
			}
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1104
		    }
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1105
		}
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1106
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1107
#               undef BLOCK_ARG
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1108
#               undef IBLOCK_ARG
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1109
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1110
		RETURN (self );
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1111
	    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1112
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1113
	    /*
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1114
	     * not a block - send it #value:
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1115
	     */
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1116
	    for (index=indexHigh; index >= indexLow; index--) {
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1117
		if (InterruptPending != nil) __interruptL(@line);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1118
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1119
		(*val.ilc_func)(aBlock, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1120
				@symbol(value:), 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1121
				nil, &val, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1122
				__InstPtr(self)->i_instvars[index]);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1123
	    }
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1124
	    RETURN ( self );
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1125
	}
42
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1126
    }
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1127
%}.
42
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1128
    ^ super from:start to:stop reverseDo:aBlock
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1129
!
e33491f6f260 *** empty log message ***
claus
parents: 36
diff changeset
  1130
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1131
keysAndValuesDo:aBlock
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1132
    "evaluate the argument, aBlock for each element in the collection.
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1133
     Pass both index and element to the block.
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1134
     - reimplemented for speed"
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1135
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1136
%{
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1137
    REGISTER OBJFUNC codeVal;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1138
    REGISTER INT index;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1139
    static struct inlineCache val2 = _ILC2;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1140
    REGISTER OBJ rHome;
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1141
    int actualSize;
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  1142
    OBJ myClass;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1143
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  1144
    myClass = __qClass(self);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1145
    if ((__ClassInstPtr(myClass)->c_ninstvars) == __mkSmallInteger(0)) {
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1146
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1147
	actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1148
	index = 0;
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1149
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1150
	if (index < actualSize) {
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1151
	    if (__isBlockLike(aBlock)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1152
	     && (__BlockInstPtr(aBlock)->b_nargs == __mkSmallInteger(2))) {
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1153
		{
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1154
		    /*
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1155
		     * the most common case: a static compiled block, with home on the stack ...
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1156
		     */
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1157
		    REGISTER OBJFUNC codeVal;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1158
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1159
		    if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil)
2678
37eec0043bdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
  1160
#ifdef PARANOIA
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1161
		     && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC)))
2678
37eec0043bdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
  1162
#endif
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1163
		    ) {
2254
5e3cb9e7e682 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
  1164
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1165
#ifdef NEW_BLOCK_CALL
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1166
#                       define BLOCK_ARG        aBlock
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1167
#else
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1168
#                       define BLOCK_ARG        rHome
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1169
			REGISTER OBJ rHome;
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1170
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1171
			rHome = __BlockInstPtr(aBlock)->b_home;
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1172
			if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1173
#endif
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1174
			{
2878
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1175
			    OBJ el;
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1176
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1177
			    while (index < actualSize) {
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1178
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1179
				el = __InstPtr(self)->i_instvars[index];
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1180
				if (InterruptPending != nil) goto interruptX;
2878
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1181
		continueX:
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1182
				index++;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1183
				(*codeVal)(BLOCK_ARG, __mkSmallInteger(index), el);
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1184
			    }
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1185
			    RETURN (self);
2878
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1186
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1187
		interruptX:
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1188
			    __interruptL(@line); 
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1189
			    el = __InstPtr(self)->i_instvars[index];
71f51a44643f comment
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  1190
			    goto continueX;
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1191
			}
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1192
		    }
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1193
		}
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1194
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1195
		/*
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1196
		 * sorry, must check code-pointer in the loop
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1197
		 * it could be recompiled or flushed
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1198
		 */
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1199
#               undef BLOCK_ARG
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1200
#ifdef NEW_BLOCK_CALL
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1201
#               define BLOCK_ARG        aBlock
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1202
#               define IBLOCK_ARG       nil
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1203
#else
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1204
#               define BLOCK_ARG        (__BlockInstPtr(aBlock)->b_home)
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1205
#               define IBLOCK_ARG       (__BlockInstPtr(aBlock)->b_home)
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1206
#endif
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1207
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1208
		while (index < actualSize) {
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1209
		    REGISTER OBJFUNC codeVal;
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1210
		    OBJ el;
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1211
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1212
		    if (InterruptPending != nil) __interruptL(@line);
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1213
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1214
		    el = __InstPtr(self)->i_instvars[index];
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1215
		    index++;
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1216
		    if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1217
			(*codeVal)(BLOCK_ARG, __mkSmallInteger(index), el);
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1218
		    } else {
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1219
			if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1220
			    /*
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1221
			     * arg is a compiled block with bytecode -
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1222
			     * directly call interpreter without going through Block>>value
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1223
			     */
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1224
#ifdef PASS_ARG_POINTER
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1225
			    {
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1226
				OBJ t[2];
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1227
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1228
				t[0] = __mkSmallInteger(index);
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1229
				t[1] = el;
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1230
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1231
				__interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t);
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1232
			    }
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1233
#else
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1234
			    __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __mkSmallInteger(index), el);
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1235
#endif
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1236
			} else {
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1237
			    (*val2.ilc_func)(aBlock, 
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1238
						@symbol(value:value:), 
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1239
						nil, &val2, 
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1240
						__mkSmallInteger(index),
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1241
						el);
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1242
			}
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1243
		    }
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1244
		}
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1245
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1246
#               undef BLOCK_ARG
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1247
#               undef IBLOCK_ARG
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1248
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1249
		RETURN (self );
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  1250
	    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1251
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  1252
	    /*
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1253
	     * not a block - send it #value:
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  1254
	     */
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1255
	    while (index < actualSize) {
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1256
		OBJ el;
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  1257
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1258
		if (InterruptPending != nil) __interruptL(@line);
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  1259
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1260
		el = __InstPtr(self)->i_instvars[index];
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1261
		index++;
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1262
		(*val2.ilc_func)(aBlock, 
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1263
				    @symbol(value:value:), 
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1264
				    nil, &val2, 
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1265
				    __mkSmallInteger(index),
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1266
				    el);
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1267
	    }
2842
1cda44a3660e oops - #keysAndValuesDo: was from for subclasses with named instVars
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  1268
	    RETURN ( self );
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1269
	}
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1270
    }
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1271
%}.
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1272
    ^ super keysAndValuesDo:aBlock
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1273
!
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1274
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1275
reverseDo:aBlock
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1276
    "evaluate the argument, aBlock for each element in the collection in reverse order.
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1277
     - reimplemented for speed"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1278
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1279
    |home sz "{ Class: SmallInteger }" |
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1280
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1281
    sz := self size.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1282
%{
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1283
    REGISTER OBJFUNC codeVal;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1284
    REGISTER int index;
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1285
    unsigned int nIndex;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1286
    int endIndex;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1287
    static struct inlineCache val = _ILC1;
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1288
    int actualSize;
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  1289
    OBJ myClass;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1290
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  1291
    myClass = __qClass(self);
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  1292
    {
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1293
	endIndex = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1294
	actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1295
	nIndex = endIndex + __intVal(sz);
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1296
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1297
	if (nIndex <= actualSize) {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1298
	    if (__isBlockLike(aBlock)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1299
	     && (__BlockInstPtr(aBlock)->b_nargs == __mkSmallInteger(1))) {
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1300
#               undef BLOCK_ARG
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1301
#ifdef NEW_BLOCK_CALL
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1302
#               define BLOCK_ARG        aBlock
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1303
#               define IBLOCK_ARG       nil
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1304
#else
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1305
#               define BLOCK_ARG        (__BlockInstPtr(aBlock)->b_home)
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1306
#               define IBLOCK_ARG       (__BlockInstPtr(aBlock)->b_home)
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1307
#endif
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1308
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1309
		for (index=nIndex-1; index >= endIndex; index--) {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1310
		    REGISTER OBJFUNC codeVal;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1311
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1312
		    if (InterruptPending != nil) __interruptL(@line);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1313
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1314
		    if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1315
			(*codeVal)(BLOCK_ARG, __InstPtr(self)->i_instvars[index]);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1316
		    } else {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1317
			if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1318
			    /*
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1319
			     * arg is a compiled block with bytecode -
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1320
			     * directly call interpreter without going through Block>>value
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1321
			     */
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1322
#ifdef PASS_ARG_POINTER
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1323
			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &(__InstPtr(self)->i_instvars[index]));
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1324
#else
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1325
			    __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, __InstPtr(self)->i_instvars[index]);
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
  1326
#endif
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1327
			} else {
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1328
			    (*val.ilc_func)(aBlock, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1329
					    @symbol(value:), 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1330
					    nil, &val, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1331
					    __InstPtr(self)->i_instvars[index]);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1332
			}
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1333
		    }
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1334
		}
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1335
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1336
#               undef BLOCK_ARG
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1337
#               undef IBLOCK_ARG
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1338
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1339
		RETURN (self );
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1340
	    }
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1341
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1342
	    /*
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1343
	     * not a block - send it #value:
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1344
	     */
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1345
	    for (index=nIndex-1; index >= endIndex; index--) {
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1346
		if (InterruptPending != nil) __interruptL(@line);
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1347
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1348
		(*val.ilc_func)(aBlock, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1349
				@symbol(value:), 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1350
				nil, &val, 
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1351
				__InstPtr(self)->i_instvars[index]);
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1352
	    }
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1353
	    RETURN ( self );
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1354
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1355
    }
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1356
%}.
946
35962f2a169b be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1357
    ^ super reverseDo:aBlock
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
  1358
!
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
  1359
328
claus
parents: 325
diff changeset
  1360
traverse:aBlock
claus
parents: 325
diff changeset
  1361
    "Evaluate aBlock for every element that is not an Array, 
1123
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1362
     and recursively traverse Arrays.
328
claus
parents: 325
diff changeset
  1363
     Implemented here to support better search for selectors in
claus
parents: 325
diff changeset
  1364
     literal arrays - might be a good idea to move it up in the collection
claus
parents: 325
diff changeset
  1365
     hierarchy, since this may be a useful method for other collections
claus
parents: 325
diff changeset
  1366
     as well."
claus
parents: 325
diff changeset
  1367
claus
parents: 325
diff changeset
  1368
    self do: [:el |
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1369
	el isArray
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1370
	    ifTrue: [el traverse: aBlock]
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1371
	    ifFalse: [aBlock value: el]]
328
claus
parents: 325
diff changeset
  1372
claus
parents: 325
diff changeset
  1373
    "
claus
parents: 325
diff changeset
  1374
     example: flattening an Array:
claus
parents: 325
diff changeset
  1375
claus
parents: 325
diff changeset
  1376
     |s|
claus
parents: 325
diff changeset
  1377
claus
parents: 325
diff changeset
  1378
     s := WriteStream on:Array new.
claus
parents: 325
diff changeset
  1379
     #(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | s nextPut:el].
claus
parents: 325
diff changeset
  1380
     s contents 
claus
parents: 325
diff changeset
  1381
    "
1123
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1382
    "
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1383
     example: deep search
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1384
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1385
     #(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | 
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1386
	el == 10 ifTrue:[Transcript showCR:'found']
1123
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1387
     ]
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1388
    "
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1389
4e79c452592f commentary
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
  1390
    "Modified: 26.3.1996 / 17:08:10 / cg"
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1391
! !
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1392
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1393
!Array methodsFor:'filling & replacing'!
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1394
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1395
from:index1 to:index2 put:anObject
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1396
    "reimplemented for speed if receiver is an Array"
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1397
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1398
%{  /* NOCONTEXT */
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1399
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1400
    REGISTER int index;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1401
    unsigned int nIndex;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1402
    unsigned int endIndex;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1403
    REGISTER OBJ *dst;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1404
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1405
    if ((__qClass(self) == Array)
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1406
     && __bothSmallInteger(index1, index2)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
  1407
	index = __intVal(index1) - 1;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1408
	if (index >= 0) {
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1409
	    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
  1410
	    endIndex = __intVal(index2) - 1;
2185
790f4c380343 care for blocks being recompiled or code being flushed, while
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  1411
951
2dd898849a8a directly call __new if quick allocation fails;
Claus Gittinger <cg@exept.de>
parents: 946
diff changeset
  1412
	    if ((endIndex >= index) && (endIndex < nIndex)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
  1413
		dst = &(__InstPtr(self)->i_instvars[index]);
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1414
#ifdef memset4
2865
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1415
		{
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1416
		    int n4 = endIndex-index+1;
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1417
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1418
		    memset4(dst, anObject, n4);
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1419
		}
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1420
#else
2865
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1421
# ifdef FAST_MEMSET
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1422
		if ((INT)anObject == 0) {
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1423
		    memset(dst, 0, __OBJS2BYTES__(endIndex-index+1));
2865
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1424
		} else 
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1425
# endif
4d09015b12cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  1426
		{
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  1427
# ifdef __UNROLL_LOOPS__
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1428
		    {
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1429
			int i8;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1430
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1431
			while ((i8 = index + 8) <= endIndex) {
3041
f9487e848b67 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2991
diff changeset
  1432
			    dst[3] = dst[2] = dst[1] = dst[0] = anObject;
f9487e848b67 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2991
diff changeset
  1433
			    dst[7] = dst[6] = dst[5] = dst[4] = anObject;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1434
			    dst += 8;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1435
			    index = i8;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1436
			}
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1437
		    }
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1438
# endif
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1439
		    for (; index <= endIndex; index++) {
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1440
			*dst++ = anObject;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1441
		    }
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1442
		}
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1443
#endif
3730
375237229a8e replaceFrom... - unrolled 8 times;
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
  1444
		__STORE(self, anObject);
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1445
		RETURN ( self );
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1446
	    }
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1447
	}
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1448
    }
945
b2a1dc200c42 allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
  1449
%}.
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1450
    ^ super from:index1 to:index2 put:anObject
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1451
!
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1452
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1453
replaceFrom:start to:stop with:aCollection startingAt:repStart
1168
a8ac7ccb76db commentary
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
  1454
    "replace elements in the receiver between index start and stop,
a8ac7ccb76db commentary
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
  1455
     with elements  taken from replacementCollection starting at repStart.
3234
4cc58bc6a8ed comment
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1456
     Return the receiver.
1168
a8ac7ccb76db commentary
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
  1457
     Reimplemented for speed if both receiver and aCollection are Arrays"
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1458
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1459
%{  /* NOCONTEXT */
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1460
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1461
    unsigned int nIndex;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1462
    unsigned int repNIndex;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1463
    int startIndex, stopIndex;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1464
    REGISTER OBJ *src;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1465
    REGISTER OBJ *dst;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1466
    int repStopIndex;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1467
    REGISTER int repStartIndex;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1468
    REGISTER OBJ t;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1469
    REGISTER int count;
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1470
    OBJ myClass;
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1471
    
2210
9df9b4c48a6c weakText was wrong
Claus Gittinger <cg@exept.de>
parents: 2202
diff changeset
  1472
    if (
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1473
	(__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0))
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1474
     && __isNonNilObject(aCollection)
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1475
     && (((t = __qClass(aCollection)) == Array) || (t == myClass))
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1476
     && __bothSmallInteger(start, stop)
2210
9df9b4c48a6c weakText was wrong
Claus Gittinger <cg@exept.de>
parents: 2202
diff changeset
  1477
     && __isSmallInteger(repStart)
9df9b4c48a6c weakText was wrong
Claus Gittinger <cg@exept.de>
parents: 2202
diff changeset
  1478
    ) {
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1479
	startIndex = __intVal(start) - 1;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1480
	if (startIndex >= 0) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1481
	    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1482
	    stopIndex = __intVal(stop) - 1;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1483
	    count = stopIndex - startIndex + 1;
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1484
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1485
	    if ((count > 0) && (stopIndex < nIndex)) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1486
		repStartIndex = __intVal(repStart) - 1;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1487
		if (repStartIndex >= 0) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1488
		    repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1489
		    repStopIndex = repStartIndex + (stopIndex - startIndex);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1490
		    if (repStopIndex < repNIndex) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1491
			src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1492
			dst = &(__InstPtr(self)->i_instvars[startIndex]);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1493
			if (aCollection == self) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1494
			    /* 
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1495
			     * no need to check stores if copying
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1496
			     * from myself
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1497
			     */
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1498
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1499
			    /* 
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1500
			     * take care of overlapping copy
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1501
			     * do not depend on memset being smart enough
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1502
			     * (some are not ;-)
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1503
			     */
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1504
			    if (src < dst) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1505
				/* must do a reverse copy */
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1506
				src += count;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1507
				dst += count;
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  1508
#ifdef __UNROLL_LOOPS__
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1509
				while (count > 8) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1510
				    dst[-1] = src[-1];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1511
				    dst[-2] = src[-2];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1512
				    dst[-3] = src[-3];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1513
				    dst[-4] = src[-4];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1514
				    dst[-5] = src[-5];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1515
				    dst[-6] = src[-6];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1516
				    dst[-7] = src[-7];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1517
				    dst[-8] = src[-8];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1518
				    dst -= 8; src -= 8;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1519
				    count -= 8;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1520
				}
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1521
#endif
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1522
				while (count-- > 0) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1523
				    *--dst = *--src;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1524
				}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1525
				RETURN ( self );
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1526
			    }
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1527
#ifdef SOFTWARE_PIPELINE
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1528
			    {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1529
				OBJ t1;
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1530
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1531
				/* 
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1532
				 * the loop below fetches one longWord behind
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1533
				 * this should not be a problem
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1534
				 */
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1535
				t1 = src[0];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1536
				count--;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1537
				if (count) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1538
				    dst++; src++;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1539
				    do {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1540
					dst[-1] = t1;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1541
					t1 = src[0];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1542
					src++;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1543
					dst++;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1544
				    } while (count--);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1545
				} else {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1546
				    dst[0] = t1;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1547
				}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1548
			    }
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1549
#else
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1550
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1551
# ifdef bcopy4
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1552
			    bcopy4(src, dst, count);
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1553
# else
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1554
#  ifdef FAST_MEMCPY
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1555
			    bcopy(src, dst, __OBJS2BYTES__(count));
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1556
#  else
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  1557
#   ifdef __UNROLL_LOOPS__
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1558
			    while (count >= 8) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1559
				dst[0] = src[0];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1560
				dst[1] = src[1];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1561
				dst[2] = src[2];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1562
				dst[3] = src[3];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1563
				dst[4] = src[4];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1564
				dst[5] = src[5];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1565
				dst[6] = src[6];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1566
				dst[7] = src[7];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1567
				dst += 8; src += 8;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1568
				count -= 8;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1569
			    }
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1570
#   endif
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1571
			    while (count--) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1572
				*dst++ = *src++;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1573
			    }
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1574
#  endif
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1575
# endif
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1576
#endif
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1577
			} else {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1578
			    REGISTER int spc;
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1579
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1580
			    spc = __qSpace(self);
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  1581
#ifdef __UNROLL_LOOPS__
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1582
			    while (count >= 8) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1583
				t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1584
				t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1585
				t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1586
				t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1587
				t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1588
				t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1589
				t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1590
				t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1591
				count -= 8; src += 8; dst += 8;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1592
			    }
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1593
#endif
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1594
			    while (count-- > 0) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1595
				t = *src++;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1596
				*dst++ = t;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1597
				__STORE_SPC(self, t, spc);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1598
			    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1599
			}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1600
			RETURN ( self );
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1601
		    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1602
		}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1603
	    }
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1604
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1605
	    if (count == 0) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1606
		RETURN ( self );
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1607
	    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  1608
	}
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1609
    }
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1610
%}.
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1611
    ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
1168
a8ac7ccb76db commentary
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
  1612
a8ac7ccb76db commentary
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
  1613
    "Modified: 13.4.1996 / 12:17:13 / cg"
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1614
! !
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1615
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1616
!Array methodsFor:'printing & storing'!
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1617
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1618
displayString
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1619
    "return a printed representation of the receiver for displaying"
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1620
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1621
    |s|
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1622
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1623
    (self isLiteral) ifTrue:[
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1624
	s := WriteStream on:String new.
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1625
	s writeLimit:5000.
1498
5083a52b1718 limit displayString to 5000 characters
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
  1626
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1627
	WriteStream writeErrorSignal handle:[:ex |
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1628
	    s writeLimit:nil.
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1629
	    s nextPutAll:' ...'
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1630
	] do:[
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1631
	    s nextPutAll:'#('.
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1632
	    self 
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1633
		do:[:each | s nextPutAll:each displayString.]
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1634
		separatedBy:[s space]
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1635
	].
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1636
	s writeLimit:nil.
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1637
	s nextPutAll:')'.
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1638
	^ s contents
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1639
    ].
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1640
    ^ super displayString
1083
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1641
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1642
    "
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1643
     #(1 2 3 4) displayString
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1644
     #(1 2 3 4) printString  
1498
5083a52b1718 limit displayString to 5000 characters
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
  1645
     (Array new:10000) displayString    
1083
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1646
    "
fadaedfa28f8 cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1647
2915
fdfc6c64bf60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
  1648
    "Modified: 12.9.1997 / 22:03:18 / cg"
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1649
!
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1650
8442
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1651
printOn:aStream
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1652
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1653
    self isLiteral ifTrue:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1654
        |limit firstOne s|
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1655
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1656
        thisContext isRecursive ifTrue:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1657
            'Array [error]: printOn: of self referencing collection.' errorPrintCR.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1658
            aStream nextPutAll:'#("recursive")'.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1659
            ^ self
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1660
        ].
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1661
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1662
        aStream nextPutAll:'#('.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1663
        firstOne := true.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1664
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1665
        "
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1666
         if aStream is not positionable, create an temporary positionable stream
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1667
         (needed for limit calculation)
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1668
        "
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1669
        aStream isPositionable ifTrue:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1670
            s := aStream.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1671
        ] ifFalse:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1672
            s := WriteStream on:(String uninitializedNew:50).
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1673
        ].
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1674
        limit := s position1Based + self maxPrint.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1675
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1676
        self printElementsDo:[:element |
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1677
            firstOne ifFalse:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1678
                s space
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1679
            ] ifTrue:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1680
                firstOne := false
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1681
            ].
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1682
            (s position1Based >= limit) ifTrue:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1683
                s ~~ aStream ifTrue:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1684
                    aStream nextPutAll:(s contents).
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1685
                ].
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1686
                aStream nextPutAll:'...etc...)'.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1687
                ^ self
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1688
            ] ifFalse:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1689
                element printOn:s.
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1690
            ].
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1691
        ].
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1692
        s ~~ aStream ifTrue:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1693
            aStream nextPutAll:(s contents).
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1694
        ].
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1695
        aStream nextPut:$)
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1696
    ] ifFalse:[
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1697
        super printOn:aStream
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1698
    ]
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1699
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1700
    "
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1701
     #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString 
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1702
     #(1 2 $a [1 2 3] true false nil #true #false #nil) printString 
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1703
    "
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1704
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1705
    "Created: 20.11.1995 / 11:16:58 / cg"
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1706
!
5b4f72d5e966 #printOn: prints Array as #(....) instead of Array(....)
Stefan Vogel <sv@exept.de>
parents: 8368
diff changeset
  1707
7600
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1708
storeArrayElementOn:aStream
8368
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1709
    "Store as element of an array. Omit the leading '#'"
7600
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1710
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1711
    self isLiteral ifTrue:[
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1712
        aStream nextPut:$(.
8368
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1713
        self 
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1714
            do:[:element | element storeArrayElementOn:aStream]
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1715
            separatedBy:[aStream space].
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1716
        aStream nextPut:$).
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1717
        ^ self.
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1718
    ].
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1719
    super storeArrayElementOn:aStream
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1720
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1721
    "
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1722
     #(1 2 3 4 5) storeOn:Transcript   
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1723
     #(1 2 3 4 5) storeArrayElementOn:Transcript   
2109093f80ff comment
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1724
    "
7600
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1725
!
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1726
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1727
storeOn:aStream
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1728
    "append a printed representation of the receiver to aStream,
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1729
     which allows reconstructing it via readFrom:.
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1730
     Redefined to output a somewhat more user friendly string."
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1731
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1732
    self isLiteral ifTrue:[
7600
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1733
        aStream nextPutAll:'#('.
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1734
        self do:[:element | element storeArrayElementOn:aStream]
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1735
             separatedBy:[aStream space].
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1736
        aStream nextPut:$)
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1737
    ] ifFalse:[
7600
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1738
        super storeOn:aStream
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1739
    ]
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1740
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1741
    "
7600
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1742
     #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') storeString 
5a3fee21c032 #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 6497
diff changeset
  1743
     #(1 2 $a [1 2 3] true false nil #true #false #nil) storeString 
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1744
    "
588
ec7e2bc63d77 testing checkin
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1745
ec7e2bc63d77 testing checkin
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1746
    "Created: 20.11.1995 / 11:16:58 / cg"
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1747
! !
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1748
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1749
!Array methodsFor:'queries'!
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1750
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1751
basicSize
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1752
    "return the number of indexed elements in the receiver"
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1753
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1754
%{  /* NOCONTEXT */
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1755
    REGISTER OBJ slf = self;
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1756
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1757
    RETURN ( __mkSmallInteger(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) ));
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1758
%}
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1759
!
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1760
8625
0e0637c66519 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 8603
diff changeset
  1761
fooBar
0e0637c66519 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 8603
diff changeset
  1762
0e0637c66519 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 8603
diff changeset
  1763
    ^ 'hello world 2'
0e0637c66519 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 8603
diff changeset
  1764
!
0e0637c66519 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 8603
diff changeset
  1765
1243
955b7f55f7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1766
refersToLiteral:aLiteral
955b7f55f7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1767
    "return true if the receiver or recursively any array element in the
5537
05d01dd462f6 comments
Claus Gittinger <cg@exept.de>
parents: 5531
diff changeset
  1768
     receiver referes to aLiteral (i.e. a deep search)"
1243
955b7f55f7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1769
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1770
    self do: [ :el | 
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1771
	el == aLiteral ifTrue:[^true].
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1772
	el class == Array ifTrue:[
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1773
	    (el refersToLiteral: aLiteral) ifTrue: [^true]
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1774
	]
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1775
    ].
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1776
    ^ false
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1777
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1778
    "
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1779
     #(1 2 3) refersToLiteral:#foo  
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1780
     #(1 2 3 foo bar baz) refersToLiteral:#foo 
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1781
     #(1 2 3 (((bar foo))) bar baz) refersToLiteral:#foo  
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1782
    "
1243
955b7f55f7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1783
5537
05d01dd462f6 comments
Claus Gittinger <cg@exept.de>
parents: 5531
diff changeset
  1784
    "Modified: / 18.8.2000 / 21:18:14 / cg"
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1785
!
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1786
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1787
size
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1788
    "return the number of indexed elements in the receiver.
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1789
     Reimplemented here to avoid the additional size->basicSize send
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1790
     (which we can do here, since when arriving here, #size is obviously not
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1791
      redefined in a subclass).
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1792
     This method is the same as basicSize."
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1793
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1794
%{  /* NOCONTEXT */
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1795
    REGISTER OBJ slf = self;
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1796
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1797
    RETURN ( __mkSmallInteger(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) ));
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5554
diff changeset
  1798
%}
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1799
! !
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1800
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  1801
!Array methodsFor:'searching'!
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1802
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1803
identityIndexOf:anElement or:alternative 
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1804
    "search the array for anElement or alternative; 
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1805
     return the index of anElement if found, or the index of anAlternative,
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1806
     if not found. If anAlternative is also not found, return 0.
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1807
     This is a special interface for high-speed searching in an array
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1808
     and at the same time searching for an empty slot.
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1809
     Do not use this method for your application classes, since it is
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1810
     not portable (i.e. other smalltalks do not offer this)"
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1811
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1812
%{  /* NOCONTEXT */
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1813
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1814
    REGISTER INT index;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1815
    REGISTER OBJ o, el1, el2;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1816
    REGISTER OBJ *op;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1817
    REGISTER unsigned INT nIndex;
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1818
    INT altIndex = 0;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1819
    int nInsts;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1820
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1821
    index = 0;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
  1822
    nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1823
    index += nInsts;
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1824
    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1825
    el1 = anElement; el2 = alternative; 
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1123
diff changeset
  1826
    op = & (__InstPtr(self)->i_instvars[index]);
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1827
    while (index++ < nIndex) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1828
	if ((o = *op++) == el1) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1829
	    RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1830
	}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1831
	if (o == el2) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1832
	    if (altIndex == 0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1833
		altIndex = index;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1834
	    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1835
	}
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1836
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1837
    RETURN ( __mkSmallInteger(altIndex) );
5403
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  1838
%}.
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  1839
    ^ super identityIndexOf:anElement or:alternative
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1840
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1841
    "
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1842
     #(1 2 3 4 5 6 7 8 9) identityIndexOf:3 or:5
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1843
     #(1 2 0 4 5 6 7 8 9) identityIndexOf:3 or:5
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1844
     #(1 2 0 4 5 6 7 3 9) identityIndexOf:3 or:5
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1845
     #(1 2 3 4 5 nil 7 3 9) identityIndexOf:3 or:nil 
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1846
     #(1 2 nil 4 5 6 7 3 9) identityIndexOf:3 or:nil  
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1847
     #(1 2 nil 4 5 6 7 8 9) identityIndexOf:3 or:nil 
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1848
     #() identityIndexOf:3 or:nil        
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1849
     #(1 2) identityIndexOf:3 or:nil 
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1850
    "
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1851
!
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1852
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1853
identityIndexOf:anElement startingAt:start
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1854
    "search the array for anElement; return index if found, 0 otherwise
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1855
     - reimplemented for speed"
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1856
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1857
%{  /* NOCONTEXT */
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1858
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1859
    REGISTER INT index;
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1860
    REGISTER OBJ el;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1861
    REGISTER OBJ *op;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1862
    REGISTER unsigned INT nIndex;
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1863
    int nInsts;
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1864
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1865
    if (__isSmallInteger(start)) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1866
	index = __intVal(start) - 1;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1867
	if (index >= 0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1868
	    nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1869
	    index += nInsts;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1870
	    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1871
	    el = anElement;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1872
	    op = & (__InstPtr(self)->i_instvars[index]);
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  1873
2213
2a4a3df451bf fast memsrch4 (i386 only)
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1874
#if defined(memsrch4)
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1875
	    if (index < nIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1876
		OBJ *p;
2213
2a4a3df451bf fast memsrch4 (i386 only)
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1877
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1878
		p = memsrch4(op, (INT)el, (nIndex - index));
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1879
		if (p) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1880
		    index += (p - op + 1);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1881
		    RETURN ( __mkSmallInteger(index) ); 
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1882
		}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1883
	    }
2213
2a4a3df451bf fast memsrch4 (i386 only)
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1884
#else
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  1885
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  1886
# ifdef __UNROLL_LOOPS__
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1887
	    {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1888
		/*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1889
		 * dont argue about those gotos below - they speed up that thing by 30%;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1890
		 * its better to exit the loops below with a goto,
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1891
		 * since the generated code will then be:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1892
		 *   compare
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1893
		 *   branch-on-equal found
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1894
		 *
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1895
		 * otherwise (with ret as if-statement), we get:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1896
		 *   compare
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1897
		 *   branch-on-not-equal skipLabel
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1898
		 *   move-to-ret-register true
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1899
		 *   goto ret-label
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1900
		 * skipLabel
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1901
		 *
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1902
		 * therefore, WITH the so-much-blamed goto, we only branch
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1903
		 * when found; without the goto, we branch always.
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1904
		 * Pipelined CPUs do usually not like taken branches.
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1905
		 */
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  1906
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1907
		unsigned int i8;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  1908
                
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1909
		while ((i8 = index + 8) < nIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1910
		    if (op[0] == el) goto found1;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1911
		    if (op[1] == el) goto found2;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1912
		    if (op[2] == el) goto found3;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1913
		    if (op[3] == el) goto found4;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1914
		    if (op[4] == el) goto found5;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1915
		    if (op[5] == el) goto found6;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1916
		    if (op[6] == el) goto found7;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1917
		    if (op[7] == el) goto found8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1918
		    index = i8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1919
		    op += 8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1920
		}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1921
		if (0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1922
		    found1:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1923
			RETURN ( __mkSmallInteger(index + 1 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1924
		    found2:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1925
			RETURN ( __mkSmallInteger(index + 2 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1926
		    found3:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1927
			RETURN ( __mkSmallInteger(index + 3 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1928
		    found4:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1929
			RETURN ( __mkSmallInteger(index + 4 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1930
		    found5:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1931
			RETURN ( __mkSmallInteger(index + 5 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1932
		    found6:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1933
			RETURN ( __mkSmallInteger(index + 6 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1934
		    found7:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1935
			RETURN ( __mkSmallInteger(index + 7 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1936
		    found8:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1937
			RETURN ( __mkSmallInteger(index + 8 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1938
		}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1939
	    }
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  1940
# endif /* __UNROLLED_LOOPS__ */
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
  1941
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1942
	    while (index++ < nIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1943
		if (*op++ == el) goto found0;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1944
	    }
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
  1945
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1946
	    if (0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1947
		found0:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1948
		    RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1949
	    }
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
  1950
#endif /* no memsrch */
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1951
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1952
	RETURN ( __mkSmallInteger(0) );
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1953
    }
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1954
%}.
5403
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  1955
    ^ super identityIndexOf:anElement startingAt:start
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1956
!
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1957
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1958
identityIndexOf:anElement startingAt:start endingAt:stop
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1959
    "search the array for anElement in the range start..stop; 
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1960
     return the index if found, 0 otherwise.
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1961
     - reimplemented for speed when searching in OrderedCollections"
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1962
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1963
%{  /* NOCONTEXT */
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1964
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1965
    REGISTER INT index;
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1966
    REGISTER OBJ el;
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1967
    REGISTER OBJ *op;
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1968
    REGISTER unsigned int lastIndex;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1969
    unsigned INT nIndex;
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1970
    int nInsts;
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1971
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  1972
    if (__bothSmallInteger(start, stop)) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1973
	index = __intVal(start) - 1;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1974
	if (index >= 0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1975
	    nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1976
	    index += nInsts;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1977
	    lastIndex = nInsts + __intVal(stop);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1978
	    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1979
	    if (nIndex < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1980
		lastIndex = nIndex;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1981
	    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1982
	    el = anElement;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1983
	    op = & (__InstPtr(self)->i_instvars[index]);
2213
2a4a3df451bf fast memsrch4 (i386 only)
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1984
2a4a3df451bf fast memsrch4 (i386 only)
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1985
#if defined(memsrch4)
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1986
	    if (index < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1987
		OBJ *p;
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  1988
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1989
		p = memsrch4(op, (INT)el, (lastIndex - index));
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1990
		if (p) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1991
		    index += (p - op + 1);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  1992
		    RETURN ( __mkSmallInteger(index) ); 
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1993
		}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1994
	    }
2216
e4fed6c622de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  1995
#else
2213
2a4a3df451bf fast memsrch4 (i386 only)
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1996
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  1997
# ifdef __UNROLL_LOOPS__
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1998
	    {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  1999
		unsigned int i8;
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2000
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2001
		while ((i8 = index + 8) < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2002
		    if (op[0] == el) goto found1;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2003
		    if (op[1] == el) goto found2;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2004
		    if (op[2] == el) goto found3;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2005
		    if (op[3] == el) goto found4;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2006
		    if (op[4] == el) goto found5;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2007
		    if (op[5] == el) goto found6;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2008
		    if (op[6] == el) goto found7;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2009
		    if (op[7] == el) goto found8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2010
		    index = i8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2011
		    op += 8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2012
		}
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
  2013
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2014
		if (0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2015
	    found1:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2016
		    RETURN ( __mkSmallInteger(index + 1 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2017
	    found2:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2018
		    RETURN ( __mkSmallInteger(index + 2 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2019
	    found3:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2020
		    RETURN ( __mkSmallInteger(index + 3 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2021
	    found4:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2022
		    RETURN ( __mkSmallInteger(index + 4 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2023
	    found5:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2024
		    RETURN ( __mkSmallInteger(index + 5 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2025
	    found6:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2026
		    RETURN ( __mkSmallInteger(index + 6 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2027
	    found7:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2028
		    RETURN ( __mkSmallInteger(index + 7 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2029
	    found8:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2030
		    RETURN ( __mkSmallInteger(index + 8 - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2031
		}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2032
	    }
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  2033
# endif /* __UNROLL_LOOPS__ */
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
  2034
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2035
	    while (index++ < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2036
		if (*op++ == el) goto found0;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2037
	    }
2715
48beff18cec0 software pipeline element access in enumeration method
Claus Gittinger <cg@exept.de>
parents: 2683
diff changeset
  2038
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2039
	    if (0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2040
		found0:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2041
		    RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2042
	    }
2213
2a4a3df451bf fast memsrch4 (i386 only)
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  2043
#endif
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2044
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2045
	RETURN ( __mkSmallInteger(0) );
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2046
    }
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2047
%}.
5403
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2048
    ^ super identityIndexOf:anElement startingAt:start endingAt:stop
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2049
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2050
!
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2051
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2052
indexOf:anElement startingAt:start
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2053
    "search the array for anElement; return index if found, 0 otherwise
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2054
     - reimplemented for speed"
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2055
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2056
    |element|
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2057
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2058
    REGISTER INT index;
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2059
    unsigned INT nIndex;
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2060
    unsigned int nInsts;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2061
    static struct inlineCache eq = _ILC1;
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2062
    OBJ myClass, e;
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2063
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  2064
    myClass = __qClass(self);
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  2065
    if ( __isSmallInteger(start) ) {
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2066
	index = __intVal(start) - 1;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2067
	if (index >= 0) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2068
	    nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2069
	    index += nInsts;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2070
	    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2071
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2072
	    e = anElement;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2073
	    if (e != nil) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2074
		/*
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2075
		 * special kludge to search for a string;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2076
		 * this is so common, that its worth a special case
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2077
		 */
825
f7b73d83b9d4 optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
  2078
#define SPECIAL_STRING_OPT
f7b73d83b9d4 optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
  2079
#ifdef SPECIAL_STRING_OPT
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2080
		if (__isString(e)) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2081
		    while (index < nIndex) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2082
			element = __InstPtr(self)->i_instvars[index++];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2083
			if (__isNonNilObject(element)) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2084
			    if (element == e) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2085
				RETURN ( __mkSmallInteger(index - nInsts) );
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2086
			    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2087
			    if (__qClass(element) == @global(String)) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2088
				if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2089
				    RETURN ( __mkSmallInteger(index - nInsts) );
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2090
				}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2091
			    } else {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2092
				if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2093
				    RETURN ( __mkSmallInteger(index - nInsts) );
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2094
				}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2095
				/*
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2096
				 * send of #= could have lead to a GC - refetch e
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2097
				 */
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2098
				e = anElement;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2099
			    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2100
			}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2101
		    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2102
		    RETURN (__mkSmallInteger(0));
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2103
		}
825
f7b73d83b9d4 optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
  2104
#endif
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2105
		if (__isSmallInteger(e)) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2106
		    /* search for a small number */
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2107
		    while (index < nIndex) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2108
			element = __InstPtr(self)->i_instvars[index++];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2109
			if (element == e) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2110
			    RETURN ( __mkSmallInteger(index - nInsts) );
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2111
			}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2112
			if (!__isSmallInteger(element)) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2113
			    if ((*eq.ilc_func)(e,
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2114
						@symbol(=), 
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2115
						nil,&eq,
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2116
						element) == true) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2117
				RETURN ( __mkSmallInteger(index - nInsts) );
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2118
			    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2119
			    /*
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2120
			     * send of #= could have lead to a GC - refetch e
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2121
			     */
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2122
			    e = anElement;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2123
			}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2124
		    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2125
		    RETURN (__mkSmallInteger(0));
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2126
		}
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2127
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2128
		while (index < nIndex) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2129
		    element = __InstPtr(self)->i_instvars[index++];
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2130
		    if (element != nil) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2131
			e = anElement;
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2132
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2133
			if ((element == e) 
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2134
			 || ((*eq.ilc_func)(e,
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2135
					    @symbol(=), 
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2136
					    nil,&eq,
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2137
					    element) == true)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2138
			    RETURN ( __mkSmallInteger(index - nInsts) );
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2139
			}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2140
		    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2141
		}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2142
	    } else {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2143
		OBJ slf = self;
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2144
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2145
		/* 
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2146
		 * search for nil - do an identity-search
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2147
		 */
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  2148
#ifdef __UNROLL_LOOPS__
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2149
		{
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2150
		    unsigned int i8;
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2151
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2152
		    while ((i8 = index + 8) < nIndex) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2153
			if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2154
			if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2155
			if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2156
			if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2157
			if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2158
			if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2159
			if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2160
			if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2161
			index = i8;
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2162
		    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2163
		}
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2164
#endif
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2165
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2166
		while (index < nIndex) {
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2167
		    if (__InstPtr(slf)->i_instvars[index++] == nil) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2168
			RETURN ( __mkSmallInteger(index - nInsts) );
4305
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2169
		    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2170
		}
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2171
	    }
e71100d13b67 void possible return warning
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2172
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2173
	RETURN (__mkSmallInteger(0));
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2174
    }
554
716dee42f589 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2175
%}.
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  2176
    ^ super indexOf:anElement startingAt:start
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2177
!
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2178
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2179
indexOf:anElement startingAt:start endingAt:stop
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2180
    "search the array for anElement in the range start..stop; 
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2181
     Return the index if found, 0 otherwise.
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2182
     - reimplemented for speed when searching in OrderedCollections"
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2183
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2184
    |element|
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2185
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2186
    REGISTER INT index;
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2187
    unsigned INT lastIndex, nIndex;
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2188
    unsigned int nInsts;
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2189
    static struct inlineCache eq = _ILC1;
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2190
    OBJ myClass, e;
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2191
2184
f25db3e10530 no block-copy operations are allowed with WeakArrays
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
  2192
    myClass = __qClass(self);
2357
061dadc13df1 removed WEAKPOINTER checks - WeakArray is no longer allowed to be a subclass of Array
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  2193
    if ( __bothSmallInteger(start, stop) ) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2194
	index = __intVal(start) - 1;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2195
	if (index >= 0) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2196
	    nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2197
	    index += nInsts;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2198
	    lastIndex = nInsts + __intVal(stop);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2199
	    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2200
	    if (nIndex < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2201
		lastIndex = nIndex;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2202
	    }
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2203
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2204
	    e = anElement;
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2205
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2206
	    if (e != nil) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2207
		/*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2208
		 * special kludge to search for a string;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2209
		 * this is so common, that its worth a special case
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2210
		 */
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2211
#define SPECIAL_STRING_OPT
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2212
#ifdef SPECIAL_STRING_OPT
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2213
		if (__isString(e)) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2214
		    while (index < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2215
			element = __InstPtr(self)->i_instvars[index++];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2216
			if (__isNonNilObject(element)) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2217
			    if (element == e) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2218
				RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2219
			    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2220
			    if (__qClass(element) == @global(String)) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2221
				if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2222
				    RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2223
				}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2224
			    } else {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2225
				if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2226
				    RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2227
				}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2228
				/*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2229
				 * send of #= could have lead to a GC - refetch e
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2230
				 */
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2231
				e = anElement;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2232
			    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2233
			}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2234
		    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2235
		    RETURN (__mkSmallInteger(0));
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2236
		}
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2237
#endif
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2238
		if (__isSmallInteger(e)) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2239
		    /* search for a small number */
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2240
		    while (index < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2241
			element = __InstPtr(self)->i_instvars[index++];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2242
			if (element == e) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2243
			    RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2244
			}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2245
			if (!__isSmallInteger(element)) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2246
			    if ((*eq.ilc_func)(e,
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2247
						@symbol(=), 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2248
						nil,&eq,
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2249
						element) == true) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2250
				RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2251
			    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2252
			    /*
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2253
			     * send of #= could have lead to a GC - refetch e
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2254
			     */
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2255
			    e = anElement;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2256
			}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2257
		    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2258
		    RETURN (__mkSmallInteger(0));
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2259
		}
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2260
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2261
		while (index < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2262
		    element = __InstPtr(self)->i_instvars[index++];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2263
		    if (element != nil) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2264
			e = anElement;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2265
			if ((element == e) 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2266
			 || ((*eq.ilc_func)(e,
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2267
					    @symbol(=), 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2268
					    nil,&eq,
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2269
					    element) == true)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2270
			    RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2271
			}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2272
		    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2273
		}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2274
	    } else {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2275
		OBJ slf = self;
4130
662554f2a37c avoid refetch of void variables (if possible)
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  2276
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2277
		/* 
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2278
		 * search for nil - do an identity-search
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2279
		 */
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  2280
#ifdef __UNROLL_LOOPS__
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2281
		{
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2282
		    unsigned int i8;
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2283
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2284
		    while ((i8 = index + 8) < lastIndex) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2285
			if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2286
			if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2287
			if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2288
			if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2289
			if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2290
			if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2291
			if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2292
			if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2293
			index = i8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2294
		    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2295
		}
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2296
#endif
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2297
		while (index < lastIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2298
		    if (__InstPtr(slf)->i_instvars[index++] == nil) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2299
			RETURN ( __mkSmallInteger(index - nInsts) );
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2300
		    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2301
		}
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2302
	    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2303
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8901
diff changeset
  2304
	RETURN (__mkSmallInteger(0));
1158
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2305
    }
bf9aec9e892c added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2306
%}.
2211
289095fe875a oops - must send super indeOf...endingAt:
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2307
    ^ super indexOf:anElement startingAt:start endingAt:stop
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2308
! !
543
09293a92bddb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2309
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2310
!Array methodsFor:'testing'!
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2311
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2312
includes:anObject
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2313
    "return true, if the argument, anObject is contained in the array
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2314
     - reimplemented for speed"
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2315
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2316
    |element|
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2317
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2318
%{  /* NOCONTEXT */
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2319
    /* 
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2320
     * first, do a quick check using ==
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2321
     * this does not need a context or message send.
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2322
     * In many cases this will already find a match.
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2323
     */
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2324
    REGISTER int index;
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2325
    REGISTER OBJ o;
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2326
    unsigned int nIndex;
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2327
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2328
    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2329
    index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2330
4309
7d8976a3abe3 bug fix
Claus Gittinger <cg@exept.de>
parents: 4305
diff changeset
  2331
    o = anObject;
7d8976a3abe3 bug fix
Claus Gittinger <cg@exept.de>
parents: 4305
diff changeset
  2332
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2333
    /*
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2334
     * however, the search is limited to the first 500
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2335
     * elements, since otherwise, we may spend too much time
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2336
     * searching for identity if an equal value is found early
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2337
     * (except if searching for nil - there is no need for equal compare ...)
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2338
     */
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2339
    if (nIndex > 500) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2340
	if (o != nil)
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2341
	    nIndex = 500;
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2342
    }
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2343
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2344
# ifdef memsrch4
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2345
    if (index < nIndex) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2346
	OBJ *p;
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2347
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2348
	p = memsrch4(&(__InstPtr(self)->i_instvars[index]), (INT)o, (nIndex - index));
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2349
	if (p) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2350
	    RETURN ( true );
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2351
	}
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2352
    }
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2353
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2354
# else
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2355
    /*
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2356
     * dont argue those gotos below - they speed up that thing by 30%
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2357
     * its better to exit the loops below with a goto,
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2358
     * since the generated code will then be:
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2359
     *   compare
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2360
     *   branch-on-equal found
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2361
     *
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2362
     * otherwise, we get:
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2363
     *   compare
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2364
     *   branch-on-not-equal skipLabel
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2365
     *   move-to-return-register true
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2366
     *   goto return-label
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2367
     * skipLabel
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2368
     *
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2369
     * therefore, WITH the so-much-blamed goto, we only branch
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2370
     * when found; without the goto, we branch always.
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2371
     * Pipelined CPUs do usually not like taken branches.
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2372
     * also, all branches are forward, which are usually predicted
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2373
     * as not taken.
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2374
     */
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  2375
#  ifdef __UNROLL_LOOPS__
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2376
    {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2377
	unsigned int i8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2378
	REGISTER OBJ slf = self;
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2379
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2380
	while ((i8 = index + 8) < nIndex) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2381
	    if (__InstPtr(slf)->i_instvars[index] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2382
	    if (__InstPtr(slf)->i_instvars[index+1] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2383
	    if (__InstPtr(slf)->i_instvars[index+2] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2384
	    if (__InstPtr(slf)->i_instvars[index+3] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2385
	    if (__InstPtr(slf)->i_instvars[index+4] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2386
	    if (__InstPtr(slf)->i_instvars[index+5] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2387
	    if (__InstPtr(slf)->i_instvars[index+6] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2388
	    if (__InstPtr(slf)->i_instvars[index+7] == o) goto found;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2389
	    index = i8;
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2390
	}
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2391
    }
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  2392
#  endif /* __UNROLL_LOOPS__ */
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2393
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2394
    while (index < nIndex) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2395
	if (__InstPtr(self)->i_instvars[index++] == o) goto found;
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2396
    }
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2397
    if (0) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2398
	found:
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2399
	    RETURN (true);
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2400
    }
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2401
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2402
# endif /* no memsrch */
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2403
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2404
    if (o == nil) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2405
	RETURN ( false );
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2406
    }
5403
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2407
%}.
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2408
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2409
%{
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2410
    REGISTER int index;
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2411
    REGISTER OBJ o;
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2412
    unsigned int nIndex;
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2413
    static struct inlineCache eq = _ILC1;
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2414
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2415
    /* 
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2416
     * then do a slow(er) check using =
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2417
     */
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2418
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2419
    /* 
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2420
     * sorry: cannot access the stuff from above ...
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2421
     */
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2422
    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2423
    index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2424
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2425
    while (index < nIndex) {
6497
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2426
	element = __InstPtr(self)->i_instvars[index++];
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2427
	if (element != nil) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2428
	    if ((*eq.ilc_func)(anObject,
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2429
			       @symbol(=),
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2430
			       nil,&eq,
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2431
			       element)==true) {
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2432
		RETURN ( true );
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2433
	    }
786812ab9bb3 use arrayVal macro
Claus Gittinger <cg@exept.de>
parents: 5576
diff changeset
  2434
	}
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2435
    }
5403
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2436
    RETURN (false);
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2437
%}.
5403
55cbe7c0a58f super-send fallBacks
Claus Gittinger <cg@exept.de>
parents: 5347
diff changeset
  2438
    ^ super includes:anObject
5049
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2439
!
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2440
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2441
includesIdentical:anObject
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2442
    "return true, if the argument, anObject is contained in the array
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2443
     uses #== (instead of #=) when comparing; i.e. the search is for
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2444
     the object, not some object being equal."
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2445
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2446
    ^ (self identityIndexOf:anObject) ~~ 0
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2447
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2448
    "
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2449
     #(1 2 3 4 5) includes:3.0
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2450
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2451
     #(1 2 3 4 5) includesIdentical:3.0
d8279f59df21 added #includesIdentical:
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
  2452
    "
5554
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2453
!
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2454
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2455
isArray
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2456
    "return true, if the receiver is some kind of array (or weakArray etc).
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2457
     true is returned here."
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2458
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2459
    ^ true
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2460
!
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2461
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2462
isEmpty
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2463
    "return true if the receiver contains no elements.
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2464
     Reimplemented here for performance."
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2465
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2466
%{  /* NOCONTEXT */
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2467
    REGISTER OBJ slf = self;
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2468
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2469
    if (__qClass(slf) == Array) {
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2470
	RETURN ( (__arraySize(slf) == 0) ? true : false);
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2471
    }
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2472
%}.
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2473
    ^ self size == 0
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2474
!
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2475
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2476
isLiteral
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2477
    "return true, if the receiver can be used as a literal constant in ST syntax
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2478
     (i.e. can be used in constant arrays)"
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2479
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2480
    "/ no, simply returning true here is a mistake:
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2481
    "/ it could be a subclass of Array 
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2482
    "/ (of which the compiler does not know at all ...)
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2483
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2484
    self class == Array ifFalse:[^ false].
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2485
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2486
    "/
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2487
    "/ care for recursive arrays ...
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2488
    "/
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2489
    thisContext isRecursive ifTrue:[^ false].
10089
833fffc641ef code cleanup: use #conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents: 9360
diff changeset
  2490
    ^ self conform:[:element | element isLiteral].
5554
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2491
10089
833fffc641ef code cleanup: use #conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents: 9360
diff changeset
  2492
    "Modified: / 13-10-2006 / 13:00:45 / cg"
5554
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2493
!
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2494
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2495
notEmpty
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2496
    "return true if the receiver contains elements.
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2497
     Reimplemented here for performance."
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2498
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2499
%{  /* NOCONTEXT */
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2500
    REGISTER OBJ slf = self;
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2501
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2502
    if (__qClass(slf) == Array) {
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2503
	RETURN ( (__arraySize(slf) != 0) ? true : false);
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2504
    }
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2505
%}.
28520e96cca9 category changes
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  2506
    ^ self size ~~ 0
3088
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2507
! !
8b7011bef899 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3041
diff changeset
  2508
4681
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2509
!Array methodsFor:'tracing'!
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2510
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2511
traceInto:aRequestor level:level from:referrer
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2512
    "double dispatch into tracer, passing my type implicitely in the selector"
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2513
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2514
    ^ aRequestor traceArray:self level:level from:referrer
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2515
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2516
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2517
! !
7bac1e0ba551 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  2518
1903
30c98b3377c5 slight tuning
Claus Gittinger <cg@exept.de>
parents: 1730
diff changeset
  2519
!Array class methodsFor:'documentation'!
626
f359cb7eba58 version at the end
Claus Gittinger <cg@exept.de>
parents: 588
diff changeset
  2520
f359cb7eba58 version at the end
Claus Gittinger <cg@exept.de>
parents: 588
diff changeset
  2521
version
10796
08a9ee8cf317 Do not add nil elements to a Set in #asSet and #asIdentitySet
Stefan Vogel <sv@exept.de>
parents: 10089
diff changeset
  2522
    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.143 2007-11-21 10:10:11 stefan Exp $'
1244
dc9dd731258c commentary
Claus Gittinger <cg@exept.de>
parents: 1243
diff changeset
  2523
! !