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