author | Stefan Vogel <sv@exept.de> |
Fri, 11 Jun 2004 20:12:49 +0200 | |
changeset 8394 | da194de43766 |
parent 8305 | 7f80b5a18ffc |
child 8517 | c3827ae1ead2 |
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 |
" |
|
12 |
||
5467
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
13 |
"{ Package: 'stx:libbasic' }" |
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
14 |
|
1 | 15 |
Object subclass:#Boolean |
1245 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Kernel-Objects' |
|
1 | 20 |
! |
21 |
||
88 | 22 |
!Boolean class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 27 |
All Rights Reserved |
1 | 28 |
|
88 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
1 | 37 |
|
88 | 38 |
documentation |
39 |
" |
|
40 |
Boolean is an abstract class defining the common protocol for logical |
|
41 |
values. The logical values are represented by its two subclasses True and False. |
|
42 |
||
43 |
There are no instances of Boolean in the system and there is only one |
|
44 |
instance of True (which is the global true) and one of False (false). |
|
1 | 45 |
|
88 | 46 |
Boolean redefines some messages which deal with copying Booleans, |
47 |
to make certain there is only one instance of each. |
|
48 |
The system will behave strange if you fiddle around here and create |
|
49 |
new instances of True or False (i.e. it will not recognize these new |
|
50 |
instances as being true or false). |
|
1294 | 51 |
|
52 |
[author:] |
|
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
53 |
Claus Gittinger |
88 | 54 |
" |
55 |
! ! |
|
1 | 56 |
|
57 |
!Boolean class methodsFor:'instance creation'! |
|
58 |
||
59 |
basicNew |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
60 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
61 |
|
1 | 62 |
"catch instance creation |
2 | 63 |
- there must be exactly one instance of each - no more" |
1 | 64 |
|
65 |
self error:'new instances of True/False are not allowed' |
|
66 |
! ! |
|
67 |
||
3 | 68 |
!Boolean class methodsFor:'queries'! |
69 |
||
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
70 |
hasSharedInstances |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
71 |
"return true if this class has shared instances, that is, instances |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
72 |
with the same value are identical. |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
73 |
False is returned here, only redefined in classes which have unified |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
74 |
instances (or should be treated so)." |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
75 |
|
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
76 |
^ true |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
77 |
|
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
78 |
! |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
79 |
|
3 | 80 |
isBuiltInClass |
1266 | 81 |
"return true if this class is known by the run-time-system. |
82 |
Here, true is returned (for my two subclasses)." |
|
3 | 83 |
|
84 |
^ true |
|
1266 | 85 |
|
86 |
"Modified: 23.4.1996 / 15:58:22 / cg" |
|
3 | 87 |
! ! |
88 |
||
698 | 89 |
!Boolean methodsFor:'binary storage'! |
90 |
||
91 |
hasSpecialBinaryRepresentation |
|
92 |
"return true, if the receiver has a special binary representation" |
|
93 |
||
3070 | 94 |
^ true |
698 | 95 |
! ! |
96 |
||
4878 | 97 |
!Boolean methodsFor:'blocked'! |
98 |
||
99 |
onChangeSend:selector to:someOne |
|
100 |
"/ not really an error ... |
|
101 |
"/ self error:'should not be invoked for booleans' |
|
102 |
! ! |
|
103 |
||
422 | 104 |
!Boolean methodsFor:'converting'! |
105 |
||
5937 | 106 |
asBoolean |
107 |
^ self |
|
108 |
! |
|
109 |
||
2416 | 110 |
decodeAsLiteralArray |
111 |
"given a literalEncoding in the receiver, |
|
112 |
create & return the corresponding object. |
|
113 |
The inverse operation to #literalArrayEncoding." |
|
114 |
||
115 |
^ self |
|
116 |
||
117 |
"Created: 25.2.1997 / 19:16:43 / cg" |
|
118 |
"Modified: 25.2.1997 / 19:17:45 / cg" |
|
119 |
! |
|
120 |
||
422 | 121 |
literalArrayEncoding |
1245 | 122 |
"encode myself as an array literal, from which a copy of the receiver |
123 |
can be reconstructed with #decodeAsLiteralArray." |
|
422 | 124 |
|
125 |
^ self |
|
126 |
||
127 |
"Modified: 5.9.1995 / 22:46:57 / claus" |
|
1245 | 128 |
"Modified: 22.4.1996 / 13:00:05 / cg" |
422 | 129 |
! ! |
130 |
||
1 | 131 |
!Boolean methodsFor:'copying'! |
132 |
||
159 | 133 |
copy |
134 |
"return a shallow copy of the receiver |
|
135 |
- since both true and false are unique, return the receiver" |
|
136 |
||
137 |
^ self |
|
138 |
! |
|
139 |
||
12 | 140 |
deepCopyUsing:aDictionary |
141 |
"return a deep copy of the receiver |
|
142 |
- since both true and false are unique, return the receiver" |
|
143 |
||
144 |
^ self |
|
145 |
! |
|
146 |
||
698 | 147 |
shallowCopy |
148 |
"return a shallow copy of the receiver |
|
149 |
- since both true and false are unique, return the receiver" |
|
150 |
||
151 |
^ self |
|
152 |
! |
|
153 |
||
12 | 154 |
simpleDeepCopy |
155 |
"return a deep copy of the receiver |
|
156 |
- since both true and false are unique, return the receiver" |
|
157 |
||
158 |
^ self |
|
1 | 159 |
! ! |
160 |
||
698 | 161 |
!Boolean methodsFor:'printing & storing'! |
162 |
||
163 |
printOn:aStream |
|
164 |
"append a character sequence representing the receiver to the argument, |
|
165 |
aStream" |
|
166 |
||
167 |
aStream nextPutAll:self printString |
|
168 |
! |
|
169 |
||
170 |
storeOn:aStream |
|
171 |
"append a character sequence to the argument, aStream from which the |
|
172 |
receiver can be reconstructed using readFrom:." |
|
173 |
||
174 |
^ self printOn:aStream |
|
175 |
! |
|
176 |
||
177 |
storeString |
|
178 |
"return a character sequence to the argument, aStream from which the |
|
179 |
receiver can be reconstructed using readFrom:." |
|
180 |
||
181 |
^ self printString |
|
182 |
! ! |
|
183 |
||
5825 | 184 |
!Boolean methodsFor:'testing'! |
185 |
||
186 |
isBoolean |
|
187 |
||
188 |
" |
|
189 |
Return true, because it is a boolean. |
|
190 |
" |
|
191 |
||
192 |
^ true. |
|
8305 | 193 |
! |
194 |
||
195 |
isLiteral |
|
196 |
"return true, if the receiver can be used as a literal constant in ST syntax |
|
197 |
(i.e. can be used in constant arrays)" |
|
198 |
||
199 |
^ true |
|
5825 | 200 |
! ! |
4728 | 201 |
|
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
202 |
!Boolean methodsFor:'tracing'! |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
203 |
|
4682 | 204 |
traceInto:aRequestor level:level from:referrer |
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
205 |
"double dispatch into tracer, passing my type implicitely in the selector" |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
206 |
|
4682 | 207 |
^ aRequestor traceBoolean:self level:level from:referrer |
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
208 |
|
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
209 |
|
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
210 |
! ! |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
211 |
|
8394
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
212 |
!Boolean methodsFor:'visiting'! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
213 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
214 |
acceptVisitor:aVisitor with:aParameter |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
215 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
216 |
^ aVisitor visitBoolean:self with:aParameter |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
217 |
! ! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
218 |
|
698 | 219 |
!Boolean class methodsFor:'documentation'! |
54 | 220 |
|
698 | 221 |
version |
8394
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8305
diff
changeset
|
222 |
^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.31 2004-06-11 18:12:22 stefan Exp $' |
1 | 223 |
! ! |