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