1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
41
|
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 |
Boolean subclass:#True
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Objects'
|
|
18 |
!
|
|
19 |
|
|
20 |
True comment:'
|
|
21 |
|
5
|
22 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
41
|
23 |
All Rights Reserved
|
1
|
24 |
|
|
25 |
Class True has only one instance, true, representing logical truth.
|
|
26 |
|
41
|
27 |
$Header: /cvs/stx/stx/libbasic/True.st,v 1.5 1994-01-09 21:25:44 claus Exp $
|
1
|
28 |
'!
|
|
29 |
|
|
30 |
!True methodsFor: 'logical operations'!
|
|
31 |
|
|
32 |
& aBoolean
|
|
33 |
"return true if both the receiver and the argument are true
|
|
34 |
(since the receiver is true, return the argument, aBoolen)"
|
|
35 |
|
|
36 |
^ aBoolean
|
|
37 |
!
|
|
38 |
|
|
39 |
| aBoolean
|
|
40 |
"return true if either the receiver or the argument are true
|
|
41 |
(since the receiver is true, return true)"
|
|
42 |
|
|
43 |
^ true
|
|
44 |
!
|
|
45 |
|
|
46 |
not
|
|
47 |
"return true if the receiver is false, false otherwise
|
|
48 |
(since the receiver is true, return false)"
|
|
49 |
|
|
50 |
^ false
|
|
51 |
!
|
|
52 |
|
|
53 |
eqv:aBoolean
|
|
54 |
"return true if both the receiver and the argument are the same truth value
|
|
55 |
(since the receiver is true, return true if the argument is also)"
|
|
56 |
|
|
57 |
^ aBoolean
|
|
58 |
!
|
|
59 |
|
|
60 |
xor:aBoolean
|
|
61 |
"return true if the receiver and the argument are different truth values
|
|
62 |
(since the receiver is true, return true, if the argument is not)"
|
|
63 |
|
|
64 |
^ aBoolean not
|
|
65 |
! !
|
|
66 |
|
|
67 |
!True methodsFor: 'conditional evaluation'!
|
|
68 |
|
|
69 |
and:aBlock
|
|
70 |
"evaluate aBlock if the receiver is true.
|
|
71 |
since the receiver is known to be true,
|
|
72 |
return the value of evaluating the block.
|
|
73 |
- open coded by compiler"
|
|
74 |
|
|
75 |
^ aBlock value
|
|
76 |
!
|
|
77 |
|
|
78 |
or:aBlock
|
|
79 |
"evaluate aBlock if the receiver is false.
|
|
80 |
since the receiver is known to be true simply return true.
|
|
81 |
- open coded by compiler"
|
|
82 |
|
|
83 |
^ self
|
|
84 |
!
|
|
85 |
|
|
86 |
ifTrue:aBlock
|
|
87 |
"return the value of evaluating aBlock (since the receiver is true)
|
|
88 |
- open coded by compiler"
|
|
89 |
|
|
90 |
^ aBlock value
|
|
91 |
!
|
|
92 |
|
|
93 |
ifFalse:aBlock
|
|
94 |
"return the true alternative, nil (since the receiver is true)
|
|
95 |
- open coded by compiler"
|
|
96 |
|
|
97 |
^ nil
|
|
98 |
!
|
|
99 |
|
|
100 |
ifTrue:trueBlock ifFalse:falseBlock
|
|
101 |
"return the value of evaluating trueBlock (since the receiver is true)
|
|
102 |
- open coded by compiler"
|
|
103 |
|
|
104 |
^ trueBlock value
|
|
105 |
!
|
|
106 |
|
|
107 |
ifFalse:falseBlock ifTrue:trueBlock
|
|
108 |
"return the value of evaluating trueBlock (since the receiver is true)
|
|
109 |
- open coded by compiler"
|
|
110 |
|
|
111 |
^ trueBlock value
|
|
112 |
! !
|
|
113 |
|
|
114 |
!True methodsFor: 'printing'!
|
|
115 |
|
|
116 |
printString
|
|
117 |
"return a Character sequence representing the receiver"
|
|
118 |
|
|
119 |
^ 'true'
|
|
120 |
! !
|
2
|
121 |
|
|
122 |
!True methodsFor: 'binary storage'!
|
|
123 |
|
|
124 |
storeBinaryOn: stream manager: manager
|
41
|
125 |
"store a binary representation of the receiver on stream;
|
|
126 |
redefined, since true is stored with a special type-code"
|
|
127 |
|
2
|
128 |
stream nextPut: manager codeForTrue
|
|
129 |
! !
|