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