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