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