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