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