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