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