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