203 REGISTER int pos; |
203 REGISTER int pos; |
204 unsigned ch; |
204 unsigned ch; |
205 OBJ coll; |
205 OBJ coll; |
206 OBJ p, l; |
206 OBJ p, l; |
207 |
207 |
208 coll = _INST(collection); |
208 coll = __INST(collection); |
209 p = _INST(position); |
209 p = __INST(position); |
210 |
210 |
211 if (__isNonNilObject(coll) && __isSmallInteger(p)) { |
211 if (__isNonNilObject(coll) && __isSmallInteger(p)) { |
212 |
212 |
213 pos = _intVal(p); |
213 pos = __intVal(p); |
214 l = _INST(writeLimit); |
214 l = __INST(writeLimit); |
215 |
215 |
216 if ((l == nil) |
216 if ((l == nil) |
217 || (__isSmallInteger(l) && (pos <= _intVal(l)))) { |
217 || (__isSmallInteger(l) && (pos <= __intVal(l)))) { |
218 OBJ cls; |
218 OBJ cls; |
219 |
219 |
220 cls = __qClass(coll); |
220 cls = __qClass(coll); |
221 |
221 |
222 if (cls == @global(String)) { |
222 if (cls == @global(String)) { |
223 if (__isCharacter(anObject) |
223 if (__isCharacter(anObject) |
224 && (pos <= _stringSize(coll))) { |
224 && (pos <= __stringSize(coll))) { |
225 ch = _intVal(_characterVal(anObject)); |
225 ch = __intVal(_characterVal(anObject)); |
226 if ((ch >= 0) && (ch <= 255)) { |
226 if ((ch >= 0) && (ch <= 255)) { |
227 _StringInstPtr(coll)->s_element[pos-1] = ch; |
227 __StringInstPtr(coll)->s_element[pos-1] = ch; |
228 _INST(position) = _MKSMALLINT(pos + 1); |
228 __INST(position) = __MKSMALLINT(pos + 1); |
229 if (__isSmallInteger(_INST(readLimit)) |
229 if (__isSmallInteger(__INST(readLimit)) |
230 && (pos >= _intVal(_INST(readLimit)))) { |
230 && (pos >= __intVal(__INST(readLimit)))) { |
231 _INST(readLimit) = _MKSMALLINT(pos); |
231 __INST(readLimit) = __MKSMALLINT(pos); |
232 } |
232 } |
233 RETURN ( anObject ); |
233 RETURN ( anObject ); |
234 } |
234 } |
235 } |
235 } |
236 } else { |
236 } else { |
237 if (cls == @global(ByteArray)) { |
237 if (cls == @global(ByteArray)) { |
238 if (__isSmallInteger(anObject) |
238 if (__isSmallInteger(anObject) |
239 && ((ch = _intVal(anObject)) >= 0) |
239 && ((ch = __intVal(anObject)) >= 0) |
240 && (ch <= 255) |
240 && (ch <= 255) |
241 && (pos <= _byteArraySize(coll))) { |
241 && (pos <= _byteArraySize(coll))) { |
242 _ByteArrayInstPtr(coll)->ba_element[pos-1] = ch; |
242 __ByteArrayInstPtr(coll)->ba_element[pos-1] = ch; |
243 _INST(position) = _MKSMALLINT(pos + 1); |
243 __INST(position) = __MKSMALLINT(pos + 1); |
244 if (__isSmallInteger(_INST(readLimit)) |
244 if (__isSmallInteger(__INST(readLimit)) |
245 && (pos >= _intVal(_INST(readLimit)))) { |
245 && (pos >= __intVal(__INST(readLimit)))) { |
246 _INST(readLimit) = _MKSMALLINT(pos); |
246 __INST(readLimit) = __MKSMALLINT(pos); |
247 } |
247 } |
248 RETURN ( anObject ); |
248 RETURN ( anObject ); |
249 } |
249 } |
250 } else { |
250 } else { |
251 if (cls == @global(Array)) { |
251 if (cls == @global(Array)) { |
252 if (pos <= _arraySize(coll)) { |
252 if (pos <= _arraySize(coll)) { |
253 _ArrayInstPtr(coll)->a_element[pos-1] = anObject; |
253 __ArrayInstPtr(coll)->a_element[pos-1] = anObject; |
254 __STORE(coll, anObject); |
254 __STORE(coll, anObject); |
255 _INST(position) = _MKSMALLINT(pos + 1); |
255 __INST(position) = __MKSMALLINT(pos + 1); |
256 if (__isSmallInteger(_INST(readLimit)) |
256 if (__isSmallInteger(__INST(readLimit)) |
257 && (pos >= _intVal(_INST(readLimit)))) { |
257 && (pos >= __intVal(__INST(readLimit)))) { |
258 _INST(readLimit) = _MKSMALLINT(pos); |
258 __INST(readLimit) = __MKSMALLINT(pos); |
259 } |
259 } |
260 RETURN ( anObject ); |
260 RETURN ( anObject ); |
261 } |
261 } |
262 } |
262 } |
263 } |
263 } |