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