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