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