132 p = __INST(position); |
131 p = __INST(position); |
133 l = __INST(readLimit); |
132 l = __INST(readLimit); |
134 |
133 |
135 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
134 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
136 |
135 |
137 pos = __intVal(p); |
136 pos = __intVal(p); |
138 /* make 1-based */ |
137 /* make 1-based */ |
139 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
138 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
140 if (pos > 0 && pos <= __intVal(l)) { |
139 if (pos > 0 && pos <= __intVal(l)) { |
141 OBJ cls; |
140 OBJ cls; |
142 |
141 |
143 cls = __qClass(coll); |
142 cls = __qClass(coll); |
144 if (cls == @global(String)) { |
143 if (cls == @global(String)) { |
145 if (pos <= __stringSize(coll)) { |
144 if (pos <= __stringSize(coll)) { |
146 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
145 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
147 ch = __stringVal(coll)[pos-1]; |
146 ch = __stringVal(coll)[pos-1]; |
148 RETURN ( __MKCHARACTER(ch) ); |
147 RETURN ( __MKCHARACTER(ch) ); |
149 } |
148 } |
150 } else if (cls == @global(ByteArray)) { |
149 } else if (cls == @global(ByteArray)) { |
151 if (pos <= __byteArraySize(coll)) { |
150 if (pos <= __byteArraySize(coll)) { |
152 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
151 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
153 ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
152 ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
154 RETURN ( __MKSMALLINT(ch) ); |
153 RETURN ( __MKSMALLINT(ch) ); |
155 } |
154 } |
156 } else if (cls == @global(Array)) { |
155 } else if (cls == @global(Unicode16String)) { |
157 if (pos <= __arraySize(coll)) { |
156 if (pos <= __unicode16StringSize(coll)) { |
158 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
157 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
159 RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
158 ch = __Unicode16StringInstPtr(coll)->s_element[pos-1]; |
160 } |
159 RETURN ( __MKUCHARACTER(ch) ); |
161 } |
160 } |
162 } |
161 } else if (cls == @global(Array)) { |
|
162 if (pos <= __arraySize(coll)) { |
|
163 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
|
164 RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
|
165 } |
|
166 } |
|
167 } |
163 } |
168 } |
164 %}. |
169 %}. |
165 ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd]. |
170 ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd]. |
166 ret := collection at:(position + 1 - ZeroPosition). |
171 ret := collection at:(position + 1 - ZeroPosition). |
167 position := position + 1. |
172 position := position + 1. |
257 p = __INST(position); |
262 p = __INST(position); |
258 l = __INST(readLimit); |
263 l = __INST(readLimit); |
259 |
264 |
260 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
265 if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
261 |
266 |
262 pos = __intVal(p); |
267 pos = __intVal(p); |
263 /* make 1-based */ |
268 /* make 1-based */ |
264 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
269 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
265 if (pos > 0 && pos <= __intVal(l)) { |
270 if (pos > 0 && pos <= __intVal(l)) { |
266 OBJ cls; |
271 OBJ cls; |
267 |
272 |
268 cls = __qClass(coll); |
273 cls = __qClass(coll); |
269 if (cls == @global(String)) { |
274 if (cls == @global(String)) { |
270 if (pos <= __stringSize(coll)) { |
275 if (pos <= __stringSize(coll)) { |
271 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
276 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
272 ch = __stringVal(coll)[pos-1]; |
277 ch = __stringVal(coll)[pos-1]; |
273 RETURN ( __MKSMALLINT(ch) ); |
278 RETURN ( __MKSMALLINT(ch) ); |
274 } |
279 } |
275 } else if (cls == @global(ByteArray)) { |
280 } else if (cls == @global(ByteArray)) { |
276 if (pos <= __byteArraySize(coll)) { |
281 if (pos <= __byteArraySize(coll)) { |
277 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
282 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
278 ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
283 ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
279 RETURN ( __MKSMALLINT(ch) ); |
284 RETURN ( __MKSMALLINT(ch) ); |
280 } |
285 } |
281 } else if (cls == @global(Array)) { |
286 } else if (cls == @global(Array)) { |
282 if (pos <= __arraySize(coll)) { |
287 if (pos <= __arraySize(coll)) { |
283 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
288 __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1); |
284 RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
289 RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
285 } |
290 } |
286 } |
291 } |
287 } |
292 } |
288 } |
293 } |
289 %}. |
294 %}. |
290 ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd]. |
295 ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd]. |
291 ret := collection at:(position + 1 -ZeroPosition). |
296 ret := collection at:(position + 1 -ZeroPosition). |
292 position := position + 1. |
297 position := position + 1. |
293 ^ ret |
298 ^ ret asInteger |
294 ! |
299 ! |
295 |
300 |
296 nextDecimalInteger |
301 nextDecimalInteger |
297 "read the next integer in radix 10. dont skip whitespace. |
302 "read the next integer in radix 10. dont skip whitespace. |
298 - tuned for speed on String-Streams for faster scanning" |
303 - tuned for speed on String-Streams for faster scanning" |