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