author | Claus Gittinger <cg@exept.de> |
Mon, 22 Feb 1999 22:06:24 +0100 | |
changeset 3996 | 3183ccccabaa |
parent 3980 | 8f9443e37693 |
child 4307 | 29dd3e6c91ca |
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 |
" |
|
12 |
||
13 |
Object subclass:#Behavior |
|
1634 | 14 |
instanceVariableNames:'superclass flags methodDictionary otherSuperclasses instSize' |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
15 |
classVariableNames:'SubclassInfo' |
1088 | 16 |
poolDictionaries:'' |
17 |
category:'Kernel-Classes' |
|
1 | 18 |
! |
19 |
||
1760 | 20 |
!Behavior class methodsFor:'documentation'! |
47 | 21 |
|
88 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
154 | 25 |
All Rights Reserved |
88 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
47 | 36 |
documentation |
37 |
" |
|
68 | 38 |
Every class in the system inherits from Behavior (via Class, ClassDescription); |
39 |
so here is where most of the class messages end up being implemented. |
|
40 |
(to answer a FAQ: 'Point basicNew' will be done here :-) |
|
41 |
||
356 | 42 |
Beginners should keep in mind, that all classes are instances (of subclasses) |
91 | 43 |
of Behavior, therefore you will find the above mentioned 'basicNew:' method |
44 |
under the 'instance'-methods of Behavior - NOT under the class methods |
|
154 | 45 |
('Behavior new' will create and return a new class, while sending 'new' to |
46 |
any instance of Behavior (i.e. any class) will return an instance of that class). |
|
68 | 47 |
|
2226 | 48 |
|
68 | 49 |
Behavior provides minimum support for all classes - additional stuff is |
77 | 50 |
found in ClassDescription and Class. Behaviors provides all mechanisms needed |
51 |
to create instances, and send messages to those. However, Behavior does not provide |
|
52 |
all the (symbolic) information needed to compile methods for a class or to get |
|
53 |
useful information in inspectors. |
|
47 | 54 |
|
2226 | 55 |
for experts: |
56 |
||
57 |
Since instances of Behavior provide all that is needed to interact with the VM's |
|
58 |
message dispatch mechanism, these can be used as 'light weight' classes. |
|
59 |
I.e. it is possible, to generate completely anonymous classes (and instances thereof) |
|
60 |
on the fly - 'Behavior new new' is such a thingy. |
|
61 |
||
62 |
The selectors and Methods are organized in a MethodDictionary (which is not a true |
|
63 |
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
|
64 |
This avoids the need for knowledge about Dictionaries in the runtime library (VM) |
68 | 65 |
(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
|
66 |
hashed dictionary is almost void). |
1 | 67 |
|
1285 | 68 |
[Instance variables:] |
69 |
||
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
70 |
superclass <Class> the receivers superclass |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
71 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
72 |
otherSuperclasses <Array of Class> experimental: other superclasses |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
73 |
a hook for experimental multiple inheritance |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
74 |
implementations |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
75 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
76 |
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
|
77 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
78 |
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
|
79 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
80 |
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
|
81 |
not for application use |
1 | 82 |
|
81 | 83 |
flag bits (see stc.h): |
47 | 84 |
|
68 | 85 |
NOTICE: layout known by compiler and runtime system; be careful when changing |
1285 | 86 |
|
1292 | 87 |
[author:] |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
88 |
Claus Gittinger |
1292 | 89 |
|
1285 | 90 |
[see also:] |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
91 |
Class ClassDescription Metaclass |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
92 |
Method MethodDictionary |
47 | 93 |
" |
356 | 94 |
! |
95 |
||
96 |
virtualMachineRelationship |
|
97 |
" |
|
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
98 |
Expert info follows: |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
99 |
|
357 | 100 |
NOTICE: |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
101 |
the stuff described below may not be available on other |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
102 |
Smalltalk implementations; be aware that these error mechanisms |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
103 |
are ST/X specials and applications using these (tricks) may |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
104 |
not be portable to other systems. |
357 | 105 |
|
106 |
WARNING: |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
107 |
do not try the examples below on (some) other smalltalk systems; |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
108 |
it has been reported, that some crash badly when doing this .... ;-) |
357 | 109 |
|
356 | 110 |
Instances of Behavior and subclasses (i.e. in sloppy words: classes) |
111 |
play a special role w.r.t. the VM. Only objects whose class-slot is marked |
|
112 |
as being behaviorLike (in the flag-instvar) are considered to be classLike |
|
113 |
and a message lookup will be done for it in the well known way. |
|
114 |
Thus, if an object has a class for which its class does NOT have |
|
362 | 115 |
this flag bit set, the VM will trigger an error on a message send. |
356 | 116 |
|
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
117 |
|
356 | 118 |
Why is this so: |
119 |
||
120 |
the above lets every object play the role of a class, |
|
121 |
which has been flagged as behaviorLike in its class's flag. |
|
122 |
Thus, you can create arbitrary new classLike objects and have the VM |
|
123 |
play with them. |
|
124 |
This may offer the flexibility to create a totally different object scheme |
|
362 | 125 |
on top of ST/X (for example: Self like objects) where any object can play |
126 |
a classRole for another object. |
|
356 | 127 |
|
2148 | 128 |
[A concrete application of this is found in the Structure class, |
129 |
which creates objects which are their own class !! |
|
130 |
This may look to be of theoretical value at first sight, |
|
131 |
however, such a construct saves memory, by not requiring an extra |
|
132 |
class object per Structure object.] |
|
133 |
||
134 |
Be aware, that the VM trusts the isBehaviorLike flag - IF it is set for some |
|
135 |
object, the VM EXPECTS the object selector and methodDictionaries to be found |
|
362 | 136 |
at the instance positions as defined here. |
137 |
(i.e. instanceVariables with contents and semantic corresponding to |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
138 |
superclass |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
139 |
flags |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
140 |
methodDictionary |
362 | 141 |
must be present and have the same instVar-index as here). |
142 |
||
356 | 143 |
The VM (and the system) may crash badly, if this is not the case. |
362 | 144 |
|
356 | 145 |
Since every class in the system derives from Behavior, the flag setting |
357 | 146 |
(and instance variable layout) is correct for all 'normal' classes. |
147 |
If you experiment by creating new behaviorLike objects, please take |
|
148 |
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
|
149 |
instVars 'superclass' and 'methodDictionary' are required |
357 | 150 |
and have to be at the same instVar index. |
362 | 151 |
(we suggest, you subclass Behavior, to make certain) |
357 | 152 |
|
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
153 |
|
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
154 |
Vice versa, defining 'dump classes', which have the behaviorLike bit turned |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
155 |
of may be useful as well; if a message is sent to an instance of such |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
156 |
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
|
157 |
#doesNotUnderstand: mechanism - however, since the instance is no good |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
158 |
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
|
159 |
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
|
160 |
and arguments) along with the original receiver. |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
161 |
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
|
162 |
however, you may redefine this in your 'dum class' for recovery. |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
163 |
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
|
164 |
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
|
165 |
interface. |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
166 |
|
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
167 |
All of the above is pure expert stuff |
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
168 |
- 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
|
169 |
ST-programmer, though (and even most of those will never use these features). |
357 | 170 |
|
356 | 171 |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
746
diff
changeset
|
172 |
Examples (only of theoretical interest): |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
173 |
take away the behaviorLike-flag from a class. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
174 |
-> The instances will not understand any messages, since the VM will |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
175 |
not recognize its class as being a class ... |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
176 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
177 |
|newMeta notRecognizedAsClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
178 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
179 |
newMeta := Metaclass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
180 |
newMeta flags:0. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
181 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
182 |
notRecognizedAsClass := newMeta new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
183 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
184 |
someInstance := notRecognizedAsClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
185 |
someInstance perform:#isNil |
356 | 186 |
|
357 | 187 |
|
188 |
Of course, this is an exception which can be handled ...: |
|
189 |
Example: |
|
190 |
||
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
191 |
|newMeta notRecognizedAsClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
192 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
193 |
newMeta := Metaclass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
194 |
newMeta flags:0. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
195 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
196 |
notRecognizedAsClass := newMeta new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
197 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
198 |
someInstance := notRecognizedAsClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
199 |
Object errorSignal handle:[:ex | |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
200 |
ex return |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
201 |
] do:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
202 |
someInstance perform:#isNil |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
203 |
] |
357 | 204 |
|
205 |
||
206 |
likewise, a doesNotUnderstand-notUnderstood can be handled: |
|
207 |
Example: |
|
208 |
||
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
209 |
|newMeta funnyClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
210 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
211 |
newMeta := Metaclass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
212 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
213 |
funnyClass := newMeta new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
214 |
funnyClass setSuperclass:nil. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
215 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
216 |
someInstance := funnyClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
217 |
Object errorSignal handle:[:ex | |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
218 |
ex return |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
219 |
] do:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
220 |
someInstance perform:#isNil |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
221 |
] |
357 | 222 |
|
223 |
||
362 | 224 |
more examples, which try to trick the VM ;-): |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
225 |
badly playing around with a classes internals ... |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
226 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
227 |
|newClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
228 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
229 |
newClass := Class new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
230 |
newClass setSuperclass:nil. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
231 |
someInstance := newClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
232 |
someInstance inspect |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
233 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
234 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
235 |
|newClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
236 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
237 |
newClass := Class new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
238 |
newClass setSuperclass:newClass. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
239 |
someInstance := newClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
240 |
someInstance inspect |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
241 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
242 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
243 |
|newClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
244 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
245 |
newClass := Class new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
246 |
newClass setSuperclass:1. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
247 |
someInstance := newClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
248 |
someInstance inspect |
357 | 249 |
|
250 |
||
356 | 251 |
Example: |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
252 |
creating totally anonymous classes: |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
253 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
254 |
|newClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
255 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
256 |
newClass := Class new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
257 |
someInstance := newClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
258 |
someInstance inspect |
356 | 259 |
|
357 | 260 |
|
356 | 261 |
Example: |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
262 |
creating totally anonymous metaclasses: |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
263 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
264 |
|newMeta newClass someInstance| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
265 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
266 |
newMeta := Metaclass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
267 |
newClass := newMeta new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
268 |
someInstance := newClass new. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
269 |
someInstance inspect |
357 | 270 |
|
2230
b7a86880ab9c
beahvior documentation updated
Claus Gittinger <cg@exept.de>
parents:
2228
diff
changeset
|
271 |
|
357 | 272 |
PS: if you experiment with new behaviorLike objects, you may want |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
273 |
to turn off the VM's debugPrintouts |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
274 |
with: |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
275 |
'Smalltalk debugPrinting:false' |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
276 |
and: |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
277 |
'Smalltalk infoPrinting:false' |
356 | 278 |
" |
47 | 279 |
! ! |
1 | 280 |
|
1760 | 281 |
!Behavior class methodsFor:'creating new classes'! |
1 | 282 |
|
283 |
new |
|
356 | 284 |
"creates and return a new behavior (which is like a class, |
285 |
but without the symbolic & name information). |
|
286 |
Not for normal applications. |
|
287 |
Sending the returned behavior the #new message gives you |
|
288 |
an instance if it. |
|
289 |
||
290 |
Notice: the returned class is given a superclass of Object; |
|
291 |
this allows for its new instances to be inspected and the like." |
|
1 | 292 |
|
293 |
|newClass| |
|
294 |
||
295 |
newClass := self basicNew. |
|
296 |
newClass setSuperclass:Object |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
297 |
methodDictionary:MethodDictionary new |
154 | 298 |
instSize:0 |
345 | 299 |
flags:(self flagBehavior). |
1 | 300 |
^ newClass |
356 | 301 |
|
302 |
" |
|
303 |
Behavior new <- a new behavior |
|
304 |
Behavior new new <- an instance of it |
|
305 |
ClassDescription new <- a new classDescription |
|
306 |
ClassDescription new new <- an instance of it |
|
307 |
Class new <- a new class |
|
308 |
Class new new <- an instance of it |
|
309 |
Metaclass new <- a new metaclass |
|
310 |
Metaclass new new <- an instance (i.e. a class) of it |
|
311 |
Metaclass new new new <- an instance of this new class |
|
312 |
" |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
313 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
314 |
"Modified: 7.6.1996 / 15:38:58 / stefan" |
1 | 315 |
! ! |
316 |
||
1760 | 317 |
!Behavior class methodsFor:'flag bit constants'! |
620 | 318 |
|
319 |
flagBehavior |
|
320 |
"return the flag code which marks Behavior-like instances. |
|
2226 | 321 |
The VM checks this single bit in the flag value when |
620 | 322 |
checking for behaviors." |
323 |
||
324 |
%{ /* NOCONTEXT */ |
|
325 |
/* this is defined as a primitive to get defines from stc.h */ |
|
326 |
||
1133 | 327 |
RETURN ( __MKSMALLINT(BEHAVIOR_INSTS) ); |
620 | 328 |
%} |
329 |
||
330 |
"consistency check: |
|
331 |
all class-entries must be behaviors; |
|
332 |
all behaviors must be flagged so (in its class's flags) |
|
333 |
(otherwise, VM will bark) |
|
334 |
all non-behaviors may not be flagged |
|
335 |
||
336 |
|bit| |
|
337 |
bit := Class flagBehavior. |
|
338 |
||
339 |
ObjectMemory allObjectsDo:[:o| |
|
340 |
o isBehavior ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
341 |
(o class flags bitTest:bit) ifFalse:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
342 |
self halt |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
343 |
]. |
620 | 344 |
] ifFalse:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
345 |
(o class flags bitTest:bit) ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
346 |
self halt |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
347 |
]. |
620 | 348 |
]. |
349 |
o class isBehavior ifFalse:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
350 |
self halt |
620 | 351 |
] ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
352 |
(o class class flags bitTest:bit) ifFalse:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
353 |
self halt |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
354 |
] |
620 | 355 |
] |
356 |
] |
|
357 |
" |
|
358 |
! |
|
359 |
||
360 |
flagBlock |
|
361 |
"return the flag code which marks Block-like instances. |
|
2236 | 362 |
The VM checks for either this bit or the blockLike bit in the flag |
363 |
value when checking for blocks to be evaluated from bytecodes. |
|
364 |
However, compiled code only checks for the block bit." |
|
620 | 365 |
|
366 |
%{ /* NOCONTEXT */ |
|
367 |
/* this is defined as a primitive to get defines from stc.h */ |
|
368 |
||
1133 | 369 |
RETURN ( __MKSMALLINT(BLOCK_INSTS) ); |
620 | 370 |
%} |
371 |
! |
|
372 |
||
373 |
flagBlockContext |
|
374 |
"return the flag code which marks BlockContext-like instances. |
|
2226 | 375 |
The VM checks this single bit in the flag value when |
620 | 376 |
checking for blockContexts." |
377 |
||
378 |
%{ /* NOCONTEXT */ |
|
379 |
/* this is defined as a primitive to get defines from stc.h */ |
|
380 |
||
1133 | 381 |
RETURN ( __MKSMALLINT(BCONTEXT_INSTS) ); |
620 | 382 |
%} |
383 |
! |
|
384 |
||
2236 | 385 |
flagBlockLike |
386 |
"return the flag code which marks Block-like instances |
|
387 |
with respect to byteCode interpretation. |
|
388 |
The VM checks for either this bit or the block bit in the flag |
|
389 |
value when checking for blocks to be evaluated from bytecodes. |
|
390 |
However, compiled code only checks for the block bit." |
|
391 |
||
392 |
%{ /* NOCONTEXT */ |
|
393 |
/* this is defined as a primitive to get defines from stc.h */ |
|
394 |
||
395 |
RETURN ( __MKSMALLINT(BLOCKLIKE_INSTS) ); |
|
396 |
%} |
|
397 |
! |
|
398 |
||
620 | 399 |
flagBytes |
400 |
"return the flag code for byte-valued indexed instances. |
|
2226 | 401 |
The VM masks the flag value with the indexMask (maskIndexType) |
402 |
and compares it to this flag value, when checking for byte valued |
|
403 |
variable instances." |
|
620 | 404 |
|
405 |
%{ /* NOCONTEXT */ |
|
406 |
/* this is defined as a primitive to get defines from stc.h */ |
|
407 |
||
1133 | 408 |
RETURN ( __MKSMALLINT(BYTEARRAY) ); |
620 | 409 |
%} |
410 |
" |
|
411 |
Behavior flagBytes |
|
412 |
" |
|
413 |
! |
|
414 |
||
415 |
flagContext |
|
416 |
"return the flag code which marks Context-like instances. |
|
2226 | 417 |
The VM checks this single bit in the flag value when |
620 | 418 |
checking for contexts." |
419 |
||
420 |
%{ /* NOCONTEXT */ |
|
421 |
/* this is defined as a primitive to get defines from stc.h */ |
|
422 |
||
1133 | 423 |
RETURN ( __MKSMALLINT(CONTEXT_INSTS) ); |
620 | 424 |
%} |
425 |
! |
|
426 |
||
427 |
flagDoubles |
|
428 |
"return the flag code for double-valued indexed instances (i.e. 8-byte reals). |
|
2226 | 429 |
The VM masks the flag value with the indexMask (maskIndexType) |
430 |
and compares it to this flag value, when checking for double valued |
|
431 |
variable instances." |
|
620 | 432 |
|
433 |
%{ /* NOCONTEXT */ |
|
434 |
/* this is defined as a primitive to get defines from stc.h */ |
|
435 |
||
1133 | 436 |
RETURN ( __MKSMALLINT(DOUBLEARRAY) ); |
620 | 437 |
%} |
438 |
" |
|
439 |
Behavior flagDoubles |
|
2226 | 440 |
|
441 |
(ByteArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
442 |
(DoubleArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
443 |
(Object flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles) |
|
620 | 444 |
" |
445 |
! |
|
446 |
||
447 |
flagFloat |
|
448 |
"return the flag code which marks Float-like instances. |
|
2226 | 449 |
The VM checks this single bit in the flag value when |
450 |
checking for a float." |
|
620 | 451 |
|
452 |
%{ /* NOCONTEXT */ |
|
453 |
/* this is defined as a primitive to get defines from stc.h */ |
|
454 |
||
1133 | 455 |
RETURN ( __MKSMALLINT(FLOAT_INSTS) ); |
620 | 456 |
%} |
457 |
! |
|
458 |
||
459 |
flagFloats |
|
460 |
"return the flag code for float-valued indexed instances (i.e. 4-byte reals). |
|
2226 | 461 |
The VM masks the flag value with the indexMask (maskIndexType) |
462 |
and compares it to this flag value, when checking for double valued |
|
463 |
variable instances." |
|
620 | 464 |
|
465 |
%{ /* NOCONTEXT */ |
|
466 |
/* this is defined as a primitive to get defines from stc.h */ |
|
467 |
||
1133 | 468 |
RETURN ( __MKSMALLINT(FLOATARRAY) ); |
620 | 469 |
%} |
470 |
" |
|
471 |
Behavior flagFloats |
|
472 |
" |
|
473 |
! |
|
474 |
||
1634 | 475 |
flagForSymbolic:aSymbol |
476 |
"return the flag code for indexed instances with aSymbolic type. |
|
477 |
The argument may be one of #float, #double, #long, #word, #signedWord, |
|
478 |
#signedLong or #byte." |
|
479 |
||
480 |
%{ /* NOCONTEXT */ |
|
481 |
if (aSymbol == @symbol(float)) { |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
482 |
RETURN ( __MKSMALLINT(FLOATARRAY) ); |
1634 | 483 |
} |
484 |
if (aSymbol == @symbol(double)) { |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
485 |
RETURN ( __MKSMALLINT(DOUBLEARRAY) ); |
1634 | 486 |
} |
487 |
if (aSymbol == @symbol(long)) { |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
488 |
RETURN ( __MKSMALLINT(LONGARRAY) ); |
1634 | 489 |
} |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
490 |
if (aSymbol == @symbol(longLong)) { |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
491 |
RETURN ( __MKSMALLINT(LONGLONGARRAY) ); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
492 |
} |
1634 | 493 |
if (aSymbol == @symbol(word)) { |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
494 |
RETURN ( __MKSMALLINT(WORDARRAY) ); |
1634 | 495 |
} |
496 |
if (aSymbol == @symbol(signedWord)) { |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
497 |
RETURN ( __MKSMALLINT(SWORDARRAY) ); |
1634 | 498 |
} |
499 |
if (aSymbol == @symbol(signedLong)) { |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
500 |
RETURN ( __MKSMALLINT(SLONGARRAY) ); |
1634 | 501 |
} |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
502 |
if (aSymbol == @symbol(signedLongLong)) { |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
503 |
RETURN ( __MKSMALLINT(SLONGLONGARRAY) ); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
504 |
} |
1634 | 505 |
if (aSymbol == @symbol(byte)) { |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
506 |
RETURN ( __MKSMALLINT(BYTEARRAY) ); |
1634 | 507 |
} |
508 |
%}. |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
509 |
^ 0 "/ not indexed |
1634 | 510 |
! |
511 |
||
3141 | 512 |
flagJavaClass |
513 |
"return the flag code which marks JavaClass-like instances. |
|
514 |
The VM checks this single bit in the flag value when |
|
515 |
checking for a javaClass." |
|
516 |
||
517 |
%{ /* NOCONTEXT */ |
|
518 |
/* this is defined as a primitive to get defines from stc.h */ |
|
519 |
||
520 |
RETURN ( __MKSMALLINT(JCLASS_INSTS) ); |
|
521 |
%} |
|
522 |
! |
|
523 |
||
2801 | 524 |
flagJavaMethod |
525 |
"return the flag code which marks JavaMethod-like instances. |
|
526 |
The VM checks this single bit in the flag value when |
|
527 |
checking for a method." |
|
528 |
||
529 |
%{ /* NOCONTEXT */ |
|
530 |
/* this is defined as a primitive to get defines from stc.h */ |
|
531 |
||
532 |
RETURN ( __MKSMALLINT(JMETHOD_INSTS) ); |
|
533 |
%} |
|
534 |
! |
|
535 |
||
620 | 536 |
flagLongs |
537 |
"return the flag code for long-valued indexed instances (i.e. 4-byte). |
|
2226 | 538 |
The VM masks the flag value with the indexMask (maskIndexType) |
539 |
and compares it to this flag value, when checking for |
|
540 |
unsigned long valued variable instances." |
|
620 | 541 |
|
542 |
%{ /* NOCONTEXT */ |
|
543 |
/* this is defined as a primitive to get defines from stc.h */ |
|
544 |
||
1133 | 545 |
RETURN ( __MKSMALLINT(LONGARRAY) ); |
620 | 546 |
%} |
547 |
" |
|
548 |
Behavior flagLongs |
|
549 |
" |
|
550 |
! |
|
551 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
552 |
flagLongLongs |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
553 |
"return the flag code for longlong-valued indexed instances (i.e. 8-byte). |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
554 |
The VM masks the flag value with the indexMask (maskIndexType) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
555 |
and compares it to this flag value, when checking for |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
556 |
unsigned long valued variable instances." |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
557 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
558 |
%{ /* NOCONTEXT */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
559 |
/* this is defined as a primitive to get defines from stc.h */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
560 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
561 |
RETURN ( __MKSMALLINT(LONGLONGARRAY) ); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
562 |
%} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
563 |
" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
564 |
Behavior flagLongLongs |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
565 |
" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
566 |
! |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
567 |
|
620 | 568 |
flagMethod |
569 |
"return the flag code which marks Method-like instances. |
|
2226 | 570 |
The VM checks this single bit in the flag value when |
571 |
checking for a method." |
|
620 | 572 |
|
573 |
%{ /* NOCONTEXT */ |
|
574 |
/* this is defined as a primitive to get defines from stc.h */ |
|
575 |
||
1133 | 576 |
RETURN ( __MKSMALLINT(METHOD_INSTS) ); |
620 | 577 |
%} |
578 |
! |
|
579 |
||
580 |
flagNonObjectInst |
|
581 |
"return the flag code which marks instances which have a |
|
582 |
non-object instance variable (in slot 1). |
|
583 |
(these are ignored by the garbage collector)" |
|
584 |
||
585 |
%{ /* NOCONTEXT */ |
|
586 |
/* this is defined as a primitive to get defines from stc.h */ |
|
587 |
||
1133 | 588 |
RETURN ( __MKSMALLINT(NONOBJECT_INSTS) ); |
620 | 589 |
%} |
590 |
! |
|
591 |
||
592 |
flagNotIndexed |
|
593 |
"return the flag code for non-indexed instances. |
|
594 |
You have to mask the flag value with indexMask when comparing |
|
595 |
it with flagNotIndexed." |
|
596 |
||
597 |
^ 0 |
|
598 |
! |
|
599 |
||
600 |
flagPointers |
|
601 |
"return the flag code for pointer indexed instances (i.e. Array of object). |
|
2226 | 602 |
The VM masks the flag value with the indexMask (maskIndexType) |
603 |
and compares it to this flag value, when checking for |
|
604 |
pointer variable instances." |
|
620 | 605 |
|
606 |
%{ /* NOCONTEXT */ |
|
607 |
/* this is defined as a primitive to get defines from stc.h */ |
|
608 |
||
1133 | 609 |
RETURN ( __MKSMALLINT(POINTERARRAY) ); |
620 | 610 |
%} |
611 |
" |
|
612 |
Behavior flagPointers |
|
613 |
" |
|
614 |
! |
|
615 |
||
1383 | 616 |
flagRegular |
617 |
"return the flag code which marks regular instances." |
|
618 |
||
619 |
^ 0 |
|
620 |
||
621 |
"Created: 12.5.1996 / 17:53:36 / cg" |
|
622 |
! |
|
623 |
||
1634 | 624 |
flagSignedLongs |
625 |
"return the flag code for signed long-valued indexed instances (i.e. 4-byte). |
|
2226 | 626 |
The VM masks the flag value with the indexMask (maskIndexType) |
627 |
and compares it to this flag value, when checking for |
|
628 |
signed long valued variable instances." |
|
1634 | 629 |
|
630 |
%{ /* NOCONTEXT */ |
|
631 |
/* this is defined as a primitive to get defines from stc.h */ |
|
632 |
||
633 |
RETURN ( __MKSMALLINT(SLONGARRAY) ); |
|
634 |
%} |
|
635 |
" |
|
636 |
Behavior flagSignedLongs |
|
637 |
" |
|
638 |
! |
|
639 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
640 |
flagSignedLongLongs |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
641 |
"return the flag code for signed longlong-valued indexed instances (i.e. 8-byte). |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
642 |
The VM masks the flag value with the indexMask (maskIndexType) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
643 |
and compares it to this flag value, when checking for |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
644 |
signed long valued variable instances." |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
645 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
646 |
%{ /* NOCONTEXT */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
647 |
/* this is defined as a primitive to get defines from stc.h */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
648 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
649 |
RETURN ( __MKSMALLINT(SLONGLONGARRAY) ); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
650 |
%} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
651 |
" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
652 |
Behavior flagSignedLongLongs |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
653 |
" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
654 |
! |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
655 |
|
1634 | 656 |
flagSignedWords |
657 |
"return the flag code for signed word-valued indexed instances (i.e. 2-byte). |
|
2226 | 658 |
The VM masks the flag value with the indexMask (maskIndexType) |
659 |
and compares it to this flag value, when checking for |
|
660 |
signed word valued variable instances." |
|
1634 | 661 |
|
662 |
%{ /* NOCONTEXT */ |
|
663 |
/* this is defined as a primitive to get defines from stc.h */ |
|
664 |
||
665 |
RETURN ( __MKSMALLINT(SWORDARRAY) ); |
|
666 |
%} |
|
667 |
" |
|
668 |
Behavior flagSignedWords |
|
669 |
" |
|
670 |
! |
|
671 |
||
620 | 672 |
flagSymbol |
673 |
"return the flag code which marks Symbol-like instances. |
|
2226 | 674 |
The VM checks this single bit in the flag value when |
620 | 675 |
checking for symbols." |
676 |
||
677 |
%{ /* NOCONTEXT */ |
|
678 |
/* this is defined as a primitive to get defines from stc.h */ |
|
679 |
||
1133 | 680 |
RETURN ( __MKSMALLINT(SYMBOL_INSTS) ); |
620 | 681 |
%} |
682 |
! |
|
683 |
||
684 |
flagWeakPointers |
|
685 |
"return the flag code for weak pointer indexed instances (i.e. WeakArray). |
|
2226 | 686 |
The VM masks the flag value with the indexMask (maskIndexType) |
687 |
and compares it to this flag value, when checking for weak pointers." |
|
620 | 688 |
|
689 |
%{ /* NOCONTEXT */ |
|
690 |
/* this is defined as a primitive to get defines from stc.h */ |
|
691 |
||
1133 | 692 |
RETURN ( __MKSMALLINT(WKPOINTERARRAY) ); |
620 | 693 |
%} |
694 |
! |
|
695 |
||
696 |
flagWords |
|
697 |
"return the flag code for word-valued indexed instances (i.e. 2-byte). |
|
2226 | 698 |
The VM masks the flag value with the indexMask (maskIndexType) |
699 |
and compares it to this flag value, when checking for |
|
700 |
unsigned word valued variable instances." |
|
620 | 701 |
|
702 |
%{ /* NOCONTEXT */ |
|
703 |
/* this is defined as a primitive to get defines from stc.h */ |
|
704 |
||
1133 | 705 |
RETURN ( __MKSMALLINT(WORDARRAY) ); |
620 | 706 |
%} |
707 |
" |
|
708 |
Behavior flagWords |
|
709 |
" |
|
710 |
! |
|
711 |
||
712 |
maskIndexType |
|
713 |
"return a mask to extract all index-type bits" |
|
714 |
||
715 |
%{ /* NOCONTEXT */ |
|
716 |
/* this is defined as a primitive to get defines from stc.h */ |
|
717 |
||
1133 | 718 |
RETURN ( __MKSMALLINT(ARRAYMASK) ); |
620 | 719 |
%} |
720 |
! ! |
|
721 |
||
1760 | 722 |
!Behavior class methodsFor:'private '! |
308 | 723 |
|
620 | 724 |
flushSubclassInfo |
2224 | 725 |
"throw away (forget) the cached subclass information, as created |
726 |
by #subclassInfo. |
|
727 |
This is private protocol" |
|
728 |
||
620 | 729 |
SubclassInfo := nil. |
730 |
||
731 |
" |
|
732 |
Class flushSubclassInfo |
|
733 |
" |
|
2224 | 734 |
|
735 |
"Modified: 22.1.1997 / 18:39:36 / cg" |
|
620 | 736 |
! |
737 |
||
308 | 738 |
subclassInfo |
2224 | 739 |
"build & return a dictionary, containing the set of subclass |
740 |
for each class. This information is kept until explicitely flushed |
|
741 |
by #flushSubclassInfo. |
|
742 |
This cache is used internally, for enumerators like #allSubclasses |
|
743 |
or #allSubclassesDo:, to avoid repeated recursive walks over the class |
|
744 |
hierarchy. |
|
745 |
This is private protocol." |
|
746 |
||
357 | 747 |
|d| |
308 | 748 |
|
749 |
SubclassInfo notNil ifTrue:[^ SubclassInfo]. |
|
750 |
||
751 |
d := IdentityDictionary new. |
|
752 |
Smalltalk allClassesDo:[:aClass | |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
753 |
|superCls| |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
754 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
755 |
aClass isMeta not ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
756 |
superCls := aClass superclass. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
757 |
superCls notNil ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
758 |
(d includesKey: superCls) ifFalse:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
759 |
d at:superCls put:(IdentitySet with:aClass). |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
760 |
] ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
761 |
(d at:superCls ) add:aClass |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
762 |
] |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
763 |
] |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
764 |
]. |
308 | 765 |
]. |
766 |
SubclassInfo := d. |
|
767 |
^ d |
|
768 |
||
769 |
" |
|
770 |
Class subclassInfo |
|
771 |
" |
|
2224 | 772 |
|
773 |
"Modified: 22.1.1997 / 18:44:59 / cg" |
|
620 | 774 |
! ! |
775 |
||
1760 | 776 |
!Behavior class methodsFor:'queries'! |
620 | 777 |
|
778 |
isBuiltInClass |
|
1266 | 779 |
"return true if this class is known by the run-time-system. |
780 |
Here, true is returned for myself, false for subclasses." |
|
620 | 781 |
|
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
782 |
^ (self == Behavior class) or:[self == Behavior] |
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
783 |
|
1266 | 784 |
"Modified: 23.4.1996 / 15:55:52 / cg" |
620 | 785 |
! ! |
786 |
||
787 |
!Behavior methodsFor:'accessing'! |
|
788 |
||
789 |
addSelector:newSelector withLazyMethod:newMethod |
|
790 |
"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
|
791 |
1st argument to the methodDictionary. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
792 |
Since it does not normally flush any caches, |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
793 |
this is only allowed for lazy methods (which are for a new class)." |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
794 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
795 |
|oldMethod| |
620 | 796 |
|
797 |
newMethod isLazyMethod ifFalse:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
798 |
self error:'operation only allowed for lazy methods'. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
799 |
^ false |
620 | 800 |
]. |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
801 |
oldMethod := self compiledMethodAt:newSelector. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
802 |
"/ |
620 | 803 |
"/ oops: we must flush, if this method already exists ... |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
804 |
"/ otherwise, the old method would still be executed out of the caches. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
805 |
"/ |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
806 |
oldMethod notNil ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
807 |
newMethod privacy:(oldMethod privacy). |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
808 |
newMethod restricted:(oldMethod isRestricted). |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
809 |
ObjectMemory flushCaches |
620 | 810 |
]. |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
811 |
|
620 | 812 |
(self primAddSelector:newSelector withMethod:newMethod) ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
813 |
"/ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
814 |
"/ pass the selector AND the old method as changeArg |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
815 |
"/ - this allows for watchers to find out if its a new method or a method-change |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
816 |
"/ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
817 |
self changed:#methodDictionary with:(Array with:newSelector with:oldMethod). |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
818 |
"/ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
819 |
"/ also notify a change of Smalltalk; |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
820 |
"/ this allows a dependent of Smalltalk to watch all class |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
821 |
"/ changes (no need for observing all classes) |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
822 |
"/ - this allows for watchers to find out if its a new method or a method-change |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
823 |
"/ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
824 |
Smalltalk changed:#methodInClass with:(Array with:self with:newSelector with:oldMethod). |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
825 |
^ true |
620 | 826 |
]. |
827 |
^ false |
|
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
828 |
|
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
829 |
"Modified: 8.1.1997 / 23:02:10 / cg" |
308 | 830 |
! |
831 |
||
620 | 832 |
addSelector:newSelector withMethod:newMethod |
833 |
"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
|
834 |
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
|
835 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
836 |
|nargs oldMethod| |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
837 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
838 |
oldMethod := self compiledMethodAt:newSelector. |
620 | 839 |
(self primAddSelector:newSelector withMethod:newMethod) ifFalse:[^ false]. |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
840 |
|
620 | 841 |
" |
842 |
if I have no subclasses, all we have to flush is cached |
|
843 |
data for myself ... (actually, in any case all that needs |
|
844 |
to be flushed is info for myself and all of my subclasses) |
|
845 |
" |
|
846 |
" |
|
847 |
problem: this is slower; since looking for all subclasses is (currently) |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
848 |
a bit slow :-( |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
849 |
We need the hasSubclasses-info bit in Behavior; now |
620 | 850 |
|
851 |
self withAllSubclassesDo:[:aClass | |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
852 |
ObjectMemory flushInlineCachesFor:aClass withArgs:nargs. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
853 |
ObjectMemory flushMethodCacheFor:aClass |
620 | 854 |
]. |
855 |
" |
|
856 |
||
857 |
nargs := newSelector numArgs. |
|
858 |
||
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
859 |
ObjectMemory flushMethodCacheForSelector:newSelector. |
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
860 |
"/ ObjectMemory flushMethodCache. |
620 | 861 |
ObjectMemory flushInlineCachesWithArgs:nargs. |
862 |
||
3805
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
863 |
oldMethod notNil ifTrue:[ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
864 |
newMethod privacy:(oldMethod privacy). |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
865 |
newMethod restricted:(oldMethod isRestricted). |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
866 |
]. |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
867 |
|
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
868 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
869 |
"/ 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
|
870 |
"/ - 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
|
871 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
872 |
self changed:#methodDictionary with:(Array with:newSelector with:oldMethod). |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
873 |
|
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
874 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
875 |
"/ 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
|
876 |
"/ 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
|
877 |
"/ 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
|
878 |
"/ - 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
|
879 |
"/ |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
880 |
Smalltalk changed:#methodInClass with:(Array with:self with:newSelector with:oldMethod). |
d525b3acc091
flush cache first in addMethod - then do a change notification
Claus Gittinger <cg@exept.de>
parents:
3641
diff
changeset
|
881 |
|
620 | 882 |
^ true |
734
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
883 |
|
a4378f483a86
pass original method as changeArg when doing method changes;
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
884 |
"Created: 11.12.1995 / 13:59:37 / cg" |
2095
fa85d9f387ac
beside notifying a self-changed,
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
885 |
"Modified: 8.1.1997 / 22:43:13 / cg" |
620 | 886 |
! |
887 |
||
888 |
addSuperclass:aClass |
|
889 |
"EXPERIMENTAL MI support: add aClass to the set of classes, from which instances |
|
890 |
inherit protocol." |
|
891 |
||
892 |
"first, check if the class is abstract - |
|
893 |
allows abstract mixins are allowed in the current implementation" |
|
894 |
||
895 |
aClass instSize == 0 ifFalse:[ |
|
896 |
self error:'only abstract mixins allowed'. |
|
897 |
^ self |
|
898 |
]. |
|
899 |
otherSuperclasses isNil ifTrue:[ |
|
900 |
otherSuperclasses := Array with:aClass |
|
901 |
] ifFalse:[ |
|
902 |
otherSuperclasses := otherSuperclasses copyWith:aClass |
|
903 |
]. |
|
308 | 904 |
SubclassInfo := nil. |
620 | 905 |
ObjectMemory flushCaches |
906 |
! |
|
907 |
||
908 |
displayString |
|
909 |
"although behaviors have no name, we return something |
|
910 |
useful here - there are many places (inspectors) where |
|
911 |
a classes name is asked for. |
|
912 |
Implementing this message here allows instances of anonymous classes |
|
913 |
to show a reasonable name." |
|
914 |
||
915 |
^ 'someBehavior' |
|
916 |
! |
|
917 |
||
918 |
flags |
|
919 |
"return the receivers flag bits" |
|
920 |
||
921 |
^ flags |
|
922 |
! |
|
923 |
||
3327
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
924 |
getMethodDictionary |
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
925 |
"ST 80 compatibility: return the receivers method dictionary." |
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
926 |
|
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
927 |
^ methodDictionary |
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
928 |
|
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
929 |
"Modified: / 6.3.1998 / 15:45:50 / stefan" |
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
930 |
! |
5efc0a1f0e2c
Add #getMethodDictionary (ST80)
Stefan Vogel <sv@exept.de>
parents:
3237
diff
changeset
|
931 |
|
620 | 932 |
instSize |
933 |
"return the number of instance variables of the receiver. |
|
934 |
This includes all superclass instance variables." |
|
935 |
||
936 |
^ instSize |
|
937 |
! |
|
938 |
||
939 |
methodDictionary |
|
1634 | 940 |
"return the receivers method dictionary." |
620 | 941 |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
942 |
^ methodDictionary |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
943 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
944 |
"Modified: 12.6.1996 / 13:47:08 / stefan" |
1634 | 945 |
"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
|
946 |
! |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
947 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
948 |
methodDictionary:dict |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
949 |
"set the receivers method dictionary and flush inline caches." |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
950 |
|
1814 | 951 |
dict isNil ifTrue:[ |
952 |
self halt:'attempt to set methodDictionary to nil.' |
|
953 |
]. |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
954 |
self setMethodDictionary:dict. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
955 |
ObjectMemory flushCaches. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
956 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
957 |
"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
|
958 |
"Modified: 7.6.1996 / 08:39:51 / stefan" |
620 | 959 |
! |
960 |
||
961 |
removeSelector:aSelector |
|
962 |
"remove the selector, aSelector and its associated method |
|
963 |
from the methodDictionary" |
|
964 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
965 |
|dict newDict| |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
966 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
967 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
968 |
newDict := dict removeKeyAndCompress:aSelector. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
969 |
newDict isNil ifTrue:[ |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
970 |
^ false. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
971 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
972 |
self setMethodDictionary:newDict. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
973 |
|
620 | 974 |
" |
975 |
[ |
|
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
976 |
|nargs| |
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
977 |
nargs := aSelector numArgs. |
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
978 |
ObjectMemory flushMethodCache. |
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
979 |
ObjectMemory flushInlineCachesWithArgs:nargs. |
620 | 980 |
] value |
981 |
" |
|
982 |
" |
|
983 |
actually, we would do better with less flushing ... |
|
984 |
" |
|
985 |
ObjectMemory flushCaches. |
|
986 |
^ true |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
987 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
988 |
"Modified: 12.6.1996 / 11:54:29 / stefan" |
620 | 989 |
! |
990 |
||
991 |
removeSuperclass:aClass |
|
992 |
"EXPERIMENTAL MI support: remove aClass from the set of classes, from which instances |
|
993 |
inherit protocol." |
|
994 |
||
995 |
otherSuperclasses notNil ifTrue:[ |
|
996 |
otherSuperclasses := otherSuperclasses copyWithout:aClass. |
|
997 |
otherSuperclasses isEmpty ifTrue:[ |
|
998 |
otherSuperclasses := nil |
|
999 |
]. |
|
1000 |
SubclassInfo := nil. |
|
1001 |
ObjectMemory flushCaches |
|
1002 |
]. |
|
1003 |
! |
|
1004 |
||
1005 |
selectors |
|
1006 |
"return the receivers selector array as an orderedCollection. |
|
1007 |
Notice: this may not be compatible with ST-80. |
|
1008 |
(should we return a Set ?)" |
|
1009 |
||
1814 | 1010 |
|md| |
1011 |
||
1967
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
1012 |
(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
|
1013 |
'oops - nil methodDictionary' errorPrintCR. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1014 |
^ #() |
1814 | 1015 |
]. |
1016 |
^ md keys |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1017 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
1018 |
"Modified: 7.6.1996 / 15:33:18 / stefan" |
1967
e8a6fb1e14ce
oops - iNil instead of isNil
Claus Gittinger <cg@exept.de>
parents:
1918
diff
changeset
|
1019 |
"Modified: 12.11.1996 / 11:31:51 / cg" |
620 | 1020 |
! |
1021 |
||
1022 |
superclass |
|
1023 |
"return the receivers superclass" |
|
1024 |
||
1025 |
^ superclass |
|
1026 |
! |
|
1027 |
||
1028 |
superclass:aClass |
|
1029 |
"set the superclass - this actually creates a new class, |
|
1030 |
recompiling all methods for the new one. The receiving class stays |
|
1031 |
around anonymous to allow existing instances some life. |
|
1032 |
This may change in the future (adjusting existing instances)" |
|
1033 |
||
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1034 |
|owner ns name| |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1035 |
|
620 | 1036 |
SubclassInfo := nil. |
1037 |
||
1038 |
"must flush caches since lookup chain changes" |
|
1039 |
ObjectMemory flushCaches. |
|
1040 |
||
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1041 |
"/ for correct recompilation, just create a new class ... |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1042 |
"/ but care to avoid a nameSpace change, by giving my |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1043 |
"/ full name and answering with Smalltalk to a nameSpace query. |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1044 |
|
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1045 |
(owner := self owningClass) notNil ifTrue:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1046 |
ns := owner. |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1047 |
name := self nameWithoutPrefix asSymbol |
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1048 |
] ifFalse:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1049 |
ns := Smalltalk. |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1050 |
name := self name |
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1051 |
]. |
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1052 |
|
3628
5b58b3b8644a
auto-keep package - when changing superclass
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
1053 |
Class classRedefinitionSignal answer:#keep do:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1054 |
Class nameSpaceQuerySignal answer:ns |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1055 |
do:[ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1056 |
aClass |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1057 |
perform:(self definitionSelector) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1058 |
withArguments:(Array with:name |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1059 |
with:(self instanceVariableString) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1060 |
with:(self classVariableString) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1061 |
with:'' "/ pool |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1062 |
with:(self category)). |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1063 |
] |
2054
1601ad49cf59
care for nameSpace and owning class when changing the superClass.
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
1064 |
] |
2436 | 1065 |
|
3628
5b58b3b8644a
auto-keep package - when changing superclass
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
1066 |
"Modified: / 20.6.1998 / 18:17:37 / cg" |
620 | 1067 |
! ! |
1068 |
||
1069 |
!Behavior methodsFor:'autoload check'! |
|
1070 |
||
1071 |
autoload |
|
1072 |
"force autoloading - do nothing here; |
|
1073 |
redefined in Autoload; see comment there" |
|
1074 |
||
1075 |
^ self |
|
1076 |
! |
|
1077 |
||
1078 |
isLoaded |
|
1079 |
"return true, if the class has been loaded; |
|
1080 |
redefined in Autoload; see comment there" |
|
1081 |
||
1082 |
^ true |
|
1083 |
! ! |
|
1084 |
||
1085 |
!Behavior methodsFor:'binary storage'! |
|
1086 |
||
1087 |
binaryDefinitionFrom:stream manager:manager |
|
1088 |
"sent during a binary read by the input manager. |
|
1089 |
Read the definition on an empty instance (of my class) from stream. |
|
1090 |
All pointer instances are left nil, while all bits are read in here. |
|
1091 |
return the new object." |
|
1092 |
||
1093 |
|obj t |
|
1094 |
basicSize "{ Class: SmallInteger }" | |
|
1095 |
||
1096 |
self isPointers ifTrue: [ |
|
1097 |
"/ |
|
1098 |
"/ inst size not needed - if you uncomment the line below, |
|
1099 |
"/ also uncomment the corresponding line in |
|
1100 |
"/ Object>>storeBinaryDefinitionOn:manager: |
|
1101 |
"/ |
|
1102 |
"/ stream next. "skip instSize" |
|
1103 |
self isVariable ifTrue: [ |
|
1104 |
^ self basicNew:(stream nextNumber:3) |
|
1105 |
]. |
|
1106 |
^ self basicNew |
|
1107 |
]. |
|
308 | 1108 |
|
1109 |
" |
|
620 | 1110 |
an object with bit-valued instance variables. |
1111 |
These are read here. |
|
1112 |
" |
|
1113 |
basicSize := stream nextNumber:4. |
|
1114 |
obj := self basicNew:basicSize. |
|
1115 |
||
1116 |
self isBytes ifTrue: [ |
|
1117 |
stream nextBytes:basicSize into:obj |
|
1118 |
] ifFalse: [ |
|
1119 |
self isWords ifTrue: [ |
|
1120 |
1 to:basicSize do:[:i | |
|
1121 |
obj basicAt:i put:(stream nextNumber:2) |
|
1122 |
] |
|
1123 |
] ifFalse:[ |
|
1124 |
self isLongs ifTrue: [ |
|
1125 |
1 to:basicSize do:[:i | |
|
1126 |
obj basicAt:i put:(stream nextNumber:4) |
|
1127 |
] |
|
1128 |
] ifFalse:[ |
|
1129 |
self isFloats ifTrue: [ |
|
1130 |
"could do it in one big read on machines which use IEEE floats ..." |
|
1131 |
t := Float basicNew. |
|
1132 |
1 to:basicSize do:[:i | |
|
1133 |
Float readBinaryIEEESingleFrom:stream into:t. |
|
1134 |
obj basicAt:i put: t |
|
1135 |
] |
|
1136 |
] ifFalse:[ |
|
1137 |
self isDoubles ifTrue: [ |
|
1138 |
"could do it in one big read on machines which use IEEE doubles ..." |
|
1139 |
t := Float basicNew. |
|
1140 |
1 to:basicSize do:[:i | |
|
1141 |
Float readBinaryIEEEDoubleFrom:stream into:t. |
|
1142 |
obj basicAt:i put: t |
|
1143 |
] |
|
1144 |
] |
|
1145 |
] |
|
1146 |
] |
|
1147 |
] |
|
1148 |
]. |
|
1149 |
^obj |
|
1150 |
! |
|
1151 |
||
1152 |
canCloneFrom:anObject |
|
1153 |
"return true, if this class can clone an obsolete object as retrieved |
|
1154 |
by a binary load. Subclasses which do not want to have obsolete objects |
|
1155 |
be converted, should redefine this method to return false. |
|
1156 |
(However, conversion is never done silently in a binary load; you |
|
1157 |
have to have a handler for the binaryload errors and for the conversion |
|
1158 |
request signal.)" |
|
1159 |
||
1160 |
^ true |
|
1161 |
! |
|
1162 |
||
1163 |
cloneFrom:aPrototype |
|
1164 |
"return an instance of myself with variables initialized from |
|
1165 |
a prototype. This is used when instances of obsolete classes are |
|
1166 |
binary loaded and a conversion is done on the obsolete object. |
|
1167 |
UserClasses may redefine this for better conversions." |
|
1168 |
||
1169 |
|newInst indexed myInfo otherInfo varIndexAssoc| |
|
1170 |
||
1171 |
indexed := false. |
|
1172 |
aPrototype class isVariable ifTrue:[ |
|
1173 |
self isVariable ifTrue:[ |
|
1174 |
indexed := true. |
|
1175 |
]. |
|
1176 |
"otherwise, these are lost ..." |
|
1177 |
]. |
|
1178 |
indexed ifTrue:[ |
|
1179 |
newInst := self basicNew:aPrototype basicSize |
|
1180 |
] ifFalse:[ |
|
1181 |
newInst := self basicNew |
|
1182 |
]. |
|
1183 |
||
1184 |
myInfo := self instanceVariableOffsets. |
|
1185 |
otherInfo := aPrototype class instanceVariableOffsets. |
|
1186 |
myInfo keysAndValuesDo:[:name :index | |
|
1187 |
varIndexAssoc := otherInfo at:name ifAbsent:[]. |
|
1188 |
varIndexAssoc notNil ifTrue:[ |
|
1189 |
newInst instVarAt:index put:(aPrototype instVarAt:(varIndexAssoc value)) |
|
1190 |
] |
|
1191 |
]. |
|
1192 |
indexed ifTrue:[ |
|
1193 |
1 to:aPrototype basicSize do:[:index | |
|
1194 |
newInst basicAt:index put:(aPrototype basicAt:index) |
|
1195 |
]. |
|
1196 |
]. |
|
1197 |
^ newInst |
|
1198 |
||
1199 |
" |
|
1200 |
Class withoutUpdatingChangesDo:[ |
|
1201 |
Point subclass:#Point3D |
|
1202 |
instanceVariableNames:'z' |
|
1203 |
classVariableNames:'' |
|
1204 |
poolDictionaries:'' |
|
1205 |
category:'testing'. |
|
1206 |
(Point3D cloneFrom:1@2) inspect. |
|
1207 |
] |
|
1208 |
" |
|
1209 |
||
1210 |
" |
|
1211 |
Class withoutUpdatingChangesDo:[ |
|
1212 |
Point variableSubclass:#Point3D |
|
1213 |
instanceVariableNames:'z' |
|
1214 |
classVariableNames:'' |
|
1215 |
poolDictionaries:'' |
|
1216 |
category:'testing'. |
|
1217 |
(Point3D cloneFrom:#(1 2 3)) inspect. |
|
1218 |
] |
|
1219 |
" |
|
1220 |
||
1221 |
" |
|
1222 |
|someObject| |
|
1223 |
||
1224 |
Class withoutUpdatingChangesDo:[ |
|
1225 |
Object subclass:#TestClass1 |
|
1226 |
instanceVariableNames:'foo bar' |
|
1227 |
classVariableNames:'' |
|
1228 |
poolDictionaries:'' |
|
1229 |
category:'testing'. |
|
1230 |
someObject := TestClass1 new. |
|
1231 |
someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'. |
|
1232 |
Object subclass:#TestClass2 |
|
1233 |
instanceVariableNames:'bar foo' |
|
1234 |
classVariableNames:'' |
|
1235 |
poolDictionaries:'' |
|
1236 |
category:'testing'. |
|
1237 |
(TestClass2 cloneFrom:someObject) inspect. |
|
1238 |
] |
|
1239 |
" |
|
1240 |
! |
|
1241 |
||
1242 |
readBinaryFrom:aStream |
|
1243 |
"read an objects binary representation from the argument, |
|
1244 |
aStream and return it. |
|
1245 |
The read object must be a kind of myself, otherwise an error is raised. |
|
1246 |
To get any object, use 'Object readBinaryFrom:...', |
|
1247 |
To get any number, use 'Number readBinaryFrom:...' and so on. |
|
1248 |
This is the reverse operation to 'storeBinaryOn:'. " |
|
1249 |
||
1250 |
^ self readBinaryFrom:aStream onError:[self error:('expected ' , self name)] |
|
1251 |
||
1252 |
" |
|
1253 |
|s| |
|
1254 |
s := WriteStream on:(ByteArray new). |
|
1255 |
#(1 2 3 4) storeBinaryOn:s. |
|
1256 |
Object readBinaryFrom:(ReadStream on:s contents) |
|
1257 |
" |
|
1258 |
" |
|
1259 |
|s| |
|
1260 |
s := 'testFile' asFilename writeStream binary. |
|
1261 |
#(1 2 3 4) storeBinaryOn:s. |
|
1262 |
'hello world' storeBinaryOn:s. |
|
1263 |
s close. |
|
1264 |
||
1265 |
s := 'testFile' asFilename readStream binary. |
|
1422 | 1266 |
Transcript showCR:(Object readBinaryFrom:s). |
1267 |
Transcript showCR:(Object readBinaryFrom:s). |
|
620 | 1268 |
s close. |
1269 |
" |
|
1270 |
! |
|
1271 |
||
1272 |
readBinaryFrom:aStream onError:exceptionBlock |
|
1273 |
"read an objects binary representation from the argument, |
|
1274 |
aStream and return it. |
|
1275 |
The read object must be a kind of myself, otherwise the value of |
|
1276 |
the exceptionBlock is returned. |
|
1277 |
To get any object, use 'Object readBinaryFrom:...', |
|
1278 |
To get any number, use 'Number readBinaryFrom:...' and so on. |
|
1279 |
This is the reverse operation to 'storeBinaryOn:'. " |
|
1280 |
||
1281 |
|newObject| |
|
1282 |
||
3069 | 1283 |
newObject := (BinaryInputManager new) readFrom:aStream. |
1834
b46ca5e3f1ec
allow readBinaryFrom ... to return a nonObject, if sent to
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1284 |
(self ~~ Object |
b46ca5e3f1ec
allow readBinaryFrom ... to return a nonObject, if sent to
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1285 |
and:[(newObject isKindOf:self) not]) ifTrue:[^ exceptionBlock value]. |
620 | 1286 |
^ newObject |
1287 |
||
1288 |
" |
|
1289 |
|s| |
|
1290 |
s := WriteStream on:(ByteArray new). |
|
1291 |
#(1 2 3 4) storeBinaryOn:s. |
|
1292 |
Object readBinaryFrom:(ReadStream on:s contents) onError:['oops'] |
|
1293 |
" |
|
1294 |
" |
|
1295 |
|s| |
|
1296 |
s := WriteStream on:(ByteArray new). |
|
1297 |
#[1 2 3 4] storeBinaryOn:s. |
|
1298 |
Array readBinaryFrom:(ReadStream on:s contents) onError:['oops'] |
|
1299 |
" |
|
1834
b46ca5e3f1ec
allow readBinaryFrom ... to return a nonObject, if sent to
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1300 |
|
3069 | 1301 |
"Modified: / 1.11.1997 / 16:53:36 / cg" |
620 | 1302 |
! |
1303 |
||
1304 |
storeBinaryDefinitionOn: stream manager: manager |
|
1305 |
"binary store of a classes definition. |
|
1306 |
Classes will store the name only and restore by looking for |
|
1259 | 1307 |
that name in the Smalltalk dictionary. |
2463
b0937b570306
save strings in one write (binary storage)
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1308 |
This is an internal interface for the binary storage mechanism." |
620 | 1309 |
|
1310 |
| myName | |
|
1311 |
||
1312 |
myName := self name. |
|
1313 |
stream nextNumber:4 put:self signature. |
|
2463
b0937b570306
save strings in one write (binary storage)
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1314 |
stream nextNumber:2 put:0. "/ no instVarNames string here |
620 | 1315 |
stream nextNumber:2 put:myName size. |
2463
b0937b570306
save strings in one write (binary storage)
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1316 |
stream nextPutBytes:(myName size) from:myName startingAt:1. |
b0937b570306
save strings in one write (binary storage)
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1317 |
"/ myName do:[:c| |
b0937b570306
save strings in one write (binary storage)
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1318 |
"/ stream nextPut:c asciiValue |
b0937b570306
save strings in one write (binary storage)
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1319 |
"/ ] |
620 | 1320 |
|
1321 |
" |
|
1322 |
|s| |
|
1323 |
s := WriteStream on:ByteArray new. |
|
1324 |
#(1 2 3 4) storeBinaryOn:s. |
|
1325 |
Object readBinaryFrom:(ReadStream on:s contents) |
|
1326 |
||
1327 |
|s| |
|
1328 |
s := WriteStream on:ByteArray new. |
|
1329 |
Rectangle storeBinaryOn:s. |
|
1330 |
Object readBinaryFrom:(ReadStream on:s contents) |
|
1331 |
" |
|
1259 | 1332 |
|
2463
b0937b570306
save strings in one write (binary storage)
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1333 |
"Modified: 19.3.1997 / 19:49:59 / cg" |
620 | 1334 |
! ! |
1335 |
||
1336 |
!Behavior methodsFor:'compiler interface'! |
|
1337 |
||
1328 | 1338 |
browserClass |
1339 |
"return the browser to use for this class - |
|
1340 |
this can be redefined in special classes, to get different browsers" |
|
1341 |
||
1342 |
^ SystemBrowser |
|
1343 |
||
1344 |
"Created: 3.5.1996 / 12:36:40 / cg" |
|
1345 |
! |
|
1346 |
||
620 | 1347 |
compiler |
1348 |
"return the compiler to use for this class. |
|
1349 |
OBSOLETE: This is the old ST/X interface, kept for migration. |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1350 |
Dont use it - it will vanish." |
2823 | 1351 |
|
1352 |
self obsoleteMethodWarning:'use #compilerClass'. |
|
620 | 1353 |
^ self compilerClass |
2823 | 1354 |
|
1355 |
"Modified: 31.7.1997 / 23:04:33 / cg" |
|
620 | 1356 |
! |
1357 |
||
1358 |
compilerClass |
|
1359 |
"return the compiler to use for this class - |
|
1360 |
this can be redefined in special classes, to get classes with |
|
1361 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1362 |
||
1363 |
^ Compiler |
|
1364 |
! |
|
1365 |
||
1366 |
evaluatorClass |
|
1367 |
"return the compiler to use for expression evaluation for this class - |
|
1368 |
this can be redefined in special classes, to get classes with |
|
1369 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1370 |
||
1371 |
^ Compiler |
|
2569 | 1372 |
! |
1373 |
||
3411
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1374 |
formatterClass |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1375 |
"return the parser to use for farmatting (prettyPrinting) this class - |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1376 |
this can be redefined in special classes, to get classes with |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1377 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1378 |
|
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1379 |
^ Parser |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1380 |
|
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1381 |
"Created: / 27.4.1998 / 15:33:34 / cg" |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1382 |
! |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1383 |
|
2569 | 1384 |
parserClass |
1385 |
"return the parser to use for parsing this class - |
|
1386 |
this can be redefined in special classes, to get classes with |
|
1387 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1388 |
||
1389 |
^ Parser |
|
1390 |
||
1391 |
"Created: 18.4.1997 / 21:02:41 / cg" |
|
3411
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1392 |
! |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1393 |
|
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1394 |
syntaxHighlighterClass |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1395 |
"return the parser to use for farmatting (prettyPrinting) this class - |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1396 |
this can be redefined in special classes, to get classes with |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1397 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1398 |
|
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1399 |
^ SyntaxHighlighter |
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1400 |
|
5c71b3ce77ac
added queries for #formatterClass & #syntaxHighliterClass
Claus Gittinger <cg@exept.de>
parents:
3327
diff
changeset
|
1401 |
"Created: / 27.4.1998 / 15:34:08 / cg" |
620 | 1402 |
! ! |
1403 |
||
1404 |
!Behavior methodsFor:'copying'! |
|
1405 |
||
1406 |
deepCopy |
|
1407 |
"return a deep copy of the receiver |
|
1408 |
- return the receiver here - time will show if this is ok" |
|
1409 |
||
1410 |
^ self |
|
1411 |
! |
|
1412 |
||
1413 |
deepCopyUsing:aDictionary |
|
1414 |
"return a deep copy of the receiver |
|
1415 |
- return the receiver here - time will show if this is ok" |
|
1416 |
||
1417 |
^ self |
|
1418 |
! |
|
1419 |
||
1420 |
simpleDeepCopy |
|
1421 |
"return a deep copy of the receiver |
|
1422 |
- return the receiver here - time will show if this is ok" |
|
1423 |
||
1424 |
^ self |
|
1425 |
! ! |
|
1426 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1427 |
!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
|
1428 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1429 |
addChangeRecordForClassRemove:aClassName |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1430 |
"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
|
1431 |
Defined as dummy here, since Behavior does not know about change management. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1432 |
(only Classes do). 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
|
1433 |
(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
|
1434 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1435 |
"Created: 16.4.1996 / 16:30:09 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1436 |
"Modified: 16.4.1996 / 18:10:35 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1437 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1438 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1439 |
!Behavior methodsFor:'dummy fileOut'! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1440 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1441 |
fileOutDefinitionOn:aStream |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1442 |
"dummy fileOut defined here. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1443 |
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
|
1444 |
(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
|
1445 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1446 |
^ self |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1447 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1448 |
"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
|
1449 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1450 |
|
620 | 1451 |
!Behavior methodsFor:'enumerating'! |
1452 |
||
1453 |
allDerivedInstancesDo:aBlock |
|
1454 |
"evaluate aBlock for all of my instances and all instances of subclasses. |
|
1455 |
This method is going to be removed for protocol compatibility with |
|
1456 |
other STs; use allSubInstancesDo:" |
|
1457 |
||
2823 | 1458 |
self obsoleteMethodWarning:'use #allSubInstancesDo:'. |
620 | 1459 |
self allSubInstancesDo:aBlock |
1460 |
||
1461 |
" |
|
1422 | 1462 |
StandardSystemView allDerivedInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1463 |
" |
2823 | 1464 |
|
1465 |
"Modified: 31.7.1997 / 23:05:04 / cg" |
|
620 | 1466 |
! |
1467 |
||
1468 |
allInstancesDo:aBlock |
|
1469 |
"evaluate aBlock for all of my instances" |
|
1470 |
||
1471 |
ObjectMemory allInstancesOf:self do:[:anObject | |
|
1472 |
aBlock value:anObject |
|
1473 |
] |
|
1474 |
||
1475 |
" |
|
1422 | 1476 |
StandardSystemView allInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1477 |
" |
1478 |
! |
|
1479 |
||
1480 |
allSubInstancesDo:aBlock |
|
1481 |
"evaluate aBlock for all of my instances and all instances of subclasses" |
|
1482 |
||
1483 |
ObjectMemory allObjectsDo:[:anObject | |
|
1484 |
(anObject isKindOf:self) ifTrue:[ |
|
1485 |
aBlock value:anObject |
|
1486 |
] |
|
1487 |
] |
|
1488 |
||
1489 |
" |
|
1422 | 1490 |
StandardSystemView allSubInstancesDo:[:v | Transcript showCR:(v name)] |
620 | 1491 |
" |
1492 |
! |
|
1493 |
||
1494 |
allSubclassesDo:aBlock |
|
1495 |
"evaluate aBlock for all of my subclasses. |
|
1496 |
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
|
1497 |
Warning: |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1498 |
This will only enumerate globally known classes - for anonymous |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1499 |
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
|
1500 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1501 |
self isMeta ifTrue:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1502 |
"/ metaclasses are not found via Smalltalk allBehaviorsDo: |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1503 |
"/ here, walk over classes and enumerate corresponding metas. |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1504 |
self soleInstance allSubclassesDo:[:aSubClass | |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1505 |
aBlock value:(aSubClass class) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1506 |
]. |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1507 |
] ifFalse:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1508 |
Smalltalk allBehaviorsDo:[:aClass | |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1509 |
(aClass isSubclassOf:self) ifTrue:[ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1510 |
aBlock value:aClass |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1511 |
] |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1512 |
] |
620 | 1513 |
] |
1514 |
||
1515 |
" |
|
1422 | 1516 |
Collection allSubclassesDo:[:c | Transcript showCR:(c name)] |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1517 |
Collection class allSubclassesDo:[:c | Transcript showCR:(c name)] |
620 | 1518 |
" |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1519 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1520 |
"Modified: / 25.10.1997 / 21:17:13 / cg" |
620 | 1521 |
! |
1522 |
||
1523 |
allSubclassesInOrderDo:aBlock |
|
1524 |
"evaluate aBlock for all of my subclasses. |
|
1525 |
Higher level subclasses will be enumerated before the deeper ones, |
|
1526 |
so the order in which aBlock gets called is ok to fileOut classes in |
|
1527 |
correct order for later fileIn. |
|
1528 |
This will only enumerate globally known classes - for anonymous |
|
1529 |
behaviors, you have to walk over all instances of Behavior" |
|
1530 |
||
1531 |
self subclassesDo:[:aClass | |
|
1532 |
aBlock value:aClass. |
|
1533 |
aClass allSubclassesInOrderDo:aBlock |
|
1534 |
] |
|
1535 |
||
1536 |
" |
|
1422 | 1537 |
Collection allSubclassesInOrderDo:[:c | Transcript showCR:(c name)] |
620 | 1538 |
" |
1539 |
! |
|
1540 |
||
1541 |
allSuperclassesDo:aBlock |
|
1542 |
"evaluate aBlock for all of my superclasses" |
|
1543 |
||
1544 |
|theClass| |
|
1545 |
||
1546 |
theClass := superclass. |
|
1547 |
[theClass notNil] whileTrue:[ |
|
1548 |
aBlock value:theClass. |
|
1549 |
theClass := theClass superclass |
|
1550 |
] |
|
1551 |
||
1552 |
" |
|
1422 | 1553 |
String allSuperclassesDo:[:c | Transcript showCR:(c name)] |
620 | 1554 |
" |
1555 |
! |
|
1556 |
||
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1557 |
selectorsAndMethodsDo:aTwoArgBlock |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1558 |
"evaluate the argument, aBlock for all selectors, |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1559 |
passing the corresponding method as second argument" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1560 |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1561 |
methodDictionary keysAndValuesDo:aTwoArgBlock |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1562 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1563 |
"Created: / 27.10.1997 / 14:09:27 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1564 |
! |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
1565 |
|
620 | 1566 |
subclassesDo:aBlock |
1567 |
"evaluate the argument, aBlock for all immediate subclasses. |
|
1568 |
This will only enumerate globally known classes - for anonymous |
|
1569 |
behaviors, you have to walk over all instances of Behavior." |
|
1570 |
||
1571 |
|coll| |
|
1572 |
||
2224 | 1573 |
"/ use cached information (avoid class hierarchy search) |
1574 |
"/ if possible |
|
1575 |
||
620 | 1576 |
SubclassInfo isNil ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1577 |
Behavior subclassInfo |
620 | 1578 |
]. |
1579 |
SubclassInfo notNil ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1580 |
coll := SubclassInfo at:self ifAbsent:nil. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1581 |
coll notNil ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1582 |
coll do:aBlock. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1583 |
]. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1584 |
^ self |
620 | 1585 |
]. |
1586 |
||
1587 |
Smalltalk allBehaviorsDo:[:aClass | |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1588 |
(aClass superclass == self) ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1589 |
aBlock value:aClass |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
1590 |
] |
620 | 1591 |
] |
1592 |
||
1593 |
" |
|
1422 | 1594 |
Collection subclassesDo:[:c | Transcript showCR:(c name)] |
308 | 1595 |
" |
2224 | 1596 |
|
1597 |
"Modified: 22.1.1997 / 18:44:01 / cg" |
|
308 | 1598 |
! ! |
1599 |
||
1 | 1600 |
!Behavior methodsFor:'initialization'! |
1601 |
||
620 | 1602 |
deinitialize |
1603 |
"deinitialize is sent to a class before it is physically unloaded. |
|
1604 |
This is only done with classes which have been loaded in from a binary |
|
1605 |
file. Classes may release any primitive memory or other stuff which is |
|
1606 |
not visible to smalltalk (for example, release internal memory). |
|
1607 |
The default action here is to do nothing." |
|
1608 |
||
1609 |
^ self |
|
1610 |
! |
|
1611 |
||
1 | 1612 |
initialize |
442 | 1613 |
"initialize is sent to a class either during startup, |
1614 |
(for all statically compiled-in classes) or after a class |
|
1615 |
has been loaded into the system (either bytecodes or machinecode). |
|
1616 |
The default action here is to do nothing." |
|
1 | 1617 |
|
1618 |
^ self |
|
1619 |
! |
|
1620 |
||
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1621 |
initializeWithAllPrivateClasses |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1622 |
"if implemented, send #initialize to myself and any private |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1623 |
class which does so. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1624 |
This is sent to a class after it |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1625 |
has been loaded into the system. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1626 |
Statically compiled classes are initialized by the VM" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1627 |
|
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1628 |
(self class implements:#initialize) ifTrue:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1629 |
self initialize. |
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1630 |
]. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1631 |
self privateClassesSorted do:[:aPrivateClass | |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1632 |
aPrivateClass initializeWithAllPrivateClasses. |
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1633 |
]. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1634 |
|
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1635 |
"Created: / 13.5.1998 / 23:33:16 / cg" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1636 |
"Modified: / 13.5.1998 / 23:34:06 / cg" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1637 |
! |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1638 |
|
328 | 1639 |
postAutoload |
442 | 1640 |
"postAutoload is sent to a class after it has been autoloaded. |
1641 |
This gives it a chance to arrange for automatic unloading to be done |
|
1642 |
after a while ... |
|
1643 |
This is NOT sent to statically compiled in or explicitely filedIn |
|
1644 |
classes. |
|
1645 |
The default action here is to do nothing." |
|
328 | 1646 |
|
1647 |
^ self |
|
1648 |
! |
|
1649 |
||
1 | 1650 |
reinitialize |
442 | 1651 |
"reinitialize is sent to a class when an image has been restarted. |
1652 |
I.e. when the system is restarted. |
|
1653 |
This gives classes a chance to flush any device dependent or otherwise |
|
1654 |
obsolete data which may be a leftover from the previous live. |
|
1655 |
The default action here is to do nothing." |
|
1656 |
||
1657 |
^ self |
|
11 | 1658 |
! ! |
1659 |
||
492
fa23b14f444b
renamed instance creation category
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
1660 |
!Behavior methodsFor:'instance creation'! |
1 | 1661 |
|
1662 |
basicNew |
|
54 | 1663 |
"return an instance of myself without indexed variables. |
1 | 1664 |
If the receiver-class has indexed instvars, the new object will have |
91 | 1665 |
a basicSize of zero - |
1666 |
i.e. 'aClass basicNew' is equivalent to 'aClass basicNew:0'. |
|
54 | 1667 |
|
1 | 1668 |
** Do not redefine this method in any class **" |
1669 |
||
1670 |
%{ /* NOCONTEXT */ |
|
81 | 1671 |
REGISTER OBJ newobj; |
1672 |
REGISTER char *nextPtr; |
|
91 | 1673 |
unsigned int instsize; |
1674 |
REGISTER unsigned int nInstVars; |
|
1 | 1675 |
|
54 | 1676 |
/* |
369 | 1677 |
* the following ugly code is nothing more than a __new() followed |
54 | 1678 |
* by a nilling of the new instance. |
91 | 1679 |
* Unrolled for a bit more speed since this is one of the central object |
1680 |
* allocation methods in the system |
|
54 | 1681 |
*/ |
1133 | 1682 |
nInstVars = __intVal(__INST(instSize)); |
92 | 1683 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
54 | 1684 |
|
983 | 1685 |
newobj = (OBJ) __newNextPtr; |
81 | 1686 |
nextPtr = ((char *)newobj) + instsize; |
1687 |
||
1688 |
/* |
|
1689 |
* dont argue about the goto and the arrangement below - it saves |
|
1690 |
* an extra nil-compare and branch in the common case ... |
|
91 | 1691 |
* (i.e. if no GC is needed, we fall through without a branch) |
81 | 1692 |
*/ |
983 | 1693 |
if (nextPtr < __newEndPtr) { |
154 | 1694 |
_objPtr(newobj)->o_size = instsize; |
1695 |
/* o_allFlags(newobj) = 0; */ |
|
983 | 1696 |
/* _objPtr(newobj)->o_space = __newSpace; */ |
1697 |
o_setAllFlags(newobj, __newSpace); |
|
2894 | 1698 |
#ifdef __HAS_ALIGN4__ |
1699 |
/* |
|
1700 |
* if the alignment is 4, we are already sat, |
|
1701 |
* since a non-indexed object always has a word-aligned size. |
|
1702 |
*/ |
|
983 | 1703 |
__newNextPtr = nextPtr; |
91 | 1704 |
#else |
2894 | 1705 |
if (instsize & (__ALIGN__-1)) { |
1706 |
__newNextPtr = (char *)newobj + (instsize & ~(__ALIGN__-1)) + __ALIGN__; |
|
154 | 1707 |
} else { |
983 | 1708 |
__newNextPtr = nextPtr; |
154 | 1709 |
} |
91 | 1710 |
#endif |
82 | 1711 |
|
1712 |
ok: |
|
1133 | 1713 |
__InstPtr(newobj)->o_class = self; |
369 | 1714 |
__qSTORE(newobj, self); |
82 | 1715 |
|
154 | 1716 |
if (nInstVars) { |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1717 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 1718 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
82 | 1719 |
#else |
154 | 1720 |
REGISTER OBJ *op; |
82 | 1721 |
|
1133 | 1722 |
op = __InstPtr(newobj)->i_instvars; |
82 | 1723 |
|
154 | 1724 |
/* |
1725 |
* knowing that nil is 0 |
|
1726 |
*/ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1727 |
# if defined(FAST_OBJECT_MEMSET_DOUBLES_UNROLLED) |
154 | 1728 |
if (nInstVars > 8) { |
1729 |
*op++ = nil; /* for alignment */ |
|
1730 |
nInstVars--; |
|
1731 |
while (nInstVars >= 8) { |
|
1732 |
*(double *)op = 0.0; |
|
1733 |
((double *)op)[1] = 0.0; |
|
1734 |
((double *)op)[2] = 0.0; |
|
1735 |
((double *)op)[3] = 0.0; |
|
1736 |
op += 8; |
|
1737 |
nInstVars -= 8; |
|
1738 |
} |
|
1739 |
} |
|
1740 |
while (nInstVars != 0) { |
|
1741 |
*op++ = 0; |
|
1742 |
nInstVars--; |
|
1743 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1744 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1745 |
# if defined(FAST_OBJECT_MEMSET_LONGLONG_UNROLLED) |
154 | 1746 |
if (nInstVars > 8) { |
1747 |
*op++ = nil; /* for alignment */ |
|
1748 |
nInstVars--; |
|
1749 |
while (nInstVars >= 8) { |
|
1750 |
*(long long *)op = 0; |
|
1751 |
((long long *)op)[1] = 0; |
|
1752 |
((long long *)op)[2] = 0; |
|
1753 |
((long long *)op)[3] = 0; |
|
1754 |
op += 8; |
|
1755 |
nInstVars -= 8; |
|
1756 |
} |
|
1757 |
} |
|
1758 |
while (nInstVars != 0) { |
|
1759 |
*op++ = 0; |
|
1760 |
nInstVars--; |
|
1761 |
} |
|
91 | 1762 |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1763 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1764 |
# if defined(FAST_OBJECT_MEMSET_WORDS_UNROLLED) |
154 | 1765 |
while (nInstVars >= 8) { |
1766 |
*op = nil; |
|
1767 |
*(op+1) = nil; |
|
1768 |
*(op+2) = nil; |
|
1769 |
*(op+3) = nil; |
|
1770 |
*(op+4) = nil; |
|
1771 |
*(op+5) = nil; |
|
1772 |
*(op+6) = nil; |
|
1773 |
*(op+7) = nil; |
|
1774 |
op += 8; |
|
1775 |
nInstVars -= 8; |
|
1776 |
} |
|
1777 |
while (nInstVars != 0) { |
|
1778 |
*op++ = nil; |
|
1779 |
nInstVars--; |
|
1780 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1781 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1782 |
# if defined(FAST_MEMSET) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1783 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
91 | 1784 |
# else |
154 | 1785 |
do { |
1786 |
*op++ = nil; |
|
1787 |
nInstVars--; |
|
1788 |
} while (nInstVars != 0); |
|
82 | 1789 |
# endif |
1790 |
# endif |
|
1791 |
# endif |
|
1792 |
# endif |
|
1793 |
#endif |
|
154 | 1794 |
} |
1795 |
RETURN ( newobj ); |
|
81 | 1796 |
} |
54 | 1797 |
|
92 | 1798 |
/* |
1799 |
* the slow case - a GC will occur |
|
1800 |
*/ |
|
834 | 1801 |
__PROTECT_CONTEXT__ |
3980
8f9443e37693
renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents:
3935
diff
changeset
|
1802 |
newobj = __STX___new(instsize); |
834 | 1803 |
__UNPROTECT_CONTEXT__ |
82 | 1804 |
if (newobj != nil) goto ok; |
1 | 1805 |
%} |
2 | 1806 |
. |
68 | 1807 |
" |
1808 |
memory allocation failed. |
|
1809 |
When we arrive here, there was no memory, even after |
|
165 | 1810 |
a garbage collect. |
1811 |
This means, that the VM wanted to get some more memory from the |
|
1812 |
Operatingsystem, which was not kind enough to give it. |
|
1813 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 1814 |
" |
127 | 1815 |
^ ObjectMemory allocationFailureSignal raise. |
1 | 1816 |
! |
1817 |
||
1818 |
basicNew:anInteger |
|
1819 |
"return an instance of myself with anInteger indexed variables. |
|
1820 |
If the receiver-class has no indexed instvars, this is only allowed |
|
1821 |
if the argument, anInteger is zero. |
|
1822 |
** Do not redefine this method in any class **" |
|
1823 |
||
1824 |
%{ /* NOCONTEXT */ |
|
1825 |
||
1826 |
OBJ newobj; |
|
154 | 1827 |
unsigned INT instsize, nInstVars; |
1828 |
INT nindexedinstvars; |
|
92 | 1829 |
unsigned INT flags; |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1830 |
#if ! defined(FAST_ARRAY_MEMSET) |
1 | 1831 |
REGISTER char *cp; |
1832 |
short *sp; |
|
1833 |
long *lp; |
|
1834 |
#endif |
|
1835 |
REGISTER OBJ *op; |
|
1836 |
float *fp; |
|
1837 |
double *dp; |
|
1838 |
||
249 | 1839 |
if (__isSmallInteger(anInteger)) { |
1133 | 1840 |
nindexedinstvars = __intVal(anInteger); |
154 | 1841 |
if (nindexedinstvars >= 0) { |
1133 | 1842 |
nInstVars = __intVal(__INST(instSize)); |
1843 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
|
154 | 1844 |
switch (flags) { |
1845 |
case BYTEARRAY: |
|
1846 |
instsize = OHDR_SIZE + nindexedinstvars; |
|
1847 |
if (nInstVars == 0) { |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1848 |
if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */ |
154 | 1849 |
/* |
1850 |
* the most common case |
|
1851 |
*/ |
|
835 | 1852 |
__qCheckedNew(newobj, instsize); |
1133 | 1853 |
__InstPtr(newobj)->o_class = self; |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1854 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
359 | 1855 |
nInstVars = nindexedinstvars >> 2; |
1856 |
if (nindexedinstvars & 3) nInstVars++; |
|
1133 | 1857 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
357 | 1858 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1859 |
# if defined(FAST_ARRAY_MEMSET) |
1133 | 1860 |
memset(__InstPtr(newobj)->i_instvars, 0, nindexedinstvars); |
357 | 1861 |
# else |
1133 | 1862 |
cp = (char *)__InstPtr(newobj)->i_instvars; |
154 | 1863 |
while (nindexedinstvars >= sizeof(long)) { |
1864 |
*(long *)cp = 0; |
|
1865 |
cp += sizeof(long); |
|
1866 |
nindexedinstvars -= sizeof(long); |
|
1867 |
} |
|
1868 |
while (nindexedinstvars--) |
|
1869 |
*cp++ = '\0'; |
|
357 | 1870 |
# endif |
92 | 1871 |
#endif |
154 | 1872 |
RETURN ( newobj ); |
1873 |
} |
|
1874 |
} else { |
|
1875 |
instsize += __OBJS2BYTES__(nInstVars); |
|
1876 |
} |
|
834 | 1877 |
__PROTECT_CONTEXT__ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1878 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 1879 |
__UNPROTECT_CONTEXT__ |
154 | 1880 |
if (newobj == nil) { |
1881 |
break; |
|
1882 |
} |
|
1133 | 1883 |
__InstPtr(newobj)->o_class = self; |
369 | 1884 |
__qSTORE(newobj, self); |
1885 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1886 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
357 | 1887 |
nInstVars = (instsize-OHDR_SIZE) >> 2; |
1888 |
if (instsize & 3) nInstVars++; |
|
1133 | 1889 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
357 | 1890 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1891 |
# if defined(FAST_ARRAY_MEMSET) |
154 | 1892 |
/* |
1893 |
* knowing that nil is 0 |
|
1894 |
*/ |
|
1133 | 1895 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
357 | 1896 |
# else |
1133 | 1897 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1898 |
while (nInstVars--) |
1899 |
*op++ = nil; |
|
1900 |
cp = (char *)op; |
|
1901 |
while (nindexedinstvars >= sizeof(long)) { |
|
1902 |
*(long *)cp = 0; |
|
1903 |
cp += sizeof(long); |
|
1904 |
nindexedinstvars -= sizeof(long); |
|
1905 |
} |
|
1906 |
while (nindexedinstvars--) |
|
1907 |
*cp++ = '\0'; |
|
357 | 1908 |
# endif |
1 | 1909 |
#endif |
154 | 1910 |
RETURN ( newobj ); |
1911 |
break; |
|
1 | 1912 |
|
154 | 1913 |
case WORDARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
1914 |
case SWORDARRAY: |
154 | 1915 |
instsize = OHDR_SIZE + |
1916 |
__OBJS2BYTES__(nInstVars) + |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1917 |
nindexedinstvars * 2; |
834 | 1918 |
__PROTECT_CONTEXT__ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1919 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 1920 |
__UNPROTECT_CONTEXT__ |
154 | 1921 |
if (newobj == nil) { |
1922 |
break; |
|
1923 |
} |
|
1133 | 1924 |
__InstPtr(newobj)->o_class = self; |
369 | 1925 |
__qSTORE(newobj, self); |
1926 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1927 |
#if defined(FAST_ARRAY_MEMSET) |
154 | 1928 |
/* |
1929 |
* knowing that nil is 0 |
|
1930 |
*/ |
|
1133 | 1931 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 1932 |
#else |
1133 | 1933 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1934 |
while (nInstVars--) |
1935 |
*op++ = nil; |
|
1936 |
sp = (short *)op; |
|
1937 |
while (nindexedinstvars--) |
|
1938 |
*sp++ = 0; |
|
1 | 1939 |
#endif |
154 | 1940 |
RETURN ( newobj ); |
1941 |
break; |
|
1 | 1942 |
|
154 | 1943 |
case LONGARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
1944 |
case SLONGARRAY: |
154 | 1945 |
instsize = OHDR_SIZE + |
1946 |
__OBJS2BYTES__(nInstVars) + |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1947 |
nindexedinstvars * 4; |
834 | 1948 |
__PROTECT_CONTEXT__ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1949 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 1950 |
__UNPROTECT_CONTEXT__ |
154 | 1951 |
if (newobj == nil) { |
1952 |
break; |
|
1953 |
} |
|
1133 | 1954 |
__InstPtr(newobj)->o_class = self; |
369 | 1955 |
__qSTORE(newobj, self); |
1956 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1957 |
#if defined(memset4) |
154 | 1958 |
/* |
1959 |
* knowing that nil is 0 |
|
1960 |
*/ |
|
2865 | 1961 |
{ |
1962 |
int n4 = nInstVars + nindexedinstvars; |
|
1963 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1964 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
2865 | 1965 |
} |
1 | 1966 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1967 |
# if defined(FAST_ARRAY_MEMSET) |
154 | 1968 |
/* |
1969 |
* knowing that nil is 0 |
|
1970 |
*/ |
|
1133 | 1971 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 1972 |
# else |
1133 | 1973 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1974 |
while (nInstVars--) |
1975 |
*op++ = nil; |
|
1976 |
lp = (long *)op; |
|
1977 |
while (nindexedinstvars--) |
|
1978 |
*lp++ = 0; |
|
1 | 1979 |
# endif |
1980 |
#endif |
|
154 | 1981 |
RETURN ( newobj ); |
1982 |
break; |
|
1 | 1983 |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1984 |
case LONGLONGARRAY: |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1985 |
case SLONGLONGARRAY: |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1986 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1987 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1988 |
#ifdef __NEED_LONGLONG_ALIGN |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1989 |
instsize = ((instsize-1) + __LONGLONG_ALIGN) & ~(__LONGLONG_ALIGN-1); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1990 |
#endif |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1991 |
instsize += nindexedinstvars * 8; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1992 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1993 |
__PROTECT_CONTEXT__ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1994 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1995 |
__UNPROTECT_CONTEXT__ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1996 |
if (newobj == nil) { |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1997 |
break; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1998 |
} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
1999 |
__InstPtr(newobj)->o_class = self; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2000 |
__qSTORE(newobj, self); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2001 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2002 |
#if defined(memset4) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2003 |
{ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2004 |
int n4 = (instsize-OHDR_SIZE) / 4; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2005 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2006 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2007 |
} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2008 |
#else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2009 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2010 |
#endif |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2011 |
RETURN ( newobj ); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2012 |
break; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2013 |
|
154 | 2014 |
case FLOATARRAY: |
325 | 2015 |
instsize = sizeof(struct __floatArray) + |
154 | 2016 |
__OBJS2BYTES__(nInstVars) + |
2017 |
(nindexedinstvars - 1) * sizeof(float); |
|
54 | 2018 |
|
834 | 2019 |
__PROTECT_CONTEXT__ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2020 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 2021 |
__UNPROTECT_CONTEXT__ |
154 | 2022 |
if (newobj == nil) { |
2023 |
break; |
|
2024 |
} |
|
1133 | 2025 |
__InstPtr(newobj)->o_class = self; |
369 | 2026 |
__qSTORE(newobj, self); |
2027 |
||
1133 | 2028 |
op = __InstPtr(newobj)->i_instvars; |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2029 |
#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
|
2030 |
# if defined(memset4) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2031 |
{ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2032 |
int n4 = (instsize-OHDR_SIZE) / 4; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2033 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2034 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2035 |
} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2036 |
# else |
1133 | 2037 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2038 |
# endif |
3870
ea7a0f0db4be
use memset to initialize float- and doubleArrays, if float0/double0 is int0
Claus Gittinger <cg@exept.de>
parents:
3805
diff
changeset
|
2039 |
#else |
154 | 2040 |
while (nInstVars--) |
2041 |
*op++ = nil; |
|
2042 |
fp = (float *)op; |
|
2043 |
while (nindexedinstvars--) |
|
2044 |
*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
|
2045 |
#endif |
154 | 2046 |
RETURN ( newobj ); |
2047 |
break; |
|
1 | 2048 |
|
154 | 2049 |
case DOUBLEARRAY: |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2050 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2051 |
#ifdef __NEED_DOUBLE_ALIGN |
3935 | 2052 |
instsize = ((instsize-1) + __DOUBLE_ALIGN) & ~(__DOUBLE_ALIGN-1); |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2053 |
#endif |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2054 |
instsize += nindexedinstvars * sizeof(double); |
54 | 2055 |
|
834 | 2056 |
__PROTECT_CONTEXT__ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2057 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 2058 |
__UNPROTECT_CONTEXT__ |
154 | 2059 |
if (newobj == nil) { |
2060 |
break; |
|
2061 |
} |
|
1133 | 2062 |
__InstPtr(newobj)->o_class = self; |
369 | 2063 |
__qSTORE(newobj, self); |
2064 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2065 |
#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
|
2066 |
# ifdef memset4 |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2067 |
{ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2068 |
int n4 = (instsize-OHDR_SIZE) / 4; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2069 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2070 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2071 |
} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2072 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2073 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2074 |
# endif |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2075 |
#else |
1133 | 2076 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2077 |
while (nInstVars--) |
2078 |
*op++ = nil; |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2079 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2080 |
# ifdef __NEED_DOUBLE_ALIGN |
154 | 2081 |
/* |
2082 |
* care for double alignment |
|
2894 | 2083 |
* add filler. |
154 | 2084 |
*/ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2085 |
if ((INT)op & (__DOUBLE_ALIGN-1)) { |
154 | 2086 |
*op++ = nil; |
2087 |
} |
|
3870
ea7a0f0db4be
use memset to initialize float- and doubleArrays, if float0/double0 is int0
Claus Gittinger <cg@exept.de>
parents:
3805
diff
changeset
|
2088 |
# endif |
154 | 2089 |
dp = (double *)op; |
2090 |
while (nindexedinstvars--) |
|
2091 |
*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
|
2092 |
#endif |
154 | 2093 |
RETURN ( newobj ); |
2094 |
break; |
|
1 | 2095 |
|
154 | 2096 |
case WKPOINTERARRAY: |
2097 |
case POINTERARRAY: |
|
2098 |
nInstVars += nindexedinstvars; |
|
2099 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
834 | 2100 |
__PROTECT_CONTEXT__ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2101 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 2102 |
__UNPROTECT_CONTEXT__ |
154 | 2103 |
if (newobj == nil) { |
2104 |
break; |
|
2105 |
} |
|
1133 | 2106 |
__InstPtr(newobj)->o_class = self; |
369 | 2107 |
__qSTORE(newobj, self); |
2108 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2109 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 2110 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 2111 |
#else |
154 | 2112 |
/* |
2113 |
* knowing that nil is 0 |
|
2114 |
*/ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2115 |
# ifdef sparc |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2116 |
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2117 |
# endif |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2118 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2119 |
# if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED) |
1133 | 2120 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2121 |
if (nInstVars > 8) { |
2122 |
*op++ = nil; /* for alignment */ |
|
2123 |
nInstVars--; |
|
2124 |
while (nInstVars >= 8) { |
|
2125 |
*(double *)op = 0.0; |
|
2126 |
((double *)op)[1] = 0.0; |
|
2127 |
((double *)op)[2] = 0.0; |
|
2128 |
((double *)op)[3] = 0.0; |
|
2129 |
op += 8; |
|
2130 |
nInstVars -= 8; |
|
2131 |
} |
|
2132 |
} |
|
2133 |
while (nInstVars) { |
|
2134 |
*op++ = 0; |
|
2135 |
nInstVars--; |
|
2136 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2137 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2138 |
# if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED) |
1133 | 2139 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2140 |
if (nInstVars > 8) { |
2141 |
*op++ = nil; /* for alignment */ |
|
2142 |
nInstVars--; |
|
2143 |
while (nInstVars >= 8) { |
|
2144 |
*(long long *)op = 0; |
|
2145 |
((long long *)op)[1] = 0; |
|
2146 |
((long long *)op)[2] = 0; |
|
2147 |
((long long *)op)[3] = 0; |
|
2148 |
op += 8; |
|
2149 |
nInstVars -= 8; |
|
2150 |
} |
|
2151 |
} |
|
2152 |
while (nInstVars) { |
|
2153 |
*op++ = 0; |
|
2154 |
nInstVars--; |
|
2155 |
} |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2156 |
# else |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2157 |
# if defined(FAST_ARRAY_MEMSET) |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2158 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
91 | 2159 |
# else |
1133 | 2160 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2161 |
while (nInstVars--) |
2162 |
*op++ = nil; |
|
82 | 2163 |
# endif |
2164 |
# endif |
|
1 | 2165 |
# endif |
2166 |
#endif |
|
154 | 2167 |
RETURN ( newobj ); |
2168 |
break; |
|
1 | 2169 |
|
154 | 2170 |
default: |
2171 |
/* |
|
2172 |
* new:n for non-variable classes only allowed if |
|
2173 |
* n == 0 |
|
2174 |
*/ |
|
2175 |
if (nindexedinstvars == 0) { |
|
2176 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
834 | 2177 |
__PROTECT_CONTEXT__ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2178 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 2179 |
__UNPROTECT_CONTEXT__ |
154 | 2180 |
if (newobj == nil) { |
2181 |
break; |
|
2182 |
} |
|
1133 | 2183 |
__InstPtr(newobj)->o_class = self; |
369 | 2184 |
__qSTORE(newobj, self); |
2185 |
||
154 | 2186 |
if (nInstVars) { |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2187 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 2188 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 2189 |
#else |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2190 |
# if defined(FAST_MEMSET) |
154 | 2191 |
/* |
2192 |
* knowing that nil is 0 |
|
2193 |
*/ |
|
1133 | 2194 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 2195 |
# else |
1133 | 2196 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2197 |
do { |
2198 |
*op++ = nil; |
|
2199 |
} while (--nInstVars); |
|
1 | 2200 |
# endif |
2201 |
#endif |
|
154 | 2202 |
} |
2203 |
RETURN ( newobj ); |
|
2204 |
} |
|
2205 |
break; |
|
2206 |
} |
|
2207 |
} |
|
1 | 2208 |
} |
68 | 2209 |
%}. |
2210 |
" |
|
2211 |
arrive here if something went wrong ... |
|
2212 |
figure out what it was |
|
2213 |
" |
|
11 | 2214 |
|
1 | 2215 |
(anInteger isMemberOf:SmallInteger) ifFalse:[ |
154 | 2216 |
" |
2217 |
the argument is either not an integer, |
|
2218 |
or a LargeInteger (which means that its definitely too big) |
|
2219 |
" |
|
2220 |
self error:'argument to new: must be Integer'. |
|
2221 |
^ nil |
|
68 | 2222 |
]. |
2223 |
(anInteger < 0) ifTrue:[ |
|
154 | 2224 |
" |
2225 |
the argument is negative, |
|
2226 |
" |
|
2227 |
self error:'bad (negative) argument to new:'. |
|
2228 |
^ nil |
|
68 | 2229 |
]. |
2230 |
self isVariable ifFalse:[ |
|
154 | 2231 |
" |
2232 |
this class does not have any indexed instance variables |
|
2233 |
" |
|
2234 |
self error:'class has no indexed instvars - cannot create with new:'. |
|
2235 |
^ nil |
|
68 | 2236 |
]. |
2237 |
" |
|
2238 |
memory allocation failed. |
|
2239 |
When we arrive here, there was no memory, even after |
|
165 | 2240 |
a garbage collect. |
2241 |
This means, that the VM wanted to get some more memory from the |
|
2242 |
Operatingsystem, which was not kind enough to give it. |
|
2243 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 2244 |
" |
127 | 2245 |
^ ObjectMemory allocationFailureSignal raise. |
11 | 2246 |
! |
2247 |
||
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2248 |
decodeFromLiteralArray:anArray |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2249 |
"create & return a new instance from information encoded in anArray." |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2250 |
|
3237
5c3d09b9239d
use #new instead of #basicNew when decoding from a literal array;
Claus Gittinger <cg@exept.de>
parents:
3141
diff
changeset
|
2251 |
^ self new fromLiteralArrayEncoding:anArray. |
2370
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2252 |
|
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2253 |
" |
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2254 |
Rectangle |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2255 |
decodeFromLiteralArray:#(Rectangle 10 10 100 100) |
2370
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2256 |
" |
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2257 |
|
3237
5c3d09b9239d
use #new instead of #basicNew when decoding from a literal array;
Claus Gittinger <cg@exept.de>
parents:
3141
diff
changeset
|
2258 |
"Modified: / 28.1.1998 / 17:40:30 / cg" |
2370
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2259 |
! |
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2260 |
|
620 | 2261 |
new |
2262 |
"return an instance of myself without indexed variables" |
|
2263 |
||
2264 |
^ self basicNew |
|
2265 |
! |
|
2266 |
||
2267 |
new:anInteger |
|
2268 |
"return an instance of myself with anInteger indexed variables" |
|
2269 |
||
2270 |
^ self basicNew:anInteger |
|
2271 |
! |
|
2272 |
||
2273 |
niceBasicNew:anInteger |
|
2274 |
"same as basicNew:anInteger, but tries to avoid long pauses |
|
2275 |
due to garbage collection. This method checks to see if |
|
2276 |
allocation is possible without a pause, and does a background |
|
2277 |
incremental garbage collect first if there is not enough memory |
|
2278 |
available at the moment for fast allocation. |
|
2279 |
This is useful in low-priority background processes which like to |
|
2280 |
avoid disturbing any higher priority foreground process while allocating |
|
2281 |
big amounts of memory. Of course, using this method only makes |
|
2282 |
sense for big or huge objects (say > 200k). |
|
2283 |
||
2284 |
EXPERIMENTAL: this is a non-standard interface and should only |
|
2285 |
be used for special applications. There is no guarantee, that this |
|
2286 |
method will be available in future ST/X releases." |
|
2287 |
||
2288 |
|size| |
|
2289 |
||
2290 |
size := self sizeOfInst:anInteger. |
|
2291 |
(ObjectMemory checkForFastNew:size) ifFalse:[ |
|
2292 |
" |
|
2293 |
incrementally collect garbage |
|
2294 |
" |
|
2295 |
ObjectMemory incrementalGC. |
|
2296 |
]. |
|
2297 |
^ self basicNew:anInteger |
|
2298 |
! |
|
2299 |
||
11 | 2300 |
readFrom:aStream |
43 | 2301 |
"read an objects printed representation from the argument, aStream |
2302 |
and return it. |
|
154 | 2303 |
The read object must be a kind of myself if its not, an error is raised. |
11 | 2304 |
This is the reverse operation to 'storeOn:'. |
43 | 2305 |
|
68 | 2306 |
WARNING: storeOn: does not handle circular references and multiple |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2307 |
references to the same object. |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2308 |
Use #storeBinary:/readBinaryFrom: for this." |
3480 | 2309 |
|
2310 |
^ self readFrom:aStream onError:[self error:'conversion error for: ' , self name] |
|
11 | 2311 |
|
91 | 2312 |
" |
2313 |
|s| |
|
11 | 2314 |
s := WriteStream on:String new. |
2315 |
#(1 2 3 4) storeOn:s. |
|
2316 |
Object readFrom:(ReadStream on:s contents) |
|
2317 |
" |
|
2318 |
! |
|
2319 |
||
198 | 2320 |
readFrom:aStream onError:exceptionBlock |
2321 |
"read an objects printed representation from the argument, aStream |
|
2322 |
and return it (i.e. the stream should contain some representation of |
|
2323 |
the object which was created using #storeOn:). |
|
2324 |
The read object must be a kind of myself if its not, the value of |
|
2325 |
exceptionBlock is returned. |
|
2326 |
To get any object, use 'Object readFrom:...', |
|
2327 |
To get any number, use 'Number readFrom:...' and so on. |
|
2328 |
This is the reverse operation to 'storeOn:'. |
|
2329 |
||
2330 |
WARNING: storeOn: does not handle circular references and multiple |
|
2331 |
references to the same object. |
|
2332 |
Use #storeBinary:/readBinaryFrom: for this." |
|
2333 |
||
2334 |
|newObject| |
|
2335 |
||
340 | 2336 |
ErrorSignal handle:[:ex | |
2337 |
ex return |
|
2338 |
] do:[ |
|
345 | 2339 |
newObject := self evaluatorClass evaluate:aStream. |
340 | 2340 |
]. |
198 | 2341 |
(newObject isKindOf:self) ifFalse:[^ exceptionBlock value]. |
2342 |
^ newObject |
|
2343 |
||
2344 |
" |
|
2345 |
|s| |
|
2346 |
s := WriteStream on:String new. |
|
2347 |
#(1 2 3 4) storeOn:s. |
|
1422 | 2348 |
Transcript showCR:( |
293 | 2349 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
2350 |
) |
|
198 | 2351 |
" |
2352 |
" |
|
2353 |
|s| |
|
2354 |
s := WriteStream on:String new. |
|
2355 |
#[1 2 3 4] storeOn:s. |
|
1422 | 2356 |
Transcript showCR:( |
293 | 2357 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
345 | 2358 |
) |
198 | 2359 |
" |
2360 |
! |
|
2361 |
||
11 | 2362 |
readFromString:aString |
275 | 2363 |
"create an object from its printed representation. |
2364 |
For most classes, the string is expected to be in a format created by |
|
2365 |
storeOn: or storeString; however, some (Time, Date) expect a user |
|
2366 |
readable string here. |
|
2367 |
See comments in Behavior>>readFromString:onError:, |
|
2368 |
Behavior>>readFrom: and Behavior>>readFrom:onError:" |
|
11 | 2369 |
|
345 | 2370 |
^ self readFromString:aString onError:[self error:'expected: ' , self name] |
91 | 2371 |
|
2372 |
" |
|
2373 |
Integer readFromString:'12345678901234567890' |
|
2374 |
Point readFromString:'1@2' |
|
345 | 2375 |
Point readFromString:'1' |
91 | 2376 |
" |
198 | 2377 |
! |
2378 |
||
2379 |
readFromString:aString onError:exceptionBlock |
|
275 | 2380 |
"create an object from its printed representation. |
2381 |
Here, the string is expected to be in a format created by |
|
2382 |
storeOn: or storeString; however, some classes (Time, Date) may redefine |
|
2383 |
it to expect a user readable string here. |
|
198 | 2384 |
See comments in Behavior>>readFrom: and Behavior>>readFrom:onError:" |
2385 |
||
2386 |
^ self readFrom:(ReadStream on:aString) onError:exceptionBlock |
|
2387 |
||
2388 |
" |
|
2389 |
Integer readFromString:'12345678901234567890' |
|
275 | 2390 |
Integer readFromString:'abc' |
2391 |
Integer readFromString:'abc' onError:0 |
|
198 | 2392 |
Point readFromString:'1@2' |
345 | 2393 |
Point readFromString:'0' |
275 | 2394 |
Point readFromString:'0' onError:[0@0] |
198 | 2395 |
" |
620 | 2396 |
! |
2397 |
||
2398 |
uninitializedNew |
|
2399 |
"create an instance of myself with uninitialized contents. |
|
2400 |
For all classes except ByteArray, this is the same as #basicNew." |
|
2401 |
||
2402 |
^ self basicNew |
|
2403 |
! |
|
2404 |
||
2405 |
uninitializedNew:anInteger |
|
2406 |
"create an instance of myself with uninitialized contents. |
|
2407 |
For all classes except ByteArray, this is the same as #basicNew:." |
|
2408 |
||
2409 |
^ self basicNew:anInteger |
|
1 | 2410 |
! ! |
2411 |
||
3619 | 2412 |
!Behavior methodsFor:'misc'! |
2413 |
||
2414 |
sourceCodeTemplate |
|
2415 |
^ 'messageSelector and arguments |
|
2416 |
"method comment - purpose of message" |
|
2417 |
||
2418 |
|temporaries| |
|
2419 |
||
2420 |
statements |
|
2421 |
||
2422 |
" |
|
2423 |
example uses |
|
2424 |
" |
|
2425 |
' |
|
2426 |
||
2427 |
"Created: / 19.6.1998 / 02:14:02 / cg" |
|
2428 |
! ! |
|
2429 |
||
620 | 2430 |
!Behavior methodsFor:'private accessing'! |
2431 |
||
2432 |
flags:aNumber |
|
2433 |
"set the flags. |
|
2434 |
this method is for special uses only - there will be no recompilation |
|
2435 |
and no change record written here; |
|
2436 |
Do NOT use it." |
|
2437 |
||
2438 |
flags := aNumber |
|
2439 |
! |
|
2440 |
||
2441 |
instSize:aNumber |
|
2442 |
"set the instance size. |
|
2443 |
this method is for special uses only - there will be no recompilation |
|
2444 |
and no change record written here; |
|
2445 |
Do NOT use it." |
|
2446 |
||
2447 |
instSize := aNumber |
|
2448 |
! |
|
2449 |
||
2450 |
primAddSelector:newSelector withMethod:newMethod |
|
2451 |
"add the method given by 2nd argument under the selector given by |
|
2452 |
the 1st argument to the methodDictionary. |
|
2453 |
Does NOT flush any caches, does NOT write a change record. |
|
2454 |
||
2455 |
Do not use this in normal situations, strange behavior will be |
|
2456 |
the consequence. |
|
2457 |
I.e. executing obsolete methods, since the old method will still |
|
2458 |
be executed out of the caches." |
|
2459 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2460 |
|dict| |
620 | 2461 |
|
2462 |
(newSelector isMemberOf:Symbol) ifFalse:[ |
|
2463 |
self error:'invalid selector'. |
|
2464 |
^ false |
|
2465 |
]. |
|
2466 |
newMethod isNil ifTrue:[ |
|
2467 |
self error:'invalid method'. |
|
2468 |
^ false |
|
2469 |
]. |
|
2470 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2471 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2472 |
self setMethodDictionary:(dict at:newSelector putOrAppend:newMethod). |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2473 |
^ true. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2474 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2475 |
"Modified: 7.6.1996 / 14:48:45 / stefan" |
620 | 2476 |
! |
2477 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2478 |
setMethodDictionary:dict |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2479 |
"set the receivers method dictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2480 |
Convert dict to a MethodDictionary if necessary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2481 |
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
|
2482 |
after this call" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2483 |
|
2228 | 2484 |
"/ since the only thing the VM is prepared to deal with are |
2485 |
"/ proper methodDictionaries (it cannot do another message send, to |
|
2486 |
"/ find any methods ...), we convert it here if required. |
|
2487 |
"/ No other classes instances are allowed. |
|
2488 |
||
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2489 |
dict class ~~ MethodDictionary ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2490 |
methodDictionary := MethodDictionary withAll:dict. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2491 |
methodDictionary isNil ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2492 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2493 |
"/ refuse to do this |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2494 |
"/ (can only happen in case of memory allocation trouble, |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2495 |
"/ where the allocation failed and some exception handler returned |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2496 |
"/ nil ...) |
2228 | 2497 |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2498 |
self halt:'cannot set methodDictionary to nil'. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2499 |
^ self. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2500 |
] |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2501 |
] ifFalse:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2502 |
methodDictionary := dict. |
620 | 2503 |
]. |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2504 |
^ self. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2505 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2506 |
"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
|
2507 |
"Modified: 12.6.1996 / 13:58:55 / stefan" |
2228 | 2508 |
"Modified: 22.1.1997 / 21:10:48 / cg" |
620 | 2509 |
! |
2510 |
||
2511 |
setOtherSuperclasses:anArrayOfClasses |
|
2512 |
"EXPERIMENTAL: set the other superclasses of the receiver. |
|
2513 |
this method is for special uses only - there will be no recompilation |
|
2514 |
and no change record written here; |
|
2515 |
Do NOT use it." |
|
2516 |
||
2517 |
SubclassInfo := nil. |
|
2518 |
otherSuperclasses := anArrayOfClasses |
|
2519 |
! |
|
2520 |
||
2521 |
setSuperclass:aClass |
|
2522 |
"set the superclass of the receiver. |
|
2523 |
this method is for special uses only - there will be no recompilation |
|
2524 |
and no change record written here. Also, if the receiver class has |
|
2525 |
already been in use, future operation of the system is not guaranteed to |
|
2526 |
be correct, since no caches are flushed. |
|
2527 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2528 |
||
2438
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2529 |
|info| |
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2530 |
|
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2531 |
SubclassInfo notNil ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2532 |
"/ flush/update the subclass information |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2533 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2534 |
"/ if my class is already contained |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2535 |
(info := SubclassInfo at:aClass ifAbsent:nil) notNil ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2536 |
info add:self |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2537 |
] ifFalse:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2538 |
SubclassInfo := nil. "/ flush it |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2539 |
] |
2438
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2540 |
]. |
620 | 2541 |
superclass := aClass |
2224 | 2542 |
|
2438
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2543 |
"Modified: 3.3.1997 / 13:27:00 / cg" |
620 | 2544 |
! |
2545 |
||
2224 | 2546 |
setSuperclass:aClass methodDictionary:d instSize:i flags:f |
620 | 2547 |
"set some inst vars. |
2548 |
this method is for special uses only - there will be no recompilation |
|
2549 |
and no change record is written here. Also, if the receiver class has |
|
2550 |
already been in use, future operation of the system is not guaranteed to |
|
2551 |
be correct, since no caches are flushed. |
|
2552 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2553 |
||
2224 | 2554 |
self setSuperclass:aClass. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2555 |
self setMethodDictionary:d. |
620 | 2556 |
instSize := i. |
2557 |
flags := f |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2558 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2559 |
"Created: 7.6.1996 / 08:41:20 / stefan" |
2224 | 2560 |
"Modified: 22.1.1997 / 18:42:12 / cg" |
620 | 2561 |
! ! |
2562 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2563 |
!Behavior methodsFor:'private helpers'! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2564 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2565 |
addAllClassVarNamesTo:aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2566 |
"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
|
2567 |
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
|
2568 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2569 |
|classvars| |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2570 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2571 |
(superclass notNil) ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2572 |
superclass addAllClassVarNamesTo:aCollection |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2573 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2574 |
(classvars := self classVariableString) notNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2575 |
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
|
2576 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2577 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2578 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2579 |
"Created: 16.4.1996 / 18:00:38 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2580 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2581 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2582 |
addAllInstVarNamesTo:aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2583 |
"helper for allInstVarNames - add the name-strings of the instance variables |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2584 |
and of the inst-vars of all superclasses to the argument, aCollection. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2585 |
Return aCollection." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2586 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2587 |
|superInsts instvars| |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2588 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2589 |
(superclass notNil) ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2590 |
superclass addAllInstVarNamesTo:aCollection |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2591 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2592 |
(instvars := self instanceVariableString) notNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2593 |
aCollection addAll:(instvars asCollectionOfWords). |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2594 |
] ifFalse:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2595 |
"/ mhmh - either someone klduged around, or this is |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2596 |
"/ a system running without sourceInfo. Generate |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2597 |
"/ synthetic names. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2598 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2599 |
superclass isNil ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2600 |
superInsts := 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2601 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2602 |
superInsts := superclass instSize |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2603 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2604 |
aCollection addAll:((superInsts+1 to:self instSize) |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2605 |
collect:[:index | '* instVar' , index printString , ' *']) |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2606 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2607 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2608 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2609 |
"Modified: 30.10.1995 / 19:46:21 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2610 |
"Created: 16.4.1996 / 18:03:14 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2611 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2612 |
|
620 | 2613 |
!Behavior methodsFor:'queries'! |
2614 |
||
2615 |
allClassVarNames |
|
2616 |
"return a collection of all the class variable name-strings |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2617 |
this includes all superclass-class variables" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2618 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2619 |
^ self addAllClassVarNamesTo:(OrderedCollection new) |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2620 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2621 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2622 |
Float allClassVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2623 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2624 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2625 |
"Modified: 16.4.1996 / 18:01:00 / cg" |
620 | 2626 |
! |
2627 |
||
2628 |
allDerivedInstances |
|
2629 |
"return a collection of all instances of myself and |
|
2630 |
instances of all subclasses of myself. |
|
2631 |
This method is going to be removed for protocol compatibility with |
|
2632 |
other STs; use allSubInstances" |
|
2633 |
||
2823 | 2634 |
self obsoleteMethodWarning:'use #allSubInstances'. |
620 | 2635 |
^ self allSubInstances |
2823 | 2636 |
|
2637 |
"Modified: 31.7.1997 / 23:04:59 / cg" |
|
620 | 2638 |
! |
2639 |
||
2640 |
allInstVarNames |
|
2641 |
"return a collection of all the instance variable name-strings |
|
2642 |
this includes all superclass-instance variables. |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2643 |
Instvars of superclasses come first (i.e. the position matches |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2644 |
the instVarAt:-index)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2645 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2646 |
^ self addAllInstVarNamesTo:(OrderedCollection new) |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2647 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2648 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2649 |
Dictionary instVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2650 |
Dictionary allInstVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2651 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2652 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2653 |
"Modified: 16.4.1996 / 18:03:55 / cg" |
620 | 2654 |
! |
2655 |
||
2656 |
allInstances |
|
2657 |
"return a collection of all my instances" |
|
2658 |
||
2659 |
"Read the documentation on why there seem to be no |
|
2660 |
instances of SmallInteger and UndefinedObject" |
|
2661 |
||
2662 |
|coll| |
|
2663 |
||
2664 |
coll := OrderedCollection new:100. |
|
2665 |
self allInstancesDo:[:anObject | |
|
2666 |
coll add:anObject |
|
2667 |
]. |
|
2668 |
^ coll |
|
2669 |
||
2670 |
" |
|
2671 |
ScrollBar allInstances |
|
2672 |
" |
|
2673 |
! |
|
2674 |
||
3620
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2675 |
allInstancesWeakly:doWeakly |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2676 |
"return a collection of all my instances. |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2677 |
If weakly is true, a weak collection is returned." |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2678 |
|
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2679 |
"Read the documentation on why there seem to be no |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2680 |
instances of SmallInteger and UndefinedObject" |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2681 |
|
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2682 |
|coll| |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2683 |
|
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2684 |
coll := self allInstances. |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2685 |
doWeakly ifTrue:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2686 |
coll := WeakArray withAll:coll |
3620
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2687 |
]. |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2688 |
^ coll |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2689 |
|
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2690 |
"Created: / 19.6.1998 / 02:17:20 / cg" |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2691 |
! |
e517c8b18e90
added #allInstancesWeakly for ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3619
diff
changeset
|
2692 |
|
2053 | 2693 |
allSelectors |
2694 |
"return a collection of all selectors understood by the receiver; |
|
2695 |
this includes my selectors and all superclass selectors |
|
2696 |
(i.e. the receivers full protocol)" |
|
2697 |
||
2698 |
superclass notNil ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2699 |
^ superclass allSelectors addAll:(self selectors); yourself. |
2053 | 2700 |
]. |
2701 |
^ self selectors asIdentitySet |
|
2702 |
||
2703 |
" |
|
2704 |
Point allSelectors |
|
2705 |
View allSelectors |
|
2706 |
Array allSelectors |
|
2707 |
" |
|
2708 |
||
2709 |
! |
|
2710 |
||
620 | 2711 |
allSubInstances |
2712 |
"return a collection of all instances of myself and |
|
2713 |
instances of all subclasses of myself." |
|
2714 |
||
2715 |
|coll| |
|
2716 |
||
2717 |
coll := OrderedCollection new:100. |
|
2718 |
self allSubInstancesDo:[:anObject | |
|
2719 |
(anObject isKindOf:self) ifTrue:[ |
|
2720 |
coll add:anObject |
|
2721 |
] |
|
2722 |
]. |
|
2723 |
^ coll |
|
2724 |
||
2725 |
" |
|
2726 |
View allSubInstances |
|
2727 |
" |
|
2728 |
! |
|
2729 |
||
2730 |
allSubclasses |
|
2731 |
"return a collection of all subclasses (direct AND indirect) of |
|
2732 |
the receiver. There will be no specific order, in which entries |
|
2733 |
are returned." |
|
2734 |
||
2735 |
|newColl| |
|
2736 |
||
2737 |
newColl := OrderedCollection new. |
|
2738 |
self allSubclassesDo:[:aClass | |
|
2739 |
newColl add:aClass |
|
2740 |
]. |
|
2741 |
^ newColl |
|
2742 |
||
2743 |
" |
|
2744 |
Collection allSubclasses |
|
2745 |
" |
|
2746 |
! |
|
2747 |
||
2748 |
allSubclassesInOrder |
|
2749 |
"return a collection of all subclasses (direct AND indirect) of |
|
2750 |
the receiver. Higher level subclasses will come before lower ones." |
|
2751 |
||
2752 |
|newColl| |
|
2753 |
||
2754 |
newColl := OrderedCollection new. |
|
2755 |
self allSubclassesInOrderDo:[:aClass | |
|
2756 |
newColl add:aClass |
|
2757 |
]. |
|
2758 |
^ newColl |
|
2759 |
||
2760 |
" |
|
2761 |
Collection allSubclassesInOrder |
|
2762 |
" |
|
2763 |
! |
|
2764 |
||
2765 |
allSuperclasses |
|
2766 |
"return a collection of the receivers accumulated superclasses" |
|
2767 |
||
2768 |
|aCollection theSuperClass| |
|
2769 |
||
2770 |
theSuperClass := superclass. |
|
2771 |
theSuperClass notNil ifTrue:[ |
|
2772 |
aCollection := OrderedCollection new. |
|
2773 |
[theSuperClass notNil] whileTrue:[ |
|
2774 |
aCollection add:theSuperClass. |
|
2775 |
theSuperClass := theSuperClass superclass |
|
2776 |
] |
|
2777 |
]. |
|
2778 |
^ aCollection |
|
2779 |
||
2780 |
" |
|
2781 |
String allSuperclasses |
|
2782 |
" |
|
2783 |
! |
|
2784 |
||
2785 |
cachedLookupMethodFor:aSelector |
|
2786 |
"return the method, which would be executed if aSelector was sent to |
|
2787 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
2788 |
and all of its superclasses are searched for aSelector. |
|
2789 |
Return the method, or nil if instances do not understand aSelector. |
|
2790 |
This interface provides exactly the same information as #lookupMethodFor:, |
|
2791 |
but uses the lookup-cache in the VM for faster search. |
|
2792 |
However, keep in mind, that doing a lookup through the cache also adds new |
|
2793 |
entries and can thus slow down the system by polluting the cache with |
|
2794 |
irrelevant entries. (do NOT loop over all objects calling this method). |
|
2795 |
Does NOT (currently) handle MI" |
|
2796 |
||
2797 |
%{ /* NOCONTEXT */ |
|
2201
db0f6e86c8bb
COMMA_SENDER arg is no longer supported / needed
Claus Gittinger <cg@exept.de>
parents:
2148
diff
changeset
|
2798 |
RETURN ( __lookup(self, aSelector) ); |
620 | 2799 |
%} |
2800 |
||
2801 |
" |
|
2802 |
String cachedLookupMethodFor:#= |
|
2803 |
String cachedLookupMethodFor:#asOrderedCollection |
|
2804 |
" |
|
2805 |
! |
|
2806 |
||
2807 |
canBeSubclassed |
|
2808 |
"return true, if its allowed to create subclasses of the receiver. |
|
2809 |
This method is redefined in SmallInteger and UndefinedObject, since |
|
2810 |
instances are detected by their pointer-fields, i.e. they do not have |
|
2811 |
a class entry (you dont have to understand this :-)" |
|
10 | 2812 |
|
2813 |
^ true |
|
2814 |
! |
|
2815 |
||
620 | 2816 |
canUnderstand:aSelector |
2817 |
"return true, if the receiver or one of its superclasses implements aSelector. |
|
2818 |
(i.e. true if my instances understand aSelector)" |
|
2819 |
||
2820 |
^ (self lookupMethodFor:aSelector) notNil |
|
2821 |
||
2822 |
" |
|
2823 |
True canUnderstand:#ifTrue: |
|
2824 |
True canUnderstand:#== |
|
2825 |
True canUnderstand:#do: |
|
2826 |
" |
|
91 | 2827 |
! |
2828 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2829 |
category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2830 |
"return the category of the class. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2831 |
Returning nil here, since Behavior does not define a category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2832 |
(only ClassDescriptions do)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2833 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2834 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2835 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2836 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2837 |
Point category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2838 |
Behavior new category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2839 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2840 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2841 |
|
3044 | 2842 |
classPool |
2843 |
^ IdentityDictionary new |
|
2844 |
||
2845 |
"Modified: 17.10.1997 / 12:07:29 / cg" |
|
2846 |
! |
|
2847 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2848 |
classVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2849 |
"return a collection of the class variable name-strings. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2850 |
Returning empty here, since Behavior does not define any classVariables. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2851 |
(only Classes do). 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
|
2852 |
(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
|
2853 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2854 |
^ #() |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2855 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2856 |
"Created: 16.4.1996 / 17:57:31 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2857 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2858 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2859 |
classVariableString |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2860 |
"return a string of the class variables names. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2861 |
Returning empty here, since Behavior does not define any classVariables. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2862 |
(only Classes do). 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
|
2863 |
(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
|
2864 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2865 |
^ '' |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2866 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2867 |
"Created: 16.4.1996 / 16:28:56 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2868 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2869 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2870 |
comment |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2871 |
"return the comment of the class. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2872 |
Returning nil here, since Behavior does not define a category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2873 |
(only Classes do). 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
|
2874 |
(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
|
2875 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2876 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2877 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2878 |
"Modified: 16.4.1996 / 16:25:23 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2879 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2880 |
|
3641 | 2881 |
commonSuperclass:aClass |
2882 |
"Return the common superclass of the receiver and aClass. |
|
2883 |
Assumes that there is a common superclass of any two classes." |
|
2884 |
||
2885 |
(aClass includesBehavior:self) ifTrue:[^ self]. |
|
2886 |
(self inheritsFrom:aClass) ifTrue:[^ aClass]. |
|
2887 |
^ superclass commonSuperclass:aClass |
|
2888 |
||
2889 |
" |
|
2890 |
Integer commonSuperclass:Fraction |
|
2891 |
SmallInteger commonSuperclass:Fraction |
|
2892 |
View commonSuperclass:Form |
|
2893 |
View commonSuperclass:Image |
|
2894 |
" |
|
2895 |
||
2896 |
"Modified: / 10.7.1998 / 02:13:04 / cg" |
|
2897 |
! |
|
2898 |
||
620 | 2899 |
compiledMethodAt:aSelector |
2900 |
"return the method for given selector aSelector or nil. |
|
2901 |
Only methods in the receiver - not in the superclass chain are tested." |
|
2902 |
||
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2903 |
^ self compiledMethodAt:aSelector ifAbsent:nil |
620 | 2904 |
|
293 | 2905 |
" |
620 | 2906 |
Object compiledMethodAt:#== |
2907 |
(Object compiledMethodAt:#==) category |
|
293 | 2908 |
" |
1088 | 2909 |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2910 |
"Modified: / 7.6.1996 / 14:43:32 / stefan" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2911 |
"Modified: / 27.10.1997 / 20:18:55 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2912 |
! |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2913 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2914 |
compiledMethodAt:aSelector ifAbsent:exceptionValue |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2915 |
"return the method for given selector aSelector or the value |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2916 |
of exceptionValue if not present. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2917 |
Only methods in the receiver - not in the superclass chain are tested." |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2918 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2919 |
|dict| |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2920 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2921 |
dict := self methodDictionary. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2922 |
dict isNil ifTrue:[ |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2923 |
('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR. |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2924 |
^ exceptionValue value |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2925 |
]. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2926 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2927 |
^ dict at:aSelector ifAbsent:exceptionValue |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2928 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2929 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2930 |
Object compiledMethodAt:#== |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2931 |
(Object compiledMethodAt:#==) category |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2932 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2933 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2934 |
"Modified: / 7.6.1996 / 14:43:32 / stefan" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2935 |
"Modified: / 10.1.1997 / 17:27:21 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2936 |
"Created: / 27.10.1997 / 20:18:28 / cg" |
620 | 2937 |
! |
2938 |
||
2939 |
containsMethod:aMethod |
|
2940 |
"Return true, if the argument, aMethod is a method of myself" |
|
2941 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2942 |
|dict| |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2943 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2944 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2945 |
dict isNil ifTrue:[^ false]. "degenerated class" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2946 |
^ (dict keyAtValue:aMethod ifAbsent:[0]) ~~ 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2947 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2948 |
"Modified: 12.6.1996 / 13:33:53 / stefan" |
620 | 2949 |
! |
2950 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2951 |
firstDefinitionSelectorPart |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2952 |
"return the first part of the selector with which I was (can be) defined in my superclass" |
2436 | 2953 |
|
2954 |
self isVariable ifFalse:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2955 |
^ #'subclass:' |
2436 | 2956 |
]. |
2957 |
self isBytes ifTrue:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2958 |
^ #'variableByteSubclass:' |
2436 | 2959 |
]. |
2960 |
self isLongs ifTrue:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2961 |
^ #'variableLongSubclass:' |
2436 | 2962 |
]. |
2963 |
self isFloats ifTrue:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2964 |
^ #'variableFloatSubclass:' |
2436 | 2965 |
]. |
2966 |
self isDoubles ifTrue:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2967 |
^ #'variableDoubleSubclass:' |
2436 | 2968 |
]. |
2969 |
self isWords ifTrue:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2970 |
^ #'variableWordSubclass:' |
2436 | 2971 |
]. |
2972 |
self isSignedWords ifTrue:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2973 |
^ #'variableSignedWordSubclass:' |
2436 | 2974 |
]. |
2975 |
self isSignedLongs ifTrue:[ |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2976 |
^ #'variableSignedLongSubclass:' |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2977 |
]. |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2978 |
self isSignedLongLongs ifTrue:[ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2979 |
^ #'variableSignedLongLongSubclass:' |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2980 |
]. |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2981 |
self isLongLongs ifTrue:[ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2982 |
^ #'variableLongLongSubclass:' |
2436 | 2983 |
]. |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2984 |
^ #'variableSubclass:' |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2985 |
! |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2986 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2987 |
definitionSelector |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2988 |
"return the selector with which I was (can be) defined in my superclass" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2989 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2990 |
^ (self firstDefinitionSelectorPart |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2991 |
, |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
2992 |
'instanceVariableNames:classVariableNames:poolDictionaries:category:') asSymbol |
2436 | 2993 |
|
2994 |
" |
|
2995 |
Object definitionSelector |
|
2996 |
Array definitionSelector |
|
2997 |
ByteArray definitionSelector |
|
2998 |
FloatArray definitionSelector |
|
2999 |
" |
|
3000 |
||
3001 |
"Modified: 3.3.1997 / 11:50:37 / cg" |
|
3002 |
! |
|
3003 |
||
2713 | 3004 |
definitionSelectorPrivate |
3005 |
"return the selector with which I was (can be) defined in my superclass |
|
3006 |
as a private class" |
|
3007 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3008 |
^ (self firstDefinitionSelectorPart |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3009 |
, |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3010 |
'instanceVariableNames:classVariableNames:poolDictionaries:privateIn:') asSymbol |
2713 | 3011 |
|
3012 |
" |
|
3013 |
Array definitionSelector |
|
3014 |
Array definitionSelectorPrivate |
|
3015 |
" |
|
3016 |
||
3017 |
"Modified: 23.6.1997 / 10:45:57 / cg" |
|
3018 |
! |
|
3019 |
||
620 | 3020 |
derivedInstanceCount |
3021 |
"return the number of instances of myself and of subclasses" |
|
3022 |
||
3023 |
|count| |
|
3024 |
||
3025 |
count := 0. |
|
3026 |
ObjectMemory allObjectsDo:[:anObject | |
|
3027 |
(anObject isKindOf:self) ifTrue:[ |
|
3028 |
count := count + 1 |
|
3029 |
] |
|
3030 |
]. |
|
3031 |
^ count |
|
3032 |
||
293 | 3033 |
" |
620 | 3034 |
View derivedInstanceCount |
3035 |
SequenceableCollection derivedInstanceCount |
|
983 | 3036 |
Object derivedInstanceCount |
3037 |
" |
|
3038 |
! |
|
3039 |
||
3040 |
hasDerivedInstances |
|
3041 |
"return true, if there are any instances of myself or of any subclass" |
|
3042 |
||
3043 |
"Read the documentation on why there seem to be no |
|
3044 |
instances of SmallInteger and UndefinedObject" |
|
3045 |
||
3046 |
ObjectMemory allObjectsDo:[:anObject | |
|
3047 |
(anObject isKindOf:self) ifTrue:[ |
|
3048 |
^ true |
|
3049 |
] |
|
3050 |
]. |
|
3051 |
^ false |
|
3052 |
||
3053 |
" |
|
3054 |
Object hasDerivedInstances - certainly true |
|
3055 |
SharedQueue hasDerivedInstances |
|
293 | 3056 |
" |
620 | 3057 |
! |
3058 |
||
2674
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3059 |
hasImmediateInstances |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3060 |
"return true if this class has immediate instances. |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3061 |
Redefined in classes which have." |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3062 |
|
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3063 |
^ false |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3064 |
|
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3065 |
"Created: 3.6.1997 / 12:01:05 / cg" |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3066 |
! |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
3067 |
|
620 | 3068 |
hasInstances |
3069 |
"return true, if there are any instances of myself" |
|
3070 |
||
3071 |
"Read the documentation on why there seem to be no |
|
3072 |
instances of SmallInteger and UndefinedObject" |
|
3073 |
||
3074 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
3075 |
"/ (anObject class == self) ifTrue:[ |
|
3076 |
"/ ^ true |
|
3077 |
"/ ] |
|
3078 |
"/ ]. |
|
983 | 3079 |
|
620 | 3080 |
ObjectMemory allInstancesOf:self do:[:anObject | |
983 | 3081 |
^ true |
620 | 3082 |
]. |
3083 |
^ false |
|
3084 |
||
293 | 3085 |
" |
620 | 3086 |
Object hasInstances |
3087 |
SequenceableCollection hasInstances |
|
3088 |
Float hasInstances |
|
3089 |
SmallInteger hasInstances |
|
293 | 3090 |
" |
620 | 3091 |
! |
3092 |
||
3093 |
hasMethods |
|
3094 |
"return true, if there are any (local) methods in this class" |
|
3095 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3096 |
^ (self methodDictionary size ~~ 0) |
620 | 3097 |
|
293 | 3098 |
" |
620 | 3099 |
True hasMethods |
3100 |
True class hasMethods |
|
3101 |
" |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3102 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3103 |
"Modified: 7.6.1996 / 15:43:09 / stefan" |
620 | 3104 |
! |
3105 |
||
3106 |
hasMultipleSuperclasses |
|
3107 |
"Return true, if this class inherits from other classes |
|
3108 |
(beside its primary superclass). |
|
3109 |
This method is a preparation for a future multiple inheritance extension |
|
3110 |
- currently it is not supported by the VM" |
|
3111 |
||
3112 |
^ otherSuperclasses notNil |
|
3113 |
! |
|
3114 |
||
3115 |
implements:aSelector |
|
3116 |
"return true, if the receiver implements aSelector. |
|
3117 |
(i.e. implemented in THIS class - NOT in a superclass). |
|
983 | 3118 |
|
3119 |
Caveat: |
|
3120 |
This simply checks for the selector being present in the classes |
|
3121 |
selector table - therefore, it does not care for ignoredMethods. |
|
3122 |
(but: you should not use this method for protocol-testing, anyway). |
|
3123 |
||
3124 |
Hint: |
|
3125 |
Dont use this method to check if someone responds to a message - |
|
3126 |
use #canUnderstand: on the class or #respondsTo: on the instance |
|
3127 |
to do this." |
|
3128 |
||
3129 |
^ self includesSelector:aSelector |
|
620 | 3130 |
|
3131 |
" |
|
983 | 3132 |
notice: this is class protocol |
3133 |
||
3134 |
True implements:#ifTrue: |
|
3135 |
True implements:#== |
|
3136 |
||
3137 |
notice: this is instance protocol |
|
3138 |
||
3139 |
true respondsTo:#ifTrue: |
|
3140 |
true respondsTo:#== |
|
3141 |
||
3142 |
notice: this is class protocol |
|
3143 |
||
3144 |
True canUnderstand:#ifTrue: |
|
3145 |
True canUnderstand:#== |
|
620 | 3146 |
" |
983 | 3147 |
|
3148 |
"Modified: 10.2.1996 / 13:15:56 / cg" |
|
620 | 3149 |
! |
3150 |
||
2698
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3151 |
includesBehavior:aClass |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3152 |
"return true, if the receiver includes the behavior of aClass; |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3153 |
i.e. if is either identical to a class or inherits from it." |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3154 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3155 |
^ (self == aClass) or:[self isSubclassOf:aClass] |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3156 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3157 |
" |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3158 |
True includesBehavior:Object |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3159 |
True includesBehavior:Boolean |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3160 |
True includesBehavior:True |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3161 |
True includesBehavior:False |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3162 |
" |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3163 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3164 |
"Modified: 19.6.1997 / 18:14:35 / cg" |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3165 |
! |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3166 |
|
620 | 3167 |
includesSelector:aSelector |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
3168 |
"return true, if the methodDictionary of THIS class includes |
983 | 3169 |
a method for aSelector. |
3170 |
(i.e. if aSelector is implemented in THIS class - NOT in a superclass). |
|
3171 |
||
3172 |
Hint: |
|
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3173 |
Dont use this method to check if someone responds to a message - |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3174 |
use #canUnderstand: on the class or #respondsTo: on the instance |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3175 |
to do this." |
3882 | 3176 |
|
3177 |
^ (self methodDictionary at:aSelector ifAbsent:nil) notNil |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3178 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3179 |
" |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3180 |
Object includesSelector:#== |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3181 |
Object includesSelector:#murks |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3182 |
" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3183 |
|
3882 | 3184 |
"Modified: / 7.6.1996 / 14:27:24 / stefan" |
3185 |
"Modified: / 16.10.1998 / 13:00:15 / cg" |
|
620 | 3186 |
! |
3187 |
||
3188 |
inheritsFrom:aClass |
|
2698
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3189 |
"return true, if the receiver inherits methods from aClass; |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3190 |
i.e. if aClass is on the receivers superclass chain." |
620 | 3191 |
|
3192 |
^ self isSubclassOf:aClass |
|
3193 |
||
3194 |
" |
|
3195 |
True inheritsFrom:Object |
|
3196 |
LinkedList inheritsFrom:Array |
|
356 | 3197 |
" |
2698
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3198 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3199 |
"Modified: 19.6.1997 / 18:13:21 / cg" |
357 | 3200 |
! |
3201 |
||
620 | 3202 |
instanceCount |
3203 |
"return the number of instances of myself." |
|
3204 |
||
3205 |
"Read the documentation on why there seem to be no |
|
3206 |
instances of SmallInteger and UndefinedObject" |
|
3207 |
||
3208 |
|count| |
|
3209 |
||
3210 |
count := 0. |
|
3211 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
3212 |
"/ (anObject class == self) ifTrue:[ |
|
3213 |
"/ count := count + 1 |
|
3214 |
"/ ] |
|
3215 |
"/ ]. |
|
983 | 3216 |
|
620 | 3217 |
ObjectMemory allInstancesOf:self do:[:anObject | |
3218 |
count := count + 1 |
|
3219 |
]. |
|
3220 |
^ count |
|
3221 |
||
3222 |
" |
|
3223 |
View instanceCount |
|
3224 |
Object instanceCount |
|
3225 |
Float instanceCount |
|
3226 |
SequenceableCollection instanceCount |
|
3227 |
SmallInteger instanceCount .... mhmh - hear, hear |
|
3228 |
" |
|
3229 |
! |
|
3230 |
||
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3231 |
instanceVariableString |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3232 |
"return a string with dummy names here - typically, your |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3233 |
objects are instances of Class, not Behavior." |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3234 |
|
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3235 |
|s superInsts n "{Class: SmallInteger }"| |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3236 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3237 |
s := ''. |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3238 |
superclass isNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3239 |
superInsts := 0 |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3240 |
] ifFalse:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3241 |
superInsts := superclass instSize |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3242 |
]. |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3243 |
n := self instSize. |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3244 |
superInsts+1 to:n do:[:i | |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3245 |
s size == 0 ifFalse:[s := s , ' ']. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3246 |
s := s , 'instvar' , i printString |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3247 |
]. |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3248 |
^ s |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3249 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3250 |
" |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3251 |
Behavior new instanceVariableString |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3252 |
" |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3253 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3254 |
"Modified: 7.5.1996 / 12:50:25 / cg" |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3255 |
"Modified: 3.6.1996 / 16:03:33 / stefan" |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3256 |
! |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3257 |
|
620 | 3258 |
isBehavior |
3259 |
"return true, if the receiver is describing another objects behavior, |
|
3260 |
i.e. is a class. Defined to avoid the need to use isKindOf:" |
|
3261 |
||
3262 |
^ true |
|
3263 |
||
3264 |
" |
|
3265 |
True isBehavior |
|
3266 |
true isBehavior |
|
3267 |
" |
|
3268 |
! |
|
3269 |
||
3270 |
isBits |
|
3271 |
"return true, if instances have indexed byte or short instance variables. |
|
3272 |
Ignore long, float and double arrays, since ST-80 code using isBits are probably |
|
3273 |
not prepared to handle them correctly." |
|
92 | 3274 |
|
3275 |
%{ /* NOCONTEXT */ |
|
620 | 3276 |
|
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3277 |
REGISTER int what; |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3278 |
|
1133 | 3279 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3280 |
RETURN (( (what == __MASKSMALLINT(BYTEARRAY)) |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3281 |
|| (what == __MASKSMALLINT(WORDARRAY))) ? true : false ); |
620 | 3282 |
%} |
3283 |
! |
|
3284 |
||
1832 | 3285 |
isBuiltInClass |
3286 |
"return true if this class is known by the run-time-system. |
|
3287 |
Here, false is returned as default. |
|
3288 |
Notice, this is instance protocol, which means that any class |
|
3289 |
other than those special ones) are non-builtIn by default." |
|
3290 |
||
3291 |
^ false |
|
3292 |
||
3293 |
"Modified: 23.4.1996 / 15:55:52 / cg" |
|
3294 |
"Created: 28.10.1996 / 15:10:02 / cg" |
|
3295 |
! |
|
3296 |
||
620 | 3297 |
isBytes |
3298 |
"return true, if instances have indexed byte instance variables" |
|
3299 |
||
3300 |
"this could also be defined as: |
|
3301 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagBytes |
|
3302 |
" |
|
3303 |
%{ /* NOCONTEXT */ |
|
3304 |
||
1133 | 3305 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(BYTEARRAY)) ? true : false ); |
68 | 3306 |
%} |
620 | 3307 |
! |
3308 |
||
3309 |
isDoubles |
|
3310 |
"return true, if instances have indexed double instance variables" |
|
3311 |
||
3312 |
"this could also be defined as: |
|
3313 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagDoubles |
|
3314 |
" |
|
3315 |
%{ /* NOCONTEXT */ |
|
3316 |
||
1133 | 3317 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(DOUBLEARRAY)) ? true : false ); |
620 | 3318 |
%} |
3319 |
! |
|
3320 |
||
3321 |
isFixed |
|
3322 |
"return true, if instances do not have indexed instance variables" |
|
3323 |
||
3324 |
"this could also be defined as: |
|
3325 |
^ self isVariable not |
|
3326 |
" |
|
3327 |
||
3328 |
%{ /* NOCONTEXT */ |
|
3329 |
||
1133 | 3330 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? false : true ); |
620 | 3331 |
%} |
3332 |
! |
|
3333 |
||
3334 |
isFloats |
|
3335 |
"return true, if instances have indexed float instance variables" |
|
3336 |
||
3337 |
"this could also be defined as: |
|
3338 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagFloats |
|
3339 |
" |
|
3340 |
%{ /* NOCONTEXT */ |
|
3341 |
||
1133 | 3342 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(FLOATARRAY)) ? true : false ); |
620 | 3343 |
%} |
91 | 3344 |
! |
3345 |
||
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3346 |
isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3347 |
"return true, if instances have indexed float or double instance variables" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3348 |
|
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3349 |
%{ /* NOCONTEXT */ |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3350 |
|
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3351 |
int what; |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3352 |
|
1133 | 3353 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3354 |
RETURN (( (what == __MASKSMALLINT(FLOATARRAY)) |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3355 |
|| (what == __MASKSMALLINT(DOUBLEARRAY))) ? true : false ); |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3356 |
%} |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3357 |
" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3358 |
(Object new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3359 |
(Point new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3360 |
(Array new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3361 |
(ByteArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3362 |
(FloatArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3363 |
(DoubleArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3364 |
" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3365 |
! |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3366 |
|
2455 | 3367 |
isJavaClass |
3368 |
"return true, if the receiver is a java class. |
|
3369 |
Java class support is not yet released to the public." |
|
3370 |
||
3371 |
^ false |
|
3372 |
||
3373 |
"Created: 17.3.1997 / 16:23:59 / cg" |
|
3374 |
! |
|
3375 |
||
620 | 3376 |
isLongs |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3377 |
"return true, if instances have indexed long instance variables (4 byte uints)" |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3378 |
|
620 | 3379 |
%{ /* NOCONTEXT */ |
3380 |
||
1133 | 3381 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(LONGARRAY)) ? true : false ); |
620 | 3382 |
%} |
356 | 3383 |
! |
3384 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3385 |
isLongLongs |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3386 |
"return true, if instances have indexed long-long instance variables (8 byte uints)" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3387 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3388 |
%{ /* NOCONTEXT */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3389 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3390 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(LONGLONGARRAY)) ? true : false ); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3391 |
%} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3392 |
! |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3393 |
|
620 | 3394 |
isPointers |
3395 |
"return true, if instances have pointer instance variables |
|
3396 |
i.e. are either non-indexed or have indexed pointer variables" |
|
3397 |
||
3398 |
"QUESTION: should we ignore WeakPointers ?" |
|
3399 |
||
3400 |
%{ /* NOCONTEXT */ |
|
3401 |
||
3402 |
REGISTER int flags; |
|
3403 |
||
1133 | 3404 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
620 | 3405 |
switch (flags) { |
3406 |
default: |
|
3407 |
/* normal objects */ |
|
3408 |
RETURN ( true ); |
|
3409 |
||
3410 |
case BYTEARRAY: |
|
3411 |
case WORDARRAY: |
|
3412 |
case LONGARRAY: |
|
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3413 |
case SWORDARRAY: |
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3414 |
case SLONGARRAY: |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3415 |
case SLONGLONGARRAY: |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3416 |
case LONGLONGARRAY: |
620 | 3417 |
case FLOATARRAY: |
3418 |
case DOUBLEARRAY: |
|
3419 |
RETURN (false ); |
|
3420 |
||
3421 |
case WKPOINTERARRAY: |
|
3422 |
/* what about those ? */ |
|
3423 |
RETURN (true ); |
|
3424 |
} |
|
3425 |
%} |
|
3426 |
! |
|
3427 |
||
1722 | 3428 |
isPrivate |
3429 |
"return true, if the receiver is some private class" |
|
3430 |
||
3431 |
^ self owningClass notNil |
|
3432 |
||
3433 |
"Modified: 12.10.1996 / 20:11:05 / cg" |
|
3434 |
! |
|
3435 |
||
1634 | 3436 |
isSignedLongs |
3437 |
"return true, if instances have indexed signed long instance variables (4 byte ints)" |
|
3438 |
||
3439 |
%{ /* NOCONTEXT */ |
|
3440 |
||
3441 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SLONGARRAY)) ? true : false ); |
|
3442 |
%} |
|
3443 |
! |
|
3444 |
||
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3445 |
isSignedLongLongs |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3446 |
"return true, if instances have indexed signed long-long instance variables (8 byte ints)" |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3447 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3448 |
%{ /* NOCONTEXT */ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3449 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3450 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SLONGLONGARRAY)) ? true : false ); |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3451 |
%} |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3452 |
! |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3453 |
|
1634 | 3454 |
isSignedWords |
3455 |
"return true, if instances have indexed signed short instance variables" |
|
3456 |
||
3457 |
%{ /* NOCONTEXT */ |
|
3458 |
||
3459 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SWORDARRAY)) ? true : false ); |
|
3460 |
%} |
|
3461 |
! |
|
3462 |
||
620 | 3463 |
isSubclassOf:aClass |
3464 |
"return true, if I am a subclass of the argument, aClass" |
|
3465 |
||
3466 |
|theClass| |
|
3467 |
||
3468 |
theClass := superclass. |
|
3469 |
[theClass notNil] whileTrue:[ |
|
3470 |
(theClass == aClass) ifTrue:[^ true]. |
|
3471 |
%{ |
|
3472 |
if (__isBehaviorLike(theClass)) { |
|
3473 |
theClass = __ClassInstPtr(theClass)->c_superclass; |
|
3474 |
} else { |
|
3475 |
theClass = nil; |
|
3476 |
} |
|
3477 |
%}. |
|
3478 |
"/ theClass := theClass superclass. |
|
3479 |
]. |
|
3480 |
^ false |
|
356 | 3481 |
|
3482 |
" |
|
620 | 3483 |
String isSubclassOf:Collection |
3484 |
LinkedList isSubclassOf:Array |
|
3485 |
1 isSubclassOf:Number <- will fail since 1 is no class |
|
3486 |
" |
|
3487 |
! |
|
3488 |
||
3489 |
isVariable |
|
3490 |
"return true, if instances have indexed instance variables" |
|
3491 |
||
3492 |
"this could also be defined as: |
|
3493 |
^ (flags bitAnd:(Behavior maskIndexType)) ~~ 0 |
|
3494 |
" |
|
3495 |
||
3496 |
%{ /* NOCONTEXT */ |
|
3497 |
||
1133 | 3498 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? true : false ); |
620 | 3499 |
%} |
3500 |
! |
|
3501 |
||
3502 |
isWords |
|
3503 |
"return true, if instances have indexed short instance variables" |
|
3504 |
||
3505 |
"this could also be defined as: |
|
3506 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagWords |
|
3507 |
" |
|
3508 |
%{ /* NOCONTEXT */ |
|
3509 |
||
1133 | 3510 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(WORDARRAY)) ? true : false ); |
620 | 3511 |
%} |
3512 |
! |
|
3513 |
||
3514 |
lookupMethodFor:aSelector |
|
3515 |
"return the method, which would be executed if aSelector was sent to |
|
3516 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
3517 |
and all of its superclasses are searched for aSelector. |
|
3518 |
Return the method, or nil if instances do not understand aSelector. |
|
3519 |
EXPERIMENTAL: take care of multiple superclasses." |
|
3520 |
||
3521 |
|m cls| |
|
3522 |
||
3523 |
cls := self. |
|
3524 |
[cls notNil] whileTrue:[ |
|
3525 |
m := cls compiledMethodAt:aSelector. |
|
3526 |
m notNil ifTrue:[^ m]. |
|
3527 |
cls hasMultipleSuperclasses ifTrue:[ |
|
3528 |
cls superclasses do:[:aSuperClass | |
|
3529 |
m := aSuperClass lookupMethodFor:aSelector. |
|
3530 |
m notNil ifTrue:[^ m]. |
|
3531 |
]. |
|
3532 |
^ nil |
|
3533 |
] ifFalse:[ |
|
3534 |
cls := cls superclass |
|
3535 |
] |
|
3536 |
]. |
|
3537 |
^ nil |
|
3538 |
! |
|
3539 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3540 |
name |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3541 |
"although behaviors have no name, we return something |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3542 |
useful here - there are many places (inspectors) where |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3543 |
a classes name is asked for. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3544 |
Implementing this message here allows anonymous classes |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3545 |
and instances of them to be inspected." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3546 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3547 |
^ 'someBehavior' |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3548 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3549 |
|
1760 | 3550 |
owningClass |
3551 |
"return my owning class - nil if I am a public class" |
|
3552 |
||
1918 | 3553 |
"/ this information is in the metaclass ... |
3554 |
||
1760 | 3555 |
^ self class owningClass |
3556 |
||
3557 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
1918 | 3558 |
"Modified: 7.11.1996 / 13:49:28 / cg" |
1760 | 3559 |
! |
3560 |
||
620 | 3561 |
selectorAtMethod:aMethod |
3562 |
"Return the selector for given method aMethod." |
|
3563 |
||
3564 |
^ self selectorAtMethod:aMethod ifAbsent:[nil] |
|
3565 |
||
3566 |
" |
|
3567 |
|m| |
|
3568 |
||
3569 |
m := Object compiledMethodAt:#copy. |
|
3570 |
Fraction selectorAtMethod:m. |
|
3571 |
" |
|
3572 |
" |
|
3573 |
|m| |
|
3574 |
||
3575 |
m := Object compiledMethodAt:#copy. |
|
3576 |
Object selectorAtMethod:m. |
|
356 | 3577 |
" |
3578 |
! |
|
3579 |
||
620 | 3580 |
selectorAtMethod:aMethod ifAbsent:failBlock |
3581 |
"return the selector for given method aMethod |
|
3582 |
or the value of failBlock, if not found." |
|
3583 |
||
1814 | 3584 |
|md| |
3585 |
||
3586 |
md := self methodDictionary. |
|
3587 |
md isNil ifTrue:[ |
|
3588 |
'OOPS - nil methodDictionary' errorPrintCR. |
|
3589 |
^ nil |
|
3590 |
]. |
|
3591 |
^ md keyAtValue:aMethod ifAbsent:failBlock. |
|
216 | 3592 |
|
3593 |
" |
|
620 | 3594 |
|m| |
3595 |
||
3596 |
m := Object compiledMethodAt:#copy. |
|
3597 |
Object selectorAtMethod:m ifAbsent:['oops']. |
|
3598 |
" |
|
216 | 3599 |
" |
620 | 3600 |
|m| |
3601 |
||
3602 |
m := Object compiledMethodAt:#copy. |
|
3603 |
Fraction selectorAtMethod:m ifAbsent:['oops']. |
|
216 | 3604 |
" |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3605 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3606 |
"Modified: 7.6.1996 / 15:15:45 / stefan" |
216 | 3607 |
! |
3608 |
||
2699
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3609 |
sharedPools |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3610 |
^ #() |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3611 |
|
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3612 |
"Created: 19.6.1997 / 18:19:36 / cg" |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3613 |
! |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3614 |
|
127 | 3615 |
sizeOfInst:n |
3616 |
"return the number of bytes required for an instance of |
|
3617 |
myself with n indexed instance variables. The argument n |
|
3618 |
should be zero for classes without indexed instance variables. |
|
3619 |
See Behavior>>niceNew: for an application of this." |
|
216 | 3620 |
|
127 | 3621 |
|nInstvars| |
3622 |
||
3623 |
nInstvars := self instSize. |
|
3624 |
%{ |
|
3625 |
int nBytes; |
|
3626 |
||
1133 | 3627 |
nBytes = __intVal(nInstvars) * sizeof(OBJ) + OHDR_SIZE; |
249 | 3628 |
if (__isSmallInteger(n)) { |
154 | 3629 |
int nIndex; |
127 | 3630 |
|
1133 | 3631 |
nIndex = __intVal(n); |
3632 |
switch (__intVal(__INST(flags)) & ARRAYMASK) { |
|
154 | 3633 |
case BYTEARRAY: |
3634 |
nBytes += nIndex; |
|
2894 | 3635 |
if (nBytes & (__ALIGN__ - 1)) { |
3636 |
nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__; |
|
154 | 3637 |
} |
3638 |
break; |
|
127 | 3639 |
|
154 | 3640 |
case WORDARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3641 |
case SWORDARRAY: |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3642 |
nBytes += nIndex * 2; |
2894 | 3643 |
if (nBytes & (__ALIGN__ - 1)) { |
3644 |
nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__; |
|
154 | 3645 |
} |
3646 |
break; |
|
127 | 3647 |
|
154 | 3648 |
case LONGARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3649 |
case SLONGARRAY: |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3650 |
nBytes += nIndex * 4; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3651 |
break; |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3652 |
|
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3653 |
case LONGLONGARRAY: |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3654 |
case SLONGLONGARRAY: |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3655 |
nBytes += nIndex * 8; |
154 | 3656 |
break; |
127 | 3657 |
|
154 | 3658 |
case FLOATARRAY: |
3659 |
nBytes += nIndex * sizeof(float); |
|
3660 |
break; |
|
127 | 3661 |
|
154 | 3662 |
case DOUBLEARRAY: |
3663 |
nBytes += nIndex * sizeof(double); |
|
3664 |
break; |
|
127 | 3665 |
|
154 | 3666 |
default: |
3667 |
nBytes += nIndex * sizeof(OBJ); |
|
3668 |
break; |
|
3669 |
} |
|
127 | 3670 |
} |
1133 | 3671 |
RETURN (__MKSMALLINT(nBytes)); |
127 | 3672 |
%} |
3673 |
! |
|
3674 |
||
620 | 3675 |
sourceCodeAt:aSelector |
3676 |
"return the methods source for given selector aSelector or nil. |
|
3677 |
Only methods in the receiver - not in the superclass chain are tested." |
|
3678 |
||
3679 |
|method| |
|
3680 |
||
3681 |
method := self compiledMethodAt:aSelector. |
|
3682 |
method isNil ifTrue:[^ nil]. |
|
3683 |
^ method source |
|
45 | 3684 |
|
91 | 3685 |
" |
620 | 3686 |
True sourceCodeAt:#ifTrue: |
3687 |
Object sourceCodeAt:#== |
|
3688 |
Behavior sourceCodeAt:#sourceCodeAt: |
|
91 | 3689 |
" |
1 | 3690 |
! |
3691 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3692 |
sourceCodeManager |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3693 |
"return the sourceCodeManager of the class. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3694 |
Returning nil here, since Behavior does not define any sourceCode management. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3695 |
(only Classes do). 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
|
3696 |
(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
|
3697 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3698 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3699 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3700 |
"Created: 16.4.1996 / 16:26:03 / cg" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3701 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3702 |
|
1 | 3703 |
subclasses |
3704 |
"return a collection of the direct subclasses of the receiver" |
|
3705 |
||
3706 |
|newColl| |
|
3707 |
||
2224 | 3708 |
"/ use cached information (avoid class hierarchy search) |
3709 |
"/ if possible |
|
3710 |
||
308 | 3711 |
SubclassInfo notNil ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
3712 |
newColl := SubclassInfo at:self ifAbsent:nil. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
3713 |
newColl notNil ifTrue:[^ newColl asOrderedCollection] |
308 | 3714 |
]. |
3715 |
||
1 | 3716 |
newColl := OrderedCollection new. |
3717 |
self subclassesDo:[:aClass | |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
3718 |
newColl add:aClass |
1 | 3719 |
]. |
3720 |
^ newColl |
|
45 | 3721 |
|
91 | 3722 |
" |
3723 |
Collection subclasses |
|
3724 |
" |
|
2224 | 3725 |
|
3726 |
"Modified: 22.1.1997 / 18:43:52 / cg" |
|
1 | 3727 |
! |
3728 |
||
620 | 3729 |
superclasses |
3730 |
"return a collection of the receivers immediate superclasses. |
|
3731 |
This method is a preparation for a future multiple inheritance extension |
|
3732 |
- currently it is not supported by the VM" |
|
3733 |
||
3734 |
|a| |
|
3735 |
||
3736 |
a := Array with:superclass. |
|
3737 |
otherSuperclasses notNil ifTrue:[ |
|
3738 |
^ a , otherSuperclasses |
|
1 | 3739 |
]. |
620 | 3740 |
^ a |
154 | 3741 |
|
3742 |
" |
|
620 | 3743 |
String superclasses |
91 | 3744 |
" |
2 | 3745 |
! |
3746 |
||
2809 | 3747 |
supportsMethodCategories |
3748 |
"return true, if my methods are categorized. |
|
3749 |
This is a hook for the browser to allow alien classes |
|
3750 |
to be handled (aktually, this is not yet used)." |
|
3751 |
||
3752 |
^ true |
|
3753 |
||
3754 |
"Created: 30.7.1997 / 14:59:08 / cg" |
|
3755 |
"Modified: 30.7.1997 / 15:02:03 / cg" |
|
3756 |
! |
|
3757 |
||
2048 | 3758 |
topOwningClass |
3759 |
"return my outermost owning class - nil if I am a public class" |
|
3760 |
||
3761 |
"/ this information is in the metaclass ... |
|
3762 |
||
3763 |
^ self class topOwningClass |
|
3764 |
||
3765 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
3766 |
"Modified: 3.1.1997 / 19:18:49 / cg" |
|
3767 |
! |
|
3768 |
||
1191
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3769 |
wasAutoloaded |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3770 |
"return true, if this class came into the system via an |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3771 |
autoload; false otherwise. |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3772 |
Returning false here. This allows different Behavior-like objects |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3773 |
(alien classes) to be handled by the browser as well." |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3774 |
|
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3775 |
^ false |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3776 |
|
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3777 |
"Created: 16.4.1996 / 16:27:16 / cg" |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3778 |
! |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3779 |
|
2 | 3780 |
whichClassImplements:aSelector |
328 | 3781 |
"obsolete interface; |
3782 |
use whichClassIncludesSelector: for ST-80 compatibility." |
|
3783 |
||
3784 |
^ self whichClassIncludesSelector:aSelector |
|
3785 |
! |
|
3786 |
||
3787 |
whichClassIncludesSelector:aSelector |
|
68 | 3788 |
"return the class in the inheritance chain, which implements the method |
3789 |
for aSelector; return nil if none. |
|
3790 |
EXPERIMENTAL: handle multiple superclasses" |
|
3791 |
||
3792 |
|cls| |
|
2 | 3793 |
|
68 | 3794 |
cls := self. |
3795 |
[cls notNil] whileTrue:[ |
|
983 | 3796 |
(cls includesSelector:aSelector) ifTrue:[^ cls]. |
154 | 3797 |
cls hasMultipleSuperclasses ifTrue:[ |
3798 |
cls superclasses do:[:aSuperClass | |
|
3799 |
|implementingClass| |
|
2 | 3800 |
|
328 | 3801 |
implementingClass := aSuperClass whichClassIncludesSelector:aSelector. |
154 | 3802 |
implementingClass notNil ifTrue:[^ implementingClass]. |
3803 |
]. |
|
3804 |
^ nil |
|
3805 |
] ifFalse:[ |
|
3806 |
cls := cls superclass |
|
3807 |
] |
|
2 | 3808 |
]. |
3809 |
^ nil |
|
3810 |
||
91 | 3811 |
" |
328 | 3812 |
String whichClassIncludesSelector:#== |
3813 |
String whichClassIncludesSelector:#collect: |
|
91 | 3814 |
" |
2 | 3815 |
! |
3816 |
||
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3817 |
whichSelectorsReferTo:someLiteralConstant |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3818 |
"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
|
3819 |
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
|
3820 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3821 |
|setOfSelectors| |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3822 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3823 |
setOfSelectors := IdentitySet new. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3824 |
methodDictionary keysAndValuesDo:[:sel :mthd | |
3920
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3825 |
(mthd referencesLiteral:someLiteralConstant) ifTrue:[ |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3826 |
setOfSelectors add:sel |
0c1b9b2fa23b
added longlong indexed instvars;
Claus Gittinger <cg@exept.de>
parents:
3882
diff
changeset
|
3827 |
]. |
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3828 |
]. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3829 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3830 |
^ setOfSelectors |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3831 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3832 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3833 |
String whichSelectorsReferTo:#at: |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3834 |
String whichSelectorsReferTo:CharacterArray |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3835 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3836 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3837 |
"Modified: / 28.10.1997 / 13:13:18 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3838 |
! |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3839 |
|
620 | 3840 |
withAllSubclasses |
3841 |
"return a collection containing the receiver and |
|
3842 |
all subclasses (direct AND indirect) of the receiver" |
|
3843 |
||
3844 |
|newColl| |
|
3845 |
||
3846 |
newColl := OrderedCollection with:self. |
|
3847 |
self allSubclassesDo:[:aClass | |
|
3848 |
newColl add:aClass |
|
3849 |
]. |
|
3850 |
^ newColl |
|
328 | 3851 |
|
3852 |
" |
|
620 | 3853 |
Collection withAllSubclasses |
91 | 3854 |
" |
1 | 3855 |
! |
3856 |
||
620 | 3857 |
withAllSuperclasses |
3858 |
"return a collection containing the receiver and all |
|
3859 |
of the receivers accumulated superclasses" |
|
3860 |
||
3861 |
|aCollection theSuperClass| |
|
3862 |
||
3863 |
aCollection := OrderedCollection with:self. |
|
3864 |
theSuperClass := superclass. |
|
3865 |
[theSuperClass notNil] whileTrue:[ |
|
3866 |
aCollection add:theSuperClass. |
|
3867 |
theSuperClass := theSuperClass superclass |
|
308 | 3868 |
]. |
620 | 3869 |
^ aCollection |
11 | 3870 |
|
91 | 3871 |
" |
620 | 3872 |
String withAllSuperclasses |
308 | 3873 |
" |
2 | 3874 |
! ! |
620 | 3875 |
|
3876 |
!Behavior methodsFor:'snapshots'! |
|
3877 |
||
3878 |
postSnapshot |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3879 |
"sent by ObjectMemory to all classes, after a snapshot has been written. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3880 |
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
|
3881 |
about snapshooting." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3882 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3883 |
"Modified: 16.4.1996 / 18:12:08 / cg" |
620 | 3884 |
! |
3885 |
||
3886 |
preSnapshot |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3887 |
"sent by ObjectMemory to all classes, before a snapshot is written. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3888 |
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
|
3889 |
about snapshooting." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3890 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3891 |
"Modified: 16.4.1996 / 18:12:14 / cg" |
620 | 3892 |
! ! |
3893 |
||
1760 | 3894 |
!Behavior class methodsFor:'documentation'! |
662 | 3895 |
|
3896 |
version |
|
3980
8f9443e37693
renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents:
3935
diff
changeset
|
3897 |
^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.141 1999-02-12 14:55:00 cg Exp $' |
662 | 3898 |
! ! |