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