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