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