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