author | Claus Gittinger <cg@exept.de> |
Wed, 22 Jan 1997 21:11:17 +0100 | |
changeset 2228 | ddcc662bd9b1 |
parent 2226 | b59ec5725a9d |
child 2230 | b7a86880ab9c |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
154 | 3 |
All Rights Reserved |
1 | 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:#Behavior |
|
1634 | 14 |
instanceVariableNames:'superclass flags methodDictionary otherSuperclasses instSize' |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
15 |
classVariableNames:'SubclassInfo' |
1088 | 16 |
poolDictionaries:'' |
17 |
category:'Kernel-Classes' |
|
1 | 18 |
! |
19 |
||
1760 | 20 |
!Behavior class methodsFor:'documentation'! |
47 | 21 |
|
88 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
154 | 25 |
All Rights Reserved |
88 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
47 | 36 |
documentation |
37 |
" |
|
68 | 38 |
Every class in the system inherits from Behavior (via Class, ClassDescription); |
39 |
so here is where most of the class messages end up being implemented. |
|
40 |
(to answer a FAQ: 'Point basicNew' will be done here :-) |
|
41 |
||
356 | 42 |
Beginners should keep in mind, that all classes are instances (of subclasses) |
91 | 43 |
of Behavior, therefore you will find the above mentioned 'basicNew:' method |
44 |
under the 'instance'-methods of Behavior - NOT under the class methods |
|
154 | 45 |
('Behavior new' will create and return a new class, while sending 'new' to |
46 |
any instance of Behavior (i.e. any class) will return an instance of that class). |
|
68 | 47 |
|
2226 | 48 |
|
68 | 49 |
Behavior provides minimum support for all classes - additional stuff is |
77 | 50 |
found in ClassDescription and Class. Behaviors provides all mechanisms needed |
51 |
to create instances, and send messages to those. However, Behavior does not provide |
|
52 |
all the (symbolic) information needed to compile methods for a class or to get |
|
53 |
useful information in inspectors. |
|
47 | 54 |
|
2226 | 55 |
for experts: |
56 |
||
57 |
Since instances of Behavior provide all that is needed to interact with the VM's |
|
58 |
message dispatch mechanism, these can be used as 'light weight' classes. |
|
59 |
I.e. it is possible, to generate completely anonymous classes (and instances thereof) |
|
60 |
on the fly - 'Behavior new new' is such a thingy. |
|
61 |
||
62 |
The selectors and Methods are organized in a MethodDictionary (which is not a true |
|
63 |
dictionary, but an Array with alternating selector/method entries). |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
64 |
This avoids the need for knowledge about Dictionaries in the runtime library (VM) |
68 | 65 |
(lookup and search in these is seldom anyway, so the added benefit from using a |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
66 |
hashed dictionary is almost void). |
1 | 67 |
|
1285 | 68 |
[Instance variables:] |
69 |
||
2226 | 70 |
superclass <Class> the receivers superclass |
71 |
||
72 |
otherSuperclasses <Array of Class> experimental: other superclasses |
|
73 |
a hook for experimental multiple inheritance |
|
74 |
implementations |
|
75 |
||
76 |
methodDictionary <MethodDictionary> inst-selectors and methods |
|
77 |
||
78 |
instSize <SmallInteger> the number of instance variables |
|
79 |
||
80 |
flags <SmallInteger> special flag bits coded in a number |
|
81 |
not for application use |
|
1 | 82 |
|
81 | 83 |
flag bits (see stc.h): |
47 | 84 |
|
68 | 85 |
NOTICE: layout known by compiler and runtime system; be careful when changing |
1285 | 86 |
|
1292 | 87 |
[author:] |
2226 | 88 |
Claus Gittinger |
1292 | 89 |
|
1285 | 90 |
[see also:] |
2226 | 91 |
Class ClassDescription Metaclass |
92 |
Method MethodDictionary |
|
47 | 93 |
" |
356 | 94 |
! |
95 |
||
96 |
virtualMachineRelationship |
|
97 |
" |
|
357 | 98 |
NOTICE: |
2148 | 99 |
the stuff described below may not be available on other |
100 |
Smalltalk implementations; be aware that these error mechanisms |
|
101 |
are ST/X specials and applications using these (tricks) may |
|
102 |
not be portable to other systems. |
|
357 | 103 |
|
104 |
WARNING: |
|
2148 | 105 |
do not try the examples below on (some) other smalltalk systems; |
106 |
it has been reported, that some crash badly when doing this .... ;-) |
|
357 | 107 |
|
356 | 108 |
Instances of Behavior and subclasses (i.e. in sloppy words: classes) |
109 |
play a special role w.r.t. the VM. Only objects whose class-slot is marked |
|
110 |
as being behaviorLike (in the flag-instvar) are considered to be classLike |
|
111 |
and a message lookup will be done for it in the well known way. |
|
112 |
Thus, if an object has a class for which its class does NOT have |
|
362 | 113 |
this flag bit set, the VM will trigger an error on a message send. |
356 | 114 |
|
115 |
Why is this so: |
|
116 |
||
117 |
the above lets every object play the role of a class, |
|
118 |
which has been flagged as behaviorLike in its class's flag. |
|
119 |
Thus, you can create arbitrary new classLike objects and have the VM |
|
120 |
play with them. |
|
121 |
This may offer the flexibility to create a totally different object scheme |
|
362 | 122 |
on top of ST/X (for example: Self like objects) where any object can play |
123 |
a classRole for another object. |
|
356 | 124 |
|
2148 | 125 |
[A concrete application of this is found in the Structure class, |
126 |
which creates objects which are their own class !! |
|
127 |
This may look to be of theoretical value at first sight, |
|
128 |
however, such a construct saves memory, by not requiring an extra |
|
129 |
class object per Structure object.] |
|
130 |
||
131 |
Be aware, that the VM trusts the isBehaviorLike flag - IF it is set for some |
|
132 |
object, the VM EXPECTS the object selector and methodDictionaries to be found |
|
362 | 133 |
at the instance positions as defined here. |
134 |
(i.e. instanceVariables with contents and semantic corresponding to |
|
2148 | 135 |
superclass |
136 |
flags |
|
137 |
methodDictionary |
|
362 | 138 |
must be present and have the same instVar-index as here). |
139 |
||
356 | 140 |
The VM (and the system) may crash badly, if this is not the case. |
362 | 141 |
|
356 | 142 |
Since every class in the system derives from Behavior, the flag setting |
357 | 143 |
(and instance variable layout) is correct for all 'normal' classes. |
144 |
If you experiment by creating new behaviorLike objects, please take |
|
145 |
care of this flag. If you want to use the VM's lookup function, the |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
146 |
instVars 'superclass' and 'methodDictionary' are required |
357 | 147 |
and have to be at the same instVar index. |
362 | 148 |
(we suggest, you subclass Behavior, to make certain) |
357 | 149 |
|
150 |
You do not have to care about the above details if you are a 'normal' |
|
151 |
ST-programmer, though. |
|
152 |
||
356 | 153 |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
746
diff
changeset
|
154 |
Examples (only of theoretical interest): |
2148 | 155 |
take away the behaviorLike-flag from a class. |
156 |
-> The instances will not understand any messages, since the VM will |
|
157 |
not recognize its class as being a class ... |
|
158 |
||
159 |
|newMeta notRecognizedAsClass someInstance| |
|
160 |
||
161 |
newMeta := Metaclass new. |
|
162 |
newMeta flags:0. |
|
163 |
||
164 |
notRecognizedAsClass := newMeta new. |
|
165 |
||
166 |
someInstance := notRecognizedAsClass new. |
|
167 |
someInstance perform:#isNil |
|
356 | 168 |
|
357 | 169 |
|
170 |
Of course, this is an exception which can be handled ...: |
|
171 |
Example: |
|
172 |
||
2148 | 173 |
|newMeta notRecognizedAsClass someInstance| |
174 |
||
175 |
newMeta := Metaclass new. |
|
176 |
newMeta flags:0. |
|
177 |
||
178 |
notRecognizedAsClass := newMeta new. |
|
179 |
||
180 |
someInstance := notRecognizedAsClass new. |
|
181 |
Object errorSignal handle:[:ex | |
|
182 |
ex return |
|
183 |
] do:[ |
|
184 |
someInstance perform:#isNil |
|
185 |
] |
|
357 | 186 |
|
187 |
||
188 |
likewise, a doesNotUnderstand-notUnderstood can be handled: |
|
189 |
Example: |
|
190 |
||
2148 | 191 |
|newMeta funnyClass someInstance| |
192 |
||
193 |
newMeta := Metaclass new. |
|
194 |
||
195 |
funnyClass := newMeta new. |
|
196 |
funnyClass setSuperclass:nil. |
|
197 |
||
198 |
someInstance := funnyClass new. |
|
199 |
Object errorSignal handle:[:ex | |
|
200 |
ex return |
|
201 |
] do:[ |
|
202 |
someInstance perform:#isNil |
|
203 |
] |
|
357 | 204 |
|
205 |
||
362 | 206 |
more examples, which try to trick the VM ;-): |
2148 | 207 |
badly playing around with a classes internals ... |
208 |
||
209 |
|newClass someInstance| |
|
210 |
||
211 |
newClass := Class new. |
|
212 |
newClass setSuperclass:nil. |
|
213 |
someInstance := newClass new. |
|
214 |
someInstance inspect |
|
215 |
||
216 |
||
217 |
|newClass someInstance| |
|
218 |
||
219 |
newClass := Class new. |
|
220 |
newClass setSuperclass:newClass. |
|
221 |
someInstance := newClass new. |
|
222 |
someInstance inspect |
|
223 |
||
224 |
||
225 |
|newClass someInstance| |
|
226 |
||
227 |
newClass := Class new. |
|
228 |
newClass setSuperclass:1. |
|
229 |
someInstance := newClass new. |
|
230 |
someInstance inspect |
|
357 | 231 |
|
232 |
||
356 | 233 |
Example: |
2148 | 234 |
creating totally anonymous classes: |
235 |
||
236 |
|newClass someInstance| |
|
237 |
||
238 |
newClass := Class new. |
|
239 |
someInstance := newClass new. |
|
240 |
someInstance inspect |
|
356 | 241 |
|
357 | 242 |
|
356 | 243 |
Example: |
2148 | 244 |
creating totally anonymous metaclasses: |
245 |
||
246 |
|newMeta newClass someInstance| |
|
247 |
||
248 |
newMeta := Metaclass new. |
|
249 |
newClass := newMeta new. |
|
250 |
someInstance := newClass new. |
|
251 |
someInstance inspect |
|
357 | 252 |
|
253 |
PS: if you experiment with new behaviorLike objects, you may want |
|
2148 | 254 |
to turn off the VM's debugPrintouts |
255 |
with: |
|
256 |
'Smalltalk debugPrinting:false' |
|
257 |
and: |
|
258 |
'Smalltalk infoPrinting:false' |
|
356 | 259 |
" |
47 | 260 |
! ! |
1 | 261 |
|
1760 | 262 |
!Behavior class methodsFor:'creating new classes'! |
1 | 263 |
|
264 |
new |
|
356 | 265 |
"creates and return a new behavior (which is like a class, |
266 |
but without the symbolic & name information). |
|
267 |
Not for normal applications. |
|
268 |
Sending the returned behavior the #new message gives you |
|
269 |
an instance if it. |
|
270 |
||
271 |
Notice: the returned class is given a superclass of Object; |
|
272 |
this allows for its new instances to be inspected and the like." |
|
1 | 273 |
|
274 |
|newClass| |
|
275 |
||
276 |
newClass := self basicNew. |
|
277 |
newClass setSuperclass:Object |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
278 |
methodDictionary:MethodDictionary new |
154 | 279 |
instSize:0 |
345 | 280 |
flags:(self flagBehavior). |
1 | 281 |
^ newClass |
356 | 282 |
|
283 |
" |
|
284 |
Behavior new <- a new behavior |
|
285 |
Behavior new new <- an instance of it |
|
286 |
ClassDescription new <- a new classDescription |
|
287 |
ClassDescription new new <- an instance of it |
|
288 |
Class new <- a new class |
|
289 |
Class new new <- an instance of it |
|
290 |
Metaclass new <- a new metaclass |
|
291 |
Metaclass new new <- an instance (i.e. a class) of it |
|
292 |
Metaclass new new new <- an instance of this new class |
|
293 |
" |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
294 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
295 |
"Modified: 7.6.1996 / 15:38:58 / stefan" |
1 | 296 |
! ! |
297 |
||
1760 | 298 |
!Behavior class methodsFor:'flag bit constants'! |
620 | 299 |
|
300 |
flagBehavior |
|
301 |
"return the flag code which marks Behavior-like instances. |
|
2226 | 302 |
The VM checks this single bit in the flag value when |
620 | 303 |
checking for behaviors." |
304 |
||
305 |
%{ /* NOCONTEXT */ |
|
306 |
/* this is defined as a primitive to get defines from stc.h */ |
|
307 |
||
1133 | 308 |
RETURN ( __MKSMALLINT(BEHAVIOR_INSTS) ); |
620 | 309 |
%} |
310 |
||
311 |
"consistency check: |
|
312 |
all class-entries must be behaviors; |
|
313 |
all behaviors must be flagged so (in its class's flags) |
|
314 |
(otherwise, VM will bark) |
|
315 |
all non-behaviors may not be flagged |
|
316 |
||
317 |
|bit| |
|
318 |
bit := Class flagBehavior. |
|
319 |
||
320 |
ObjectMemory allObjectsDo:[:o| |
|
321 |
o isBehavior ifTrue:[ |
|
2226 | 322 |
(o class flags bitTest:bit) ifFalse:[ |
323 |
self halt |
|
324 |
]. |
|
620 | 325 |
] ifFalse:[ |
2226 | 326 |
(o class flags bitTest:bit) ifTrue:[ |
327 |
self halt |
|
328 |
]. |
|
620 | 329 |
]. |
330 |
o class isBehavior ifFalse:[ |
|
2226 | 331 |
self halt |
620 | 332 |
] ifTrue:[ |
2226 | 333 |
(o class class flags bitTest:bit) ifFalse:[ |
334 |
self halt |
|
335 |
] |
|
620 | 336 |
] |
337 |
] |
|
338 |
" |
|
339 |
! |
|
340 |
||
341 |
flagBlock |
|
342 |
"return the flag code which marks Block-like instances. |
|
2226 | 343 |
The VM checks this single bit in the flag value when |
620 | 344 |
checking for blocks." |
345 |
||
346 |
%{ /* NOCONTEXT */ |
|
347 |
/* this is defined as a primitive to get defines from stc.h */ |
|
348 |
||
1133 | 349 |
RETURN ( __MKSMALLINT(BLOCK_INSTS) ); |
620 | 350 |
%} |
351 |
! |
|
352 |
||
353 |
flagBlockContext |
|
354 |
"return the flag code which marks BlockContext-like instances. |
|
2226 | 355 |
The VM checks this single bit in the flag value when |
620 | 356 |
checking for blockContexts." |
357 |
||
358 |
%{ /* NOCONTEXT */ |
|
359 |
/* this is defined as a primitive to get defines from stc.h */ |
|
360 |
||
1133 | 361 |
RETURN ( __MKSMALLINT(BCONTEXT_INSTS) ); |
620 | 362 |
%} |
363 |
! |
|
364 |
||
365 |
flagBytes |
|
366 |
"return the flag code for byte-valued indexed instances. |
|
2226 | 367 |
The VM masks the flag value with the indexMask (maskIndexType) |
368 |
and compares it to this flag value, when checking for byte valued |
|
369 |
variable instances." |
|
620 | 370 |
|
371 |
%{ /* NOCONTEXT */ |
|
372 |
/* this is defined as a primitive to get defines from stc.h */ |
|
373 |
||
1133 | 374 |
RETURN ( __MKSMALLINT(BYTEARRAY) ); |
620 | 375 |
%} |
376 |
" |
|
377 |
Behavior flagBytes |
|
378 |
" |
|
379 |
! |
|
380 |
||
381 |
flagContext |
|
382 |
"return the flag code which marks Context-like instances. |
|
2226 | 383 |
The VM checks this single bit in the flag value when |
620 | 384 |
checking for contexts." |
385 |
||
386 |
%{ /* NOCONTEXT */ |
|
387 |
/* this is defined as a primitive to get defines from stc.h */ |
|
388 |
||
1133 | 389 |
RETURN ( __MKSMALLINT(CONTEXT_INSTS) ); |
620 | 390 |
%} |
391 |
! |
|
392 |
||
393 |
flagDoubles |
|
394 |
"return the flag code for double-valued indexed instances (i.e. 8-byte reals). |
|
2226 | 395 |
The VM masks the flag value with the indexMask (maskIndexType) |
396 |
and compares it to this flag value, when checking for double valued |
|
397 |
variable instances." |
|
620 | 398 |
|
399 |
%{ /* NOCONTEXT */ |
|
400 |
/* this is defined as a primitive to get defines from stc.h */ |
|
401 |
||
1133 | 402 |
RETURN ( __MKSMALLINT(DOUBLEARRAY) ); |
620 | 403 |
%} |
404 |
" |
|
405 |
Behavior flagDoubles |
|
2226 | 406 |
|
407 |
(ByteArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
408 |
(DoubleArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
409 |
(Object flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
620 | 410 |
" |
411 |
! |
|
412 |
||
413 |
flagFloat |
|
414 |
"return the flag code which marks Float-like instances. |
|
2226 | 415 |
The VM checks this single bit in the flag value when |
416 |
checking for a float." |
|
620 | 417 |
|
418 |
%{ /* NOCONTEXT */ |
|
419 |
/* this is defined as a primitive to get defines from stc.h */ |
|
420 |
||
1133 | 421 |
RETURN ( __MKSMALLINT(FLOAT_INSTS) ); |
620 | 422 |
%} |
423 |
! |
|
424 |
||
425 |
flagFloats |
|
426 |
"return the flag code for float-valued indexed instances (i.e. 4-byte reals). |
|
2226 | 427 |
The VM masks the flag value with the indexMask (maskIndexType) |
428 |
and compares it to this flag value, when checking for double valued |
|
429 |
variable instances." |
|
620 | 430 |
|
431 |
%{ /* NOCONTEXT */ |
|
432 |
/* this is defined as a primitive to get defines from stc.h */ |
|
433 |
||
1133 | 434 |
RETURN ( __MKSMALLINT(FLOATARRAY) ); |
620 | 435 |
%} |
436 |
" |
|
437 |
Behavior flagFloats |
|
438 |
" |
|
439 |
! |
|
440 |
||
1634 | 441 |
flagForSymbolic:aSymbol |
442 |
"return the flag code for indexed instances with aSymbolic type. |
|
443 |
The argument may be one of #float, #double, #long, #word, #signedWord, |
|
444 |
#signedLong or #byte." |
|
445 |
||
446 |
%{ /* NOCONTEXT */ |
|
447 |
if (aSymbol == @symbol(float)) { |
|
448 |
RETURN ( __MKSMALLINT(FLOATARRAY) ); |
|
449 |
} |
|
450 |
if (aSymbol == @symbol(double)) { |
|
451 |
RETURN ( __MKSMALLINT(DOUBLEARRAY) ); |
|
452 |
} |
|
453 |
if (aSymbol == @symbol(long)) { |
|
454 |
RETURN ( __MKSMALLINT(LONGARRAY) ); |
|
455 |
} |
|
456 |
if (aSymbol == @symbol(word)) { |
|
457 |
RETURN ( __MKSMALLINT(WORDARRAY) ); |
|
458 |
} |
|
459 |
if (aSymbol == @symbol(signedWord)) { |
|
460 |
RETURN ( __MKSMALLINT(SWORDARRAY) ); |
|
461 |
} |
|
462 |
if (aSymbol == @symbol(signedLong)) { |
|
463 |
RETURN ( __MKSMALLINT(SLONGARRAY) ); |
|
464 |
} |
|
465 |
if (aSymbol == @symbol(byte)) { |
|
466 |
RETURN ( __MKSMALLINT(BYTEARRAY) ); |
|
467 |
} |
|
468 |
%}. |
|
469 |
^ 0 "/ not indexed |
|
470 |
! |
|
471 |
||
620 | 472 |
flagLongs |
473 |
"return the flag code for long-valued indexed instances (i.e. 4-byte). |
|
2226 | 474 |
The VM masks the flag value with the indexMask (maskIndexType) |
475 |
and compares it to this flag value, when checking for |
|
476 |
unsigned long valued variable instances." |
|
620 | 477 |
|
478 |
%{ /* NOCONTEXT */ |
|
479 |
/* this is defined as a primitive to get defines from stc.h */ |
|
480 |
||
1133 | 481 |
RETURN ( __MKSMALLINT(LONGARRAY) ); |
620 | 482 |
%} |
483 |
" |
|
484 |
Behavior flagLongs |
|
485 |
" |
|
486 |
! |
|
487 |
||
488 |
flagMethod |
|
489 |
"return the flag code which marks Method-like instances. |
|
2226 | 490 |
The VM checks this single bit in the flag value when |
491 |
checking for a method." |
|
620 | 492 |
|
493 |
%{ /* NOCONTEXT */ |
|
494 |
/* this is defined as a primitive to get defines from stc.h */ |
|
495 |
||
1133 | 496 |
RETURN ( __MKSMALLINT(METHOD_INSTS) ); |
620 | 497 |
%} |
498 |
! |
|
499 |
||
500 |
flagNonObjectInst |
|
501 |
"return the flag code which marks instances which have a |
|
502 |
non-object instance variable (in slot 1). |
|
503 |
(these are ignored by the garbage collector)" |
|
504 |
||
505 |
%{ /* NOCONTEXT */ |
|
506 |
/* this is defined as a primitive to get defines from stc.h */ |
|
507 |
||
1133 | 508 |
RETURN ( __MKSMALLINT(NONOBJECT_INSTS) ); |
620 | 509 |
%} |
510 |
! |
|
511 |
||
512 |
flagNotIndexed |
|
513 |
"return the flag code for non-indexed instances. |
|
514 |
You have to mask the flag value with indexMask when comparing |
|
515 |
it with flagNotIndexed." |
|
516 |
||
517 |
^ 0 |
|
518 |
! |
|
519 |
||
520 |
flagPointers |
|
521 |
"return the flag code for pointer indexed instances (i.e. Array of object). |
|
2226 | 522 |
The VM masks the flag value with the indexMask (maskIndexType) |
523 |
and compares it to this flag value, when checking for |
|
524 |
pointer variable instances." |
|
620 | 525 |
|
526 |
%{ /* NOCONTEXT */ |
|
527 |
/* this is defined as a primitive to get defines from stc.h */ |
|
528 |
||
1133 | 529 |
RETURN ( __MKSMALLINT(POINTERARRAY) ); |
620 | 530 |
%} |
531 |
" |
|
532 |
Behavior flagPointers |
|
533 |
" |
|
534 |
! |
|
535 |
||
1383 | 536 |
flagRegular |
537 |
"return the flag code which marks regular instances." |
|
538 |
||
539 |
^ 0 |
|
540 |
||
541 |
"Created: 12.5.1996 / 17:53:36 / cg" |
|
542 |
! |
|
543 |
||
1634 | 544 |
flagSignedLongs |
545 |
"return the flag code for signed long-valued indexed instances (i.e. 4-byte). |
|
2226 | 546 |
The VM masks the flag value with the indexMask (maskIndexType) |
547 |
and compares it to this flag value, when checking for |
|
548 |
signed long valued variable instances." |
|
1634 | 549 |
|
550 |
%{ /* NOCONTEXT */ |
|
551 |
/* this is defined as a primitive to get defines from stc.h */ |
|
552 |
||
553 |
RETURN ( __MKSMALLINT(SLONGARRAY) ); |
|
554 |
%} |
|
555 |
" |
|
556 |
Behavior flagSignedLongs |
|
557 |
" |
|
558 |
! |
|
559 |
||
560 |
flagSignedWords |
|
561 |
"return the flag code for signed word-valued indexed instances (i.e. 2-byte). |
|
2226 | 562 |
The VM masks the flag value with the indexMask (maskIndexType) |
563 |
and compares it to this flag value, when checking for |
|
564 |
signed word valued variable instances." |
|
1634 | 565 |
|
566 |
%{ /* NOCONTEXT */ |
|
567 |
/* this is defined as a primitive to get defines from stc.h */ |
|
568 |
||
569 |
RETURN ( __MKSMALLINT(SWORDARRAY) ); |
|
570 |
%} |
|
571 |
" |
|
572 |
Behavior flagSignedWords |
|
573 |
" |
|
574 |
! |
|
575 |
||
620 | 576 |
flagSymbol |
577 |
"return the flag code which marks Symbol-like instances. |
|
2226 | 578 |
The VM checks this single bit in the flag value when |
620 | 579 |
checking for symbols." |
580 |
||
581 |
%{ /* NOCONTEXT */ |
|
582 |
/* this is defined as a primitive to get defines from stc.h */ |
|
583 |
||
1133 | 584 |
RETURN ( __MKSMALLINT(SYMBOL_INSTS) ); |
620 | 585 |
%} |
586 |
! |
|
587 |
||
588 |
flagWeakPointers |
|
589 |
"return the flag code for weak pointer indexed instances (i.e. WeakArray). |
|
2226 | 590 |
The VM masks the flag value with the indexMask (maskIndexType) |
591 |
and compares it to this flag value, when checking for weak pointers." |
|
620 | 592 |
|
593 |
%{ /* NOCONTEXT */ |
|
594 |
/* this is defined as a primitive to get defines from stc.h */ |
|
595 |
||
1133 | 596 |
RETURN ( __MKSMALLINT(WKPOINTERARRAY) ); |
620 | 597 |
%} |
598 |
! |
|
599 |
||
600 |
flagWords |
|
601 |
"return the flag code for word-valued indexed instances (i.e. 2-byte). |
|
2226 | 602 |
The VM masks the flag value with the indexMask (maskIndexType) |
603 |
and compares it to this flag value, when checking for |
|
604 |
unsigned word valued variable instances." |
|
620 | 605 |
|
606 |
%{ /* NOCONTEXT */ |
|
607 |
/* this is defined as a primitive to get defines from stc.h */ |
|
608 |
||
1133 | 609 |
RETURN ( __MKSMALLINT(WORDARRAY) ); |
620 | 610 |
%} |
611 |
" |
|
612 |
Behavior flagWords |
|
613 |
" |
|
614 |
! |
|
615 |
||
616 |
maskIndexType |
|
617 |
"return a mask to extract all index-type bits" |
|
618 |
||
619 |
%{ /* NOCONTEXT */ |
|
620 |
/* this is defined as a primitive to get defines from stc.h */ |
|
621 |
||
1133 | 622 |
RETURN ( __MKSMALLINT(ARRAYMASK) ); |
620 | 623 |
%} |
624 |
! ! |
|
625 |
||
1760 | 626 |
!Behavior class methodsFor:'private '! |
308 | 627 |
|
620 | 628 |
flushSubclassInfo |
2224 | 629 |
"throw away (forget) the cached subclass information, as created |
630 |
by #subclassInfo. |
|
631 |
This is private protocol" |
|
632 |
||
620 | 633 |
SubclassInfo := nil. |
634 |
||
635 |
" |
|
636 |
Class flushSubclassInfo |
|
637 |
" |
|
2224 | 638 |
|
639 |
"Modified: 22.1.1997 / 18:39:36 / cg" |
|
620 | 640 |
! |
641 |
||
308 | 642 |
subclassInfo |
2224 | 643 |
"build & return a dictionary, containing the set of subclass |
644 |
for each class. This information is kept until explicitely flushed |
|
645 |
by #flushSubclassInfo. |
|
646 |
This cache is used internally, for enumerators like #allSubclasses |
|
647 |
or #allSubclassesDo:, to avoid repeated recursive walks over the class |
|
648 |
hierarchy. |
|
649 |
This is private protocol." |
|
650 |
||
357 | 651 |
|d| |
308 | 652 |
|
653 |
SubclassInfo notNil ifTrue:[^ SubclassInfo]. |
|
654 |
||
655 |
d := IdentityDictionary new. |
|
656 |
Smalltalk allClassesDo:[:aClass | |
|
2224 | 657 |
|superCls| |
658 |
||
659 |
aClass isMeta not ifTrue:[ |
|
660 |
superCls := aClass superclass. |
|
661 |
superCls notNil ifTrue:[ |
|
662 |
(d includesKey: superCls) ifFalse:[ |
|
663 |
d at:superCls put:(IdentitySet with:aClass). |
|
664 |
] ifTrue:[ |
|
665 |
(d at:superCls ) add:aClass |
|
666 |
] |
|
667 |
] |
|
668 |
]. |
|
308 | 669 |
]. |
670 |
SubclassInfo := d. |
|
671 |
^ d |
|
672 |
||
673 |
" |
|
674 |
Class subclassInfo |
|
675 |
" |
|
2224 | 676 |
|
677 |
"Modified: 22.1.1997 / 18:44:59 / cg" |
|
620 | 678 |
! ! |
679 |
||
1760 | 680 |
!Behavior class methodsFor:'queries'! |
620 | 681 |
|
682 |
isBuiltInClass |
|
1266 | 683 |
"return true if this class is known by the run-time-system. |
684 |
Here, true is returned for myself, false for subclasses." |
|
620 | 685 |
|
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
686 |
^ (self == Behavior class) or:[self == Behavior] |
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
687 |
|
1266 | 688 |
"Modified: 23.4.1996 / 15:55:52 / cg" |
620 | 689 |
! ! |
690 |
||
691 |
!Behavior methodsFor:'accessing'! |
|
692 |
||
693 |
addSelector:newSelector withLazyMethod:newMethod |
|
694 |
"add the method given by 2nd argument under the selector given by |
|
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
695 |
1st argument to the methodDictionary. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
696 |
Since it does not normally flush any caches, |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
697 |
this is only allowed for lazy methods (which are for a new class)." |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
698 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
699 |
|oldMethod| |
620 | 700 |
|
701 |
newMethod isLazyMethod ifFalse:[ |
|
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
702 |
self error:'operation only allowed for lazy methods'. |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
703 |
^ false |
620 | 704 |
]. |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
705 |
oldMethod := self compiledMethodAt:newSelector. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
706 |
"/ |
620 | 707 |
"/ oops: we must flush, if this method already exists ... |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
708 |
"/ otherwise, the old method would still be executed out of the caches. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
709 |
"/ |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
710 |
oldMethod notNil ifTrue:[ |
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
711 |
newMethod privacy:(oldMethod privacy). |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
712 |
newMethod restricted:(oldMethod isRestricted). |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
713 |
ObjectMemory flushCaches |
620 | 714 |
]. |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
715 |
|
620 | 716 |
(self primAddSelector:newSelector withMethod:newMethod) ifTrue:[ |
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
717 |
"/ |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
718 |
"/ pass the selector AND the old method as changeArg |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
719 |
"/ - this allows for watchers to find out if its a new method or a method-change |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
720 |
"/ |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
721 |
self changed:#methodDictionary with:(Array with:newSelector with:oldMethod). |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
722 |
"/ |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
723 |
"/ also notify a change of Smalltalk; |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
724 |
"/ this allows a dependent of Smalltalk to watch all class |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
725 |
"/ changes (no need for observing all classes) |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
726 |
"/ - this allows for watchers to find out if its a new method or a method-change |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
727 |
"/ |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
728 |
Smalltalk changed:#methodInClass with:(Array with:self with:newSelector with:oldMethod). |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
729 |
^ true |
620 | 730 |
]. |
731 |
^ false |
|
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
732 |
|
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
733 |
"Modified: 8.1.1997 / 23:02:10 / cg" |
308 | 734 |
! |
735 |
||
620 | 736 |
addSelector:newSelector withMethod:newMethod |
737 |
"add the method given by 2nd argument under the selector given by |
|
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
738 |
1st argument to the methodDictionary. Flushes all caches." |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
739 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
740 |
|nargs oldMethod| |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
741 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
742 |
oldMethod := self compiledMethodAt:newSelector. |
620 | 743 |
(self primAddSelector:newSelector withMethod:newMethod) ifFalse:[^ false]. |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
744 |
|
746
31f5d9af5680
dont forget privace & restricted when entering a method
Claus Gittinger <cg@exept.de>
parents:
734
diff
changeset
|
745 |
oldMethod notNil ifTrue:[ |
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
746 |
newMethod privacy:(oldMethod privacy). |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
747 |
newMethod restricted:(oldMethod isRestricted). |
746
31f5d9af5680
dont forget privace & restricted when entering a method
Claus Gittinger <cg@exept.de>
parents:
734
diff
changeset
|
748 |
]. |
31f5d9af5680
dont forget privace & restricted when entering a method
Claus Gittinger <cg@exept.de>
parents:
734
diff
changeset
|
749 |
|
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
750 |
"/ |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
751 |
"/ pass the selector AND the old method as changeArg |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
752 |
"/ - this allows for watchers to find out if its a new method or a method-change |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
753 |
"/ |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
754 |
self changed:#methodDictionary with:(Array with:newSelector with:oldMethod). |
620 | 755 |
|
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
756 |
"/ |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
757 |
"/ also notify a change of Smalltalk; |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
758 |
"/ this allows a dependent of Smalltalk to watch all class |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
759 |
"/ changes (no need for observing all classes) |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
760 |
"/ - this allows for watchers to find out if its a new method or a method-change |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
761 |
"/ |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
762 |
Smalltalk changed:#methodInClass with:(Array with:self with:newSelector with:oldMethod). |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
763 |
|
620 | 764 |
" |
765 |
if I have no subclasses, all we have to flush is cached |
|
766 |
data for myself ... (actually, in any case all that needs |
|
767 |
to be flushed is info for myself and all of my subclasses) |
|
768 |
" |
|
769 |
" |
|
770 |
problem: this is slower; since looking for all subclasses is (currently) |
|
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
771 |
a bit slow :-( |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
772 |
We need the hasSubclasses-info bit in Behavior; now |
620 | 773 |
|
774 |
self withAllSubclassesDo:[:aClass | |
|
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
775 |
ObjectMemory flushInlineCachesFor:aClass withArgs:nargs. |
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
776 |
ObjectMemory flushMethodCacheFor:aClass |
620 | 777 |
]. |
778 |
" |
|
779 |
||
780 |
nargs := newSelector numArgs. |
|
781 |
||
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
782 |
ObjectMemory flushMethodCacheForSelector:newSelector. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
783 |
"/ ObjectMemory flushMethodCache. |
620 | 784 |
ObjectMemory flushInlineCachesWithArgs:nargs. |
785 |
||
786 |
^ true |
|
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
787 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
788 |
"Created: 11.12.1995 / 13:59:37 / cg" |
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
789 |
"Modified: 8.1.1997 / 22:43:13 / cg" |
620 | 790 |
! |
791 |
||
792 |
addSuperclass:aClass |
|
793 |
"EXPERIMENTAL MI support: add aClass to the set of classes, from which instances |
|
794 |
inherit protocol." |
|
795 |
||
796 |
"first, check if the class is abstract - |
|
797 |
allows abstract mixins are allowed in the current implementation" |
|
798 |
||
799 |
aClass instSize == 0 ifFalse:[ |
|
800 |
self error:'only abstract mixins allowed'. |
|
801 |
^ self |
|
802 |
]. |
|
803 |
otherSuperclasses isNil ifTrue:[ |
|
804 |
otherSuperclasses := Array with:aClass |
|
805 |
] ifFalse:[ |
|
806 |
otherSuperclasses := otherSuperclasses copyWith:aClass |
|
807 |
]. |
|
308 | 808 |
SubclassInfo := nil. |
620 | 809 |
ObjectMemory flushCaches |
810 |
! |
|
811 |
||
812 |
displayString |
|
813 |
"although behaviors have no name, we return something |
|
814 |
useful here - there are many places (inspectors) where |
|
815 |
a classes name is asked for. |
|
816 |
Implementing this message here allows instances of anonymous classes |
|
817 |
to show a reasonable name." |
|
818 |
||
819 |
^ 'someBehavior' |
|
820 |
! |
|
821 |
||
822 |
flags |
|
823 |
"return the receivers flag bits" |
|
824 |
||
825 |
^ flags |
|
826 |
! |
|
827 |
||
828 |
instSize |
|
829 |
"return the number of instance variables of the receiver. |
|
830 |
This includes all superclass instance variables." |
|
831 |
||
832 |
^ instSize |
|
833 |
! |
|
834 |
||
835 |
methodDictionary |
|
1634 | 836 |
"return the receivers method dictionary." |
620 | 837 |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
838 |
^ methodDictionary |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
839 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
840 |
"Modified: 12.6.1996 / 13:47:08 / stefan" |
1634 | 841 |
"Modified: 16.8.1996 / 14:55:21 / cg" |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
842 |
! |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
843 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
844 |
methodDictionary:dict |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
845 |
"set the receivers method dictionary and flush inline caches." |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
846 |
|
1814 | 847 |
dict isNil ifTrue:[ |
848 |
self halt:'attempt to set methodDictionary to nil.' |
|
849 |
]. |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
850 |
self setMethodDictionary:dict. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
851 |
ObjectMemory flushCaches. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
852 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
853 |
"Created: 5.6.1996 / 11:29:36 / stefan" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
854 |
"Modified: 7.6.1996 / 08:39:51 / stefan" |
620 | 855 |
! |
856 |
||
857 |
removeSelector:aSelector |
|
858 |
"remove the selector, aSelector and its associated method |
|
859 |
from the methodDictionary" |
|
860 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
861 |
|dict newDict| |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
862 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
863 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
864 |
newDict := dict removeKeyAndCompress:aSelector. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
865 |
newDict isNil ifTrue:[ |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
866 |
^ false. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
867 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
868 |
self setMethodDictionary:newDict. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
869 |
|
620 | 870 |
" |
871 |
[ |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
872 |
|nargs| |
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
873 |
nargs := aSelector numArgs. |
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
874 |
ObjectMemory flushMethodCache. |
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
875 |
ObjectMemory flushInlineCachesWithArgs:nargs. |
620 | 876 |
] value |
877 |
" |
|
878 |
" |
|
879 |
actually, we would do better with less flushing ... |
|
880 |
" |
|
881 |
ObjectMemory flushCaches. |
|
882 |
^ true |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
883 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
884 |
"Modified: 12.6.1996 / 11:54:29 / stefan" |
620 | 885 |
! |
886 |
||
887 |
removeSuperclass:aClass |
|
888 |
"EXPERIMENTAL MI support: remove aClass from the set of classes, from which instances |
|
889 |
inherit protocol." |
|
890 |
||
891 |
otherSuperclasses notNil ifTrue:[ |
|
892 |
otherSuperclasses := otherSuperclasses copyWithout:aClass. |
|
893 |
otherSuperclasses isEmpty ifTrue:[ |
|
894 |
otherSuperclasses := nil |
|
895 |
]. |
|
896 |
SubclassInfo := nil. |
|
897 |
ObjectMemory flushCaches |
|
898 |
]. |
|
899 |
! |
|
900 |
||
901 |
selectors |
|
902 |
"return the receivers selector array as an orderedCollection. |
|
903 |
Notice: this may not be compatible with ST-80. |
|
904 |
(should we return a Set ?)" |
|
905 |
||
1814 | 906 |
|md| |
907 |
||
1967
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
908 |
(md := self methodDictionary) isNil ifTrue:[ |
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
909 |
'oops - nil methodDictionary' errorPrintCR. |
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
910 |
^ #() |
1814 | 911 |
]. |
912 |
^ md keys |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
913 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
914 |
"Modified: 7.6.1996 / 15:33:18 / stefan" |
1967
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
915 |
"Modified: 12.11.1996 / 11:31:51 / cg" |
620 | 916 |
! |
917 |
||
918 |
superclass |
|
919 |
"return the receivers superclass" |
|
920 |
||
921 |
^ superclass |
|
922 |
! |
|
923 |
||
924 |
superclass:aClass |
|
925 |
"set the superclass - this actually creates a new class, |
|
926 |
recompiling all methods for the new one. The receiving class stays |
|
927 |
around anonymous to allow existing instances some life. |
|
928 |
This may change in the future (adjusting existing instances)" |
|
929 |
||
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
930 |
|owner ns name| |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
931 |
|
620 | 932 |
SubclassInfo := nil. |
933 |
||
934 |
"must flush caches since lookup chain changes" |
|
935 |
ObjectMemory flushCaches. |
|
936 |
||
937 |
" |
|
938 |
superclass := aClass |
|
939 |
" |
|
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
940 |
"/ for correct recompilation, just create a new class ... |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
941 |
"/ but care to avoid a nameSpace change, by giving my |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
942 |
"/ full name and answering with Smalltalk to a nameSpace query. |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
943 |
|
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
944 |
(owner := self owningClass) notNil ifTrue:[ |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
945 |
ns := owner. |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
946 |
name := self nameWithoutPrefix asSymbol |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
947 |
] ifFalse:[ |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
948 |
ns := Smalltalk. |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
949 |
name := self name |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
950 |
]. |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
951 |
|
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
952 |
Class nameSpaceQuerySignal |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
953 |
answer:ns |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
954 |
do:[ |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
955 |
aClass |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
956 |
subclass:name |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
957 |
instanceVariableNames:(self instanceVariableString) |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
958 |
classVariableNames:(self classVariableString) |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
959 |
poolDictionaries:'' |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
960 |
category:self category |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
961 |
] |
620 | 962 |
! ! |
963 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
964 |
!Behavior methodsFor:'accessing virtual instvars'! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
965 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
966 |
implicit_methodDict |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
967 |
"ST-80 compatibility behavior subclasses. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
968 |
This allows subclasses to assume there is an instance variable |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
969 |
named methodDict (compile them with implicit self-sends)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
970 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
971 |
^ self methodDictionary |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
972 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
973 |
"Modified: 16.4.1996 / 18:09:44 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
974 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
975 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
976 |
implicit_methodDict:aDictionary |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
977 |
"ST-80 compatibility behavior subclasses. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
978 |
This allows subclasses to assume there is an instance variable |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
979 |
named methodDict (compile them with implicit self-sends)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
980 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
981 |
^ self error:'not allowed to set the methodDictionary' |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
982 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
983 |
"Modified: 16.4.1996 / 18:09:52 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
984 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
985 |
|
620 | 986 |
!Behavior methodsFor:'autoload check'! |
987 |
||
988 |
autoload |
|
989 |
"force autoloading - do nothing here; |
|
990 |
redefined in Autoload; see comment there" |
|
991 |
||
992 |
^ self |
|
993 |
! |
|
994 |
||
995 |
isLoaded |
|
996 |
"return true, if the class has been loaded; |
|
997 |
redefined in Autoload; see comment there" |
|
998 |
||
999 |
^ true |
|
1000 |
! ! |
|
1001 |
||
1002 |
!Behavior methodsFor:'binary storage'! |
|
1003 |
||
1004 |
binaryDefinitionFrom:stream manager:manager |
|
1005 |
"sent during a binary read by the input manager. |
|
1006 |
Read the definition on an empty instance (of my class) from stream. |
|
1007 |
All pointer instances are left nil, while all bits are read in here. |
|
1008 |
return the new object." |
|
1009 |
||
1010 |
|obj t |
|
1011 |
basicSize "{ Class: SmallInteger }" | |
|
1012 |
||
1013 |
self isPointers ifTrue: [ |
|
1014 |
"/ |
|
1015 |
"/ inst size not needed - if you uncomment the line below, |
|
1016 |
"/ also uncomment the corresponding line in |
|
1017 |
"/ Object>>storeBinaryDefinitionOn:manager: |
|
1018 |
"/ |
|
1019 |
"/ stream next. "skip instSize" |
|
1020 |
self isVariable ifTrue: [ |
|
1021 |
^ self basicNew:(stream nextNumber:3) |
|
1022 |
]. |
|
1023 |
^ self basicNew |
|
1024 |
]. |
|
308 | 1025 |
|
1026 |
" |
|
620 | 1027 |
an object with bit-valued instance variables. |
1028 |
These are read here. |
|
1029 |
" |
|
1030 |
basicSize := stream nextNumber:4. |
|
1031 |
obj := self basicNew:basicSize. |
|
1032 |
||
1033 |
self isBytes ifTrue: [ |
|
1034 |
stream nextBytes:basicSize into:obj |
|
1035 |
] ifFalse: [ |
|
1036 |
self isWords ifTrue: [ |
|
1037 |
1 to:basicSize do:[:i | |
|
1038 |
obj basicAt:i put:(stream nextNumber:2) |
|
1039 |
] |
|
1040 |
] ifFalse:[ |
|
1041 |
self isLongs ifTrue: [ |
|
1042 |
1 to:basicSize do:[:i | |
|
1043 |
obj basicAt:i put:(stream nextNumber:4) |
|
1044 |
] |
|
1045 |
] ifFalse:[ |
|
1046 |
self isFloats ifTrue: [ |
|
1047 |
"could do it in one big read on machines which use IEEE floats ..." |
|
1048 |
t := Float basicNew. |
|
1049 |
1 to:basicSize do:[:i | |
|
1050 |
Float readBinaryIEEESingleFrom:stream into:t. |
|
1051 |
obj basicAt:i put: t |
|
1052 |
] |
|
1053 |
] ifFalse:[ |
|
1054 |
self isDoubles ifTrue: [ |
|
1055 |
"could do it in one big read on machines which use IEEE doubles ..." |
|
1056 |
t := Float basicNew. |
|
1057 |
1 to:basicSize do:[:i | |
|
1058 |
Float readBinaryIEEEDoubleFrom:stream into:t. |
|
1059 |
obj basicAt:i put: t |
|
1060 |
] |
|
1061 |
] |
|
1062 |
] |
|
1063 |
] |
|
1064 |
] |
|
1065 |
]. |
|
1066 |
^obj |
|
1067 |
! |
|
1068 |
||
1069 |
canCloneFrom:anObject |
|
1070 |
"return true, if this class can clone an obsolete object as retrieved |
|
1071 |
by a binary load. Subclasses which do not want to have obsolete objects |
|
1072 |
be converted, should redefine this method to return false. |
|
1073 |
(However, conversion is never done silently in a binary load; you |
|
1074 |
have to have a handler for the binaryload errors and for the conversion |
|
1075 |
request signal.)" |
|
1076 |
||
1077 |
^ true |
|
1078 |
! |
|
1079 |
||
1080 |
cloneFrom:aPrototype |
|
1081 |
"return an instance of myself with variables initialized from |
|
1082 |
a prototype. This is used when instances of obsolete classes are |
|
1083 |
binary loaded and a conversion is done on the obsolete object. |
|
1084 |
UserClasses may redefine this for better conversions." |
|
1085 |
||
1086 |
|newInst indexed myInfo otherInfo varIndexAssoc| |
|
1087 |
||
1088 |
indexed := false. |
|
1089 |
aPrototype class isVariable ifTrue:[ |
|
1090 |
self isVariable ifTrue:[ |
|
1091 |
indexed := true. |
|
1092 |
]. |
|
1093 |
"otherwise, these are lost ..." |
|
1094 |
]. |
|
1095 |
indexed ifTrue:[ |
|
1096 |
newInst := self basicNew:aPrototype basicSize |
|
1097 |
] ifFalse:[ |
|
1098 |
newInst := self basicNew |
|
1099 |
]. |
|
1100 |
||
1101 |
myInfo := self instanceVariableOffsets. |
|
1102 |
otherInfo := aPrototype class instanceVariableOffsets. |
|
1103 |
myInfo keysAndValuesDo:[:name :index | |
|
1104 |
varIndexAssoc := otherInfo at:name ifAbsent:[]. |
|
1105 |
varIndexAssoc notNil ifTrue:[ |
|
1106 |
newInst instVarAt:index put:(aPrototype instVarAt:(varIndexAssoc value)) |
|
1107 |
] |
|
1108 |
]. |
|
1109 |
indexed ifTrue:[ |
|
1110 |
1 to:aPrototype basicSize do:[:index | |
|
1111 |
newInst basicAt:index put:(aPrototype basicAt:index) |
|
1112 |
]. |
|
1113 |
]. |
|
1114 |
^ newInst |
|
1115 |
||
1116 |
" |
|
1117 |
Class withoutUpdatingChangesDo:[ |
|
1118 |
Point subclass:#Point3D |
|
1119 |
instanceVariableNames:'z' |
|
1120 |
classVariableNames:'' |
|
1121 |
poolDictionaries:'' |
|
1122 |
category:'testing'. |
|
1123 |
(Point3D cloneFrom:1@2) inspect. |
|
1124 |
] |
|
1125 |
" |
|
1126 |
||
1127 |
" |
|
1128 |
Class withoutUpdatingChangesDo:[ |
|
1129 |
Point variableSubclass:#Point3D |
|
1130 |
instanceVariableNames:'z' |
|
1131 |
classVariableNames:'' |
|
1132 |
poolDictionaries:'' |
|
1133 |
category:'testing'. |
|
1134 |
(Point3D cloneFrom:#(1 2 3)) inspect. |
|
1135 |
] |
|
1136 |
" |
|
1137 |
||
1138 |
" |
|
1139 |
|someObject| |
|
1140 |
||
1141 |
Class withoutUpdatingChangesDo:[ |
|
1142 |
Object subclass:#TestClass1 |
|
1143 |
instanceVariableNames:'foo bar' |
|
1144 |
classVariableNames:'' |
|
1145 |
poolDictionaries:'' |
|
1146 |
category:'testing'. |
|
1147 |
someObject := TestClass1 new. |
|
1148 |
someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'. |
|
1149 |
Object subclass:#TestClass2 |
|
1150 |
instanceVariableNames:'bar foo' |
|
1151 |
classVariableNames:'' |
|
1152 |
poolDictionaries:'' |
|
1153 |
category:'testing'. |
|
1154 |
(TestClass2 cloneFrom:someObject) inspect. |
|
1155 |
] |
|
1156 |
" |
|
1157 |
! |
|
1158 |
||
1159 |
readBinaryFrom:aStream |
|
1160 |
"read an objects binary representation from the argument, |
|
1161 |
aStream and return it. |
|
1162 |
The read object must be a kind of myself, otherwise an error is raised. |
|
1163 |
To get any object, use 'Object readBinaryFrom:...', |
|
1164 |
To get any number, use 'Number readBinaryFrom:...' and so on. |
|
1165 |
This is the reverse operation to 'storeBinaryOn:'. " |
|
1166 |
||
1167 |
^ self readBinaryFrom:aStream onError:[self error:('expected ' , self name)] |
|
1168 |
||
1169 |
" |
|
1170 |
|s| |
|
1171 |
s := WriteStream on:(ByteArray new). |
|
1172 |
#(1 2 3 4) storeBinaryOn:s. |
|
1173 |
Object readBinaryFrom:(ReadStream on:s contents) |
|
1174 |
" |
|
1175 |
" |
|
1176 |
|s| |
|
1177 |
s := 'testFile' asFilename writeStream binary. |
|
1178 |
#(1 2 3 4) storeBinaryOn:s. |
|
1179 |
'hello world' storeBinaryOn:s. |
|
1180 |
s close. |
|
1181 |
||
1182 |
s := 'testFile' asFilename readStream binary. |
|
1422 | 1183 |
Transcript showCR:(Object readBinaryFrom:s). |
1184 |
Transcript showCR:(Object readBinaryFrom:s). |
|
620 | 1185 |
s close. |
1186 |
" |
|
1187 |
! |
|
1188 |
||
1189 |
readBinaryFrom:aStream onError:exceptionBlock |
|
1190 |
"read an objects binary representation from the argument, |
|
1191 |
aStream and return it. |
|
1192 |
The read object must be a kind of myself, otherwise the value of |
|
1193 |
the exceptionBlock is returned. |
|
1194 |
To get any object, use 'Object readBinaryFrom:...', |
|
1195 |
To get any number, use 'Number readBinaryFrom:...' and so on. |
|
1196 |
This is the reverse operation to 'storeBinaryOn:'. " |
|
1197 |
||
1198 |
|newObject| |
|
1199 |
||
1200 |
newObject := (BinaryInputManager new:1024) readFrom:aStream. |
|
1834
b46ca5e3f1ec
allow readBinaryFrom ... to return a nonObject, if sent to
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1201 |
(self ~~ Object |
b46ca5e3f1ec
allow readBinaryFrom ... to return a nonObject, if sent to
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1202 |
and:[(newObject isKindOf:self) not]) ifTrue:[^ exceptionBlock value]. |
620 | 1203 |
^ newObject |
1204 |
||
1205 |
" |
|
1206 |
|s| |
|
1207 |
s := WriteStream on:(ByteArray new). |
|
1208 |
#(1 2 3 4) storeBinaryOn:s. |
|
1209 |
Object readBinaryFrom:(ReadStream on:s contents) onError:['oops'] |
|
1210 |
" |
|
1211 |
" |
|
1212 |
|s| |
|
1213 |
s := WriteStream on:(ByteArray new). |
|
1214 |
#[1 2 3 4] storeBinaryOn:s. |
|
1215 |
Array readBinaryFrom:(ReadStream on:s contents) onError:['oops'] |
|
1216 |
" |
|
1834
b46ca5e3f1ec
allow readBinaryFrom ... to return a nonObject, if sent to
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1217 |
|
b46ca5e3f1ec
allow readBinaryFrom ... to return a nonObject, if sent to
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1218 |
"Modified: 28.10.1996 / 16:31:32 / cg" |
620 | 1219 |
! |
1220 |
||
1221 |
storeBinaryDefinitionOn: stream manager: manager |
|
1222 |
"binary store of a classes definition. |
|
1223 |
Classes will store the name only and restore by looking for |
|
1259 | 1224 |
that name in the Smalltalk dictionary. |
1225 |
This is an internal interface for binary storage mechanism." |
|
620 | 1226 |
|
1227 |
| myName | |
|
1228 |
||
1229 |
myName := self name. |
|
1230 |
stream nextNumber:4 put:self signature. |
|
1231 |
stream nextNumber:2 put:0. |
|
1232 |
stream nextNumber:2 put:myName size. |
|
1233 |
myName do:[:c| |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1234 |
stream nextPut:c asciiValue |
620 | 1235 |
] |
1236 |
||
1237 |
" |
|
1238 |
|s| |
|
1239 |
s := WriteStream on:ByteArray new. |
|
1240 |
#(1 2 3 4) storeBinaryOn:s. |
|
1241 |
Object readBinaryFrom:(ReadStream on:s contents) |
|
1242 |
||
1243 |
|s| |
|
1244 |
s := WriteStream on:ByteArray new. |
|
1245 |
Rectangle storeBinaryOn:s. |
|
1246 |
Object readBinaryFrom:(ReadStream on:s contents) |
|
1247 |
" |
|
1259 | 1248 |
|
1249 |
"Modified: 23.4.1996 / 09:29:44 / cg" |
|
620 | 1250 |
! ! |
1251 |
||
1252 |
!Behavior methodsFor:'compiler interface'! |
|
1253 |
||
1328 | 1254 |
browserClass |
1255 |
"return the browser to use for this class - |
|
1256 |
this can be redefined in special classes, to get different browsers" |
|
1257 |
||
1258 |
^ SystemBrowser |
|
1259 |
||
1260 |
"Created: 3.5.1996 / 12:36:40 / cg" |
|
1261 |
! |
|
1262 |
||
620 | 1263 |
compiler |
1264 |
"return the compiler to use for this class. |
|
1265 |
OBSOLETE: This is the old ST/X interface, kept for migration. |
|
1266 |
Dont use it - it will vanish." |
|
1267 |
||
1268 |
^ self compilerClass |
|
1269 |
! |
|
1270 |
||
1271 |
compilerClass |
|
1272 |
"return the compiler to use for this class - |
|
1273 |
this can be redefined in special classes, to get classes with |
|
1274 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1275 |
||
1276 |
^ Compiler |
|
1277 |
! |
|
1278 |
||
1279 |
evaluatorClass |
|
1280 |
"return the compiler to use for expression evaluation for this class - |
|
1281 |
this can be redefined in special classes, to get classes with |
|
1282 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1283 |
||
1284 |
^ Compiler |
|
1285 |
! ! |
|
1286 |
||
1287 |
!Behavior methodsFor:'copying'! |
|
1288 |
||
1289 |
deepCopy |
|
1290 |
"return a deep copy of the receiver |
|
1291 |
- return the receiver here - time will show if this is ok" |
|
1292 |
||
1293 |
^ self |
|
1294 |
! |
|
1295 |
||
1296 |
deepCopyUsing:aDictionary |
|
1297 |
"return a deep copy of the receiver |
|
1298 |
- return the receiver here - time will show if this is ok" |
|
1299 |
||
1300 |
^ self |
|
1301 |
! |
|
1302 |
||
1303 |
simpleDeepCopy |
|
1304 |
"return a deep copy of the receiver |
|
1305 |
- return the receiver here - time will show if this is ok" |
|
1306 |
||
1307 |
^ self |
|
1308 |
! ! |
|
1309 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1310 |
!Behavior methodsFor:'dummy changes management'! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1311 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1312 |
addChangeRecordForClassRemove:aClassName |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1313 |
"add a change record that some class has been removed. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1314 |
Defined as dummy here, since Behavior does not know about change management. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1315 |
(only Classes do). This allows different Behavior-like objects |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1316 |
(alien classes) to be handled by the browser as well." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1317 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1318 |
"Created: 16.4.1996 / 16:30:09 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1319 |
"Modified: 16.4.1996 / 18:10:35 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1320 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1321 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1322 |
!Behavior methodsFor:'dummy fileOut'! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1323 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1324 |
fileOutDefinitionOn:aStream |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1325 |
"dummy fileOut defined here. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1326 |
This allows different Behavior-like objects |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1327 |
(alien classes) to be handled by the browser as well." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1328 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1329 |
^ self |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1330 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1331 |
"Created: 16.4.1996 / 16:28:01 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1332 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1333 |
|
620 | 1334 |
!Behavior methodsFor:'enumerating'! |
1335 |
||
1336 |
allDerivedInstancesDo:aBlock |
|
1337 |
"evaluate aBlock for all of my instances and all instances of subclasses. |
|
1338 |
This method is going to be removed for protocol compatibility with |
|
1339 |
other STs; use allSubInstancesDo:" |
|
1340 |
||
1341 |
self obsoleteMethodWarning:'please use #allSubInstancesDo:'. |
|
1342 |
self allSubInstancesDo:aBlock |
|
1343 |
||
1344 |
" |
|
1422 | 1345 |
StandardSystemView allDerivedInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1346 |
" |
1347 |
! |
|
1348 |
||
1349 |
allInstancesDo:aBlock |
|
1350 |
"evaluate aBlock for all of my instances" |
|
1351 |
||
1352 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
1353 |
"/ (anObject class == self) ifTrue:[ |
|
1354 |
"/ aBlock value:anObject |
|
1355 |
"/ ] |
|
1356 |
"/ ] |
|
1357 |
||
1358 |
ObjectMemory allInstancesOf:self do:[:anObject | |
|
1359 |
aBlock value:anObject |
|
1360 |
] |
|
1361 |
||
1362 |
" |
|
1422 | 1363 |
StandardSystemView allInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1364 |
" |
1365 |
! |
|
1366 |
||
1367 |
allSubInstancesDo:aBlock |
|
1368 |
"evaluate aBlock for all of my instances and all instances of subclasses" |
|
1369 |
||
1370 |
ObjectMemory allObjectsDo:[:anObject | |
|
1371 |
(anObject isKindOf:self) ifTrue:[ |
|
1372 |
aBlock value:anObject |
|
1373 |
] |
|
1374 |
] |
|
1375 |
||
1376 |
" |
|
1422 | 1377 |
StandardSystemView allSubInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1378 |
" |
1379 |
! |
|
1380 |
||
1381 |
allSubclassesDo:aBlock |
|
1382 |
"evaluate aBlock for all of my subclasses. |
|
1383 |
There is no specific order, in which the entries are enumerated. |
|
1384 |
This will only enumerate globally known classes - for anonymous |
|
1385 |
behaviors, you have to walk over all instances of Behavior." |
|
1386 |
||
1387 |
Smalltalk allBehaviorsDo:[:aClass | |
|
1388 |
(aClass isSubclassOf:self) ifTrue:[ |
|
1389 |
aBlock value:aClass |
|
1390 |
] |
|
1391 |
] |
|
1392 |
||
1393 |
" |
|
1422 | 1394 |
Collection allSubclassesDo:[:c | Transcript showCR:(c name)] |
620 | 1395 |
" |
1396 |
! |
|
1397 |
||
1398 |
allSubclassesInOrderDo:aBlock |
|
1399 |
"evaluate aBlock for all of my subclasses. |
|
1400 |
Higher level subclasses will be enumerated before the deeper ones, |
|
1401 |
so the order in which aBlock gets called is ok to fileOut classes in |
|
1402 |
correct order for later fileIn. |
|
1403 |
This will only enumerate globally known classes - for anonymous |
|
1404 |
behaviors, you have to walk over all instances of Behavior" |
|
1405 |
||
1406 |
self subclassesDo:[:aClass | |
|
1407 |
aBlock value:aClass. |
|
1408 |
aClass allSubclassesInOrderDo:aBlock |
|
1409 |
] |
|
1410 |
||
1411 |
" |
|
1422 | 1412 |
Collection allSubclassesInOrderDo:[:c | Transcript showCR:(c name)] |
620 | 1413 |
" |
1414 |
! |
|
1415 |
||
1416 |
allSuperclassesDo:aBlock |
|
1417 |
"evaluate aBlock for all of my superclasses" |
|
1418 |
||
1419 |
|theClass| |
|
1420 |
||
1421 |
theClass := superclass. |
|
1422 |
[theClass notNil] whileTrue:[ |
|
1423 |
aBlock value:theClass. |
|
1424 |
theClass := theClass superclass |
|
1425 |
] |
|
1426 |
||
1427 |
" |
|
1422 | 1428 |
String allSuperclassesDo:[:c | Transcript showCR:(c name)] |
620 | 1429 |
" |
1430 |
! |
|
1431 |
||
1432 |
subclassesDo:aBlock |
|
1433 |
"evaluate the argument, aBlock for all immediate subclasses. |
|
1434 |
This will only enumerate globally known classes - for anonymous |
|
1435 |
behaviors, you have to walk over all instances of Behavior." |
|
1436 |
||
1437 |
|coll| |
|
1438 |
||
2224 | 1439 |
"/ use cached information (avoid class hierarchy search) |
1440 |
"/ if possible |
|
1441 |
||
620 | 1442 |
SubclassInfo isNil ifTrue:[ |
2224 | 1443 |
Behavior subclassInfo |
620 | 1444 |
]. |
1445 |
SubclassInfo notNil ifTrue:[ |
|
2224 | 1446 |
coll := SubclassInfo at:self ifAbsent:nil. |
1447 |
coll notNil ifTrue:[ |
|
1448 |
coll do:aBlock. |
|
1449 |
]. |
|
1450 |
^ self |
|
620 | 1451 |
]. |
1452 |
||
1453 |
Smalltalk allBehaviorsDo:[:aClass | |
|
2224 | 1454 |
(aClass superclass == self) ifTrue:[ |
1455 |
aBlock value:aClass |
|
1456 |
] |
|
620 | 1457 |
] |
1458 |
||
1459 |
" |
|
1422 | 1460 |
Collection subclassesDo:[:c | Transcript showCR:(c name)] |
308 | 1461 |
" |
2224 | 1462 |
|
1463 |
"Modified: 22.1.1997 / 18:44:01 / cg" |
|
308 | 1464 |
! ! |
1465 |
||
1 | 1466 |
!Behavior methodsFor:'initialization'! |
1467 |
||
620 | 1468 |
deinitialize |
1469 |
"deinitialize is sent to a class before it is physically unloaded. |
|
1470 |
This is only done with classes which have been loaded in from a binary |
|
1471 |
file. Classes may release any primitive memory or other stuff which is |
|
1472 |
not visible to smalltalk (for example, release internal memory). |
|
1473 |
The default action here is to do nothing." |
|
1474 |
||
1475 |
^ self |
|
1476 |
! |
|
1477 |
||
1 | 1478 |
initialize |
442 | 1479 |
"initialize is sent to a class either during startup, |
1480 |
(for all statically compiled-in classes) or after a class |
|
1481 |
has been loaded into the system (either bytecodes or machinecode). |
|
1482 |
The default action here is to do nothing." |
|
1 | 1483 |
|
1484 |
^ self |
|
1485 |
! |
|
1486 |
||
328 | 1487 |
postAutoload |
442 | 1488 |
"postAutoload is sent to a class after it has been autoloaded. |
1489 |
This gives it a chance to arrange for automatic unloading to be done |
|
1490 |
after a while ... |
|
1491 |
This is NOT sent to statically compiled in or explicitely filedIn |
|
1492 |
classes. |
|
1493 |
The default action here is to do nothing." |
|
328 | 1494 |
|
1495 |
^ self |
|
1496 |
! |
|
1497 |
||
1 | 1498 |
reinitialize |
442 | 1499 |
"reinitialize is sent to a class when an image has been restarted. |
1500 |
I.e. when the system is restarted. |
|
1501 |
This gives classes a chance to flush any device dependent or otherwise |
|
1502 |
obsolete data which may be a leftover from the previous live. |
|
1503 |
The default action here is to do nothing." |
|
1504 |
||
1505 |
^ self |
|
11 | 1506 |
! ! |
1507 |
||
492
fa23b14f444b
renamed instance creation category
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
1508 |
!Behavior methodsFor:'instance creation'! |
1 | 1509 |
|
1510 |
basicNew |
|
54 | 1511 |
"return an instance of myself without indexed variables. |
1 | 1512 |
If the receiver-class has indexed instvars, the new object will have |
91 | 1513 |
a basicSize of zero - |
1514 |
i.e. 'aClass basicNew' is equivalent to 'aClass basicNew:0'. |
|
54 | 1515 |
|
1 | 1516 |
** Do not redefine this method in any class **" |
1517 |
||
1518 |
%{ /* NOCONTEXT */ |
|
81 | 1519 |
REGISTER OBJ newobj; |
1520 |
REGISTER char *nextPtr; |
|
91 | 1521 |
unsigned int instsize; |
1522 |
REGISTER unsigned int nInstVars; |
|
1 | 1523 |
|
54 | 1524 |
/* |
369 | 1525 |
* the following ugly code is nothing more than a __new() followed |
54 | 1526 |
* by a nilling of the new instance. |
91 | 1527 |
* Unrolled for a bit more speed since this is one of the central object |
1528 |
* allocation methods in the system |
|
54 | 1529 |
*/ |
1133 | 1530 |
nInstVars = __intVal(__INST(instSize)); |
92 | 1531 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
54 | 1532 |
|
983 | 1533 |
newobj = (OBJ) __newNextPtr; |
81 | 1534 |
nextPtr = ((char *)newobj) + instsize; |
1535 |
||
1536 |
/* |
|
1537 |
* dont argue about the goto and the arrangement below - it saves |
|
1538 |
* an extra nil-compare and branch in the common case ... |
|
91 | 1539 |
* (i.e. if no GC is needed, we fall through without a branch) |
81 | 1540 |
*/ |
983 | 1541 |
if (nextPtr < __newEndPtr) { |
154 | 1542 |
_objPtr(newobj)->o_size = instsize; |
1543 |
/* o_allFlags(newobj) = 0; */ |
|
983 | 1544 |
/* _objPtr(newobj)->o_space = __newSpace; */ |
1545 |
o_setAllFlags(newobj, __newSpace); |
|
91 | 1546 |
#ifdef ALIGN4 |
983 | 1547 |
__newNextPtr = nextPtr; |
91 | 1548 |
#else |
154 | 1549 |
if (instsize & (ALIGN-1)) { |
983 | 1550 |
__newNextPtr = (char *)newobj + (instsize & ~(ALIGN-1)) + ALIGN; |
154 | 1551 |
} else { |
983 | 1552 |
__newNextPtr = nextPtr; |
154 | 1553 |
} |
91 | 1554 |
#endif |
82 | 1555 |
|
1556 |
ok: |
|
1133 | 1557 |
__InstPtr(newobj)->o_class = self; |
369 | 1558 |
__qSTORE(newobj, self); |
82 | 1559 |
|
154 | 1560 |
if (nInstVars) { |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1561 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 1562 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
82 | 1563 |
#else |
154 | 1564 |
REGISTER OBJ *op; |
82 | 1565 |
|
1133 | 1566 |
op = __InstPtr(newobj)->i_instvars; |
82 | 1567 |
|
91 | 1568 |
# if !defined(NEGATIVE_ADDRESSES) |
154 | 1569 |
/* |
1570 |
* knowing that nil is 0 |
|
1571 |
*/ |
|
91 | 1572 |
# if defined(FAST_OBJECT_MEMSET_DOUBLES_UNROLLED) |
154 | 1573 |
if (nInstVars > 8) { |
1574 |
*op++ = nil; /* for alignment */ |
|
1575 |
nInstVars--; |
|
1576 |
while (nInstVars >= 8) { |
|
1577 |
*(double *)op = 0.0; |
|
1578 |
((double *)op)[1] = 0.0; |
|
1579 |
((double *)op)[2] = 0.0; |
|
1580 |
((double *)op)[3] = 0.0; |
|
1581 |
op += 8; |
|
1582 |
nInstVars -= 8; |
|
1583 |
} |
|
1584 |
} |
|
1585 |
while (nInstVars != 0) { |
|
1586 |
*op++ = 0; |
|
1587 |
nInstVars--; |
|
1588 |
} |
|
82 | 1589 |
# else |
91 | 1590 |
# if defined(FAST_OBJECT_MEMSET_LONGLONG_UNROLLED) |
154 | 1591 |
if (nInstVars > 8) { |
1592 |
*op++ = nil; /* for alignment */ |
|
1593 |
nInstVars--; |
|
1594 |
while (nInstVars >= 8) { |
|
1595 |
*(long long *)op = 0; |
|
1596 |
((long long *)op)[1] = 0; |
|
1597 |
((long long *)op)[2] = 0; |
|
1598 |
((long long *)op)[3] = 0; |
|
1599 |
op += 8; |
|
1600 |
nInstVars -= 8; |
|
1601 |
} |
|
1602 |
} |
|
1603 |
while (nInstVars != 0) { |
|
1604 |
*op++ = 0; |
|
1605 |
nInstVars--; |
|
1606 |
} |
|
91 | 1607 |
|
1608 |
# else |
|
1609 |
# if defined(FAST_OBJECT_MEMSET_WORDS_UNROLLED) |
|
154 | 1610 |
while (nInstVars >= 8) { |
1611 |
*op = nil; |
|
1612 |
*(op+1) = nil; |
|
1613 |
*(op+2) = nil; |
|
1614 |
*(op+3) = nil; |
|
1615 |
*(op+4) = nil; |
|
1616 |
*(op+5) = nil; |
|
1617 |
*(op+6) = nil; |
|
1618 |
*(op+7) = nil; |
|
1619 |
op += 8; |
|
1620 |
nInstVars -= 8; |
|
1621 |
} |
|
1622 |
while (nInstVars != 0) { |
|
1623 |
*op++ = nil; |
|
1624 |
nInstVars--; |
|
1625 |
} |
|
91 | 1626 |
# else |
1627 |
# if defined(FAST_MEMSET) |
|
1133 | 1628 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
91 | 1629 |
# else |
154 | 1630 |
do { |
1631 |
*op++ = nil; |
|
1632 |
nInstVars--; |
|
1633 |
} while (nInstVars != 0); |
|
91 | 1634 |
# endif |
82 | 1635 |
# endif |
1636 |
# endif |
|
1637 |
# endif |
|
1638 |
# else /* nil could be ~~ 0 */ |
|
154 | 1639 |
while (nInstVars >= 8) { |
1640 |
*op = nil; |
|
1641 |
*(op+1) = nil; |
|
1642 |
*(op+2) = nil; |
|
1643 |
*(op+3) = nil; |
|
1644 |
*(op+4) = nil; |
|
1645 |
*(op+5) = nil; |
|
1646 |
*(op+6) = nil; |
|
1647 |
*(op+7) = nil; |
|
1648 |
op += 8; |
|
1649 |
nInstVars -= 8; |
|
1650 |
} |
|
1651 |
while (nInstVars != 0) { |
|
1652 |
*op++ = nil; |
|
1653 |
nInstVars--; |
|
1654 |
} |
|
82 | 1655 |
# endif |
1656 |
#endif |
|
154 | 1657 |
} |
1658 |
RETURN ( newobj ); |
|
81 | 1659 |
} |
54 | 1660 |
|
92 | 1661 |
/* |
1662 |
* the slow case - a GC will occur |
|
1663 |
*/ |
|
834 | 1664 |
__PROTECT_CONTEXT__ |
369 | 1665 |
newobj = __new(instsize); |
834 | 1666 |
__UNPROTECT_CONTEXT__ |
82 | 1667 |
if (newobj != nil) goto ok; |
1 | 1668 |
%} |
2 | 1669 |
. |
68 | 1670 |
" |
1671 |
memory allocation failed. |
|
1672 |
When we arrive here, there was no memory, even after |
|
165 | 1673 |
a garbage collect. |
1674 |
This means, that the VM wanted to get some more memory from the |
|
1675 |
Operatingsystem, which was not kind enough to give it. |
|
1676 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 1677 |
" |
127 | 1678 |
^ ObjectMemory allocationFailureSignal raise. |
1 | 1679 |
! |
1680 |
||
1681 |
basicNew:anInteger |
|
1682 |
"return an instance of myself with anInteger indexed variables. |
|
1683 |
If the receiver-class has no indexed instvars, this is only allowed |
|
1684 |
if the argument, anInteger is zero. |
|
1685 |
** Do not redefine this method in any class **" |
|
1686 |
||
1687 |
%{ /* NOCONTEXT */ |
|
1688 |
||
1689 |
OBJ newobj; |
|
154 | 1690 |
unsigned INT instsize, nInstVars; |
1691 |
INT nindexedinstvars; |
|
92 | 1692 |
unsigned INT flags; |
1693 |
#if ! defined(FAST_ARRAY_MEMSET) || defined(NEGATIVE_ADDRESSES) |
|
1 | 1694 |
REGISTER char *cp; |
1695 |
short *sp; |
|
1696 |
long *lp; |
|
1697 |
#endif |
|
1698 |
REGISTER OBJ *op; |
|
1699 |
float *fp; |
|
1700 |
double *dp; |
|
1701 |
||
249 | 1702 |
if (__isSmallInteger(anInteger)) { |
1133 | 1703 |
nindexedinstvars = __intVal(anInteger); |
154 | 1704 |
if (nindexedinstvars >= 0) { |
1133 | 1705 |
nInstVars = __intVal(__INST(instSize)); |
1706 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
|
154 | 1707 |
switch (flags) { |
1708 |
case BYTEARRAY: |
|
1709 |
instsize = OHDR_SIZE + nindexedinstvars; |
|
1710 |
if (nInstVars == 0) { |
|
835 | 1711 |
if (__CanDoQuickNew(instsize)) { |
154 | 1712 |
/* |
1713 |
* the most common case |
|
1714 |
*/ |
|
835 | 1715 |
__qCheckedNew(newobj, instsize); |
1133 | 1716 |
__InstPtr(newobj)->o_class = self; |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1717 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
359 | 1718 |
nInstVars = nindexedinstvars >> 2; |
1719 |
if (nindexedinstvars & 3) nInstVars++; |
|
1133 | 1720 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
357 | 1721 |
#else |
1722 |
# if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
|
1133 | 1723 |
memset(__InstPtr(newobj)->i_instvars, 0, nindexedinstvars); |
357 | 1724 |
# else |
1133 | 1725 |
cp = (char *)__InstPtr(newobj)->i_instvars; |
154 | 1726 |
while (nindexedinstvars >= sizeof(long)) { |
1727 |
*(long *)cp = 0; |
|
1728 |
cp += sizeof(long); |
|
1729 |
nindexedinstvars -= sizeof(long); |
|
1730 |
} |
|
1731 |
while (nindexedinstvars--) |
|
1732 |
*cp++ = '\0'; |
|
357 | 1733 |
# endif |
92 | 1734 |
#endif |
154 | 1735 |
RETURN ( newobj ); |
1736 |
} |
|
1737 |
} else { |
|
1738 |
instsize += __OBJS2BYTES__(nInstVars); |
|
1739 |
} |
|
834 | 1740 |
__PROTECT_CONTEXT__ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1741 |
__qNew(newobj, instsize); |
834 | 1742 |
__UNPROTECT_CONTEXT__ |
154 | 1743 |
if (newobj == nil) { |
1744 |
break; |
|
1745 |
} |
|
1133 | 1746 |
__InstPtr(newobj)->o_class = self; |
369 | 1747 |
__qSTORE(newobj, self); |
1748 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1749 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
357 | 1750 |
nInstVars = (instsize-OHDR_SIZE) >> 2; |
1751 |
if (instsize & 3) nInstVars++; |
|
1133 | 1752 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
357 | 1753 |
#else |
1754 |
# if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
|
154 | 1755 |
/* |
1756 |
* knowing that nil is 0 |
|
1757 |
*/ |
|
1133 | 1758 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
357 | 1759 |
# else |
1133 | 1760 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1761 |
while (nInstVars--) |
1762 |
*op++ = nil; |
|
1763 |
cp = (char *)op; |
|
1764 |
while (nindexedinstvars >= sizeof(long)) { |
|
1765 |
*(long *)cp = 0; |
|
1766 |
cp += sizeof(long); |
|
1767 |
nindexedinstvars -= sizeof(long); |
|
1768 |
} |
|
1769 |
while (nindexedinstvars--) |
|
1770 |
*cp++ = '\0'; |
|
357 | 1771 |
# endif |
1 | 1772 |
#endif |
154 | 1773 |
RETURN ( newobj ); |
1774 |
break; |
|
1 | 1775 |
|
154 | 1776 |
case WORDARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
1777 |
case SWORDARRAY: |
154 | 1778 |
instsize = OHDR_SIZE + |
1779 |
__OBJS2BYTES__(nInstVars) + |
|
1780 |
nindexedinstvars * sizeof(short); |
|
834 | 1781 |
__PROTECT_CONTEXT__ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1782 |
__qNew(newobj, instsize); |
834 | 1783 |
__UNPROTECT_CONTEXT__ |
154 | 1784 |
if (newobj == nil) { |
1785 |
break; |
|
1786 |
} |
|
1133 | 1787 |
__InstPtr(newobj)->o_class = self; |
369 | 1788 |
__qSTORE(newobj, self); |
1789 |
||
92 | 1790 |
#if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
154 | 1791 |
/* |
1792 |
* knowing that nil is 0 |
|
1793 |
*/ |
|
1133 | 1794 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 1795 |
#else |
1133 | 1796 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1797 |
while (nInstVars--) |
1798 |
*op++ = nil; |
|
1799 |
sp = (short *)op; |
|
1800 |
while (nindexedinstvars--) |
|
1801 |
*sp++ = 0; |
|
1 | 1802 |
#endif |
154 | 1803 |
RETURN ( newobj ); |
1804 |
break; |
|
1 | 1805 |
|
154 | 1806 |
case LONGARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
1807 |
case SLONGARRAY: |
154 | 1808 |
instsize = OHDR_SIZE + |
1809 |
__OBJS2BYTES__(nInstVars) + |
|
1810 |
nindexedinstvars * sizeof(long); |
|
834 | 1811 |
__PROTECT_CONTEXT__ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1812 |
__qAlignedNew(newobj, instsize); |
834 | 1813 |
__UNPROTECT_CONTEXT__ |
154 | 1814 |
if (newobj == nil) { |
1815 |
break; |
|
1816 |
} |
|
1133 | 1817 |
__InstPtr(newobj)->o_class = self; |
369 | 1818 |
__qSTORE(newobj, self); |
1819 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1820 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
154 | 1821 |
/* |
1822 |
* knowing that nil is 0 |
|
1823 |
*/ |
|
1133 | 1824 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars + nindexedinstvars); |
1 | 1825 |
#else |
92 | 1826 |
# if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
154 | 1827 |
/* |
1828 |
* knowing that nil is 0 |
|
1829 |
*/ |
|
1133 | 1830 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 1831 |
# else |
1133 | 1832 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1833 |
while (nInstVars--) |
1834 |
*op++ = nil; |
|
1835 |
lp = (long *)op; |
|
1836 |
while (nindexedinstvars--) |
|
1837 |
*lp++ = 0; |
|
1 | 1838 |
# endif |
1839 |
#endif |
|
154 | 1840 |
RETURN ( newobj ); |
1841 |
break; |
|
1 | 1842 |
|
154 | 1843 |
case FLOATARRAY: |
325 | 1844 |
instsize = sizeof(struct __floatArray) + |
154 | 1845 |
__OBJS2BYTES__(nInstVars) + |
1846 |
(nindexedinstvars - 1) * sizeof(float); |
|
54 | 1847 |
|
834 | 1848 |
__PROTECT_CONTEXT__ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1849 |
__qNew(newobj, instsize); |
834 | 1850 |
__UNPROTECT_CONTEXT__ |
154 | 1851 |
if (newobj == nil) { |
1852 |
break; |
|
1853 |
} |
|
1133 | 1854 |
__InstPtr(newobj)->o_class = self; |
369 | 1855 |
__qSTORE(newobj, self); |
1856 |
||
1133 | 1857 |
op = __InstPtr(newobj)->i_instvars; |
92 | 1858 |
# if defined(mips) /* knowin that float 0.0 is all-zeros */ |
1133 | 1859 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
92 | 1860 |
# else |
154 | 1861 |
while (nInstVars--) |
1862 |
*op++ = nil; |
|
1863 |
fp = (float *)op; |
|
1864 |
while (nindexedinstvars--) |
|
1865 |
*fp++ = 0.0; |
|
92 | 1866 |
# endif |
154 | 1867 |
RETURN ( newobj ); |
1868 |
break; |
|
1 | 1869 |
|
154 | 1870 |
case DOUBLEARRAY: |
325 | 1871 |
instsize = sizeof(struct __doubleArray) + |
154 | 1872 |
__OBJS2BYTES__(nInstVars) + |
1873 |
(nindexedinstvars - 1) * sizeof(double); |
|
54 | 1874 |
|
834 | 1875 |
__PROTECT_CONTEXT__ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1876 |
__qAlignedNew(newobj, instsize); |
834 | 1877 |
__UNPROTECT_CONTEXT__ |
154 | 1878 |
if (newobj == nil) { |
1879 |
break; |
|
1880 |
} |
|
1133 | 1881 |
__InstPtr(newobj)->o_class = self; |
369 | 1882 |
__qSTORE(newobj, self); |
1883 |
||
1133 | 1884 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1885 |
while (nInstVars--) |
1886 |
*op++ = nil; |
|
54 | 1887 |
#ifdef NEED_DOUBLE_ALIGN |
154 | 1888 |
/* |
1889 |
* care for double alignment |
|
1890 |
*/ |
|
1891 |
if ((INT)op & (ALIGN-1)) { |
|
1892 |
*op++ = nil; |
|
1893 |
} |
|
54 | 1894 |
#endif |
154 | 1895 |
dp = (double *)op; |
1896 |
while (nindexedinstvars--) |
|
1897 |
*dp++ = 0.0; |
|
1898 |
RETURN ( newobj ); |
|
1899 |
break; |
|
1 | 1900 |
|
154 | 1901 |
case WKPOINTERARRAY: |
1902 |
case POINTERARRAY: |
|
1903 |
nInstVars += nindexedinstvars; |
|
1904 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
834 | 1905 |
__PROTECT_CONTEXT__ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1906 |
__qAlignedNew(newobj, instsize); |
834 | 1907 |
__UNPROTECT_CONTEXT__ |
154 | 1908 |
if (newobj == nil) { |
1909 |
break; |
|
1910 |
} |
|
1133 | 1911 |
__InstPtr(newobj)->o_class = self; |
369 | 1912 |
__qSTORE(newobj, self); |
1913 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1914 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 1915 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 1916 |
#else |
82 | 1917 |
# if !defined(NEGATIVE_ADDRESSES) |
154 | 1918 |
/* |
1919 |
* knowing that nil is 0 |
|
1920 |
*/ |
|
360 | 1921 |
#ifdef XXmips |
92 | 1922 |
# undef FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
1923 |
# undef FAST_ARRAY_MEMSET_LONGLONG_UNROLLED |
|
198 | 1924 |
/* seems to be slightly faster */ |
92 | 1925 |
# define FAST_ARRAY_MEMSET |
1926 |
#endif |
|
1927 |
#ifdef sparc |
|
1928 |
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
|
1929 |
#endif |
|
1930 |
||
91 | 1931 |
# if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED) |
1133 | 1932 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1933 |
if (nInstVars > 8) { |
1934 |
*op++ = nil; /* for alignment */ |
|
1935 |
nInstVars--; |
|
1936 |
while (nInstVars >= 8) { |
|
1937 |
*(double *)op = 0.0; |
|
1938 |
((double *)op)[1] = 0.0; |
|
1939 |
((double *)op)[2] = 0.0; |
|
1940 |
((double *)op)[3] = 0.0; |
|
1941 |
op += 8; |
|
1942 |
nInstVars -= 8; |
|
1943 |
} |
|
1944 |
} |
|
1945 |
while (nInstVars) { |
|
1946 |
*op++ = 0; |
|
1947 |
nInstVars--; |
|
1948 |
} |
|
82 | 1949 |
# else |
91 | 1950 |
# if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED) |
1133 | 1951 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1952 |
if (nInstVars > 8) { |
1953 |
*op++ = nil; /* for alignment */ |
|
1954 |
nInstVars--; |
|
1955 |
while (nInstVars >= 8) { |
|
1956 |
*(long long *)op = 0; |
|
1957 |
((long long *)op)[1] = 0; |
|
1958 |
((long long *)op)[2] = 0; |
|
1959 |
((long long *)op)[3] = 0; |
|
1960 |
op += 8; |
|
1961 |
nInstVars -= 8; |
|
1962 |
} |
|
1963 |
} |
|
1964 |
while (nInstVars) { |
|
1965 |
*op++ = 0; |
|
1966 |
nInstVars--; |
|
1967 |
} |
|
91 | 1968 |
# else |
1969 |
# if defined(FAST_ARRAY_MEMSET) |
|
1133 | 1970 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
91 | 1971 |
# else |
1133 | 1972 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1973 |
while (nInstVars--) |
1974 |
*op++ = nil; |
|
91 | 1975 |
# endif |
82 | 1976 |
# endif |
1977 |
# endif |
|
1978 |
# else |
|
1133 | 1979 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1980 |
while (nInstVars--) |
1981 |
*op++ = nil; |
|
1 | 1982 |
# endif |
1983 |
#endif |
|
154 | 1984 |
RETURN ( newobj ); |
1985 |
break; |
|
1 | 1986 |
|
154 | 1987 |
default: |
1988 |
/* |
|
1989 |
* new:n for non-variable classes only allowed if |
|
1990 |
* n == 0 |
|
1991 |
*/ |
|
1992 |
if (nindexedinstvars == 0) { |
|
1993 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
834 | 1994 |
__PROTECT_CONTEXT__ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1995 |
__qAlignedNew(newobj, instsize); |
834 | 1996 |
__UNPROTECT_CONTEXT__ |
154 | 1997 |
if (newobj == nil) { |
1998 |
break; |
|
1999 |
} |
|
1133 | 2000 |
__InstPtr(newobj)->o_class = self; |
369 | 2001 |
__qSTORE(newobj, self); |
2002 |
||
154 | 2003 |
if (nInstVars) { |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2004 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 2005 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 2006 |
#else |
2007 |
# if defined(FAST_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
|
154 | 2008 |
/* |
2009 |
* knowing that nil is 0 |
|
2010 |
*/ |
|
1133 | 2011 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 2012 |
# else |
1133 | 2013 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2014 |
do { |
2015 |
*op++ = nil; |
|
2016 |
} while (--nInstVars); |
|
1 | 2017 |
# endif |
2018 |
#endif |
|
154 | 2019 |
} |
2020 |
RETURN ( newobj ); |
|
2021 |
} |
|
2022 |
break; |
|
2023 |
} |
|
2024 |
} |
|
1 | 2025 |
} |
68 | 2026 |
%}. |
2027 |
" |
|
2028 |
arrive here if something went wrong ... |
|
2029 |
figure out what it was |
|
2030 |
" |
|
11 | 2031 |
|
1 | 2032 |
(anInteger isMemberOf:SmallInteger) ifFalse:[ |
154 | 2033 |
" |
2034 |
the argument is either not an integer, |
|
2035 |
or a LargeInteger (which means that its definitely too big) |
|
2036 |
" |
|
2037 |
self error:'argument to new: must be Integer'. |
|
2038 |
^ nil |
|
68 | 2039 |
]. |
2040 |
(anInteger < 0) ifTrue:[ |
|
154 | 2041 |
" |
2042 |
the argument is negative, |
|
2043 |
" |
|
2044 |
self error:'bad (negative) argument to new:'. |
|
2045 |
^ nil |
|
68 | 2046 |
]. |
2047 |
self isVariable ifFalse:[ |
|
154 | 2048 |
" |
2049 |
this class does not have any indexed instance variables |
|
2050 |
" |
|
2051 |
self error:'class has no indexed instvars - cannot create with new:'. |
|
2052 |
^ nil |
|
68 | 2053 |
]. |
2054 |
" |
|
2055 |
memory allocation failed. |
|
2056 |
When we arrive here, there was no memory, even after |
|
165 | 2057 |
a garbage collect. |
2058 |
This means, that the VM wanted to get some more memory from the |
|
2059 |
Operatingsystem, which was not kind enough to give it. |
|
2060 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 2061 |
" |
127 | 2062 |
^ ObjectMemory allocationFailureSignal raise. |
11 | 2063 |
! |
2064 |
||
620 | 2065 |
new |
2066 |
"return an instance of myself without indexed variables" |
|
2067 |
||
2068 |
^ self basicNew |
|
2069 |
! |
|
2070 |
||
2071 |
new:anInteger |
|
2072 |
"return an instance of myself with anInteger indexed variables" |
|
2073 |
||
2074 |
^ self basicNew:anInteger |
|
2075 |
! |
|
2076 |
||
2077 |
niceBasicNew:anInteger |
|
2078 |
"same as basicNew:anInteger, but tries to avoid long pauses |
|
2079 |
due to garbage collection. This method checks to see if |
|
2080 |
allocation is possible without a pause, and does a background |
|
2081 |
incremental garbage collect first if there is not enough memory |
|
2082 |
available at the moment for fast allocation. |
|
2083 |
This is useful in low-priority background processes which like to |
|
2084 |
avoid disturbing any higher priority foreground process while allocating |
|
2085 |
big amounts of memory. Of course, using this method only makes |
|
2086 |
sense for big or huge objects (say > 200k). |
|
2087 |
||
2088 |
EXPERIMENTAL: this is a non-standard interface and should only |
|
2089 |
be used for special applications. There is no guarantee, that this |
|
2090 |
method will be available in future ST/X releases." |
|
2091 |
||
2092 |
|size| |
|
2093 |
||
2094 |
size := self sizeOfInst:anInteger. |
|
2095 |
(ObjectMemory checkForFastNew:size) ifFalse:[ |
|
2096 |
" |
|
2097 |
incrementally collect garbage |
|
2098 |
" |
|
2099 |
ObjectMemory incrementalGC. |
|
2100 |
]. |
|
2101 |
^ self basicNew:anInteger |
|
2102 |
! |
|
2103 |
||
11 | 2104 |
readFrom:aStream |
43 | 2105 |
"read an objects printed representation from the argument, aStream |
2106 |
and return it. |
|
154 | 2107 |
The read object must be a kind of myself if its not, an error is raised. |
11 | 2108 |
This is the reverse operation to 'storeOn:'. |
43 | 2109 |
|
68 | 2110 |
WARNING: storeOn: does not handle circular references and multiple |
198 | 2111 |
references to the same object. |
2112 |
Use #storeBinary:/readBinaryFrom: for this." |
|
11 | 2113 |
|
345 | 2114 |
^ self readFrom:aStream onError:[self error:'expected: ' , self name] |
11 | 2115 |
|
91 | 2116 |
" |
2117 |
|s| |
|
11 | 2118 |
s := WriteStream on:String new. |
2119 |
#(1 2 3 4) storeOn:s. |
|
2120 |
Object readFrom:(ReadStream on:s contents) |
|
2121 |
" |
|
2122 |
! |
|
2123 |
||
198 | 2124 |
readFrom:aStream onError:exceptionBlock |
2125 |
"read an objects printed representation from the argument, aStream |
|
2126 |
and return it (i.e. the stream should contain some representation of |
|
2127 |
the object which was created using #storeOn:). |
|
2128 |
The read object must be a kind of myself if its not, the value of |
|
2129 |
exceptionBlock is returned. |
|
2130 |
To get any object, use 'Object readFrom:...', |
|
2131 |
To get any number, use 'Number readFrom:...' and so on. |
|
2132 |
This is the reverse operation to 'storeOn:'. |
|
2133 |
||
2134 |
WARNING: storeOn: does not handle circular references and multiple |
|
2135 |
references to the same object. |
|
2136 |
Use #storeBinary:/readBinaryFrom: for this." |
|
2137 |
||
2138 |
|newObject| |
|
2139 |
||
340 | 2140 |
ErrorSignal handle:[:ex | |
2141 |
ex return |
|
2142 |
] do:[ |
|
345 | 2143 |
newObject := self evaluatorClass evaluate:aStream. |
340 | 2144 |
]. |
198 | 2145 |
(newObject isKindOf:self) ifFalse:[^ exceptionBlock value]. |
2146 |
^ newObject |
|
2147 |
||
2148 |
" |
|
2149 |
|s| |
|
2150 |
s := WriteStream on:String new. |
|
2151 |
#(1 2 3 4) storeOn:s. |
|
1422 | 2152 |
Transcript showCR:( |
293 | 2153 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
2154 |
) |
|
198 | 2155 |
" |
2156 |
" |
|
2157 |
|s| |
|
2158 |
s := WriteStream on:String new. |
|
2159 |
#[1 2 3 4] storeOn:s. |
|
1422 | 2160 |
Transcript showCR:( |
293 | 2161 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
345 | 2162 |
) |
198 | 2163 |
" |
2164 |
! |
|
2165 |
||
11 | 2166 |
readFromString:aString |
275 | 2167 |
"create an object from its printed representation. |
2168 |
For most classes, the string is expected to be in a format created by |
|
2169 |
storeOn: or storeString; however, some (Time, Date) expect a user |
|
2170 |
readable string here. |
|
2171 |
See comments in Behavior>>readFromString:onError:, |
|
2172 |
Behavior>>readFrom: and Behavior>>readFrom:onError:" |
|
11 | 2173 |
|
345 | 2174 |
^ self readFromString:aString onError:[self error:'expected: ' , self name] |
91 | 2175 |
|
2176 |
" |
|
2177 |
Integer readFromString:'12345678901234567890' |
|
2178 |
Point readFromString:'1@2' |
|
345 | 2179 |
Point readFromString:'1' |
91 | 2180 |
" |
198 | 2181 |
! |
2182 |
||
2183 |
readFromString:aString onError:exceptionBlock |
|
275 | 2184 |
"create an object from its printed representation. |
2185 |
Here, the string is expected to be in a format created by |
|
2186 |
storeOn: or storeString; however, some classes (Time, Date) may redefine |
|
2187 |
it to expect a user readable string here. |
|
198 | 2188 |
See comments in Behavior>>readFrom: and Behavior>>readFrom:onError:" |
2189 |
||
2190 |
^ self readFrom:(ReadStream on:aString) onError:exceptionBlock |
|
2191 |
||
2192 |
" |
|
2193 |
Integer readFromString:'12345678901234567890' |
|
275 | 2194 |
Integer readFromString:'abc' |
2195 |
Integer readFromString:'abc' onError:0 |
|
198 | 2196 |
Point readFromString:'1@2' |
345 | 2197 |
Point readFromString:'0' |
275 | 2198 |
Point readFromString:'0' onError:[0@0] |
198 | 2199 |
" |
620 | 2200 |
! |
2201 |
||
2202 |
uninitializedNew |
|
2203 |
"create an instance of myself with uninitialized contents. |
|
2204 |
For all classes except ByteArray, this is the same as #basicNew." |
|
2205 |
||
2206 |
^ self basicNew |
|
2207 |
! |
|
2208 |
||
2209 |
uninitializedNew:anInteger |
|
2210 |
"create an instance of myself with uninitialized contents. |
|
2211 |
For all classes except ByteArray, this is the same as #basicNew:." |
|
2212 |
||
2213 |
^ self basicNew:anInteger |
|
1 | 2214 |
! ! |
2215 |
||
620 | 2216 |
!Behavior methodsFor:'private accessing'! |
2217 |
||
2218 |
flags:aNumber |
|
2219 |
"set the flags. |
|
2220 |
this method is for special uses only - there will be no recompilation |
|
2221 |
and no change record written here; |
|
2222 |
Do NOT use it." |
|
2223 |
||
2224 |
flags := aNumber |
|
2225 |
! |
|
2226 |
||
2227 |
instSize:aNumber |
|
2228 |
"set the instance size. |
|
2229 |
this method is for special uses only - there will be no recompilation |
|
2230 |
and no change record written here; |
|
2231 |
Do NOT use it." |
|
2232 |
||
2233 |
instSize := aNumber |
|
2234 |
! |
|
2235 |
||
2236 |
primAddSelector:newSelector withMethod:newMethod |
|
2237 |
"add the method given by 2nd argument under the selector given by |
|
2238 |
the 1st argument to the methodDictionary. |
|
2239 |
Does NOT flush any caches, does NOT write a change record. |
|
2240 |
||
2241 |
Do not use this in normal situations, strange behavior will be |
|
2242 |
the consequence. |
|
2243 |
I.e. executing obsolete methods, since the old method will still |
|
2244 |
be executed out of the caches." |
|
2245 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2246 |
|dict| |
620 | 2247 |
|
2248 |
(newSelector isMemberOf:Symbol) ifFalse:[ |
|
2249 |
self error:'invalid selector'. |
|
2250 |
^ false |
|
2251 |
]. |
|
2252 |
newMethod isNil ifTrue:[ |
|
2253 |
self error:'invalid method'. |
|
2254 |
^ false |
|
2255 |
]. |
|
2256 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2257 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2258 |
self setMethodDictionary:(dict at:newSelector putOrAppend:newMethod). |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2259 |
^ true. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2260 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2261 |
"Modified: 7.6.1996 / 14:48:45 / stefan" |
620 | 2262 |
! |
2263 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2264 |
setMethodDictionary:dict |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2265 |
"set the receivers method dictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2266 |
Convert dict to a MethodDictionary if necessary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2267 |
Do not flush inline caches, therefore old cached methods may be executed |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2268 |
after this call" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2269 |
|
2228 | 2270 |
"/ since the only thing the VM is prepared to deal with are |
2271 |
"/ proper methodDictionaries (it cannot do another message send, to |
|
2272 |
"/ find any methods ...), we convert it here if required. |
|
2273 |
"/ No other classes instances are allowed. |
|
2274 |
||
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2275 |
dict class ~~ MethodDictionary ifTrue:[ |
2228 | 2276 |
methodDictionary := MethodDictionary withAll:dict. |
2277 |
methodDictionary isNil ifTrue:[ |
|
2278 |
||
2279 |
"/ refuse to do this |
|
2280 |
"/ (can only happen in case of memory allocation trouble, |
|
2281 |
"/ where the allocation failed and some exception handler returned |
|
2282 |
"/ nil ...) |
|
2283 |
||
2284 |
self halt:'cannot set methodDictionary to nil'. |
|
2285 |
^ self. |
|
2286 |
] |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2287 |
] ifFalse:[ |
2228 | 2288 |
methodDictionary := dict. |
620 | 2289 |
]. |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2290 |
^ self. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2291 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2292 |
"Created: 5.6.1996 / 11:29:36 / stefan" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2293 |
"Modified: 12.6.1996 / 13:58:55 / stefan" |
2228 | 2294 |
"Modified: 22.1.1997 / 21:10:48 / cg" |
620 | 2295 |
! |
2296 |
||
2297 |
setOtherSuperclasses:anArrayOfClasses |
|
2298 |
"EXPERIMENTAL: set the other superclasses of the receiver. |
|
2299 |
this method is for special uses only - there will be no recompilation |
|
2300 |
and no change record written here; |
|
2301 |
Do NOT use it." |
|
2302 |
||
2303 |
SubclassInfo := nil. |
|
2304 |
otherSuperclasses := anArrayOfClasses |
|
2305 |
! |
|
2306 |
||
2307 |
setSuperclass:aClass |
|
2308 |
"set the superclass of the receiver. |
|
2309 |
this method is for special uses only - there will be no recompilation |
|
2310 |
and no change record written here. Also, if the receiver class has |
|
2311 |
already been in use, future operation of the system is not guaranteed to |
|
2312 |
be correct, since no caches are flushed. |
|
2313 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2314 |
||
2224 | 2315 |
"/ flush the subclass information |
2316 |
||
620 | 2317 |
SubclassInfo := nil. |
2318 |
superclass := aClass |
|
2224 | 2319 |
|
2320 |
"Modified: 22.1.1997 / 18:43:24 / cg" |
|
620 | 2321 |
! |
2322 |
||
2224 | 2323 |
setSuperclass:aClass methodDictionary:d instSize:i flags:f |
620 | 2324 |
"set some inst vars. |
2325 |
this method is for special uses only - there will be no recompilation |
|
2326 |
and no change record is written here. Also, if the receiver class has |
|
2327 |
already been in use, future operation of the system is not guaranteed to |
|
2328 |
be correct, since no caches are flushed. |
|
2329 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2330 |
||
2224 | 2331 |
self setSuperclass:aClass. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2332 |
self setMethodDictionary:d. |
620 | 2333 |
instSize := i. |
2334 |
flags := f |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2335 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2336 |
"Created: 7.6.1996 / 08:41:20 / stefan" |
2224 | 2337 |
"Modified: 22.1.1997 / 18:42:12 / cg" |
620 | 2338 |
! ! |
2339 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2340 |
!Behavior methodsFor:'private helpers'! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2341 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2342 |
addAllClassVarNamesTo:aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2343 |
"helper - add the name-strings of the class variables and of the class-vars |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2344 |
of all superclasses to the argument, aCollection. Return aCollection" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2345 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2346 |
|classvars| |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2347 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2348 |
(superclass notNil) ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2349 |
superclass addAllClassVarNamesTo:aCollection |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2350 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2351 |
(classvars := self classVariableString) notNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2352 |
aCollection addAll:(classvars asCollectionOfWords). |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2353 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2354 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2355 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2356 |
"Created: 16.4.1996 / 18:00:38 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2357 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2358 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2359 |
addAllInstVarNamesTo:aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2360 |
"helper for allInstVarNames - add the name-strings of the instance variables |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2361 |
and of the inst-vars of all superclasses to the argument, aCollection. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2362 |
Return aCollection." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2363 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2364 |
|superInsts instvars| |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2365 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2366 |
(superclass notNil) ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2367 |
superclass addAllInstVarNamesTo:aCollection |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2368 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2369 |
(instvars := self instanceVariableString) notNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2370 |
aCollection addAll:(instvars asCollectionOfWords). |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2371 |
] ifFalse:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2372 |
"/ mhmh - either someone klduged around, or this is |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2373 |
"/ a system running without sourceInfo. Generate |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2374 |
"/ synthetic names. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2375 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2376 |
superclass isNil ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2377 |
superInsts := 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2378 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2379 |
superInsts := superclass instSize |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2380 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2381 |
aCollection addAll:((superInsts+1 to:self instSize) |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2382 |
collect:[:index | '* instVar' , index printString , ' *']) |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2383 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2384 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2385 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2386 |
"Modified: 30.10.1995 / 19:46:21 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2387 |
"Created: 16.4.1996 / 18:03:14 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2388 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2389 |
|
620 | 2390 |
!Behavior methodsFor:'queries'! |
2391 |
||
2392 |
allClassVarNames |
|
2393 |
"return a collection of all the class variable name-strings |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2394 |
this includes all superclass-class variables" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2395 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2396 |
^ self addAllClassVarNamesTo:(OrderedCollection new) |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2397 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2398 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2399 |
Float allClassVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2400 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2401 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2402 |
"Modified: 16.4.1996 / 18:01:00 / cg" |
620 | 2403 |
! |
2404 |
||
2405 |
allDerivedInstances |
|
2406 |
"return a collection of all instances of myself and |
|
2407 |
instances of all subclasses of myself. |
|
2408 |
This method is going to be removed for protocol compatibility with |
|
2409 |
other STs; use allSubInstances" |
|
2410 |
||
2411 |
self obsoleteMethodWarning:'please use #allSubInstances'. |
|
2412 |
^ self allSubInstances |
|
2413 |
! |
|
2414 |
||
2415 |
allInstVarNames |
|
2416 |
"return a collection of all the instance variable name-strings |
|
2417 |
this includes all superclass-instance variables. |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2418 |
Instvars of superclasses come first (i.e. the position matches |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2419 |
the instVarAt:-index)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2420 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2421 |
^ self addAllInstVarNamesTo:(OrderedCollection new) |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2422 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2423 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2424 |
Dictionary instVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2425 |
Dictionary allInstVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2426 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2427 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2428 |
"Modified: 16.4.1996 / 18:03:55 / cg" |
620 | 2429 |
! |
2430 |
||
2431 |
allInstances |
|
2432 |
"return a collection of all my instances" |
|
2433 |
||
2434 |
"Read the documentation on why there seem to be no |
|
2435 |
instances of SmallInteger and UndefinedObject" |
|
2436 |
||
2437 |
|coll| |
|
2438 |
||
2439 |
coll := OrderedCollection new:100. |
|
2440 |
self allInstancesDo:[:anObject | |
|
2441 |
coll add:anObject |
|
2442 |
]. |
|
2443 |
^ coll |
|
2444 |
||
2445 |
" |
|
2446 |
ScrollBar allInstances |
|
2447 |
" |
|
2448 |
! |
|
2449 |
||
2053 | 2450 |
allSelectors |
2451 |
"return a collection of all selectors understood by the receiver; |
|
2452 |
this includes my selectors and all superclass selectors |
|
2453 |
(i.e. the receivers full protocol)" |
|
2454 |
||
2455 |
superclass notNil ifTrue:[ |
|
2456 |
^ superclass allSelectors addAll:(self selectors); yourself. |
|
2457 |
]. |
|
2458 |
^ self selectors asIdentitySet |
|
2459 |
||
2460 |
" |
|
2461 |
Point allSelectors |
|
2462 |
View allSelectors |
|
2463 |
Array allSelectors |
|
2464 |
" |
|
2465 |
||
2466 |
! |
|
2467 |
||
620 | 2468 |
allSubInstances |
2469 |
"return a collection of all instances of myself and |
|
2470 |
instances of all subclasses of myself." |
|
2471 |
||
2472 |
|coll| |
|
2473 |
||
2474 |
coll := OrderedCollection new:100. |
|
2475 |
self allSubInstancesDo:[:anObject | |
|
2476 |
(anObject isKindOf:self) ifTrue:[ |
|
2477 |
coll add:anObject |
|
2478 |
] |
|
2479 |
]. |
|
2480 |
^ coll |
|
2481 |
||
2482 |
" |
|
2483 |
View allSubInstances |
|
2484 |
" |
|
2485 |
! |
|
2486 |
||
2487 |
allSubclasses |
|
2488 |
"return a collection of all subclasses (direct AND indirect) of |
|
2489 |
the receiver. There will be no specific order, in which entries |
|
2490 |
are returned." |
|
2491 |
||
2492 |
|newColl| |
|
2493 |
||
2494 |
newColl := OrderedCollection new. |
|
2495 |
self allSubclassesDo:[:aClass | |
|
2496 |
newColl add:aClass |
|
2497 |
]. |
|
2498 |
^ newColl |
|
2499 |
||
2500 |
" |
|
2501 |
Collection allSubclasses |
|
2502 |
" |
|
2503 |
! |
|
2504 |
||
2505 |
allSubclassesInOrder |
|
2506 |
"return a collection of all subclasses (direct AND indirect) of |
|
2507 |
the receiver. Higher level subclasses will come before lower ones." |
|
2508 |
||
2509 |
|newColl| |
|
2510 |
||
2511 |
newColl := OrderedCollection new. |
|
2512 |
self allSubclassesInOrderDo:[:aClass | |
|
2513 |
newColl add:aClass |
|
2514 |
]. |
|
2515 |
^ newColl |
|
2516 |
||
2517 |
" |
|
2518 |
Collection allSubclassesInOrder |
|
2519 |
" |
|
2520 |
! |
|
2521 |
||
2522 |
allSuperclasses |
|
2523 |
"return a collection of the receivers accumulated superclasses" |
|
2524 |
||
2525 |
|aCollection theSuperClass| |
|
2526 |
||
2527 |
theSuperClass := superclass. |
|
2528 |
theSuperClass notNil ifTrue:[ |
|
2529 |
aCollection := OrderedCollection new. |
|
2530 |
[theSuperClass notNil] whileTrue:[ |
|
2531 |
aCollection add:theSuperClass. |
|
2532 |
theSuperClass := theSuperClass superclass |
|
2533 |
] |
|
2534 |
]. |
|
2535 |
^ aCollection |
|
2536 |
||
2537 |
" |
|
2538 |
String allSuperclasses |
|
2539 |
" |
|
2540 |
! |
|
2541 |
||
2542 |
cachedLookupMethodFor:aSelector |
|
2543 |
"return the method, which would be executed if aSelector was sent to |
|
2544 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
2545 |
and all of its superclasses are searched for aSelector. |
|
2546 |
Return the method, or nil if instances do not understand aSelector. |
|
2547 |
This interface provides exactly the same information as #lookupMethodFor:, |
|
2548 |
but uses the lookup-cache in the VM for faster search. |
|
2549 |
However, keep in mind, that doing a lookup through the cache also adds new |
|
2550 |
entries and can thus slow down the system by polluting the cache with |
|
2551 |
irrelevant entries. (do NOT loop over all objects calling this method). |
|
2552 |
Does NOT (currently) handle MI" |
|
2553 |
||
2554 |
%{ /* NOCONTEXT */ |
|
2201
db0f6e86c8bb
COMMA_SENDER arg is no longer supported / needed
Claus Gittinger <cg@exept.de>
parents:
2148
diff
changeset
|
2555 |
RETURN ( __lookup(self, aSelector) ); |
620 | 2556 |
%} |
2557 |
||
2558 |
" |
|
2559 |
String cachedLookupMethodFor:#= |
|
2560 |
String cachedLookupMethodFor:#asOrderedCollection |
|
2561 |
" |
|
2562 |
! |
|
2563 |
||
2564 |
canBeSubclassed |
|
2565 |
"return true, if its allowed to create subclasses of the receiver. |
|
2566 |
This method is redefined in SmallInteger and UndefinedObject, since |
|
2567 |
instances are detected by their pointer-fields, i.e. they do not have |
|
2568 |
a class entry (you dont have to understand this :-)" |
|
10 | 2569 |
|
2570 |
^ true |
|
2571 |
! |
|
2572 |
||
620 | 2573 |
canUnderstand:aSelector |
2574 |
"return true, if the receiver or one of its superclasses implements aSelector. |
|
2575 |
(i.e. true if my instances understand aSelector)" |
|
2576 |
||
2577 |
^ (self lookupMethodFor:aSelector) notNil |
|
2578 |
||
2579 |
" |
|
2580 |
True canUnderstand:#ifTrue: |
|
2581 |
True canUnderstand:#== |
|
2582 |
True canUnderstand:#do: |
|
2583 |
" |
|
91 | 2584 |
! |
2585 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2586 |
category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2587 |
"return the category of the class. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2588 |
Returning nil here, since Behavior does not define a category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2589 |
(only ClassDescriptions do)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2590 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2591 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2592 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2593 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2594 |
Point category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2595 |
Behavior new category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2596 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2597 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2598 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2599 |
classVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2600 |
"return a collection of the class variable name-strings. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2601 |
Returning empty here, since Behavior does not define any classVariables. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2602 |
(only Classes do). This allows different Behavior-like objects |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2603 |
(alien classes) to be handled by the browser as well." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2604 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2605 |
^ #() |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2606 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2607 |
"Created: 16.4.1996 / 17:57:31 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2608 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2609 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2610 |
classVariableString |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2611 |
"return a string of the class variables names. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2612 |
Returning empty here, since Behavior does not define any classVariables. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2613 |
(only Classes do). This allows different Behavior-like objects |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2614 |
(alien classes) to be handled by the browser as well." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2615 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2616 |
^ '' |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2617 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2618 |
"Created: 16.4.1996 / 16:28:56 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2619 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2620 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2621 |
comment |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2622 |
"return the comment of the class. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2623 |
Returning nil here, since Behavior does not define a category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2624 |
(only Classes do). This allows different Behavior-like objects |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2625 |
(alien classes) to be handled by the browser as well." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2626 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2627 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2628 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2629 |
"Modified: 16.4.1996 / 16:25:23 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2630 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2631 |
|
620 | 2632 |
compiledMethodAt:aSelector |
2633 |
"return the method for given selector aSelector or nil. |
|
2634 |
Only methods in the receiver - not in the superclass chain are tested." |
|
2635 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2636 |
|dict| |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2637 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2638 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2639 |
dict isNil ifTrue:[ |
2128 | 2640 |
('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR. |
2641 |
^ nil |
|
620 | 2642 |
]. |
2643 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2644 |
^ dict at:aSelector ifAbsent:[nil] |
620 | 2645 |
|
293 | 2646 |
" |
620 | 2647 |
Object compiledMethodAt:#== |
2648 |
(Object compiledMethodAt:#==) category |
|
293 | 2649 |
" |
1088 | 2650 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2651 |
"Modified: 7.6.1996 / 14:43:32 / stefan" |
2128 | 2652 |
"Modified: 10.1.1997 / 17:27:21 / cg" |
620 | 2653 |
! |
2654 |
||
2655 |
containsMethod:aMethod |
|
2656 |
"Return true, if the argument, aMethod is a method of myself" |
|
2657 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2658 |
|dict| |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2659 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2660 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2661 |
dict isNil ifTrue:[^ false]. "degenerated class" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2662 |
^ (dict keyAtValue:aMethod ifAbsent:[0]) ~~ 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2663 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2664 |
"Modified: 12.6.1996 / 13:33:53 / stefan" |
620 | 2665 |
! |
2666 |
||
2667 |
derivedInstanceCount |
|
2668 |
"return the number of instances of myself and of subclasses" |
|
2669 |
||
2670 |
|count| |
|
2671 |
||
2672 |
count := 0. |
|
2673 |
ObjectMemory allObjectsDo:[:anObject | |
|
2674 |
(anObject isKindOf:self) ifTrue:[ |
|
2675 |
count := count + 1 |
|
2676 |
] |
|
2677 |
]. |
|
2678 |
^ count |
|
2679 |
||
293 | 2680 |
" |
620 | 2681 |
View derivedInstanceCount |
2682 |
SequenceableCollection derivedInstanceCount |
|
983 | 2683 |
Object derivedInstanceCount |
2684 |
" |
|
2685 |
! |
|
2686 |
||
2687 |
hasDerivedInstances |
|
2688 |
"return true, if there are any instances of myself or of any subclass" |
|
2689 |
||
2690 |
"Read the documentation on why there seem to be no |
|
2691 |
instances of SmallInteger and UndefinedObject" |
|
2692 |
||
2693 |
ObjectMemory allObjectsDo:[:anObject | |
|
2694 |
(anObject isKindOf:self) ifTrue:[ |
|
2695 |
^ true |
|
2696 |
] |
|
2697 |
]. |
|
2698 |
^ false |
|
2699 |
||
2700 |
" |
|
2701 |
Object hasDerivedInstances - certainly true |
|
2702 |
SharedQueue hasDerivedInstances |
|
293 | 2703 |
" |
620 | 2704 |
! |
2705 |
||
2706 |
hasInstances |
|
2707 |
"return true, if there are any instances of myself" |
|
2708 |
||
2709 |
"Read the documentation on why there seem to be no |
|
2710 |
instances of SmallInteger and UndefinedObject" |
|
2711 |
||
2712 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
2713 |
"/ (anObject class == self) ifTrue:[ |
|
2714 |
"/ ^ true |
|
2715 |
"/ ] |
|
2716 |
"/ ]. |
|
983 | 2717 |
|
620 | 2718 |
ObjectMemory allInstancesOf:self do:[:anObject | |
983 | 2719 |
^ true |
620 | 2720 |
]. |
2721 |
^ false |
|
2722 |
||
293 | 2723 |
" |
620 | 2724 |
Object hasInstances |
2725 |
SequenceableCollection hasInstances |
|
2726 |
Float hasInstances |
|
2727 |
SmallInteger hasInstances |
|
293 | 2728 |
" |
620 | 2729 |
! |
2730 |
||
2731 |
hasMethods |
|
2732 |
"return true, if there are any (local) methods in this class" |
|
2733 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2734 |
^ (self methodDictionary size ~~ 0) |
620 | 2735 |
|
293 | 2736 |
" |
620 | 2737 |
True hasMethods |
2738 |
True class hasMethods |
|
2739 |
" |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2740 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2741 |
"Modified: 7.6.1996 / 15:43:09 / stefan" |
620 | 2742 |
! |
2743 |
||
2744 |
hasMultipleSuperclasses |
|
2745 |
"Return true, if this class inherits from other classes |
|
2746 |
(beside its primary superclass). |
|
2747 |
This method is a preparation for a future multiple inheritance extension |
|
2748 |
- currently it is not supported by the VM" |
|
2749 |
||
2750 |
^ otherSuperclasses notNil |
|
2751 |
! |
|
2752 |
||
2753 |
implements:aSelector |
|
2754 |
"return true, if the receiver implements aSelector. |
|
2755 |
(i.e. implemented in THIS class - NOT in a superclass). |
|
983 | 2756 |
|
2757 |
Caveat: |
|
2758 |
This simply checks for the selector being present in the classes |
|
2759 |
selector table - therefore, it does not care for ignoredMethods. |
|
2760 |
(but: you should not use this method for protocol-testing, anyway). |
|
2761 |
||
2762 |
Hint: |
|
2763 |
Dont use this method to check if someone responds to a message - |
|
2764 |
use #canUnderstand: on the class or #respondsTo: on the instance |
|
2765 |
to do this." |
|
2766 |
||
2767 |
^ self includesSelector:aSelector |
|
620 | 2768 |
|
2769 |
" |
|
983 | 2770 |
notice: this is class protocol |
2771 |
||
2772 |
True implements:#ifTrue: |
|
2773 |
True implements:#== |
|
2774 |
||
2775 |
notice: this is instance protocol |
|
2776 |
||
2777 |
true respondsTo:#ifTrue: |
|
2778 |
true respondsTo:#== |
|
2779 |
||
2780 |
notice: this is class protocol |
|
2781 |
||
2782 |
True canUnderstand:#ifTrue: |
|
2783 |
True canUnderstand:#== |
|
620 | 2784 |
" |
983 | 2785 |
|
2786 |
"Modified: 10.2.1996 / 13:15:56 / cg" |
|
620 | 2787 |
! |
2788 |
||
2789 |
includesSelector:aSelector |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2790 |
"return true, if the methodDictionary of THIS class includes |
983 | 2791 |
a method for aSelector. |
2792 |
(i.e. if aSelector is implemented in THIS class - NOT in a superclass). |
|
2793 |
||
2794 |
Hint: |
|
2795 |
Dont use this method to check if someone responds to a message - |
|
2796 |
use #canUnderstand: on the class or #respondsTo: on the instance |
|
2797 |
to do this." |
|
2798 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2799 |
^ (self methodDictionary at:aSelector ifAbsent:[0]) ~~ 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2800 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2801 |
" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2802 |
Object includesSelector:#== |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2803 |
Object includesSelector:#murks |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2804 |
" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2805 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2806 |
"Modified: 7.6.1996 / 14:27:24 / stefan" |
620 | 2807 |
! |
2808 |
||
2809 |
inheritsFrom:aClass |
|
2810 |
"return true, if the receiver inherits methods from aClass" |
|
2811 |
||
2812 |
^ self isSubclassOf:aClass |
|
2813 |
||
2814 |
" |
|
2815 |
True inheritsFrom:Object |
|
2816 |
LinkedList inheritsFrom:Array |
|
356 | 2817 |
" |
357 | 2818 |
! |
2819 |
||
620 | 2820 |
instanceCount |
2821 |
"return the number of instances of myself." |
|
2822 |
||
2823 |
"Read the documentation on why there seem to be no |
|
2824 |
instances of SmallInteger and UndefinedObject" |
|
2825 |
||
2826 |
|count| |
|
2827 |
||
2828 |
count := 0. |
|
2829 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
2830 |
"/ (anObject class == self) ifTrue:[ |
|
2831 |
"/ count := count + 1 |
|
2832 |
"/ ] |
|
2833 |
"/ ]. |
|
983 | 2834 |
|
620 | 2835 |
ObjectMemory allInstancesOf:self do:[:anObject | |
2836 |
count := count + 1 |
|
2837 |
]. |
|
2838 |
^ count |
|
2839 |
||
2840 |
" |
|
2841 |
View instanceCount |
|
2842 |
Object instanceCount |
|
2843 |
Float instanceCount |
|
2844 |
SequenceableCollection instanceCount |
|
2845 |
SmallInteger instanceCount .... mhmh - hear, hear |
|
2846 |
" |
|
2847 |
! |
|
2848 |
||
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2849 |
instanceVariableString |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2850 |
"return a string with dummy names here - typically, your |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2851 |
objects are instances of Class, not Behavior." |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2852 |
|
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
2853 |
|s superInsts n "{Class: SmallInteger }"| |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2854 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2855 |
s := ''. |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
2856 |
superclass isNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2857 |
superInsts := 0 |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
2858 |
] ifFalse:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2859 |
superInsts := superclass instSize |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
2860 |
]. |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2861 |
n := self instSize. |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
2862 |
superInsts+1 to:n do:[:i | |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2863 |
s size == 0 ifFalse:[s := s , ' ']. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2864 |
s := s , 'instvar' , i printString |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2865 |
]. |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2866 |
^ s |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2867 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2868 |
" |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2869 |
Behavior new instanceVariableString |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2870 |
" |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2871 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2872 |
"Modified: 7.5.1996 / 12:50:25 / cg" |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
2873 |
"Modified: 3.6.1996 / 16:03:33 / stefan" |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2874 |
! |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
2875 |
|
620 | 2876 |
isBehavior |
2877 |
"return true, if the receiver is describing another objects behavior, |
|
2878 |
i.e. is a class. Defined to avoid the need to use isKindOf:" |
|
2879 |
||
2880 |
^ true |
|
2881 |
||
2882 |
" |
|
2883 |
True isBehavior |
|
2884 |
true isBehavior |
|
2885 |
" |
|
2886 |
! |
|
2887 |
||
2888 |
isBits |
|
2889 |
"return true, if instances have indexed byte or short instance variables. |
|
2890 |
Ignore long, float and double arrays, since ST-80 code using isBits are probably |
|
2891 |
not prepared to handle them correctly." |
|
92 | 2892 |
|
2893 |
%{ /* NOCONTEXT */ |
|
620 | 2894 |
|
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2895 |
REGISTER int what; |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2896 |
|
1133 | 2897 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2898 |
RETURN (( (what == __MASKSMALLINT(BYTEARRAY)) |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2899 |
|| (what == __MASKSMALLINT(WORDARRAY))) ? true : false ); |
620 | 2900 |
%} |
2901 |
! |
|
2902 |
||
1832 | 2903 |
isBuiltInClass |
2904 |
"return true if this class is known by the run-time-system. |
|
2905 |
Here, false is returned as default. |
|
2906 |
Notice, this is instance protocol, which means that any class |
|
2907 |
other than those special ones) are non-builtIn by default." |
|
2908 |
||
2909 |
^ false |
|
2910 |
||
2911 |
"Modified: 23.4.1996 / 15:55:52 / cg" |
|
2912 |
"Created: 28.10.1996 / 15:10:02 / cg" |
|
2913 |
! |
|
2914 |
||
620 | 2915 |
isBytes |
2916 |
"return true, if instances have indexed byte instance variables" |
|
2917 |
||
2918 |
"this could also be defined as: |
|
2919 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagBytes |
|
2920 |
" |
|
2921 |
%{ /* NOCONTEXT */ |
|
2922 |
||
1133 | 2923 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(BYTEARRAY)) ? true : false ); |
68 | 2924 |
%} |
620 | 2925 |
! |
2926 |
||
2927 |
isDoubles |
|
2928 |
"return true, if instances have indexed double instance variables" |
|
2929 |
||
2930 |
"this could also be defined as: |
|
2931 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagDoubles |
|
2932 |
" |
|
2933 |
%{ /* NOCONTEXT */ |
|
2934 |
||
1133 | 2935 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(DOUBLEARRAY)) ? true : false ); |
620 | 2936 |
%} |
2937 |
! |
|
2938 |
||
2939 |
isFixed |
|
2940 |
"return true, if instances do not have indexed instance variables" |
|
2941 |
||
2942 |
"this could also be defined as: |
|
2943 |
^ self isVariable not |
|
2944 |
" |
|
2945 |
||
2946 |
%{ /* NOCONTEXT */ |
|
2947 |
||
1133 | 2948 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? false : true ); |
620 | 2949 |
%} |
2950 |
! |
|
2951 |
||
2952 |
isFloats |
|
2953 |
"return true, if instances have indexed float instance variables" |
|
2954 |
||
2955 |
"this could also be defined as: |
|
2956 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagFloats |
|
2957 |
" |
|
2958 |
%{ /* NOCONTEXT */ |
|
2959 |
||
1133 | 2960 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(FLOATARRAY)) ? true : false ); |
620 | 2961 |
%} |
91 | 2962 |
! |
2963 |
||
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2964 |
isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2965 |
"return true, if instances have indexed float or double instance variables" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2966 |
|
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2967 |
%{ /* NOCONTEXT */ |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2968 |
|
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2969 |
int what; |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2970 |
|
1133 | 2971 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2972 |
RETURN (( (what == __MASKSMALLINT(FLOATARRAY)) |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2973 |
|| (what == __MASKSMALLINT(DOUBLEARRAY))) ? true : false ); |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2974 |
%} |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2975 |
" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2976 |
(Object new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2977 |
(Point new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2978 |
(Array new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2979 |
(ByteArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2980 |
(FloatArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2981 |
(DoubleArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2982 |
" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2983 |
! |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
2984 |
|
620 | 2985 |
isLongs |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
2986 |
"return true, if instances have indexed long instance variables (4 byte ints)" |
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
2987 |
|
620 | 2988 |
%{ /* NOCONTEXT */ |
2989 |
||
1133 | 2990 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(LONGARRAY)) ? true : false ); |
620 | 2991 |
%} |
356 | 2992 |
! |
2993 |
||
620 | 2994 |
isPointers |
2995 |
"return true, if instances have pointer instance variables |
|
2996 |
i.e. are either non-indexed or have indexed pointer variables" |
|
2997 |
||
2998 |
"QUESTION: should we ignore WeakPointers ?" |
|
2999 |
||
3000 |
%{ /* NOCONTEXT */ |
|
3001 |
||
3002 |
REGISTER int flags; |
|
3003 |
||
1133 | 3004 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
620 | 3005 |
switch (flags) { |
3006 |
default: |
|
3007 |
/* normal objects */ |
|
3008 |
RETURN ( true ); |
|
3009 |
||
3010 |
case BYTEARRAY: |
|
3011 |
case WORDARRAY: |
|
3012 |
case LONGARRAY: |
|
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3013 |
case SWORDARRAY: |
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3014 |
case SLONGARRAY: |
620 | 3015 |
case FLOATARRAY: |
3016 |
case DOUBLEARRAY: |
|
3017 |
RETURN (false ); |
|
3018 |
||
3019 |
case WKPOINTERARRAY: |
|
3020 |
/* what about those ? */ |
|
3021 |
RETURN (true ); |
|
3022 |
} |
|
3023 |
%} |
|
3024 |
! |
|
3025 |
||
1722 | 3026 |
isPrivate |
3027 |
"return true, if the receiver is some private class" |
|
3028 |
||
3029 |
^ self owningClass notNil |
|
3030 |
||
3031 |
"Modified: 12.10.1996 / 20:11:05 / cg" |
|
3032 |
! |
|
3033 |
||
1634 | 3034 |
isSignedLongs |
3035 |
"return true, if instances have indexed signed long instance variables (4 byte ints)" |
|
3036 |
||
3037 |
%{ /* NOCONTEXT */ |
|
3038 |
||
3039 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SLONGARRAY)) ? true : false ); |
|
3040 |
%} |
|
3041 |
! |
|
3042 |
||
3043 |
isSignedWords |
|
3044 |
"return true, if instances have indexed signed short instance variables" |
|
3045 |
||
3046 |
%{ /* NOCONTEXT */ |
|
3047 |
||
3048 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SWORDARRAY)) ? true : false ); |
|
3049 |
%} |
|
3050 |
! |
|
3051 |
||
620 | 3052 |
isSubclassOf:aClass |
3053 |
"return true, if I am a subclass of the argument, aClass" |
|
3054 |
||
3055 |
|theClass| |
|
3056 |
||
3057 |
theClass := superclass. |
|
3058 |
[theClass notNil] whileTrue:[ |
|
3059 |
(theClass == aClass) ifTrue:[^ true]. |
|
3060 |
%{ |
|
3061 |
if (__isBehaviorLike(theClass)) { |
|
3062 |
theClass = __ClassInstPtr(theClass)->c_superclass; |
|
3063 |
} else { |
|
3064 |
theClass = nil; |
|
3065 |
} |
|
3066 |
%}. |
|
3067 |
"/ theClass := theClass superclass. |
|
3068 |
]. |
|
3069 |
^ false |
|
356 | 3070 |
|
3071 |
" |
|
620 | 3072 |
String isSubclassOf:Collection |
3073 |
LinkedList isSubclassOf:Array |
|
3074 |
1 isSubclassOf:Number <- will fail since 1 is no class |
|
3075 |
" |
|
3076 |
! |
|
3077 |
||
3078 |
isVariable |
|
3079 |
"return true, if instances have indexed instance variables" |
|
3080 |
||
3081 |
"this could also be defined as: |
|
3082 |
^ (flags bitAnd:(Behavior maskIndexType)) ~~ 0 |
|
3083 |
" |
|
3084 |
||
3085 |
%{ /* NOCONTEXT */ |
|
3086 |
||
1133 | 3087 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? true : false ); |
620 | 3088 |
%} |
3089 |
! |
|
3090 |
||
3091 |
isWords |
|
3092 |
"return true, if instances have indexed short instance variables" |
|
3093 |
||
3094 |
"this could also be defined as: |
|
3095 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagWords |
|
3096 |
" |
|
3097 |
%{ /* NOCONTEXT */ |
|
3098 |
||
1133 | 3099 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(WORDARRAY)) ? true : false ); |
620 | 3100 |
%} |
3101 |
! |
|
3102 |
||
3103 |
lookupMethodFor:aSelector |
|
3104 |
"return the method, which would be executed if aSelector was sent to |
|
3105 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
3106 |
and all of its superclasses are searched for aSelector. |
|
3107 |
Return the method, or nil if instances do not understand aSelector. |
|
3108 |
EXPERIMENTAL: take care of multiple superclasses." |
|
3109 |
||
3110 |
|m cls| |
|
3111 |
||
3112 |
cls := self. |
|
3113 |
[cls notNil] whileTrue:[ |
|
3114 |
m := cls compiledMethodAt:aSelector. |
|
3115 |
m notNil ifTrue:[^ m]. |
|
3116 |
cls hasMultipleSuperclasses ifTrue:[ |
|
3117 |
cls superclasses do:[:aSuperClass | |
|
3118 |
m := aSuperClass lookupMethodFor:aSelector. |
|
3119 |
m notNil ifTrue:[^ m]. |
|
3120 |
]. |
|
3121 |
^ nil |
|
3122 |
] ifFalse:[ |
|
3123 |
cls := cls superclass |
|
3124 |
] |
|
3125 |
]. |
|
3126 |
^ nil |
|
3127 |
! |
|
3128 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3129 |
name |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3130 |
"although behaviors have no name, we return something |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3131 |
useful here - there are many places (inspectors) where |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3132 |
a classes name is asked for. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3133 |
Implementing this message here allows anonymous classes |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3134 |
and instances of them to be inspected." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3135 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3136 |
^ 'someBehavior' |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3137 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3138 |
|
1760 | 3139 |
owningClass |
3140 |
"return my owning class - nil if I am a public class" |
|
3141 |
||
1918 | 3142 |
"/ this information is in the metaclass ... |
3143 |
||
1760 | 3144 |
^ self class owningClass |
3145 |
||
3146 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
1918 | 3147 |
"Modified: 7.11.1996 / 13:49:28 / cg" |
1760 | 3148 |
! |
3149 |
||
620 | 3150 |
selectorAtMethod:aMethod |
3151 |
"Return the selector for given method aMethod." |
|
3152 |
||
3153 |
^ self selectorAtMethod:aMethod ifAbsent:[nil] |
|
3154 |
||
3155 |
" |
|
3156 |
|m| |
|
3157 |
||
3158 |
m := Object compiledMethodAt:#copy. |
|
3159 |
Fraction selectorAtMethod:m. |
|
3160 |
" |
|
3161 |
" |
|
3162 |
|m| |
|
3163 |
||
3164 |
m := Object compiledMethodAt:#copy. |
|
3165 |
Object selectorAtMethod:m. |
|
356 | 3166 |
" |
3167 |
! |
|
3168 |
||
620 | 3169 |
selectorAtMethod:aMethod ifAbsent:failBlock |
3170 |
"return the selector for given method aMethod |
|
3171 |
or the value of failBlock, if not found." |
|
3172 |
||
1814 | 3173 |
|md| |
3174 |
||
3175 |
md := self methodDictionary. |
|
3176 |
md isNil ifTrue:[ |
|
3177 |
'OOPS - nil methodDictionary' errorPrintCR. |
|
3178 |
^ nil |
|
3179 |
]. |
|
3180 |
^ md keyAtValue:aMethod ifAbsent:failBlock. |
|
216 | 3181 |
|
3182 |
" |
|
620 | 3183 |
|m| |
3184 |
||
3185 |
m := Object compiledMethodAt:#copy. |
|
3186 |
Object selectorAtMethod:m ifAbsent:['oops']. |
|
3187 |
" |
|
216 | 3188 |
" |
620 | 3189 |
|m| |
3190 |
||
3191 |
m := Object compiledMethodAt:#copy. |
|
3192 |
Fraction selectorAtMethod:m ifAbsent:['oops']. |
|
216 | 3193 |
" |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3194 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3195 |
"Modified: 7.6.1996 / 15:15:45 / stefan" |
216 | 3196 |
! |
3197 |
||
127 | 3198 |
sizeOfInst:n |
3199 |
"return the number of bytes required for an instance of |
|
3200 |
myself with n indexed instance variables. The argument n |
|
3201 |
should be zero for classes without indexed instance variables. |
|
3202 |
See Behavior>>niceNew: for an application of this." |
|
216 | 3203 |
|
127 | 3204 |
|nInstvars| |
3205 |
||
3206 |
nInstvars := self instSize. |
|
3207 |
%{ |
|
3208 |
int nBytes; |
|
3209 |
||
1133 | 3210 |
nBytes = __intVal(nInstvars) * sizeof(OBJ) + OHDR_SIZE; |
249 | 3211 |
if (__isSmallInteger(n)) { |
154 | 3212 |
int nIndex; |
127 | 3213 |
|
1133 | 3214 |
nIndex = __intVal(n); |
3215 |
switch (__intVal(__INST(flags)) & ARRAYMASK) { |
|
154 | 3216 |
case BYTEARRAY: |
3217 |
nBytes += nIndex; |
|
3218 |
if (nBytes & (ALIGN - 1)) { |
|
3219 |
nBytes = (nBytes & ~(ALIGN - 1)) + ALIGN; |
|
3220 |
} |
|
3221 |
break; |
|
127 | 3222 |
|
154 | 3223 |
case WORDARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3224 |
case SWORDARRAY: |
154 | 3225 |
nBytes += nIndex * sizeof(short); |
3226 |
if (nBytes & (ALIGN - 1)) { |
|
3227 |
nBytes = (nBytes & ~(ALIGN - 1)) + ALIGN; |
|
3228 |
} |
|
3229 |
break; |
|
127 | 3230 |
|
154 | 3231 |
case LONGARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3232 |
case SLONGARRAY: |
154 | 3233 |
nBytes += nIndex * sizeof(long); |
3234 |
break; |
|
127 | 3235 |
|
154 | 3236 |
case FLOATARRAY: |
3237 |
nBytes += nIndex * sizeof(float); |
|
3238 |
break; |
|
127 | 3239 |
|
154 | 3240 |
case DOUBLEARRAY: |
3241 |
nBytes += nIndex * sizeof(double); |
|
3242 |
break; |
|
127 | 3243 |
|
154 | 3244 |
default: |
3245 |
nBytes += nIndex * sizeof(OBJ); |
|
3246 |
break; |
|
3247 |
} |
|
127 | 3248 |
} |
1133 | 3249 |
RETURN (__MKSMALLINT(nBytes)); |
127 | 3250 |
%} |
3251 |
! |
|
3252 |
||
620 | 3253 |
sourceCodeAt:aSelector |
3254 |
"return the methods source for given selector aSelector or nil. |
|
3255 |
Only methods in the receiver - not in the superclass chain are tested." |
|
3256 |
||
3257 |
|method| |
|
3258 |
||
3259 |
method := self compiledMethodAt:aSelector. |
|
3260 |
method isNil ifTrue:[^ nil]. |
|
3261 |
^ method source |
|
45 | 3262 |
|
91 | 3263 |
" |
620 | 3264 |
True sourceCodeAt:#ifTrue: |
3265 |
Object sourceCodeAt:#== |
|
3266 |
Behavior sourceCodeAt:#sourceCodeAt: |
|
91 | 3267 |
" |
1 | 3268 |
! |
3269 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3270 |
sourceCodeManager |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3271 |
"return the sourceCodeManager of the class. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3272 |
Returning nil here, since Behavior does not define any sourceCode management. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3273 |
(only Classes do). This allows different Behavior-like objects |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3274 |
(alien classes) to be handled by the browser as well." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3275 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3276 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3277 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3278 |
"Created: 16.4.1996 / 16:26:03 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3279 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3280 |
|
1 | 3281 |
subclasses |
3282 |
"return a collection of the direct subclasses of the receiver" |
|
3283 |
||
3284 |
|newColl| |
|
3285 |
||
2224 | 3286 |
"/ use cached information (avoid class hierarchy search) |
3287 |
"/ if possible |
|
3288 |
||
308 | 3289 |
SubclassInfo notNil ifTrue:[ |
2224 | 3290 |
newColl := SubclassInfo at:self ifAbsent:nil. |
3291 |
newColl notNil ifTrue:[^ newColl asOrderedCollection] |
|
308 | 3292 |
]. |
3293 |
||
1 | 3294 |
newColl := OrderedCollection new. |
3295 |
self subclassesDo:[:aClass | |
|
2224 | 3296 |
newColl add:aClass |
1 | 3297 |
]. |
3298 |
^ newColl |
|
45 | 3299 |
|
91 | 3300 |
" |
3301 |
Collection subclasses |
|
3302 |
" |
|
2224 | 3303 |
|
3304 |
"Modified: 22.1.1997 / 18:43:52 / cg" |
|
1 | 3305 |
! |
3306 |
||
620 | 3307 |
superclasses |
3308 |
"return a collection of the receivers immediate superclasses. |
|
3309 |
This method is a preparation for a future multiple inheritance extension |
|
3310 |
- currently it is not supported by the VM" |
|
3311 |
||
3312 |
|a| |
|
3313 |
||
3314 |
a := Array with:superclass. |
|
3315 |
otherSuperclasses notNil ifTrue:[ |
|
3316 |
^ a , otherSuperclasses |
|
1 | 3317 |
]. |
620 | 3318 |
^ a |
154 | 3319 |
|
3320 |
" |
|
620 | 3321 |
String superclasses |
91 | 3322 |
" |
2 | 3323 |
! |
3324 |
||
2048 | 3325 |
topOwningClass |
3326 |
"return my outermost owning class - nil if I am a public class" |
|
3327 |
||
3328 |
"/ this information is in the metaclass ... |
|
3329 |
||
3330 |
^ self class topOwningClass |
|
3331 |
||
3332 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
3333 |
"Modified: 3.1.1997 / 19:18:49 / cg" |
|
3334 |
! |
|
3335 |
||
1191
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3336 |
wasAutoloaded |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3337 |
"return true, if this class came into the system via an |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3338 |
autoload; false otherwise. |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3339 |
Returning false here. This allows different Behavior-like objects |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3340 |
(alien classes) to be handled by the browser as well." |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3341 |
|
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3342 |
^ false |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3343 |
|
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3344 |
"Created: 16.4.1996 / 16:27:16 / cg" |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3345 |
! |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3346 |
|
2 | 3347 |
whichClassImplements:aSelector |
328 | 3348 |
"obsolete interface; |
3349 |
use whichClassIncludesSelector: for ST-80 compatibility." |
|
3350 |
||
3351 |
^ self whichClassIncludesSelector:aSelector |
|
3352 |
! |
|
3353 |
||
3354 |
whichClassIncludesSelector:aSelector |
|
68 | 3355 |
"return the class in the inheritance chain, which implements the method |
3356 |
for aSelector; return nil if none. |
|
3357 |
EXPERIMENTAL: handle multiple superclasses" |
|
3358 |
||
3359 |
|cls| |
|
2 | 3360 |
|
68 | 3361 |
cls := self. |
3362 |
[cls notNil] whileTrue:[ |
|
983 | 3363 |
(cls includesSelector:aSelector) ifTrue:[^ cls]. |
154 | 3364 |
cls hasMultipleSuperclasses ifTrue:[ |
3365 |
cls superclasses do:[:aSuperClass | |
|
3366 |
|implementingClass| |
|
2 | 3367 |
|
328 | 3368 |
implementingClass := aSuperClass whichClassIncludesSelector:aSelector. |
154 | 3369 |
implementingClass notNil ifTrue:[^ implementingClass]. |
3370 |
]. |
|
3371 |
^ nil |
|
3372 |
] ifFalse:[ |
|
3373 |
cls := cls superclass |
|
3374 |
] |
|
2 | 3375 |
]. |
3376 |
^ nil |
|
3377 |
||
91 | 3378 |
" |
328 | 3379 |
String whichClassIncludesSelector:#== |
3380 |
String whichClassIncludesSelector:#collect: |
|
91 | 3381 |
" |
2 | 3382 |
! |
3383 |
||
620 | 3384 |
withAllSubclasses |
3385 |
"return a collection containing the receiver and |
|
3386 |
all subclasses (direct AND indirect) of the receiver" |
|
3387 |
||
3388 |
|newColl| |
|
3389 |
||
3390 |
newColl := OrderedCollection with:self. |
|
3391 |
self allSubclassesDo:[:aClass | |
|
3392 |
newColl add:aClass |
|
3393 |
]. |
|
3394 |
^ newColl |
|
328 | 3395 |
|
3396 |
" |
|
620 | 3397 |
Collection withAllSubclasses |
91 | 3398 |
" |
1 | 3399 |
! |
3400 |
||
620 | 3401 |
withAllSuperclasses |
3402 |
"return a collection containing the receiver and all |
|
3403 |
of the receivers accumulated superclasses" |
|
3404 |
||
3405 |
|aCollection theSuperClass| |
|
3406 |
||
3407 |
aCollection := OrderedCollection with:self. |
|
3408 |
theSuperClass := superclass. |
|
3409 |
[theSuperClass notNil] whileTrue:[ |
|
3410 |
aCollection add:theSuperClass. |
|
3411 |
theSuperClass := theSuperClass superclass |
|
308 | 3412 |
]. |
620 | 3413 |
^ aCollection |
11 | 3414 |
|
91 | 3415 |
" |
620 | 3416 |
String withAllSuperclasses |
308 | 3417 |
" |
2 | 3418 |
! ! |
620 | 3419 |
|
3420 |
!Behavior methodsFor:'snapshots'! |
|
3421 |
||
3422 |
postSnapshot |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3423 |
"sent by ObjectMemory to all classes, after a snapshot has been written. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3424 |
Nothing done here. This can be redefined in classes which like to know |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3425 |
about snapshooting." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3426 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3427 |
"Modified: 16.4.1996 / 18:12:08 / cg" |
620 | 3428 |
! |
3429 |
||
3430 |
preSnapshot |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3431 |
"sent by ObjectMemory to all classes, before a snapshot is written. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3432 |
Nothing done here. This can be redefined in classes which like to know |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3433 |
about snapshooting." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3434 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3435 |
"Modified: 16.4.1996 / 18:12:14 / cg" |
620 | 3436 |
! ! |
3437 |
||
1760 | 3438 |
!Behavior class methodsFor:'documentation'! |
662 | 3439 |
|
3440 |
version |
|
2228 | 3441 |
^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.101 1997-01-22 20:11:17 cg Exp $' |
662 | 3442 |
! ! |