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 |
"
|
|
12 |
|
|
13 |
Object subclass:#UndefinedObject
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Objects'
|
|
18 |
!
|
|
19 |
|
|
20 |
UndefinedObject comment:'
|
88
|
21 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
159
|
22 |
All Rights Reserved
|
95
|
23 |
|
293
|
24 |
$Header: /cvs/stx/stx/libbasic/UndefinedObject.st,v 1.14 1995-03-06 19:18:09 claus Exp $
|
88
|
25 |
'!
|
1
|
26 |
|
88
|
27 |
!UndefinedObject class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
159
|
32 |
All Rights Reserved
|
1
|
33 |
|
88
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
293
|
45 |
$Header: /cvs/stx/stx/libbasic/UndefinedObject.st,v 1.14 1995-03-06 19:18:09 claus Exp $
|
88
|
46 |
"
|
|
47 |
!
|
1
|
48 |
|
88
|
49 |
documentation
|
|
50 |
"
|
|
51 |
there is only one instance of this class: nil, representing an undefined
|
|
52 |
or otherwise unspecified object.
|
|
53 |
|
|
54 |
All instance variables, array elements and even method/block local
|
|
55 |
variables are initially set to nil.
|
|
56 |
Since in Smalltalk/X, nil is represented by a special pointer value,
|
|
57 |
there can be only one instance of UndefinedObject, and no subclassing is
|
|
58 |
possible.
|
|
59 |
(to be exact: subclassing is technically possible, but instances of it
|
|
60 |
would not be recognized as being nil - therefore, subclassing is blocked)
|
|
61 |
"
|
|
62 |
! !
|
1
|
63 |
|
|
64 |
!UndefinedObject class methodsFor:'instance creation'!
|
|
65 |
|
|
66 |
basicNew
|
|
67 |
"catch new - there MUST be only one nil in the system"
|
|
68 |
|
|
69 |
^ nil
|
|
70 |
!
|
|
71 |
|
|
72 |
basicNew:size
|
|
73 |
"catch new - there MUST be only one nil in the system"
|
|
74 |
|
|
75 |
^ nil
|
|
76 |
! !
|
|
77 |
|
51
|
78 |
!UndefinedObject class methodsFor:'queries'!
|
|
79 |
|
|
80 |
canBeSubclassed
|
|
81 |
"return true, if its allowed to create subclasses of the receiver.
|
|
82 |
Return nil here - since it is NOT possible for UndefinedObject"
|
|
83 |
|
|
84 |
^ false
|
|
85 |
! !
|
|
86 |
|
1
|
87 |
!UndefinedObject methodsFor:'error catching'!
|
|
88 |
|
|
89 |
basicAt:index
|
|
90 |
"catch array access - its illegal
|
|
91 |
defined here since basicAt: in Object ommits the nil-check"
|
|
92 |
|
|
93 |
^ self notIndexed
|
|
94 |
!
|
|
95 |
|
|
96 |
basicAt:index put:anObject
|
|
97 |
"catch array access - its illegal
|
|
98 |
defined here since basicAt:put: in Object ommits the nil-check"
|
|
99 |
|
|
100 |
^ self notIndexed
|
|
101 |
! !
|
|
102 |
|
|
103 |
!UndefinedObject methodsFor:'testing'!
|
|
104 |
|
|
105 |
isNil
|
|
106 |
"return true if I am nil - since I am, return true"
|
|
107 |
|
|
108 |
^ true
|
|
109 |
!
|
|
110 |
|
|
111 |
notNil
|
|
112 |
"return true if I am not nil - since I am nil, return false"
|
|
113 |
|
|
114 |
^ false
|
|
115 |
!
|
|
116 |
|
|
117 |
size
|
|
118 |
"return the number of indexed instvars
|
|
119 |
defined here since size in Object ommits the nil-check"
|
|
120 |
|
|
121 |
^ 0
|
|
122 |
!
|
|
123 |
|
|
124 |
basicSize
|
|
125 |
"return the number of indexed instvars
|
|
126 |
defined here since size in Object ommits the nil-check"
|
|
127 |
|
|
128 |
^ 0
|
|
129 |
!
|
|
130 |
|
|
131 |
hash
|
|
132 |
"return an integer useful as a hash key"
|
|
133 |
|
|
134 |
^ 0
|
|
135 |
!
|
|
136 |
|
|
137 |
identityHash
|
|
138 |
"return an integer useful as a hash key"
|
|
139 |
|
|
140 |
^ 0
|
41
|
141 |
!
|
|
142 |
|
|
143 |
isLiteral
|
|
144 |
"return true, if the receiver can be used as a literal
|
|
145 |
(i.e. can be used in constant arrays)"
|
|
146 |
|
|
147 |
^ true
|
1
|
148 |
! !
|
|
149 |
|
|
150 |
!UndefinedObject methodsFor:'copying'!
|
|
151 |
|
159
|
152 |
copy
|
|
153 |
"return a shallow copy of myself
|
|
154 |
- since there is only one nil in the system return self"
|
|
155 |
|
|
156 |
^ self
|
|
157 |
!
|
|
158 |
|
1
|
159 |
shallowCopy
|
|
160 |
"return a shallow copy of myself
|
|
161 |
- since there is only one nil in the system return self"
|
|
162 |
|
|
163 |
^ self
|
|
164 |
!
|
|
165 |
|
159
|
166 |
deepCopy
|
|
167 |
"return a deep copy of myself
|
|
168 |
- since there is only one nil in the system return self"
|
|
169 |
|
|
170 |
^ self
|
|
171 |
!
|
|
172 |
|
13
|
173 |
simpleDeepCopy
|
|
174 |
"return a deep copy of myself
|
|
175 |
- since there is only one nil in the system return self"
|
|
176 |
|
|
177 |
^ self
|
|
178 |
!
|
|
179 |
|
|
180 |
deepCopyUsing:aDictionary
|
|
181 |
"return a deep copy of myself
|
|
182 |
- since there is only one nil in the system return self"
|
|
183 |
|
|
184 |
^ self
|
1
|
185 |
! !
|
|
186 |
|
|
187 |
!UndefinedObject methodsFor:'printing & storing'!
|
|
188 |
|
|
189 |
printString
|
|
190 |
"return a string for printing myself"
|
|
191 |
|
|
192 |
^ 'nil'
|
|
193 |
!
|
|
194 |
|
|
195 |
storeString
|
|
196 |
"return a string for storing myself"
|
|
197 |
|
|
198 |
^ 'nil'
|
63
|
199 |
!
|
|
200 |
|
|
201 |
printOn:aStream
|
|
202 |
"append a printed representation of the receiver to the
|
|
203 |
argument, aStream"
|
|
204 |
|
|
205 |
aStream nextPutAll:'nil'
|
|
206 |
!
|
|
207 |
|
|
208 |
storeOn:aStream
|
|
209 |
"append a printed representation of the receiver to the
|
|
210 |
argument, aStream, which allows reconstruction of it"
|
|
211 |
|
|
212 |
^ self printOn:aStream
|
1
|
213 |
! !
|
2
|
214 |
|
77
|
215 |
!UndefinedObject methodsFor:'subclass creation'!
|
|
216 |
|
202
|
217 |
nilSubclass:selector args:args
|
|
218 |
"common helper for subclass creation."
|
77
|
219 |
|
202
|
220 |
|newClass|
|
|
221 |
|
|
222 |
Class withoutUpdatingChangesDo:
|
77
|
223 |
[
|
202
|
224 |
newClass := Object perform:selector withArguments:args
|
77
|
225 |
].
|
|
226 |
newClass notNil ifTrue:[
|
159
|
227 |
newClass setSuperclass:nil.
|
|
228 |
newClass
|
202
|
229 |
setSelectors:(Array with:#class
|
159
|
230 |
with:#doesNotUnderstand:)
|
|
231 |
methods:(Array with:(Object compiledMethodAt:#class)
|
|
232 |
with:(Object compiledMethodAt:#doesNotUnderstand:)).
|
|
233 |
Class addChangeRecordForClass:newClass.
|
77
|
234 |
].
|
|
235 |
^ newClass
|
202
|
236 |
!
|
|
237 |
|
|
238 |
subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
|
|
239 |
"create a new class which has nil as superclass
|
|
240 |
- i.e. traps into doesNotUnderstand: for all of its messages."
|
|
241 |
|
|
242 |
^ self nilSubclass:(thisContext selector) args:(thisContext args)
|
77
|
243 |
!
|
|
244 |
|
|
245 |
variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
|
159
|
246 |
"create a new class which has nil as superclass
|
|
247 |
- i.e. traps into doesNotUnderstand: for all of its messages."
|
77
|
248 |
|
202
|
249 |
^ self nilSubclass:(thisContext selector) args:(thisContext args)
|
77
|
250 |
!
|
|
251 |
|
|
252 |
variableByteSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
|
159
|
253 |
"create a new class which has nil as superclass
|
|
254 |
- i.e. traps into doesNotUnderstand: for all of its messages."
|
77
|
255 |
|
202
|
256 |
^ self nilSubclass:(thisContext selector) args:(thisContext args)
|
77
|
257 |
! !
|