author | Claus Gittinger <cg@exept.de> |
Mon, 05 Oct 2009 20:06:38 +0200 | |
changeset 12148 | e7a761017355 |
parent 12114 | 53048e0b6bf7 |
child 12195 | 65f344e48a03 |
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 |
" |
|
5368
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
13 |
|
1 | 14 |
Object subclass:#Behavior |
7331
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
15 |
instanceVariableNames:'superclass flags methodDictionary instSize' |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
16 |
classVariableNames:'SubclassInfo' |
1088 | 17 |
poolDictionaries:'' |
18 |
category:'Kernel-Classes' |
|
1 | 19 |
! |
20 |
||
1760 | 21 |
!Behavior class methodsFor:'documentation'! |
47 | 22 |
|
88 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
154 | 26 |
All Rights Reserved |
88 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
47 | 37 |
documentation |
38 |
" |
|
68 | 39 |
Every class in the system inherits from Behavior (via Class, ClassDescription); |
40 |
so here is where most of the class messages end up being implemented. |
|
41 |
(to answer a FAQ: 'Point basicNew' will be done here :-) |
|
42 |
||
356 | 43 |
Beginners should keep in mind, that all classes are instances (of subclasses) |
12094 | 44 |
of Behavior, therefore you will find the above mentioned 'basicNew:' method |
45 |
under the 'instance'-methods of Behavior - NOT under the class methods |
|
46 |
('Behavior new' will create and return a new class, while sending 'new' to |
|
154 | 47 |
any instance of Behavior (i.e. any class) will return an instance of that class). |
68 | 48 |
|
2226 | 49 |
|
68 | 50 |
Behavior provides minimum support for all classes - additional stuff is |
77 | 51 |
found in ClassDescription and Class. Behaviors provides all mechanisms needed |
12094 | 52 |
to create instances, and send messages to those. However, Behavior does not provide |
77 | 53 |
all the (symbolic) information needed to compile methods for a class or to get |
54 |
useful information in inspectors. |
|
47 | 55 |
|
2226 | 56 |
for experts: |
57 |
||
58 |
Since instances of Behavior provide all that is needed to interact with the VM's |
|
59 |
message dispatch mechanism, these can be used as 'light weight' classes. |
|
60 |
I.e. it is possible, to generate completely anonymous classes (and instances thereof) |
|
61 |
on the fly - 'Behavior new new' is such a thingy. |
|
62 |
||
12094 | 63 |
The selectors and Methods are organized in a MethodDictionary (which is not a true |
2226 | 64 |
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
|
65 |
This avoids the need for knowledge about Dictionaries in the runtime library (VM) |
12094 | 66 |
(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
|
67 |
hashed dictionary is almost void). |
1 | 68 |
|
1285 | 69 |
[Instance variables:] |
70 |
||
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
71 |
superclass <Class> the receivers superclass |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
72 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
73 |
methodDictionary <MethodDictionary> inst-selectors and methods |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
74 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
75 |
instSize <SmallInteger> the number of instance variables |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
76 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
77 |
flags <SmallInteger> special flag bits coded in a number |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
78 |
not for application use |
1 | 79 |
|
81 | 80 |
flag bits (see stc.h): |
47 | 81 |
|
68 | 82 |
NOTICE: layout known by compiler and runtime system; be careful when changing |
1285 | 83 |
|
1292 | 84 |
[author:] |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
85 |
Claus Gittinger |
1292 | 86 |
|
1285 | 87 |
[see also:] |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
88 |
Class ClassDescription Metaclass |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
89 |
Method MethodDictionary |
47 | 90 |
" |
356 | 91 |
! |
92 |
||
12094 | 93 |
virtualMachineRelationship |
356 | 94 |
" |
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
95 |
Expert info follows: |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
96 |
|
12094 | 97 |
NOTICE: |
98 |
the stuff described below may not be available on other |
|
99 |
Smalltalk implementations; be aware that these error mechanisms |
|
100 |
are ST/X specials and applications using these (tricks) may |
|
101 |
not be portable to other systems. |
|
102 |
||
103 |
WARNING: |
|
104 |
do not try the examples below on (some) other smalltalk systems; |
|
105 |
it has been reported, that some crash badly when doing this .... ;-) |
|
357 | 106 |
|
356 | 107 |
Instances of Behavior and subclasses (i.e. in sloppy words: classes) |
108 |
play a special role w.r.t. the VM. Only objects whose class-slot is marked |
|
109 |
as being behaviorLike (in the flag-instvar) are considered to be classLike |
|
110 |
and a message lookup will be done for it in the well known way. |
|
111 |
Thus, if an object has a class for which its class does NOT have |
|
362 | 112 |
this flag bit set, the VM will trigger an error on a message send. |
356 | 113 |
|
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
114 |
|
356 | 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. |
|
12094 | 119 |
Thus, you can create arbitrary new classLike objects and have the VM |
356 | 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 !! |
|
12094 | 127 |
This may look to be of theoretical value at first sight, |
128 |
however, such a construct saves memory, by not requiring an extra |
|
2148 | 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 |
|
12094 | 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 |
|
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
150 |
|
8503 | 151 |
Vice versa, defining 'dumb classes', which have the behaviorLike bit turned |
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
152 |
of may be useful as well; if a message is sent to an instance of such |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
153 |
a thingy, the VM performs a recovery sequence, which is much like the |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
154 |
#doesNotUnderstand: mechanism - however, since the instance is no good |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
155 |
receiver of such a message, a #cannotSendMessage:to: is now sent to the |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
156 |
class (which is not a real class), passing the original message (selector |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
157 |
and arguments) along with the original receiver. |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
158 |
The default behavior for this message is to raise an internalError signal - |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
159 |
however, you may redefine this in your 'dum class' for recovery. |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
160 |
One possible use of this is to provide new message send algorithms - the |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
161 |
class may lookup a method and invoke it directly, via the #valueWithReceiver: |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
162 |
interface. |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
163 |
|
12094 | 164 |
All of the above is pure expert stuff |
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
165 |
- You do not have to care about the above details if you are a 'normal' |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
166 |
ST-programmer, though (and even most of those will never use these features). |
357 | 167 |
|
356 | 168 |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
746
diff
changeset
|
169 |
Examples (only of theoretical interest): |
12094 | 170 |
take away the behaviorLike-flag from a class. |
171 |
-> The instances will not understand any messages, since the VM will |
|
172 |
not recognize its class as being a class ... |
|
173 |
||
174 |
|newMeta notRecognizedAsClass someInstance| |
|
175 |
||
176 |
newMeta := Metaclass new. |
|
177 |
newMeta flags:0. |
|
178 |
||
179 |
notRecognizedAsClass := newMeta new. |
|
180 |
||
181 |
someInstance := notRecognizedAsClass new. |
|
182 |
someInstance perform:#isNil |
|
356 | 183 |
|
357 | 184 |
|
185 |
Of course, this is an exception which can be handled ...: |
|
186 |
Example: |
|
187 |
||
12094 | 188 |
|newMeta notRecognizedAsClass someInstance| |
189 |
||
190 |
newMeta := Metaclass new. |
|
191 |
newMeta flags:0. |
|
192 |
||
193 |
notRecognizedAsClass := newMeta new. |
|
194 |
||
195 |
someInstance := notRecognizedAsClass new. |
|
196 |
Object errorSignal handle:[:ex | |
|
197 |
ex return |
|
198 |
] do:[ |
|
199 |
someInstance perform:#isNil |
|
200 |
] |
|
357 | 201 |
|
202 |
||
203 |
likewise, a doesNotUnderstand-notUnderstood can be handled: |
|
204 |
Example: |
|
205 |
||
12094 | 206 |
|newMeta funnyClass someInstance| |
207 |
||
208 |
newMeta := Metaclass new. |
|
209 |
||
210 |
funnyClass := newMeta new. |
|
211 |
funnyClass setSuperclass:nil. |
|
212 |
||
213 |
someInstance := funnyClass new. |
|
214 |
Object errorSignal handle:[:ex | |
|
215 |
ex return |
|
216 |
] do:[ |
|
217 |
someInstance perform:#isNil |
|
218 |
] |
|
357 | 219 |
|
220 |
||
362 | 221 |
more examples, which try to trick the VM ;-): |
12094 | 222 |
badly playing around with a classes internals ... |
223 |
||
224 |
|newClass someInstance| |
|
225 |
||
226 |
newClass := Class new. |
|
227 |
newClass setSuperclass:nil. |
|
228 |
someInstance := newClass new. |
|
229 |
someInstance inspect |
|
230 |
||
231 |
||
232 |
|newClass someInstance| |
|
233 |
||
234 |
newClass := Class new. |
|
235 |
newClass setSuperclass:newClass. |
|
236 |
someInstance := newClass new. |
|
237 |
someInstance inspect |
|
238 |
||
239 |
||
240 |
|newClass someInstance| |
|
241 |
||
242 |
newClass := Class new. |
|
243 |
newClass setSuperclass:1. |
|
244 |
someInstance := newClass new. |
|
245 |
someInstance inspect |
|
357 | 246 |
|
247 |
||
356 | 248 |
Example: |
12094 | 249 |
creating totally anonymous classes: |
250 |
||
251 |
|newClass someInstance| |
|
252 |
||
253 |
newClass := Class new. |
|
254 |
someInstance := newClass new. |
|
255 |
someInstance inspect |
|
356 | 256 |
|
357 | 257 |
|
356 | 258 |
Example: |
12094 | 259 |
creating totally anonymous metaclasses: |
260 |
||
261 |
|newMeta newClass someInstance| |
|
262 |
||
263 |
newMeta := Metaclass new. |
|
264 |
newClass := newMeta new. |
|
265 |
someInstance := newClass new. |
|
266 |
someInstance inspect |
|
267 |
||
268 |
||
269 |
PS: if you experiment with new behaviorLike objects, you may want |
|
270 |
to turn off the VM's debugPrintouts |
|
271 |
with: |
|
272 |
'Smalltalk debugPrinting:false' |
|
273 |
and: |
|
274 |
'Smalltalk infoPrinting:false' |
|
356 | 275 |
" |
47 | 276 |
! ! |
1 | 277 |
|
1760 | 278 |
!Behavior class methodsFor:'creating new classes'! |
1 | 279 |
|
280 |
new |
|
356 | 281 |
"creates and return a new behavior (which is like a class, |
282 |
but without the symbolic & name information). |
|
283 |
Not for normal applications. |
|
284 |
Sending the returned behavior the #new message gives you |
|
285 |
an instance if it. |
|
286 |
||
287 |
Notice: the returned class is given a superclass of Object; |
|
288 |
this allows for its new instances to be inspected and the like." |
|
1 | 289 |
|
290 |
|newClass| |
|
291 |
||
292 |
newClass := self basicNew. |
|
12094 | 293 |
newClass |
294 |
setSuperclass:Object |
|
295 |
methodDictionary:(MethodDictionary new) |
|
296 |
instSize:0 |
|
297 |
flags:(self flagBehavior). |
|
1 | 298 |
^ newClass |
356 | 299 |
|
300 |
" |
|
301 |
Behavior new <- a new behavior |
|
302 |
Behavior new new <- an instance of it |
|
303 |
ClassDescription new <- a new classDescription |
|
304 |
ClassDescription new new <- an instance of it |
|
305 |
Class new <- a new class |
|
306 |
Class new new <- an instance of it |
|
307 |
Metaclass new <- a new metaclass |
|
308 |
Metaclass new new <- an instance (i.e. a class) of it |
|
309 |
Metaclass new new new <- an instance of this new class |
|
310 |
" |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
311 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
312 |
"Modified: 7.6.1996 / 15:38:58 / stefan" |
1 | 313 |
! ! |
314 |
||
1760 | 315 |
!Behavior class methodsFor:'flag bit constants'! |
620 | 316 |
|
317 |
flagBehavior |
|
318 |
"return the flag code which marks Behavior-like instances. |
|
7190 | 319 |
Inline C-code and the VM check this single bit in the flag value when |
620 | 320 |
checking for behaviors." |
321 |
||
322 |
%{ /* NOCONTEXT */ |
|
323 |
/* this is defined as a primitive to get defines from stc.h */ |
|
324 |
||
8913 | 325 |
RETURN ( __mkSmallInteger(BEHAVIOR_INSTS) ); |
620 | 326 |
%} |
327 |
||
328 |
"consistency check: |
|
329 |
all class-entries must be behaviors; |
|
330 |
all behaviors must be flagged so (in its class's flags) |
|
331 |
(otherwise, VM will bark) |
|
332 |
all non-behaviors may not be flagged |
|
333 |
||
334 |
|bit| |
|
335 |
bit := Class flagBehavior. |
|
336 |
||
337 |
ObjectMemory allObjectsDo:[:o| |
|
338 |
o isBehavior ifTrue:[ |
|
12094 | 339 |
(o class flags bitTest:bit) ifFalse:[ |
340 |
self halt |
|
341 |
]. |
|
620 | 342 |
] ifFalse:[ |
12094 | 343 |
(o class flags bitTest:bit) ifTrue:[ |
344 |
self halt |
|
345 |
]. |
|
620 | 346 |
]. |
347 |
o class isBehavior ifFalse:[ |
|
12094 | 348 |
self halt |
620 | 349 |
] ifTrue:[ |
12094 | 350 |
(o class class flags bitTest:bit) ifFalse:[ |
351 |
self halt |
|
352 |
] |
|
620 | 353 |
] |
354 |
] |
|
355 |
" |
|
356 |
! |
|
357 |
||
358 |
flagBlock |
|
359 |
"return the flag code which marks Block-like instances. |
|
12094 | 360 |
The VM checks for either this bit or the blockLike bit in the flag |
2236 | 361 |
value when checking for blocks to be evaluated from bytecodes. |
362 |
However, compiled code only checks for the block bit." |
|
620 | 363 |
|
364 |
%{ /* NOCONTEXT */ |
|
365 |
/* this is defined as a primitive to get defines from stc.h */ |
|
366 |
||
8913 | 367 |
RETURN ( __mkSmallInteger(BLOCK_INSTS) ); |
620 | 368 |
%} |
369 |
! |
|
370 |
||
371 |
flagBlockContext |
|
372 |
"return the flag code which marks BlockContext-like instances. |
|
2226 | 373 |
The VM checks this single bit in the flag value when |
620 | 374 |
checking for blockContexts." |
375 |
||
376 |
%{ /* NOCONTEXT */ |
|
377 |
/* this is defined as a primitive to get defines from stc.h */ |
|
378 |
||
8913 | 379 |
RETURN ( __mkSmallInteger(BCONTEXT_INSTS) ); |
620 | 380 |
%} |
381 |
! |
|
382 |
||
2236 | 383 |
flagBlockLike |
384 |
"return the flag code which marks Block-like instances |
|
385 |
with respect to byteCode interpretation. |
|
12094 | 386 |
The VM checks for either this bit or the block bit in the flag |
2236 | 387 |
value when checking for blocks to be evaluated from bytecodes. |
388 |
However, compiled code only checks for the block bit." |
|
389 |
||
390 |
%{ /* NOCONTEXT */ |
|
391 |
/* this is defined as a primitive to get defines from stc.h */ |
|
392 |
||
8913 | 393 |
RETURN ( __mkSmallInteger(BLOCKLIKE_INSTS) ); |
2236 | 394 |
%} |
395 |
! |
|
396 |
||
620 | 397 |
flagBytes |
398 |
"return the flag code for byte-valued indexed instances. |
|
12094 | 399 |
The VM masks the flag value with the indexMask (maskIndexType) |
2226 | 400 |
and compares it to this flag value, when checking for byte valued |
401 |
variable instances." |
|
620 | 402 |
|
403 |
%{ /* NOCONTEXT */ |
|
404 |
/* this is defined as a primitive to get defines from stc.h */ |
|
405 |
||
8913 | 406 |
RETURN ( __mkSmallInteger(BYTEARRAY) ); |
620 | 407 |
%} |
408 |
" |
|
12094 | 409 |
Behavior flagBytes |
620 | 410 |
" |
411 |
! |
|
412 |
||
413 |
flagContext |
|
414 |
"return the flag code which marks Context-like instances. |
|
2226 | 415 |
The VM checks this single bit in the flag value when |
620 | 416 |
checking for contexts." |
417 |
||
418 |
%{ /* NOCONTEXT */ |
|
419 |
/* this is defined as a primitive to get defines from stc.h */ |
|
420 |
||
8913 | 421 |
RETURN ( __mkSmallInteger(CONTEXT_INSTS) ); |
620 | 422 |
%} |
423 |
! |
|
424 |
||
425 |
flagDoubles |
|
426 |
"return the flag code for double-valued indexed instances (i.e. 8-byte reals). |
|
12094 | 427 |
The VM masks the flag value with the indexMask (maskIndexType) |
2226 | 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 |
||
8913 | 434 |
RETURN ( __mkSmallInteger(DOUBLEARRAY) ); |
620 | 435 |
%} |
436 |
" |
|
12094 | 437 |
Behavior flagDoubles |
438 |
||
439 |
(ByteArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
440 |
(DoubleArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
441 |
(Object flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
620 | 442 |
" |
443 |
! |
|
444 |
||
7190 | 445 |
flagExternalBytes |
446 |
"return the flag code which marks ExternalBytes-like instances. |
|
447 |
Inline C-code and the VM check this single bit in the flag value when |
|
448 |
checking for an externalBytes-like objet." |
|
449 |
||
450 |
%{ /* NOCONTEXT */ |
|
451 |
/* this is defined as a primitive to get defines from stc.h */ |
|
452 |
||
8913 | 453 |
RETURN ( __mkSmallInteger(EXTERNALBYTES_INSTS) ); |
7190 | 454 |
%} |
455 |
! |
|
456 |
||
620 | 457 |
flagFloat |
458 |
"return the flag code which marks Float-like instances. |
|
7190 | 459 |
Inline C-code and the VM check this single bit in the flag value when |
2226 | 460 |
checking for a float." |
620 | 461 |
|
462 |
%{ /* NOCONTEXT */ |
|
463 |
/* this is defined as a primitive to get defines from stc.h */ |
|
464 |
||
8913 | 465 |
RETURN ( __mkSmallInteger(FLOAT_INSTS) ); |
620 | 466 |
%} |
467 |
! |
|
468 |
||
469 |
flagFloats |
|
470 |
"return the flag code for float-valued indexed instances (i.e. 4-byte reals). |
|
12094 | 471 |
The VM masks the flag value with the indexMask (maskIndexType) |
2226 | 472 |
and compares it to this flag value, when checking for double valued |
473 |
variable instances." |
|
620 | 474 |
|
475 |
%{ /* NOCONTEXT */ |
|
476 |
/* this is defined as a primitive to get defines from stc.h */ |
|
477 |
||
8913 | 478 |
RETURN ( __mkSmallInteger(FLOATARRAY) ); |
620 | 479 |
%} |
480 |
" |
|
12094 | 481 |
Behavior flagFloats |
620 | 482 |
" |
483 |
! |
|
484 |
||
1634 | 485 |
flagForSymbolic:aSymbol |
486 |
"return the flag code for indexed instances with aSymbolic type. |
|
12094 | 487 |
The argument may be one of |
488 |
#float, #double, |
|
489 |
#word, #signedWord, |
|
490 |
#long, #signedLong |
|
491 |
#longLong, #signedLongLong, |
|
492 |
#byte |
|
493 |
#weakObjects |
|
6104 | 494 |
For VW compatibility, also accept: |
12094 | 495 |
#objects, #bytes, #weak. |
6104 | 496 |
" |
1634 | 497 |
|
498 |
%{ /* NOCONTEXT */ |
|
499 |
if (aSymbol == @symbol(float)) { |
|
12094 | 500 |
RETURN ( __mkSmallInteger(FLOATARRAY) ); |
1634 | 501 |
} |
502 |
if (aSymbol == @symbol(double)) { |
|
12094 | 503 |
RETURN ( __mkSmallInteger(DOUBLEARRAY) ); |
1634 | 504 |
} |
505 |
if (aSymbol == @symbol(long)) { |
|
12094 | 506 |
RETURN ( __mkSmallInteger(LONGARRAY) ); |
1634 | 507 |
} |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
508 |
if (aSymbol == @symbol(longLong)) { |
12094 | 509 |
RETURN ( __mkSmallInteger(LONGLONGARRAY) ); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
510 |
} |
1634 | 511 |
if (aSymbol == @symbol(word)) { |
12094 | 512 |
RETURN ( __mkSmallInteger(WORDARRAY) ); |
1634 | 513 |
} |
514 |
if (aSymbol == @symbol(signedWord)) { |
|
12094 | 515 |
RETURN ( __mkSmallInteger(SWORDARRAY) ); |
1634 | 516 |
} |
517 |
if (aSymbol == @symbol(signedLong)) { |
|
12094 | 518 |
RETURN ( __mkSmallInteger(SLONGARRAY) ); |
1634 | 519 |
} |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
520 |
if (aSymbol == @symbol(signedLongLong)) { |
12094 | 521 |
RETURN ( __mkSmallInteger(SLONGLONGARRAY) ); |
6104 | 522 |
} |
523 |
if ((aSymbol == @symbol(byte)) || (aSymbol == @symbol(bytes))) { |
|
12094 | 524 |
RETURN ( __mkSmallInteger(BYTEARRAY) ); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
525 |
} |
6104 | 526 |
if (aSymbol == @symbol(objects)) { |
12094 | 527 |
RETURN ( __mkSmallInteger(POINTERARRAY) ); |
6104 | 528 |
} |
10605 | 529 |
if ((aSymbol == @symbol(weakObjects)) || (aSymbol == @symbol(weak))) { |
12094 | 530 |
RETURN ( __mkSmallInteger(WKPOINTERARRAY) ); |
1634 | 531 |
} |
532 |
%}. |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
533 |
^ 0 "/ not indexed |
10605 | 534 |
|
535 |
"Modified: / 07-06-2007 / 11:57:44 / cg" |
|
1634 | 536 |
! |
537 |
||
3141 | 538 |
flagJavaClass |
539 |
"return the flag code which marks JavaClass-like instances. |
|
540 |
The VM checks this single bit in the flag value when |
|
541 |
checking for a javaClass." |
|
542 |
||
543 |
%{ /* NOCONTEXT */ |
|
544 |
/* this is defined as a primitive to get defines from stc.h */ |
|
545 |
||
8913 | 546 |
RETURN ( __mkSmallInteger(JCLASS_INSTS) ); |
3141 | 547 |
%} |
548 |
! |
|
549 |
||
2801 | 550 |
flagJavaMethod |
551 |
"return the flag code which marks JavaMethod-like instances. |
|
7190 | 552 |
Inline C-code and the VM check this single bit in the flag value when |
2801 | 553 |
checking for a method." |
554 |
||
555 |
%{ /* NOCONTEXT */ |
|
556 |
/* this is defined as a primitive to get defines from stc.h */ |
|
557 |
||
8913 | 558 |
RETURN ( __mkSmallInteger(JMETHOD_INSTS) ); |
2801 | 559 |
%} |
560 |
! |
|
561 |
||
4307 | 562 |
flagLongLongs |
563 |
"return the flag code for longlong-valued indexed instances (i.e. 8-byte). |
|
12094 | 564 |
The VM masks the flag value with the indexMask (maskIndexType) |
565 |
and compares it to this flag value, when checking for |
|
4307 | 566 |
unsigned long valued variable instances." |
567 |
||
568 |
%{ /* NOCONTEXT */ |
|
569 |
/* this is defined as a primitive to get defines from stc.h */ |
|
570 |
||
8913 | 571 |
RETURN ( __mkSmallInteger(LONGLONGARRAY) ); |
4307 | 572 |
%} |
573 |
" |
|
12094 | 574 |
Behavior flagLongLongs |
4307 | 575 |
" |
576 |
! |
|
577 |
||
620 | 578 |
flagLongs |
579 |
"return the flag code for long-valued indexed instances (i.e. 4-byte). |
|
12094 | 580 |
The VM masks the flag value with the indexMask (maskIndexType) |
581 |
and compares it to this flag value, when checking for |
|
2226 | 582 |
unsigned long valued variable instances." |
620 | 583 |
|
584 |
%{ /* NOCONTEXT */ |
|
585 |
/* this is defined as a primitive to get defines from stc.h */ |
|
586 |
||
8913 | 587 |
RETURN ( __mkSmallInteger(LONGARRAY) ); |
620 | 588 |
%} |
589 |
" |
|
12094 | 590 |
Behavior flagLongs |
620 | 591 |
" |
592 |
! |
|
593 |
||
5743 | 594 |
flagMetaMethod |
595 |
"return the flag code which marks MetaMethod-like instances. |
|
7190 | 596 |
Inline C-code and the VM check this single bit in the flag value when |
5743 | 597 |
about to evaluate a method." |
598 |
||
599 |
%{ /* NOCONTEXT */ |
|
600 |
/* this is defined as a primitive to get defines from stc.h */ |
|
601 |
||
8913 | 602 |
RETURN ( __mkSmallInteger(METAMETHOD_INSTS) ); |
5743 | 603 |
%} |
604 |
! |
|
605 |
||
620 | 606 |
flagMethod |
607 |
"return the flag code which marks Method-like instances. |
|
7190 | 608 |
Inline C-code and the VM check this single bit in the flag value when |
2226 | 609 |
checking for a method." |
620 | 610 |
|
611 |
%{ /* NOCONTEXT */ |
|
612 |
/* this is defined as a primitive to get defines from stc.h */ |
|
613 |
||
8913 | 614 |
RETURN ( __mkSmallInteger(METHOD_INSTS) ); |
620 | 615 |
%} |
616 |
! |
|
617 |
||
618 |
flagNonObjectInst |
|
619 |
"return the flag code which marks instances which have a |
|
620 |
non-object instance variable (in slot 1). |
|
621 |
(these are ignored by the garbage collector)" |
|
622 |
||
623 |
%{ /* NOCONTEXT */ |
|
624 |
/* this is defined as a primitive to get defines from stc.h */ |
|
625 |
||
8913 | 626 |
RETURN ( __mkSmallInteger(NONOBJECT_INSTS) ); |
620 | 627 |
%} |
628 |
! |
|
629 |
||
630 |
flagNotIndexed |
|
631 |
"return the flag code for non-indexed instances. |
|
632 |
You have to mask the flag value with indexMask when comparing |
|
633 |
it with flagNotIndexed." |
|
634 |
||
635 |
^ 0 |
|
636 |
! |
|
637 |
||
638 |
flagPointers |
|
639 |
"return the flag code for pointer indexed instances (i.e. Array of object). |
|
12094 | 640 |
The VM masks the flag value with the indexMask (maskIndexType) |
641 |
and compares it to this flag value, when checking for |
|
2226 | 642 |
pointer variable instances." |
620 | 643 |
|
644 |
%{ /* NOCONTEXT */ |
|
645 |
/* this is defined as a primitive to get defines from stc.h */ |
|
646 |
||
8913 | 647 |
RETURN ( __mkSmallInteger(POINTERARRAY) ); |
620 | 648 |
%} |
649 |
" |
|
12094 | 650 |
Behavior flagPointers |
620 | 651 |
" |
652 |
! |
|
653 |
||
1383 | 654 |
flagRegular |
655 |
"return the flag code which marks regular instances." |
|
656 |
||
657 |
^ 0 |
|
658 |
||
659 |
"Created: 12.5.1996 / 17:53:36 / cg" |
|
660 |
! |
|
661 |
||
4307 | 662 |
flagSignedLongLongs |
663 |
"return the flag code for signed longlong-valued indexed instances (i.e. 8-byte). |
|
12094 | 664 |
The VM masks the flag value with the indexMask (maskIndexType) |
665 |
and compares it to this flag value, when checking for |
|
4307 | 666 |
signed long valued variable instances." |
667 |
||
668 |
%{ /* NOCONTEXT */ |
|
669 |
/* this is defined as a primitive to get defines from stc.h */ |
|
670 |
||
8913 | 671 |
RETURN ( __mkSmallInteger(SLONGLONGARRAY) ); |
4307 | 672 |
%} |
673 |
" |
|
674 |
Behavior flagSignedLongLongs |
|
675 |
" |
|
676 |
! |
|
677 |
||
1634 | 678 |
flagSignedLongs |
679 |
"return the flag code for signed long-valued indexed instances (i.e. 4-byte). |
|
12094 | 680 |
The VM masks the flag value with the indexMask (maskIndexType) |
681 |
and compares it to this flag value, when checking for |
|
2226 | 682 |
signed long valued variable instances." |
1634 | 683 |
|
684 |
%{ /* NOCONTEXT */ |
|
685 |
/* this is defined as a primitive to get defines from stc.h */ |
|
686 |
||
8913 | 687 |
RETURN ( __mkSmallInteger(SLONGARRAY) ); |
1634 | 688 |
%} |
689 |
" |
|
690 |
Behavior flagSignedLongs |
|
691 |
" |
|
692 |
! |
|
693 |
||
694 |
flagSignedWords |
|
695 |
"return the flag code for signed word-valued indexed instances (i.e. 2-byte). |
|
12094 | 696 |
The VM masks the flag value with the indexMask (maskIndexType) |
697 |
and compares it to this flag value, when checking for |
|
2226 | 698 |
signed word valued variable instances." |
1634 | 699 |
|
700 |
%{ /* NOCONTEXT */ |
|
701 |
/* this is defined as a primitive to get defines from stc.h */ |
|
702 |
||
8913 | 703 |
RETURN ( __mkSmallInteger(SWORDARRAY) ); |
1634 | 704 |
%} |
705 |
" |
|
706 |
Behavior flagSignedWords |
|
707 |
" |
|
708 |
! |
|
709 |
||
620 | 710 |
flagSymbol |
711 |
"return the flag code which marks Symbol-like instances. |
|
7190 | 712 |
Inline C-code and the VM check this single bit in the flag value when |
620 | 713 |
checking for symbols." |
714 |
||
715 |
%{ /* NOCONTEXT */ |
|
716 |
/* this is defined as a primitive to get defines from stc.h */ |
|
717 |
||
8913 | 718 |
RETURN ( __mkSmallInteger(SYMBOL_INSTS) ); |
620 | 719 |
%} |
720 |
! |
|
721 |
||
10605 | 722 |
flagWeak |
723 |
"return the flag code for weak-object-pointer indexed instances. |
|
12094 | 724 |
The VM masks the flag value with the indexMask (maskIndexType) |
725 |
and compares it to this flag value, when checking for |
|
10605 | 726 |
weak pointer variable instances." |
727 |
||
728 |
%{ /* NOCONTEXT */ |
|
729 |
/* this is defined as a primitive to get defines from stc.h */ |
|
730 |
||
731 |
RETURN ( __mkSmallInteger(WKPOINTERARRAY) ); |
|
732 |
%} |
|
733 |
" |
|
12094 | 734 |
Behavior flagWeak |
10605 | 735 |
" |
736 |
||
737 |
"Created: / 07-06-2007 / 11:59:12 / cg" |
|
738 |
! |
|
739 |
||
620 | 740 |
flagWeakPointers |
741 |
"return the flag code for weak pointer indexed instances (i.e. WeakArray). |
|
12094 | 742 |
The VM masks the flag value with the indexMask (maskIndexType) |
2226 | 743 |
and compares it to this flag value, when checking for weak pointers." |
620 | 744 |
|
745 |
%{ /* NOCONTEXT */ |
|
746 |
/* this is defined as a primitive to get defines from stc.h */ |
|
747 |
||
8913 | 748 |
RETURN ( __mkSmallInteger(WKPOINTERARRAY) ); |
620 | 749 |
%} |
750 |
! |
|
751 |
||
752 |
flagWords |
|
753 |
"return the flag code for word-valued indexed instances (i.e. 2-byte). |
|
12094 | 754 |
The VM masks the flag value with the indexMask (maskIndexType) |
755 |
and compares it to this flag value, when checking for |
|
2226 | 756 |
unsigned word valued variable instances." |
620 | 757 |
|
758 |
%{ /* NOCONTEXT */ |
|
759 |
/* this is defined as a primitive to get defines from stc.h */ |
|
760 |
||
8913 | 761 |
RETURN ( __mkSmallInteger(WORDARRAY) ); |
620 | 762 |
%} |
763 |
" |
|
12094 | 764 |
Behavior flagWords |
620 | 765 |
" |
766 |
! |
|
767 |
||
768 |
maskIndexType |
|
769 |
"return a mask to extract all index-type bits" |
|
770 |
||
771 |
%{ /* NOCONTEXT */ |
|
772 |
/* this is defined as a primitive to get defines from stc.h */ |
|
773 |
||
8913 | 774 |
RETURN ( __mkSmallInteger(ARRAYMASK) ); |
620 | 775 |
%} |
776 |
! ! |
|
777 |
||
8962 | 778 |
!Behavior class methodsFor:'helpers'! |
779 |
||
9849 | 780 |
classesSortedByLoadOrder:someClasses |
781 |
"return a copy of the given collection of classes, which is sorted |
|
782 |
by inheritance and superclass-of-any-private class. |
|
783 |
This is the optimal order for loading, and the required order for compilation" |
|
784 |
||
785 |
|remaining classesInLoadOrder| |
|
786 |
||
10008
85b80de0562a
fix private class dependency handling in #classesSortedByLoadOrder:
Stefan Vogel <sv@exept.de>
parents:
9849
diff
changeset
|
787 |
"private classes are not loaded directly, so ignore them" |
10866
49e2ad93cb32
#classesSortedByLoadOrder: - use IdentitySet
Stefan Vogel <sv@exept.de>
parents:
10854
diff
changeset
|
788 |
remaining := someClasses asIdentitySet reject:[:eachClass| eachClass isPrivate]. |
10008
85b80de0562a
fix private class dependency handling in #classesSortedByLoadOrder:
Stefan Vogel <sv@exept.de>
parents:
9849
diff
changeset
|
789 |
classesInLoadOrder := OrderedCollection new:(remaining size). |
85b80de0562a
fix private class dependency handling in #classesSortedByLoadOrder:
Stefan Vogel <sv@exept.de>
parents:
9849
diff
changeset
|
790 |
|
9849 | 791 |
[remaining notEmpty] whileTrue:[ |
12094 | 792 |
|thoseWithOtherSuperclasses thoseWhichCanBeLoadedNow| |
793 |
||
794 |
"find the next class(es) to be loaded. |
|
795 |
Consider first: |
|
796 |
all those, which do not have a superclass in the remaining set. |
|
797 |
and which do not use a shared pool defined in the remaining set" |
|
798 |
||
799 |
thoseWithOtherSuperclasses := |
|
800 |
remaining |
|
801 |
reject:[:eachClass | |
|
802 |
(remaining includes:eachClass superclass) |
|
803 |
or:[eachClass sharedPools contains:[:eachPoolSymbol| |
|
804 |
remaining contains:[:eachRemainingClass| eachPoolSymbol = eachRemainingClass name] |
|
805 |
] |
|
806 |
]. |
|
807 |
]. |
|
808 |
||
809 |
"second: the subset with all those having no private classes, |
|
810 |
or having private classes, whose superclasses are NOT in the remaining set" |
|
811 |
||
812 |
thoseWhichCanBeLoadedNow := |
|
813 |
thoseWithOtherSuperclasses |
|
814 |
reject:[:eachClass | |
|
815 |
eachClass allPrivateClasses contains:[:eachPrivateClass| |superClassesOwner| |
|
816 |
superClassesOwner := eachPrivateClass superclass. |
|
817 |
"take care of classes inheriting from nil or ProtoObject" |
|
818 |
superClassesOwner isBehavior ifTrue:[ |
|
819 |
superClassesOwner := superClassesOwner owningClassOrYourself. |
|
820 |
]. |
|
821 |
superClassesOwner ~~ eachClass |
|
822 |
and:[remaining includes:superClassesOwner] |
|
823 |
]. |
|
824 |
]. |
|
825 |
||
826 |
thoseWhichCanBeLoadedNow isEmpty ifTrue:[ |
|
827 |
thoseWithOtherSuperclasses isEmpty ifTrue:[ |
|
828 |
"this does not normally happen" |
|
829 |
self error:'superclass order is cyclic'. |
|
830 |
] ifFalse:[ |
|
831 |
"no class found, that may be loaded - maybe there is a cyclic |
|
832 |
dependency involving private classes. |
|
833 |
If you proceed here, private class dependencies are ignored |
|
834 |
for this pass" |
|
835 |
self error:'load order is cyclic (care for private classes)' mayProceed:true. |
|
836 |
thoseWhichCanBeLoadedNow := thoseWithOtherSuperclasses. |
|
837 |
]. |
|
838 |
]. |
|
839 |
remaining removeAllFoundIn:thoseWhichCanBeLoadedNow. |
|
840 |
classesInLoadOrder addAll:(thoseWhichCanBeLoadedNow asArray sort:[:a :b | a name < b name]). |
|
9849 | 841 |
]. |
842 |
^ classesInLoadOrder |
|
843 |
||
844 |
" |
|
12094 | 845 |
Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libbasic') |
846 |
Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libbasic3') |
|
847 |
Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libwidg') |
|
9849 | 848 |
" |
849 |
||
850 |
"Created: / 14-09-2006 / 11:21:25 / cg" |
|
851 |
! |
|
852 |
||
8962 | 853 |
commonSuperclassOf:listOfClassesOrClassNames |
11984 | 854 |
"given a list of classes, return the common superclass. |
855 |
A helper for the browser, some dialogs and some refactorings" |
|
856 |
||
8962 | 857 |
|common| |
858 |
||
859 |
listOfClassesOrClassNames do:[:classOrClassName | |
|
12094 | 860 |
|class| |
861 |
||
862 |
class := classOrClassName isBehavior |
|
863 |
ifTrue:[classOrClassName] |
|
864 |
ifFalse:[Smalltalk classNamed:classOrClassName]. |
|
865 |
||
866 |
common isNil ifTrue:[ |
|
867 |
common := class |
|
868 |
] ifFalse:[ |
|
869 |
(class isSubclassOf:common) ifTrue:[ |
|
870 |
"keep common" |
|
871 |
] ifFalse:[ |
|
872 |
(common isSubclassOf:class) ifTrue:[ |
|
873 |
common := class |
|
874 |
] ifFalse:[ |
|
875 |
common := common commonSuperclass:class. |
|
8962 | 876 |
|
877 |
"/ "walk up, checking" |
|
878 |
"/ found := false. |
|
879 |
"/ |
|
880 |
"/ common allSuperclassesDo:[:sup | |
|
881 |
"/ (found not and:[class isSubclassOf:sup]) ifTrue:[ |
|
882 |
"/ common := sup. |
|
883 |
"/ found := true. |
|
884 |
"/ ] |
|
885 |
"/ ]. |
|
886 |
"/ found ifFalse:[ |
|
887 |
"/ class allSuperclassesDo:[:sup | |
|
888 |
"/ (found not and:[common isSubclassOf:sup]) ifTrue:[ |
|
889 |
"/ common := sup. |
|
890 |
"/ found := true. |
|
891 |
"/ ] |
|
892 |
"/ ]. |
|
893 |
"/ ]. |
|
12094 | 894 |
] |
895 |
]. |
|
896 |
]. |
|
897 |
(common isNil or:[common == Object]) ifTrue:[^ common]. |
|
8962 | 898 |
]. |
899 |
^ common |
|
900 |
||
11984 | 901 |
" |
902 |
Class commonSuperclassOf:#(Array OrderedCollection Set) |
|
903 |
Class commonSuperclassOf:#(Character Number Point) |
|
904 |
" |
|
905 |
||
8962 | 906 |
"Modified: 17.6.1996 / 17:09:21 / stefan" |
907 |
"Modified: 5.9.1996 / 19:34:41 / cg" |
|
908 |
! ! |
|
909 |
||
4964 | 910 |
!Behavior class methodsFor:'misc'! |
911 |
||
912 |
autoload |
|
913 |
"for compatibility with autoloaded classes - dummy here" |
|
914 |
||
915 |
^ self |
|
916 |
||
917 |
! ! |
|
918 |
||
1760 | 919 |
!Behavior class methodsFor:'queries'! |
620 | 920 |
|
4332
c672bf261fbd
added query for class-def selectors.
Claus Gittinger <cg@exept.de>
parents:
4307
diff
changeset
|
921 |
definitionSelectorFirstParts |
c672bf261fbd
added query for class-def selectors.
Claus Gittinger <cg@exept.de>
parents:
4307
diff
changeset
|
922 |
"return a collection of partial class-definition selectors" |
c672bf261fbd
added query for class-def selectors.
Claus Gittinger <cg@exept.de>
parents:
4307
diff
changeset
|
923 |
|
c672bf261fbd
added query for class-def selectors.
Claus Gittinger <cg@exept.de>
parents:
4307
diff
changeset
|
924 |
^ #( #'subclass:' |
4657
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
925 |
#'variableSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
926 |
#'variableByteSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
927 |
#'variableWordSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
928 |
#'variableLongSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
929 |
#'variableSignedWordSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
930 |
#'variableSignedLongSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
931 |
#'variableLongLongSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
932 |
#'variableSignedLongLongSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
933 |
#'variableFloatSubclass:' |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
934 |
#'variableDoubleSubclass:' |
12094 | 935 |
) |
4332
c672bf261fbd
added query for class-def selectors.
Claus Gittinger <cg@exept.de>
parents:
4307
diff
changeset
|
936 |
! |
c672bf261fbd
added query for class-def selectors.
Claus Gittinger <cg@exept.de>
parents:
4307
diff
changeset
|
937 |
|
4428 | 938 |
definitionSelectors |
939 |
"return a collection class-definition selectors" |
|
940 |
||
12094 | 941 |
^ #( |
12113
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
942 |
#'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
943 |
#'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
944 |
#'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
945 |
#'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
946 |
#'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
947 |
#'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
948 |
#'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
949 |
#'variableLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
950 |
#'variableSignedLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
951 |
#'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
952 |
#'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
953 |
|
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
954 |
"/ ST/X private subclasses |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
955 |
|
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
956 |
#'subclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
957 |
#'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
958 |
#'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
959 |
#'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
960 |
#'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
961 |
#'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
962 |
#'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
963 |
#'variableLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
964 |
#'variableSignedLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
965 |
#'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
966 |
#'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
967 |
|
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
968 |
"/ ST/V subclass messages |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
969 |
|
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
970 |
#'subclass:instanceVariableNames:classVariableNames:poolDictionaries:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
971 |
#'variableByteSubclass:classVariableNames:poolDictionaries:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
972 |
#'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:' |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
973 |
|
12114
53048e0b6bf7
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12113
diff
changeset
|
974 |
"/ Dolphin |
12113
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
975 |
#'subclass:instanceVariableNames:classVariableNames:poolDictionaries:classInstanceVariableNames:' |
12094 | 976 |
) |
9194 | 977 |
! |
978 |
||
979 |
isBuiltInClass |
|
980 |
"return true if this class is known by the run-time-system. |
|
981 |
Here, true is returned for myself, false for subclasses." |
|
982 |
||
983 |
^ (self == Behavior class) or:[self == Behavior] |
|
984 |
||
985 |
"Modified: 23.4.1996 / 15:55:52 / cg" |
|
986 |
! ! |
|
987 |
||
988 |
!Behavior methodsFor:'Camp Smalltalk'! |
|
989 |
||
990 |
sunitAllSelectors |
|
991 |
^self allSelectors asSortedCollection asOrderedCollection |
|
992 |
! |
|
8531
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
993 |
|
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
994 |
sunitSelectors |
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
995 |
^self selectors asSortedCollection asOrderedCollection |
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
996 |
|
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
997 |
"Created: / 20.6.2000 / 11:54:54 / Sames" |
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
998 |
! ! |
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
999 |
|
7269 | 1000 |
!Behavior methodsFor:'Compatibility-Dolphin'! |
6329 | 1001 |
|
1002 |
allSubinstances |
|
11953 | 1003 |
"Compatibility method - do not use in new code. |
1004 |
Same as allSubInstances; added for Dolphin compatibility" |
|
1005 |
||
6865 | 1006 |
^ self allSubInstances |
1007 |
! |
|
1008 |
||
6889
7efa6d375ef7
+fromBinaryStoreBytes; +fromString.
Claus Gittinger <cg@exept.de>
parents:
6865
diff
changeset
|
1009 |
fromString:aString |
11953 | 1010 |
"reconstruct an instance of myself from the ascii-store string. |
1011 |
These bytes are typically the result from storing into a string/stream. |
|
1012 |
Same as readFrom:, for Dolphin compatibility." |
|
1013 |
||
6889
7efa6d375ef7
+fromBinaryStoreBytes; +fromString.
Claus Gittinger <cg@exept.de>
parents:
6865
diff
changeset
|
1014 |
^ self readFrom:aString |
7efa6d375ef7
+fromBinaryStoreBytes; +fromString.
Claus Gittinger <cg@exept.de>
parents:
6865
diff
changeset
|
1015 |
! |
7efa6d375ef7
+fromBinaryStoreBytes; +fromString.
Claus Gittinger <cg@exept.de>
parents:
6865
diff
changeset
|
1016 |
|
6865 | 1017 |
guid:aUUID |
11953 | 1018 |
"Compatibility method - do not use in new code. |
1019 |
An ignored dummy; for Dolphin compatibility." |
|
1020 |
||
1021 |
"/ intentionally left blank - for now |
|
11158 | 1022 |
! |
1023 |
||
1024 |
lookupMethod:selector |
|
11953 | 1025 |
"Compatibility method - do not use in new code. |
1026 |
Return the method for given selector aSelector or nil. |
|
1027 |
Only methods in the receiver - not in the superclass chain are returned. |
|
1028 |
For dolphin compatibility. |
|
1029 |
TODO: fixme if I am wrong, and dolphin does a full lookup here. If that is the case, |
|
1030 |
change to use lookupMethodFor:aSelector below." |
|
1031 |
||
11158 | 1032 |
^ self compiledMethodAt:selector |
6329 | 1033 |
! ! |
1034 |
||
7269 | 1035 |
!Behavior methodsFor:'Compatibility-Squeak'! |
4889 | 1036 |
|
9194 | 1037 |
defaultNameStemForInstances |
1038 |
"Answer a basis for names of default instances of the receiver" |
|
1039 |
||
1040 |
^ self name |
|
1041 |
||
1042 |
! |
|
5753
65cce9486ee9
added #lookupSelector: for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
5743
diff
changeset
|
1043 |
|
65cce9486ee9
added #lookupSelector: for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
5743
diff
changeset
|
1044 |
lookupSelector:aSelector |
65cce9486ee9
added #lookupSelector: for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
5743
diff
changeset
|
1045 |
"return the method for a selector - Squeak compatibility" |
65cce9486ee9
added #lookupSelector: for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
5743
diff
changeset
|
1046 |
|
65cce9486ee9
added #lookupSelector: for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
5743
diff
changeset
|
1047 |
^ self lookupMethodFor:aSelector |
6147 | 1048 |
! |
1049 |
||
12094 | 1050 |
selectorsWithArgs:numberOfArgs |
6147 | 1051 |
"Return all selectors defined in this class that take this number of arguments." |
1052 |
||
12094 | 1053 |
^ self selectors |
1054 |
select:[:sel | sel numArgs == numberOfArgs] |
|
6147 | 1055 |
|
1056 |
" |
|
12094 | 1057 |
SmallInteger selectorsWithArgs:0 |
1058 |
SmallInteger selectorsWithArgs:2 |
|
6147 | 1059 |
SmallInteger selectorsWithArgs:3 |
12094 | 1060 |
SmallInteger selectorsWithArgs:4 |
6147 | 1061 |
" |
4889 | 1062 |
! ! |
1063 |
||
7269 | 1064 |
!Behavior methodsFor:'Compatibility-VW'! |
5964 | 1065 |
|
1066 |
>> aSelector |
|
1067 |
"return the method stored under the given selector; nil if there is none" |
|
1068 |
||
1069 |
^ self compiledMethodAt:aSelector |
|
1070 |
||
1071 |
" |
|
1072 |
self compiledMethodAt:#compiledMethodAt: |
|
1073 |
self >> #compiledMethodAt: |
|
1074 |
" |
|
6115 | 1075 |
! |
1076 |
||
1077 |
fixedFieldsMask |
|
1078 |
"Mask on the format word to indicate the number of fixed fields in instances |
|
1079 |
of a behavior. If this is non-zero, the behavior must be pointer-type" |
|
1080 |
||
1081 |
^ 255 |
|
1082 |
||
1083 |
! |
|
1084 |
||
1085 |
format |
|
1086 |
"Answer an Integer that encodes the kinds and numbers of |
|
1087 |
variables of instances of the receiver. |
|
1088 |
||
1089 |
See instSize method for reference to the fixedFieldsMask bit mask of the format. |
|
1090 |
See isVariable method for reference to the indexableMask bit mask of the format. |
|
1091 |
See isBits method for reference to the pointersMask bit mask of the format. |
|
1092 |
All other bits of the format are unused and should be 0." |
|
1093 |
||
1094 |
"/ simulate a VW5i mask |
|
1095 |
||
1096 |
^ (self instSize |
|
1097 |
bitOr:( self isPointers ifTrue:[16384] ifFalse:[0])) |
|
1098 |
bitOr:( self isVariable ifTrue:[ 4096] ifFalse:[0]) |
|
1099 |
||
1100 |
! |
|
1101 |
||
10085 | 1102 |
getMethodDictionary |
1103 |
"ST 80 compatibility: return the receivers method dictionary." |
|
1104 |
||
1105 |
^ self methodDictionary |
|
1106 |
||
1107 |
"Modified: / 6.3.1998 / 15:45:50 / stefan" |
|
1108 |
! |
|
1109 |
||
6115 | 1110 |
instanceBehavior |
12094 | 1111 |
"Answer the instance behavior of the receiver. |
1112 |
This is the receiver for non metaclasses. |
|
6115 | 1113 |
Metaclass overrides this to answer a Metaclass's sole instance. |
1114 |
Same as #theNonMetaclass - for VW compatibility |
|
1115 |
" |
|
1116 |
||
1117 |
^ self theNonMetaclass |
|
1118 |
||
6968 | 1119 |
! |
1120 |
||
1121 |
shortName |
|
1122 |
^ self nameWithoutPrefix |
|
5964 | 1123 |
! ! |
1124 |
||
9196
a6d45629bb3b
readFromString allows for whiteSpace after reading
Claus Gittinger <cg@exept.de>
parents:
9194
diff
changeset
|
1125 |
|
12113
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
1126 |
|
620 | 1127 |
!Behavior methodsFor:'accessing'! |
1128 |
||
1129 |
addSelector:newSelector withMethod:newMethod |
|
1130 |
"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
|
1131 |
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
|
1132 |
|
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
1133 |
|oldMethod| |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
1134 |
|
7800 | 1135 |
(newSelector isMemberOf:Symbol) ifFalse:[ |
12094 | 1136 |
self error:'invalid selector'. |
7800 | 1137 |
]. |
8865
1f4824500318
#addSelectorWithMethod no longer returns a boolean
Stefan Vogel <sv@exept.de>
parents:
8857
diff
changeset
|
1138 |
|
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
1139 |
oldMethod := self compiledMethodAt:newSelector. |
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
1140 |
oldMethod notNil ifTrue:[ |
12094 | 1141 |
newMethod restricted:(oldMethod isRestricted). |
1142 |
newMethod setPrivacy:(oldMethod privacy) flushCaches:false. |
|
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
1143 |
]. |
11578 | 1144 |
|
1145 |
(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
|
1146 |
|
620 | 1147 |
" |
1148 |
if I have no subclasses, all we have to flush is cached |
|
1149 |
data for myself ... (actually, in any case all that needs |
|
1150 |
to be flushed is info for myself and all of my subclasses) |
|
1151 |
" |
|
1152 |
" |
|
1153 |
problem: this is slower; since looking for all subclasses is (currently) |
|
12094 | 1154 |
a bit slow :-( |
1155 |
We need the hasSubclasses-info bit in Behavior; now |
|
620 | 1156 |
|
1157 |
self withAllSubclassesDo:[:aClass | |
|
12094 | 1158 |
ObjectMemory flushInlineCachesFor:aClass withArgs:nargs. |
1159 |
ObjectMemory flushMethodCacheFor:aClass |
|
620 | 1160 |
]. |
1161 |
" |
|
1162 |
||
3805
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1163 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1164 |
"/ pass the selector AND the old method as changeArg |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1165 |
"/ - this allows for watchers to find out if its a new method or a method-change |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1166 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1167 |
self changed:#methodDictionary with:(Array with:newSelector with:oldMethod). |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1168 |
|
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1169 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1170 |
"/ also notify a change of Smalltalk; |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1171 |
"/ this allows a dependent of Smalltalk to watch all class |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1172 |
"/ changes (no need for observing all classes) |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1173 |
"/ - this allows for watchers to find out if its a new method or a method-change |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1174 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1175 |
Smalltalk changed:#methodInClass with:(Array with:self with:newSelector with:oldMethod). |
11574 | 1176 |
^ true. |
3805
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
1177 |
|
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
1178 |
"Created: / 11-12-1995 / 13:59:37 / cg" |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
1179 |
"Modified: / 04-08-2006 / 11:39:28 / cg" |
620 | 1180 |
! |
1181 |
||
9445 | 1182 |
basicAddSelector:newSelector withMethod:newMethod |
1183 |
"add the method given by 2nd argument under the selector given by |
|
1184 |
1st argument to the methodDictionary. Flushes all caches." |
|
1185 |
||
1186 |
|nargs | |
|
1187 |
||
1188 |
self primAddSelector:newSelector withMethod:newMethod. |
|
1189 |
||
1190 |
nargs := newSelector numArgs. |
|
1191 |
||
1192 |
ObjectMemory flushMethodCacheForSelector:newSelector. |
|
1193 |
"/ ObjectMemory flushMethodCache. |
|
1194 |
ObjectMemory flushInlineCachesWithArgs:nargs. |
|
1195 |
ObjectMemory flushCachesForSelector:newSelector |
|
1196 |
||
1197 |
"Created: / 15-07-2006 / 16:56:43 / cg" |
|
1198 |
! |
|
1199 |
||
10535 | 1200 |
basicRemoveSelector:aSelector |
12094 | 1201 |
"remove the selector, aSelector and its associated method |
10535 | 1202 |
from the methodDictionary" |
1203 |
||
1204 |
|dict newDict| |
|
1205 |
||
12094 | 1206 |
(Smalltalk |
1207 |
changeRequest:#methodInClassRemoved |
|
1208 |
with:(Array with:self with:aSelector)) ifFalse:[ |
|
1209 |
^ false |
|
11578 | 1210 |
]. |
1211 |
||
10535 | 1212 |
dict := self methodDictionary. |
1213 |
newDict := dict removeKeyAndCompress:aSelector. |
|
12094 | 1214 |
newDict isNil ifTrue:[ |
1215 |
^ false. |
|
10535 | 1216 |
]. |
1217 |
self setMethodDictionary:newDict. |
|
1218 |
||
1219 |
" |
|
1220 |
actually, we would do better with less flushing ... |
|
1221 |
" |
|
1222 |
"/ObjectMemory flushCaches. |
|
1223 |
||
1224 |
"yes, we can:" |
|
1225 |
ObjectMemory flushCachesForSelector:aSelector. |
|
1226 |
^ true |
|
1227 |
||
1228 |
"Modified: 12.6.1996 / 11:54:29 / stefan" |
|
1229 |
! |
|
1230 |
||
620 | 1231 |
flags |
1232 |
"return the receivers flag bits" |
|
1233 |
||
1234 |
^ flags |
|
1235 |
! |
|
1236 |
||
1237 |
instSize |
|
1238 |
"return the number of instance variables of the receiver. |
|
1239 |
This includes all superclass instance variables." |
|
1240 |
||
1241 |
^ instSize |
|
1242 |
! |
|
1243 |
||
1244 |
methodDictionary |
|
1634 | 1245 |
"return the receivers method dictionary." |
620 | 1246 |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
1247 |
^ methodDictionary |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1248 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1249 |
"Modified: 12.6.1996 / 13:47:08 / stefan" |
1634 | 1250 |
"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
|
1251 |
! |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1252 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1253 |
methodDictionary:dict |
12094 | 1254 |
"set the receivers method dictionary and flush inline caches." |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1255 |
|
1814 | 1256 |
dict isNil ifTrue:[ |
12094 | 1257 |
self error:'attempt to set methodDictionary to nil.' mayProceed:true. |
1258 |
^ self |
|
1814 | 1259 |
]. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1260 |
self setMethodDictionary:dict. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1261 |
ObjectMemory flushCaches. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1262 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1263 |
"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
|
1264 |
"Modified: 7.6.1996 / 08:39:51 / stefan" |
620 | 1265 |
! |
1266 |
||
7605
945a2cd8115c
moved some stuff from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7435
diff
changeset
|
1267 |
package |
945a2cd8115c
moved some stuff from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7435
diff
changeset
|
1268 |
"for protocol compatibility with class" |
945a2cd8115c
moved some stuff from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7435
diff
changeset
|
1269 |
|
945a2cd8115c
moved some stuff from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7435
diff
changeset
|
1270 |
^ '' |
945a2cd8115c
moved some stuff from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7435
diff
changeset
|
1271 |
! |
945a2cd8115c
moved some stuff from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7435
diff
changeset
|
1272 |
|
620 | 1273 |
removeSelector:aSelector |
12094 | 1274 |
"remove the selector, aSelector and its associated method |
620 | 1275 |
from the methodDictionary" |
1276 |
||
10535 | 1277 |
^ self basicRemoveSelector:aSelector |
620 | 1278 |
! |
1279 |
||
1280 |
selectors |
|
1281 |
"return the receivers selector array as an orderedCollection. |
|
1282 |
Notice: this may not be compatible with ST-80. |
|
1283 |
(should we return a Set ?)" |
|
1284 |
||
1814 | 1285 |
|md| |
1286 |
||
1967
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
1287 |
(md := self methodDictionary) isNil ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1288 |
'oops - nil methodDictionary' errorPrintCR. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1289 |
^ #() |
1814 | 1290 |
]. |
1291 |
^ md keys |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1292 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1293 |
"Modified: 7.6.1996 / 15:33:18 / stefan" |
1967
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
1294 |
"Modified: 12.11.1996 / 11:31:51 / cg" |
620 | 1295 |
! |
1296 |
||
1297 |
superclass |
|
1298 |
"return the receivers superclass" |
|
1299 |
||
1300 |
^ superclass |
|
1301 |
! |
|
1302 |
||
1303 |
superclass:aClass |
|
1304 |
"set the superclass - this actually creates a new class, |
|
1305 |
recompiling all methods for the new one. The receiving class stays |
|
1306 |
around anonymous to allow existing instances some life. |
|
1307 |
This may change in the future (adjusting existing instances)" |
|
1308 |
||
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1309 |
|owner ns name| |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1310 |
|
7435
c5afb1b0fd1b
Prepare for moving of SubclassInfo to subclass instcar in Class
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1311 |
Class flushSubclassInfo. |
620 | 1312 |
|
1313 |
"must flush caches since lookup chain changes" |
|
1314 |
ObjectMemory flushCaches. |
|
1315 |
||
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1316 |
"/ 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
|
1317 |
"/ 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
|
1318 |
"/ 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
|
1319 |
|
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1320 |
(owner := self owningClass) notNil ifTrue:[ |
12094 | 1321 |
ns := owner. |
1322 |
name := self nameWithoutPrefix asSymbol |
|
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1323 |
] ifFalse:[ |
12094 | 1324 |
ns := Smalltalk. |
1325 |
name := self name |
|
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1326 |
]. |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1327 |
|
8838
81ee56a49ac3
Rename #xxxRedefinitionSignal to #xxxRedefinitionNotification.
Stefan Vogel <sv@exept.de>
parents:
8725
diff
changeset
|
1328 |
Class classRedefinitionNotification answer:#keep do:[ |
12094 | 1329 |
Class nameSpaceQuerySignal answer:ns |
1330 |
do:[ |
|
1331 |
aClass |
|
1332 |
perform:(self definitionSelector) |
|
1333 |
withArguments:(Array with:name |
|
1334 |
with:(self instanceVariableString) |
|
1335 |
with:(self classVariableString) |
|
1336 |
with:'' "/ pool |
|
1337 |
with:(self category)). |
|
1338 |
] |
|
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1339 |
] |
2436 | 1340 |
|
3628
5b58b3b8644a
auto-keep package - when changing superclass
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
1341 |
"Modified: / 20.6.1998 / 18:17:37 / cg" |
620 | 1342 |
! ! |
1343 |
||
1344 |
!Behavior methodsFor:'autoload check'! |
|
1345 |
||
1346 |
autoload |
|
12094 | 1347 |
"force autoloading - do nothing here; |
620 | 1348 |
redefined in Autoload; see comment there" |
1349 |
||
1350 |
^ self |
|
1351 |
! |
|
1352 |
||
1353 |
isLoaded |
|
12094 | 1354 |
"return true, if the class has been loaded; |
620 | 1355 |
redefined in Autoload; see comment there" |
1356 |
||
1357 |
^ true |
|
6727 | 1358 |
! |
1359 |
||
1360 |
wasAutoloaded |
|
1361 |
"return true, if this class came into the system via an |
|
1362 |
autoload; false otherwise. |
|
1363 |
Returning false here. This allows different Behavior-like objects |
|
1364 |
(alien classes) to be handled by the browser as well." |
|
1365 |
||
1366 |
^ false |
|
1367 |
||
1368 |
"Created: 16.4.1996 / 16:27:16 / cg" |
|
620 | 1369 |
! ! |
1370 |
||
11160
4a413380f57c
support for dolphin binary storage format
Claus Gittinger <cg@exept.de>
parents:
11158
diff
changeset
|
1371 |
|
9639 | 1372 |
!Behavior methodsFor:'compiler interface'! |
1373 |
||
1374 |
browserClass |
|
12094 | 1375 |
"return the browser to use for this class - |
9639 | 1376 |
this can be redefined in special classes, to get different browsers" |
1377 |
||
1378 |
^ self class browserClass. |
|
1379 |
! |
|
1380 |
||
1381 |
compilerClass |
|
12094 | 1382 |
"return the compiler to use for this class - |
9639 | 1383 |
this can be redefined in special classes, to compile classes with |
1384 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1385 |
||
1386 |
^ self class compilerClass. |
|
1387 |
! |
|
1388 |
||
1389 |
evaluatorClass |
|
12094 | 1390 |
"return the compiler to use for expression evaluation for this class - |
9639 | 1391 |
this can be redefined in special classes, to evaluate expressions with |
1392 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1393 |
||
1394 |
^ self class evaluatorClass. |
|
1395 |
! |
|
1396 |
||
1397 |
formatterClass |
|
12094 | 1398 |
"return the parser to use for formatting (prettyPrinting) this class - |
9639 | 1399 |
this can be redefined in special classes, to format classes with |
1400 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1401 |
||
1402 |
^ self class formatterClass. |
|
620 | 1403 |
! |
1404 |
||
11990 | 1405 |
language |
12148
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1406 |
self halt. |
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1407 |
^ self class programmingLanguage |
11990 | 1408 |
|
1409 |
"Created: / 15-08-2009 / 09:06:46 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1410 |
! |
|
1411 |
||
9639 | 1412 |
parserClass |
12094 | 1413 |
"return the parser to use for parsing this class - |
9639 | 1414 |
this can be redefined in special classes, to parse classes with |
1415 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1416 |
||
1417 |
^ self class parserClass. |
|
1418 |
! |
|
1419 |
||
12148
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1420 |
programmingLanguage |
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1421 |
|
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1422 |
^self class programmingLanguage |
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1423 |
|
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1424 |
"Created: / 15-08-2009 / 09:06:46 / Jan Vrany <vranyj1@fel.cvut.cz>" |
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1425 |
! |
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
1426 |
|
9639 | 1427 |
subclassDefinerClass |
12094 | 1428 |
"Answer an evaluator class appropriate for evaluating definitions of new |
9639 | 1429 |
subclasses of this class." |
1430 |
||
1431 |
^ self class subclassDefinerClass. |
|
1432 |
! |
|
1433 |
||
1434 |
syntaxHighlighterClass |
|
12094 | 1435 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class - |
9639 | 1436 |
this can be redefined in special classes, to highlight classes with |
1437 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1438 |
||
1439 |
^ self class syntaxHighlighterClass. |
|
1440 |
! ! |
|
1441 |
||
1442 |
!Behavior methodsFor:'compiling'! |
|
1443 |
||
1444 |
compile:code notifying:requestor |
|
1445 |
"compile code, aString for this class; on any error, notify |
|
1446 |
requestor, anObject with the error reason. |
|
1447 |
Returns the new method or nil (on failure)." |
|
1448 |
||
1449 |
^ self compilerClass |
|
1450 |
compile:code |
|
1451 |
forClass:self |
|
1452 |
notifying:requestor |
|
1453 |
||
1454 |
"Modified: 13.12.1995 / 11:02:40 / cg" |
|
1455 |
"Created: 1.4.1997 / 23:43:43 / stefan" |
|
1456 |
! ! |
|
1457 |
||
1458 |
!Behavior methodsFor:'copying'! |
|
1459 |
||
12094 | 1460 |
canCloneFrom:anObject |
620 | 1461 |
"return true, if this class can clone an obsolete object as retrieved |
1462 |
by a binary load. Subclasses which do not want to have obsolete objects |
|
1463 |
be converted, should redefine this method to return false. |
|
1464 |
(However, conversion is never done silently in a binary load; you |
|
1465 |
have to have a handler for the binaryload errors and for the conversion |
|
1466 |
request signal.)" |
|
1467 |
||
1468 |
^ true |
|
1469 |
! |
|
1470 |
||
1471 |
cloneFrom:aPrototype |
|
1472 |
"return an instance of myself with variables initialized from |
|
1473 |
a prototype. This is used when instances of obsolete classes are |
|
12094 | 1474 |
binary loaded and a conversion is done on the obsolete object. |
620 | 1475 |
UserClasses may redefine this for better conversions." |
1476 |
||
4738 | 1477 |
|newInst indexed| |
620 | 1478 |
|
1479 |
indexed := false. |
|
1480 |
aPrototype class isVariable ifTrue:[ |
|
5321 | 1481 |
self isVariable ifTrue:[ |
1482 |
indexed := true. |
|
1483 |
]. |
|
1484 |
"otherwise, these are lost ..." |
|
620 | 1485 |
]. |
1486 |
indexed ifTrue:[ |
|
5321 | 1487 |
newInst := self basicNew:aPrototype basicSize |
620 | 1488 |
] ifFalse:[ |
5321 | 1489 |
newInst := self basicNew |
620 | 1490 |
]. |
1491 |
||
4692
055edf6e95af
Redefine #cloneFrom: using #cloneInstanceVariablesFrom:.
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
1492 |
newInst cloneInstanceVariablesFrom:aPrototype. |
055edf6e95af
Redefine #cloneFrom: using #cloneInstanceVariablesFrom:.
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
1493 |
|
620 | 1494 |
^ newInst |
1495 |
||
1496 |
" |
|
1497 |
Class withoutUpdatingChangesDo:[ |
|
5321 | 1498 |
Point subclass:#Point3D |
1499 |
instanceVariableNames:'z' |
|
1500 |
classVariableNames:'' |
|
1501 |
poolDictionaries:'' |
|
1502 |
category:'testing'. |
|
1503 |
(Point3D cloneFrom:1@2) inspect. |
|
620 | 1504 |
] |
1505 |
" |
|
1506 |
||
1507 |
" |
|
1508 |
Class withoutUpdatingChangesDo:[ |
|
5321 | 1509 |
Point variableSubclass:#Point3D |
1510 |
instanceVariableNames:'z' |
|
1511 |
classVariableNames:'' |
|
1512 |
poolDictionaries:'' |
|
1513 |
category:'testing'. |
|
1514 |
(Point3D cloneFrom:#(1 2 3)) inspect. |
|
620 | 1515 |
] |
1516 |
" |
|
1517 |
||
1518 |
" |
|
1519 |
|someObject| |
|
1520 |
||
1521 |
Class withoutUpdatingChangesDo:[ |
|
12094 | 1522 |
Object subclass:#TestClass1 |
5321 | 1523 |
instanceVariableNames:'foo bar' |
1524 |
classVariableNames:'' |
|
1525 |
poolDictionaries:'' |
|
1526 |
category:'testing'. |
|
1527 |
someObject := TestClass1 new. |
|
1528 |
someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'. |
|
12094 | 1529 |
Object subclass:#TestClass2 |
5321 | 1530 |
instanceVariableNames:'bar foo' |
1531 |
classVariableNames:'' |
|
1532 |
poolDictionaries:'' |
|
1533 |
category:'testing'. |
|
1534 |
(TestClass2 cloneFrom:someObject) inspect. |
|
620 | 1535 |
] |
1536 |
" |
|
1537 |
! |
|
1538 |
||
10949 | 1539 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
620 | 1540 |
"return a deep copy of the receiver |
1541 |
- return the receiver here - time will show if this is ok" |
|
1542 |
||
1543 |
^ self |
|
1544 |
! |
|
1545 |
||
1546 |
simpleDeepCopy |
|
1547 |
"return a deep copy of the receiver |
|
1548 |
- return the receiver here - time will show if this is ok" |
|
1549 |
||
1550 |
^ self |
|
1551 |
! ! |
|
1552 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1553 |
!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
|
1554 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1555 |
addChangeRecordForClassRemove:aClassName |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1556 |
"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
|
1557 |
Defined as dummy here, since Behavior does not know about change management. |
9194 | 1558 |
(only Classes do). This allows different Behavior-like objects |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1559 |
(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
|
1560 |
|
9194 | 1561 |
"Created: 16.4.1996 / 16:30:09 / cg" |
1562 |
"Modified: 16.4.1996 / 18:10:35 / cg" |
|
1563 |
! ! |
|
1564 |
||
1565 |
!Behavior methodsFor:'dummy fileOut'! |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1566 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1567 |
fileOutDefinitionOn:aStream |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1568 |
"dummy fileOut defined here. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1569 |
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
|
1570 |
(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
|
1571 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1572 |
^ self |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1573 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1574 |
"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
|
1575 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1576 |
|
620 | 1577 |
!Behavior methodsFor:'enumerating'! |
1578 |
||
1579 |
allDerivedInstancesDo:aBlock |
|
1580 |
"evaluate aBlock for all of my instances and all instances of subclasses. |
|
1581 |
This method is going to be removed for protocol compatibility with |
|
1582 |
other STs; use allSubInstancesDo:" |
|
1583 |
||
5862 | 1584 |
<resource:#obsolete> |
1585 |
||
9194 | 1586 |
self obsoleteMethodWarning:'use #allSubInstancesDo:'. |
1587 |
self allSubInstancesDo:aBlock |
|
1588 |
||
1589 |
" |
|
1590 |
StandardSystemView allDerivedInstancesDo:[:v | Transcript showCR:(v name)] |
|
1591 |
" |
|
1592 |
||
1593 |
"Modified: 31.7.1997 / 23:05:04 / cg" |
|
1594 |
! |
|
620 | 1595 |
|
1596 |
allInstancesDo:aBlock |
|
1597 |
"evaluate aBlock for all of my instances" |
|
1598 |
||
1599 |
ObjectMemory allInstancesOf:self do:[:anObject | |
|
1600 |
aBlock value:anObject |
|
1601 |
] |
|
1602 |
||
1603 |
" |
|
1422 | 1604 |
StandardSystemView allInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1605 |
" |
1606 |
! |
|
1607 |
||
7809 | 1608 |
allOwningclassesDo:aBlock |
1609 |
"evaluate aBlock for all of my owners (i.e. owner, owner-of-owner etc)." |
|
1610 |
||
1611 |
|owner| |
|
1612 |
||
1613 |
owner := self owningClass. |
|
1614 |
[owner notNil] whileTrue:[ |
|
12094 | 1615 |
aBlock value:owner. |
1616 |
owner := owner owningClass. |
|
9194 | 1617 |
]. |
1618 |
||
1619 |
" |
|
1620 |
Method::MethodWhoInfo allOwningclassesDo:[:c | Transcript showCR:(c name)] |
|
1621 |
" |
|
1622 |
! |
|
7809 | 1623 |
|
5368
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
1624 |
allSelectorsAndMethodsDo:aTwoArgBlock |
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
1625 |
"evaluate the argument, aBlock for all selectors of mySelf and my metaclass, |
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
1626 |
passing the corresponding method as second argument" |
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
1627 |
|
8353 | 1628 |
<resource: #obsolete> |
6076
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1629 |
self obsoleteMethodWarning:'use #instAndClassSelectorsAndMethodsDo:'. |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1630 |
|
6022 | 1631 |
self selectorsAndMethodsDo:aTwoArgBlock. |
9194 | 1632 |
self class selectorsAndMethodsDo:aTwoArgBlock. |
1633 |
! |
|
5368
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
1634 |
|
620 | 1635 |
allSubInstancesDo:aBlock |
1636 |
"evaluate aBlock for all of my instances and all instances of subclasses" |
|
1637 |
||
1638 |
ObjectMemory allObjectsDo:[:anObject | |
|
1639 |
(anObject isKindOf:self) ifTrue:[ |
|
1640 |
aBlock value:anObject |
|
1641 |
] |
|
1642 |
] |
|
1643 |
||
1644 |
" |
|
1422 | 1645 |
StandardSystemView allSubInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1646 |
" |
1647 |
! |
|
1648 |
||
1649 |
allSubclassesDo:aBlock |
|
1650 |
"evaluate aBlock for all of my subclasses. |
|
1651 |
There is no specific order, in which the entries are enumerated. |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1652 |
Warning: |
12094 | 1653 |
This will only enumerate globally known classes - for anonymous |
1654 |
behaviors, you have to walk over all instances of Behavior." |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1655 |
|
6931 | 1656 |
self allSubclassesInOrderDo:aBlock |
1657 |
||
1658 |
"/ self isMeta ifTrue:[ |
|
1659 |
"/ "/ metaclasses are not found via Smalltalk allClassesDo: |
|
1660 |
"/ "/ here, walk over classes and enumerate corresponding metas. |
|
1661 |
"/ self soleInstance allSubclassesDo:[:aSubClass | |
|
1662 |
"/ aBlock value:(aSubClass class) |
|
1663 |
"/ ]. |
|
1664 |
"/ ] ifFalse:[ |
|
1665 |
"/ Smalltalk allClassesDo:[:aClass | |
|
1666 |
"/ (aClass isSubclassOf:self) ifTrue:[ |
|
1667 |
"/ aBlock value:aClass |
|
1668 |
"/ ] |
|
1669 |
"/ ] |
|
1670 |
"/ ] |
|
620 | 1671 |
|
1672 |
" |
|
1422 | 1673 |
Collection allSubclassesDo:[:c | Transcript showCR:(c name)] |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1674 |
Collection class allSubclassesDo:[:c | Transcript showCR:(c name)] |
620 | 1675 |
" |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1676 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1677 |
"Modified: / 25.10.1997 / 21:17:13 / cg" |
9194 | 1678 |
! |
1679 |
||
1680 |
allSubclassesInOrderDo:aBlock |
|
620 | 1681 |
"evaluate aBlock for all of my subclasses. |
6931 | 1682 |
There is no specific order, in which the entries are enumerated. |
1683 |
Warning: |
|
12094 | 1684 |
This will only enumerate globally known classes - for anonymous |
1685 |
behaviors, you have to walk over all instances of Behavior." |
|
6931 | 1686 |
|
1687 |
|meta toDo cls| |
|
1688 |
||
1689 |
meta := self isMeta. |
|
12094 | 1690 |
|
6931 | 1691 |
toDo := OrderedCollection new. |
1692 |
toDo addAll:self theNonMetaclass subclasses. |
|
1693 |
[toDo notEmpty] whileTrue:[ |
|
12094 | 1694 |
cls := toDo removeFirst. |
1695 |
toDo addAll:cls subclasses. |
|
1696 |
meta ifTrue:[ |
|
1697 |
aBlock value:cls class. |
|
1698 |
] ifFalse:[ |
|
1699 |
aBlock value:cls. |
|
1700 |
] |
|
6931 | 1701 |
]. |
1702 |
||
1703 |
"/ self isMeta ifTrue:[ |
|
1704 |
"/ "/ metaclasses are not found via Smalltalk allClassesDo: |
|
1705 |
"/ "/ here, walk over classes and enumerate corresponding metas. |
|
1706 |
"/ self soleInstance allSubclassesDo:[:aSubClass | |
|
1707 |
"/ aBlock value:(aSubClass class) |
|
1708 |
"/ ]. |
|
1709 |
"/ ] ifFalse:[ |
|
1710 |
"/ Smalltalk allClassesDo:[:aClass | |
|
1711 |
"/ (aClass isSubclassOf:self) ifTrue:[ |
|
1712 |
"/ aBlock value:aClass |
|
1713 |
"/ ] |
|
1714 |
"/ ] |
|
1715 |
"/ ] |
|
620 | 1716 |
|
1717 |
" |
|
7435
c5afb1b0fd1b
Prepare for moving of SubclassInfo to subclass instcar in Class
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1718 |
Collection allSubclassesInOrderDo:[:c | Transcript showCR:(c name)] |
c5afb1b0fd1b
Prepare for moving of SubclassInfo to subclass instcar in Class
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1719 |
Collection class allSubclassesInOrderDo:[:c | Transcript showCR:(c name)] |
620 | 1720 |
" |
6931 | 1721 |
|
1722 |
"Modified: / 25.10.1997 / 21:17:13 / cg" |
|
9194 | 1723 |
! |
1724 |
||
1725 |
allSuperclassesDo:aBlock |
|
1726 |
"evaluate aBlock for all of my superclasses" |
|
1727 |
||
1728 |
|theClass| |
|
1729 |
||
1730 |
theClass := self superclass. |
|
1731 |
[theClass notNil] whileTrue:[ |
|
12094 | 1732 |
aBlock value:theClass. |
1733 |
theClass := theClass superclass |
|
9194 | 1734 |
] |
1735 |
||
1736 |
" |
|
1737 |
String allSuperclassesDo:[:c | Transcript showCR:(c name)] |
|
1738 |
" |
|
1739 |
! |
|
620 | 1740 |
|
6076
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1741 |
instAndClassMethodsDo:aOneArgBlock |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1742 |
"evaluate the argument, aBlock for all methods of mySelf and my metaclass |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1743 |
(i.e. for both instance- and class methods)" |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1744 |
|
6395
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
1745 |
self theNonMetaclass methodsDo:aOneArgBlock. |
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
1746 |
self theMetaclass methodsDo:aOneArgBlock. |
6076
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1747 |
! |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1748 |
|
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1749 |
instAndClassSelectorsAndMethodsDo:aTwoArgBlock |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1750 |
"evaluate the argument, aBlock for all selectors of mySelf and my metaclass, |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1751 |
passing the corresponding method as second argument" |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1752 |
|
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1753 |
self selectorsAndMethodsDo:aTwoArgBlock. |
9194 | 1754 |
self class selectorsAndMethodsDo:aTwoArgBlock. |
1755 |
! |
|
6076
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1756 |
|
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1757 |
methodsDo:aOneArgBlock |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1758 |
"evaluate the argument, aBlock for all my methods" |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1759 |
|
6395
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
1760 |
self methodDictionary do:aOneArgBlock |
6076
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1761 |
|
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1762 |
" |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1763 |
UndefinedObject methodsDo:[:m | Transcript showCR:m whoString] |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1764 |
UndefinedObject selectorsDo:[:sym | Transcript showCR:sym] |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1765 |
" |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1766 |
! |
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1767 |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1768 |
selectorsAndMethodsDo:aTwoArgBlock |
5368
192acdc335e6
added #allSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
1769 |
"evaluate the argument, aBlock for all my selectors, |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1770 |
passing the corresponding method as second argument" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1771 |
|
6395
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
1772 |
self methodDictionary keysAndValuesDo:aTwoArgBlock |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1773 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1774 |
"Created: / 27.10.1997 / 14:09:27 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1775 |
! |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1776 |
|
9194 | 1777 |
selectorsDo:aOneArgBlock |
1778 |
"evaluate the argument, aBlock for all my selectors" |
|
1779 |
||
1780 |
self methodDictionary keysDo:aOneArgBlock |
|
1781 |
! |
|
6076
2f75076b5597
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6030
diff
changeset
|
1782 |
|
620 | 1783 |
subclassesDo:aBlock |
1784 |
"evaluate the argument, aBlock for all immediate subclasses. |
|
1785 |
This will only enumerate globally known classes - for anonymous |
|
1786 |
behaviors, you have to walk over all instances of Behavior." |
|
1787 |
||
7435
c5afb1b0fd1b
Prepare for moving of SubclassInfo to subclass instcar in Class
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1788 |
"Do it the hard way. Subclasses redefine this" |
5581 | 1789 |
Smalltalk allClassesDo:[:aClass | |
12094 | 1790 |
(aClass superclass == self) ifTrue:[ |
1791 |
aBlock value:aClass |
|
1792 |
] |
|
9194 | 1793 |
] |
1794 |
! |
|
5638 | 1795 |
|
12094 | 1796 |
whichClassSatisfies: aBlock |
6727 | 1797 |
|superclass| |
1798 |
||
1799 |
(aBlock value: self) ifTrue: [^self]. |
|
1800 |
superclass := self superclass. |
|
12094 | 1801 |
^ superclass isNil |
1802 |
ifTrue: [nil] |
|
1803 |
ifFalse: [superclass whichClassSatisfies: aBlock] |
|
6727 | 1804 |
! |
1805 |
||
5638 | 1806 |
withAllSubclassesDo:aBlock |
1807 |
"evaluate aBlock for mySelf and all of my subclasses. |
|
1808 |
There is no specific order, in which the entries are enumerated. |
|
1809 |
Warning: |
|
12094 | 1810 |
This will only enumerate globally known classes - for anonymous |
1811 |
behaviors, you have to walk over all instances of Behavior." |
|
5638 | 1812 |
|
1813 |
aBlock value:self. |
|
1814 |
self allSubclassesDo:aBlock |
|
1815 |
||
1816 |
" |
|
1817 |
Collection withAllSubclassesDo:[:c | Transcript showCR:(c name)] |
|
1818 |
Collection class withAllSubclassesDo:[:c | Transcript showCR:(c name)] |
|
1819 |
" |
|
9194 | 1820 |
! |
1821 |
||
1822 |
withAllSuperclassesDo:aBlock |
|
1823 |
"evaluate aBlock for the class and all of its superclasses" |
|
1824 |
||
1825 |
|theSuperClass| |
|
1826 |
||
1827 |
aBlock value:self. |
|
1828 |
theSuperClass := self superclass. |
|
1829 |
[theSuperClass notNil] whileTrue:[ |
|
12094 | 1830 |
aBlock value:theSuperClass. |
1831 |
theSuperClass := theSuperClass superclass |
|
9194 | 1832 |
]. |
1833 |
||
1834 |
" |
|
12094 | 1835 |
String withAllSuperclassesDo:[:each| Transcript showCR:each] |
9194 | 1836 |
" |
1837 |
! ! |
|
1838 |
||
1839 |
!Behavior methodsFor:'initialization'! |
|
1 | 1840 |
|
620 | 1841 |
deinitialize |
1842 |
"deinitialize is sent to a class before it is physically unloaded. |
|
1843 |
This is only done with classes which have been loaded in from a binary |
|
1844 |
file. Classes may release any primitive memory or other stuff which is |
|
1845 |
not visible to smalltalk (for example, release internal memory). |
|
1846 |
The default action here is to do nothing." |
|
1847 |
||
1848 |
^ self |
|
1849 |
! |
|
1850 |
||
1 | 1851 |
initialize |
442 | 1852 |
"initialize is sent to a class either during startup, |
1853 |
(for all statically compiled-in classes) or after a class |
|
1854 |
has been loaded into the system (either bytecodes or machinecode). |
|
1855 |
The default action here is to do nothing." |
|
1 | 1856 |
|
1857 |
^ self |
|
1858 |
! |
|
1859 |
||
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1860 |
initializeWithAllPrivateClasses |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1861 |
"if implemented, send #initialize to myself and any private |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1862 |
class which does so. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1863 |
This is sent to a class after it |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1864 |
has been loaded into the system. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1865 |
Statically compiled classes are initialized by the VM" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1866 |
|
6412
4d6aaac56707
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
6395
diff
changeset
|
1867 |
(self class includesSelector:#initialize) ifTrue:[ |
12094 | 1868 |
self initialize. |
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1869 |
]. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1870 |
self privateClassesSorted do:[:aPrivateClass | |
12094 | 1871 |
aPrivateClass initializeWithAllPrivateClasses. |
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1872 |
]. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1873 |
|
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1874 |
"Created: / 13.5.1998 / 23:33:16 / cg" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1875 |
"Modified: / 13.5.1998 / 23:34:06 / cg" |
9194 | 1876 |
! |
1877 |
||
1878 |
postAutoload |
|
1879 |
"postAutoload is sent to a class after it has been autoloaded. |
|
1880 |
This gives it a chance to arrange for automatic unloading to be done |
|
1881 |
after a while ... |
|
1882 |
This is NOT sent to statically compiled in or explicitely filedIn |
|
1883 |
classes. |
|
1884 |
The default action here is to do nothing." |
|
1885 |
||
1886 |
^ self |
|
1887 |
! |
|
328 | 1888 |
|
1 | 1889 |
reinitialize |
442 | 1890 |
"reinitialize is sent to a class when an image has been restarted. |
1891 |
I.e. when the system is restarted. |
|
1892 |
This gives classes a chance to flush any device dependent or otherwise |
|
1893 |
obsolete data which may be a leftover from the previous live. |
|
1894 |
The default action here is to do nothing." |
|
1895 |
||
9194 | 1896 |
^ self |
1897 |
! ! |
|
1898 |
||
1899 |
!Behavior methodsFor:'instance creation'! |
|
1900 |
||
1901 |
basicNew |
|
54 | 1902 |
"return an instance of myself without indexed variables. |
1 | 1903 |
If the receiver-class has indexed instvars, the new object will have |
12094 | 1904 |
a basicSize of zero - |
91 | 1905 |
i.e. 'aClass basicNew' is equivalent to 'aClass basicNew:0'. |
54 | 1906 |
|
1 | 1907 |
** Do not redefine this method in any class **" |
1908 |
||
1909 |
%{ /* NOCONTEXT */ |
|
81 | 1910 |
REGISTER OBJ newobj; |
1911 |
REGISTER char *nextPtr; |
|
91 | 1912 |
unsigned int instsize; |
1913 |
REGISTER unsigned int nInstVars; |
|
1 | 1914 |
|
54 | 1915 |
/* |
369 | 1916 |
* the following ugly code is nothing more than a __new() followed |
54 | 1917 |
* by a nilling of the new instance. |
12094 | 1918 |
* Unrolled for a bit more speed since this is one of the central object |
91 | 1919 |
* allocation methods in the system |
54 | 1920 |
*/ |
1133 | 1921 |
nInstVars = __intVal(__INST(instSize)); |
92 | 1922 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
54 | 1923 |
|
983 | 1924 |
newobj = (OBJ) __newNextPtr; |
81 | 1925 |
nextPtr = ((char *)newobj) + instsize; |
1926 |
||
1927 |
/* |
|
12094 | 1928 |
* dont argue about the goto and the arrangement below - it saves |
81 | 1929 |
* an extra nil-compare and branch in the common case ... |
91 | 1930 |
* (i.e. if no GC is needed, we fall through without a branch) |
81 | 1931 |
*/ |
983 | 1932 |
if (nextPtr < __newEndPtr) { |
154 | 1933 |
_objPtr(newobj)->o_size = instsize; |
1934 |
/* o_allFlags(newobj) = 0; */ |
|
983 | 1935 |
/* _objPtr(newobj)->o_space = __newSpace; */ |
1936 |
o_setAllFlags(newobj, __newSpace); |
|
2894 | 1937 |
#ifdef __HAS_ALIGN4__ |
1938 |
/* |
|
1939 |
* if the alignment is 4, we are already sat, |
|
1940 |
* since a non-indexed object always has a word-aligned size. |
|
1941 |
*/ |
|
983 | 1942 |
__newNextPtr = nextPtr; |
91 | 1943 |
#else |
2894 | 1944 |
if (instsize & (__ALIGN__-1)) { |
1945 |
__newNextPtr = (char *)newobj + (instsize & ~(__ALIGN__-1)) + __ALIGN__; |
|
154 | 1946 |
} else { |
983 | 1947 |
__newNextPtr = nextPtr; |
154 | 1948 |
} |
91 | 1949 |
#endif |
82 | 1950 |
|
1951 |
ok: |
|
1133 | 1952 |
__InstPtr(newobj)->o_class = self; |
369 | 1953 |
__qSTORE(newobj, self); |
82 | 1954 |
|
154 | 1955 |
if (nInstVars) { |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1956 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 1957 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
82 | 1958 |
#else |
154 | 1959 |
REGISTER OBJ *op; |
82 | 1960 |
|
1133 | 1961 |
op = __InstPtr(newobj)->i_instvars; |
82 | 1962 |
|
154 | 1963 |
/* |
1964 |
* knowing that nil is 0 |
|
1965 |
*/ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1966 |
# if defined(FAST_OBJECT_MEMSET_DOUBLES_UNROLLED) |
154 | 1967 |
if (nInstVars > 8) { |
1968 |
*op++ = nil; /* for alignment */ |
|
1969 |
nInstVars--; |
|
1970 |
while (nInstVars >= 8) { |
|
1971 |
*(double *)op = 0.0; |
|
1972 |
((double *)op)[1] = 0.0; |
|
1973 |
((double *)op)[2] = 0.0; |
|
1974 |
((double *)op)[3] = 0.0; |
|
1975 |
op += 8; |
|
1976 |
nInstVars -= 8; |
|
1977 |
} |
|
1978 |
} |
|
1979 |
while (nInstVars != 0) { |
|
1980 |
*op++ = 0; |
|
1981 |
nInstVars--; |
|
1982 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1983 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1984 |
# if defined(FAST_OBJECT_MEMSET_LONGLONG_UNROLLED) |
154 | 1985 |
if (nInstVars > 8) { |
1986 |
*op++ = nil; /* for alignment */ |
|
1987 |
nInstVars--; |
|
1988 |
while (nInstVars >= 8) { |
|
1989 |
*(long long *)op = 0; |
|
1990 |
((long long *)op)[1] = 0; |
|
1991 |
((long long *)op)[2] = 0; |
|
1992 |
((long long *)op)[3] = 0; |
|
1993 |
op += 8; |
|
1994 |
nInstVars -= 8; |
|
1995 |
} |
|
1996 |
} |
|
1997 |
while (nInstVars != 0) { |
|
1998 |
*op++ = 0; |
|
1999 |
nInstVars--; |
|
2000 |
} |
|
91 | 2001 |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2002 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2003 |
# if defined(FAST_OBJECT_MEMSET_WORDS_UNROLLED) |
154 | 2004 |
while (nInstVars >= 8) { |
2005 |
*op = nil; |
|
2006 |
*(op+1) = nil; |
|
2007 |
*(op+2) = nil; |
|
2008 |
*(op+3) = nil; |
|
2009 |
*(op+4) = nil; |
|
2010 |
*(op+5) = nil; |
|
2011 |
*(op+6) = nil; |
|
2012 |
*(op+7) = nil; |
|
2013 |
op += 8; |
|
2014 |
nInstVars -= 8; |
|
2015 |
} |
|
2016 |
while (nInstVars != 0) { |
|
2017 |
*op++ = nil; |
|
2018 |
nInstVars--; |
|
2019 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2020 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2021 |
# if defined(FAST_MEMSET) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2022 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
91 | 2023 |
# else |
154 | 2024 |
do { |
2025 |
*op++ = nil; |
|
2026 |
nInstVars--; |
|
2027 |
} while (nInstVars != 0); |
|
82 | 2028 |
# endif |
2029 |
# endif |
|
2030 |
# endif |
|
2031 |
# endif |
|
2032 |
#endif |
|
154 | 2033 |
} |
2034 |
RETURN ( newobj ); |
|
81 | 2035 |
} |
54 | 2036 |
|
92 | 2037 |
/* |
2038 |
* the slow case - a GC will occur |
|
2039 |
*/ |
|
834 | 2040 |
__PROTECT_CONTEXT__ |
3980
8f9443e37693
renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents:
3935
diff
changeset
|
2041 |
newobj = __STX___new(instsize); |
834 | 2042 |
__UNPROTECT_CONTEXT__ |
82 | 2043 |
if (newobj != nil) goto ok; |
9194 | 2044 |
%} |
2045 |
. |
|
2046 |
" |
|
2047 |
memory allocation failed. |
|
2048 |
When we arrive here, there was no memory, even after |
|
12094 | 2049 |
a garbage collect. |
2050 |
This means, that the VM wanted to get some more memory from the |
|
9194 | 2051 |
Operatingsystem, which was not kind enough to give it. |
2052 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 2053 |
" |
127 | 2054 |
^ ObjectMemory allocationFailureSignal raise. |
1 | 2055 |
! |
2056 |
||
9194 | 2057 |
basicNew:anInteger |
1 | 2058 |
"return an instance of myself with anInteger indexed variables. |
2059 |
If the receiver-class has no indexed instvars, this is only allowed |
|
2060 |
if the argument, anInteger is zero. |
|
2061 |
** Do not redefine this method in any class **" |
|
2062 |
||
2063 |
%{ /* NOCONTEXT */ |
|
2064 |
||
2065 |
OBJ newobj; |
|
154 | 2066 |
unsigned INT instsize, nInstVars; |
2067 |
INT nindexedinstvars; |
|
92 | 2068 |
unsigned INT flags; |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2069 |
#if ! defined(FAST_ARRAY_MEMSET) |
1 | 2070 |
REGISTER char *cp; |
2071 |
short *sp; |
|
2072 |
long *lp; |
|
2073 |
#endif |
|
2074 |
REGISTER OBJ *op; |
|
2075 |
float *fp; |
|
2076 |
double *dp; |
|
2077 |
||
249 | 2078 |
if (__isSmallInteger(anInteger)) { |
12094 | 2079 |
nindexedinstvars = __intVal(anInteger); |
2080 |
if (nindexedinstvars >= 0) { |
|
2081 |
nInstVars = __intVal(__INST(instSize)); |
|
2082 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
|
2083 |
switch (flags) { |
|
2084 |
case BYTEARRAY: |
|
2085 |
instsize = OHDR_SIZE + nindexedinstvars; |
|
2086 |
if (nInstVars == 0) { |
|
2087 |
if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */ |
|
2088 |
/* |
|
2089 |
* the most common case |
|
2090 |
*/ |
|
2091 |
__qCheckedNew(newobj, instsize); |
|
2092 |
__InstPtr(newobj)->o_class = self; |
|
2093 |
__qSTORE(newobj, self); |
|
7858
65d77eb25fda
Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents:
7809
diff
changeset
|
2094 |
|
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2095 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
12094 | 2096 |
nInstVars = nindexedinstvars >> 2; |
2097 |
if (nindexedinstvars & 3) nInstVars++; |
|
2098 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
|
357 | 2099 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2100 |
# if defined(FAST_ARRAY_MEMSET) |
12094 | 2101 |
memset(__InstPtr(newobj)->i_instvars, 0, nindexedinstvars); |
357 | 2102 |
# else |
12094 | 2103 |
cp = (char *)__InstPtr(newobj)->i_instvars; |
2104 |
while (nindexedinstvars >= sizeof(long)) { |
|
2105 |
*(long *)cp = 0; |
|
2106 |
cp += sizeof(long); |
|
2107 |
nindexedinstvars -= sizeof(long); |
|
2108 |
} |
|
2109 |
while (nindexedinstvars--) |
|
2110 |
*cp++ = '\0'; |
|
357 | 2111 |
# endif |
92 | 2112 |
#endif |
12094 | 2113 |
RETURN ( newobj ); |
2114 |
} |
|
2115 |
} else { |
|
2116 |
instsize += __OBJS2BYTES__(nInstVars); |
|
2117 |
} |
|
2118 |
__PROTECT_CONTEXT__ |
|
2119 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2120 |
__UNPROTECT_CONTEXT__ |
|
2121 |
if (newobj == nil) { |
|
2122 |
break; |
|
2123 |
} |
|
2124 |
__InstPtr(newobj)->o_class = self; |
|
2125 |
__qSTORE(newobj, self); |
|
369 | 2126 |
|
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2127 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
12094 | 2128 |
nInstVars = (instsize-OHDR_SIZE) >> 2; |
2129 |
if (instsize & 3) nInstVars++; |
|
2130 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
|
357 | 2131 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2132 |
# if defined(FAST_ARRAY_MEMSET) |
12094 | 2133 |
/* |
2134 |
* knowing that nil is 0 |
|
2135 |
*/ |
|
2136 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
|
357 | 2137 |
# else |
12094 | 2138 |
op = __InstPtr(newobj)->i_instvars; |
2139 |
while (nInstVars--) |
|
2140 |
*op++ = nil; |
|
2141 |
cp = (char *)op; |
|
2142 |
while (nindexedinstvars >= sizeof(long)) { |
|
2143 |
*(long *)cp = 0; |
|
2144 |
cp += sizeof(long); |
|
2145 |
nindexedinstvars -= sizeof(long); |
|
2146 |
} |
|
2147 |
while (nindexedinstvars--) |
|
2148 |
*cp++ = '\0'; |
|
357 | 2149 |
# endif |
1 | 2150 |
#endif |
12094 | 2151 |
RETURN ( newobj ); |
2152 |
break; |
|
2153 |
||
2154 |
case WORDARRAY: |
|
2155 |
case SWORDARRAY: |
|
2156 |
instsize = OHDR_SIZE + |
|
2157 |
__OBJS2BYTES__(nInstVars) + |
|
2158 |
nindexedinstvars * 2; |
|
2159 |
__PROTECT_CONTEXT__ |
|
2160 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2161 |
__UNPROTECT_CONTEXT__ |
|
2162 |
if (newobj == nil) { |
|
2163 |
break; |
|
2164 |
} |
|
2165 |
__InstPtr(newobj)->o_class = self; |
|
2166 |
__qSTORE(newobj, self); |
|
369 | 2167 |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2168 |
#if defined(FAST_ARRAY_MEMSET) |
12094 | 2169 |
/* |
2170 |
* knowing that nil is 0 |
|
2171 |
*/ |
|
2172 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
|
1 | 2173 |
#else |
12094 | 2174 |
op = __InstPtr(newobj)->i_instvars; |
2175 |
while (nInstVars--) |
|
2176 |
*op++ = nil; |
|
2177 |
sp = (short *)op; |
|
2178 |
while (nindexedinstvars--) |
|
2179 |
*sp++ = 0; |
|
1 | 2180 |
#endif |
12094 | 2181 |
RETURN ( newobj ); |
2182 |
break; |
|
2183 |
||
2184 |
case LONGARRAY: |
|
2185 |
case SLONGARRAY: |
|
2186 |
instsize = OHDR_SIZE + |
|
2187 |
__OBJS2BYTES__(nInstVars) + |
|
2188 |
nindexedinstvars * 4; |
|
2189 |
__PROTECT_CONTEXT__ |
|
2190 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2191 |
__UNPROTECT_CONTEXT__ |
|
2192 |
if (newobj == nil) { |
|
2193 |
break; |
|
2194 |
} |
|
2195 |
__InstPtr(newobj)->o_class = self; |
|
2196 |
__qSTORE(newobj, self); |
|
369 | 2197 |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2198 |
#if defined(memset4) |
12094 | 2199 |
/* |
2200 |
* knowing that nil is 0 |
|
2201 |
*/ |
|
2202 |
{ |
|
2203 |
int n4 = nInstVars + nindexedinstvars; |
|
2204 |
||
2205 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
|
2206 |
} |
|
1 | 2207 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2208 |
# if defined(FAST_ARRAY_MEMSET) |
12094 | 2209 |
/* |
2210 |
* knowing that nil is 0 |
|
2211 |
*/ |
|
2212 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
|
1 | 2213 |
# else |
12094 | 2214 |
op = __InstPtr(newobj)->i_instvars; |
2215 |
while (nInstVars--) |
|
2216 |
*op++ = nil; |
|
2217 |
lp = (long *)op; |
|
2218 |
while (nindexedinstvars--) |
|
2219 |
*lp++ = 0; |
|
1 | 2220 |
# endif |
2221 |
#endif |
|
12094 | 2222 |
RETURN ( newobj ); |
2223 |
break; |
|
2224 |
||
2225 |
case LONGLONGARRAY: |
|
2226 |
case SLONGLONGARRAY: |
|
2227 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2228 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2229 |
#ifdef __NEED_LONGLONG_ALIGN |
12094 | 2230 |
instsize = ((instsize-1) + __LONGLONG_ALIGN) & ~(__LONGLONG_ALIGN-1); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2231 |
#endif |
12094 | 2232 |
instsize += nindexedinstvars * 8; |
2233 |
||
2234 |
__PROTECT_CONTEXT__ |
|
2235 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2236 |
__UNPROTECT_CONTEXT__ |
|
2237 |
if (newobj == nil) { |
|
2238 |
break; |
|
2239 |
} |
|
2240 |
__InstPtr(newobj)->o_class = self; |
|
2241 |
__qSTORE(newobj, self); |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2242 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2243 |
#if defined(memset4) |
12094 | 2244 |
{ |
2245 |
int n4 = (instsize-OHDR_SIZE) / 4; |
|
2246 |
||
2247 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
|
2248 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2249 |
#else |
12094 | 2250 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2251 |
#endif |
12094 | 2252 |
RETURN ( newobj ); |
2253 |
break; |
|
2254 |
||
2255 |
case FLOATARRAY: |
|
2256 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
2257 |
instsize += nindexedinstvars * sizeof(float); |
|
2258 |
||
2259 |
__PROTECT_CONTEXT__ |
|
2260 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2261 |
__UNPROTECT_CONTEXT__ |
|
2262 |
if (newobj == nil) { |
|
2263 |
break; |
|
2264 |
} |
|
2265 |
__InstPtr(newobj)->o_class = self; |
|
2266 |
__qSTORE(newobj, self); |
|
2267 |
||
2268 |
op = __InstPtr(newobj)->i_instvars; |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2269 |
#if defined(__FLOAT0_IS_INT0) /* knowin that float 0.0 is all-zeros */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2270 |
# if defined(memset4) |
12094 | 2271 |
{ |
2272 |
int n4 = (instsize-OHDR_SIZE) / 4; |
|
2273 |
||
2274 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
|
2275 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2276 |
# else |
12094 | 2277 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2278 |
# endif |
3870
ea7a0f0db4be
use memset to initialize float- and doubleArrays, if float0/double0 is int0
Claus Gittinger <cg@exept.de>
parents:
3805
diff
changeset
|
2279 |
#else |
12094 | 2280 |
while (nInstVars--) |
2281 |
*op++ = nil; |
|
2282 |
fp = (float *)op; |
|
2283 |
while (nindexedinstvars--) |
|
2284 |
*fp++ = 0.0; |
|
3870
ea7a0f0db4be
use memset to initialize float- and doubleArrays, if float0/double0 is int0
Claus Gittinger <cg@exept.de>
parents:
3805
diff
changeset
|
2285 |
#endif |
12094 | 2286 |
RETURN ( newobj ); |
2287 |
break; |
|
2288 |
||
2289 |
case DOUBLEARRAY: |
|
2290 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2291 |
#ifdef __NEED_DOUBLE_ALIGN |
12094 | 2292 |
instsize = ((instsize-1) + __DOUBLE_ALIGN) & ~(__DOUBLE_ALIGN-1); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2293 |
#endif |
12094 | 2294 |
instsize += nindexedinstvars * sizeof(double); |
2295 |
||
2296 |
__PROTECT_CONTEXT__ |
|
2297 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2298 |
__UNPROTECT_CONTEXT__ |
|
2299 |
if (newobj == nil) { |
|
2300 |
break; |
|
2301 |
} |
|
2302 |
__InstPtr(newobj)->o_class = self; |
|
2303 |
__qSTORE(newobj, self); |
|
369 | 2304 |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2305 |
#if defined(__DOUBLE0_IS_INT0) /* knowin that double 0.0 is all-zeros */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2306 |
# ifdef memset4 |
12094 | 2307 |
{ |
2308 |
int n4 = (instsize-OHDR_SIZE) / 4; |
|
2309 |
||
2310 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
|
2311 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2312 |
# else |
12094 | 2313 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2314 |
# endif |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2315 |
#else |
12094 | 2316 |
op = __InstPtr(newobj)->i_instvars; |
2317 |
while (nInstVars--) |
|
2318 |
*op++ = nil; |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2319 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2320 |
# ifdef __NEED_DOUBLE_ALIGN |
12094 | 2321 |
/* |
2322 |
* care for double alignment |
|
2323 |
* add filler. |
|
2324 |
*/ |
|
2325 |
if ((INT)op & (__DOUBLE_ALIGN-1)) { |
|
2326 |
*op++ = nil; |
|
2327 |
} |
|
3870
ea7a0f0db4be
use memset to initialize float- and doubleArrays, if float0/double0 is int0
Claus Gittinger <cg@exept.de>
parents:
3805
diff
changeset
|
2328 |
# endif |
12094 | 2329 |
dp = (double *)op; |
2330 |
while (nindexedinstvars--) |
|
2331 |
*dp++ = 0.0; |
|
3870
ea7a0f0db4be
use memset to initialize float- and doubleArrays, if float0/double0 is int0
Claus Gittinger <cg@exept.de>
parents:
3805
diff
changeset
|
2332 |
#endif |
12094 | 2333 |
RETURN ( newobj ); |
2334 |
break; |
|
2335 |
||
2336 |
case WKPOINTERARRAY: |
|
2337 |
case POINTERARRAY: |
|
2338 |
nInstVars += nindexedinstvars; |
|
2339 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
2340 |
__PROTECT_CONTEXT__ |
|
2341 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2342 |
__UNPROTECT_CONTEXT__ |
|
2343 |
if (newobj == nil) { |
|
2344 |
break; |
|
2345 |
} |
|
2346 |
__InstPtr(newobj)->o_class = self; |
|
2347 |
__qSTORE(newobj, self); |
|
369 | 2348 |
|
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2349 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
12094 | 2350 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 2351 |
#else |
12094 | 2352 |
/* |
2353 |
* knowing that nil is 0 |
|
2354 |
*/ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2355 |
# ifdef sparc |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2356 |
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2357 |
# endif |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2358 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2359 |
# if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED) |
12094 | 2360 |
op = __InstPtr(newobj)->i_instvars; |
2361 |
if (nInstVars > 8) { |
|
2362 |
*op++ = nil; /* for alignment */ |
|
2363 |
nInstVars--; |
|
2364 |
while (nInstVars >= 8) { |
|
2365 |
*(double *)op = 0.0; |
|
2366 |
((double *)op)[1] = 0.0; |
|
2367 |
((double *)op)[2] = 0.0; |
|
2368 |
((double *)op)[3] = 0.0; |
|
2369 |
op += 8; |
|
2370 |
nInstVars -= 8; |
|
2371 |
} |
|
2372 |
} |
|
2373 |
while (nInstVars) { |
|
2374 |
*op++ = 0; |
|
2375 |
nInstVars--; |
|
2376 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2377 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2378 |
# if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED) |
12094 | 2379 |
op = __InstPtr(newobj)->i_instvars; |
2380 |
if (nInstVars > 8) { |
|
2381 |
*op++ = nil; /* for alignment */ |
|
2382 |
nInstVars--; |
|
2383 |
while (nInstVars >= 8) { |
|
2384 |
*(long long *)op = 0; |
|
2385 |
((long long *)op)[1] = 0; |
|
2386 |
((long long *)op)[2] = 0; |
|
2387 |
((long long *)op)[3] = 0; |
|
2388 |
op += 8; |
|
2389 |
nInstVars -= 8; |
|
2390 |
} |
|
2391 |
} |
|
2392 |
while (nInstVars) { |
|
2393 |
*op++ = 0; |
|
2394 |
nInstVars--; |
|
2395 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2396 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2397 |
# if defined(FAST_ARRAY_MEMSET) |
12094 | 2398 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
91 | 2399 |
# else |
12094 | 2400 |
op = __InstPtr(newobj)->i_instvars; |
2401 |
while (nInstVars--) |
|
2402 |
*op++ = nil; |
|
82 | 2403 |
# endif |
2404 |
# endif |
|
1 | 2405 |
# endif |
2406 |
#endif |
|
12094 | 2407 |
RETURN ( newobj ); |
2408 |
break; |
|
2409 |
||
2410 |
default: |
|
2411 |
/* |
|
2412 |
* new:n for non-variable classes only allowed if |
|
2413 |
* n == 0 |
|
2414 |
*/ |
|
2415 |
if (nindexedinstvars == 0) { |
|
2416 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
2417 |
__PROTECT_CONTEXT__ |
|
2418 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
|
2419 |
__UNPROTECT_CONTEXT__ |
|
2420 |
if (newobj == nil) { |
|
2421 |
break; |
|
2422 |
} |
|
2423 |
__InstPtr(newobj)->o_class = self; |
|
2424 |
__qSTORE(newobj, self); |
|
2425 |
||
2426 |
if (nInstVars) { |
|
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2427 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
12094 | 2428 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 2429 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2430 |
# if defined(FAST_MEMSET) |
12094 | 2431 |
/* |
2432 |
* knowing that nil is 0 |
|
2433 |
*/ |
|
2434 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
|
1 | 2435 |
# else |
12094 | 2436 |
op = __InstPtr(newobj)->i_instvars; |
2437 |
do { |
|
2438 |
*op++ = nil; |
|
2439 |
} while (--nInstVars); |
|
1 | 2440 |
# endif |
2441 |
#endif |
|
12094 | 2442 |
} |
2443 |
RETURN ( newobj ); |
|
2444 |
} |
|
2445 |
break; |
|
2446 |
} |
|
2447 |
} |
|
1 | 2448 |
} |
68 | 2449 |
%}. |
2450 |
" |
|
2451 |
arrive here if something went wrong ... |
|
2452 |
figure out what it was |
|
2453 |
" |
|
11 | 2454 |
|
1 | 2455 |
(anInteger isMemberOf:SmallInteger) ifFalse:[ |
12094 | 2456 |
" |
2457 |
the argument is either not an integer, |
|
2458 |
or a LargeInteger (which means that its definitely too big) |
|
2459 |
" |
|
2460 |
self error:'argument to new: must be Integer' mayProceed:true. |
|
2461 |
^ nil |
|
68 | 2462 |
]. |
2463 |
(anInteger < 0) ifTrue:[ |
|
12094 | 2464 |
" |
2465 |
the argument is negative, |
|
2466 |
" |
|
2467 |
self error:'bad (negative) argument to new:'. |
|
2468 |
^ nil |
|
68 | 2469 |
]. |
2470 |
self isVariable ifFalse:[ |
|
12094 | 2471 |
" |
2472 |
this class does not have any indexed instance variables |
|
2473 |
" |
|
2474 |
self error:'class has no indexed instvars - cannot create with new:'. |
|
2475 |
^ nil |
|
68 | 2476 |
]. |
2477 |
" |
|
2478 |
memory allocation failed. |
|
2479 |
When we arrive here, there was no memory, even after |
|
12094 | 2480 |
a garbage collect. |
2481 |
This means, that the VM wanted to get some more memory from the |
|
165 | 2482 |
Operatingsystem, which was not kind enough to give it. |
2483 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 2484 |
" |
127 | 2485 |
^ ObjectMemory allocationFailureSignal raise. |
9194 | 2486 |
! |
2487 |
||
2488 |
decodeFromLiteralArray:anArray |
|
2489 |
"create & return a new instance from information encoded in anArray." |
|
2490 |
||
2491 |
^ self new fromLiteralArrayEncoding:anArray. |
|
2492 |
||
2493 |
" |
|
2494 |
Rectangle |
|
2495 |
decodeFromLiteralArray:#(Rectangle 10 10 100 100) |
|
2496 |
" |
|
2497 |
||
2498 |
"Modified: / 28.1.1998 / 17:40:30 / cg" |
|
2370
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2499 |
! |
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2500 |
|
9194 | 2501 |
new |
2502 |
"return an instance of myself without indexed variables" |
|
2503 |
||
2504 |
^ self basicNew |
|
2505 |
! |
|
2506 |
||
2507 |
new:anInteger |
|
2508 |
"return an instance of myself with anInteger indexed variables" |
|
2509 |
||
2510 |
^ self basicNew:anInteger |
|
2511 |
! |
|
2512 |
||
2513 |
niceBasicNew:anInteger |
|
620 | 2514 |
"same as basicNew:anInteger, but tries to avoid long pauses |
2515 |
due to garbage collection. This method checks to see if |
|
2516 |
allocation is possible without a pause, and does a background |
|
2517 |
incremental garbage collect first if there is not enough memory |
|
12094 | 2518 |
available at the moment for fast allocation. |
2519 |
This is useful in low-priority background processes which like to |
|
620 | 2520 |
avoid disturbing any higher priority foreground process while allocating |
2521 |
big amounts of memory. Of course, using this method only makes |
|
2522 |
sense for big or huge objects (say > 200k). |
|
2523 |
||
12094 | 2524 |
EXPERIMENTAL: this is a non-standard interface and should only |
620 | 2525 |
be used for special applications. There is no guarantee, that this |
2526 |
method will be available in future ST/X releases." |
|
2527 |
||
2528 |
|size| |
|
2529 |
||
2530 |
size := self sizeOfInst:anInteger. |
|
2531 |
(ObjectMemory checkForFastNew:size) ifFalse:[ |
|
2532 |
" |
|
2533 |
incrementally collect garbage |
|
2534 |
" |
|
2535 |
ObjectMemory incrementalGC. |
|
2536 |
]. |
|
2537 |
^ self basicNew:anInteger |
|
9194 | 2538 |
! |
2539 |
||
2540 |
readFrom:aStream |
|
12094 | 2541 |
"read an objects printed representation from the argument, aStream |
2542 |
and return it. |
|
154 | 2543 |
The read object must be a kind of myself if its not, an error is raised. |
11 | 2544 |
This is the reverse operation to 'storeOn:'. |
43 | 2545 |
|
12094 | 2546 |
WARNING: storeOn: does not handle circular references and multiple |
2547 |
references to the same object. |
|
2548 |
Use #storeBinary:/readBinaryFrom: for this." |
|
2549 |
||
2550 |
^ self |
|
2551 |
readFrom:aStream |
|
2552 |
onError:[ self conversionErrorSignal |
|
2553 |
raiseErrorString:'conversion error for: ' , self name ] |
|
11 | 2554 |
|
91 | 2555 |
" |
2556 |
|s| |
|
11 | 2557 |
s := WriteStream on:String new. |
2558 |
#(1 2 3 4) storeOn:s. |
|
12094 | 2559 |
Object readFrom:(ReadStream on:s contents) |
11 | 2560 |
" |
9194 | 2561 |
! |
2562 |
||
2563 |
readFrom:aStream onError:exceptionBlock |
|
12094 | 2564 |
"read an objects printed representation from the argument, aStream |
198 | 2565 |
and return it (i.e. the stream should contain some representation of |
12094 | 2566 |
the object which was created using #storeOn:). |
198 | 2567 |
The read object must be a kind of myself if its not, the value of |
2568 |
exceptionBlock is returned. |
|
2569 |
To get any object, use 'Object readFrom:...', |
|
2570 |
To get any number, use 'Number readFrom:...' and so on. |
|
2571 |
This is the reverse operation to 'storeOn:'. |
|
2572 |
||
12094 | 2573 |
WARNING: storeOn: does not handle circular references and multiple |
2574 |
references to the same object. |
|
2575 |
Use #storeBinary:/readBinaryFrom: for this." |
|
198 | 2576 |
|
6627
685ab6f994f0
Avoid block creation in #readFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
6596
diff
changeset
|
2577 |
^ [ |
12094 | 2578 |
|newObject| |
2579 |
newObject := self evaluatorClass evaluate:aStream ifFail:exceptionBlock. |
|
2580 |
(newObject isKindOf:self) ifTrue:[newObject] ifFalse:[exceptionBlock value]. |
|
6627
685ab6f994f0
Avoid block creation in #readFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
6596
diff
changeset
|
2581 |
] on:Error do:exceptionBlock. |
198 | 2582 |
|
2583 |
" |
|
2584 |
|s| |
|
2585 |
s := WriteStream on:String new. |
|
2586 |
#(1 2 3 4) storeOn:s. |
|
1422 | 2587 |
Transcript showCR:( |
12094 | 2588 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
293 | 2589 |
) |
198 | 2590 |
" |
2591 |
" |
|
2592 |
|s| |
|
2593 |
s := WriteStream on:String new. |
|
2594 |
#[1 2 3 4] storeOn:s. |
|
1422 | 2595 |
Transcript showCR:( |
12094 | 2596 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
345 | 2597 |
) |
198 | 2598 |
" |
5842
720736f72cb4
exceptionBlock handling in #readFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5753
diff
changeset
|
2599 |
" |
6627
685ab6f994f0
Avoid block creation in #readFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
6596
diff
changeset
|
2600 |
Object readFrom:'illegal' onError:['bla'] |
685ab6f994f0
Avoid block creation in #readFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
6596
diff
changeset
|
2601 |
String readFrom:'illegal' onError:'bla' |
5842
720736f72cb4
exceptionBlock handling in #readFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5753
diff
changeset
|
2602 |
" |
9194 | 2603 |
! |
2604 |
||
2605 |
readFromString:aString |
|
275 | 2606 |
"create an object from its printed representation. |
2607 |
For most classes, the string is expected to be in a format created by |
|
2608 |
storeOn: or storeString; however, some (Time, Date) expect a user |
|
2609 |
readable string here. |
|
2610 |
See comments in Behavior>>readFromString:onError:, |
|
2611 |
Behavior>>readFrom: and Behavior>>readFrom:onError:" |
|
11 | 2612 |
|
12094 | 2613 |
^ self |
2614 |
readFromString:aString |
|
2615 |
onError:[ self conversionErrorSignal |
|
2616 |
raiseErrorString:'expected: ' , self name ] |
|
91 | 2617 |
|
2618 |
" |
|
12094 | 2619 |
Integer readFromString:'12345678901234567890' |
2620 |
Point readFromString:'1@2' |
|
2621 |
Point readFromString:'1' |
|
91 | 2622 |
" |
198 | 2623 |
! |
2624 |
||
2625 |
readFromString:aString onError:exceptionBlock |
|
275 | 2626 |
"create an object from its printed representation. |
2627 |
Here, the string is expected to be in a format created by |
|
12094 | 2628 |
storeOn: or storeString; |
9196
a6d45629bb3b
readFromString allows for whiteSpace after reading
Claus Gittinger <cg@exept.de>
parents:
9194
diff
changeset
|
2629 |
However, some classes (Time, Date) may redefine it to expect a user readable string here. |
198 | 2630 |
See comments in Behavior>>readFrom: and Behavior>>readFrom:onError:" |
2631 |
||
8531
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
2632 |
|str val| |
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
2633 |
|
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
2634 |
str := ReadStream on:aString. |
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
2635 |
val := self readFrom:str onError:[^ exceptionBlock value]. |
12094 | 2636 |
str atEnd ifFalse:[ |
2637 |
str skipSeparators. |
|
2638 |
str atEnd ifFalse:[ |
|
2639 |
^ exceptionBlock value |
|
2640 |
] |
|
9196
a6d45629bb3b
readFromString allows for whiteSpace after reading
Claus Gittinger <cg@exept.de>
parents:
9194
diff
changeset
|
2641 |
]. |
8531
2bbe01cfb56f
differenciate between readFrom: (which allows more text after read part)
Claus Gittinger <cg@exept.de>
parents:
8529
diff
changeset
|
2642 |
^ val |
198 | 2643 |
|
2644 |
" |
|
12094 | 2645 |
Integer readFromString:'12345678901234567890' |
2646 |
Integer readFromString:'abc' |
|
275 | 2647 |
Integer readFromString:'abc' onError:0 |
12094 | 2648 |
Point readFromString:'1@2' |
2649 |
Point readFromString:'0' |
|
2650 |
Point readFromString:'0' onError:[0@0] |
|
198 | 2651 |
" |
9194 | 2652 |
! |
2653 |
||
2654 |
uninitializedNew |
|
2655 |
"create an instance of myself with uninitialized contents. |
|
2656 |
For all classes except ByteArray, this is the same as #basicNew." |
|
2657 |
||
2658 |
^ self basicNew |
|
2659 |
! |
|
2660 |
||
2661 |
uninitializedNew:anInteger |
|
2662 |
"create an instance of myself with uninitialized contents. |
|
2663 |
For all classes except ByteArray, this is the same as #basicNew:." |
|
2664 |
||
2665 |
^ self basicNew:anInteger |
|
2666 |
! ! |
|
2667 |
||
2668 |
!Behavior methodsFor:'misc'! |
|
3619 | 2669 |
|
4928 | 2670 |
browse |
5727 | 2671 |
"open a browser showing the receiver" |
2672 |
||
12094 | 2673 |
self browserClass openInClass:self |
4928 | 2674 |
|
2675 |
" |
|
5546 | 2676 |
Array browserClass |
4928 | 2677 |
Array browse |
2678 |
" |
|
2679 |
! |
|
2680 |
||
8725 | 2681 |
classOperationsMenu |
2682 |
"a chance to return additional menu items for the browsers class-menu" |
|
2683 |
||
2684 |
^ nil |
|
2685 |
! |
|
2686 |
||
10667
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2687 |
iconInBrowserSymbol |
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2688 |
"can be redefined for a private icon in the browser (for me and my subclasses). |
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2689 |
The returned symbol must be a selector of the ToolbarIconLibrary." |
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2690 |
|
12094 | 2691 |
(self isBrowserStartable) ifTrue:[ |
2692 |
self isVisualStartable ifTrue:[ |
|
2693 |
^ #visualStartableClassBrowserIcon |
|
2694 |
]. |
|
2695 |
^ #startableClassBrowserIcon |
|
2696 |
]. |
|
2697 |
self isLoaded ifFalse:[ |
|
2698 |
^ #autoloadedClassBrowserIcon |
|
2699 |
]. |
|
2700 |
||
2701 |
"/ give ruby and other special metaclasses a chance ot provide their orn icon... |
|
2702 |
^ self class iconInBrowserSymbol |
|
10667
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2703 |
|
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2704 |
"Created: / 20-07-2007 / 08:52:17 / cg" |
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2705 |
! |
8d1076445237
icons in ToolbarIconLibrary
Claus Gittinger <cg@exept.de>
parents:
10605
diff
changeset
|
2706 |
|
3619 | 2707 |
sourceCodeTemplate |
2708 |
^ 'messageSelector and arguments |
|
2709 |
"method comment - purpose of message" |
|
2710 |
||
2711 |
|temporaries| |
|
2712 |
||
2713 |
statements |
|
2714 |
||
2715 |
" |
|
2716 |
example uses |
|
2717 |
" |
|
2718 |
' |
|
2719 |
||
2720 |
"Created: / 19.6.1998 / 02:14:02 / cg" |
|
2721 |
! ! |
|
2722 |
||
9194 | 2723 |
!Behavior methodsFor:'printing & storing'! |
2724 |
||
10085 | 2725 |
displayString |
2726 |
"although behaviors have no name, we return something |
|
2727 |
useful here - there are many places (inspectors) where |
|
2728 |
a classes name is asked for. |
|
2729 |
Implementing this message here allows instances of anonymous classes |
|
2730 |
to show a reasonable name." |
|
2731 |
||
2732 |
^ 'someBehavior' |
|
2733 |
! |
|
2734 |
||
9194 | 2735 |
printOn:aStream |
2736 |
aStream nextPutAll:(self name). |
|
6590 | 2737 |
! ! |
6589 | 2738 |
|
9194 | 2739 |
!Behavior methodsFor:'private-accessing'! |
2740 |
||
2741 |
flags:aNumber |
|
2742 |
"set the flags. |
|
2743 |
this method is for special uses only - there will be no recompilation |
|
12094 | 2744 |
and no change record written here; |
9194 | 2745 |
Do NOT use it." |
2746 |
||
2747 |
flags := aNumber |
|
2748 |
! |
|
620 | 2749 |
|
2750 |
instSize:aNumber |
|
2751 |
"set the instance size. |
|
2752 |
this method is for special uses only - there will be no recompilation |
|
12094 | 2753 |
and no change record written here; |
620 | 2754 |
Do NOT use it." |
2755 |
||
2756 |
instSize := aNumber |
|
2757 |
! |
|
2758 |
||
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
2759 |
primAddSelector:aSelector withMethod:newMethod |
620 | 2760 |
"add the method given by 2nd argument under the selector given by |
12094 | 2761 |
the 1st argument to the methodDictionary. |
620 | 2762 |
Does NOT flush any caches, does NOT write a change record. |
2763 |
||
2764 |
Do not use this in normal situations, strange behavior will be |
|
2765 |
the consequence. |
|
12094 | 2766 |
I.e. executing obsolete methods, since the old method will still |
620 | 2767 |
be executed out of the caches." |
2768 |
||
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
2769 |
|dict oldMethod| |
620 | 2770 |
|
2771 |
newMethod isNil ifTrue:[ |
|
12094 | 2772 |
self error:'invalid method'. |
620 | 2773 |
]. |
12094 | 2774 |
(Smalltalk |
2775 |
changeRequest:#methodInClass |
|
2776 |
with:(Array with:self with:aSelector with:oldMethod)) ifFalse:[ |
|
2777 |
^ false |
|
11578 | 2778 |
]. |
10693
d397d49e1134
changed #primAddSelector:withMethod:
Claus Gittinger <cg@exept.de>
parents:
10669
diff
changeset
|
2779 |
"/ oldMethod := self compiledMethodAt:aSelector. |
620 | 2780 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2781 |
dict := self methodDictionary. |
10693
d397d49e1134
changed #primAddSelector:withMethod:
Claus Gittinger <cg@exept.de>
parents:
10669
diff
changeset
|
2782 |
"/ oldMethod := dict at:aSelector ifAbsent:nil. |
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
2783 |
|
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
2784 |
self setMethodDictionary:(dict at:aSelector putOrAppend:newMethod). |
7123
2af84f5b1447
pre-set the methods mclass cache when adding a method
Claus Gittinger <cg@exept.de>
parents:
6968
diff
changeset
|
2785 |
newMethod mclass:self. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2786 |
|
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
2787 |
ObjectMemory flushCachesForSelector:aSelector. |
11578 | 2788 |
^ true |
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
2789 |
|
9445 | 2790 |
"Modified: / 07-06-1996 / 14:48:45 / stefan" |
10693
d397d49e1134
changed #primAddSelector:withMethod:
Claus Gittinger <cg@exept.de>
parents:
10669
diff
changeset
|
2791 |
"Modified: / 31-08-2007 / 16:53:20 / cg" |
9194 | 2792 |
! |
2793 |
||
2794 |
setMethodDictionary:dict |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2795 |
"set the receivers method dictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2796 |
Convert dict to a MethodDictionary if necessary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2797 |
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
|
2798 |
after this call" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2799 |
|
2228 | 2800 |
"/ since the only thing the VM is prepared to deal with are |
2801 |
"/ proper methodDictionaries (it cannot do another message send, to |
|
2802 |
"/ find any methods ...), we convert it here if required. |
|
2803 |
"/ No other classes instances are allowed. |
|
2804 |
||
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2805 |
dict class ~~ MethodDictionary ifTrue:[ |
12094 | 2806 |
methodDictionary := MethodDictionary withAll:dict. |
2807 |
methodDictionary isNil ifTrue:[ |
|
2808 |
||
2809 |
"/ refuse to do this |
|
2810 |
"/ (can only happen in case of memory allocation trouble, |
|
2811 |
"/ where the allocation failed and some exception handler returned |
|
2812 |
"/ nil ...) |
|
2813 |
||
2814 |
self error:'cannot set methodDictionary to nil' mayProceed:true. |
|
2815 |
^ self. |
|
2816 |
] |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2817 |
] ifFalse:[ |
12094 | 2818 |
methodDictionary := dict. |
620 | 2819 |
]. |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2820 |
^ self. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2821 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2822 |
"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
|
2823 |
"Modified: 12.6.1996 / 13:58:55 / stefan" |
2228 | 2824 |
"Modified: 22.1.1997 / 21:10:48 / cg" |
9194 | 2825 |
! |
2826 |
||
2827 |
setSuperclass:aClass |
|
2828 |
"set the superclass of the receiver. |
|
2829 |
this method is for special uses only - there will be no recompilation |
|
2830 |
and no change record written here. Also, if the receiver class has |
|
2831 |
already been in use, future operation of the system is not guaranteed to |
|
2832 |
be correct, since no caches are flushed. |
|
2833 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2834 |
||
2835 |
superclass := aClass |
|
2836 |
||
2837 |
"Modified: 3.3.1997 / 13:27:00 / cg" |
|
2838 |
! |
|
620 | 2839 |
|
12094 | 2840 |
setSuperclass:aClass instSize:i |
2841 |
"set some inst vars. |
|
5906 | 2842 |
this method is for special uses only - there will be no recompilation |
12094 | 2843 |
and no change record is written here. Also, if the receiver class has |
5906 | 2844 |
already been in use, future operation of the system is not guaranteed to |
2845 |
be correct, since no caches are flushed. |
|
2846 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2847 |
||
2848 |
self setSuperclass:aClass. |
|
2849 |
instSize := i. |
|
2850 |
! |
|
2851 |
||
9194 | 2852 |
setSuperclass:aClass methodDictionary:d instSize:i flags:f |
12094 | 2853 |
"set some inst vars. |
9194 | 2854 |
this method is for special uses only - there will be no recompilation |
12094 | 2855 |
and no change record is written here. Also, if the receiver class has |
9194 | 2856 |
already been in use, future operation of the system is not guaranteed to |
2857 |
be correct, since no caches are flushed. |
|
2858 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2859 |
||
2860 |
self setSuperclass:aClass. |
|
2861 |
self setMethodDictionary:d. |
|
620 | 2862 |
instSize := i. |
2863 |
flags := f |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2864 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2865 |
"Created: 7.6.1996 / 08:41:20 / stefan" |
2224 | 2866 |
"Modified: 22.1.1997 / 18:42:12 / cg" |
620 | 2867 |
! ! |
2868 |
||
7260 | 2869 |
!Behavior methodsFor:'private-helpers'! |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2870 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2871 |
addAllClassVarNamesTo:aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2872 |
"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
|
2873 |
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
|
2874 |
|
6395
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
2875 |
|classvars superclass| |
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
2876 |
|
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
2877 |
superclass := self superclass. |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2878 |
(superclass notNil) ifTrue:[ |
12094 | 2879 |
superclass addAllClassVarNamesTo:aCollection |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2880 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2881 |
(classvars := self classVariableString) notNil ifTrue:[ |
12094 | 2882 |
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
|
2883 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2884 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2885 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2886 |
"Created: 16.4.1996 / 18:00:38 / cg" |
9194 | 2887 |
! |
2888 |
||
2889 |
addAllInstVarNamesTo:aCollection |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2890 |
"helper for allInstVarNames - add the name-strings of the instance variables |
12094 | 2891 |
and of the inst-vars of all superclasses to the argument, aCollection. |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2892 |
Return aCollection." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2893 |
|
6395
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
2894 |
|superclass| |
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
2895 |
|
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
2896 |
superclass := self superclass. |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2897 |
(superclass notNil) ifTrue:[ |
12094 | 2898 |
superclass addAllInstVarNamesTo:aCollection |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2899 |
]. |
5512 | 2900 |
aCollection addAll:self instVarNames. |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2901 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2902 |
|
5512 | 2903 |
" |
2904 |
SortedCollection allInstVarNames |
|
2905 |
SortedCollection instVarNames |
|
2906 |
" |
|
4371
dc83645cc903
support to recursively enumerate all private classes
Claus Gittinger <cg@exept.de>
parents:
4366
diff
changeset
|
2907 |
! |
dc83645cc903
support to recursively enumerate all private classes
Claus Gittinger <cg@exept.de>
parents:
4366
diff
changeset
|
2908 |
|
9194 | 2909 |
addAllPrivateClassesTo:aCollection |
2910 |
"add all of my private classes to aCollection" |
|
2911 |
||
2912 |
self privateClassesDo:[:aPrivateClass | |
|
2913 |
aCollection add:aPrivateClass. |
|
2914 |
aPrivateClass addAllPrivateClassesTo:aCollection |
|
2915 |
]. |
|
2916 |
! ! |
|
2917 |
||
2918 |
!Behavior methodsFor:'queries'! |
|
620 | 2919 |
|
6727 | 2920 |
category |
12094 | 2921 |
"return the category of the class. |
6727 | 2922 |
Returning nil here, since Behavior does not define a category |
2923 |
(only ClassDescriptions do)." |
|
2924 |
||
2925 |
^ nil |
|
2926 |
||
2927 |
" |
|
12094 | 2928 |
Point category |
2929 |
Behavior new category |
|
6727 | 2930 |
" |
9194 | 2931 |
! |
6727 | 2932 |
|
2933 |
comment |
|
12094 | 2934 |
"return the comment of the class. |
6727 | 2935 |
Returning nil here, since Behavior does not define a category |
2936 |
(only Classes do). This allows different Behavior-like objects |
|
2937 |
(alien classes) to be handled by the browser as well." |
|
2938 |
||
9194 | 2939 |
^ nil |
2940 |
||
2941 |
"Modified: 16.4.1996 / 16:25:23 / cg" |
|
2942 |
! |
|
6727 | 2943 |
|
2944 |
definitionSelector |
|
2945 |
"return the selector with which I was (can be) defined in my superclass" |
|
2946 |
||
2947 |
^ (self firstDefinitionSelectorPart |
|
2948 |
, |
|
2949 |
'instanceVariableNames:classVariableNames:poolDictionaries:category:') asSymbol |
|
2950 |
||
2951 |
" |
|
2952 |
Object definitionSelector |
|
12094 | 2953 |
Array definitionSelector |
2954 |
ByteArray definitionSelector |
|
2955 |
FloatArray definitionSelector |
|
9194 | 2956 |
" |
2957 |
||
2958 |
"Modified: 3.3.1997 / 11:50:37 / cg" |
|
2959 |
! |
|
6727 | 2960 |
|
2961 |
definitionSelectorPrivate |
|
2962 |
"return the selector with which I was (can be) defined in my superclass |
|
2963 |
as a private class" |
|
2964 |
||
2965 |
^ (self firstDefinitionSelectorPart |
|
2966 |
, |
|
2967 |
'instanceVariableNames:classVariableNames:poolDictionaries:privateIn:') asSymbol |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2968 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2969 |
" |
12094 | 2970 |
Array definitionSelector |
2971 |
Array definitionSelectorPrivate |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2972 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2973 |
|
6727 | 2974 |
"Modified: 23.6.1997 / 10:45:57 / cg" |
620 | 2975 |
! |
2976 |
||
9194 | 2977 |
firstDefinitionSelectorPart |
6727 | 2978 |
"return the first part of the selector with which I was (can be) defined in my superclass" |
2979 |
||
2980 |
self isVariable ifFalse:[ |
|
2981 |
^ #'subclass:' |
|
2982 |
]. |
|
2983 |
self isBytes ifTrue:[ |
|
2984 |
^ #'variableByteSubclass:' |
|
2985 |
]. |
|
2986 |
self isLongs ifTrue:[ |
|
2987 |
^ #'variableLongSubclass:' |
|
2988 |
]. |
|
2989 |
self isFloats ifTrue:[ |
|
2990 |
^ #'variableFloatSubclass:' |
|
2991 |
]. |
|
2992 |
self isDoubles ifTrue:[ |
|
2993 |
^ #'variableDoubleSubclass:' |
|
2994 |
]. |
|
2995 |
self isWords ifTrue:[ |
|
2996 |
^ #'variableWordSubclass:' |
|
2997 |
]. |
|
2998 |
self isSignedWords ifTrue:[ |
|
2999 |
^ #'variableSignedWordSubclass:' |
|
3000 |
]. |
|
3001 |
self isSignedLongs ifTrue:[ |
|
3002 |
^ #'variableSignedLongSubclass:' |
|
3003 |
]. |
|
3004 |
self isSignedLongLongs ifTrue:[ |
|
3005 |
^ #'variableSignedLongLongSubclass:' |
|
3006 |
]. |
|
3007 |
self isLongLongs ifTrue:[ |
|
3008 |
^ #'variableLongLongSubclass:' |
|
3009 |
]. |
|
3010 |
^ #'variableSubclass:' |
|
9194 | 3011 |
! |
3012 |
||
3013 |
fullName |
|
3014 |
"Answer the name of the receiver, fully qualified." |
|
3015 |
||
3016 |
^ self name asString |
|
3017 |
||
3018 |
! |
|
3019 |
||
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3020 |
hasExtensions |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3021 |
^ false |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3022 |
|
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3023 |
"Created: / 06-08-2006 / 15:23:32 / cg" |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3024 |
! |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3025 |
|
9194 | 3026 |
isBehavior |
9219 | 3027 |
"return true, if the receiver is describing another objects behavior. |
3028 |
Defined to avoid the need to use isKindOf:" |
|
9194 | 3029 |
|
3030 |
^ true |
|
3031 |
||
3032 |
" |
|
12094 | 3033 |
True isBehavior |
9194 | 3034 |
true isBehavior |
3035 |
" |
|
3036 |
! |
|
620 | 3037 |
|
10043
22138758483e
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
10008
diff
changeset
|
3038 |
isBrowserStartable |
22138758483e
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
10008
diff
changeset
|
3039 |
^ false |
22138758483e
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
10008
diff
changeset
|
3040 |
|
22138758483e
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
10008
diff
changeset
|
3041 |
"Created: / 06-10-2006 / 11:33:42 / cg" |
22138758483e
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
10008
diff
changeset
|
3042 |
! |
22138758483e
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
10008
diff
changeset
|
3043 |
|
6727 | 3044 |
isBuiltInClass |
3045 |
"return true if this class is known by the run-time-system. |
|
3046 |
Here, false is returned as default. |
|
3047 |
Notice, this is instance protocol, which means that any class |
|
3048 |
other than those special ones) are non-builtIn by default." |
|
3049 |
||
3050 |
^ false |
|
3051 |
||
3052 |
"Modified: 23.4.1996 / 15:55:52 / cg" |
|
9194 | 3053 |
"Created: 28.10.1996 / 15:10:02 / cg" |
3054 |
! |
|
3055 |
||
3056 |
isPrivate |
|
3057 |
"return true, if the receiver is some private class" |
|
3058 |
||
3059 |
^ self owningClass notNil |
|
3060 |
||
3061 |
"Modified: 12.10.1996 / 20:11:05 / cg" |
|
3062 |
! |
|
6727 | 3063 |
|
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3064 |
isStartableWithMain |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3065 |
^ false |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3066 |
|
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3067 |
"Created: / 06-08-2006 / 15:23:50 / cg" |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3068 |
! |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3069 |
|
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3070 |
isStartableWithStart |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3071 |
^ false |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3072 |
|
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3073 |
"Created: / 06-08-2006 / 15:23:57 / cg" |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3074 |
! |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3075 |
|
6727 | 3076 |
isSubclassOf:aClass |
3077 |
"return true, if I am a subclass of the argument, aClass" |
|
3078 |
||
3079 |
|theClass| |
|
3080 |
||
3081 |
theClass := superclass. |
|
3082 |
[theClass notNil] whileTrue:[ |
|
3083 |
(theClass == aClass) ifTrue:[^ true]. |
|
3084 |
%{ |
|
3085 |
if (__isBehaviorLike(theClass)) { |
|
3086 |
theClass = __ClassInstPtr(theClass)->c_superclass; |
|
3087 |
} else { |
|
3088 |
theClass = nil; |
|
3089 |
} |
|
3090 |
%}. |
|
3091 |
"/ theClass := theClass superclass. |
|
3620
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
3092 |
]. |
9194 | 3093 |
^ false |
3094 |
||
3095 |
" |
|
12094 | 3096 |
String isSubclassOf:Collection |
3097 |
LinkedList isSubclassOf:Array |
|
9194 | 3098 |
1 isSubclassOf:Number <- will fail since 1 is no class |
12094 | 3099 |
" |
6727 | 3100 |
! |
3101 |
||
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3102 |
isVisualStartable |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3103 |
^ false |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3104 |
|
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3105 |
"Created: / 06-08-2006 / 15:23:38 / cg" |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3106 |
! |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3107 |
|
6727 | 3108 |
name |
3109 |
"although behaviors have no name, we return something |
|
3110 |
useful here - there are many places (inspectors) where |
|
3111 |
a classes name is asked for. |
|
3112 |
Implementing this message here allows anonymous classes |
|
9194 | 3113 |
and instances of them to be inspected." |
3114 |
||
3115 |
^ #'anonymous Behavior' |
|
3116 |
! |
|
3117 |
||
3118 |
nameInBrowser |
|
3119 |
"return a nameString as shown in browsers" |
|
3120 |
||
3121 |
^ self name ? '?' |
|
3122 |
! |
|
6727 | 3123 |
|
7331
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3124 |
nameWithArticle |
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3125 |
"return a string consisting of classname preceeded by an article. |
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3126 |
(dont expect me to write national variants for this ... :-) |
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3127 |
If you have special preferences, redefine it..." |
12094 | 3128 |
|
7331
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3129 |
|classname| |
12094 | 3130 |
|
7331
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3131 |
classname := self name. |
9445 | 3132 |
classname isEmpty ifTrue:[ ^ 'an anonymous' ]. |
7331
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3133 |
^ classname article , ' ' , classname |
12094 | 3134 |
|
7331
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3135 |
" |
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3136 |
SmallInteger nameWithArticle |
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3137 |
" |
9445 | 3138 |
|
3139 |
"Modified: / 16-07-2006 / 00:02:23 / cg" |
|
7331
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3140 |
! |
cd0f1492d540
code motion from ClassDescription
Claus Gittinger <cg@exept.de>
parents:
7269
diff
changeset
|
3141 |
|
6727 | 3142 |
owningClass |
3143 |
"return my owning class - nil if I am a public class" |
|
3144 |
||
3145 |
"/ this information is in the metaclass ... |
|
3146 |
||
3147 |
^ self class owningClass |
|
3148 |
||
3149 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
3150 |
"Modified: 7.11.1996 / 13:49:28 / cg" |
|
3151 |
! |
|
3152 |
||
6733
4f8a80a22261
added #owningClassOrYourself
Claus Gittinger <cg@exept.de>
parents:
6727
diff
changeset
|
3153 |
owningClassOrYourself |
4f8a80a22261
added #owningClassOrYourself
Claus Gittinger <cg@exept.de>
parents:
6727
diff
changeset
|
3154 |
"return my owning class if I am private, myself otherwise" |
4f8a80a22261
added #owningClassOrYourself
Claus Gittinger <cg@exept.de>
parents:
6727
diff
changeset
|
3155 |
|
9194 | 3156 |
self owningClass notNil ifTrue:[^ self topOwningClass]. |
3157 |
^ self |
|
3158 |
! |
|
6733
4f8a80a22261
added #owningClassOrYourself
Claus Gittinger <cg@exept.de>
parents:
6727
diff
changeset
|
3159 |
|
9469
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3160 |
revision |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3161 |
^ nil |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3162 |
|
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3163 |
"Created: / 03-08-2006 / 01:53:44 / cg" |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3164 |
! |
580edc421e81
support for lazy methods ceased.
Claus Gittinger <cg@exept.de>
parents:
9445
diff
changeset
|
3165 |
|
6727 | 3166 |
sourceCodeAt:aSelector |
3167 |
"return the methods source for given selector aSelector or nil. |
|
3168 |
Only methods in the receiver - not in the superclass chain are tested." |
|
3169 |
||
7676 | 3170 |
^ self sourceCodeAt:aSelector ifAbsent:nil |
6727 | 3171 |
|
3172 |
" |
|
3173 |
True sourceCodeAt:#ifTrue: |
|
3174 |
Object sourceCodeAt:#== |
|
3175 |
Behavior sourceCodeAt:#sourceCodeAt: |
|
2053 | 3176 |
" |
3177 |
! |
|
3178 |
||
7676 | 3179 |
sourceCodeAt:aSelector ifAbsent:exceptionalValue |
3180 |
"return the methods source for given selector aSelector or exceptionalValue. |
|
3181 |
Only methods in the receiver - not in the superclass chain are tested." |
|
3182 |
||
3183 |
|method| |
|
3184 |
||
3185 |
method := self compiledMethodAt:aSelector. |
|
3186 |
method isNil ifTrue:[^ exceptionalValue value]. |
|
9194 | 3187 |
^ method source |
3188 |
! |
|
7676 | 3189 |
|
6727 | 3190 |
sourceCodeManager |
12094 | 3191 |
"return the sourceCodeManager of the class. |
6727 | 3192 |
Returning nil here, since Behavior does not define any sourceCode management. |
3193 |
(only Classes do). This allows different Behavior-like objects |
|
3194 |
(alien classes) to be handled by the browser as well." |
|
3195 |
||
3196 |
^ nil |
|
3197 |
||
3198 |
"Created: 16.4.1996 / 16:26:03 / cg" |
|
9194 | 3199 |
! |
6727 | 3200 |
|
3201 |
supportsMethodCategories |
|
3202 |
"return true, if my methods are categorized. |
|
3203 |
This is a hook for the browser to allow alien classes |
|
3204 |
to be handled (aktually, this is not yet used)." |
|
3205 |
||
3206 |
^ true |
|
3207 |
||
3208 |
"Created: 30.7.1997 / 14:59:08 / cg" |
|
3209 |
"Modified: 30.7.1997 / 15:02:03 / cg" |
|
620 | 3210 |
! |
3211 |
||
6727 | 3212 |
theMetaclass |
9696 | 3213 |
"return the metaClass of the class-meta pair. |
3214 |
Here, return my metaclass object, because I am the class. |
|
3215 |
Also implemented in my metaclass, which returns itself." |
|
9194 | 3216 |
|
3217 |
^ self class |
|
3218 |
||
3219 |
"Created: / 30.1.2000 / 23:08:30 / cg" |
|
3220 |
"Modified: / 31.1.2000 / 16:16:52 / cg" |
|
3221 |
! |
|
6727 | 3222 |
|
3223 |
theNonMetaclass |
|
9696 | 3224 |
"return the nonMetaClass of the class-meta pair. |
3225 |
Here, return myself, because I am the nonMetaclass. |
|
3226 |
Also implemented in my metaclass, which also returns me." |
|
6727 | 3227 |
|
3228 |
^ self |
|
3229 |
||
3230 |
"Created: / 30.1.2000 / 23:07:59 / cg" |
|
3231 |
"Modified: / 31.1.2000 / 16:17:46 / cg" |
|
3232 |
! |
|
3233 |
||
3234 |
topOwningClass |
|
3235 |
"return my outermost owning class - nil if I am a public class" |
|
3236 |
||
3237 |
"/ this information is in the metaclass ... |
|
3238 |
||
3239 |
^ self class topOwningClass |
|
3240 |
||
3241 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
3242 |
"Modified: 3.1.1997 / 19:18:49 / cg" |
|
3243 |
! ! |
|
3244 |
||
9194 | 3245 |
!Behavior methodsFor:'queries-inheritance'! |
6727 | 3246 |
|
620 | 3247 |
allSubclasses |
3248 |
"return a collection of all subclasses (direct AND indirect) of |
|
3249 |
the receiver. There will be no specific order, in which entries |
|
10172 | 3250 |
are returned. NameSpaces are excluded from the list." |
620 | 3251 |
|
3252 |
|newColl| |
|
3253 |
||
3254 |
newColl := OrderedCollection new. |
|
3255 |
self allSubclassesDo:[:aClass | |
|
12094 | 3256 |
(aClass isRealNameSpace) ifFalse:[ |
3257 |
newColl add:aClass |
|
3258 |
] |
|
620 | 3259 |
]. |
3260 |
^ newColl |
|
3261 |
||
3262 |
" |
|
3263 |
Collection allSubclasses |
|
3264 |
" |
|
10172 | 3265 |
|
3266 |
"Modified: / 10-11-2006 / 17:22:58 / cg" |
|
620 | 3267 |
! |
3268 |
||
3269 |
allSubclassesInOrder |
|
3270 |
"return a collection of all subclasses (direct AND indirect) of |
|
10172 | 3271 |
the receiver. Higher level subclasses will come before lower ones. |
3272 |
NameSpaces are excluded from the list." |
|
620 | 3273 |
|
3274 |
|newColl| |
|
3275 |
||
3276 |
newColl := OrderedCollection new. |
|
3277 |
self allSubclassesInOrderDo:[:aClass | |
|
12094 | 3278 |
(aClass isRealNameSpace) ifFalse:[ |
3279 |
newColl add:aClass |
|
3280 |
] |
|
620 | 3281 |
]. |
3282 |
^ newColl |
|
3283 |
||
3284 |
" |
|
9194 | 3285 |
Collection allSubclassesInOrder |
3286 |
" |
|
10172 | 3287 |
|
3288 |
"Modified: / 10-11-2006 / 17:23:06 / cg" |
|
9194 | 3289 |
! |
620 | 3290 |
|
3291 |
allSuperclasses |
|
3292 |
"return a collection of the receivers accumulated superclasses" |
|
3293 |
||
3294 |
|aCollection theSuperClass| |
|
3295 |
||
6395
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
3296 |
theSuperClass := self superclass. |
4451 | 3297 |
theSuperClass isNil ifTrue:[ |
12094 | 3298 |
^ #() |
4451 | 3299 |
]. |
3300 |
aCollection := OrderedCollection new. |
|
3301 |
[theSuperClass notNil] whileTrue:[ |
|
12094 | 3302 |
aCollection add:theSuperClass. |
3303 |
theSuperClass := theSuperClass superclass |
|
620 | 3304 |
]. |
3305 |
^ aCollection |
|
3306 |
||
3307 |
" |
|
12094 | 3308 |
String allSuperclasses |
9194 | 3309 |
" |
3310 |
! |
|
620 | 3311 |
|
3312 |
canBeSubclassed |
|
3313 |
"return true, if its allowed to create subclasses of the receiver. |
|
3314 |
This method is redefined in SmallInteger and UndefinedObject, since |
|
3315 |
instances are detected by their pointer-fields, i.e. they do not have |
|
7435
c5afb1b0fd1b
Prepare for moving of SubclassInfo to subclass instcar in Class
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
3316 |
a class entry (you don't have to understand this :-)" |
10 | 3317 |
|
3318 |
^ true |
|
3319 |
! |
|
3320 |
||
3641 | 3321 |
commonSuperclass:aClass |
3322 |
"Return the common superclass of the receiver and aClass. |
|
6754
d9c0f178f091
commonSuperClass: care for nil subclass
Claus Gittinger <cg@exept.de>
parents:
6733
diff
changeset
|
3323 |
Assumes that there is a common superclass of any two classes. |
d9c0f178f091
commonSuperClass: care for nil subclass
Claus Gittinger <cg@exept.de>
parents:
6733
diff
changeset
|
3324 |
(might return nil, if either the receiver or the argument inherit from nil)" |
3641 | 3325 |
|
3326 |
(aClass includesBehavior:self) ifTrue:[^ self]. |
|
3327 |
(self inheritsFrom:aClass) ifTrue:[^ aClass]. |
|
6754
d9c0f178f091
commonSuperClass: care for nil subclass
Claus Gittinger <cg@exept.de>
parents:
6733
diff
changeset
|
3328 |
superclass isNil ifTrue:[^ nil]. |
d9c0f178f091
commonSuperClass: care for nil subclass
Claus Gittinger <cg@exept.de>
parents:
6733
diff
changeset
|
3329 |
^ superclass commonSuperclass:aClass |
3641 | 3330 |
|
3331 |
" |
|
12094 | 3332 |
Integer commonSuperclass:Fraction |
3333 |
SmallInteger commonSuperclass:Fraction |
|
3334 |
View commonSuperclass:Form |
|
3335 |
View commonSuperclass:Image |
|
3336 |
View commonSuperclass:View |
|
3337 |
Integer commonSuperclass:Autoload |
|
3338 |
Integer commonSuperclass:Object |
|
3641 | 3339 |
" |
3340 |
||
3341 |
"Modified: / 10.7.1998 / 02:13:04 / cg" |
|
9194 | 3342 |
! |
3343 |
||
3344 |
hasMultipleSuperclasses |
|
12094 | 3345 |
"Return true, if this class inherits from other classes |
3346 |
(beside its primary superclass). |
|
3347 |
This method is a preparation for a future multiple inheritance extension |
|
9194 | 3348 |
- currently it is not supported by the VM" |
3349 |
||
3350 |
^ false |
|
3351 |
! |
|
6727 | 3352 |
|
3353 |
inheritsFrom:aClass |
|
3354 |
"return true, if the receiver inherits methods from aClass; |
|
3355 |
i.e. if aClass is on the receivers superclass chain." |
|
3356 |
||
3357 |
^ self isSubclassOf:aClass |
|
620 | 3358 |
|
293 | 3359 |
" |
6727 | 3360 |
True inheritsFrom:Object |
3361 |
LinkedList inheritsFrom:Array |
|
293 | 3362 |
" |
1088 | 3363 |
|
9194 | 3364 |
"Modified: 19.6.1997 / 18:13:21 / cg" |
3365 |
! |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3366 |
|
6727 | 3367 |
subclasses |
3368 |
"return a collection of the direct subclasses of the receiver" |
|
3369 |
||
3370 |
|newColl| |
|
3371 |
||
3372 |
newColl := OrderedCollection new. |
|
3373 |
self subclassesDo:[:aClass | |
|
12094 | 3374 |
newColl add:aClass |
6727 | 3375 |
]. |
7435
c5afb1b0fd1b
Prepare for moving of SubclassInfo to subclass instcar in Class
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
3376 |
^ newColl. |
6727 | 3377 |
! |
3378 |
||
3379 |
superclasses |
|
9194 | 3380 |
"return a collection of the receivers immediate superclasses. |
12094 | 3381 |
This method is a preparation for a future multiple inheritance extension |
9194 | 3382 |
- currently it is not supported by the VM" |
3383 |
||
3384 |
^ Array with:self superclass. |
|
3385 |
||
3386 |
" |
|
12094 | 3387 |
String superclasses |
9194 | 3388 |
" |
3389 |
! |
|
6727 | 3390 |
|
3391 |
withAllSubclasses |
|
12094 | 3392 |
"return a collection containing the receiver and |
6727 | 3393 |
all subclasses (direct AND indirect) of the receiver" |
3394 |
||
3395 |
|coll| |
|
3396 |
||
3397 |
coll := self allSubclasses asOrderedCollection. |
|
3398 |
coll addFirst:self. |
|
3399 |
^ coll |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3400 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3401 |
" |
6727 | 3402 |
Collection withAllSubclasses |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3403 |
" |
620 | 3404 |
! |
3405 |
||
6727 | 3406 |
withAllSuperclasses |
3407 |
"return a collection containing the receiver and all |
|
3408 |
of the receivers accumulated superclasses" |
|
3409 |
||
3410 |
|aCollection| |
|
3411 |
||
3412 |
aCollection := OrderedCollection new. |
|
3413 |
self withAllSuperclassesDo:[:cls | |
|
12094 | 3414 |
aCollection add:cls |
6727 | 3415 |
]. |
9194 | 3416 |
^ aCollection |
3417 |
||
3418 |
" |
|
12094 | 3419 |
String withAllSuperclasses |
9194 | 3420 |
" |
3421 |
! ! |
|
3422 |
||
3423 |
!Behavior methodsFor:'queries-instances'! |
|
6727 | 3424 |
|
3425 |
allDerivedInstances |
|
12094 | 3426 |
"return a collection of all instances of myself and |
6727 | 3427 |
instances of all subclasses of myself. |
3428 |
This method is going to be removed for protocol compatibility with |
|
3429 |
other STs; use allSubInstances" |
|
3430 |
||
3431 |
<resource:#obsolete> |
|
3432 |
||
3433 |
self obsoleteMethodWarning:'use #allSubInstances'. |
|
3434 |
^ self allSubInstances |
|
3435 |
||
9194 | 3436 |
"Modified: 31.7.1997 / 23:04:59 / cg" |
3437 |
! |
|
2436 | 3438 |
|
6727 | 3439 |
allInstances |
3440 |
"return a collection of all my instances" |
|
3441 |
||
3442 |
"Read the documentation on why there seem to be no |
|
3443 |
instances of SmallInteger and UndefinedObject" |
|
3444 |
||
3445 |
|coll| |
|
3446 |
||
3447 |
coll := OrderedCollection new:100. |
|
3448 |
self allInstancesDo:[:anObject | |
|
3449 |
coll add:anObject |
|
3450 |
]. |
|
12094 | 3451 |
^ coll |
2713 | 3452 |
|
3453 |
" |
|
6727 | 3454 |
ScrollBar allInstances |
2713 | 3455 |
" |
6727 | 3456 |
! |
3457 |
||
3458 |
allInstancesWeakly:doWeakly |
|
3459 |
"return a collection of all my instances. |
|
3460 |
If weakly is true, a weak collection is returned." |
|
3461 |
||
3462 |
"Read the documentation on why there seem to be no |
|
3463 |
instances of SmallInteger and UndefinedObject" |
|
3464 |
||
3465 |
|coll| |
|
3466 |
||
3467 |
coll := self allInstances. |
|
3468 |
doWeakly ifTrue:[ |
|
9194 | 3469 |
coll := WeakArray withAll:coll |
3470 |
]. |
|
3471 |
^ coll |
|
3472 |
||
3473 |
"Created: / 19.6.1998 / 02:17:20 / cg" |
|
3474 |
! |
|
6727 | 3475 |
|
3476 |
allSubInstances |
|
12094 | 3477 |
"return a collection of all instances of myself and |
6727 | 3478 |
instances of all subclasses of myself." |
3479 |
||
3480 |
|coll| |
|
3481 |
||
3482 |
coll := OrderedCollection new:100. |
|
3483 |
self allSubInstancesDo:[:anObject | |
|
3484 |
(anObject isKindOf:self) ifTrue:[ |
|
3485 |
coll add:anObject |
|
3486 |
] |
|
3487 |
]. |
|
12094 | 3488 |
^ coll |
6727 | 3489 |
|
3490 |
" |
|
3491 |
View allSubInstances |
|
3492 |
" |
|
2713 | 3493 |
! |
3494 |
||
10669 | 3495 |
anyInstance |
3496 |
"return any of my instances; raise an error, if there is none" |
|
3497 |
||
3498 |
"Read the documentation on why there seem to be no |
|
3499 |
instances of SmallInteger and UndefinedObject" |
|
3500 |
||
3501 |
self allInstancesDo:[:anObject | ^ anObject]. |
|
3502 |
self errorNotFound |
|
3503 |
||
3504 |
" |
|
3505 |
ScrollBar anyInstance |
|
3506 |
SmallInteger anyInstance |
|
3507 |
" |
|
3508 |
||
3509 |
"Created: / 24-07-2007 / 06:12:27 / cg" |
|
3510 |
! |
|
3511 |
||
620 | 3512 |
derivedInstanceCount |
3513 |
"return the number of instances of myself and of subclasses" |
|
3514 |
||
3515 |
|count| |
|
3516 |
||
3517 |
count := 0. |
|
3518 |
ObjectMemory allObjectsDo:[:anObject | |
|
3519 |
(anObject isKindOf:self) ifTrue:[ |
|
3520 |
count := count + 1 |
|
3521 |
] |
|
3522 |
]. |
|
3523 |
^ count |
|
3524 |
||
293 | 3525 |
" |
620 | 3526 |
View derivedInstanceCount |
9194 | 3527 |
SequenceableCollection derivedInstanceCount |
3528 |
Object derivedInstanceCount |
|
3529 |
" |
|
3530 |
! |
|
983 | 3531 |
|
3532 |
hasDerivedInstances |
|
3533 |
"return true, if there are any instances of myself or of any subclass" |
|
3534 |
||
3535 |
"Read the documentation on why there seem to be no |
|
3536 |
instances of SmallInteger and UndefinedObject" |
|
3537 |
||
3538 |
ObjectMemory allObjectsDo:[:anObject | |
|
3539 |
(anObject isKindOf:self) ifTrue:[ |
|
3540 |
^ true |
|
3541 |
] |
|
3542 |
]. |
|
3543 |
^ false |
|
3544 |
||
3545 |
" |
|
9194 | 3546 |
Object hasDerivedInstances - certainly true |
3547 |
SharedQueue hasDerivedInstances |
|
3548 |
" |
|
3549 |
! |
|
620 | 3550 |
|
2674
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3551 |
hasImmediateInstances |
4657
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
3552 |
"return true if this class has immediate instances |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
3553 |
i.e. if the instances are represented in the pointer itself and |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
3554 |
no real object header/storage is used for the object. |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
3555 |
Redefined in classes which have so (only SmallInteger and UndefinedObject)" |
2674
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3556 |
|
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3557 |
^ false |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3558 |
|
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3559 |
"Created: 3.6.1997 / 12:01:05 / cg" |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3560 |
! |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3561 |
|
620 | 3562 |
hasInstances |
3563 |
"return true, if there are any instances of myself" |
|
3564 |
||
3565 |
"Read the documentation on why there seem to be no |
|
3566 |
instances of SmallInteger and UndefinedObject" |
|
3567 |
||
3568 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
3569 |
"/ (anObject class == self) ifTrue:[ |
|
3570 |
"/ ^ true |
|
3571 |
"/ ] |
|
3572 |
"/ ]. |
|
983 | 3573 |
|
620 | 3574 |
ObjectMemory allInstancesOf:self do:[:anObject | |
983 | 3575 |
^ true |
620 | 3576 |
]. |
3577 |
^ false |
|
3578 |
||
293 | 3579 |
" |
620 | 3580 |
Object hasInstances |
3581 |
SequenceableCollection hasInstances |
|
3582 |
Float hasInstances |
|
3583 |
SmallInteger hasInstances |
|
293 | 3584 |
" |
9194 | 3585 |
! |
3586 |
||
3587 |
hasSharedInstances |
|
3588 |
"return true if this class has shared instances, that is, instances |
|
3589 |
with the same value are identical. |
|
3590 |
False is returned here, only redefined in classes which have unified |
|
3591 |
instances (or should be treated so)." |
|
3592 |
||
3593 |
^ false |
|
3594 |
! |
|
3595 |
||
3596 |
instanceCount |
|
6727 | 3597 |
"return the number of instances of myself." |
3598 |
||
3599 |
"Read the documentation on why there seem to be no |
|
3600 |
instances of SmallInteger and UndefinedObject" |
|
3601 |
||
3602 |
|count| |
|
3603 |
||
3604 |
count := 0. |
|
3605 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
3606 |
"/ (anObject class == self) ifTrue:[ |
|
3607 |
"/ count := count + 1 |
|
3608 |
"/ ] |
|
3609 |
"/ ]. |
|
3610 |
||
3611 |
ObjectMemory allInstancesOf:self do:[:anObject | |
|
3612 |
count := count + 1 |
|
3613 |
]. |
|
3614 |
^ count |
|
3615 |
||
3616 |
" |
|
3617 |
View instanceCount |
|
3618 |
Object instanceCount |
|
3619 |
Float instanceCount |
|
3620 |
SequenceableCollection instanceCount |
|
3621 |
SmallInteger instanceCount .... mhmh - hear, hear |
|
3622 |
" |
|
9194 | 3623 |
! ! |
3624 |
||
3625 |
!Behavior methodsFor:'queries-instlayout'! |
|
6727 | 3626 |
|
3627 |
elementByteSize |
|
9194 | 3628 |
"for bit-like containers, return the number of bytes stored per |
3629 |
element. For pointer indexed classes, 0 is returned" |
|
3630 |
||
3631 |
self isBitsExtended ifTrue:[ |
|
3632 |
self isBytes ifTrue:[^ 1]. |
|
3633 |
self isWords ifTrue:[^ 2]. |
|
3634 |
self isSignedWords ifTrue:[^ 2]. |
|
3635 |
self isLongs ifTrue:[^ 4]. |
|
3636 |
self isSignedLongs ifTrue:[^ 4]. |
|
3637 |
self isLongLongs ifTrue:[^ 8]. |
|
3638 |
self isSignedLongLongs ifTrue:[^ 8]. |
|
3639 |
]. |
|
3640 |
self isFloats ifTrue:[^ 4]. |
|
3641 |
self isDoubles ifTrue:[^ 8]. |
|
3642 |
||
3643 |
^ 0 |
|
3644 |
||
3645 |
! |
|
6727 | 3646 |
|
3647 |
isBits |
|
3648 |
"return true, if instances have indexed byte or short instance variables. |
|
3649 |
Ignore long, float and double arrays, since ST-80 code using isBits are probably |
|
3650 |
not prepared to handle them correctly." |
|
3651 |
||
3652 |
%{ /* NOCONTEXT */ |
|
3653 |
||
3654 |
REGISTER int what; |
|
3655 |
||
3656 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
|
3657 |
RETURN (( (what == __MASKSMALLINT(BYTEARRAY)) |
|
12094 | 3658 |
|| (what == __MASKSMALLINT(WORDARRAY))) ? true : false ); |
6727 | 3659 |
%}. |
9194 | 3660 |
^ self isBytes or:[self isWords] |
3661 |
! |
|
3662 |
||
3663 |
isBitsExtended |
|
3664 |
"return true, if instances have indexed byte, short, long or longlong instance variables. |
|
3665 |
Ignore float and double arrays. |
|
3666 |
This is really the thing we expect #isBits to return, however, #isBits |
|
3667 |
is defined to only return true for byte- and wordIndexed instances. |
|
3668 |
This avoids confusion of ST80 code, which is not prepared for long or longLong |
|
3669 |
instVars." |
|
3670 |
||
3671 |
%{ /* NOCONTEXT */ |
|
3672 |
||
3673 |
REGISTER int what; |
|
3674 |
||
3675 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
|
6727 | 3676 |
RETURN (( (what == __MASKSMALLINT(BYTEARRAY)) |
3677 |
|| (what == __MASKSMALLINT(WORDARRAY)) |
|
3678 |
|| (what == __MASKSMALLINT(SWORDARRAY)) |
|
3679 |
|| (what == __MASKSMALLINT(LONGARRAY)) |
|
3680 |
|| (what == __MASKSMALLINT(SLONGARRAY)) |
|
3681 |
|| (what == __MASKSMALLINT(LONGLONGARRAY)) |
|
12094 | 3682 |
|| (what == __MASKSMALLINT(SLONGLONGARRAY))) ? true : false ); |
6727 | 3683 |
%} |
3684 |
! |
|
3685 |
||
3686 |
isBytes |
|
3687 |
"return true, if instances have indexed byte instance variables" |
|
3688 |
||
3689 |
"this could also be defined as: |
|
3690 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagBytes |
|
3691 |
" |
|
3692 |
%{ /* NOCONTEXT */ |
|
3693 |
||
12094 | 3694 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(BYTEARRAY)) ? true : false ); |
6727 | 3695 |
%} |
3696 |
! |
|
3697 |
||
3698 |
isDoubles |
|
3699 |
"return true, if instances have indexed double instance variables" |
|
3700 |
||
3701 |
"this could also be defined as: |
|
3702 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagDoubles |
|
3703 |
" |
|
3704 |
%{ /* NOCONTEXT */ |
|
3705 |
||
12094 | 3706 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(DOUBLEARRAY)) ? true : false ); |
9194 | 3707 |
%} |
3708 |
! |
|
6727 | 3709 |
|
3710 |
isFixed |
|
3711 |
"return true, if instances do not have indexed instance variables" |
|
3712 |
||
3713 |
"this could also be defined as: |
|
12094 | 3714 |
^ self isVariable not |
6727 | 3715 |
" |
3716 |
||
3717 |
%{ /* NOCONTEXT */ |
|
3718 |
||
12094 | 3719 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? false : true ); |
6727 | 3720 |
%}. |
3721 |
^ self isVariable not |
|
3722 |
! |
|
3723 |
||
3724 |
isFloats |
|
9194 | 3725 |
"return true, if instances have indexed float instance variables" |
6727 | 3726 |
|
3727 |
"this could also be defined as: |
|
9194 | 3728 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagFloats |
6727 | 3729 |
" |
9194 | 3730 |
%{ /* NOCONTEXT */ |
3731 |
||
12094 | 3732 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(FLOATARRAY)) ? true : false ); |
9194 | 3733 |
%} |
3734 |
! |
|
3735 |
||
3736 |
isFloatsOrDoubles |
|
3737 |
"return true, if instances have indexed float or double instance variables" |
|
3738 |
||
3739 |
%{ /* NOCONTEXT */ |
|
3740 |
||
3741 |
int what; |
|
3742 |
||
3743 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
|
3744 |
RETURN (( (what == __MASKSMALLINT(FLOATARRAY)) |
|
12094 | 3745 |
|| (what == __MASKSMALLINT(DOUBLEARRAY))) ? true : false ); |
9194 | 3746 |
%}. |
3747 |
^ self isFloats or:[self isDoubles] |
|
3748 |
||
3749 |
" |
|
12094 | 3750 |
(Object new) class isFloatsOrDoubles |
3751 |
(Point new) class isFloatsOrDoubles |
|
3752 |
(Array new) class isFloatsOrDoubles |
|
3753 |
(ByteArray new) class isFloatsOrDoubles |
|
3754 |
(FloatArray new) class isFloatsOrDoubles |
|
3755 |
(DoubleArray new) class isFloatsOrDoubles |
|
6727 | 3756 |
" |
3757 |
! |
|
3758 |
||
3759 |
isLongLongs |
|
3760 |
"return true, if instances have indexed long-long instance variables (8 byte uints)" |
|
3761 |
||
3762 |
%{ /* NOCONTEXT */ |
|
3763 |
||
3764 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(LONGLONGARRAY)) ? true : false ); |
|
3765 |
%} |
|
3766 |
! |
|
3767 |
||
3768 |
isLongs |
|
9194 | 3769 |
"return true, if instances have indexed long instance variables (4 byte uints)" |
3770 |
||
3771 |
%{ /* NOCONTEXT */ |
|
3772 |
||
12094 | 3773 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(LONGARRAY)) ? true : false ); |
9194 | 3774 |
%} |
3775 |
! |
|
3776 |
||
3777 |
isPointers |
|
12094 | 3778 |
"return true, if instances have pointer instance variables |
9194 | 3779 |
i.e. are either non-indexed or have indexed pointer variables" |
3780 |
||
3781 |
"QUESTION: should we ignore WeakPointers ?" |
|
6727 | 3782 |
|
3783 |
%{ /* NOCONTEXT */ |
|
3784 |
||
9194 | 3785 |
REGISTER int flags; |
3786 |
||
3787 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
|
3788 |
switch (flags) { |
|
3789 |
default: |
|
3790 |
/* normal objects */ |
|
3791 |
RETURN ( true ); |
|
3792 |
||
3793 |
case BYTEARRAY: |
|
3794 |
case WORDARRAY: |
|
3795 |
case LONGARRAY: |
|
3796 |
case SWORDARRAY: |
|
3797 |
case SLONGARRAY: |
|
3798 |
case SLONGLONGARRAY: |
|
3799 |
case LONGLONGARRAY: |
|
6727 | 3800 |
case FLOATARRAY: |
3801 |
case DOUBLEARRAY: |
|
3802 |
RETURN (false ); |
|
3803 |
||
3804 |
case WKPOINTERARRAY: |
|
3805 |
/* what about those ? */ |
|
3806 |
RETURN (true ); |
|
3807 |
} |
|
3808 |
%} |
|
3809 |
! |
|
3810 |
||
3811 |
isSignedLongLongs |
|
3812 |
"return true, if instances have indexed signed long-long instance variables (8 byte ints)" |
|
3813 |
||
3814 |
%{ /* NOCONTEXT */ |
|
3815 |
||
3816 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SLONGLONGARRAY)) ? true : false ); |
|
3817 |
%} |
|
3818 |
! |
|
3819 |
||
3820 |
isSignedLongs |
|
9194 | 3821 |
"return true, if instances have indexed signed long instance variables (4 byte ints)" |
3822 |
||
3823 |
%{ /* NOCONTEXT */ |
|
3824 |
||
3825 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SLONGARRAY)) ? true : false ); |
|
3826 |
%} |
|
3827 |
! |
|
6727 | 3828 |
|
3829 |
isSignedWords |
|
3830 |
"return true, if instances have indexed signed short instance variables" |
|
3831 |
||
3832 |
%{ /* NOCONTEXT */ |
|
3833 |
||
3834 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SWORDARRAY)) ? true : false ); |
|
3835 |
%} |
|
3836 |
! |
|
3837 |
||
3838 |
isVariable |
|
3839 |
"return true, if instances have indexed instance variables" |
|
3840 |
||
3841 |
"this could also be defined as: |
|
9194 | 3842 |
^ (flags bitAnd:(Behavior maskIndexType)) ~~ 0 |
3843 |
" |
|
3844 |
||
3845 |
%{ /* NOCONTEXT */ |
|
3846 |
||
12094 | 3847 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? true : false ); |
9194 | 3848 |
%} |
3849 |
! |
|
6727 | 3850 |
|
3851 |
isWeakPointers |
|
3852 |
"return true, if instances have weak pointer instance variables" |
|
3853 |
||
3854 |
%{ /* NOCONTEXT */ |
|
3855 |
||
3856 |
REGISTER int flags; |
|
3857 |
||
3858 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
|
3859 |
if (flags == WKPOINTERARRAY) { |
|
12094 | 3860 |
RETURN ( true ); |
6727 | 3861 |
} |
3862 |
%}. |
|
3863 |
^ false |
|
3864 |
! |
|
3865 |
||
3866 |
isWords |
|
3867 |
"return true, if instances have indexed short instance variables" |
|
3868 |
||
3869 |
"this could also be defined as: |
|
9194 | 3870 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagWords |
3871 |
" |
|
3872 |
%{ /* NOCONTEXT */ |
|
3873 |
||
12094 | 3874 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(WORDARRAY)) ? true : false ); |
6727 | 3875 |
%} |
9194 | 3876 |
! |
3877 |
||
3878 |
sizeOfInst:n |
|
6727 | 3879 |
"return the number of bytes required for an instance of |
12094 | 3880 |
myself with n indexed instance variables. The argument n |
6727 | 3881 |
should be zero for classes without indexed instance variables. |
3882 |
See Behavior>>niceNew: for an application of this." |
|
3883 |
||
3884 |
|nInstvars| |
|
3885 |
||
3886 |
nInstvars := self instSize. |
|
3887 |
%{ |
|
8910 | 3888 |
INT nBytes; |
6727 | 3889 |
|
12094 | 3890 |
nBytes = __intVal(nInstvars) * sizeof(OBJ) + OHDR_SIZE; |
6727 | 3891 |
if (__isSmallInteger(n)) { |
3892 |
int nIndex; |
|
3893 |
||
3894 |
nIndex = __intVal(n); |
|
3895 |
switch (__intVal(__INST(flags)) & ARRAYMASK) { |
|
3896 |
case BYTEARRAY: |
|
3897 |
nBytes += nIndex; |
|
3898 |
if (nBytes & (__ALIGN__ - 1)) { |
|
3899 |
nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__; |
|
3900 |
} |
|
3901 |
break; |
|
3902 |
||
3903 |
case WORDARRAY: |
|
3904 |
case SWORDARRAY: |
|
3905 |
nBytes += nIndex * 2; |
|
3906 |
if (nBytes & (__ALIGN__ - 1)) { |
|
3907 |
nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__; |
|
3908 |
} |
|
9194 | 3909 |
break; |
3910 |
||
3911 |
case LONGARRAY: |
|
3912 |
case SLONGARRAY: |
|
3913 |
nBytes += nIndex * 4; |
|
3914 |
break; |
|
3915 |
||
3916 |
case LONGLONGARRAY: |
|
3917 |
case SLONGLONGARRAY: |
|
3918 |
nBytes += nIndex * 8; |
|
3919 |
break; |
|
3920 |
||
3921 |
case FLOATARRAY: |
|
3922 |
nBytes += nIndex * sizeof(float); |
|
3923 |
break; |
|
3924 |
||
3925 |
case DOUBLEARRAY: |
|
3926 |
nBytes += nIndex * sizeof(double); |
|
3927 |
break; |
|
3928 |
||
3929 |
default: |
|
3930 |
nBytes += nIndex * sizeof(OBJ); |
|
3931 |
break; |
|
3932 |
} |
|
3933 |
} |
|
3934 |
RETURN (__mkSmallInteger(nBytes)); |
|
3935 |
%} |
|
3936 |
! ! |
|
3937 |
||
3938 |
!Behavior methodsFor:'queries-protocol'! |
|
6727 | 3939 |
|
3940 |
allSelectors |
|
3941 |
"return a collection of all selectors understood by the receiver; |
|
3942 |
this includes my selectors and all superclass selectors |
|
3943 |
(i.e. the receivers full protocol)" |
|
3944 |
||
3945 |
|superclass| |
|
3946 |
||
3947 |
superclass := self superclass. |
|
3948 |
superclass notNil ifTrue:[ |
|
12094 | 3949 |
^ superclass allSelectors addAll:(self selectors); yourself. |
6727 | 3950 |
]. |
3951 |
^ self selectors asIdentitySet |
|
3952 |
||
3953 |
" |
|
3954 |
Point allSelectors |
|
3955 |
View allSelectors |
|
9194 | 3956 |
Array allSelectors |
3957 |
" |
|
3958 |
! |
|
3959 |
||
3960 |
cachedLookupMethodFor:aSelector |
|
3961 |
"return the method, which would be executed if aSelector was sent to |
|
3962 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
3963 |
and all of its superclasses are searched for aSelector. |
|
3964 |
Return the method, or nil if instances do not understand aSelector. |
|
3965 |
This interface provides exactly the same information as #lookupMethodFor:, |
|
12094 | 3966 |
but uses the lookup-cache in the VM for faster search. |
9194 | 3967 |
However, keep in mind, that doing a lookup through the cache also adds new |
12094 | 3968 |
entries and can thus slow down the system by polluting the cache with |
6727 | 3969 |
irrelevant entries. (do NOT loop over all objects calling this method). |
3970 |
Does NOT (currently) handle MI" |
|
3971 |
||
3972 |
%{ /* NOCONTEXT */ |
|
3973 |
RETURN ( __lookup(self, aSelector) ); |
|
3974 |
%} |
|
3975 |
||
3976 |
" |
|
3977 |
String cachedLookupMethodFor:#= |
|
3978 |
String cachedLookupMethodFor:#asOrderedCollection |
|
3979 |
" |
|
3980 |
! |
|
3981 |
||
3982 |
canUnderstand:aSelector |
|
9194 | 3983 |
"return true, if the receiver or one of its superclasses implements aSelector. |
3984 |
(i.e. true if my instances understand aSelector)" |
|
3985 |
||
3986 |
^ (self lookupMethodFor:aSelector) notNil |
|
3987 |
||
3988 |
" |
|
3989 |
True canUnderstand:#ifTrue: |
|
3990 |
True canUnderstand:#== |
|
3991 |
True canUnderstand:#do: |
|
3992 |
" |
|
3993 |
! |
|
6727 | 3994 |
|
3995 |
compiledMethodAt:aSelector |
|
3996 |
"return the method for given selector aSelector or nil. |
|
3997 |
Only methods in the receiver - not in the superclass chain are tested." |
|
3998 |
||
3999 |
^ self compiledMethodAt:aSelector ifAbsent:nil |
|
4000 |
||
4001 |
" |
|
4002 |
Object compiledMethodAt:#== |
|
4003 |
(Object compiledMethodAt:#==) category |
|
4004 |
" |
|
4005 |
||
4006 |
"Modified: / 7.6.1996 / 14:43:32 / stefan" |
|
4007 |
"Modified: / 27.10.1997 / 20:18:55 / cg" |
|
4008 |
! |
|
4009 |
||
4010 |
compiledMethodAt:aSelector ifAbsent:exceptionValue |
|
4011 |
"return the method for given selector aSelector or the value |
|
4012 |
of exceptionValue if not present. |
|
4013 |
Only methods in the receiver - not in the superclass chain are tested." |
|
4014 |
||
4015 |
|dict| |
|
4016 |
||
4017 |
dict := self methodDictionary. |
|
4018 |
dict isNil ifTrue:[ |
|
4019 |
('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR. |
|
4020 |
^ exceptionValue value |
|
4021 |
]. |
|
4022 |
||
4023 |
^ dict at:aSelector ifAbsent:exceptionValue |
|
4024 |
||
4025 |
" |
|
4026 |
Object compiledMethodAt:#== |
|
4027 |
(Object compiledMethodAt:#==) category |
|
4028 |
" |
|
4029 |
||
4030 |
"Modified: / 7.6.1996 / 14:43:32 / stefan" |
|
4031 |
"Modified: / 10.1.1997 / 17:27:21 / cg" |
|
4032 |
"Created: / 27.10.1997 / 20:18:28 / cg" |
|
9194 | 4033 |
! |
4034 |
||
4035 |
containsMethod:aMethod |
|
4036 |
"Return true, if the argument, aMethod is a method of myself" |
|
4037 |
||
4038 |
|dict| |
|
4039 |
||
12094 | 4040 |
dict := self methodDictionary. |
9194 | 4041 |
dict isNil ifTrue:[^ false]. "degenerated class" |
4042 |
^ (dict keyAtValue:aMethod ifAbsent:[0]) ~~ 0 |
|
4043 |
||
4044 |
"Modified: 12.6.1996 / 13:33:53 / stefan" |
|
4045 |
! |
|
6727 | 4046 |
|
620 | 4047 |
hasMethods |
4048 |
"return true, if there are any (local) methods in this class" |
|
4049 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4050 |
^ (self methodDictionary size ~~ 0) |
620 | 4051 |
|
293 | 4052 |
" |
620 | 4053 |
True hasMethods |
4054 |
True class hasMethods |
|
4055 |
" |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4056 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4057 |
"Modified: 7.6.1996 / 15:43:09 / stefan" |
620 | 4058 |
! |
4059 |
||
4060 |
implements:aSelector |
|
4061 |
"return true, if the receiver implements aSelector. |
|
4062 |
(i.e. implemented in THIS class - NOT in a superclass). |
|
983 | 4063 |
|
4064 |
Caveat: |
|
4065 |
This simply checks for the selector being present in the classes |
|
4066 |
selector table - therefore, it does not care for ignoredMethods. |
|
4067 |
(but: you should not use this method for protocol-testing, anyway). |
|
4068 |
||
4069 |
Hint: |
|
4070 |
Dont use this method to check if someone responds to a message - |
|
4071 |
use #canUnderstand: on the class or #respondsTo: on the instance |
|
4072 |
to do this." |
|
4073 |
||
4074 |
^ self includesSelector:aSelector |
|
620 | 4075 |
|
4076 |
" |
|
983 | 4077 |
notice: this is class protocol |
4078 |
||
12094 | 4079 |
True implements:#ifTrue: |
4080 |
True implements:#== |
|
983 | 4081 |
|
4082 |
notice: this is instance protocol |
|
4083 |
||
12094 | 4084 |
true respondsTo:#ifTrue: |
4085 |
true respondsTo:#== |
|
983 | 4086 |
|
4087 |
notice: this is class protocol |
|
4088 |
||
12094 | 4089 |
True canUnderstand:#ifTrue: |
4090 |
True canUnderstand:#== |
|
620 | 4091 |
" |
983 | 4092 |
|
4093 |
"Modified: 10.2.1996 / 13:15:56 / cg" |
|
620 | 4094 |
! |
4095 |
||
9194 | 4096 |
includesBehavior:aClass |
4097 |
"return true, if the receiver includes the behavior of aClass; |
|
4098 |
i.e. if is either identical to a class or inherits from it." |
|
4099 |
||
4100 |
^ (self == aClass) or:[self isSubclassOf:aClass] |
|
4101 |
||
4102 |
" |
|
12094 | 4103 |
True includesBehavior:Object |
4104 |
True includesBehavior:Boolean |
|
4105 |
True includesBehavior:True |
|
4106 |
True includesBehavior:False |
|
9194 | 4107 |
" |
4108 |
||
4109 |
"Modified: 19.6.1997 / 18:14:35 / cg" |
|
4110 |
! |
|
4111 |
||
4112 |
includesSelector:aSelector |
|
9219 | 4113 |
"return true, if the methodDictionary of THIS class includes a method for aSelector. |
983 | 4114 |
(i.e. if aSelector is implemented in THIS class - NOT in a superclass). |
4115 |
||
4116 |
Hint: |
|
12094 | 4117 |
Dont use this method to check if someone responds to a message - |
4118 |
use #canUnderstand: on the class or #respondsTo: on the instance |
|
4119 |
to do this." |
|
4307 | 4120 |
|
10534 | 4121 |
^ self methodDictionary includesIdenticalKey:aSelector |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4122 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4123 |
" |
9219 | 4124 |
Object includesSelector:#== |
4125 |
Object includesSelector:#murks |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4126 |
" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4127 |
|
3882 | 4128 |
"Modified: / 7.6.1996 / 14:27:24 / stefan" |
4129 |
"Modified: / 16.10.1998 / 13:00:15 / cg" |
|
9194 | 4130 |
! |
4131 |
||
10085 | 4132 |
instAndClassMethods |
4133 |
^ (self theMetaclass methodDictionary values) , (self theNonMetaclass methodDictionary values) |
|
4134 |
||
4135 |
"Created: / 12-10-2006 / 18:36:57 / cg" |
|
4136 |
"Modified: / 12-10-2006 / 20:36:34 / cg" |
|
4137 |
! |
|
4138 |
||
9194 | 4139 |
lookupMethodFor:aSelector |
620 | 4140 |
"return the method, which would be executed if aSelector was sent to |
4141 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
4142 |
and all of its superclasses are searched for aSelector. |
|
4143 |
Return the method, or nil if instances do not understand aSelector. |
|
4144 |
EXPERIMENTAL: take care of multiple superclasses." |
|
4145 |
||
4146 |
|m cls| |
|
4147 |
||
4148 |
cls := self. |
|
4149 |
[cls notNil] whileTrue:[ |
|
4150 |
m := cls compiledMethodAt:aSelector. |
|
4151 |
m notNil ifTrue:[^ m]. |
|
4152 |
cls hasMultipleSuperclasses ifTrue:[ |
|
4153 |
cls superclasses do:[:aSuperClass | |
|
4154 |
m := aSuperClass lookupMethodFor:aSelector. |
|
4155 |
m notNil ifTrue:[^ m]. |
|
4156 |
]. |
|
4157 |
^ nil |
|
4158 |
] ifFalse:[ |
|
4159 |
cls := cls superclass |
|
4160 |
] |
|
4161 |
]. |
|
4162 |
^ nil |
|
4163 |
! |
|
4164 |
||
6460 | 4165 |
responseTo:aSelector |
12094 | 4166 |
"return the method (from here or the inheritance chain), |
6460 | 4167 |
which implements aSelector; return nil if none." |
4168 |
||
4169 |
|cls| |
|
4170 |
||
4171 |
cls := self whichClassIncludesSelector:aSelector. |
|
4172 |
cls notNil ifTrue:[ |
|
12094 | 4173 |
^ cls compiledMethodAt:aSelector |
6460 | 4174 |
]. |
4175 |
^ nil |
|
4176 |
||
4177 |
" |
|
12094 | 4178 |
String responseTo:#== |
4179 |
String responseTo:#collect: |
|
4180 |
String responseTo:#, |
|
6460 | 4181 |
" |
4182 |
! |
|
4183 |
||
9194 | 4184 |
selectorAtMethod:aMethod |
4185 |
"Return the selector for given method aMethod." |
|
4186 |
||
4187 |
^ self selectorAtMethod:aMethod ifAbsent:[nil] |
|
4188 |
||
620 | 4189 |
" |
9194 | 4190 |
|m| |
4191 |
||
4192 |
m := Object compiledMethodAt:#copy. |
|
4193 |
Fraction selectorAtMethod:m. |
|
4194 |
" |
|
4195 |
" |
|
4196 |
|m| |
|
4197 |
||
4198 |
m := Object compiledMethodAt:#copy. |
|
4199 |
Object selectorAtMethod:m. |
|
4200 |
" |
|
356 | 4201 |
! |
4202 |
||
9194 | 4203 |
selectorAtMethod:aMethod ifAbsent:failBlock |
620 | 4204 |
"return the selector for given method aMethod |
4205 |
or the value of failBlock, if not found." |
|
4206 |
||
1814 | 4207 |
|md| |
4208 |
||
4209 |
md := self methodDictionary. |
|
4210 |
md isNil ifTrue:[ |
|
4211 |
'OOPS - nil methodDictionary' errorPrintCR. |
|
4212 |
^ nil |
|
4213 |
]. |
|
4214 |
^ md keyAtValue:aMethod ifAbsent:failBlock. |
|
216 | 4215 |
|
4216 |
" |
|
620 | 4217 |
|m| |
4218 |
||
4219 |
m := Object compiledMethodAt:#copy. |
|
4220 |
Object selectorAtMethod:m ifAbsent:['oops']. |
|
4221 |
" |
|
216 | 4222 |
" |
620 | 4223 |
|m| |
4224 |
||
4225 |
m := Object compiledMethodAt:#copy. |
|
4226 |
Fraction selectorAtMethod:m ifAbsent:['oops']. |
|
216 | 4227 |
" |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4228 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
4229 |
"Modified: 7.6.1996 / 15:15:45 / stefan" |
216 | 4230 |
! |
4231 |
||
2 | 4232 |
whichClassImplements:aSelector |
328 | 4233 |
"obsolete interface; |
4234 |
use whichClassIncludesSelector: for ST-80 compatibility." |
|
4235 |
||
9363 | 4236 |
<resource:#obsolete> |
4237 |
||
328 | 4238 |
^ self whichClassIncludesSelector:aSelector |
4239 |
! |
|
4240 |
||
4241 |
whichClassIncludesSelector:aSelector |
|
68 | 4242 |
"return the class in the inheritance chain, which implements the method |
4243 |
for aSelector; return nil if none. |
|
4244 |
EXPERIMENTAL: handle multiple superclasses" |
|
4245 |
||
4246 |
|cls| |
|
2 | 4247 |
|
68 | 4248 |
cls := self. |
4249 |
[cls notNil] whileTrue:[ |
|
983 | 4250 |
(cls includesSelector:aSelector) ifTrue:[^ cls]. |
154 | 4251 |
cls hasMultipleSuperclasses ifTrue:[ |
4252 |
cls superclasses do:[:aSuperClass | |
|
4253 |
|implementingClass| |
|
2 | 4254 |
|
328 | 4255 |
implementingClass := aSuperClass whichClassIncludesSelector:aSelector. |
154 | 4256 |
implementingClass notNil ifTrue:[^ implementingClass]. |
4257 |
]. |
|
4258 |
^ nil |
|
4259 |
] ifFalse:[ |
|
4260 |
cls := cls superclass |
|
4261 |
] |
|
2 | 4262 |
]. |
4263 |
^ nil |
|
4264 |
||
91 | 4265 |
" |
328 | 4266 |
String whichClassIncludesSelector:#== |
4267 |
String whichClassIncludesSelector:#collect: |
|
91 | 4268 |
" |
6727 | 4269 |
! ! |
4270 |
||
6931 | 4271 |
!Behavior methodsFor:'queries-variables'! |
6727 | 4272 |
|
4273 |
allClassVarNames |
|
4274 |
"return a collection of all the class variable name-strings |
|
4275 |
this includes all superclass-class variables" |
|
4276 |
||
4277 |
^ self addAllClassVarNamesTo:(OrderedCollection new) |
|
4278 |
||
4279 |
" |
|
4280 |
Float allClassVarNames |
|
4281 |
" |
|
4282 |
||
4283 |
"Modified: 16.4.1996 / 18:01:00 / cg" |
|
4284 |
! |
|
4285 |
||
4286 |
allInstVarNames |
|
4287 |
"return a collection of all the instance variable name-strings |
|
4288 |
this includes all superclass-instance variables. |
|
4289 |
Instvars of superclasses come first (i.e. the position matches |
|
4290 |
the instVarAt:-index)." |
|
4291 |
||
4292 |
self superclass isNil ifTrue:[^ self instVarNames]. |
|
4293 |
^ self addAllInstVarNamesTo:(OrderedCollection new) |
|
4294 |
||
4295 |
" |
|
12094 | 4296 |
Dictionary instVarNames |
4297 |
Dictionary allInstVarNames |
|
6727 | 4298 |
" |
4299 |
||
4300 |
"Modified: 16.4.1996 / 18:03:55 / cg" |
|
4301 |
! |
|
4302 |
||
4303 |
allInstanceVariableNames |
|
4304 |
"alias for allInstVarNames" |
|
4305 |
||
4306 |
^ self allInstVarNames |
|
4307 |
! |
|
4308 |
||
4309 |
classVarNames |
|
4310 |
"return a collection of the class variable name-strings. |
|
4311 |
Returning empty here, since Behavior does not define any classVariables. |
|
4312 |
(only Classes do). This allows different Behavior-like objects |
|
4313 |
(alien classes) to be handled by the browser as well." |
|
4314 |
||
4315 |
^ #() |
|
4316 |
||
4317 |
"Created: 16.4.1996 / 17:57:31 / cg" |
|
4318 |
! |
|
4319 |
||
4320 |
classVariableString |
|
4321 |
"return a string of the class variables names. |
|
4322 |
Returning empty here, since Behavior does not define any classVariables. |
|
4323 |
(only Classes do). This allows different Behavior-like objects |
|
4324 |
(alien classes) to be handled by the browser as well." |
|
4325 |
||
4326 |
^ '' |
|
4327 |
||
4328 |
"Created: 16.4.1996 / 16:28:56 / cg" |
|
4329 |
! |
|
4330 |
||
9445 | 4331 |
instVarNameForIndex:index |
4332 |
"Behavior does not provide this info - generate synthetic names." |
|
4333 |
||
4334 |
^ '* instVar' , index printString , ' *' |
|
4335 |
||
4336 |
"Created: / 17-07-2006 / 00:28:24 / cg" |
|
4337 |
! |
|
4338 |
||
6727 | 4339 |
instVarNames |
4340 |
"Behavior does not provide this info - generate synthetic names." |
|
4341 |
||
4342 |
|superclass superInsts| |
|
4343 |
||
4344 |
superclass := self superclass. |
|
4345 |
superclass isNil ifTrue:[ |
|
12094 | 4346 |
superInsts := 0 |
6727 | 4347 |
] ifFalse:[ |
12094 | 4348 |
superInsts := superclass instSize |
6727 | 4349 |
]. |
12094 | 4350 |
^ (superInsts+1 to:self instSize) |
9445 | 4351 |
collect:[:index | self instVarNameForIndex:index] |
4352 |
||
4353 |
"Modified: / 17-07-2006 / 00:28:40 / cg" |
|
6727 | 4354 |
! |
4355 |
||
4356 |
instanceVariableNames |
|
4357 |
"alias for instVarNames." |
|
4358 |
||
4359 |
^ self instVarNames |
|
4360 |
! |
|
4361 |
||
4362 |
instanceVariableString |
|
4363 |
"return a string with dummy names here - typically, your |
|
8857 | 4364 |
objects are instances of Class, not Behavior, |
4365 |
so this is only invoked for very artificial behaviors." |
|
4366 |
||
4367 |
|superclass s superInsts first n "{Class: SmallInteger }"| |
|
6727 | 4368 |
|
4369 |
superclass := self superclass. |
|
4370 |
s := ''. |
|
4371 |
superclass isNil ifTrue:[ |
|
12094 | 4372 |
superInsts := 0 |
6727 | 4373 |
] ifFalse:[ |
12094 | 4374 |
superInsts := superclass instSize |
6727 | 4375 |
]. |
4376 |
n := self instSize. |
|
8857 | 4377 |
first := true. |
6727 | 4378 |
superInsts+1 to:n do:[:i | |
12094 | 4379 |
first ifFalse:[s := s , ' '] ifTrue:[first := false]. |
4380 |
||
4381 |
s := s , 'instvar' , i printString |
|
6727 | 4382 |
]. |
4383 |
^ s |
|
4384 |
||
4385 |
" |
|
12094 | 4386 |
Behavior new instanceVariableString |
4387 |
(Behavior new instSize:2) instanceVariableString |
|
6727 | 4388 |
" |
4389 |
||
4390 |
"Modified: 7.5.1996 / 12:50:25 / cg" |
|
4391 |
"Modified: 3.6.1996 / 16:03:33 / stefan" |
|
4392 |
! |
|
4393 |
||
12094 | 4394 |
whichClassDefinesClassVar: aString |
4395 |
^self whichClassSatisfies: |
|
4396 |
[:aClass | |
|
4397 |
(aClass classVarNames collect: [:each | each asString]) |
|
6727 | 4398 |
includes: aString asString] |
4399 |
! |
|
4400 |
||
12094 | 4401 |
whichClassDefinesInstVar: aString |
6727 | 4402 |
^self whichClassSatisfies: [:aClass | aClass instVarNames includes: aString] |
4403 |
! |
|
4404 |
||
12094 | 4405 |
whichSelectorsAssign: instVarName |
4406 |
"Answer a set of selectors whose methods write the argument, instVarName, |
|
4407 |
as a named instance variable." |
|
4408 |
||
4409 |
^ self whichSelectorsWrite: instVarName |
|
6727 | 4410 |
! |
4411 |
||
12094 | 4412 |
whichSelectorsRead: instVarName |
4413 |
"Answer a set of selectors whose methods read the argument, instVarName, |
|
9194 | 4414 |
as a named instance variable." |
4415 |
||
4416 |
| instVarIndex methodDict| |
|
4417 |
instVarIndex := self allInstVarNames indexOf: instVarName ifAbsent: [^Set new]. |
|
4418 |
methodDict := self methodDictionary. |
|
4419 |
^methodDict keys select: [:sel | (methodDict at: sel) |
|
4420 |
readsField: instVarIndex] |
|
2 | 4421 |
! |
4422 |
||
9194 | 4423 |
whichSelectorsReferTo:someLiteralConstant |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4424 |
"return a collection of selectors of methods which refer to the argument. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4425 |
Search the literal arrays of my methods to do this." |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4426 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4427 |
|setOfSelectors| |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4428 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4429 |
setOfSelectors := IdentitySet new. |
6395
2ad7a8e870ab
instance variables should only be accessed by getters/setters
Claus Gittinger <cg@exept.de>
parents:
6329
diff
changeset
|
4430 |
self methodDictionary keysAndValuesDo:[:sel :mthd | |
12094 | 4431 |
(mthd referencesLiteral:someLiteralConstant) ifTrue:[ |
4432 |
setOfSelectors add:sel |
|
4433 |
]. |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4434 |
]. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4435 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4436 |
^ setOfSelectors |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4437 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4438 |
" |
12094 | 4439 |
String whichSelectorsReferTo:#at: |
4440 |
String whichSelectorsReferTo:CharacterArray |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4441 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4442 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4443 |
"Modified: / 28.10.1997 / 13:13:18 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4444 |
! |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
4445 |
|
5297 | 4446 |
whichSelectorsReferToClassVariable:nameOfClassVariable |
4447 |
"return a collection of selectors of methods which refer to the argument. |
|
4448 |
Search the literal arrays of my methods to do this." |
|
4449 |
||
10413 | 4450 |
^ self whichSelectorsReferToGlobal:(self theNonMetaclass globalKeyForClassVar:nameOfClassVariable) |
5297 | 4451 |
|
4452 |
" |
|
4453 |
Object whichSelectorsReferToClassVariable:#Dependencies |
|
4454 |
" |
|
4455 |
||
10185 | 4456 |
"Modified: / 18-11-2006 / 17:14:08 / cg" |
5297 | 4457 |
! |
4458 |
||
4459 |
whichSelectorsReferToGlobal:nameOfGlobal |
|
4460 |
"return a collection of selectors of methods which refer to the argument. |
|
4461 |
Search the literal arrays of my methods to do this." |
|
4462 |
||
4463 |
|internalNameOfVar| |
|
4464 |
||
4465 |
internalNameOfVar := nameOfGlobal asSymbol. |
|
4466 |
^ self whichSelectorsReferTo:internalNameOfVar |
|
4467 |
||
4468 |
" |
|
4469 |
Object whichSelectorsReferToGlobal:#Debugger |
|
4470 |
" |
|
4471 |
||
4472 |
"Modified: / 4.2.2000 / 00:41:10 / cg" |
|
4473 |
! |
|
4474 |
||
12094 | 4475 |
whichSelectorsWrite: instVarName |
4476 |
"Answer a set of selectors whose methods write the argument, instVarName, |
|
6727 | 4477 |
as a named instance variable." |
4478 |
||
4479 |
| instVarIndex methodDict | |
|
4480 |
instVarIndex := self allInstVarNames indexOf: instVarName ifAbsent: [^Set new]. |
|
4481 |
methodDict := self methodDictionary. |
|
4482 |
^methodDict keys select: [:sel | (methodDict at: sel) |
|
4483 |
writesField: instVarIndex] |
|
2 | 4484 |
! ! |
620 | 4485 |
|
4486 |
!Behavior methodsFor:'snapshots'! |
|
4487 |
||
9194 | 4488 |
postSnapshot |
4489 |
"sent by ObjectMemory to all classes, after a snapshot has been written. |
|
4490 |
Nothing done here. This can be redefined in classes which like to know |
|
4491 |
about snapshooting." |
|
4492 |
||
4493 |
"Modified: 16.4.1996 / 18:12:08 / cg" |
|
4494 |
! |
|
9189
3fbc934d46a9
readFromString: - allow for whitespace following the string
Claus Gittinger <cg@exept.de>
parents:
8962
diff
changeset
|
4495 |
|
3fbc934d46a9
readFromString: - allow for whitespace following the string
Claus Gittinger <cg@exept.de>
parents:
8962
diff
changeset
|
4496 |
preSnapshot |
3fbc934d46a9
readFromString: - allow for whitespace following the string
Claus Gittinger <cg@exept.de>
parents:
8962
diff
changeset
|
4497 |
"sent by ObjectMemory to all classes, before a snapshot is written. |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
4498 |
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
|
4499 |
about snapshooting." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
4500 |
|
9189
3fbc934d46a9
readFromString: - allow for whitespace following the string
Claus Gittinger <cg@exept.de>
parents:
8962
diff
changeset
|
4501 |
"Modified: 16.4.1996 / 18:12:14 / cg" |
620 | 4502 |
! ! |
4503 |
||
4657
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
4504 |
!Behavior methodsFor:'tracing'! |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
4505 |
|
9194 | 4506 |
traceInto:aRequestor level:level from:referrer |
4507 |
"double dispatch into tracer, passing my type implicitely in the selector" |
|
4508 |
||
4509 |
^ aRequestor traceBehavior:self level:level from:referrer |
|
4510 |
||
4511 |
||
4657
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
4512 |
! ! |
ace3dc642424
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
4636
diff
changeset
|
4513 |
|
9194 | 4514 |
!Behavior methodsFor:'visiting'! |
4515 |
||
4516 |
acceptVisitor:aVisitor with:aParameter |
|
8398
666ef609ec93
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8353
diff
changeset
|
4517 |
|
666ef609ec93
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8353
diff
changeset
|
4518 |
^ aVisitor visitBehavior:self with:aParameter |
666ef609ec93
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8353
diff
changeset
|
4519 |
! ! |
666ef609ec93
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8353
diff
changeset
|
4520 |
|
1760 | 4521 |
!Behavior class methodsFor:'documentation'! |
662 | 4522 |
|
4523 |
version |
|
12148
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
4524 |
^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.293 2009-10-05 18:06:38 cg Exp $' |
12113
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
4525 |
! |
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
4526 |
|
6fbe0157e258
changed: #definitionSelectors
Claus Gittinger <cg@exept.de>
parents:
12094
diff
changeset
|
4527 |
version_CVS |
12148
e7a761017355
added: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12114
diff
changeset
|
4528 |
^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.293 2009-10-05 18:06:38 cg Exp $' |
662 | 4529 |
! ! |