author | Stefan Vogel <sv@exept.de> |
Tue, 18 Jul 2000 10:57:43 +0200 | |
changeset 5467 | 248b61f615c8 |
parent 4878 | 1a64a89d6c01 |
child 5825 | 6743e22cd010 |
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 |
||
5467
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
89 |
|
698 | 90 |
!Boolean methodsFor:'binary storage'! |
91 |
||
92 |
hasSpecialBinaryRepresentation |
|
93 |
"return true, if the receiver has a special binary representation" |
|
94 |
||
3070 | 95 |
^ true |
698 | 96 |
! ! |
97 |
||
4878 | 98 |
!Boolean methodsFor:'blocked'! |
99 |
||
100 |
onChangeSend:selector to:someOne |
|
101 |
"/ not really an error ... |
|
102 |
"/ self error:'should not be invoked for booleans' |
|
103 |
! ! |
|
104 |
||
422 | 105 |
!Boolean methodsFor:'converting'! |
106 |
||
2416 | 107 |
decodeAsLiteralArray |
108 |
"given a literalEncoding in the receiver, |
|
109 |
create & return the corresponding object. |
|
110 |
The inverse operation to #literalArrayEncoding." |
|
111 |
||
112 |
^ self |
|
113 |
||
114 |
"Created: 25.2.1997 / 19:16:43 / cg" |
|
115 |
"Modified: 25.2.1997 / 19:17:45 / cg" |
|
116 |
! |
|
117 |
||
422 | 118 |
literalArrayEncoding |
1245 | 119 |
"encode myself as an array literal, from which a copy of the receiver |
120 |
can be reconstructed with #decodeAsLiteralArray." |
|
422 | 121 |
|
122 |
^ self |
|
123 |
||
124 |
"Modified: 5.9.1995 / 22:46:57 / claus" |
|
1245 | 125 |
"Modified: 22.4.1996 / 13:00:05 / cg" |
422 | 126 |
! ! |
127 |
||
1 | 128 |
!Boolean methodsFor:'copying'! |
129 |
||
159 | 130 |
copy |
131 |
"return a shallow copy of the receiver |
|
132 |
- since both true and false are unique, return the receiver" |
|
133 |
||
134 |
^ self |
|
135 |
! |
|
136 |
||
12 | 137 |
deepCopyUsing:aDictionary |
138 |
"return a deep copy of the receiver |
|
139 |
- since both true and false are unique, return the receiver" |
|
140 |
||
141 |
^ self |
|
142 |
! |
|
143 |
||
698 | 144 |
shallowCopy |
145 |
"return a shallow copy of the receiver |
|
146 |
- since both true and false are unique, return the receiver" |
|
147 |
||
148 |
^ self |
|
149 |
! |
|
150 |
||
12 | 151 |
simpleDeepCopy |
152 |
"return a deep copy of the receiver |
|
153 |
- since both true and false are unique, return the receiver" |
|
154 |
||
155 |
^ self |
|
1 | 156 |
! ! |
157 |
||
5467
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
158 |
!Boolean methodsFor:'encoding'! |
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
159 |
|
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
160 |
encodeOn:anEncoder with:aParameter |
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
161 |
|
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
162 |
anEncoder encodeBoolean:self with:aParameter |
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
163 |
|
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
164 |
|
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
165 |
! ! |
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
166 |
|
698 | 167 |
!Boolean methodsFor:'printing & storing'! |
168 |
||
169 |
printOn:aStream |
|
170 |
"append a character sequence representing the receiver to the argument, |
|
171 |
aStream" |
|
172 |
||
173 |
aStream nextPutAll:self printString |
|
174 |
! |
|
175 |
||
176 |
storeOn:aStream |
|
177 |
"append a character sequence to the argument, aStream from which the |
|
178 |
receiver can be reconstructed using readFrom:." |
|
179 |
||
180 |
^ self printOn:aStream |
|
181 |
! |
|
182 |
||
183 |
storeString |
|
184 |
"return a character sequence to the argument, aStream from which the |
|
185 |
receiver can be reconstructed using readFrom:." |
|
186 |
||
187 |
^ self printString |
|
188 |
! ! |
|
189 |
||
379 | 190 |
!Boolean methodsFor:'queries'! |
191 |
||
192 |
isLiteral |
|
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
193 |
"return true, if the receiver can be used as a literal constant in ST syntax |
379 | 194 |
(i.e. can be used in constant arrays)" |
195 |
||
196 |
^ true |
|
197 |
! ! |
|
198 |
||
4728 | 199 |
|
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
200 |
!Boolean methodsFor:'tracing'! |
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
201 |
|
4682 | 202 |
traceInto:aRequestor level:level from:referrer |
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
203 |
"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
|
204 |
|
4682 | 205 |
^ aRequestor traceBoolean:self level:level from:referrer |
4656
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
206 |
|
aa895a9835a2
added #hasSharedInstances and tracing support.
Claus Gittinger <cg@exept.de>
parents:
3070
diff
changeset
|
207 |
|
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 |
|
698 | 210 |
!Boolean class methodsFor:'documentation'! |
54 | 211 |
|
698 | 212 |
version |
5467
248b61f615c8
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4878
diff
changeset
|
213 |
^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.27 2000-07-18 08:57:43 stefan Exp $' |
1 | 214 |
! ! |