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