1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1988-93 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Object subclass:#Object
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:'ErrorSignal HaltSignal
|
|
16 |
MessageNotUnderstoodSignal UserInterruptSignal
|
|
17 |
RecursionInterruptSignal ExceptionInterruptSignal
|
2
|
18 |
SubscriptOutOfBoundsSignal NonIntegerIndexSignal
|
|
19 |
NotFoundSignal KeyNotFoundSignal ElementOutOfBoundsSignal InformationSignal
|
|
20 |
InterruptSignal'
|
1
|
21 |
poolDictionaries:''
|
|
22 |
category:'Kernel-Objects'
|
|
23 |
!
|
|
24 |
|
|
25 |
Object comment:'
|
|
26 |
|
|
27 |
COPYRIGHT (c) 1988-93 by Claus Gittinger
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
Class Object is the superclass of all other classes. Protocol common to
|
|
31 |
all objects is defined here.
|
|
32 |
Also some utility stuff (like notify) and error handling is implemented here.
|
|
33 |
|
|
34 |
%W% %E%
|
|
35 |
'!
|
|
36 |
|
|
37 |
Smalltalk at:#ErrorRecursion put:false!
|
|
38 |
Smalltalk at:#ErrorActive put:false!
|
|
39 |
Smalltalk at:#Dependencies put:nil!
|
|
40 |
Smalltalk at:#SystemNotifier put:nil!
|
|
41 |
Smalltalk at:#SystemWarningBox put:nil!
|
|
42 |
Smalltalk at:#SystemInfoBox put:nil!
|
|
43 |
Smalltalk at:#SystemConfirmer put:nil!
|
|
44 |
|
|
45 |
!Object class methodsFor:'initialization'!
|
|
46 |
|
|
47 |
initialize
|
|
48 |
"called only once - initialize signals"
|
|
49 |
|
|
50 |
ErrorSignal isNil ifTrue:[
|
|
51 |
ErrorSignal := (Signal new) mayProceed:true.
|
|
52 |
ErrorSignal notifierString:'error'.
|
|
53 |
|
|
54 |
HaltSignal := (Signal new) mayProceed:true.
|
|
55 |
HaltSignal notifierString:'halt encountered'.
|
|
56 |
|
2
|
57 |
UnhandledInterruptSignal := (Signal new) mayProceed:true.
|
|
58 |
UnhandledInterruptSignal notifierString:'unhandled interrupt'.
|
|
59 |
|
1
|
60 |
MessageNotUnderstoodSignal := (Signal new) mayProceed:true.
|
|
61 |
MessageNotUnderstoodSignal notifierString:'message not understood'.
|
|
62 |
|
|
63 |
UserInterruptSignal := (Signal new) mayProceed:true.
|
|
64 |
UserInterruptSignal notifierString:'user Interrupt'.
|
|
65 |
|
|
66 |
RecursionInterruptSignal := (Signal new) mayProceed:false.
|
|
67 |
RecursionInterruptSignal notifierString:'recursion interrupt'.
|
|
68 |
|
|
69 |
ExceptionInterruptSignal := (Signal new) mayProceed:true.
|
|
70 |
ExceptionInterruptSignal notifierString:'exception Interrupt'.
|
|
71 |
|
2
|
72 |
SubscriptOutOfBoundsSignal := (Signal new) mayProceed:false.
|
|
73 |
SubscriptOutOfBoundsSignal notifierString:'subscript out of bounds'.
|
|
74 |
|
|
75 |
ElementOutOfBoundsSignal := (Signal new) mayProceed:false.
|
|
76 |
ElementOutOfBoundsSignal notifierString:'element out of bounds'.
|
|
77 |
|
|
78 |
NotFoundSignal := (Signal new) mayProceed:true.
|
|
79 |
NotFoundSignal notifierString:'no such element'.
|
|
80 |
|
|
81 |
KeyNotFoundSignal := (Signal new) mayProceed:true.
|
|
82 |
KeyNotFoundSignal notifierString:'no such key'.
|
1
|
83 |
|
|
84 |
NonIntegerIndexSignal := (Signal new) mayProceed:false.
|
|
85 |
NonIntegerIndexSignal notifierString:'index must be integer'.
|
|
86 |
|
|
87 |
InformationSignal := (Signal new) mayProceed:true.
|
|
88 |
InformationSignal notifierString:'information'.
|
|
89 |
|
|
90 |
Dependencies := IdentityDictionary new.
|
|
91 |
]
|
|
92 |
|
|
93 |
"Object initialize"
|
|
94 |
! !
|
|
95 |
|
|
96 |
!Object class methodsFor:'signal access'!
|
|
97 |
|
|
98 |
errorSignal
|
|
99 |
"return the signal used for error/error: - messages"
|
|
100 |
|
|
101 |
^ ErrorSignal
|
|
102 |
!
|
|
103 |
|
|
104 |
haltSignal
|
|
105 |
"return the signal used for halt/halt: - messages"
|
|
106 |
|
|
107 |
^ HaltSignal
|
|
108 |
!
|
|
109 |
|
2
|
110 |
unhandledInterruptSignal
|
|
111 |
"return the signal used for unhandled interrupts"
|
|
112 |
|
|
113 |
^ UnhandledInterruptSignal
|
|
114 |
!
|
|
115 |
|
1
|
116 |
messageNotUnderstoodSignal
|
|
117 |
"return the signal used for doesNotUnderstand: - messages"
|
|
118 |
|
|
119 |
^ MessageNotUnderstoodSignal
|
|
120 |
!
|
|
121 |
|
|
122 |
userInterruptSignal
|
|
123 |
"return the signal used for ^C interrupts"
|
|
124 |
|
|
125 |
^ UserInterruptSignal
|
|
126 |
!
|
|
127 |
|
|
128 |
recursionInterruptSignal
|
|
129 |
"return the signal used for recursion overflow reporting"
|
|
130 |
|
|
131 |
^ RecursionInterruptSignal
|
|
132 |
!
|
|
133 |
|
|
134 |
exceptionInterruptSignal
|
|
135 |
"return the signal used for exception (display errors) reporting"
|
|
136 |
|
|
137 |
^ ExceptionInterruptSignal
|
|
138 |
!
|
|
139 |
|
2
|
140 |
subscriptOutOfBoundsSignal
|
|
141 |
"return the signal used for subscript error reporting.
|
|
142 |
(this signal is used for example when an array is accessed with an
|
|
143 |
index less than 1 or greater than the array size)"
|
1
|
144 |
|
2
|
145 |
^ SubscriptOutOfBoundsSignal
|
|
146 |
!
|
|
147 |
|
|
148 |
elementOutOfBoundsSignal
|
|
149 |
"return the signal used for element error reporting
|
|
150 |
(this signal is used for example when a value not in 0..255 is to
|
|
151 |
be put into a bytearray)"
|
|
152 |
|
|
153 |
^ ElementOutOfBoundsSignal
|
1
|
154 |
!
|
|
155 |
|
|
156 |
nonIntegerIndexSignal
|
|
157 |
"return the signal used for bad subscript error reporting"
|
|
158 |
|
|
159 |
^ NonIntegerIndexSignal
|
|
160 |
!
|
|
161 |
|
2
|
162 |
notFoundSignal
|
|
163 |
"return the signal used for element not found error reporting"
|
|
164 |
|
|
165 |
^ NotFoundSignal
|
|
166 |
!
|
|
167 |
|
|
168 |
keyNotFoundSignal
|
|
169 |
"return the signal used for no such key error reporting"
|
|
170 |
|
|
171 |
^ KeyNotFoundSignal
|
|
172 |
!
|
|
173 |
|
1
|
174 |
informationSignal
|
|
175 |
"return the signal used for informations"
|
|
176 |
|
|
177 |
^ InformationSignal
|
|
178 |
! !
|
|
179 |
|
|
180 |
!Object methodsFor:'initialization'!
|
|
181 |
|
|
182 |
initialize
|
|
183 |
"just to ignore initialize to objects which do not need it"
|
|
184 |
|
|
185 |
^ self
|
|
186 |
! !
|
|
187 |
|
|
188 |
!Object methodsFor:'instance creation'!
|
|
189 |
|
|
190 |
readFromString:aString
|
|
191 |
"create an object from its printed representation"
|
|
192 |
|
|
193 |
^ self readFrom:(ReadStream on:aString)
|
|
194 |
!
|
|
195 |
|
|
196 |
readFrom:aStream
|
|
197 |
"read an objects printed representation from the argument,
|
|
198 |
aStream and return it."
|
|
199 |
|
|
200 |
|newObject|
|
|
201 |
newObject := Compiler evaluate:aStream.
|
|
202 |
(newObject isKindOf:self) ifFalse:[
|
|
203 |
self error:('expected ' , self name)
|
|
204 |
].
|
|
205 |
^ newObject
|
|
206 |
! !
|
|
207 |
|
|
208 |
!Object methodsFor:'system primitives'!
|
|
209 |
|
|
210 |
become:anotherObject
|
|
211 |
"make all references to the receiver become references to anotherObject and vice-versa.
|
|
212 |
This may be an expensive (i.e. slow) operation, since in the worst case, the whole memory
|
|
213 |
has to be searched for references to the two objects. In general, using become: should be
|
|
214 |
avoided if possible since it may produce many strange effects.
|
|
215 |
This method fails, if the receiver or the argument is a SmallInteger or nil, or is a context
|
|
216 |
of a living method (i.e. one that has not already returned).
|
|
217 |
(notice that become: is not used by the system - the Collection classes have been rewritten
|
|
218 |
to not use it.)"
|
|
219 |
%{
|
|
220 |
if (primBecome(self, anotherObject))
|
|
221 |
RETURN ( self );
|
|
222 |
%}
|
|
223 |
.
|
|
224 |
self primitiveFailed
|
|
225 |
!
|
|
226 |
|
|
227 |
address
|
|
228 |
"return the core address as an integer
|
|
229 |
- since objects may move around the returned value is invalid after the
|
|
230 |
next scavenge/collect, therefore use only for debugging."
|
|
231 |
|
|
232 |
%{ /* NOCONTEXT */
|
|
233 |
|
|
234 |
if (! _isNonNilObject(self)) {
|
|
235 |
RETURN ( nil );
|
|
236 |
}
|
|
237 |
if ((_qSpace(self) != OLDSPACE) && (_qSpace(self) != STACKSPACE)) {
|
|
238 |
RETURN ( nil );
|
|
239 |
}
|
|
240 |
RETURN ( _MKSMALLINT( (int)self ) );
|
|
241 |
%}
|
|
242 |
! !
|
|
243 |
|
|
244 |
!Object methodsFor:'queries'!
|
|
245 |
|
|
246 |
size
|
|
247 |
"return the number of the receivers indexed instance variables;
|
|
248 |
this method may be redefined in subclasses"
|
|
249 |
|
|
250 |
^ self basicSize
|
|
251 |
!
|
|
252 |
|
|
253 |
basicSize
|
|
254 |
"return the number of the receivers indexed instance variables
|
|
255 |
this method should NOT be redefined in any subclass"
|
|
256 |
|
|
257 |
%{ /* NOCONTEXT */
|
|
258 |
|
|
259 |
register int nbytes;
|
|
260 |
register OBJ myClass;
|
|
261 |
|
|
262 |
/*
|
|
263 |
* notice the missing test for self beeing a nonNilObject -
|
|
264 |
* this can be done since basicSize is defined both in UndefinedObject
|
|
265 |
* and SmallInteger
|
|
266 |
*/
|
|
267 |
myClass = _qClass(self);
|
|
268 |
nbytes = _qSize(self)
|
|
269 |
- OHDR_SIZE
|
|
270 |
- _intVal(_ClassInstPtr(myClass)->c_ninstvars) * sizeof(OBJ);
|
|
271 |
|
|
272 |
switch (_intVal(_ClassInstPtr(myClass)->c_flags) & ARRAYMASK) {
|
|
273 |
case BYTEARRAY:
|
|
274 |
RETURN ( _MKSMALLINT(nbytes / sizeof(char)) );
|
|
275 |
|
|
276 |
case WORDARRAY:
|
|
277 |
RETURN ( _MKSMALLINT(nbytes / sizeof(short)) );
|
|
278 |
|
|
279 |
case LONGARRAY:
|
|
280 |
RETURN ( _MKSMALLINT(nbytes / sizeof(long)) );
|
|
281 |
|
|
282 |
case FLOATARRAY:
|
|
283 |
RETURN ( _MKSMALLINT(nbytes / sizeof(float)) );
|
|
284 |
|
|
285 |
case DOUBLEARRAY:
|
|
286 |
RETURN ( _MKSMALLINT(nbytes / sizeof(double)) );
|
|
287 |
|
|
288 |
case WKPOINTERARRAY:
|
|
289 |
case POINTERARRAY:
|
|
290 |
RETURN ( _MKSMALLINT(nbytes / sizeof(OBJ)) );
|
|
291 |
}
|
|
292 |
%}
|
|
293 |
.
|
|
294 |
^ 0
|
|
295 |
!
|
|
296 |
|
|
297 |
objectSize
|
|
298 |
"return the size of the receiver in bytes - for debugging only"
|
|
299 |
|
|
300 |
%{ /* NOCONTEXT */
|
|
301 |
|
|
302 |
RETURN ( _isNonNilObject(self) ? _MKSMALLINT(_qSize(self))
|
|
303 |
: _MKSMALLINT(0) )
|
|
304 |
%}
|
|
305 |
!
|
|
306 |
|
|
307 |
isVariable
|
|
308 |
"return true if the receiver has indexed instance variables,
|
|
309 |
false otherwise"
|
|
310 |
|
|
311 |
^ self class isVariable
|
|
312 |
!
|
|
313 |
|
|
314 |
isFixedSize
|
|
315 |
"return true if the receiver cannot grow - this will vanish once things
|
|
316 |
like Array and String learn how to grow ..."
|
|
317 |
|
|
318 |
^ true
|
|
319 |
!
|
|
320 |
|
|
321 |
class
|
|
322 |
"return the receivers class"
|
|
323 |
|
|
324 |
%{ /* NOCONTEXT */
|
|
325 |
|
|
326 |
RETURN ( _Class(self) );
|
|
327 |
%}
|
|
328 |
!
|
|
329 |
|
|
330 |
species
|
|
331 |
"return a class which is similar to (or the same as) the receivers class.
|
|
332 |
This is used to create an appropriate object when creating derived
|
|
333 |
copies in the Collection classes (sometimes redefined)."
|
|
334 |
|
|
335 |
^ self class
|
|
336 |
!
|
|
337 |
|
|
338 |
yourself
|
|
339 |
"return the receiver - used for cascades to return self at the end"
|
|
340 |
|
|
341 |
^ self
|
|
342 |
!
|
|
343 |
|
|
344 |
isBehavior
|
|
345 |
"return true, if the receiver is some kind of class (i.e. behavior);
|
|
346 |
false is returned here - the method is redefined in Behavior"
|
|
347 |
|
|
348 |
^ false
|
|
349 |
!
|
|
350 |
|
2
|
351 |
isClass
|
|
352 |
"return true, if the receiver is some kind of class (real class, not
|
|
353 |
just behavior);
|
|
354 |
false is returned here - the method is redefined in Class"
|
|
355 |
|
|
356 |
^ false
|
|
357 |
!
|
|
358 |
|
1
|
359 |
isMeta
|
|
360 |
"return true, if the receiver is some kind of metaclass;
|
|
361 |
false is returned here - the method is redefined in Metaclass"
|
|
362 |
|
|
363 |
^ false
|
|
364 |
!
|
|
365 |
|
|
366 |
isBlock
|
|
367 |
"return true, iff the receiver is some kind of Block;
|
|
368 |
false returned here - the method is redefined in Block."
|
|
369 |
|
|
370 |
^ false
|
|
371 |
!
|
|
372 |
|
|
373 |
isContext
|
|
374 |
"return true, iff the receiver is some kind of Context;
|
|
375 |
false returned here - the method is redefined in Context."
|
|
376 |
|
|
377 |
^ false
|
|
378 |
!
|
|
379 |
|
|
380 |
isStream
|
|
381 |
"return true, if the receiver is some kind of stream;
|
|
382 |
false is returned here - the method is redefined in Stream"
|
|
383 |
|
|
384 |
^ false
|
|
385 |
!
|
|
386 |
|
2
|
387 |
isFileStream
|
|
388 |
"return true, if the receiver is some kind of fileStream;
|
|
389 |
false is returned here - the method is redefined in FileStream"
|
|
390 |
|
|
391 |
^false
|
|
392 |
!
|
|
393 |
|
1
|
394 |
isInteger
|
|
395 |
"return true, if the receiver is some kind of integer number;
|
|
396 |
false is returned here - the method is redefined in Integer"
|
|
397 |
|
|
398 |
^ false
|
|
399 |
!
|
|
400 |
|
|
401 |
respondsToArithmetic
|
|
402 |
"return true, if the receiver responds to arithmetic messages.
|
|
403 |
false is returned here - the method is redefined in ArithmeticValue"
|
|
404 |
|
|
405 |
^ false
|
|
406 |
!
|
|
407 |
|
|
408 |
isMemberOf:aClass
|
|
409 |
"return true, if the receiver is an instance of aClass, false otherwise"
|
|
410 |
|
|
411 |
^ (self class) == aClass
|
|
412 |
!
|
|
413 |
|
|
414 |
isKindOf:aClass
|
|
415 |
"return true, if the receiver is an instance of aClass or one of its
|
|
416 |
subclasses, false otherwise"
|
|
417 |
|
|
418 |
%{ /* NOCONTEXT */
|
|
419 |
|
|
420 |
register OBJ thisClass;
|
|
421 |
|
|
422 |
thisClass = _Class(self);
|
|
423 |
while (thisClass != nil) {
|
|
424 |
if (thisClass == aClass) {
|
|
425 |
RETURN ( true );
|
|
426 |
}
|
|
427 |
thisClass = _ClassInstPtr(thisClass)->c_superclass;
|
|
428 |
}
|
|
429 |
%}
|
|
430 |
.
|
|
431 |
^ false
|
|
432 |
!
|
|
433 |
|
|
434 |
respondsTo:aSelector
|
|
435 |
"return true, if the receiver implements a method with selector equal
|
|
436 |
to aSelector; i.e. if there is a method for aSelector in either the
|
|
437 |
receivers class or one of its superclasses"
|
|
438 |
|
|
439 |
%{ /* NOCONTEXT */
|
|
440 |
|
|
441 |
extern OBJ lookup();
|
|
442 |
|
|
443 |
if (lookup(_Class(self), aSelector) == nil) {
|
|
444 |
RETURN ( false );
|
|
445 |
}
|
|
446 |
RETURN ( true );
|
|
447 |
%}
|
|
448 |
.
|
|
449 |
^ self class canUnderstand:aSelector
|
|
450 |
!
|
|
451 |
|
|
452 |
references:anObject
|
|
453 |
"return true, if the receiver refers to the argument, anObject.
|
|
454 |
- for debugging only"
|
|
455 |
|
|
456 |
|myClass
|
|
457 |
numInst "{ Class: SmallInteger }" |
|
|
458 |
|
|
459 |
myClass := self class.
|
|
460 |
|
|
461 |
"check the class"
|
|
462 |
(myClass == anObject) ifTrue:[^ true].
|
|
463 |
|
|
464 |
"check the instance variables"
|
|
465 |
numInst := myClass instSize.
|
|
466 |
1 to:numInst do:[:i |
|
|
467 |
((self instVarAt:i) == anObject) ifTrue:[^ true]
|
|
468 |
].
|
|
469 |
|
|
470 |
"check the indexed variables"
|
|
471 |
myClass isVariable ifTrue:[
|
|
472 |
numInst := myClass basicSize.
|
|
473 |
1 to:numInst do:[:i |
|
|
474 |
((self basicAt:i) == anObject) ifTrue:[^ true]
|
|
475 |
]
|
|
476 |
].
|
|
477 |
^ false
|
|
478 |
!
|
|
479 |
|
|
480 |
allOwners
|
|
481 |
"return a collection of all objects referencing the receiver"
|
|
482 |
|
|
483 |
^ ObjectMemory whoReferences:self
|
|
484 |
! !
|
|
485 |
|
|
486 |
!Object methodsFor:'misc'!
|
|
487 |
|
|
488 |
-> anObject
|
|
489 |
"return an association with the receiver as key and
|
|
490 |
the argument as value"
|
|
491 |
|
|
492 |
^ Association key:self value:anObject
|
|
493 |
! !
|
|
494 |
|
|
495 |
!Object methodsFor:'copying'!
|
|
496 |
|
|
497 |
copy
|
|
498 |
"return a copy of the receiver - defaults to shallowcopy here"
|
|
499 |
|
|
500 |
^ self shallowCopy
|
|
501 |
!
|
|
502 |
|
|
503 |
shallowCopy
|
|
504 |
"return a copy of the object with shared subobjects i.e. shallow copies
|
|
505 |
of its instance objects.
|
|
506 |
This method does NOT handle cycles"
|
|
507 |
|
|
508 |
|myClass aCopy
|
|
509 |
sz "{ Class: SmallInteger }" |
|
|
510 |
|
|
511 |
myClass := self class.
|
|
512 |
myClass isVariable ifTrue:[
|
|
513 |
sz := self basicSize.
|
|
514 |
aCopy := myClass basicNew:sz.
|
|
515 |
|
|
516 |
"copy the indexed variables"
|
|
517 |
1 to:sz do:[:i |
|
|
518 |
aCopy basicAt:i put:(self basicAt:i)
|
|
519 |
]
|
|
520 |
] ifFalse:[
|
|
521 |
aCopy := myClass basicNew
|
|
522 |
].
|
|
523 |
|
|
524 |
"copy the instance variables"
|
|
525 |
sz := myClass instSize.
|
|
526 |
1 to:sz do:[:i |
|
|
527 |
aCopy instVarAt:i put:(self instVarAt:i)
|
|
528 |
].
|
|
529 |
|
|
530 |
^ aCopy
|
|
531 |
!
|
|
532 |
|
|
533 |
deepCopy
|
|
534 |
"return a copy of the object with all subobjects also copied.
|
|
535 |
This method does NOT handle cycles"
|
|
536 |
|
|
537 |
|myClass aCopy
|
|
538 |
sz "{ Class: SmallInteger }" |
|
|
539 |
|
|
540 |
myClass := self class.
|
|
541 |
myClass isVariable ifTrue:[
|
|
542 |
sz := self basicSize.
|
|
543 |
aCopy := myClass basicNew:sz.
|
|
544 |
|
|
545 |
"copy the indexed variables"
|
|
546 |
1 to:sz do:[:i |
|
|
547 |
aCopy basicAt:i put:((self basicAt:i) deepCopy)
|
|
548 |
]
|
|
549 |
] ifFalse:[
|
|
550 |
aCopy := myClass basicNew
|
|
551 |
].
|
|
552 |
|
|
553 |
"copy the instance variables"
|
|
554 |
sz := myClass instSize.
|
|
555 |
1 to:sz do:[:i |
|
|
556 |
aCopy instVarAt:i put:((self instVarAt:i) deepCopy)
|
|
557 |
].
|
|
558 |
|
|
559 |
^ aCopy
|
|
560 |
! !
|
|
561 |
|
|
562 |
!Object methodsFor:'comparing'!
|
|
563 |
|
|
564 |
== anObject
|
|
565 |
"return true, if the receiver and the arg are the same object"
|
|
566 |
|
|
567 |
%{ /* NOCONTEXT */
|
|
568 |
|
|
569 |
RETURN ( (self == anObject) ? true : false );
|
|
570 |
%}
|
|
571 |
!
|
|
572 |
|
|
573 |
~~ anObject
|
|
574 |
"return true, if the receiver and the arg are not the same object"
|
|
575 |
|
|
576 |
%{ /* NOCONTEXT */
|
|
577 |
|
|
578 |
RETURN ( (self == anObject) ? false : true );
|
|
579 |
%}
|
|
580 |
!
|
|
581 |
|
|
582 |
= anObject
|
|
583 |
"return true, if the receiver and the arg have the same structure"
|
|
584 |
|
|
585 |
^ self == anObject
|
|
586 |
!
|
|
587 |
|
|
588 |
~= anObject
|
|
589 |
"return true, if the receiver and the arg do not have the same structure"
|
|
590 |
|
|
591 |
^ (self = anObject) not
|
|
592 |
!
|
|
593 |
|
|
594 |
isNil
|
|
595 |
"return true, if the receiver is nil"
|
|
596 |
|
|
597 |
^ false
|
|
598 |
!
|
|
599 |
|
|
600 |
notNil
|
|
601 |
"return true, if the receiver is not nil"
|
|
602 |
|
|
603 |
^ true
|
|
604 |
!
|
|
605 |
|
|
606 |
hash
|
|
607 |
"return an Integer useful as a hash key for the receiver.
|
|
608 |
This hash should return same values for objects with same
|
|
609 |
contents (i.e. use this to hash on structure)"
|
|
610 |
|
|
611 |
^ self identityHash
|
|
612 |
!
|
|
613 |
|
|
614 |
identityHash
|
|
615 |
"return an Integer useful as a hash key for the receiver.
|
|
616 |
This hash should return same values for the same object (i.e. use
|
|
617 |
this to hash on identity of objects).
|
|
618 |
|
|
619 |
We cannot use the Objects address (as other smalltalks do) since
|
|
620 |
no object-table exists and the hashval must not change when objects
|
|
621 |
are moved by the collector. Therefore we assign each object a unique
|
|
622 |
Id in the object header itself as its hashed upon.
|
|
623 |
(luckily we have 12 bits spare to do this - unluckily its only 12 bits).
|
|
624 |
To expand the range a bit, these 12 hashBits are concatenated to the
|
|
625 |
receivers class hashBits, to form a 24bit hashvalue (which will not
|
2
|
626 |
help, if many objects of the same class are hashed upon ...).
|
|
627 |
Time will show, if 12 bits are enough, if not another entry in the
|
|
628 |
object header will be needed, adding 4 bytes to every object. Alternatively,
|
|
629 |
hashed-upon objects could add an instvar containing the hash value."
|
1
|
630 |
|
|
631 |
%{ /* NOCONTEXT */
|
|
632 |
|
|
633 |
REGISTER int v1, v2;
|
|
634 |
static int nextHash = 0;
|
|
635 |
OBJ cls;
|
|
636 |
|
|
637 |
if (_isObject(self)) {
|
|
638 |
v1 = ((self->o_age & ~AGE_MASK) >> 5) << 8;
|
|
639 |
v1 |= (self->o_hashLow);
|
|
640 |
if (v1 == 0) {
|
|
641 |
v1 = nextHash++;
|
|
642 |
if (v1 == 0)
|
|
643 |
v1 = nextHash++;
|
|
644 |
self->o_hashLow = v1 & 0xFF;
|
|
645 |
self->o_age |= (v1 >> 8) << 5;
|
|
646 |
}
|
|
647 |
|
|
648 |
cls = _qClass(self);
|
|
649 |
v2 = ((cls->o_age & ~AGE_MASK) >> 5) << 8;
|
|
650 |
v2 |= (cls->o_hashLow);
|
|
651 |
if (v2 == 0) {
|
|
652 |
v2 = nextHash++;
|
|
653 |
if (v2 == 0)
|
|
654 |
v2 = nextHash++;
|
|
655 |
cls->o_hashLow = v2 & 0xFF;
|
|
656 |
cls->o_age |= (v2 >> 8) << 5;
|
|
657 |
}
|
|
658 |
RETURN ( _MKSMALLINT((v2<<12) | v1) );
|
|
659 |
}
|
|
660 |
%}
|
|
661 |
.
|
|
662 |
^ 0
|
|
663 |
! !
|
|
664 |
|
|
665 |
!Object methodsFor:'interrupt handling'!
|
|
666 |
|
2
|
667 |
internalError:msg
|
|
668 |
"this is triggered, when system hits some bad error,
|
|
669 |
such as corrupted class, corrupted method/selector array
|
|
670 |
etc. (for example, if you set an objects class to a small-
|
|
671 |
integer, nil etc).
|
|
672 |
Its not guaranteed, that the system is in a working condition ...."
|
|
673 |
|
|
674 |
self error:msg
|
|
675 |
!
|
|
676 |
|
1
|
677 |
userInterrupt
|
|
678 |
"user (^c) interrupt - enter debugger"
|
|
679 |
|
2
|
680 |
"UserInterruptSignal raise"
|
1
|
681 |
self error:'user Interrupt'
|
|
682 |
!
|
|
683 |
|
|
684 |
ioInterrupt
|
|
685 |
"io (SIGIO/SIGPOLL) interrupt and no handler - enter debugger"
|
|
686 |
|
|
687 |
self error:'user Interrupt'
|
|
688 |
!
|
|
689 |
|
2
|
690 |
childSignalInterrupt
|
|
691 |
"death of a child process (unix process) - do nothing"
|
|
692 |
|
|
693 |
^ self
|
|
694 |
!
|
|
695 |
|
1
|
696 |
spyInterrupt
|
|
697 |
"spy interrupt and no handler - enter debugger"
|
|
698 |
|
|
699 |
self error:'spy Interrupt'
|
|
700 |
!
|
|
701 |
|
|
702 |
timerInterrupt
|
|
703 |
"timer interrupt and no handler - enter debugger"
|
|
704 |
|
|
705 |
self error:'timer Interrupt'
|
|
706 |
!
|
|
707 |
|
|
708 |
errorInterrupt
|
2
|
709 |
"x-error interrupt"
|
1
|
710 |
|
2
|
711 |
^ ErrorSignal
|
|
712 |
raiseRequestWith:nil
|
|
713 |
errorString: 'Display error: ' , (Display lastError)
|
|
714 |
"
|
1
|
715 |
self error:'error Interrupt:' , (Display lastError)
|
2
|
716 |
"
|
1
|
717 |
!
|
|
718 |
|
|
719 |
memoryInterrupt
|
|
720 |
"out-of-memory interrupt and no handler - enter debugger"
|
|
721 |
|
|
722 |
self error:'almost out of memory'
|
|
723 |
!
|
|
724 |
|
|
725 |
fpExceptionInterrupt
|
|
726 |
"a floating point exception occured - this one
|
|
727 |
has to be handled differently since they come asynchronous
|
|
728 |
on some machines"
|
|
729 |
|
|
730 |
self error:'a floating point exception occured'
|
|
731 |
!
|
|
732 |
|
|
733 |
signalInterrupt:signalNumber
|
2
|
734 |
"unix signal occured - some signals are handled as Smalltalk Exceptions (SIGPIPE),
|
|
735 |
others (SIGBUS) are rather fatal ..."
|
1
|
736 |
|
|
737 |
|box|
|
|
738 |
|
2
|
739 |
(signalNumber == 13) ifTrue:[
|
|
740 |
"SIGPIPE - write on a pipe with no one to read"
|
|
741 |
|
|
742 |
^ PipeStream pipeSignal raise.
|
|
743 |
].
|
|
744 |
(signalNumber == 15) ifTrue:[
|
|
745 |
"SIGTERM - software termination"
|
|
746 |
].
|
|
747 |
(signalNumber == 16) ifTrue:[
|
|
748 |
"SIGURG - io urgent condition"
|
|
749 |
].
|
|
750 |
|
|
751 |
"other signals bring up a box asking for what to do ..."
|
|
752 |
|
1
|
753 |
(Smalltalk at:#SignalCatchBlock) notNil ifTrue:[
|
|
754 |
box := OptionBox title:('Signal ' ,
|
|
755 |
signalNumber printString ,
|
|
756 |
' cought')
|
|
757 |
numberOfOptions:5.
|
|
758 |
|
|
759 |
box buttonTitles:#('ignore' 'debug' 'restart' 'dump' 'exit').
|
|
760 |
box actions:(Array with:[^ nil]
|
|
761 |
with:[Debugger enterWithMessage:'Signal ', signalNumber printString. ^nil]
|
|
762 |
with:[SignalCatchBlock value. ^nil]
|
|
763 |
with:[Smalltalk fatalAbort]
|
|
764 |
with:[Smalltalk exit]).
|
|
765 |
box showAtPointer
|
|
766 |
].
|
|
767 |
|
|
768 |
self error:('signal ' , signalNumber printString)
|
|
769 |
!
|
|
770 |
|
|
771 |
recursionInterrupt
|
|
772 |
"recursion limit interrupt - enter debugger"
|
|
773 |
|
2
|
774 |
"RecursionInterruptSignal raise"
|
1
|
775 |
self error:'recursion limit reached'
|
|
776 |
!
|
|
777 |
|
|
778 |
exceptionInterrupt
|
|
779 |
"exception interrupt - enter debugger"
|
|
780 |
|
|
781 |
self error:'exception Interrupt'
|
|
782 |
! !
|
|
783 |
|
|
784 |
!Object methodsFor:'error handling'!
|
|
785 |
|
2
|
786 |
subscriptBoundsError
|
1
|
787 |
"report error that badIndex is out of bounds"
|
|
788 |
|
2
|
789 |
SubscriptOutOfBoundsSignal raise
|
|
790 |
!
|
|
791 |
|
|
792 |
elementBoundsError
|
|
793 |
"report error that badElement is out of bounds (i.e. cannot be put into
|
|
794 |
that collection)"
|
|
795 |
|
|
796 |
ElementOutOfBoundsSignal raise
|
1
|
797 |
!
|
|
798 |
|
|
799 |
indexNotInteger
|
|
800 |
"report error that index is not an Integer"
|
|
801 |
|
|
802 |
NonIntegerIndexSignal raise
|
2
|
803 |
!
|
|
804 |
|
|
805 |
errorNotFound
|
|
806 |
"report error that an element was not found in a collection"
|
|
807 |
|
|
808 |
NotFoundSignal raise
|
|
809 |
!
|
|
810 |
|
|
811 |
errorKeyNotFound
|
|
812 |
"report error that a key was not found in a collection"
|
|
813 |
|
|
814 |
KeyNotFoundSignal raise
|
1
|
815 |
!
|
|
816 |
|
|
817 |
elementNotInteger
|
|
818 |
"report error that object to be stored is no Integer"
|
|
819 |
|
2
|
820 |
ElementOutOfBoundsSignal raise
|
|
821 |
"
|
1
|
822 |
^ self error:'element must be an Integer'
|
2
|
823 |
"
|
1
|
824 |
!
|
|
825 |
|
|
826 |
elementNotCharacter
|
|
827 |
"report error that object to be stored is no Character"
|
|
828 |
|
|
829 |
^ self error:'element must be a Character'
|
|
830 |
!
|
|
831 |
|
|
832 |
elementOutOfBounds
|
|
833 |
"report error that object to be stored is not valid"
|
|
834 |
|
|
835 |
^ self error:'element out of bounds'
|
|
836 |
!
|
|
837 |
|
|
838 |
mustBeRectangle
|
|
839 |
"report an argument-not-rectangle-error"
|
|
840 |
|
|
841 |
^ self error:'argument must be a Rectangle'
|
|
842 |
!
|
|
843 |
|
|
844 |
mustBeString
|
|
845 |
"report an argument-not-string-error"
|
|
846 |
|
|
847 |
^ self error:'argument must be a String'
|
|
848 |
!
|
|
849 |
|
|
850 |
notIndexed
|
|
851 |
"report error that receiver has no indexed instance variables"
|
|
852 |
|
|
853 |
^ self error:'receiver has no indexed variables'
|
|
854 |
!
|
|
855 |
|
2
|
856 |
integerCheckError
|
|
857 |
"generated when a variable declared with an integer type gets a bad
|
|
858 |
value assigned"
|
|
859 |
|
|
860 |
^ self error:'bad assign of ' , self printString ,
|
|
861 |
' (' , self class name , ') to integer-typed variable'
|
|
862 |
!
|
|
863 |
|
1
|
864 |
typeCheckError
|
|
865 |
"generated when a variable declared with a type hint gets a bad
|
|
866 |
value assigned"
|
|
867 |
|
2
|
868 |
^ self error:'bad assign of ' , self printString ,
|
|
869 |
' (' , self class name , ') to typed variable'
|
1
|
870 |
!
|
|
871 |
|
|
872 |
primitiveFailed
|
|
873 |
"report error that primitive code failed"
|
|
874 |
|
|
875 |
^ self error:'primitive failed'
|
|
876 |
!
|
|
877 |
|
|
878 |
subclassResponsibility
|
|
879 |
"report error that this message should have been reimplemented in a
|
|
880 |
subclass"
|
|
881 |
|
|
882 |
^ self error:'method must be reimplemented in subclass'
|
|
883 |
!
|
|
884 |
|
|
885 |
shouldNotImplement
|
|
886 |
"report error that this message should not be implemented"
|
|
887 |
|
|
888 |
^ self error:'method not appropriate for this class'
|
|
889 |
!
|
|
890 |
|
|
891 |
error
|
|
892 |
"report error that an error occured"
|
|
893 |
|
|
894 |
^ self error:'error encountered'
|
|
895 |
!
|
|
896 |
|
|
897 |
halt
|
|
898 |
"enter debugger with halt-message"
|
|
899 |
|
2
|
900 |
"
|
|
901 |
HaltSignal raise.
|
|
902 |
"
|
1
|
903 |
^ self halt:'halt encountered'
|
|
904 |
!
|
|
905 |
|
2
|
906 |
debuggerBreak
|
|
907 |
"call the dummy debug function, on which a breakpoint
|
|
908 |
can be put in adb, sdb, dbx or gdb"
|
|
909 |
|
|
910 |
%{
|
|
911 |
_PATCHUPCONTEXTS(__context);
|
|
912 |
debugBreakPoint();
|
|
913 |
%}
|
|
914 |
!
|
|
915 |
|
1
|
916 |
fatalError:aMessage
|
|
917 |
"report a fatal-error; system dumps a backtrace and exits with core dump"
|
|
918 |
%{
|
|
919 |
/*
|
|
920 |
* do not use any message calls here
|
|
921 |
* - since this might lead to infinite recursion ...
|
|
922 |
*/
|
|
923 |
if (_isString(aMessage))
|
|
924 |
printf("%s\n", _stringVal(aMessage));
|
|
925 |
printStack(__context);
|
|
926 |
exit(1);
|
|
927 |
%}
|
|
928 |
!
|
|
929 |
|
|
930 |
checkForRecursiveError
|
|
931 |
"helper for all error-methods; catch error while in Debugger.
|
|
932 |
If Debugger is DebugView, try switching to MiniDebugger (as
|
|
933 |
a last chance) otherwise abort.
|
|
934 |
There should not be an error in the debugger, this will only
|
|
935 |
happen if some classes has been changed badly."
|
|
936 |
|
|
937 |
ErrorActive ifTrue:[
|
|
938 |
(Debugger == MiniDebugger) ifTrue:[
|
|
939 |
ErrorRecursion ifFalse:[
|
|
940 |
%{
|
|
941 |
printf("recursive error ...\n");
|
|
942 |
printStack(__context);
|
|
943 |
mainExit(0);
|
|
944 |
%}
|
|
945 |
]
|
|
946 |
].
|
|
947 |
"set to MiniDebugger - and go on"
|
|
948 |
^ MiniDebugger
|
|
949 |
].
|
|
950 |
^ Debugger
|
|
951 |
!
|
|
952 |
|
|
953 |
error:aString
|
|
954 |
"enter debugger with error-message aString;
|
|
955 |
if nonNil, the global ErrorHandler is informed instead -
|
|
956 |
this gives a chance for private error handling and error catching
|
|
957 |
within debugger"
|
|
958 |
|
|
959 |
|retVal debugger|
|
|
960 |
|
|
961 |
ErrorHandler notNil ifTrue:[
|
|
962 |
^ ErrorHandler catch:#error: with:aString for:self
|
|
963 |
].
|
2
|
964 |
|
1
|
965 |
Debugger isNil ifTrue:[
|
|
966 |
'error: ' print. aString printNewline.
|
|
967 |
self fatalError:'no Debugger defined'
|
|
968 |
].
|
|
969 |
debugger := self checkForRecursiveError.
|
|
970 |
ErrorActive := true.
|
|
971 |
retVal := debugger enterWithMessage:aString.
|
|
972 |
ErrorActive := false.
|
|
973 |
^ retVal
|
|
974 |
!
|
|
975 |
|
|
976 |
doesNotUnderstand:aMessage
|
|
977 |
"enter debugger with does-not-understand-message;
|
|
978 |
if nonNil, the global ErrorHandler is informed instead -
|
|
979 |
this gives a chance for private error handling and error catching
|
|
980 |
within debugger"
|
|
981 |
|
|
982 |
|retVal debugger|
|
|
983 |
|
2
|
984 |
"
|
|
985 |
^ Object messageNotUnderstoodSignal
|
|
986 |
raiseRequestWith: aMessage
|
|
987 |
errorString: 'Message not understood: ' , aMessage selector
|
|
988 |
"
|
1
|
989 |
ErrorHandler notNil ifTrue:[
|
|
990 |
^ ErrorHandler catch:#doesNotUnderstand: with:aMessage for:self
|
|
991 |
].
|
|
992 |
Debugger isNil ifTrue:[
|
|
993 |
'doesNotUnderstand:' print. aMessage selector printNewline.
|
|
994 |
self fatalError:'no Debugger defined'
|
|
995 |
].
|
|
996 |
debugger := self checkForRecursiveError.
|
|
997 |
ErrorActive := true.
|
|
998 |
retVal := debugger enterWithMessage:(self class name ,
|
|
999 |
' does not understand:' ,
|
|
1000 |
aMessage printString).
|
|
1001 |
ErrorActive := false.
|
|
1002 |
^ retVal
|
|
1003 |
!
|
|
1004 |
|
|
1005 |
halt:aString
|
|
1006 |
"enter debugger with halt-message;
|
|
1007 |
the global ErrorHandler if nonNil is informed instead -
|
|
1008 |
this gives a chance for private error handling and error catching
|
|
1009 |
within debugger"
|
|
1010 |
|
|
1011 |
|retVal debugger|
|
|
1012 |
|
|
1013 |
ErrorHandler notNil ifTrue:[
|
|
1014 |
^ ErrorHandler catch:#halt: with:aString for:self
|
|
1015 |
].
|
|
1016 |
Debugger isNil ifTrue:[
|
|
1017 |
'halt encountered:' print. aString printNewline.
|
|
1018 |
self fatalError:'no Debugger defined'
|
|
1019 |
].
|
|
1020 |
debugger := self checkForRecursiveError.
|
|
1021 |
ErrorActive := true.
|
|
1022 |
retVal := debugger enterWithMessage:aString.
|
|
1023 |
ErrorActive := false.
|
|
1024 |
^ retVal
|
|
1025 |
! !
|
|
1026 |
|
|
1027 |
!Object methodsFor:'debugging'!
|
|
1028 |
|
|
1029 |
notify:aString
|
|
1030 |
"launch a Notifier, telling user something"
|
|
1031 |
|
|
1032 |
SystemNotifier isNil ifTrue:[
|
|
1033 |
Notifier isNil ifTrue:[
|
|
1034 |
Transcript showCr:aString.
|
|
1035 |
^ self
|
|
1036 |
].
|
|
1037 |
SystemNotifier := Notifier new
|
|
1038 |
].
|
|
1039 |
SystemNotifier title:aString.
|
|
1040 |
SystemNotifier showAtPointer
|
|
1041 |
!
|
|
1042 |
|
|
1043 |
information:aString
|
|
1044 |
"launch an InfoBox, telling user something"
|
|
1045 |
|
|
1046 |
SystemInfoBox isNil ifTrue:[
|
|
1047 |
InfoBox isNil ifTrue:[
|
|
1048 |
Transcript showCr:aString.
|
|
1049 |
^ self
|
|
1050 |
].
|
|
1051 |
SystemInfoBox := InfoBox new
|
|
1052 |
].
|
|
1053 |
SystemInfoBox title:aString.
|
|
1054 |
SystemInfoBox showAtPointer
|
|
1055 |
!
|
|
1056 |
|
|
1057 |
warn:aString
|
|
1058 |
"launch a WarningBox, telling user something"
|
|
1059 |
|
|
1060 |
SystemWarningBox isNil ifTrue:[
|
|
1061 |
WarningBox isNil ifTrue:[
|
|
1062 |
Transcript showCr:aString.
|
|
1063 |
^ self
|
|
1064 |
].
|
|
1065 |
SystemWarningBox := WarningBox new
|
|
1066 |
].
|
|
1067 |
SystemWarningBox title:aString.
|
|
1068 |
SystemWarningBox showAtPointer
|
|
1069 |
!
|
|
1070 |
|
|
1071 |
confirm:aString
|
|
1072 |
"launch a confirmer, which allows user to enter yes or no.
|
|
1073 |
return true for yes, false for no"
|
|
1074 |
|
|
1075 |
SystemConfirmer isNil ifTrue:[
|
|
1076 |
YesNoBox isNil ifTrue:[
|
|
1077 |
Transcript show:'no YesNoBox. '.
|
|
1078 |
Transcript showCr:aString.
|
|
1079 |
^ true
|
|
1080 |
].
|
|
1081 |
SystemConfirmer := YesNoBox new
|
|
1082 |
].
|
|
1083 |
SystemConfirmer title:aString.
|
|
1084 |
SystemConfirmer yesAction:[^ true] noAction:[^ false].
|
|
1085 |
SystemConfirmer showAtPointer
|
|
1086 |
!
|
|
1087 |
|
|
1088 |
basicInspect
|
|
1089 |
"launch an inspector on the receiver.
|
|
1090 |
this method should NOT be redefined in subclasses."
|
|
1091 |
|
|
1092 |
Inspector isNil ifTrue:[
|
|
1093 |
Transcript showCr:'no Inspector defined'
|
|
1094 |
] ifFalse:[
|
|
1095 |
Inspector openOn:self
|
|
1096 |
]
|
|
1097 |
!
|
|
1098 |
|
|
1099 |
inspect
|
|
1100 |
"launch an inspector on the receiver.
|
|
1101 |
this method can be redefined in subclasses."
|
|
1102 |
|
|
1103 |
^ self basicInspect
|
|
1104 |
! !
|
|
1105 |
|
|
1106 |
!Object methodsFor:'accessing'!
|
|
1107 |
|
|
1108 |
at:index
|
|
1109 |
"return the indexed instance variable with index, anInteger;
|
|
1110 |
this method can be redefined in subclasses."
|
|
1111 |
|
|
1112 |
^ self basicAt:index
|
|
1113 |
!
|
|
1114 |
|
|
1115 |
basicAt:index
|
|
1116 |
"return the indexed instance variable with index, anInteger.
|
|
1117 |
Trigger an error if the receiver has no indexed instance variables.
|
|
1118 |
This method should NOT be redefined in any subclass"
|
|
1119 |
|
|
1120 |
%{ /* NOCONTEXT */
|
|
1121 |
|
|
1122 |
register int nbytes, indx;
|
|
1123 |
OBJ myClass;
|
|
1124 |
register char *pFirst;
|
|
1125 |
unsigned char *cp;
|
|
1126 |
unsigned short *sp;
|
|
1127 |
long *lp;
|
|
1128 |
OBJ *op;
|
|
1129 |
int nInstBytes, ninstvars;
|
|
1130 |
extern OBJ _makeLarge();
|
|
1131 |
|
|
1132 |
|
|
1133 |
/*
|
|
1134 |
* notice the missing test for self beeing a nonNilObject -
|
|
1135 |
* this can be done since basicAt: is defined both in UndefinedObject
|
|
1136 |
* and SmallInteger
|
|
1137 |
*/
|
|
1138 |
if (_isSmallInteger(index)) {
|
|
1139 |
myClass = _qClass(self);
|
|
1140 |
indx = _intVal(index) - 1;
|
|
1141 |
ninstvars = _intVal(_ClassInstPtr(myClass)->c_ninstvars);
|
|
1142 |
nInstBytes = OHDR_SIZE + ninstvars * sizeof(OBJ);
|
|
1143 |
nbytes = _qSize(self) - nInstBytes;
|
|
1144 |
pFirst = (char *)(_InstPtr(self)) + nInstBytes;
|
|
1145 |
|
|
1146 |
switch (_intVal(_ClassInstPtr(myClass)->c_flags) & ARRAYMASK) {
|
|
1147 |
case BYTEARRAY:
|
|
1148 |
if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) {
|
|
1149 |
cp = (unsigned char *)pFirst + indx;
|
|
1150 |
RETURN ( _MKSMALLINT(*cp & 0xFF) );
|
|
1151 |
}
|
|
1152 |
break;
|
|
1153 |
|
|
1154 |
case WORDARRAY:
|
|
1155 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) {
|
|
1156 |
sp = (unsigned short *)pFirst + indx;
|
|
1157 |
RETURN ( _MKSMALLINT(*sp & 0xFFFF) );
|
|
1158 |
}
|
|
1159 |
break;
|
|
1160 |
|
|
1161 |
case LONGARRAY:
|
|
1162 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) {
|
|
1163 |
lp = (long *)pFirst + indx;
|
|
1164 |
if ((*lp >= _MIN_INT) && (*lp <= _MAX_INT))
|
|
1165 |
RETURN ( _MKSMALLINT(*lp) );
|
|
1166 |
RETURN ( _makeLarge(*lp) );
|
|
1167 |
}
|
|
1168 |
break;
|
|
1169 |
|
|
1170 |
case FLOATARRAY:
|
|
1171 |
if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) {
|
|
1172 |
float *fp;
|
|
1173 |
|
|
1174 |
fp = (float *)pFirst + indx;
|
|
1175 |
RETURN ( _MKFLOAT((double)(*fp)) COMMA_CON );
|
|
1176 |
}
|
|
1177 |
break;
|
|
1178 |
|
|
1179 |
case DOUBLEARRAY:
|
|
1180 |
if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) {
|
|
1181 |
double *dp;
|
|
1182 |
|
|
1183 |
dp = (double *)pFirst + indx;
|
|
1184 |
RETURN ( _MKFLOAT(*dp) COMMA_CON );
|
|
1185 |
}
|
|
1186 |
break;
|
|
1187 |
|
|
1188 |
case WKPOINTERARRAY:
|
|
1189 |
case POINTERARRAY:
|
|
1190 |
if ((indx >= 0) && (indx < (nbytes / sizeof(OBJ)))) {
|
|
1191 |
op = (OBJ *)pFirst + indx;
|
|
1192 |
RETURN ( *op );
|
|
1193 |
}
|
|
1194 |
break;
|
|
1195 |
}
|
|
1196 |
}
|
|
1197 |
%}
|
|
1198 |
.
|
|
1199 |
(index isMemberOf:SmallInteger) ifTrue:[
|
2
|
1200 |
^ self subscriptBoundsError
|
1
|
1201 |
].
|
|
1202 |
^ self indexNotInteger
|
|
1203 |
!
|
|
1204 |
|
|
1205 |
at:index put:anObject
|
|
1206 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger.
|
|
1207 |
this method can be redefined in subclasses."
|
|
1208 |
|
|
1209 |
^ self basicAt:index put:anObject
|
|
1210 |
!
|
|
1211 |
|
|
1212 |
basicAt:index put:anObject
|
|
1213 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger.
|
|
1214 |
Trigger an error if the receiver has no indexed instance variables.
|
|
1215 |
This method should NOT be redefined in any subclass"
|
|
1216 |
|
|
1217 |
%{ /* NOCONTEXT */
|
|
1218 |
|
|
1219 |
register int nbytes, indx;
|
|
1220 |
OBJ myClass;
|
|
1221 |
register char *pFirst;
|
|
1222 |
char *cp;
|
|
1223 |
short *sp;
|
|
1224 |
long *lp;
|
|
1225 |
OBJ *op;
|
|
1226 |
int nInstBytes, ninstvars;
|
|
1227 |
int val;
|
|
1228 |
|
|
1229 |
/* notice the missing test for self beeing a nonNilObject -
|
|
1230 |
this an be done since basicAt: is defined both in UndefinedObject
|
|
1231 |
and SmallInteger */
|
|
1232 |
|
|
1233 |
if (_isSmallInteger(index)) {
|
|
1234 |
indx = _intVal(index) - 1;
|
|
1235 |
myClass = _qClass(self);
|
|
1236 |
ninstvars = _intVal(_ClassInstPtr(myClass)->c_ninstvars);
|
|
1237 |
nInstBytes = OHDR_SIZE + ninstvars * sizeof(OBJ);
|
|
1238 |
nbytes = _qSize(self) - nInstBytes;
|
|
1239 |
pFirst = (char *)(_InstPtr(self)) + nInstBytes;
|
|
1240 |
|
|
1241 |
switch (_intVal(_ClassInstPtr(myClass)->c_flags) & ARRAYMASK) {
|
|
1242 |
case BYTEARRAY:
|
|
1243 |
if (_isSmallInteger(anObject)) {
|
|
1244 |
val = _intVal(anObject);
|
|
1245 |
if ((val >= 0) && (val <= 255)) {
|
|
1246 |
if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) {
|
|
1247 |
cp = pFirst + indx;
|
|
1248 |
*cp = val;
|
|
1249 |
RETURN ( anObject );
|
|
1250 |
}
|
|
1251 |
}
|
|
1252 |
}
|
|
1253 |
break;
|
|
1254 |
|
|
1255 |
case WORDARRAY:
|
|
1256 |
if (_isSmallInteger(anObject)) {
|
|
1257 |
val = _intVal(anObject);
|
|
1258 |
if ((val >= 0) && (val <= 0xFFFF)) {
|
|
1259 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) {
|
|
1260 |
sp = (short *)pFirst + indx;
|
|
1261 |
*sp = val;
|
|
1262 |
RETURN ( anObject );
|
|
1263 |
}
|
|
1264 |
}
|
|
1265 |
}
|
|
1266 |
break;
|
|
1267 |
|
|
1268 |
case LONGARRAY:
|
|
1269 |
if (_isSmallInteger(anObject)) {
|
|
1270 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) {
|
|
1271 |
lp = (long *)pFirst + indx;
|
|
1272 |
*lp = _intVal(anObject);
|
|
1273 |
RETURN ( anObject );
|
|
1274 |
}
|
|
1275 |
}
|
|
1276 |
/* XXX
|
|
1277 |
* XXX must add possibility to put in a large number here
|
|
1278 |
* XXX
|
|
1279 |
*/
|
|
1280 |
break;
|
|
1281 |
|
|
1282 |
case FLOATARRAY:
|
|
1283 |
if (_isFloat(anObject)) {
|
|
1284 |
if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) {
|
|
1285 |
float *fp;
|
|
1286 |
|
|
1287 |
fp = (float *)pFirst + indx;
|
|
1288 |
*fp = _floatVal(anObject);
|
|
1289 |
RETURN ( anObject );
|
|
1290 |
}
|
|
1291 |
}
|
|
1292 |
break;
|
|
1293 |
|
|
1294 |
case DOUBLEARRAY:
|
|
1295 |
if (_isFloat(anObject)) {
|
|
1296 |
if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) {
|
|
1297 |
double *dp;
|
|
1298 |
|
|
1299 |
dp = (double *)pFirst + indx;
|
|
1300 |
*dp = _floatVal(anObject);
|
|
1301 |
RETURN ( anObject );
|
|
1302 |
}
|
|
1303 |
}
|
|
1304 |
break;
|
|
1305 |
|
|
1306 |
case WKPOINTERARRAY:
|
|
1307 |
case POINTERARRAY:
|
|
1308 |
if ((indx >= 0) && (indx < (nbytes / sizeof(OBJ)))) {
|
|
1309 |
op = (OBJ *)pFirst + indx;
|
|
1310 |
*op = anObject;
|
|
1311 |
__STORE(self, anObject);
|
|
1312 |
RETURN ( anObject );
|
|
1313 |
}
|
|
1314 |
break;
|
|
1315 |
|
|
1316 |
default:
|
|
1317 |
break;
|
|
1318 |
}
|
|
1319 |
}
|
|
1320 |
%}
|
|
1321 |
.
|
|
1322 |
(index isMemberOf:SmallInteger) ifFalse:[
|
|
1323 |
^ self indexNotInteger
|
|
1324 |
].
|
|
1325 |
(index between:1 and:self size) ifFalse:[
|
2
|
1326 |
^ self subscriptBoundsError
|
1
|
1327 |
].
|
2
|
1328 |
(anObject isKindOf:SmallInteger) ifFalse:[
|
|
1329 |
^ self elementNotInteger
|
|
1330 |
].
|
|
1331 |
^ self elementBoundsError
|
1
|
1332 |
!
|
|
1333 |
|
|
1334 |
instVarAt:index
|
|
1335 |
"return a non-indexed instance variable;
|
|
1336 |
this is not very object oriented - use with care (needed for inspector)"
|
|
1337 |
|
|
1338 |
%{ /* NOCONTEXT */
|
|
1339 |
|
|
1340 |
OBJ myClass;
|
|
1341 |
int idx, ninstvars;
|
|
1342 |
|
|
1343 |
if (_isSmallInteger(index)) {
|
|
1344 |
myClass = _Class(self);
|
|
1345 |
ninstvars = _intVal(_ClassInstPtr(myClass)->c_ninstvars);
|
|
1346 |
idx = _intVal(index) - 1;
|
|
1347 |
if ((idx >= 0) && (idx < ninstvars)) {
|
|
1348 |
RETURN ( _InstPtr(self)->i_instvars[idx] );
|
|
1349 |
}
|
|
1350 |
}
|
|
1351 |
%}
|
|
1352 |
.
|
|
1353 |
index isInteger ifFalse:[
|
|
1354 |
^ self indexNotInteger
|
|
1355 |
].
|
2
|
1356 |
^ self subscriptBoundsError
|
1
|
1357 |
!
|
|
1358 |
|
|
1359 |
instVarAt:index put:value
|
|
1360 |
"change a non-indexed instance variable;
|
|
1361 |
this is not very object oriented - use with care (needed for inspector)"
|
|
1362 |
|
|
1363 |
%{ /* NOCONTEXT */
|
|
1364 |
|
|
1365 |
OBJ myClass;
|
|
1366 |
int idx, ninstvars;
|
|
1367 |
|
|
1368 |
if (_isSmallInteger(index)) {
|
|
1369 |
myClass = _Class(self);
|
|
1370 |
ninstvars = _intVal(_ClassInstPtr(myClass)->c_ninstvars);
|
|
1371 |
idx = _intVal(index) - 1;
|
|
1372 |
if ((idx >= 0) && (idx < ninstvars)) {
|
|
1373 |
_InstPtr(self)->i_instvars[idx] = value;
|
|
1374 |
__STORE(self, value);
|
|
1375 |
RETURN ( value );
|
|
1376 |
}
|
|
1377 |
}
|
|
1378 |
%}
|
|
1379 |
.
|
|
1380 |
index isInteger ifFalse:[
|
|
1381 |
^ self indexNotInteger
|
|
1382 |
].
|
2
|
1383 |
^ self subscriptBoundsError
|
1
|
1384 |
! !
|
|
1385 |
|
|
1386 |
!Object methodsFor:'dependents access'!
|
|
1387 |
|
|
1388 |
dependents
|
|
1389 |
"return a Collection of dependents - nil if there is none.
|
|
1390 |
The default implementation here uses a global Dictionary to store
|
|
1391 |
dependents - some classes (Model) redefine this for better performance."
|
|
1392 |
|
|
1393 |
^ Dependencies at:self ifAbsent:[]
|
|
1394 |
!
|
|
1395 |
|
|
1396 |
dependents:aCollection
|
|
1397 |
"set the collection of dependents.
|
|
1398 |
The default implementation here uses a global Dictionary to store
|
|
1399 |
dependents - some classes (Model) redefine this for better performance."
|
|
1400 |
|
|
1401 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[
|
|
1402 |
Dependencies removeKey:self ifAbsent:[]
|
|
1403 |
] ifFalse:[
|
|
1404 |
Dependencies at:self put:aCollection
|
|
1405 |
]
|
|
1406 |
!
|
|
1407 |
|
|
1408 |
addDependent:anObject
|
|
1409 |
"make the argument, anObject be a dependent of the receiver"
|
|
1410 |
|
|
1411 |
|deps|
|
|
1412 |
|
|
1413 |
deps := self dependents.
|
|
1414 |
deps isNil ifTrue:[
|
|
1415 |
deps := IdentitySet with:anObject.
|
|
1416 |
self dependents:deps
|
|
1417 |
] ifFalse:[
|
|
1418 |
deps add:anObject
|
|
1419 |
]
|
|
1420 |
!
|
|
1421 |
|
|
1422 |
removeDependent:anObject
|
|
1423 |
"make the argument, anObject be independent of the receiver"
|
|
1424 |
|
|
1425 |
|deps|
|
|
1426 |
|
|
1427 |
deps := self dependents.
|
|
1428 |
deps notNil ifTrue:[
|
|
1429 |
deps remove:anObject ifAbsent:[].
|
|
1430 |
deps isEmpty ifTrue:[
|
|
1431 |
self dependents:nil
|
|
1432 |
]
|
|
1433 |
]
|
|
1434 |
!
|
|
1435 |
|
|
1436 |
release
|
|
1437 |
"remove all dependencies from the receiver"
|
|
1438 |
|
|
1439 |
self dependents:nil
|
|
1440 |
! !
|
|
1441 |
|
|
1442 |
!Object methodsFor:'change and update'!
|
|
1443 |
|
|
1444 |
changed
|
|
1445 |
"notify all dependents that the receiver has changed.
|
|
1446 |
Each dependent gets a '#update' message."
|
|
1447 |
|
|
1448 |
|deps|
|
|
1449 |
|
|
1450 |
deps := self dependents.
|
|
1451 |
deps notNil ifTrue:[
|
|
1452 |
deps do:[:dependent |
|
|
1453 |
dependent update:self
|
|
1454 |
]
|
|
1455 |
]
|
|
1456 |
!
|
|
1457 |
|
|
1458 |
changed:aParameter
|
|
1459 |
"notify all dependents that the receiver has changed somehow.
|
|
1460 |
Each dependent gets a '#update:aParameter' message."
|
|
1461 |
|
|
1462 |
|deps|
|
|
1463 |
|
|
1464 |
deps := self dependents.
|
|
1465 |
deps notNil ifTrue:[
|
|
1466 |
deps do:[:dependent |
|
|
1467 |
dependent update:aParameter
|
|
1468 |
]
|
|
1469 |
]
|
|
1470 |
!
|
|
1471 |
|
|
1472 |
changed:aParameter with:arguments
|
|
1473 |
"notify all dependents that the receiver has changed somehow.
|
|
1474 |
sending update:with: to each dependent with an additional arguments"
|
|
1475 |
|
|
1476 |
|deps|
|
|
1477 |
|
|
1478 |
deps := self dependents.
|
|
1479 |
deps notNil ifTrue:[
|
|
1480 |
deps do:[:dependent |
|
|
1481 |
dependent update:aParameter with:arguments
|
|
1482 |
]
|
|
1483 |
]
|
|
1484 |
!
|
|
1485 |
|
|
1486 |
broadcast:aSymbol
|
|
1487 |
"send the argument, aSelectorSymbol to all my dependents"
|
|
1488 |
|
|
1489 |
|deps|
|
|
1490 |
|
|
1491 |
deps := self dependents.
|
|
1492 |
deps notNil ifTrue:[
|
|
1493 |
deps do:[:dependent |
|
|
1494 |
dependent perform:aSymbol
|
|
1495 |
]
|
|
1496 |
]
|
|
1497 |
!
|
|
1498 |
|
|
1499 |
broadcast:aSymbol with:anObject
|
|
1500 |
"send the argument, aSelectorSymbol of a 1 argument message
|
|
1501 |
to all my dependents with the second argument, anObject as argument"
|
|
1502 |
|
|
1503 |
|deps|
|
|
1504 |
|
|
1505 |
deps := self dependents.
|
|
1506 |
deps notNil ifTrue:[
|
|
1507 |
deps do:[:dependent |
|
|
1508 |
dependent perform:aSymbol with:anObject
|
|
1509 |
]
|
|
1510 |
]
|
|
1511 |
!
|
|
1512 |
|
|
1513 |
update:aParameter
|
|
1514 |
"dependent is notified of some change -
|
|
1515 |
Default behavior is to do nothing"
|
|
1516 |
|
|
1517 |
^ self
|
|
1518 |
!
|
|
1519 |
|
|
1520 |
update:aParameter with:anArgument
|
|
1521 |
"dependent is notified of some change -
|
|
1522 |
Default is to try simple update"
|
|
1523 |
|
|
1524 |
^ self update:aParameter
|
|
1525 |
!
|
|
1526 |
|
|
1527 |
update:aParameter with:anArgument from:sender
|
|
1528 |
"dependent is notified of some change -
|
|
1529 |
Default is to try simple update"
|
|
1530 |
|
|
1531 |
^ self update:aParameter with:anArgument
|
|
1532 |
! !
|
|
1533 |
|
|
1534 |
!Object methodsFor:'message sending'!
|
|
1535 |
|
|
1536 |
perform:aSelector
|
|
1537 |
"send the message aSelector to the receiver"
|
|
1538 |
|
|
1539 |
%{ /* NOCONTEXT */
|
|
1540 |
|
|
1541 |
static struct inlineCache ilc = _ILC0;
|
|
1542 |
static OBJ lastSelector = nil;
|
|
1543 |
|
|
1544 |
#ifdef XXXTHIS_CONTEXT
|
|
1545 |
/*
|
|
1546 |
* must set lineno by hand here ...
|
|
1547 |
*/
|
|
1548 |
if (_intVal(__pilc->ilc_lineNo) > 0)
|
|
1549 |
_ContextInstPtr(__thisContext)->c_lineno = __pilc->ilc_lineNo;
|
|
1550 |
#endif
|
|
1551 |
|
|
1552 |
if (aSelector != lastSelector) {
|
|
1553 |
ilc.ilc_func = _SEND0;
|
|
1554 |
lastSelector = aSelector;
|
|
1555 |
}
|
|
1556 |
#ifdef THIS_CONTEXT
|
|
1557 |
ilc.ilc_lineNo = __pilc->ilc_lineNo;
|
|
1558 |
#endif
|
|
1559 |
|
|
1560 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc) );
|
|
1561 |
%}
|
|
1562 |
!
|
|
1563 |
|
|
1564 |
perform:aSelector with:anObject
|
|
1565 |
"send the one-arg-message aSelector to the receiver"
|
|
1566 |
|
|
1567 |
%{ /* NOCONTEXT */
|
|
1568 |
|
|
1569 |
static struct inlineCache ilc = _ILC1;
|
|
1570 |
static OBJ lastSelector = nil;
|
|
1571 |
|
|
1572 |
#ifdef XXXTHIS_CONTEXT
|
|
1573 |
/*
|
|
1574 |
* must set lineno by hand here ...
|
|
1575 |
*/
|
|
1576 |
if (_intVal(__pilc->ilc_lineNo) > 0)
|
|
1577 |
_ContextInstPtr(__thisContext)->c_lineno = __pilc->ilc_lineNo;
|
|
1578 |
#endif
|
|
1579 |
if (aSelector != lastSelector) {
|
|
1580 |
ilc.ilc_func = _SEND1;
|
|
1581 |
lastSelector = aSelector;
|
|
1582 |
}
|
|
1583 |
#ifdef THIS_CONTEXT
|
|
1584 |
ilc.ilc_lineNo = __pilc->ilc_lineNo;
|
|
1585 |
#endif
|
|
1586 |
|
|
1587 |
#ifdef PASS_ARG_REF
|
|
1588 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, &anObject) );
|
|
1589 |
#else
|
|
1590 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, anObject) );
|
|
1591 |
#endif
|
|
1592 |
%}
|
|
1593 |
!
|
|
1594 |
|
|
1595 |
perform:aSelector with:firstObject with:secondObject
|
|
1596 |
"send the two-arg-message aSelector to the receiver"
|
|
1597 |
|
|
1598 |
%{ /* NOCONTEXT */
|
|
1599 |
|
|
1600 |
static struct inlineCache ilc = _ILC2;
|
|
1601 |
static OBJ lastSelector = nil;
|
|
1602 |
|
|
1603 |
#ifdef XXXTHIS_CONTEXT
|
|
1604 |
/*
|
|
1605 |
* must set lineno by hand here ...
|
|
1606 |
*/
|
|
1607 |
if (_intVal(__pilc->ilc_lineNo) > 0)
|
|
1608 |
_ContextInstPtr(__thisContext)->c_lineno = __pilc->ilc_lineNo;
|
|
1609 |
#endif
|
|
1610 |
if (aSelector != lastSelector) {
|
|
1611 |
ilc.ilc_func = _SEND2;
|
|
1612 |
lastSelector = aSelector;
|
|
1613 |
}
|
|
1614 |
#ifdef THIS_CONTEXT
|
|
1615 |
ilc.ilc_lineNo = __pilc->ilc_lineNo;
|
|
1616 |
#endif
|
|
1617 |
|
|
1618 |
#ifdef PASS_ARG_REF
|
|
1619 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, &firstObject) );
|
|
1620 |
#else
|
|
1621 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, firstObject, secondObject) );
|
|
1622 |
#endif
|
|
1623 |
%}
|
|
1624 |
!
|
|
1625 |
|
|
1626 |
perform:aSelector with:firstObject with:secondObject with:thirdObject
|
|
1627 |
"send the three-arg-message aSelector to the receiver"
|
|
1628 |
|
|
1629 |
%{ /* NOCONTEXT */
|
|
1630 |
|
|
1631 |
static struct inlineCache ilc = _ILC3;
|
|
1632 |
static OBJ lastSelector = nil;
|
|
1633 |
|
|
1634 |
#ifdef XXXTHIS_CONTEXT
|
|
1635 |
/*
|
|
1636 |
* must set lineno by hand here ...
|
|
1637 |
*/
|
|
1638 |
if (_intVal(__pilc->ilc_lineNo) > 0)
|
|
1639 |
_ContextInstPtr(__thisContext)->c_lineno = __pilc->ilc_lineNo;
|
|
1640 |
#endif
|
|
1641 |
if (aSelector != lastSelector) {
|
|
1642 |
ilc.ilc_func = _SEND3;
|
|
1643 |
lastSelector = aSelector;
|
|
1644 |
}
|
|
1645 |
#ifdef THIS_CONTEXT
|
|
1646 |
ilc.ilc_lineNo = __pilc->ilc_lineNo;
|
|
1647 |
#endif
|
|
1648 |
|
|
1649 |
#ifdef PASS_ARG_REF
|
|
1650 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, &firstObject) );
|
|
1651 |
#else
|
|
1652 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, firstObject, secondObject, thirdObject) );
|
|
1653 |
#endif
|
|
1654 |
%}
|
|
1655 |
!
|
|
1656 |
|
|
1657 |
perform:aSelector withArguments:argArray
|
|
1658 |
"send the message aSelector with all args taken from argArray
|
|
1659 |
to the receiver"
|
|
1660 |
|
|
1661 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12|
|
|
1662 |
|
|
1663 |
numberOfArgs := argArray size.
|
|
1664 |
%{
|
|
1665 |
extern OBJ Array;
|
|
1666 |
REGISTER OBJ *argP;
|
|
1667 |
OBJ T;
|
|
1668 |
int nargs, i;
|
|
1669 |
static OBJ last0 = nil; static struct inlineCache ilc0 = _ILC0;
|
|
1670 |
static OBJ last1 = nil; static struct inlineCache ilc1 = _ILC1;
|
|
1671 |
static OBJ last2 = nil; static struct inlineCache ilc2 = _ILC2;
|
|
1672 |
static OBJ last3 = nil; static struct inlineCache ilc3 = _ILC3;
|
|
1673 |
static OBJ last4 = nil; static struct inlineCache ilc4 = _ILC4;
|
|
1674 |
static OBJ last5 = nil; static struct inlineCache ilc5 = _ILC5;
|
|
1675 |
static OBJ last6 = nil; static struct inlineCache ilc6 = _ILC6;
|
|
1676 |
static OBJ last7 = nil; static struct inlineCache ilc7 = _ILC7;
|
|
1677 |
static OBJ last8 = nil; static struct inlineCache ilc8 = _ILC8;
|
|
1678 |
static OBJ last9 = nil; static struct inlineCache ilc9 = _ILC9;
|
|
1679 |
static OBJ last10 = nil; static struct inlineCache ilc10 = _ILC10;
|
|
1680 |
static OBJ last11 = nil; static struct inlineCache ilc11 = _ILC11;
|
|
1681 |
static OBJ last12 = nil; static struct inlineCache ilc12 = _ILC12;
|
|
1682 |
|
|
1683 |
if (_isSmallInteger(numberOfArgs)) {
|
|
1684 |
nargs = _intVal(numberOfArgs);
|
|
1685 |
if (nargs) {
|
|
1686 |
argP = (OBJ *)(&a1);
|
|
1687 |
if (_Class(argArray) == Array) {
|
|
1688 |
for (i=0; i < nargs; i++) {
|
|
1689 |
*argP++ = _ArrayInstPtr(argArray)->a_element[i];
|
|
1690 |
}
|
|
1691 |
} else {
|
|
1692 |
for (i=1; i <= nargs; i++) {
|
|
1693 |
#ifdef PASS_ARG_REF
|
|
1694 |
T = _MKSMALLINT(i);
|
|
1695 |
*argP++ = _AT_(argArray, CON_COMMA &T);
|
|
1696 |
#else
|
|
1697 |
*argP++ = _AT_(argArray, CON_COMMA _MKSMALLINT(i));
|
|
1698 |
#endif
|
|
1699 |
}
|
|
1700 |
}
|
|
1701 |
}
|
|
1702 |
#ifdef XXXTHIS_CONTEXT
|
|
1703 |
/*
|
|
1704 |
* must set lineno by hand here ...
|
|
1705 |
*/
|
|
1706 |
if (_intVal(__pilc->ilc_lineNo) > 0)
|
|
1707 |
_ContextInstPtr(__context->c_sender)->c_lineno = __pilc->ilc_lineNo;
|
|
1708 |
#endif
|
|
1709 |
switch (nargs) {
|
|
1710 |
case 0:
|
|
1711 |
if (aSelector != last0) {
|
|
1712 |
ilc0.ilc_func = _SEND0;
|
|
1713 |
last0 = aSelector;
|
|
1714 |
}
|
|
1715 |
#ifdef PASS_ARG_REF
|
|
1716 |
RETURN ( (*ilc0.ilc_func)(self, aSelector, CON_COMMA nil, &ilc0, &a1) );
|
|
1717 |
#else
|
|
1718 |
RETURN ( (*ilc0.ilc_func)(self, aSelector, CON_COMMA nil, &ilc0, a1, a2) );
|
|
1719 |
#endif
|
|
1720 |
|
|
1721 |
case 1:
|
|
1722 |
if (aSelector != last1) {
|
|
1723 |
ilc1.ilc_func = _SEND1;
|
|
1724 |
last1 = aSelector;
|
|
1725 |
}
|
|
1726 |
#ifdef PASS_ARG_REF
|
|
1727 |
RETURN ( (*ilc1.ilc_func)(self, aSelector, CON_COMMA nil, &ilc1, &a1));
|
|
1728 |
#else
|
|
1729 |
RETURN ( (*ilc1.ilc_func)(self, aSelector, CON_COMMA nil, &ilc1, a1, a2));
|
|
1730 |
#endif
|
|
1731 |
|
|
1732 |
case 2:
|
|
1733 |
if (aSelector != last2) {
|
|
1734 |
ilc2.ilc_func = _SEND2;
|
|
1735 |
last2 = aSelector;
|
|
1736 |
}
|
|
1737 |
#ifdef PASS_ARG_REF
|
|
1738 |
RETURN ( (*ilc2.ilc_func)(self, aSelector, CON_COMMA nil, &ilc2, &a1));
|
|
1739 |
#else
|
|
1740 |
RETURN ( (*ilc2.ilc_func)(self, aSelector, CON_COMMA nil, &ilc2, a1, a2));
|
|
1741 |
#endif
|
|
1742 |
|
|
1743 |
case 3:
|
|
1744 |
if (aSelector != last3) {
|
|
1745 |
ilc3.ilc_func = _SEND3;
|
|
1746 |
last3 = aSelector;
|
|
1747 |
}
|
|
1748 |
#ifdef PASS_ARG_REF
|
|
1749 |
RETURN ( (*ilc3.ilc_func)(self, aSelector, CON_COMMA nil, &ilc3, &a1));
|
|
1750 |
#else
|
|
1751 |
RETURN ( (*ilc3.ilc_func)(self, aSelector, CON_COMMA nil, &ilc3, a1, a2, a3));
|
|
1752 |
#endif
|
|
1753 |
|
|
1754 |
case 4:
|
|
1755 |
if (aSelector != last4) {
|
|
1756 |
ilc4.ilc_func = _SEND4;
|
|
1757 |
last4 = aSelector;
|
|
1758 |
}
|
|
1759 |
#ifdef PASS_ARG_REF
|
|
1760 |
RETURN ( (*ilc4.ilc_func)(self, aSelector, CON_COMMA nil, &ilc4, &a1));
|
|
1761 |
#else
|
|
1762 |
RETURN ( (*ilc4.ilc_func)(self, aSelector, CON_COMMA nil, &ilc4, a1, a2, a3, a4));
|
|
1763 |
#endif
|
|
1764 |
|
|
1765 |
case 5:
|
|
1766 |
if (aSelector != last5) {
|
|
1767 |
ilc5.ilc_func = _SEND5;
|
|
1768 |
last5 = aSelector;
|
|
1769 |
}
|
|
1770 |
#ifdef PASS_ARG_REF
|
|
1771 |
RETURN ( (*ilc5.ilc_func)(self, aSelector, CON_COMMA nil, &ilc5, &a1));
|
|
1772 |
#else
|
|
1773 |
RETURN ( (*ilc5.ilc_func)(self, aSelector, CON_COMMA nil, &ilc5, a1, a2, a3, a4, a5));
|
|
1774 |
#endif
|
|
1775 |
|
|
1776 |
case 6:
|
|
1777 |
if (aSelector != last6) {
|
|
1778 |
ilc6.ilc_func = _SEND6;
|
|
1779 |
last6 = aSelector;
|
|
1780 |
}
|
|
1781 |
#ifdef PASS_ARG_REF
|
|
1782 |
RETURN ( (*ilc6.ilc_func)(self, aSelector, CON_COMMA nil, &ilc6, &a1));
|
|
1783 |
#else
|
|
1784 |
RETURN ( (*ilc6.ilc_func)(self, aSelector, CON_COMMA nil, &ilc6, a1, a2, a3, a4, a5, a6));
|
|
1785 |
#endif
|
|
1786 |
|
|
1787 |
case 7:
|
|
1788 |
if (aSelector != last7) {
|
|
1789 |
ilc7.ilc_func = _SEND7;
|
|
1790 |
last7 = aSelector;
|
|
1791 |
}
|
|
1792 |
#ifdef PASS_ARG_REF
|
|
1793 |
RETURN ( (*ilc7.ilc_func)(self, aSelector, CON_COMMA nil, &ilc7, &a1));
|
|
1794 |
#else
|
|
1795 |
RETURN ( (*ilc7.ilc_func)(self, aSelector, CON_COMMA nil, &ilc7, a1, a2, a3, a4, a5, a6, a7));
|
|
1796 |
#endif
|
|
1797 |
|
|
1798 |
case 8:
|
|
1799 |
if (aSelector != last8) {
|
|
1800 |
ilc8.ilc_func = _SEND8;
|
|
1801 |
last8 = aSelector;
|
|
1802 |
}
|
|
1803 |
#ifdef PASS_ARG_REF
|
|
1804 |
RETURN ( (*ilc8.ilc_func)(self, aSelector, CON_COMMA nil, &ilc8, &a1));
|
|
1805 |
#else
|
|
1806 |
RETURN ( (*ilc8.ilc_func)(self, aSelector, CON_COMMA nil, &ilc8, a1, a2, a3, a4, a5, a6, a7, a8));
|
|
1807 |
#endif
|
|
1808 |
|
|
1809 |
case 9:
|
|
1810 |
if (aSelector != last9) {
|
|
1811 |
ilc9.ilc_func = _SEND9;
|
|
1812 |
last9 = aSelector;
|
|
1813 |
}
|
|
1814 |
#ifdef PASS_ARG_REF
|
|
1815 |
RETURN ( (*ilc9.ilc_func)(self, aSelector, CON_COMMA nil, &ilc9, &a1));
|
|
1816 |
#else
|
|
1817 |
RETURN ( (*ilc9.ilc_func)(self, aSelector, CON_COMMA nil, &ilc9, a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
|
1818 |
#endif
|
|
1819 |
|
|
1820 |
case 10:
|
|
1821 |
if (aSelector != last10) {
|
|
1822 |
ilc10.ilc_func = _SEND10;
|
|
1823 |
last10 = aSelector;
|
|
1824 |
}
|
|
1825 |
#ifdef PASS_ARG_REF
|
|
1826 |
RETURN ( (*ilc10.ilc_func)(self, aSelector, CON_COMMA nil, &ilc10, &a1));
|
|
1827 |
#else
|
|
1828 |
RETURN ( (*ilc10.ilc_func)(self, aSelector, CON_COMMA nil, &ilc10, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
|
1829 |
#endif
|
|
1830 |
|
|
1831 |
case 11:
|
|
1832 |
if (aSelector != last11) {
|
|
1833 |
ilc11.ilc_func = _SEND11;
|
|
1834 |
last11 = aSelector;
|
|
1835 |
}
|
|
1836 |
#ifdef PASS_ARG_REF
|
|
1837 |
RETURN ( (*ilc11.ilc_func)(self, aSelector, CON_COMMA nil, &ilc11, &a1));
|
|
1838 |
#else
|
|
1839 |
RETURN ( (*ilc11.ilc_func)(self, aSelector, CON_COMMA nil, &ilc11, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
|
|
1840 |
#endif
|
|
1841 |
|
|
1842 |
case 12:
|
|
1843 |
if (aSelector != last12) {
|
|
1844 |
ilc12.ilc_func = _SEND12;
|
|
1845 |
last12 = aSelector;
|
|
1846 |
}
|
|
1847 |
#ifdef PASS_ARG_REF
|
|
1848 |
RETURN ( (*ilc12.ilc_func)(self, aSelector, CON_COMMA nil, &ilc12, &a1));
|
|
1849 |
#else
|
|
1850 |
RETURN ( (*ilc12.ilc_func)(self, aSelector, CON_COMMA nil, &ilc12, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
|
|
1851 |
#endif
|
|
1852 |
}
|
|
1853 |
}
|
|
1854 |
%}
|
|
1855 |
.
|
|
1856 |
^ self primitiveFailed
|
|
1857 |
! !
|
|
1858 |
|
2
|
1859 |
!Object methodsFor:'binary storage'!
|
|
1860 |
|
|
1861 |
storeBinaryOn: aStream
|
|
1862 |
"Writes a description of the receiver onto aStream, in a way that allows
|
|
1863 |
the object's structure to be reconstructed from the stream's contents"
|
|
1864 |
|
|
1865 |
BinaryOutputManager store: self on: aStream
|
|
1866 |
!
|
|
1867 |
|
|
1868 |
hasSpecialBinaryRepresentation
|
|
1869 |
^ false
|
|
1870 |
!
|
|
1871 |
|
|
1872 |
readBinaryContentsFrom: stream manager: manager
|
|
1873 |
| size i |
|
|
1874 |
size _ self class instSize.
|
|
1875 |
i _ 0.
|
|
1876 |
[(i _ i + 1) <= size] whileTrue: [
|
|
1877 |
self instVarAt: i put: manager nextObject].
|
|
1878 |
size _ self basicSize.
|
|
1879 |
i _ 0.
|
|
1880 |
[(i _ i + 1) <= size] whileTrue: [
|
|
1881 |
self basicAt: i put: manager nextObject]
|
|
1882 |
!
|
|
1883 |
|
|
1884 |
storeBinaryDefinitionOn: stream manager: manager
|
|
1885 |
|
|
1886 |
| i basicSize instSize |
|
|
1887 |
manager putIdOf: self class on: stream.
|
|
1888 |
i _ 0.
|
|
1889 |
self class isPointers ifTrue: [
|
|
1890 |
stream nextPut: (instSize _ self class instSize).
|
|
1891 |
self class isVariable ifTrue: [
|
|
1892 |
stream nextNumber: 3 put: (basicSize _ self basicSize)
|
|
1893 |
] ifFalse: [
|
|
1894 |
basicSize _ 0
|
|
1895 |
].
|
|
1896 |
|
|
1897 |
[(i _ i + 1) <= instSize] whileTrue: [
|
|
1898 |
manager putIdOf: (self instVarAt: i) on: stream
|
|
1899 |
].
|
|
1900 |
|
|
1901 |
i _ 0.
|
|
1902 |
[(i _ i + 1) <= basicSize] whileTrue: [
|
|
1903 |
manager putIdOf: (self basicAt: i) on: stream]
|
|
1904 |
] ifFalse: [
|
|
1905 |
stream nextNumber: 4 put: (basicSize _ self basicSize).
|
|
1906 |
self class isBytes
|
|
1907 |
ifTrue: [
|
|
1908 |
[(i _ i + 1) <= basicSize] whileTrue: [
|
|
1909 |
stream nextPut: (self basicAt: i)]]
|
|
1910 |
ifFalse: [
|
|
1911 |
[(i _ i + 1) <= basicSize] whileTrue: [
|
|
1912 |
stream "nextWordPut:" nextNumber:2 put: (self basicAt: i)]]
|
|
1913 |
]
|
|
1914 |
!
|
|
1915 |
|
|
1916 |
XXreadBinaryContentsFrom: stream manager: manager
|
|
1917 |
| size "{ Class: SmallInteger }" |
|
|
1918 |
|
|
1919 |
size := self class instSize.
|
|
1920 |
1 to:size do:[:i |
|
|
1921 |
self instVarAt: i put: manager nextObject
|
|
1922 |
].
|
|
1923 |
size := self basicSize.
|
|
1924 |
1 to:size do:[:i |
|
|
1925 |
self basicAt: i put: manager nextObject
|
|
1926 |
]
|
|
1927 |
!
|
|
1928 |
|
|
1929 |
XXstoreBinaryDefinitionOn: stream manager: manager
|
|
1930 |
| basicSize "{ Class: SmallInteger }"
|
|
1931 |
instSize "{ Class: SmallInteger }"|
|
|
1932 |
|
|
1933 |
manager putIdOf: self class on: stream.
|
|
1934 |
self class isPointers ifTrue: [
|
|
1935 |
instSize := self class instSize.
|
|
1936 |
stream nextPut: instSize.
|
|
1937 |
self class isVariable ifTrue: [
|
|
1938 |
basicSize := self basicSize.
|
|
1939 |
stream nextNumber: 3 put: basicSize
|
|
1940 |
] ifFalse: [
|
|
1941 |
basicSize := 0
|
|
1942 |
].
|
|
1943 |
|
|
1944 |
1 to:instSize do:[:i |
|
|
1945 |
manager putIdOf: (self instVarAt: i) on: stream
|
|
1946 |
].
|
|
1947 |
|
|
1948 |
1 to:basicSize do:[:i |
|
|
1949 |
manager putIdOf: (self basicAt: i) on: stream
|
|
1950 |
]
|
|
1951 |
] ifFalse: [
|
|
1952 |
basicSize := self basicSize.
|
|
1953 |
stream nextNumber: 4 put: basicSize.
|
|
1954 |
self class isBytes ifTrue: [
|
|
1955 |
1 to:basicSize do:[:i |
|
|
1956 |
stream nextPut: (self basicAt: i)
|
|
1957 |
]
|
|
1958 |
] ifFalse: [
|
|
1959 |
self class isWords ifTrue:[
|
|
1960 |
1 to:basicSize do:[:i |
|
|
1961 |
stream nextNumber:2 put: (self basicAt: i)
|
|
1962 |
]
|
|
1963 |
] ifFalse:[
|
|
1964 |
self class isLongs ifTrue:[
|
|
1965 |
1 to:basicSize do:[:i |
|
|
1966 |
stream nextNumber:4 put: (self basicAt: i)
|
|
1967 |
]
|
|
1968 |
] ifFalse:[
|
|
1969 |
self class isFloats ifTrue:[
|
|
1970 |
1 to:basicSize do:[:i |
|
|
1971 |
stream nextPutAll:(self basicAt: i) asByteArray
|
|
1972 |
]
|
|
1973 |
] ifFalse:[
|
|
1974 |
1 to:basicSize do:[:i |
|
|
1975 |
stream nextPutAll: (self basicAt: i) asByteArray
|
|
1976 |
]
|
|
1977 |
]
|
|
1978 |
]
|
|
1979 |
]
|
|
1980 |
]
|
|
1981 |
]
|
|
1982 |
!
|
|
1983 |
|
|
1984 |
storeBinaryOn: stream manager: manager
|
|
1985 |
manager putIdOf: self on: stream
|
|
1986 |
! !
|
|
1987 |
|
1
|
1988 |
!Object methodsFor:'printing & storing'!
|
|
1989 |
|
|
1990 |
className
|
|
1991 |
"return the classname of the receivers class"
|
|
1992 |
|
|
1993 |
^ self class name
|
|
1994 |
!
|
|
1995 |
|
|
1996 |
classNameWithArticle
|
|
1997 |
"return a string consisting of classname preceeded by an article"
|
|
1998 |
|
|
1999 |
|article classname firstChar|
|
|
2000 |
|
|
2001 |
classname := self className.
|
|
2002 |
firstChar := (classname at:1) asLowercase.
|
|
2003 |
(firstChar isVowel or:[firstChar == $x]) ifTrue:[
|
|
2004 |
article := 'an '
|
|
2005 |
] ifFalse:[
|
|
2006 |
article := 'a '
|
|
2007 |
].
|
|
2008 |
^ (article , classname)
|
|
2009 |
!
|
|
2010 |
|
|
2011 |
printString
|
|
2012 |
"return a string for printing the receiver.
|
|
2013 |
Default printString is the classname preceeded by an article -
|
|
2014 |
is redefined in many subclasses"
|
|
2015 |
|
|
2016 |
^ self classNameWithArticle
|
|
2017 |
!
|
|
2018 |
|
|
2019 |
printOn:aStream
|
|
2020 |
"print the receiver on the argument-stream"
|
|
2021 |
|
|
2022 |
aStream nextPutAll:(self printString)
|
|
2023 |
!
|
|
2024 |
|
2
|
2025 |
printStringPaddedTo:size with:padCharacter
|
|
2026 |
"return a printed representation of the receiver, padded with padCharacter up to size"
|
1
|
2027 |
|
2
|
2028 |
|thePrintString s len|
|
1
|
2029 |
|
|
2030 |
thePrintString := self printString.
|
|
2031 |
len := thePrintString size.
|
2
|
2032 |
len < size ifTrue:[
|
|
2033 |
s := String new:size withAll:padCharacter.
|
|
2034 |
s replaceFrom:1 to:len with:thePrintString.
|
|
2035 |
^ s
|
|
2036 |
].
|
|
2037 |
^ thePrintString
|
|
2038 |
|
|
2039 |
"123 printStringPaddedTo:10 with:$."
|
|
2040 |
!
|
|
2041 |
|
|
2042 |
printStringZeroPaddedTo:size
|
|
2043 |
"return a printed representation of the receiver, padded with zeros up to size.
|
|
2044 |
Ususally used with numbers."
|
|
2045 |
|
|
2046 |
^ self printStringPaddedTo:size with:$0
|
|
2047 |
!
|
|
2048 |
|
|
2049 |
printOn:aStream paddedTo:size with:padCharacter
|
|
2050 |
"print the receiver on aStream, padding with padCharacter up to size"
|
|
2051 |
|
|
2052 |
|s|
|
|
2053 |
|
|
2054 |
s := self printString.
|
|
2055 |
aStream nextPutAll:s.
|
|
2056 |
s size to:size do:[:i |
|
|
2057 |
aStream nextPut:padCharacter
|
|
2058 |
]
|
|
2059 |
|
|
2060 |
"123 printOn:Transcript paddedTo:10 with:$_"
|
|
2061 |
!
|
|
2062 |
|
|
2063 |
printOn:aStream zeroPaddedTo:size
|
|
2064 |
"print the receiver on aStream, padding with zeros up to size.
|
|
2065 |
Usually used with numbers."
|
|
2066 |
|
|
2067 |
^ self printOn:aStream paddedTo:size with:$0
|
|
2068 |
!
|
|
2069 |
|
|
2070 |
printStringLeftPaddedTo:size with:padCharacter
|
|
2071 |
"return my printString as a right-adjusted string of length size;
|
|
2072 |
characters on the left are filled with padCharacter."
|
|
2073 |
|
|
2074 |
|thePrintString len s|
|
|
2075 |
|
|
2076 |
thePrintString := self printString.
|
|
2077 |
len := thePrintString size.
|
|
2078 |
(len < size) ifTrue:[
|
|
2079 |
s := String new:size withAll:padCharacter.
|
|
2080 |
s replaceFrom:(size - len) with:thePrintString.
|
|
2081 |
^ s
|
1
|
2082 |
].
|
|
2083 |
^ thePrintString
|
|
2084 |
!
|
|
2085 |
|
2
|
2086 |
printStringLeftPaddedTo:size
|
|
2087 |
"return my printString as a right-adjusted string of length size;
|
|
2088 |
characters on the left are filled with spaces."
|
|
2089 |
|
|
2090 |
^ self printStringLeftPaddedTo:size with:(Character space)
|
|
2091 |
!
|
|
2092 |
|
|
2093 |
printOn:aStream leftPaddedTo:size with:padCharacter
|
|
2094 |
"print the receiver on aStream, padding with padCharacters up to size.
|
|
2095 |
padding is done on the left."
|
|
2096 |
|
|
2097 |
aStream nextPutAll:(self printStringLeftPaddedTo:size with:padCharacter)
|
|
2098 |
!
|
1
|
2099 |
|
2
|
2100 |
printOn:aStream leftPaddedTo:size
|
|
2101 |
"print the receiver on aStream, padding with spaces up to size.
|
|
2102 |
padding is done on the left."
|
|
2103 |
|
|
2104 |
aStream nextPutAll:(self printStringLeftPaddedTo:size with:(Character space))
|
|
2105 |
!
|
|
2106 |
|
|
2107 |
printStringRightAdjustLen:size
|
|
2108 |
"obsolete"
|
|
2109 |
|
|
2110 |
^ self printStringLeftPaddedTo:size
|
|
2111 |
!
|
|
2112 |
|
|
2113 |
print
|
|
2114 |
"print the receiver on the standard output stream"
|
|
2115 |
|
|
2116 |
self printString print
|
1
|
2117 |
!
|
|
2118 |
|
|
2119 |
printNL
|
|
2120 |
"print the receiver followed by a cr
|
|
2121 |
- for GNU Smalltalk compatibility"
|
|
2122 |
|
|
2123 |
^ self printNewline
|
|
2124 |
!
|
|
2125 |
|
|
2126 |
printNewline
|
|
2127 |
"print the receiver followed by a cr"
|
|
2128 |
|
|
2129 |
self print.
|
|
2130 |
Character nl print
|
|
2131 |
!
|
|
2132 |
|
2
|
2133 |
printRightAdjustLen:size
|
|
2134 |
"obsolete"
|
|
2135 |
|
|
2136 |
(self printStringLeftPaddedTo:size) printOn:Stdout
|
|
2137 |
!
|
|
2138 |
|
1
|
2139 |
displayString
|
|
2140 |
"return a string used when displaying the receiver in a view,
|
|
2141 |
for example an Inspector. This is usually the same as printString"
|
|
2142 |
|
|
2143 |
^ self printString
|
|
2144 |
!
|
|
2145 |
|
|
2146 |
storeString
|
|
2147 |
"return a string representing an expression to reconstruct the receiver"
|
|
2148 |
|
|
2149 |
| stream myClass hasSemi
|
|
2150 |
sz "{ Class: SmallInteger }" |
|
|
2151 |
|
|
2152 |
myClass := self class.
|
|
2153 |
stream := WriteStream on:(String new).
|
|
2154 |
stream nextPut:$(.
|
|
2155 |
stream nextPutAll:self class name.
|
|
2156 |
hasSemi := false.
|
|
2157 |
myClass isVariable ifTrue:[
|
|
2158 |
stream nextPutAll:' basicNew:'.
|
|
2159 |
self basicSize printOn:stream
|
|
2160 |
] ifFalse:[
|
|
2161 |
stream nextPutAll:' basicNew'
|
|
2162 |
].
|
|
2163 |
sz := myClass instSize.
|
|
2164 |
1 to:sz do:[:i |
|
|
2165 |
stream nextPutAll:' instVarAt:'.
|
|
2166 |
i printOn:stream.
|
|
2167 |
stream nextPutAll:' put:'.
|
|
2168 |
(self instVarAt:i) storeOn:stream.
|
|
2169 |
stream nextPut:$;.
|
|
2170 |
hasSemi := true
|
|
2171 |
].
|
|
2172 |
myClass isVariable ifTrue:[
|
|
2173 |
sz := self basicSize.
|
|
2174 |
1 to:sz do:[:i |
|
|
2175 |
stream nextPutAll:' basicAt:'.
|
|
2176 |
i printOn:stream.
|
|
2177 |
stream nextPutAll:' put:'.
|
|
2178 |
(self basicAt:i) storeOn:stream.
|
|
2179 |
stream nextPut:$;.
|
|
2180 |
hasSemi := true
|
|
2181 |
]
|
|
2182 |
].
|
|
2183 |
hasSemi ifTrue:[
|
|
2184 |
stream nextPutAll:' yourself'
|
|
2185 |
].
|
|
2186 |
stream nextPut:$).
|
|
2187 |
^ stream contents
|
|
2188 |
!
|
|
2189 |
|
|
2190 |
storeOn:aStream
|
|
2191 |
"store the receiver on aStream; i.e. print an expression which will
|
|
2192 |
reconstruct the receiver"
|
|
2193 |
|
|
2194 |
aStream nextPutAll:(self storeString)
|
|
2195 |
!
|
|
2196 |
|
|
2197 |
store
|
|
2198 |
"store the receiver on standard output"
|
|
2199 |
|
|
2200 |
self storeOn:Stdout
|
|
2201 |
!
|
|
2202 |
|
|
2203 |
storeNl
|
|
2204 |
"store the receiver on standard output; append a newline"
|
|
2205 |
|
|
2206 |
self store.
|
|
2207 |
Character nl print
|
|
2208 |
! !
|