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