author | convert-repo |
Tue, 17 Jan 2017 04:54:48 +0000 | |
changeset 21257 | 0f40f3a0508c |
parent 20700 | 7cc4b1aa3949 |
child 21024 | 8734987eb5c7 |
child 21316 | 186f4d063585 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 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 |
" |
|
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
13 |
|
18480 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1 | 16 |
Object subclass:#UndefinedObject |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
17 |
instanceVariableNames:'' |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
18 |
classVariableNames:'CreateMinimumProtocolInNewSubclassQuery' |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
19 |
poolDictionaries:'' |
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
20 |
category:'Kernel-Objects' |
1 | 21 |
! |
22 |
||
88 | 23 |
!UndefinedObject class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 28 |
All Rights Reserved |
1 | 29 |
|
88 | 30 |
This software is furnished under a license and may be used |
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
20215 | 41 |
there is only one instance of this class: nil, |
1303 | 42 |
representing an undefined or otherwise unspecified object. |
88 | 43 |
|
20215 | 44 |
All instance variables, array elements and even method/block local |
88 | 45 |
variables are initially set to nil. |
1303 | 46 |
|
20215 | 47 |
Since in Smalltalk/X (and in other smalltalks), nil is represented by |
48 |
a special pointer value (NULL), there can be only one instance of UndefinedObject, |
|
49 |
and no subclassing is possible. |
|
50 |
(to be exact: subclassing UndefinedObject is technically possible, |
|
51 |
but instances of it would not be recognized as being nil |
|
1303 | 52 |
- therefore, subclassing is blocked and an error is raised when it is tried) |
53 |
||
54 |
For advanced users: |
|
55 |
Beside the above role, nil can be subclassed (!!). |
|
56 |
This creates a class which inherits no protocol whatsoever - not even |
|
57 |
the basic interfaces as defined by the Object class. Subclasses of nil |
|
58 |
are useful if all messages send to instances should trap into the |
|
59 |
#doesNotUnderstand: method. For example, proxy objects are typically defined |
|
60 |
this way. |
|
1294 | 61 |
|
62 |
[author:] |
|
63 |
Claus Gittinger |
|
88 | 64 |
" |
65 |
! ! |
|
1 | 66 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
67 |
!UndefinedObject class methodsFor:'initialization'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
68 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
69 |
initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
70 |
CreateMinimumProtocolInNewSubclassQuery isNil ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
71 |
CreateMinimumProtocolInNewSubclassQuery := QuerySignal new. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
72 |
CreateMinimumProtocolInNewSubclassQuery nameClass:self message:#createMinimumProtocolInNewSubclassQuery. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
73 |
CreateMinimumProtocolInNewSubclassQuery defaultAnswer:false. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
74 |
]. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
75 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
76 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
77 |
UndefinedObject initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
78 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
79 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
80 |
"Created: 3.1.1997 / 15:02:40 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
81 |
"Modified: 3.1.1997 / 15:18:33 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
82 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
83 |
|
1 | 84 |
!UndefinedObject class methodsFor:'instance creation'! |
85 |
||
86 |
basicNew |
|
87 |
"catch new - there MUST be only one nil in the system" |
|
88 |
||
89 |
^ nil |
|
90 |
! |
|
91 |
||
92 |
basicNew:size |
|
93 |
"catch new - there MUST be only one nil in the system" |
|
94 |
||
95 |
^ nil |
|
96 |
! ! |
|
97 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
98 |
!UndefinedObject class methodsFor:'Signal constants'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
99 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
100 |
createMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
101 |
"return the signal used to ask if the minimum required protocol |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
102 |
should be created for nil subclasses. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
103 |
By default, this is not done, however, the browser answers true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
104 |
here, to avoid big trouble with nil subclasses which do not define |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
105 |
some methods which the inspector needs." |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
106 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
107 |
^ CreateMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
108 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
109 |
"Created: 3.1.1997 / 15:05:48 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
110 |
"Modified: 3.1.1997 / 15:06:15 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
111 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
112 |
|
51 | 113 |
!UndefinedObject class methodsFor:'queries'! |
114 |
||
115 |
canBeSubclassed |
|
20215 | 116 |
"return true if it is allowed to create subclasses of the receiver. |
3914 | 117 |
Return false here - since it is NOT possible for UndefinedObject. |
118 |
(due to the representation of nil as a 0-pointer)" |
|
51 | 119 |
|
120 |
^ false |
|
3914 | 121 |
|
122 |
"Modified: / 5.11.1998 / 16:11:43 / cg" |
|
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
123 |
! |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
124 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
125 |
hasImmediateInstances |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
126 |
"return true if this class has immediate instances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
127 |
i.e. if the instances are represented in the pointer itself and |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
128 |
no real object header/storage is used for the object. |
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
129 |
Redefined from Behavior" |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
130 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
131 |
^ true |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
132 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
133 |
"Created: 3.6.1997 / 12:01:39 / cg" |
4321 | 134 |
! |
135 |
||
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
136 |
hasSharedInstances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
137 |
"return true if this class has shared instances, that is, instances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
138 |
with the same value are identical. |
4654 | 139 |
True returned here - there is only one nil." |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
140 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
141 |
^ true |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
142 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
143 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
144 |
! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
145 |
|
4321 | 146 |
isBuiltInClass |
20215 | 147 |
"return true if this class is known by the run-time-system, |
4321 | 148 |
i.e. you cannot add/remove instance variables without recompiling |
149 |
the VM. |
|
150 |
Here, true is returned for myself, false for subclasses." |
|
151 |
||
152 |
^ self == UndefinedObject |
|
51 | 153 |
! ! |
154 |
||
5699 | 155 |
|
2416 | 156 |
!UndefinedObject methodsFor:'converting'! |
157 |
||
8305 | 158 |
asBoolean |
159 |
^ false |
|
160 |
! |
|
161 |
||
15081 | 162 |
asNilIfEmpty |
163 |
"I am nil, so answer nil" |
|
164 |
||
165 |
^ self |
|
166 |
! |
|
167 |
||
2416 | 168 |
literalArrayEncoding |
169 |
"encode myself as an array literal, from which a copy of the receiver |
|
170 |
can be reconstructed with #decodeAsLiteralArray." |
|
171 |
||
172 |
^ self |
|
173 |
||
174 |
"Created: 25.2.1997 / 19:18:47 / cg" |
|
175 |
! ! |
|
176 |
||
695 | 177 |
!UndefinedObject methodsFor:'copying'! |
178 |
||
179 |
copy |
|
180 |
"return a shallow copy of myself |
|
181 |
- since there is only one nil in the system return self" |
|
182 |
||
183 |
^ self |
|
184 |
! |
|
185 |
||
186 |
deepCopy |
|
187 |
"return a deep copy of myself |
|
188 |
- since there is only one nil in the system return self" |
|
189 |
||
190 |
^ self |
|
191 |
! |
|
192 |
||
10945 | 193 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
695 | 194 |
"return a deep copy of myself |
8383 | 195 |
- since there is only one nil in the system, return self" |
695 | 196 |
|
197 |
^ self |
|
198 |
! |
|
199 |
||
200 |
shallowCopy |
|
201 |
"return a shallow copy of myself |
|
202 |
- since there is only one nil in the system return self" |
|
203 |
||
204 |
^ self |
|
205 |
! |
|
206 |
||
207 |
simpleDeepCopy |
|
208 |
"return a deep copy of myself |
|
209 |
- since there is only one nil in the system return self" |
|
210 |
||
211 |
^ self |
|
212 |
! ! |
|
213 |
||
3166 | 214 |
!UndefinedObject methodsFor:'dependents access'! |
215 |
||
216 |
addDependent:someObject |
|
12968
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
217 |
"raise an error here - nil may not have dependents (it never changes anyway)" |
3166 | 218 |
|
4530
793b116fef3e
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4339
diff
changeset
|
219 |
self error:'nil may not have dependents' mayProceed:true |
793b116fef3e
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4339
diff
changeset
|
220 |
|
12968
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
221 |
"Modified: / 28-07-2010 / 19:20:36 / cg" |
3166 | 222 |
! |
223 |
||
3183 | 224 |
dependents |
225 |
"nil has no dependents" |
|
226 |
||
227 |
^#() |
|
228 |
! |
|
229 |
||
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
230 |
release |
3166 | 231 |
"ignored here - nil has no dependents" |
3183 | 232 |
! |
3166 | 233 |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
234 |
removeDependent:someObject |
3183 | 235 |
"ignored here - nil has no dependents" |
3166 | 236 |
! ! |
237 |
||
1 | 238 |
!UndefinedObject methodsFor:'error catching'! |
239 |
||
240 |
basicAt:index |
|
20700 | 241 |
"catch array access - it's illegal. |
242 |
Redefined here since basicAt: in Object ommits the nil-check" |
|
1 | 243 |
|
244 |
^ self notIndexed |
|
245 |
! |
|
246 |
||
247 |
basicAt:index put:anObject |
|
20700 | 248 |
"catch array access - it's illegal. |
249 |
Redefined here since basicAt:put: in Object ommits the nil-check" |
|
1 | 250 |
|
251 |
^ self notIndexed |
|
252 |
! ! |
|
253 |
||
14678 | 254 |
|
1 | 255 |
!UndefinedObject methodsFor:'printing & storing'! |
256 |
||
63 | 257 |
printOn:aStream |
258 |
"append a printed representation of the receiver to the |
|
259 |
argument, aStream" |
|
260 |
||
261 |
aStream nextPutAll:'nil' |
|
262 |
! |
|
263 |
||
695 | 264 |
printString |
265 |
"return a string for printing myself" |
|
266 |
||
267 |
^ 'nil' |
|
268 |
! |
|
269 |
||
63 | 270 |
storeOn:aStream |
271 |
"append a printed representation of the receiver to the |
|
272 |
argument, aStream, which allows reconstruction of it" |
|
273 |
||
274 |
^ self printOn:aStream |
|
695 | 275 |
! |
276 |
||
277 |
storeString |
|
278 |
"return a string for storing myself" |
|
279 |
||
280 |
^ 'nil' |
|
1 | 281 |
! ! |
2 | 282 |
|
5557 | 283 |
!UndefinedObject methodsFor:'queries'! |
284 |
||
285 |
basicSize |
|
286 |
"return the number of indexed instvars |
|
287 |
defined here since size in Object ommits the nil-check" |
|
288 |
||
289 |
^ 0 |
|
290 |
! |
|
291 |
||
292 |
size |
|
293 |
"return the number of indexed instvars |
|
294 |
defined here since size in Object ommits the nil-check" |
|
20215 | 295 |
|
5557 | 296 |
^ 0 |
297 |
! ! |
|
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
298 |
|
77 | 299 |
!UndefinedObject methodsFor:'subclass creation'! |
300 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
301 |
nilSubclass:action |
356 | 302 |
"common helper for subclass creation. |
20215 | 303 |
Creates a nil-superclass class. |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
304 |
If the CreateMinimumProtocolInNewSubclassQuery answers true, |
20215 | 305 |
entries for the minimum required protocol (#class, #isBehavior |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
306 |
and #doesNotUnderstand:) are also automatically created. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
307 |
(this query is typically answered by the browser) |
356 | 308 |
These are required to avoid getting into deep trouble when |
309 |
inspecting or debugging instances of this new class. |
|
310 |
The methods get a modified source code to remind you that these |
|
311 |
methods were automatically generated." |
|
312 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
313 |
|newClass methodDict method| |
202 | 314 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
315 |
Class withoutUpdatingChangesDo:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
316 |
newClass := action value |
77 | 317 |
]. |
318 |
newClass notNil ifTrue:[ |
|
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
319 |
newClass setSuperclass:nil. |
1803
754f9205b651
meta's superclass should be class - not Object.
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
320 |
newClass class setSuperclass:Class. |
356 | 321 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
322 |
newClass methodDictionary size == 0 ifTrue:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
323 |
Class addChangeRecordForClass:newClass. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
324 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
325 |
CreateMinimumProtocolInNewSubclassQuery query |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
326 |
ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
327 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
328 |
copy over method objects from Object |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
329 |
and modify the source code |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
330 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
331 |
methodDict := MethodDictionary new:3. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
332 |
#(#class #isBehavior #doesNotUnderstand:) do:[:sel| |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
333 |
method := (Object compiledMethodAt:sel) copy. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
334 |
method source: method source , ' |
356 | 335 |
" |
336 |
*** WARNING |
|
337 |
*** |
|
338 |
*** this method has been automatically created, |
|
339 |
*** since all nil-subclasses should respond to some minimum required |
|
340 |
*** protocol. |
|
341 |
*** |
|
342 |
*** Inspection and/or debugging of instances may not be possible, |
|
343 |
*** if you remove/change this method. |
|
344 |
" |
|
345 |
'. |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
346 |
methodDict at:sel put:method. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
347 |
"/ newClass addChangeRecordForMethod:method |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
348 |
]. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
349 |
newClass methodDictionary:methodDict. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
350 |
] |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
351 |
] |
77 | 352 |
]. |
353 |
^ newClass |
|
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
354 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
355 |
"Modified: / 3.1.1997 / 15:53:21 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
356 |
"Created: / 3.1.1997 / 16:00:34 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
357 |
"Modified: / 18.3.1999 / 18:29:58 / stefan" |
202 | 358 |
! |
359 |
||
9256 | 360 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool |
20215 | 361 |
"create a new class which has nil as superclass |
9256 | 362 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
363 |
||
14678 | 364 |
"this method allows fileIn of ST/V and V'Age classes |
365 |
(which seem to have no category)" |
|
366 |
||
20215 | 367 |
^ self |
368 |
subclass:nameSymbol |
|
369 |
instanceVariableNames:instVarNameString |
|
370 |
classVariableNames:classVarString |
|
9256 | 371 |
poolDictionaries:pool |
372 |
category:(Class defaultCategoryForSTVorVAGEClasses). |
|
373 |
! |
|
374 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
375 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
20215 | 376 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
377 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
202 | 378 |
|
20215 | 379 |
^ self |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
380 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
381 |
Object class |
20215 | 382 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
383 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
384 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
385 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
386 |
variable:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
387 |
words:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
388 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
389 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
390 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
391 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
392 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
393 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
394 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
395 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
396 |
"Modified: / 3.1.1997 / 16:00:39 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
397 |
"Modified: / 18.3.1999 / 18:30:07 / stefan" |
695 | 398 |
! |
399 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
400 |
variableByteSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
20215 | 401 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
402 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
695 | 403 |
|
20215 | 404 |
^ self |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
405 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
406 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
407 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
408 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
409 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
410 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
411 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
412 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
413 |
pointers:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
414 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
415 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
416 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
417 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
418 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
419 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
420 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
421 |
"Modified: / 3.1.1997 / 16:00:42 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
422 |
"Modified: / 18.3.1999 / 18:30:11 / stefan" |
695 | 423 |
! |
77 | 424 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
425 |
variableSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
20215 | 426 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
427 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
77 | 428 |
|
20215 | 429 |
^ self |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
430 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
431 |
Object class |
20215 | 432 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
433 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
434 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
435 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
436 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
437 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
438 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
439 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
440 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
441 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
442 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
443 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
444 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
445 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
446 |
"Modified: / 3.1.1997 / 16:00:45 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
447 |
"Modified: / 18.3.1999 / 18:30:16 / stefan" |
695 | 448 |
! ! |
449 |
||
7262 | 450 |
!UndefinedObject methodsFor:'subclass creation-private'! |
5745 | 451 |
|
18480 | 452 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:ownerClassArg |
20215 | 453 |
"create a new private class which has nil as superclass |
5745 | 454 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
455 |
||
18480 | 456 |
|category ownerClass| |
457 |
||
458 |
(ownerClass := ownerClassArg) isNil ifTrue:[ |
|
459 |
self error:'Nil (undefined) owner class - proceed to define as global' mayProceed:true. |
|
460 |
] ifFalse:[ |
|
461 |
category := ownerClassArg category |
|
462 |
]. |
|
20215 | 463 |
|
464 |
^ self |
|
5745 | 465 |
nilSubclass:[ |
466 |
Object class |
|
20215 | 467 |
name:nameSymbol |
5745 | 468 |
inEnvironment:ownerClass |
469 |
subclassOf:self |
|
470 |
instanceVariableNames:instVarNameString |
|
471 |
variable:false |
|
472 |
words:true |
|
473 |
pointers:true |
|
474 |
classVariableNames:classVarString |
|
475 |
poolDictionaries:pool |
|
18480 | 476 |
category:category |
5745 | 477 |
comment:nil |
478 |
changed:true |
|
479 |
] |
|
480 |
||
481 |
"Modified: / 3.1.1997 / 16:00:39 / cg" |
|
482 |
"Modified: / 18.3.1999 / 18:30:07 / stefan" |
|
483 |
! ! |
|
484 |
||
695 | 485 |
!UndefinedObject methodsFor:'testing'! |
486 |
||
1868 | 487 |
? defaultValue |
20191 | 488 |
"a syntactic sugar-piece: |
3466 | 489 |
if the receiver is nil, return the defaultValue; |
1868 | 490 |
otherwise, return the receiver. |
491 |
This method is redefined from Object; |
|
20215 | 492 |
the argument is returned unconditionally here. |
1868 | 493 |
|
1958 | 494 |
Thus, if foo and bar are simple variables or constants, |
495 |
foo ? bar |
|
496 |
is the same as: |
|
497 |
(foo isNil ifTrue:[bar] ifFalse:[foo]) |
|
498 |
||
499 |
if they are message sends, the equivalent code is: |
|
500 |
[ |
|
501 |
|t1 t2| |
|
502 |
||
503 |
t1 := foo. |
|
504 |
t2 := bar. |
|
505 |
t1 isNil ifTrue:[t2] ifFalse:[t1] |
|
506 |
] value |
|
507 |
||
1868 | 508 |
Can be used to provide defaultValues to variables, |
509 |
as in: |
|
1958 | 510 |
foo := arg ? #defaultValue |
1868 | 511 |
" |
512 |
||
513 |
^ defaultValue |
|
514 |
||
515 |
" |
|
516 |
1 ? #default |
|
20191 | 517 |
nil ? #default |
1868 | 518 |
" |
519 |
||
3466 | 520 |
"Created: / 4.11.1996 / 20:37:09 / cg" |
521 |
"Modified: / 19.5.1998 / 17:39:36 / cg" |
|
1868 | 522 |
! |
523 |
||
16127 | 524 |
?+ aOneArgBlock |
525 |
"a syntactic sugar-piece: |
|
526 |
aOneArgBlock is executed with self as argument |
|
527 |
if self is not nil. |
|
528 |
||
529 |
Note: this method should never be redefined in classes other than UndefinedObject. |
|
530 |
" |
|
531 |
||
532 |
^ self |
|
533 |
! |
|
534 |
||
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
535 |
?? defaultValue |
11635 | 536 |
"a syntactic sugar-piece: |
3466 | 537 |
much like ?, but sends value to the argument if required. |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
538 |
If the receiver is nil, return the defaultValues value; |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
539 |
otherwise, return the receiver. |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
540 |
This method is redefined from Object. |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
541 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
542 |
Thus, if foo and bar are simple variables or constants, |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
543 |
foo ?? bar |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
544 |
is the same as: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
545 |
(foo isNil ifTrue:[bar value] ifFalse:[foo]) |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
546 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
547 |
if they are message sends, the equivalent code is: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
548 |
[ |
3466 | 549 |
|t| |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
550 |
|
3466 | 551 |
t := foo. |
552 |
t isNil ifTrue:[bar value] ifFalse:[t] |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
553 |
] value |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
554 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
555 |
Can be used to provide defaultValues to variables, |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
556 |
as in: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
557 |
foo := arg ?? [something] |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
558 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
559 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
560 |
^ defaultValue value |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
561 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
562 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
563 |
1 ?? #default |
20215 | 564 |
nil ?? #default |
565 |
1 ?? [Date today] |
|
566 |
nil ?? [Date today] |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
567 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
568 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
569 |
"Created: / 4.11.1996 / 20:37:09 / cg" |
3466 | 570 |
"Modified: / 19.5.1998 / 17:42:10 / cg" |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
571 |
! |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
572 |
|
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
573 |
checkNilFileStream |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
574 |
"Do nothing if this is a valid FileStream |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
575 |
(i.e. the previous open operation was successful). |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
576 |
Also implemented in UndefinedObject, to raise an Error there. |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
577 |
|
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
578 |
This is an aid for converting from the old error reporting (returning nil) |
11635 | 579 |
to the new error reporting (with real Exceptions). |
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
580 |
|
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
581 |
It will vanish as soon as the conversion has been done" |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
582 |
|
16127 | 583 |
^ OpenError raise |
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
584 |
! |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
585 |
|
695 | 586 |
hash |
587 |
"return an integer useful as a hash key" |
|
588 |
||
589 |
^ 0 |
|
590 |
! |
|
591 |
||
592 |
identityHash |
|
593 |
"return an integer useful as a hash key" |
|
594 |
||
595 |
^ 0 |
|
596 |
! |
|
597 |
||
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
598 |
ifNil:aBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
599 |
"return myself, or the result from evaluating the argument, if I am nil. |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
600 |
This is much like #?, but sends #value to the argument in case of a nil |
5796 | 601 |
receiver. |
602 |
Notice: |
|
603 |
This method is open coded (inlined) by the compiler(s) |
|
604 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
605 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
606 |
^ aBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
607 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
608 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
609 |
ifNil:nilBlockOrValue ifNotNil:notNilBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
610 |
"return the value of the first arg, if I am nil, |
5796 | 611 |
the result from evaluating the 2nd argument, if I am not nil. |
612 |
Notice: |
|
613 |
This method is open coded (inlined) by the compiler(s) |
|
614 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
615 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
616 |
^ nilBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
617 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
618 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
619 |
ifNotNil:aBlockOrValue |
5796 | 620 |
"return myself if nil, or the result from evaluating the argument, if I am not nil. |
621 |
Notice: |
|
622 |
This method is open coded (inlined) by the compiler(s) |
|
623 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
624 |
|
8574 | 625 |
^ nil |
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
626 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
627 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
628 |
ifNotNil:notNilBlockOrValue ifNil:nilBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
629 |
"return the value of the 2nd arg, if I am nil, |
5796 | 630 |
the result from evaluating the 1st argument, if I am not nil. |
631 |
Notice: |
|
632 |
This method is open coded (inlined) by the compiler(s) |
|
633 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
634 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
635 |
^ nilBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
636 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
637 |
|
8574 | 638 |
ifNotNilDo:aBlock |
20352 | 639 |
"if the receiver is non-nil, return the value of aBlock, passing myself as argument. |
8574 | 640 |
Otherwise do nothing and return nil." |
641 |
||
642 |
^ nil |
|
643 |
! |
|
644 |
||
6181 | 645 |
isEmptyOrNil |
20215 | 646 |
"return true if I am nil or an empty collection |
13588 | 647 |
- since I am nil, return true. (from Sqeak)" |
6181 | 648 |
|
649 |
^ true |
|
650 |
||
13588 | 651 |
"Created: / 13-11-2001 / 13:16:40 / cg" |
652 |
"Modified (comment): / 17-08-2011 / 09:29:30 / cg" |
|
6181 | 653 |
! |
654 |
||
695 | 655 |
isLiteral |
20215 | 656 |
"return true if the receiver can be used as a literal constant in ST syntax |
695 | 657 |
(i.e. can be used in constant arrays)" |
77 | 658 |
|
695 | 659 |
^ true |
660 |
! |
|
661 |
||
662 |
isNil |
|
20215 | 663 |
"Return true if the receiver is nil. |
9223 | 664 |
Since I am definitely nil, unconditionally return true here. |
3044 | 665 |
Notice: |
9223 | 666 |
This method is open coded (inlined) by the compiler(s) |
667 |
- redefining it may not work as expected." |
|
695 | 668 |
|
669 |
^ true |
|
670 |
! |
|
671 |
||
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
672 |
isNilOrEmptyCollection |
8833 | 673 |
"return true if I am nil or an empty collection - false here. |
674 |
Obsolete, use isEmptyOrNil." |
|
675 |
||
676 |
<resource:#obsolete> |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
677 |
|
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
678 |
^ true |
6182 | 679 |
|
680 |
"Modified: / 13.11.2001 / 13:28:15 / cg" |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
681 |
! |
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
682 |
|
16908
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
683 |
isNotNil |
20215 | 684 |
<resource: #obsolete> |
685 |
||
686 |
"Return true if the receiver is not nil. |
|
687 |
Since I am definitely nil, unconditionally return false here. |
|
16908
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
688 |
the receiver is definitely not nil here, so unconditionally return false." |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
689 |
|
20215 | 690 |
self obsoleteMethodWarning:'use #notNil'. |
16908
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
691 |
^ false |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
692 |
|
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
693 |
"Created: / 26-10-2014 / 01:30:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
694 |
! |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
695 |
|
6932 | 696 |
notEmptyOrNil |
697 |
"Squeak compatibility: |
|
698 |
return true if I am neither nil nor an empty collection." |
|
699 |
||
700 |
^ false |
|
701 |
! |
|
702 |
||
695 | 703 |
notNil |
20215 | 704 |
"Return true if the receiver is not nil. |
9223 | 705 |
Since I am definitely nil, unconditionally return false here. |
3044 | 706 |
Notice: |
9223 | 707 |
This method is open coded (inlined) by the compiler(s) |
708 |
- redefining it may not work as expected." |
|
77 | 709 |
|
695 | 710 |
^ false |
77 | 711 |
! ! |
695 | 712 |
|
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
713 |
!UndefinedObject methodsFor:'tracing'! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
714 |
|
4682 | 715 |
traceInto:aRequestor level:level from:referrer |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
716 |
"double dispatch into tracer, passing my type implicitely in the selector" |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
717 |
|
4682 | 718 |
^ aRequestor traceUndefinedObject:self level:level from:referrer |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
719 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
720 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
721 |
! ! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
722 |
|
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
723 |
!UndefinedObject methodsFor:'visiting'! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
724 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
725 |
acceptVisitor:aVisitor with:aParameter |
16721 | 726 |
"dispatch for visitor pattern; send #visitNil:with: to aVisitor." |
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
727 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
728 |
^ aVisitor visitNilWith:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
729 |
! ! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
730 |
|
695 | 731 |
!UndefinedObject class methodsFor:'documentation'! |
732 |
||
733 |
version |
|
18480 | 734 |
^ '$Header$' |
12968
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
735 |
! |
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
736 |
|
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
737 |
version_CVS |
18480 | 738 |
^ '$Header$' |
695 | 739 |
! ! |
6932 | 740 |
|
14678 | 741 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
742 |
UndefinedObject initialize! |