author | Claus Gittinger <cg@exept.de> |
Wed, 13 May 1998 23:38:30 +0200 | |
changeset 3443 | d57ea75d3ac5 |
parent 3442 | d22afbb5864f |
child 3480 | aa538a7438ba |
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 |
||
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1584 |
initializeWithAllPrivateClasses |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1585 |
"if implemented, send #initialize to myself and any private |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1586 |
class which does so. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1587 |
This is sent to a class after it |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1588 |
has been loaded into the system. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1589 |
Statically compiled classes are initialized by the VM" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1590 |
|
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1591 |
(self class implements:#initialize) ifTrue:[ |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1592 |
self initialize. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1593 |
]. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1594 |
self privateClassesSorted do:[:aPrivateClass | |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1595 |
aPrivateClass initializeWithAllPrivateClasses. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1596 |
]. |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1597 |
|
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1598 |
"Created: / 13.5.1998 / 23:33:16 / cg" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1599 |
"Modified: / 13.5.1998 / 23:34:06 / cg" |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1600 |
! |
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
1601 |
|
328 | 1602 |
postAutoload |
442 | 1603 |
"postAutoload is sent to a class after it has been autoloaded. |
1604 |
This gives it a chance to arrange for automatic unloading to be done |
|
1605 |
after a while ... |
|
1606 |
This is NOT sent to statically compiled in or explicitely filedIn |
|
1607 |
classes. |
|
1608 |
The default action here is to do nothing." |
|
328 | 1609 |
|
1610 |
^ self |
|
1611 |
! |
|
1612 |
||
1 | 1613 |
reinitialize |
442 | 1614 |
"reinitialize is sent to a class when an image has been restarted. |
1615 |
I.e. when the system is restarted. |
|
1616 |
This gives classes a chance to flush any device dependent or otherwise |
|
1617 |
obsolete data which may be a leftover from the previous live. |
|
1618 |
The default action here is to do nothing." |
|
1619 |
||
1620 |
^ self |
|
11 | 1621 |
! ! |
1622 |
||
492
fa23b14f444b
renamed instance creation category
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
1623 |
!Behavior methodsFor:'instance creation'! |
1 | 1624 |
|
1625 |
basicNew |
|
54 | 1626 |
"return an instance of myself without indexed variables. |
1 | 1627 |
If the receiver-class has indexed instvars, the new object will have |
91 | 1628 |
a basicSize of zero - |
1629 |
i.e. 'aClass basicNew' is equivalent to 'aClass basicNew:0'. |
|
54 | 1630 |
|
1 | 1631 |
** Do not redefine this method in any class **" |
1632 |
||
1633 |
%{ /* NOCONTEXT */ |
|
81 | 1634 |
REGISTER OBJ newobj; |
1635 |
REGISTER char *nextPtr; |
|
91 | 1636 |
unsigned int instsize; |
1637 |
REGISTER unsigned int nInstVars; |
|
1 | 1638 |
|
54 | 1639 |
/* |
369 | 1640 |
* the following ugly code is nothing more than a __new() followed |
54 | 1641 |
* by a nilling of the new instance. |
91 | 1642 |
* Unrolled for a bit more speed since this is one of the central object |
1643 |
* allocation methods in the system |
|
54 | 1644 |
*/ |
1133 | 1645 |
nInstVars = __intVal(__INST(instSize)); |
92 | 1646 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
54 | 1647 |
|
983 | 1648 |
newobj = (OBJ) __newNextPtr; |
81 | 1649 |
nextPtr = ((char *)newobj) + instsize; |
1650 |
||
1651 |
/* |
|
1652 |
* dont argue about the goto and the arrangement below - it saves |
|
1653 |
* an extra nil-compare and branch in the common case ... |
|
91 | 1654 |
* (i.e. if no GC is needed, we fall through without a branch) |
81 | 1655 |
*/ |
983 | 1656 |
if (nextPtr < __newEndPtr) { |
154 | 1657 |
_objPtr(newobj)->o_size = instsize; |
1658 |
/* o_allFlags(newobj) = 0; */ |
|
983 | 1659 |
/* _objPtr(newobj)->o_space = __newSpace; */ |
1660 |
o_setAllFlags(newobj, __newSpace); |
|
2894 | 1661 |
#ifdef __HAS_ALIGN4__ |
1662 |
/* |
|
1663 |
* if the alignment is 4, we are already sat, |
|
1664 |
* since a non-indexed object always has a word-aligned size. |
|
1665 |
*/ |
|
983 | 1666 |
__newNextPtr = nextPtr; |
91 | 1667 |
#else |
2894 | 1668 |
if (instsize & (__ALIGN__-1)) { |
1669 |
__newNextPtr = (char *)newobj + (instsize & ~(__ALIGN__-1)) + __ALIGN__; |
|
154 | 1670 |
} else { |
983 | 1671 |
__newNextPtr = nextPtr; |
154 | 1672 |
} |
91 | 1673 |
#endif |
82 | 1674 |
|
1675 |
ok: |
|
1133 | 1676 |
__InstPtr(newobj)->o_class = self; |
369 | 1677 |
__qSTORE(newobj, self); |
82 | 1678 |
|
154 | 1679 |
if (nInstVars) { |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1680 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 1681 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
82 | 1682 |
#else |
154 | 1683 |
REGISTER OBJ *op; |
82 | 1684 |
|
1133 | 1685 |
op = __InstPtr(newobj)->i_instvars; |
82 | 1686 |
|
91 | 1687 |
# if !defined(NEGATIVE_ADDRESSES) |
154 | 1688 |
/* |
1689 |
* knowing that nil is 0 |
|
1690 |
*/ |
|
91 | 1691 |
# if defined(FAST_OBJECT_MEMSET_DOUBLES_UNROLLED) |
154 | 1692 |
if (nInstVars > 8) { |
1693 |
*op++ = nil; /* for alignment */ |
|
1694 |
nInstVars--; |
|
1695 |
while (nInstVars >= 8) { |
|
1696 |
*(double *)op = 0.0; |
|
1697 |
((double *)op)[1] = 0.0; |
|
1698 |
((double *)op)[2] = 0.0; |
|
1699 |
((double *)op)[3] = 0.0; |
|
1700 |
op += 8; |
|
1701 |
nInstVars -= 8; |
|
1702 |
} |
|
1703 |
} |
|
1704 |
while (nInstVars != 0) { |
|
1705 |
*op++ = 0; |
|
1706 |
nInstVars--; |
|
1707 |
} |
|
82 | 1708 |
# else |
91 | 1709 |
# if defined(FAST_OBJECT_MEMSET_LONGLONG_UNROLLED) |
154 | 1710 |
if (nInstVars > 8) { |
1711 |
*op++ = nil; /* for alignment */ |
|
1712 |
nInstVars--; |
|
1713 |
while (nInstVars >= 8) { |
|
1714 |
*(long long *)op = 0; |
|
1715 |
((long long *)op)[1] = 0; |
|
1716 |
((long long *)op)[2] = 0; |
|
1717 |
((long long *)op)[3] = 0; |
|
1718 |
op += 8; |
|
1719 |
nInstVars -= 8; |
|
1720 |
} |
|
1721 |
} |
|
1722 |
while (nInstVars != 0) { |
|
1723 |
*op++ = 0; |
|
1724 |
nInstVars--; |
|
1725 |
} |
|
91 | 1726 |
|
1727 |
# else |
|
1728 |
# if defined(FAST_OBJECT_MEMSET_WORDS_UNROLLED) |
|
154 | 1729 |
while (nInstVars >= 8) { |
1730 |
*op = nil; |
|
1731 |
*(op+1) = nil; |
|
1732 |
*(op+2) = nil; |
|
1733 |
*(op+3) = nil; |
|
1734 |
*(op+4) = nil; |
|
1735 |
*(op+5) = nil; |
|
1736 |
*(op+6) = nil; |
|
1737 |
*(op+7) = nil; |
|
1738 |
op += 8; |
|
1739 |
nInstVars -= 8; |
|
1740 |
} |
|
1741 |
while (nInstVars != 0) { |
|
1742 |
*op++ = nil; |
|
1743 |
nInstVars--; |
|
1744 |
} |
|
91 | 1745 |
# else |
1746 |
# if defined(FAST_MEMSET) |
|
1133 | 1747 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
91 | 1748 |
# else |
154 | 1749 |
do { |
1750 |
*op++ = nil; |
|
1751 |
nInstVars--; |
|
1752 |
} while (nInstVars != 0); |
|
91 | 1753 |
# endif |
82 | 1754 |
# endif |
1755 |
# endif |
|
1756 |
# endif |
|
1757 |
# else /* nil could be ~~ 0 */ |
|
154 | 1758 |
while (nInstVars >= 8) { |
1759 |
*op = nil; |
|
1760 |
*(op+1) = nil; |
|
1761 |
*(op+2) = nil; |
|
1762 |
*(op+3) = nil; |
|
1763 |
*(op+4) = nil; |
|
1764 |
*(op+5) = nil; |
|
1765 |
*(op+6) = nil; |
|
1766 |
*(op+7) = nil; |
|
1767 |
op += 8; |
|
1768 |
nInstVars -= 8; |
|
1769 |
} |
|
1770 |
while (nInstVars != 0) { |
|
1771 |
*op++ = nil; |
|
1772 |
nInstVars--; |
|
1773 |
} |
|
82 | 1774 |
# endif |
1775 |
#endif |
|
154 | 1776 |
} |
1777 |
RETURN ( newobj ); |
|
81 | 1778 |
} |
54 | 1779 |
|
92 | 1780 |
/* |
1781 |
* the slow case - a GC will occur |
|
1782 |
*/ |
|
834 | 1783 |
__PROTECT_CONTEXT__ |
369 | 1784 |
newobj = __new(instsize); |
834 | 1785 |
__UNPROTECT_CONTEXT__ |
82 | 1786 |
if (newobj != nil) goto ok; |
1 | 1787 |
%} |
2 | 1788 |
. |
68 | 1789 |
" |
1790 |
memory allocation failed. |
|
1791 |
When we arrive here, there was no memory, even after |
|
165 | 1792 |
a garbage collect. |
1793 |
This means, that the VM wanted to get some more memory from the |
|
1794 |
Operatingsystem, which was not kind enough to give it. |
|
1795 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 1796 |
" |
127 | 1797 |
^ ObjectMemory allocationFailureSignal raise. |
1 | 1798 |
! |
1799 |
||
1800 |
basicNew:anInteger |
|
1801 |
"return an instance of myself with anInteger indexed variables. |
|
1802 |
If the receiver-class has no indexed instvars, this is only allowed |
|
1803 |
if the argument, anInteger is zero. |
|
1804 |
** Do not redefine this method in any class **" |
|
1805 |
||
1806 |
%{ /* NOCONTEXT */ |
|
1807 |
||
1808 |
OBJ newobj; |
|
154 | 1809 |
unsigned INT instsize, nInstVars; |
1810 |
INT nindexedinstvars; |
|
92 | 1811 |
unsigned INT flags; |
1812 |
#if ! defined(FAST_ARRAY_MEMSET) || defined(NEGATIVE_ADDRESSES) |
|
1 | 1813 |
REGISTER char *cp; |
1814 |
short *sp; |
|
1815 |
long *lp; |
|
1816 |
#endif |
|
1817 |
REGISTER OBJ *op; |
|
1818 |
float *fp; |
|
1819 |
double *dp; |
|
1820 |
||
249 | 1821 |
if (__isSmallInteger(anInteger)) { |
1133 | 1822 |
nindexedinstvars = __intVal(anInteger); |
154 | 1823 |
if (nindexedinstvars >= 0) { |
1133 | 1824 |
nInstVars = __intVal(__INST(instSize)); |
1825 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
|
154 | 1826 |
switch (flags) { |
1827 |
case BYTEARRAY: |
|
1828 |
instsize = OHDR_SIZE + nindexedinstvars; |
|
1829 |
if (nInstVars == 0) { |
|
2894 | 1830 |
if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */ |
154 | 1831 |
/* |
1832 |
* the most common case |
|
1833 |
*/ |
|
835 | 1834 |
__qCheckedNew(newobj, instsize); |
1133 | 1835 |
__InstPtr(newobj)->o_class = self; |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1836 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
359 | 1837 |
nInstVars = nindexedinstvars >> 2; |
1838 |
if (nindexedinstvars & 3) nInstVars++; |
|
1133 | 1839 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
357 | 1840 |
#else |
1841 |
# if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
|
1133 | 1842 |
memset(__InstPtr(newobj)->i_instvars, 0, nindexedinstvars); |
357 | 1843 |
# else |
1133 | 1844 |
cp = (char *)__InstPtr(newobj)->i_instvars; |
154 | 1845 |
while (nindexedinstvars >= sizeof(long)) { |
1846 |
*(long *)cp = 0; |
|
1847 |
cp += sizeof(long); |
|
1848 |
nindexedinstvars -= sizeof(long); |
|
1849 |
} |
|
1850 |
while (nindexedinstvars--) |
|
1851 |
*cp++ = '\0'; |
|
357 | 1852 |
# endif |
92 | 1853 |
#endif |
154 | 1854 |
RETURN ( newobj ); |
1855 |
} |
|
1856 |
} else { |
|
1857 |
instsize += __OBJS2BYTES__(nInstVars); |
|
1858 |
} |
|
834 | 1859 |
__PROTECT_CONTEXT__ |
2894 | 1860 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 1861 |
__UNPROTECT_CONTEXT__ |
154 | 1862 |
if (newobj == nil) { |
1863 |
break; |
|
1864 |
} |
|
1133 | 1865 |
__InstPtr(newobj)->o_class = self; |
369 | 1866 |
__qSTORE(newobj, self); |
1867 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1868 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
357 | 1869 |
nInstVars = (instsize-OHDR_SIZE) >> 2; |
1870 |
if (instsize & 3) nInstVars++; |
|
1133 | 1871 |
memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars); |
357 | 1872 |
#else |
1873 |
# if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
|
154 | 1874 |
/* |
1875 |
* knowing that nil is 0 |
|
1876 |
*/ |
|
1133 | 1877 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE); |
357 | 1878 |
# else |
1133 | 1879 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1880 |
while (nInstVars--) |
1881 |
*op++ = nil; |
|
1882 |
cp = (char *)op; |
|
1883 |
while (nindexedinstvars >= sizeof(long)) { |
|
1884 |
*(long *)cp = 0; |
|
1885 |
cp += sizeof(long); |
|
1886 |
nindexedinstvars -= sizeof(long); |
|
1887 |
} |
|
1888 |
while (nindexedinstvars--) |
|
1889 |
*cp++ = '\0'; |
|
357 | 1890 |
# endif |
1 | 1891 |
#endif |
154 | 1892 |
RETURN ( newobj ); |
1893 |
break; |
|
1 | 1894 |
|
154 | 1895 |
case WORDARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
1896 |
case SWORDARRAY: |
154 | 1897 |
instsize = OHDR_SIZE + |
1898 |
__OBJS2BYTES__(nInstVars) + |
|
1899 |
nindexedinstvars * sizeof(short); |
|
834 | 1900 |
__PROTECT_CONTEXT__ |
2894 | 1901 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 1902 |
__UNPROTECT_CONTEXT__ |
154 | 1903 |
if (newobj == nil) { |
1904 |
break; |
|
1905 |
} |
|
1133 | 1906 |
__InstPtr(newobj)->o_class = self; |
369 | 1907 |
__qSTORE(newobj, self); |
1908 |
||
92 | 1909 |
#if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
154 | 1910 |
/* |
1911 |
* knowing that nil is 0 |
|
1912 |
*/ |
|
1133 | 1913 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 1914 |
#else |
1133 | 1915 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1916 |
while (nInstVars--) |
1917 |
*op++ = nil; |
|
1918 |
sp = (short *)op; |
|
1919 |
while (nindexedinstvars--) |
|
1920 |
*sp++ = 0; |
|
1 | 1921 |
#endif |
154 | 1922 |
RETURN ( newobj ); |
1923 |
break; |
|
1 | 1924 |
|
154 | 1925 |
case LONGARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
1926 |
case SLONGARRAY: |
154 | 1927 |
instsize = OHDR_SIZE + |
1928 |
__OBJS2BYTES__(nInstVars) + |
|
1929 |
nindexedinstvars * sizeof(long); |
|
834 | 1930 |
__PROTECT_CONTEXT__ |
2894 | 1931 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 1932 |
__UNPROTECT_CONTEXT__ |
154 | 1933 |
if (newobj == nil) { |
1934 |
break; |
|
1935 |
} |
|
1133 | 1936 |
__InstPtr(newobj)->o_class = self; |
369 | 1937 |
__qSTORE(newobj, self); |
1938 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1939 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
154 | 1940 |
/* |
1941 |
* knowing that nil is 0 |
|
1942 |
*/ |
|
2865 | 1943 |
{ |
1944 |
int n4 = nInstVars + nindexedinstvars; |
|
1945 |
||
1946 |
memset4(__InstPtr(newobj)->i_instvars, 0, n4); |
|
1947 |
} |
|
1 | 1948 |
#else |
92 | 1949 |
# if defined(FAST_ARRAY_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
154 | 1950 |
/* |
1951 |
* knowing that nil is 0 |
|
1952 |
*/ |
|
1133 | 1953 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 1954 |
# else |
1133 | 1955 |
op = __InstPtr(newobj)->i_instvars; |
154 | 1956 |
while (nInstVars--) |
1957 |
*op++ = nil; |
|
1958 |
lp = (long *)op; |
|
1959 |
while (nindexedinstvars--) |
|
1960 |
*lp++ = 0; |
|
1 | 1961 |
# endif |
1962 |
#endif |
|
154 | 1963 |
RETURN ( newobj ); |
1964 |
break; |
|
1 | 1965 |
|
154 | 1966 |
case FLOATARRAY: |
325 | 1967 |
instsize = sizeof(struct __floatArray) + |
154 | 1968 |
__OBJS2BYTES__(nInstVars) + |
1969 |
(nindexedinstvars - 1) * sizeof(float); |
|
54 | 1970 |
|
834 | 1971 |
__PROTECT_CONTEXT__ |
2894 | 1972 |
__qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 1973 |
__UNPROTECT_CONTEXT__ |
154 | 1974 |
if (newobj == nil) { |
1975 |
break; |
|
1976 |
} |
|
1133 | 1977 |
__InstPtr(newobj)->o_class = self; |
369 | 1978 |
__qSTORE(newobj, self); |
1979 |
||
1133 | 1980 |
op = __InstPtr(newobj)->i_instvars; |
92 | 1981 |
# if defined(mips) /* knowin that float 0.0 is all-zeros */ |
1133 | 1982 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
92 | 1983 |
# else |
154 | 1984 |
while (nInstVars--) |
1985 |
*op++ = nil; |
|
1986 |
fp = (float *)op; |
|
1987 |
while (nindexedinstvars--) |
|
1988 |
*fp++ = 0.0; |
|
92 | 1989 |
# endif |
154 | 1990 |
RETURN ( newobj ); |
1991 |
break; |
|
1 | 1992 |
|
154 | 1993 |
case DOUBLEARRAY: |
325 | 1994 |
instsize = sizeof(struct __doubleArray) + |
154 | 1995 |
__OBJS2BYTES__(nInstVars) + |
1996 |
(nindexedinstvars - 1) * sizeof(double); |
|
54 | 1997 |
|
834 | 1998 |
__PROTECT_CONTEXT__ |
2894 | 1999 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 2000 |
__UNPROTECT_CONTEXT__ |
154 | 2001 |
if (newobj == nil) { |
2002 |
break; |
|
2003 |
} |
|
1133 | 2004 |
__InstPtr(newobj)->o_class = self; |
369 | 2005 |
__qSTORE(newobj, self); |
2006 |
||
1133 | 2007 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2008 |
while (nInstVars--) |
2009 |
*op++ = nil; |
|
54 | 2010 |
#ifdef NEED_DOUBLE_ALIGN |
154 | 2011 |
/* |
2012 |
* care for double alignment |
|
2894 | 2013 |
* add filler. |
154 | 2014 |
*/ |
2894 | 2015 |
if ((INT)op & (__ALIGN__-1)) { |
154 | 2016 |
*op++ = nil; |
2017 |
} |
|
54 | 2018 |
#endif |
154 | 2019 |
dp = (double *)op; |
2020 |
while (nindexedinstvars--) |
|
2021 |
*dp++ = 0.0; |
|
2022 |
RETURN ( newobj ); |
|
2023 |
break; |
|
1 | 2024 |
|
154 | 2025 |
case WKPOINTERARRAY: |
2026 |
case POINTERARRAY: |
|
2027 |
nInstVars += nindexedinstvars; |
|
2028 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
834 | 2029 |
__PROTECT_CONTEXT__ |
2894 | 2030 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 2031 |
__UNPROTECT_CONTEXT__ |
154 | 2032 |
if (newobj == nil) { |
2033 |
break; |
|
2034 |
} |
|
1133 | 2035 |
__InstPtr(newobj)->o_class = self; |
369 | 2036 |
__qSTORE(newobj, self); |
2037 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2038 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 2039 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 2040 |
#else |
82 | 2041 |
# if !defined(NEGATIVE_ADDRESSES) |
154 | 2042 |
/* |
2043 |
* knowing that nil is 0 |
|
2044 |
*/ |
|
360 | 2045 |
#ifdef XXmips |
92 | 2046 |
# undef FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
2047 |
# undef FAST_ARRAY_MEMSET_LONGLONG_UNROLLED |
|
198 | 2048 |
/* seems to be slightly faster */ |
92 | 2049 |
# define FAST_ARRAY_MEMSET |
2050 |
#endif |
|
2051 |
#ifdef sparc |
|
2052 |
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
|
2053 |
#endif |
|
2054 |
||
91 | 2055 |
# if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED) |
1133 | 2056 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2057 |
if (nInstVars > 8) { |
2058 |
*op++ = nil; /* for alignment */ |
|
2059 |
nInstVars--; |
|
2060 |
while (nInstVars >= 8) { |
|
2061 |
*(double *)op = 0.0; |
|
2062 |
((double *)op)[1] = 0.0; |
|
2063 |
((double *)op)[2] = 0.0; |
|
2064 |
((double *)op)[3] = 0.0; |
|
2065 |
op += 8; |
|
2066 |
nInstVars -= 8; |
|
2067 |
} |
|
2068 |
} |
|
2069 |
while (nInstVars) { |
|
2070 |
*op++ = 0; |
|
2071 |
nInstVars--; |
|
2072 |
} |
|
82 | 2073 |
# else |
91 | 2074 |
# if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED) |
1133 | 2075 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2076 |
if (nInstVars > 8) { |
2077 |
*op++ = nil; /* for alignment */ |
|
2078 |
nInstVars--; |
|
2079 |
while (nInstVars >= 8) { |
|
2080 |
*(long long *)op = 0; |
|
2081 |
((long long *)op)[1] = 0; |
|
2082 |
((long long *)op)[2] = 0; |
|
2083 |
((long long *)op)[3] = 0; |
|
2084 |
op += 8; |
|
2085 |
nInstVars -= 8; |
|
2086 |
} |
|
2087 |
} |
|
2088 |
while (nInstVars) { |
|
2089 |
*op++ = 0; |
|
2090 |
nInstVars--; |
|
2091 |
} |
|
91 | 2092 |
# else |
2093 |
# if defined(FAST_ARRAY_MEMSET) |
|
1133 | 2094 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
91 | 2095 |
# else |
1133 | 2096 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2097 |
while (nInstVars--) |
2098 |
*op++ = nil; |
|
91 | 2099 |
# endif |
82 | 2100 |
# endif |
2101 |
# endif |
|
2102 |
# else |
|
1133 | 2103 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2104 |
while (nInstVars--) |
2105 |
*op++ = nil; |
|
1 | 2106 |
# endif |
2107 |
#endif |
|
154 | 2108 |
RETURN ( newobj ); |
2109 |
break; |
|
1 | 2110 |
|
154 | 2111 |
default: |
2112 |
/* |
|
2113 |
* new:n for non-variable classes only allowed if |
|
2114 |
* n == 0 |
|
2115 |
*/ |
|
2116 |
if (nindexedinstvars == 0) { |
|
2117 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
834 | 2118 |
__PROTECT_CONTEXT__ |
2894 | 2119 |
__qAlignedNew(newobj, instsize); /* OBJECT ALLOCATION */ |
834 | 2120 |
__UNPROTECT_CONTEXT__ |
154 | 2121 |
if (newobj == nil) { |
2122 |
break; |
|
2123 |
} |
|
1133 | 2124 |
__InstPtr(newobj)->o_class = self; |
369 | 2125 |
__qSTORE(newobj, self); |
2126 |
||
154 | 2127 |
if (nInstVars) { |
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2128 |
#if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4) |
1133 | 2129 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
1 | 2130 |
#else |
2131 |
# if defined(FAST_MEMSET) && ! defined(NEGATIVE_ADDRESSES) |
|
154 | 2132 |
/* |
2133 |
* knowing that nil is 0 |
|
2134 |
*/ |
|
1133 | 2135 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
1 | 2136 |
# else |
1133 | 2137 |
op = __InstPtr(newobj)->i_instvars; |
154 | 2138 |
do { |
2139 |
*op++ = nil; |
|
2140 |
} while (--nInstVars); |
|
1 | 2141 |
# endif |
2142 |
#endif |
|
154 | 2143 |
} |
2144 |
RETURN ( newobj ); |
|
2145 |
} |
|
2146 |
break; |
|
2147 |
} |
|
2148 |
} |
|
1 | 2149 |
} |
68 | 2150 |
%}. |
2151 |
" |
|
2152 |
arrive here if something went wrong ... |
|
2153 |
figure out what it was |
|
2154 |
" |
|
11 | 2155 |
|
1 | 2156 |
(anInteger isMemberOf:SmallInteger) ifFalse:[ |
154 | 2157 |
" |
2158 |
the argument is either not an integer, |
|
2159 |
or a LargeInteger (which means that its definitely too big) |
|
2160 |
" |
|
2161 |
self error:'argument to new: must be Integer'. |
|
2162 |
^ nil |
|
68 | 2163 |
]. |
2164 |
(anInteger < 0) ifTrue:[ |
|
154 | 2165 |
" |
2166 |
the argument is negative, |
|
2167 |
" |
|
2168 |
self error:'bad (negative) argument to new:'. |
|
2169 |
^ nil |
|
68 | 2170 |
]. |
2171 |
self isVariable ifFalse:[ |
|
154 | 2172 |
" |
2173 |
this class does not have any indexed instance variables |
|
2174 |
" |
|
2175 |
self error:'class has no indexed instvars - cannot create with new:'. |
|
2176 |
^ nil |
|
68 | 2177 |
]. |
2178 |
" |
|
2179 |
memory allocation failed. |
|
2180 |
When we arrive here, there was no memory, even after |
|
165 | 2181 |
a garbage collect. |
2182 |
This means, that the VM wanted to get some more memory from the |
|
2183 |
Operatingsystem, which was not kind enough to give it. |
|
2184 |
Bad luck - you should increase the swap space on your machine. |
|
68 | 2185 |
" |
127 | 2186 |
^ ObjectMemory allocationFailureSignal raise. |
11 | 2187 |
! |
2188 |
||
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2189 |
decodeFromLiteralArray:anArray |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2190 |
"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
|
2191 |
|
3237
5c3d09b9239d
use #new instead of #basicNew when decoding from a literal array;
Claus Gittinger <cg@exept.de>
parents:
3141
diff
changeset
|
2192 |
^ self new fromLiteralArrayEncoding:anArray. |
2370
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2193 |
|
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2194 |
" |
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2195 |
Rectangle |
3237
5c3d09b9239d
use #new instead of #basicNew when decoding from a literal array;
Claus Gittinger <cg@exept.de>
parents:
3141
diff
changeset
|
2196 |
decodeFromLiteralArray:#(Rectangle 10 10 100 100) |
2370
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2197 |
" |
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2198 |
|
3237
5c3d09b9239d
use #new instead of #basicNew when decoding from a literal array;
Claus Gittinger <cg@exept.de>
parents:
3141
diff
changeset
|
2199 |
"Modified: / 28.1.1998 / 17:40:30 / cg" |
2370
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2200 |
! |
694ebbc71f04
added #decodeFromLiteralArray: - ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
2201 |
|
620 | 2202 |
new |
2203 |
"return an instance of myself without indexed variables" |
|
2204 |
||
2205 |
^ self basicNew |
|
2206 |
! |
|
2207 |
||
2208 |
new:anInteger |
|
2209 |
"return an instance of myself with anInteger indexed variables" |
|
2210 |
||
2211 |
^ self basicNew:anInteger |
|
2212 |
! |
|
2213 |
||
2214 |
niceBasicNew:anInteger |
|
2215 |
"same as basicNew:anInteger, but tries to avoid long pauses |
|
2216 |
due to garbage collection. This method checks to see if |
|
2217 |
allocation is possible without a pause, and does a background |
|
2218 |
incremental garbage collect first if there is not enough memory |
|
2219 |
available at the moment for fast allocation. |
|
2220 |
This is useful in low-priority background processes which like to |
|
2221 |
avoid disturbing any higher priority foreground process while allocating |
|
2222 |
big amounts of memory. Of course, using this method only makes |
|
2223 |
sense for big or huge objects (say > 200k). |
|
2224 |
||
2225 |
EXPERIMENTAL: this is a non-standard interface and should only |
|
2226 |
be used for special applications. There is no guarantee, that this |
|
2227 |
method will be available in future ST/X releases." |
|
2228 |
||
2229 |
|size| |
|
2230 |
||
2231 |
size := self sizeOfInst:anInteger. |
|
2232 |
(ObjectMemory checkForFastNew:size) ifFalse:[ |
|
2233 |
" |
|
2234 |
incrementally collect garbage |
|
2235 |
" |
|
2236 |
ObjectMemory incrementalGC. |
|
2237 |
]. |
|
2238 |
^ self basicNew:anInteger |
|
2239 |
! |
|
2240 |
||
11 | 2241 |
readFrom:aStream |
43 | 2242 |
"read an objects printed representation from the argument, aStream |
2243 |
and return it. |
|
154 | 2244 |
The read object must be a kind of myself if its not, an error is raised. |
11 | 2245 |
This is the reverse operation to 'storeOn:'. |
43 | 2246 |
|
68 | 2247 |
WARNING: storeOn: does not handle circular references and multiple |
198 | 2248 |
references to the same object. |
2249 |
Use #storeBinary:/readBinaryFrom: for this." |
|
11 | 2250 |
|
345 | 2251 |
^ self readFrom:aStream onError:[self error:'expected: ' , self name] |
11 | 2252 |
|
91 | 2253 |
" |
2254 |
|s| |
|
11 | 2255 |
s := WriteStream on:String new. |
2256 |
#(1 2 3 4) storeOn:s. |
|
2257 |
Object readFrom:(ReadStream on:s contents) |
|
2258 |
" |
|
2259 |
! |
|
2260 |
||
198 | 2261 |
readFrom:aStream onError:exceptionBlock |
2262 |
"read an objects printed representation from the argument, aStream |
|
2263 |
and return it (i.e. the stream should contain some representation of |
|
2264 |
the object which was created using #storeOn:). |
|
2265 |
The read object must be a kind of myself if its not, the value of |
|
2266 |
exceptionBlock is returned. |
|
2267 |
To get any object, use 'Object readFrom:...', |
|
2268 |
To get any number, use 'Number readFrom:...' and so on. |
|
2269 |
This is the reverse operation to 'storeOn:'. |
|
2270 |
||
2271 |
WARNING: storeOn: does not handle circular references and multiple |
|
2272 |
references to the same object. |
|
2273 |
Use #storeBinary:/readBinaryFrom: for this." |
|
2274 |
||
2275 |
|newObject| |
|
2276 |
||
340 | 2277 |
ErrorSignal handle:[:ex | |
2278 |
ex return |
|
2279 |
] do:[ |
|
345 | 2280 |
newObject := self evaluatorClass evaluate:aStream. |
340 | 2281 |
]. |
198 | 2282 |
(newObject isKindOf:self) ifFalse:[^ exceptionBlock value]. |
2283 |
^ newObject |
|
2284 |
||
2285 |
" |
|
2286 |
|s| |
|
2287 |
s := WriteStream on:String new. |
|
2288 |
#(1 2 3 4) storeOn:s. |
|
1422 | 2289 |
Transcript showCR:( |
293 | 2290 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
2291 |
) |
|
198 | 2292 |
" |
2293 |
" |
|
2294 |
|s| |
|
2295 |
s := WriteStream on:String new. |
|
2296 |
#[1 2 3 4] storeOn:s. |
|
1422 | 2297 |
Transcript showCR:( |
293 | 2298 |
Array readFrom:(ReadStream on:s contents) onError:'not an Array' |
345 | 2299 |
) |
198 | 2300 |
" |
2301 |
! |
|
2302 |
||
11 | 2303 |
readFromString:aString |
275 | 2304 |
"create an object from its printed representation. |
2305 |
For most classes, the string is expected to be in a format created by |
|
2306 |
storeOn: or storeString; however, some (Time, Date) expect a user |
|
2307 |
readable string here. |
|
2308 |
See comments in Behavior>>readFromString:onError:, |
|
2309 |
Behavior>>readFrom: and Behavior>>readFrom:onError:" |
|
11 | 2310 |
|
345 | 2311 |
^ self readFromString:aString onError:[self error:'expected: ' , self name] |
91 | 2312 |
|
2313 |
" |
|
2314 |
Integer readFromString:'12345678901234567890' |
|
2315 |
Point readFromString:'1@2' |
|
345 | 2316 |
Point readFromString:'1' |
91 | 2317 |
" |
198 | 2318 |
! |
2319 |
||
2320 |
readFromString:aString onError:exceptionBlock |
|
275 | 2321 |
"create an object from its printed representation. |
2322 |
Here, the string is expected to be in a format created by |
|
2323 |
storeOn: or storeString; however, some classes (Time, Date) may redefine |
|
2324 |
it to expect a user readable string here. |
|
198 | 2325 |
See comments in Behavior>>readFrom: and Behavior>>readFrom:onError:" |
2326 |
||
2327 |
^ self readFrom:(ReadStream on:aString) onError:exceptionBlock |
|
2328 |
||
2329 |
" |
|
2330 |
Integer readFromString:'12345678901234567890' |
|
275 | 2331 |
Integer readFromString:'abc' |
2332 |
Integer readFromString:'abc' onError:0 |
|
198 | 2333 |
Point readFromString:'1@2' |
345 | 2334 |
Point readFromString:'0' |
275 | 2335 |
Point readFromString:'0' onError:[0@0] |
198 | 2336 |
" |
620 | 2337 |
! |
2338 |
||
2339 |
uninitializedNew |
|
2340 |
"create an instance of myself with uninitialized contents. |
|
2341 |
For all classes except ByteArray, this is the same as #basicNew." |
|
2342 |
||
2343 |
^ self basicNew |
|
2344 |
! |
|
2345 |
||
2346 |
uninitializedNew:anInteger |
|
2347 |
"create an instance of myself with uninitialized contents. |
|
2348 |
For all classes except ByteArray, this is the same as #basicNew:." |
|
2349 |
||
2350 |
^ self basicNew:anInteger |
|
1 | 2351 |
! ! |
2352 |
||
620 | 2353 |
!Behavior methodsFor:'private accessing'! |
2354 |
||
2355 |
flags:aNumber |
|
2356 |
"set the flags. |
|
2357 |
this method is for special uses only - there will be no recompilation |
|
2358 |
and no change record written here; |
|
2359 |
Do NOT use it." |
|
2360 |
||
2361 |
flags := aNumber |
|
2362 |
! |
|
2363 |
||
2364 |
instSize:aNumber |
|
2365 |
"set the instance size. |
|
2366 |
this method is for special uses only - there will be no recompilation |
|
2367 |
and no change record written here; |
|
2368 |
Do NOT use it." |
|
2369 |
||
2370 |
instSize := aNumber |
|
2371 |
! |
|
2372 |
||
2373 |
primAddSelector:newSelector withMethod:newMethod |
|
2374 |
"add the method given by 2nd argument under the selector given by |
|
2375 |
the 1st argument to the methodDictionary. |
|
2376 |
Does NOT flush any caches, does NOT write a change record. |
|
2377 |
||
2378 |
Do not use this in normal situations, strange behavior will be |
|
2379 |
the consequence. |
|
2380 |
I.e. executing obsolete methods, since the old method will still |
|
2381 |
be executed out of the caches." |
|
2382 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2383 |
|dict| |
620 | 2384 |
|
2385 |
(newSelector isMemberOf:Symbol) ifFalse:[ |
|
2386 |
self error:'invalid selector'. |
|
2387 |
^ false |
|
2388 |
]. |
|
2389 |
newMethod isNil ifTrue:[ |
|
2390 |
self error:'invalid method'. |
|
2391 |
^ false |
|
2392 |
]. |
|
2393 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2394 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2395 |
self setMethodDictionary:(dict at:newSelector putOrAppend:newMethod). |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2396 |
^ true. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2397 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2398 |
"Modified: 7.6.1996 / 14:48:45 / stefan" |
620 | 2399 |
! |
2400 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2401 |
setMethodDictionary:dict |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2402 |
"set the receivers method dictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2403 |
Convert dict to a MethodDictionary if necessary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2404 |
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
|
2405 |
after this call" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2406 |
|
2228 | 2407 |
"/ since the only thing the VM is prepared to deal with are |
2408 |
"/ proper methodDictionaries (it cannot do another message send, to |
|
2409 |
"/ find any methods ...), we convert it here if required. |
|
2410 |
"/ No other classes instances are allowed. |
|
2411 |
||
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2412 |
dict class ~~ MethodDictionary ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2413 |
methodDictionary := MethodDictionary withAll:dict. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2414 |
methodDictionary isNil ifTrue:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2415 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2416 |
"/ refuse to do this |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2417 |
"/ (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
|
2418 |
"/ 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
|
2419 |
"/ nil ...) |
2228 | 2420 |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2421 |
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
|
2422 |
^ self. |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2423 |
] |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2424 |
] ifFalse:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2425 |
methodDictionary := dict. |
620 | 2426 |
]. |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
2427 |
^ self. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2428 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2429 |
"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
|
2430 |
"Modified: 12.6.1996 / 13:58:55 / stefan" |
2228 | 2431 |
"Modified: 22.1.1997 / 21:10:48 / cg" |
620 | 2432 |
! |
2433 |
||
2434 |
setOtherSuperclasses:anArrayOfClasses |
|
2435 |
"EXPERIMENTAL: set the other superclasses of the receiver. |
|
2436 |
this method is for special uses only - there will be no recompilation |
|
2437 |
and no change record written here; |
|
2438 |
Do NOT use it." |
|
2439 |
||
2440 |
SubclassInfo := nil. |
|
2441 |
otherSuperclasses := anArrayOfClasses |
|
2442 |
! |
|
2443 |
||
2444 |
setSuperclass:aClass |
|
2445 |
"set the superclass of the receiver. |
|
2446 |
this method is for special uses only - there will be no recompilation |
|
2447 |
and no change record written here. Also, if the receiver class has |
|
2448 |
already been in use, future operation of the system is not guaranteed to |
|
2449 |
be correct, since no caches are flushed. |
|
2450 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2451 |
||
2438
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2452 |
|info| |
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2453 |
|
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2454 |
SubclassInfo notNil ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2455 |
"/ flush/update the subclass information |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2456 |
|
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2457 |
"/ 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
|
2458 |
(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
|
2459 |
info add:self |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2460 |
] ifFalse:[ |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2461 |
SubclassInfo := nil. "/ flush it |
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2462 |
] |
2438
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2463 |
]. |
620 | 2464 |
superclass := aClass |
2224 | 2465 |
|
2438
52ca8e0904a7
try to preserve subclassInfo in #setSuperClass.
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
2466 |
"Modified: 3.3.1997 / 13:27:00 / cg" |
620 | 2467 |
! |
2468 |
||
2224 | 2469 |
setSuperclass:aClass methodDictionary:d instSize:i flags:f |
620 | 2470 |
"set some inst vars. |
2471 |
this method is for special uses only - there will be no recompilation |
|
2472 |
and no change record is written here. Also, if the receiver class has |
|
2473 |
already been in use, future operation of the system is not guaranteed to |
|
2474 |
be correct, since no caches are flushed. |
|
2475 |
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)" |
|
2476 |
||
2224 | 2477 |
self setSuperclass:aClass. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2478 |
self setMethodDictionary:d. |
620 | 2479 |
instSize := i. |
2480 |
flags := f |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2481 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2482 |
"Created: 7.6.1996 / 08:41:20 / stefan" |
2224 | 2483 |
"Modified: 22.1.1997 / 18:42:12 / cg" |
620 | 2484 |
! ! |
2485 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2486 |
!Behavior methodsFor:'private helpers'! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2487 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2488 |
addAllClassVarNamesTo:aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2489 |
"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
|
2490 |
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
|
2491 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2492 |
|classvars| |
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 addAllClassVarNamesTo: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 |
(classvars := self classVariableString) notNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2498 |
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
|
2499 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2500 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2501 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2502 |
"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
|
2503 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2504 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2505 |
addAllInstVarNamesTo:aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2506 |
"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
|
2507 |
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
|
2508 |
Return aCollection." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2509 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2510 |
|superInsts instvars| |
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 |
(superclass notNil) ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2513 |
superclass addAllInstVarNamesTo:aCollection |
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2514 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2515 |
(instvars := self instanceVariableString) notNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2516 |
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
|
2517 |
] ifFalse:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2518 |
"/ 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
|
2519 |
"/ a system running without sourceInfo. Generate |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2520 |
"/ synthetic names. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2521 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2522 |
superclass isNil ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2523 |
superInsts := 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2524 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2525 |
superInsts := superclass instSize |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2526 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2527 |
aCollection addAll:((superInsts+1 to:self instSize) |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2528 |
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
|
2529 |
]. |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2530 |
^ aCollection |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2531 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2532 |
"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
|
2533 |
"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
|
2534 |
! ! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2535 |
|
620 | 2536 |
!Behavior methodsFor:'queries'! |
2537 |
||
2538 |
allClassVarNames |
|
2539 |
"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
|
2540 |
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
|
2541 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2542 |
^ self addAllClassVarNamesTo:(OrderedCollection new) |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2543 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2544 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2545 |
Float allClassVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2546 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2547 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2548 |
"Modified: 16.4.1996 / 18:01:00 / cg" |
620 | 2549 |
! |
2550 |
||
2551 |
allDerivedInstances |
|
2552 |
"return a collection of all instances of myself and |
|
2553 |
instances of all subclasses of myself. |
|
2554 |
This method is going to be removed for protocol compatibility with |
|
2555 |
other STs; use allSubInstances" |
|
2556 |
||
2823 | 2557 |
self obsoleteMethodWarning:'use #allSubInstances'. |
620 | 2558 |
^ self allSubInstances |
2823 | 2559 |
|
2560 |
"Modified: 31.7.1997 / 23:04:59 / cg" |
|
620 | 2561 |
! |
2562 |
||
2563 |
allInstVarNames |
|
2564 |
"return a collection of all the instance variable name-strings |
|
2565 |
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
|
2566 |
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
|
2567 |
the instVarAt:-index)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2568 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2569 |
^ self addAllInstVarNamesTo:(OrderedCollection new) |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2570 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2571 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2572 |
Dictionary instVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2573 |
Dictionary allInstVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2574 |
" |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2575 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2576 |
"Modified: 16.4.1996 / 18:03:55 / cg" |
620 | 2577 |
! |
2578 |
||
2579 |
allInstances |
|
2580 |
"return a collection of all my instances" |
|
2581 |
||
2582 |
"Read the documentation on why there seem to be no |
|
2583 |
instances of SmallInteger and UndefinedObject" |
|
2584 |
||
2585 |
|coll| |
|
2586 |
||
2587 |
coll := OrderedCollection new:100. |
|
2588 |
self allInstancesDo:[:anObject | |
|
2589 |
coll add:anObject |
|
2590 |
]. |
|
2591 |
^ coll |
|
2592 |
||
2593 |
" |
|
2594 |
ScrollBar allInstances |
|
2595 |
" |
|
2596 |
! |
|
2597 |
||
2053 | 2598 |
allSelectors |
2599 |
"return a collection of all selectors understood by the receiver; |
|
2600 |
this includes my selectors and all superclass selectors |
|
2601 |
(i.e. the receivers full protocol)" |
|
2602 |
||
2603 |
superclass notNil ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2604 |
^ superclass allSelectors addAll:(self selectors); yourself. |
2053 | 2605 |
]. |
2606 |
^ self selectors asIdentitySet |
|
2607 |
||
2608 |
" |
|
2609 |
Point allSelectors |
|
2610 |
View allSelectors |
|
2611 |
Array allSelectors |
|
2612 |
" |
|
2613 |
||
2614 |
! |
|
2615 |
||
620 | 2616 |
allSubInstances |
2617 |
"return a collection of all instances of myself and |
|
2618 |
instances of all subclasses of myself." |
|
2619 |
||
2620 |
|coll| |
|
2621 |
||
2622 |
coll := OrderedCollection new:100. |
|
2623 |
self allSubInstancesDo:[:anObject | |
|
2624 |
(anObject isKindOf:self) ifTrue:[ |
|
2625 |
coll add:anObject |
|
2626 |
] |
|
2627 |
]. |
|
2628 |
^ coll |
|
2629 |
||
2630 |
" |
|
2631 |
View allSubInstances |
|
2632 |
" |
|
2633 |
! |
|
2634 |
||
2635 |
allSubclasses |
|
2636 |
"return a collection of all subclasses (direct AND indirect) of |
|
2637 |
the receiver. There will be no specific order, in which entries |
|
2638 |
are returned." |
|
2639 |
||
2640 |
|newColl| |
|
2641 |
||
2642 |
newColl := OrderedCollection new. |
|
2643 |
self allSubclassesDo:[:aClass | |
|
2644 |
newColl add:aClass |
|
2645 |
]. |
|
2646 |
^ newColl |
|
2647 |
||
2648 |
" |
|
2649 |
Collection allSubclasses |
|
2650 |
" |
|
2651 |
! |
|
2652 |
||
2653 |
allSubclassesInOrder |
|
2654 |
"return a collection of all subclasses (direct AND indirect) of |
|
2655 |
the receiver. Higher level subclasses will come before lower ones." |
|
2656 |
||
2657 |
|newColl| |
|
2658 |
||
2659 |
newColl := OrderedCollection new. |
|
2660 |
self allSubclassesInOrderDo:[:aClass | |
|
2661 |
newColl add:aClass |
|
2662 |
]. |
|
2663 |
^ newColl |
|
2664 |
||
2665 |
" |
|
2666 |
Collection allSubclassesInOrder |
|
2667 |
" |
|
2668 |
! |
|
2669 |
||
2670 |
allSuperclasses |
|
2671 |
"return a collection of the receivers accumulated superclasses" |
|
2672 |
||
2673 |
|aCollection theSuperClass| |
|
2674 |
||
2675 |
theSuperClass := superclass. |
|
2676 |
theSuperClass notNil ifTrue:[ |
|
2677 |
aCollection := OrderedCollection new. |
|
2678 |
[theSuperClass notNil] whileTrue:[ |
|
2679 |
aCollection add:theSuperClass. |
|
2680 |
theSuperClass := theSuperClass superclass |
|
2681 |
] |
|
2682 |
]. |
|
2683 |
^ aCollection |
|
2684 |
||
2685 |
" |
|
2686 |
String allSuperclasses |
|
2687 |
" |
|
2688 |
! |
|
2689 |
||
2690 |
cachedLookupMethodFor:aSelector |
|
2691 |
"return the method, which would be executed if aSelector was sent to |
|
2692 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
2693 |
and all of its superclasses are searched for aSelector. |
|
2694 |
Return the method, or nil if instances do not understand aSelector. |
|
2695 |
This interface provides exactly the same information as #lookupMethodFor:, |
|
2696 |
but uses the lookup-cache in the VM for faster search. |
|
2697 |
However, keep in mind, that doing a lookup through the cache also adds new |
|
2698 |
entries and can thus slow down the system by polluting the cache with |
|
2699 |
irrelevant entries. (do NOT loop over all objects calling this method). |
|
2700 |
Does NOT (currently) handle MI" |
|
2701 |
||
2702 |
%{ /* NOCONTEXT */ |
|
2201
db0f6e86c8bb
COMMA_SENDER arg is no longer supported / needed
Claus Gittinger <cg@exept.de>
parents:
2148
diff
changeset
|
2703 |
RETURN ( __lookup(self, aSelector) ); |
620 | 2704 |
%} |
2705 |
||
2706 |
" |
|
2707 |
String cachedLookupMethodFor:#= |
|
2708 |
String cachedLookupMethodFor:#asOrderedCollection |
|
2709 |
" |
|
2710 |
! |
|
2711 |
||
2712 |
canBeSubclassed |
|
2713 |
"return true, if its allowed to create subclasses of the receiver. |
|
2714 |
This method is redefined in SmallInteger and UndefinedObject, since |
|
2715 |
instances are detected by their pointer-fields, i.e. they do not have |
|
2716 |
a class entry (you dont have to understand this :-)" |
|
10 | 2717 |
|
2718 |
^ true |
|
2719 |
! |
|
2720 |
||
620 | 2721 |
canUnderstand:aSelector |
2722 |
"return true, if the receiver or one of its superclasses implements aSelector. |
|
2723 |
(i.e. true if my instances understand aSelector)" |
|
2724 |
||
2725 |
^ (self lookupMethodFor:aSelector) notNil |
|
2726 |
||
2727 |
" |
|
2728 |
True canUnderstand:#ifTrue: |
|
2729 |
True canUnderstand:#== |
|
2730 |
True canUnderstand:#do: |
|
2731 |
" |
|
91 | 2732 |
! |
2733 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2734 |
category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2735 |
"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
|
2736 |
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
|
2737 |
(only ClassDescriptions do)." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2738 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2739 |
^ nil |
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 |
Point category |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2743 |
Behavior new category |
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 |
|
3044 | 2747 |
classPool |
2748 |
^ IdentityDictionary new |
|
2749 |
||
2750 |
"Modified: 17.10.1997 / 12:07:29 / cg" |
|
2751 |
! |
|
2752 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2753 |
classVarNames |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2754 |
"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
|
2755 |
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
|
2756 |
(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
|
2757 |
(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
|
2758 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2759 |
^ #() |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2760 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2761 |
"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
|
2762 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2763 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2764 |
classVariableString |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2765 |
"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
|
2766 |
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
|
2767 |
(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
|
2768 |
(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
|
2769 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2770 |
^ '' |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2771 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2772 |
"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
|
2773 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2774 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2775 |
comment |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2776 |
"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
|
2777 |
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
|
2778 |
(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
|
2779 |
(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
|
2780 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2781 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2782 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2783 |
"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
|
2784 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
2785 |
|
620 | 2786 |
compiledMethodAt:aSelector |
2787 |
"return the method for given selector aSelector or nil. |
|
2788 |
Only methods in the receiver - not in the superclass chain are tested." |
|
2789 |
||
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2790 |
^ self compiledMethodAt:aSelector ifAbsent:nil |
620 | 2791 |
|
293 | 2792 |
" |
620 | 2793 |
Object compiledMethodAt:#== |
2794 |
(Object compiledMethodAt:#==) category |
|
293 | 2795 |
" |
1088 | 2796 |
|
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2797 |
"Modified: / 7.6.1996 / 14:43:32 / stefan" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2798 |
"Modified: / 27.10.1997 / 20:18:55 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2799 |
! |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2800 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2801 |
compiledMethodAt:aSelector ifAbsent:exceptionValue |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2802 |
"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
|
2803 |
of exceptionValue if not present. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2804 |
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
|
2805 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2806 |
|dict| |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2807 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2808 |
dict := self methodDictionary. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2809 |
dict isNil ifTrue:[ |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2810 |
('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2811 |
^ exceptionValue value |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2812 |
]. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2813 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2814 |
^ dict at:aSelector ifAbsent:exceptionValue |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2815 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2816 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2817 |
Object compiledMethodAt:#== |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2818 |
(Object compiledMethodAt:#==) category |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2819 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2820 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2821 |
"Modified: / 7.6.1996 / 14:43:32 / stefan" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2822 |
"Modified: / 10.1.1997 / 17:27:21 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
2823 |
"Created: / 27.10.1997 / 20:18:28 / cg" |
620 | 2824 |
! |
2825 |
||
2826 |
containsMethod:aMethod |
|
2827 |
"Return true, if the argument, aMethod is a method of myself" |
|
2828 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2829 |
|dict| |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2830 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2831 |
dict := self methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2832 |
dict isNil ifTrue:[^ false]. "degenerated class" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2833 |
^ (dict keyAtValue:aMethod ifAbsent:[0]) ~~ 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2834 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2835 |
"Modified: 12.6.1996 / 13:33:53 / stefan" |
620 | 2836 |
! |
2837 |
||
2436 | 2838 |
definitionSelector |
2839 |
"return the selector with which I was (can be) defined in my superclass" |
|
2840 |
||
2841 |
self isVariable ifFalse:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2842 |
^ #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2843 |
]. |
2844 |
self isBytes ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2845 |
^ #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2846 |
]. |
2847 |
self isLongs ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2848 |
^ #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2849 |
]. |
2850 |
self isFloats ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2851 |
^ #'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2852 |
]. |
2853 |
self isDoubles ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2854 |
^ #'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2855 |
]. |
2856 |
self isWords ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2857 |
^ #'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2858 |
]. |
2859 |
self isSignedWords ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2860 |
^ #'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2861 |
]. |
2862 |
self isSignedLongs ifTrue:[ |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
2863 |
^ #'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
2436 | 2864 |
]. |
2865 |
^ #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:' |
|
2866 |
||
2867 |
" |
|
2868 |
Object definitionSelector |
|
2869 |
Array definitionSelector |
|
2870 |
ByteArray definitionSelector |
|
2871 |
FloatArray definitionSelector |
|
2872 |
" |
|
2873 |
||
2874 |
"Modified: 3.3.1997 / 11:50:37 / cg" |
|
2875 |
! |
|
2876 |
||
2713 | 2877 |
definitionSelectorPrivate |
2878 |
"return the selector with which I was (can be) defined in my superclass |
|
2879 |
as a private class" |
|
2880 |
||
2881 |
self isVariable ifFalse:[ |
|
2882 |
^ #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2883 |
]. |
|
2884 |
self isBytes ifTrue:[ |
|
2885 |
^ #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2886 |
]. |
|
2887 |
self isLongs ifTrue:[ |
|
2888 |
^ #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2889 |
]. |
|
2890 |
self isFloats ifTrue:[ |
|
2891 |
^ #'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2892 |
]. |
|
2893 |
self isDoubles ifTrue:[ |
|
2894 |
^ #'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2895 |
]. |
|
2896 |
self isWords ifTrue:[ |
|
2897 |
^ #'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2898 |
]. |
|
2899 |
self isSignedWords ifTrue:[ |
|
2900 |
^ #'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2901 |
]. |
|
2902 |
self isSignedLongs ifTrue:[ |
|
2903 |
^ #'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2904 |
]. |
|
2905 |
^ #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:' |
|
2906 |
||
2907 |
" |
|
2908 |
Array definitionSelector |
|
2909 |
Array definitionSelectorPrivate |
|
2910 |
" |
|
2911 |
||
2912 |
"Modified: 23.6.1997 / 10:45:57 / cg" |
|
2913 |
! |
|
2914 |
||
620 | 2915 |
derivedInstanceCount |
2916 |
"return the number of instances of myself and of subclasses" |
|
2917 |
||
2918 |
|count| |
|
2919 |
||
2920 |
count := 0. |
|
2921 |
ObjectMemory allObjectsDo:[:anObject | |
|
2922 |
(anObject isKindOf:self) ifTrue:[ |
|
2923 |
count := count + 1 |
|
2924 |
] |
|
2925 |
]. |
|
2926 |
^ count |
|
2927 |
||
293 | 2928 |
" |
620 | 2929 |
View derivedInstanceCount |
2930 |
SequenceableCollection derivedInstanceCount |
|
983 | 2931 |
Object derivedInstanceCount |
2932 |
" |
|
2933 |
! |
|
2934 |
||
2935 |
hasDerivedInstances |
|
2936 |
"return true, if there are any instances of myself or of any subclass" |
|
2937 |
||
2938 |
"Read the documentation on why there seem to be no |
|
2939 |
instances of SmallInteger and UndefinedObject" |
|
2940 |
||
2941 |
ObjectMemory allObjectsDo:[:anObject | |
|
2942 |
(anObject isKindOf:self) ifTrue:[ |
|
2943 |
^ true |
|
2944 |
] |
|
2945 |
]. |
|
2946 |
^ false |
|
2947 |
||
2948 |
" |
|
2949 |
Object hasDerivedInstances - certainly true |
|
2950 |
SharedQueue hasDerivedInstances |
|
293 | 2951 |
" |
620 | 2952 |
! |
2953 |
||
2674
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2954 |
hasImmediateInstances |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2955 |
"return true if this class has immediate instances. |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2956 |
Redefined in classes which have." |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2957 |
|
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2958 |
^ false |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2959 |
|
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2960 |
"Created: 3.6.1997 / 12:01:05 / cg" |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2961 |
! |
5278213b500c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2666
diff
changeset
|
2962 |
|
620 | 2963 |
hasInstances |
2964 |
"return true, if there are any instances of myself" |
|
2965 |
||
2966 |
"Read the documentation on why there seem to be no |
|
2967 |
instances of SmallInteger and UndefinedObject" |
|
2968 |
||
2969 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
2970 |
"/ (anObject class == self) ifTrue:[ |
|
2971 |
"/ ^ true |
|
2972 |
"/ ] |
|
2973 |
"/ ]. |
|
983 | 2974 |
|
620 | 2975 |
ObjectMemory allInstancesOf:self do:[:anObject | |
983 | 2976 |
^ true |
620 | 2977 |
]. |
2978 |
^ false |
|
2979 |
||
293 | 2980 |
" |
620 | 2981 |
Object hasInstances |
2982 |
SequenceableCollection hasInstances |
|
2983 |
Float hasInstances |
|
2984 |
SmallInteger hasInstances |
|
293 | 2985 |
" |
620 | 2986 |
! |
2987 |
||
2988 |
hasMethods |
|
2989 |
"return true, if there are any (local) methods in this class" |
|
2990 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2991 |
^ (self methodDictionary size ~~ 0) |
620 | 2992 |
|
293 | 2993 |
" |
620 | 2994 |
True hasMethods |
2995 |
True class hasMethods |
|
2996 |
" |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2997 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
2998 |
"Modified: 7.6.1996 / 15:43:09 / stefan" |
620 | 2999 |
! |
3000 |
||
3001 |
hasMultipleSuperclasses |
|
3002 |
"Return true, if this class inherits from other classes |
|
3003 |
(beside its primary superclass). |
|
3004 |
This method is a preparation for a future multiple inheritance extension |
|
3005 |
- currently it is not supported by the VM" |
|
3006 |
||
3007 |
^ otherSuperclasses notNil |
|
3008 |
! |
|
3009 |
||
3010 |
implements:aSelector |
|
3011 |
"return true, if the receiver implements aSelector. |
|
3012 |
(i.e. implemented in THIS class - NOT in a superclass). |
|
983 | 3013 |
|
3014 |
Caveat: |
|
3015 |
This simply checks for the selector being present in the classes |
|
3016 |
selector table - therefore, it does not care for ignoredMethods. |
|
3017 |
(but: you should not use this method for protocol-testing, anyway). |
|
3018 |
||
3019 |
Hint: |
|
3020 |
Dont use this method to check if someone responds to a message - |
|
3021 |
use #canUnderstand: on the class or #respondsTo: on the instance |
|
3022 |
to do this." |
|
3023 |
||
3024 |
^ self includesSelector:aSelector |
|
620 | 3025 |
|
3026 |
" |
|
983 | 3027 |
notice: this is class protocol |
3028 |
||
3029 |
True implements:#ifTrue: |
|
3030 |
True implements:#== |
|
3031 |
||
3032 |
notice: this is instance protocol |
|
3033 |
||
3034 |
true respondsTo:#ifTrue: |
|
3035 |
true respondsTo:#== |
|
3036 |
||
3037 |
notice: this is class protocol |
|
3038 |
||
3039 |
True canUnderstand:#ifTrue: |
|
3040 |
True canUnderstand:#== |
|
620 | 3041 |
" |
983 | 3042 |
|
3043 |
"Modified: 10.2.1996 / 13:15:56 / cg" |
|
620 | 3044 |
! |
3045 |
||
2698
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3046 |
includesBehavior:aClass |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3047 |
"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
|
3048 |
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
|
3049 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3050 |
^ (self == aClass) or:[self isSubclassOf:aClass] |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3051 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3052 |
" |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3053 |
True includesBehavior:Object |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3054 |
True includesBehavior:Boolean |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3055 |
True includesBehavior:True |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3056 |
True includesBehavior:False |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3057 |
" |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3058 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3059 |
"Modified: 19.6.1997 / 18:14:35 / cg" |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3060 |
! |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3061 |
|
620 | 3062 |
includesSelector:aSelector |
1494
dab70fc90ebc
Remove old methodArray and selectorArray stuff (use MethodDictionary only).
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
3063 |
"return true, if the methodDictionary of THIS class includes |
983 | 3064 |
a method for aSelector. |
3065 |
(i.e. if aSelector is implemented in THIS class - NOT in a superclass). |
|
3066 |
||
3067 |
Hint: |
|
3068 |
Dont use this method to check if someone responds to a message - |
|
3069 |
use #canUnderstand: on the class or #respondsTo: on the instance |
|
3070 |
to do this." |
|
3071 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3072 |
^ (self methodDictionary at:aSelector ifAbsent:[0]) ~~ 0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3073 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3074 |
" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3075 |
Object includesSelector:#== |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3076 |
Object includesSelector:#murks |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3077 |
" |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3078 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3079 |
"Modified: 7.6.1996 / 14:27:24 / stefan" |
620 | 3080 |
! |
3081 |
||
3082 |
inheritsFrom:aClass |
|
2698
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3083 |
"return true, if the receiver inherits methods from aClass; |
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3084 |
i.e. if aClass is on the receivers superclass chain." |
620 | 3085 |
|
3086 |
^ self isSubclassOf:aClass |
|
3087 |
||
3088 |
" |
|
3089 |
True inheritsFrom:Object |
|
3090 |
LinkedList inheritsFrom:Array |
|
356 | 3091 |
" |
2698
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3092 |
|
26abb8941250
added #includesBehavior for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2674
diff
changeset
|
3093 |
"Modified: 19.6.1997 / 18:13:21 / cg" |
357 | 3094 |
! |
3095 |
||
620 | 3096 |
instanceCount |
3097 |
"return the number of instances of myself." |
|
3098 |
||
3099 |
"Read the documentation on why there seem to be no |
|
3100 |
instances of SmallInteger and UndefinedObject" |
|
3101 |
||
3102 |
|count| |
|
3103 |
||
3104 |
count := 0. |
|
3105 |
"/ ObjectMemory allObjectsDo:[:anObject | |
|
3106 |
"/ (anObject class == self) ifTrue:[ |
|
3107 |
"/ count := count + 1 |
|
3108 |
"/ ] |
|
3109 |
"/ ]. |
|
983 | 3110 |
|
620 | 3111 |
ObjectMemory allInstancesOf:self do:[:anObject | |
3112 |
count := count + 1 |
|
3113 |
]. |
|
3114 |
^ count |
|
3115 |
||
3116 |
" |
|
3117 |
View instanceCount |
|
3118 |
Object instanceCount |
|
3119 |
Float instanceCount |
|
3120 |
SequenceableCollection instanceCount |
|
3121 |
SmallInteger instanceCount .... mhmh - hear, hear |
|
3122 |
" |
|
3123 |
! |
|
3124 |
||
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3125 |
instanceVariableString |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3126 |
"return a string with dummy names here - typically, your |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3127 |
objects are instances of Class, not Behavior." |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3128 |
|
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3129 |
|s superInsts n "{Class: SmallInteger }"| |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3130 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3131 |
s := ''. |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3132 |
superclass isNil ifTrue:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3133 |
superInsts := 0 |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3134 |
] ifFalse:[ |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3135 |
superInsts := superclass instSize |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3136 |
]. |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3137 |
n := self instSize. |
1449
19df9cda3d87
instanceVariableString must not return instance variables of superclasses.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3138 |
superInsts+1 to:n do:[:i | |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3139 |
s size == 0 ifFalse:[s := s , ' ']. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3140 |
s := s , 'instvar' , i printString |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3141 |
]. |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3142 |
^ s |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3143 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3144 |
" |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3145 |
Behavior new instanceVariableString |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3146 |
" |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3147 |
|
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3148 |
"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
|
3149 |
"Modified: 3.6.1996 / 16:03:33 / stefan" |
1340
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3150 |
! |
2e3930570745
dummy #instanceVariableString added
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
3151 |
|
620 | 3152 |
isBehavior |
3153 |
"return true, if the receiver is describing another objects behavior, |
|
3154 |
i.e. is a class. Defined to avoid the need to use isKindOf:" |
|
3155 |
||
3156 |
^ true |
|
3157 |
||
3158 |
" |
|
3159 |
True isBehavior |
|
3160 |
true isBehavior |
|
3161 |
" |
|
3162 |
! |
|
3163 |
||
3164 |
isBits |
|
3165 |
"return true, if instances have indexed byte or short instance variables. |
|
3166 |
Ignore long, float and double arrays, since ST-80 code using isBits are probably |
|
3167 |
not prepared to handle them correctly." |
|
92 | 3168 |
|
3169 |
%{ /* NOCONTEXT */ |
|
620 | 3170 |
|
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3171 |
REGISTER int what; |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3172 |
|
1133 | 3173 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3174 |
RETURN (( (what == __MASKSMALLINT(BYTEARRAY)) |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3175 |
|| (what == __MASKSMALLINT(WORDARRAY))) ? true : false ); |
620 | 3176 |
%} |
3177 |
! |
|
3178 |
||
1832 | 3179 |
isBuiltInClass |
3180 |
"return true if this class is known by the run-time-system. |
|
3181 |
Here, false is returned as default. |
|
3182 |
Notice, this is instance protocol, which means that any class |
|
3183 |
other than those special ones) are non-builtIn by default." |
|
3184 |
||
3185 |
^ false |
|
3186 |
||
3187 |
"Modified: 23.4.1996 / 15:55:52 / cg" |
|
3188 |
"Created: 28.10.1996 / 15:10:02 / cg" |
|
3189 |
! |
|
3190 |
||
620 | 3191 |
isBytes |
3192 |
"return true, if instances have indexed byte instance variables" |
|
3193 |
||
3194 |
"this could also be defined as: |
|
3195 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagBytes |
|
3196 |
" |
|
3197 |
%{ /* NOCONTEXT */ |
|
3198 |
||
1133 | 3199 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(BYTEARRAY)) ? true : false ); |
68 | 3200 |
%} |
620 | 3201 |
! |
3202 |
||
3203 |
isDoubles |
|
3204 |
"return true, if instances have indexed double instance variables" |
|
3205 |
||
3206 |
"this could also be defined as: |
|
3207 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagDoubles |
|
3208 |
" |
|
3209 |
%{ /* NOCONTEXT */ |
|
3210 |
||
1133 | 3211 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(DOUBLEARRAY)) ? true : false ); |
620 | 3212 |
%} |
3213 |
! |
|
3214 |
||
3215 |
isFixed |
|
3216 |
"return true, if instances do not have indexed instance variables" |
|
3217 |
||
3218 |
"this could also be defined as: |
|
3219 |
^ self isVariable not |
|
3220 |
" |
|
3221 |
||
3222 |
%{ /* NOCONTEXT */ |
|
3223 |
||
1133 | 3224 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? false : true ); |
620 | 3225 |
%} |
3226 |
! |
|
3227 |
||
3228 |
isFloats |
|
3229 |
"return true, if instances have indexed float instance variables" |
|
3230 |
||
3231 |
"this could also be defined as: |
|
3232 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagFloats |
|
3233 |
" |
|
3234 |
%{ /* NOCONTEXT */ |
|
3235 |
||
1133 | 3236 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(FLOATARRAY)) ? true : false ); |
620 | 3237 |
%} |
91 | 3238 |
! |
3239 |
||
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3240 |
isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3241 |
"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
|
3242 |
|
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3243 |
%{ /* NOCONTEXT */ |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3244 |
|
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3245 |
int what; |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3246 |
|
1133 | 3247 |
what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK); |
642
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3248 |
RETURN (( (what == __MASKSMALLINT(FLOATARRAY)) |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3249 |
|| (what == __MASKSMALLINT(DOUBLEARRAY))) ? true : false ); |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3250 |
%} |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3251 |
" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3252 |
(Object new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3253 |
(Point new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3254 |
(Array new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3255 |
(ByteArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3256 |
(FloatArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3257 |
(DoubleArray new) class isFloatsOrDoubles |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3258 |
" |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3259 |
! |
dbf407bedf64
slighly faster isXXX methods; added isFloatsOrDoubles
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
3260 |
|
2455 | 3261 |
isJavaClass |
3262 |
"return true, if the receiver is a java class. |
|
3263 |
Java class support is not yet released to the public." |
|
3264 |
||
3265 |
^ false |
|
3266 |
||
3267 |
"Created: 17.3.1997 / 16:23:59 / cg" |
|
3268 |
! |
|
3269 |
||
620 | 3270 |
isLongs |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3271 |
"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
|
3272 |
|
620 | 3273 |
%{ /* NOCONTEXT */ |
3274 |
||
1133 | 3275 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(LONGARRAY)) ? true : false ); |
620 | 3276 |
%} |
356 | 3277 |
! |
3278 |
||
620 | 3279 |
isPointers |
3280 |
"return true, if instances have pointer instance variables |
|
3281 |
i.e. are either non-indexed or have indexed pointer variables" |
|
3282 |
||
3283 |
"QUESTION: should we ignore WeakPointers ?" |
|
3284 |
||
3285 |
%{ /* NOCONTEXT */ |
|
3286 |
||
3287 |
REGISTER int flags; |
|
3288 |
||
1133 | 3289 |
flags = __intVal(__INST(flags)) & ARRAYMASK; |
620 | 3290 |
switch (flags) { |
3291 |
default: |
|
3292 |
/* normal objects */ |
|
3293 |
RETURN ( true ); |
|
3294 |
||
3295 |
case BYTEARRAY: |
|
3296 |
case WORDARRAY: |
|
3297 |
case LONGARRAY: |
|
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3298 |
case SWORDARRAY: |
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3299 |
case SLONGARRAY: |
620 | 3300 |
case FLOATARRAY: |
3301 |
case DOUBLEARRAY: |
|
3302 |
RETURN (false ); |
|
3303 |
||
3304 |
case WKPOINTERARRAY: |
|
3305 |
/* what about those ? */ |
|
3306 |
RETURN (true ); |
|
3307 |
} |
|
3308 |
%} |
|
3309 |
! |
|
3310 |
||
1722 | 3311 |
isPrivate |
3312 |
"return true, if the receiver is some private class" |
|
3313 |
||
3314 |
^ self owningClass notNil |
|
3315 |
||
3316 |
"Modified: 12.10.1996 / 20:11:05 / cg" |
|
3317 |
! |
|
3318 |
||
1634 | 3319 |
isSignedLongs |
3320 |
"return true, if instances have indexed signed long instance variables (4 byte ints)" |
|
3321 |
||
3322 |
%{ /* NOCONTEXT */ |
|
3323 |
||
3324 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SLONGARRAY)) ? true : false ); |
|
3325 |
%} |
|
3326 |
! |
|
3327 |
||
3328 |
isSignedWords |
|
3329 |
"return true, if instances have indexed signed short instance variables" |
|
3330 |
||
3331 |
%{ /* NOCONTEXT */ |
|
3332 |
||
3333 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(SWORDARRAY)) ? true : false ); |
|
3334 |
%} |
|
3335 |
! |
|
3336 |
||
620 | 3337 |
isSubclassOf:aClass |
3338 |
"return true, if I am a subclass of the argument, aClass" |
|
3339 |
||
3340 |
|theClass| |
|
3341 |
||
3342 |
theClass := superclass. |
|
3343 |
[theClass notNil] whileTrue:[ |
|
3344 |
(theClass == aClass) ifTrue:[^ true]. |
|
3345 |
%{ |
|
3346 |
if (__isBehaviorLike(theClass)) { |
|
3347 |
theClass = __ClassInstPtr(theClass)->c_superclass; |
|
3348 |
} else { |
|
3349 |
theClass = nil; |
|
3350 |
} |
|
3351 |
%}. |
|
3352 |
"/ theClass := theClass superclass. |
|
3353 |
]. |
|
3354 |
^ false |
|
356 | 3355 |
|
3356 |
" |
|
620 | 3357 |
String isSubclassOf:Collection |
3358 |
LinkedList isSubclassOf:Array |
|
3359 |
1 isSubclassOf:Number <- will fail since 1 is no class |
|
3360 |
" |
|
3361 |
! |
|
3362 |
||
3363 |
isVariable |
|
3364 |
"return true, if instances have indexed instance variables" |
|
3365 |
||
3366 |
"this could also be defined as: |
|
3367 |
^ (flags bitAnd:(Behavior maskIndexType)) ~~ 0 |
|
3368 |
" |
|
3369 |
||
3370 |
%{ /* NOCONTEXT */ |
|
3371 |
||
1133 | 3372 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? true : false ); |
620 | 3373 |
%} |
3374 |
! |
|
3375 |
||
3376 |
isWords |
|
3377 |
"return true, if instances have indexed short instance variables" |
|
3378 |
||
3379 |
"this could also be defined as: |
|
3380 |
^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagWords |
|
3381 |
" |
|
3382 |
%{ /* NOCONTEXT */ |
|
3383 |
||
1133 | 3384 |
RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(WORDARRAY)) ? true : false ); |
620 | 3385 |
%} |
3386 |
! |
|
3387 |
||
3388 |
lookupMethodFor:aSelector |
|
3389 |
"return the method, which would be executed if aSelector was sent to |
|
3390 |
an instance of the receiver. I.e. the selector arrays of the receiver |
|
3391 |
and all of its superclasses are searched for aSelector. |
|
3392 |
Return the method, or nil if instances do not understand aSelector. |
|
3393 |
EXPERIMENTAL: take care of multiple superclasses." |
|
3394 |
||
3395 |
|m cls| |
|
3396 |
||
3397 |
cls := self. |
|
3398 |
[cls notNil] whileTrue:[ |
|
3399 |
m := cls compiledMethodAt:aSelector. |
|
3400 |
m notNil ifTrue:[^ m]. |
|
3401 |
cls hasMultipleSuperclasses ifTrue:[ |
|
3402 |
cls superclasses do:[:aSuperClass | |
|
3403 |
m := aSuperClass lookupMethodFor:aSelector. |
|
3404 |
m notNil ifTrue:[^ m]. |
|
3405 |
]. |
|
3406 |
^ nil |
|
3407 |
] ifFalse:[ |
|
3408 |
cls := cls superclass |
|
3409 |
] |
|
3410 |
]. |
|
3411 |
^ nil |
|
3412 |
! |
|
3413 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3414 |
name |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3415 |
"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
|
3416 |
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
|
3417 |
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
|
3418 |
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
|
3419 |
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
|
3420 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3421 |
^ 'someBehavior' |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3422 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3423 |
|
1760 | 3424 |
owningClass |
3425 |
"return my owning class - nil if I am a public class" |
|
3426 |
||
1918 | 3427 |
"/ this information is in the metaclass ... |
3428 |
||
1760 | 3429 |
^ self class owningClass |
3430 |
||
3431 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
1918 | 3432 |
"Modified: 7.11.1996 / 13:49:28 / cg" |
1760 | 3433 |
! |
3434 |
||
620 | 3435 |
selectorAtMethod:aMethod |
3436 |
"Return the selector for given method aMethod." |
|
3437 |
||
3438 |
^ self selectorAtMethod:aMethod ifAbsent:[nil] |
|
3439 |
||
3440 |
" |
|
3441 |
|m| |
|
3442 |
||
3443 |
m := Object compiledMethodAt:#copy. |
|
3444 |
Fraction selectorAtMethod:m. |
|
3445 |
" |
|
3446 |
" |
|
3447 |
|m| |
|
3448 |
||
3449 |
m := Object compiledMethodAt:#copy. |
|
3450 |
Object selectorAtMethod:m. |
|
356 | 3451 |
" |
3452 |
! |
|
3453 |
||
620 | 3454 |
selectorAtMethod:aMethod ifAbsent:failBlock |
3455 |
"return the selector for given method aMethod |
|
3456 |
or the value of failBlock, if not found." |
|
3457 |
||
1814 | 3458 |
|md| |
3459 |
||
3460 |
md := self methodDictionary. |
|
3461 |
md isNil ifTrue:[ |
|
3462 |
'OOPS - nil methodDictionary' errorPrintCR. |
|
3463 |
^ nil |
|
3464 |
]. |
|
3465 |
^ md keyAtValue:aMethod ifAbsent:failBlock. |
|
216 | 3466 |
|
3467 |
" |
|
620 | 3468 |
|m| |
3469 |
||
3470 |
m := Object compiledMethodAt:#copy. |
|
3471 |
Object selectorAtMethod:m ifAbsent:['oops']. |
|
3472 |
" |
|
216 | 3473 |
" |
620 | 3474 |
|m| |
3475 |
||
3476 |
m := Object compiledMethodAt:#copy. |
|
3477 |
Fraction selectorAtMethod:m ifAbsent:['oops']. |
|
216 | 3478 |
" |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3479 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1449
diff
changeset
|
3480 |
"Modified: 7.6.1996 / 15:15:45 / stefan" |
216 | 3481 |
! |
3482 |
||
2699
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3483 |
sharedPools |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3484 |
^ #() |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3485 |
|
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3486 |
"Created: 19.6.1997 / 18:19:36 / cg" |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3487 |
! |
2a47baf52313
added #sharedPools for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2698
diff
changeset
|
3488 |
|
127 | 3489 |
sizeOfInst:n |
3490 |
"return the number of bytes required for an instance of |
|
3491 |
myself with n indexed instance variables. The argument n |
|
3492 |
should be zero for classes without indexed instance variables. |
|
3493 |
See Behavior>>niceNew: for an application of this." |
|
216 | 3494 |
|
127 | 3495 |
|nInstvars| |
3496 |
||
3497 |
nInstvars := self instSize. |
|
3498 |
%{ |
|
3499 |
int nBytes; |
|
3500 |
||
1133 | 3501 |
nBytes = __intVal(nInstvars) * sizeof(OBJ) + OHDR_SIZE; |
249 | 3502 |
if (__isSmallInteger(n)) { |
154 | 3503 |
int nIndex; |
127 | 3504 |
|
1133 | 3505 |
nIndex = __intVal(n); |
3506 |
switch (__intVal(__INST(flags)) & ARRAYMASK) { |
|
154 | 3507 |
case BYTEARRAY: |
3508 |
nBytes += nIndex; |
|
2894 | 3509 |
if (nBytes & (__ALIGN__ - 1)) { |
3510 |
nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__; |
|
154 | 3511 |
} |
3512 |
break; |
|
127 | 3513 |
|
154 | 3514 |
case WORDARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3515 |
case SWORDARRAY: |
154 | 3516 |
nBytes += nIndex * sizeof(short); |
2894 | 3517 |
if (nBytes & (__ALIGN__ - 1)) { |
3518 |
nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__; |
|
154 | 3519 |
} |
3520 |
break; |
|
127 | 3521 |
|
154 | 3522 |
case LONGARRAY: |
1514
4ac06d3251a8
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
3523 |
case SLONGARRAY: |
154 | 3524 |
nBytes += nIndex * sizeof(long); |
3525 |
break; |
|
127 | 3526 |
|
154 | 3527 |
case FLOATARRAY: |
3528 |
nBytes += nIndex * sizeof(float); |
|
3529 |
break; |
|
127 | 3530 |
|
154 | 3531 |
case DOUBLEARRAY: |
3532 |
nBytes += nIndex * sizeof(double); |
|
3533 |
break; |
|
127 | 3534 |
|
154 | 3535 |
default: |
3536 |
nBytes += nIndex * sizeof(OBJ); |
|
3537 |
break; |
|
3538 |
} |
|
127 | 3539 |
} |
1133 | 3540 |
RETURN (__MKSMALLINT(nBytes)); |
127 | 3541 |
%} |
3542 |
! |
|
3543 |
||
620 | 3544 |
sourceCodeAt:aSelector |
3545 |
"return the methods source for given selector aSelector or nil. |
|
3546 |
Only methods in the receiver - not in the superclass chain are tested." |
|
3547 |
||
3548 |
|method| |
|
3549 |
||
3550 |
method := self compiledMethodAt:aSelector. |
|
3551 |
method isNil ifTrue:[^ nil]. |
|
3552 |
^ method source |
|
45 | 3553 |
|
91 | 3554 |
" |
620 | 3555 |
True sourceCodeAt:#ifTrue: |
3556 |
Object sourceCodeAt:#== |
|
3557 |
Behavior sourceCodeAt:#sourceCodeAt: |
|
91 | 3558 |
" |
1 | 3559 |
! |
3560 |
||
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3561 |
sourceCodeManager |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3562 |
"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
|
3563 |
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
|
3564 |
(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
|
3565 |
(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
|
3566 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3567 |
^ nil |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3568 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3569 |
"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
|
3570 |
! |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3571 |
|
1 | 3572 |
subclasses |
3573 |
"return a collection of the direct subclasses of the receiver" |
|
3574 |
||
3575 |
|newColl| |
|
3576 |
||
2224 | 3577 |
"/ use cached information (avoid class hierarchy search) |
3578 |
"/ if possible |
|
3579 |
||
308 | 3580 |
SubclassInfo notNil ifTrue:[ |
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
3581 |
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
|
3582 |
newColl notNil ifTrue:[^ newColl asOrderedCollection] |
308 | 3583 |
]. |
3584 |
||
1 | 3585 |
newColl := OrderedCollection new. |
3586 |
self subclassesDo:[:aClass | |
|
2666
7981b615b48a
Make Metaclass a subclass of ClassDescription instead of Class.
Stefan Vogel <sv@exept.de>
parents:
2569
diff
changeset
|
3587 |
newColl add:aClass |
1 | 3588 |
]. |
3589 |
^ newColl |
|
45 | 3590 |
|
91 | 3591 |
" |
3592 |
Collection subclasses |
|
3593 |
" |
|
2224 | 3594 |
|
3595 |
"Modified: 22.1.1997 / 18:43:52 / cg" |
|
1 | 3596 |
! |
3597 |
||
620 | 3598 |
superclasses |
3599 |
"return a collection of the receivers immediate superclasses. |
|
3600 |
This method is a preparation for a future multiple inheritance extension |
|
3601 |
- currently it is not supported by the VM" |
|
3602 |
||
3603 |
|a| |
|
3604 |
||
3605 |
a := Array with:superclass. |
|
3606 |
otherSuperclasses notNil ifTrue:[ |
|
3607 |
^ a , otherSuperclasses |
|
1 | 3608 |
]. |
620 | 3609 |
^ a |
154 | 3610 |
|
3611 |
" |
|
620 | 3612 |
String superclasses |
91 | 3613 |
" |
2 | 3614 |
! |
3615 |
||
2809 | 3616 |
supportsMethodCategories |
3617 |
"return true, if my methods are categorized. |
|
3618 |
This is a hook for the browser to allow alien classes |
|
3619 |
to be handled (aktually, this is not yet used)." |
|
3620 |
||
3621 |
^ true |
|
3622 |
||
3623 |
"Created: 30.7.1997 / 14:59:08 / cg" |
|
3624 |
"Modified: 30.7.1997 / 15:02:03 / cg" |
|
3625 |
! |
|
3626 |
||
2048 | 3627 |
topOwningClass |
3628 |
"return my outermost owning class - nil if I am a public class" |
|
3629 |
||
3630 |
"/ this information is in the metaclass ... |
|
3631 |
||
3632 |
^ self class topOwningClass |
|
3633 |
||
3634 |
"Created: 15.10.1996 / 21:19:32 / cg" |
|
3635 |
"Modified: 3.1.1997 / 19:18:49 / cg" |
|
3636 |
! |
|
3637 |
||
1191
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3638 |
wasAutoloaded |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3639 |
"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
|
3640 |
autoload; false otherwise. |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3641 |
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
|
3642 |
(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
|
3643 |
|
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3644 |
^ false |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3645 |
|
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3646 |
"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
|
3647 |
! |
7d458640ca32
moved & added some query methods (from class) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
3648 |
|
2 | 3649 |
whichClassImplements:aSelector |
328 | 3650 |
"obsolete interface; |
3651 |
use whichClassIncludesSelector: for ST-80 compatibility." |
|
3652 |
||
3653 |
^ self whichClassIncludesSelector:aSelector |
|
3654 |
! |
|
3655 |
||
3656 |
whichClassIncludesSelector:aSelector |
|
68 | 3657 |
"return the class in the inheritance chain, which implements the method |
3658 |
for aSelector; return nil if none. |
|
3659 |
EXPERIMENTAL: handle multiple superclasses" |
|
3660 |
||
3661 |
|cls| |
|
2 | 3662 |
|
68 | 3663 |
cls := self. |
3664 |
[cls notNil] whileTrue:[ |
|
983 | 3665 |
(cls includesSelector:aSelector) ifTrue:[^ cls]. |
154 | 3666 |
cls hasMultipleSuperclasses ifTrue:[ |
3667 |
cls superclasses do:[:aSuperClass | |
|
3668 |
|implementingClass| |
|
2 | 3669 |
|
328 | 3670 |
implementingClass := aSuperClass whichClassIncludesSelector:aSelector. |
154 | 3671 |
implementingClass notNil ifTrue:[^ implementingClass]. |
3672 |
]. |
|
3673 |
^ nil |
|
3674 |
] ifFalse:[ |
|
3675 |
cls := cls superclass |
|
3676 |
] |
|
2 | 3677 |
]. |
3678 |
^ nil |
|
3679 |
||
91 | 3680 |
" |
328 | 3681 |
String whichClassIncludesSelector:#== |
3682 |
String whichClassIncludesSelector:#collect: |
|
91 | 3683 |
" |
2 | 3684 |
! |
3685 |
||
3053
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3686 |
whichSelectorsReferTo:someLiteralConstant |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3687 |
"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
|
3688 |
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
|
3689 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3690 |
|setOfSelectors| |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3691 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3692 |
setOfSelectors := IdentitySet new. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3693 |
methodDictionary keysAndValuesDo:[:sel :mthd | |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3694 |
(mthd referencesLiteral:someLiteralConstant) ifTrue:[ |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3695 |
setOfSelectors add:sel |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3696 |
]. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3697 |
]. |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3698 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3699 |
^ setOfSelectors |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3700 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3701 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3702 |
String whichSelectorsReferTo:#at: |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3703 |
String whichSelectorsReferTo:CharacterArray |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3704 |
" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3705 |
|
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3706 |
"Modified: / 28.10.1997 / 13:13:18 / cg" |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3707 |
! |
d6aad366397f
added #whichSelectorsReferTo: and #compiledMethodAt:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
3708 |
|
620 | 3709 |
withAllSubclasses |
3710 |
"return a collection containing the receiver and |
|
3711 |
all subclasses (direct AND indirect) of the receiver" |
|
3712 |
||
3713 |
|newColl| |
|
3714 |
||
3715 |
newColl := OrderedCollection with:self. |
|
3716 |
self allSubclassesDo:[:aClass | |
|
3717 |
newColl add:aClass |
|
3718 |
]. |
|
3719 |
^ newColl |
|
328 | 3720 |
|
3721 |
" |
|
620 | 3722 |
Collection withAllSubclasses |
91 | 3723 |
" |
1 | 3724 |
! |
3725 |
||
620 | 3726 |
withAllSuperclasses |
3727 |
"return a collection containing the receiver and all |
|
3728 |
of the receivers accumulated superclasses" |
|
3729 |
||
3730 |
|aCollection theSuperClass| |
|
3731 |
||
3732 |
aCollection := OrderedCollection with:self. |
|
3733 |
theSuperClass := superclass. |
|
3734 |
[theSuperClass notNil] whileTrue:[ |
|
3735 |
aCollection add:theSuperClass. |
|
3736 |
theSuperClass := theSuperClass superclass |
|
308 | 3737 |
]. |
620 | 3738 |
^ aCollection |
11 | 3739 |
|
91 | 3740 |
" |
620 | 3741 |
String withAllSuperclasses |
308 | 3742 |
" |
2 | 3743 |
! ! |
620 | 3744 |
|
3745 |
!Behavior methodsFor:'snapshots'! |
|
3746 |
||
3747 |
postSnapshot |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3748 |
"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
|
3749 |
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
|
3750 |
about snapshooting." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3751 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3752 |
"Modified: 16.4.1996 / 18:12:08 / cg" |
620 | 3753 |
! |
3754 |
||
3755 |
preSnapshot |
|
1192
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3756 |
"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
|
3757 |
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
|
3758 |
about snapshooting." |
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3759 |
|
b1c2b886f23c
moved some protocol from Class to upper levels; renamed categories
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
3760 |
"Modified: 16.4.1996 / 18:12:14 / cg" |
620 | 3761 |
! ! |
3762 |
||
1760 | 3763 |
!Behavior class methodsFor:'documentation'! |
662 | 3764 |
|
3765 |
version |
|
3442
d22afbb5864f
added #initializeWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
3411
diff
changeset
|
3766 |
^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.128 1998-05-13 21:37:11 cg Exp $' |
662 | 3767 |
! ! |