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