author | Claus Gittinger <cg@exept.de> |
Sun, 02 Nov 1997 20:14:50 +0100 | |
changeset 3089 | 0823aa17ac4d |
parent 3070 | 1bf5a29fddc9 |
child 4656 | aa895a9835a2 |
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:] |
|
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 |
||
68 |
isBuiltInClass |
|
1266 | 69 |
"return true if this class is known by the run-time-system. |
70 |
Here, true is returned (for my two subclasses)." |
|
3 | 71 |
|
72 |
^ true |
|
1266 | 73 |
|
74 |
"Modified: 23.4.1996 / 15:58:22 / cg" |
|
3 | 75 |
! ! |
76 |
||
698 | 77 |
!Boolean methodsFor:'binary storage'! |
78 |
||
79 |
hasSpecialBinaryRepresentation |
|
80 |
"return true, if the receiver has a special binary representation" |
|
81 |
||
3070 | 82 |
^ true |
83 |
||
84 |
"Modified: / 2.11.1997 / 14:13:56 / cg" |
|
698 | 85 |
! ! |
86 |
||
422 | 87 |
!Boolean methodsFor:'converting'! |
88 |
||
2416 | 89 |
decodeAsLiteralArray |
90 |
"given a literalEncoding in the receiver, |
|
91 |
create & return the corresponding object. |
|
92 |
The inverse operation to #literalArrayEncoding." |
|
93 |
||
94 |
^ self |
|
95 |
||
96 |
"Created: 25.2.1997 / 19:16:43 / cg" |
|
97 |
"Modified: 25.2.1997 / 19:17:45 / cg" |
|
98 |
! |
|
99 |
||
422 | 100 |
literalArrayEncoding |
1245 | 101 |
"encode myself as an array literal, from which a copy of the receiver |
102 |
can be reconstructed with #decodeAsLiteralArray." |
|
422 | 103 |
|
104 |
^ self |
|
105 |
||
106 |
"Modified: 5.9.1995 / 22:46:57 / claus" |
|
1245 | 107 |
"Modified: 22.4.1996 / 13:00:05 / cg" |
422 | 108 |
! ! |
109 |
||
1 | 110 |
!Boolean methodsFor:'copying'! |
111 |
||
159 | 112 |
copy |
113 |
"return a shallow copy of the receiver |
|
114 |
- since both true and false are unique, return the receiver" |
|
115 |
||
116 |
^ self |
|
117 |
! |
|
118 |
||
1 | 119 |
deepCopy |
120 |
"return a deep copy of the receiver |
|
121 |
- since both true and false are unique, return the receiver" |
|
122 |
||
123 |
^ self |
|
12 | 124 |
! |
125 |
||
126 |
deepCopyUsing:aDictionary |
|
127 |
"return a deep copy of the receiver |
|
128 |
- since both true and false are unique, return the receiver" |
|
129 |
||
130 |
^ self |
|
131 |
! |
|
132 |
||
698 | 133 |
shallowCopy |
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 |
simpleDeepCopy |
141 |
"return a deep copy of the receiver |
|
142 |
- since both true and false are unique, return the receiver" |
|
143 |
||
144 |
^ self |
|
1 | 145 |
! ! |
146 |
||
698 | 147 |
!Boolean methodsFor:'printing & storing'! |
148 |
||
149 |
printOn:aStream |
|
150 |
"append a character sequence representing the receiver to the argument, |
|
151 |
aStream" |
|
152 |
||
153 |
aStream nextPutAll:self printString |
|
154 |
! |
|
155 |
||
156 |
storeOn:aStream |
|
157 |
"append a character sequence to the argument, aStream from which the |
|
158 |
receiver can be reconstructed using readFrom:." |
|
159 |
||
160 |
^ self printOn:aStream |
|
161 |
! |
|
162 |
||
163 |
storeString |
|
164 |
"return a character sequence to the argument, aStream from which the |
|
165 |
receiver can be reconstructed using readFrom:." |
|
166 |
||
167 |
^ self printString |
|
168 |
! ! |
|
169 |
||
379 | 170 |
!Boolean methodsFor:'queries'! |
171 |
||
172 |
isLiteral |
|
173 |
"return true, if the receiver can be used as a literal |
|
174 |
(i.e. can be used in constant arrays)" |
|
175 |
||
176 |
^ true |
|
177 |
! ! |
|
178 |
||
698 | 179 |
!Boolean class methodsFor:'documentation'! |
54 | 180 |
|
698 | 181 |
version |
3070 | 182 |
^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.22 1997-11-02 17:03:45 cg Exp $' |
1 | 183 |
! ! |