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