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