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