Boolean.st
author Claus Gittinger <cg@exept.de>
Sat, 09 Dec 1995 22:34:58 +0100
changeset 726 997e30ef8423
parent 698 04533375e12c
child 1119 956d62a5656c
permissions -rw-r--r--
careful with empty revision strings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
Object subclass:#Boolean
698
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    14
	 instanceVariableNames:''
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    15
	 classVariableNames:''
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    16
	 poolDictionaries:''
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    17
	 category:'Kernel-Objects'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
88
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    20
!Boolean class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    21
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    24
 COPYRIGHT (c) 1988 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    25
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    26
88
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    34
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    35
88
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    36
documentation
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    37
"
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    38
    Boolean is an abstract class defining the common protocol for logical
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    39
    values. The logical values are represented by its two subclasses True and False.
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    40
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    41
    There are no instances of Boolean in the system and there is only one
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    42
    instance of True (which is the global true) and one of False (false).
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    43
88
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    44
    Boolean redefines some messages which deal with copying Booleans,
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    45
    to make certain there is only one instance of each.
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    46
    The system will behave strange if you fiddle around here and create
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    47
    new instances of True or False (i.e. it will not recognize these new
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    48
    instances as being true or false).
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    49
"
81dacba7a63a *** empty log message ***
claus
parents: 54
diff changeset
    50
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    51
a27a279701f8 Initial revision
claus
parents:
diff changeset
    52
!Boolean class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    53
a27a279701f8 Initial revision
claus
parents:
diff changeset
    54
basicNew
a27a279701f8 Initial revision
claus
parents:
diff changeset
    55
    "catch instance creation
2
claus
parents: 1
diff changeset
    56
     - there must be exactly one instance of each - no more"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    57
a27a279701f8 Initial revision
claus
parents:
diff changeset
    58
    self error:'new instances of True/False are not allowed'
a27a279701f8 Initial revision
claus
parents:
diff changeset
    59
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
    60
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    61
!Boolean class methodsFor:'queries'!
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    62
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    63
isBuiltInClass
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    64
    "this class is known by the run-time-system"
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    65
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    66
    ^ true
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    67
! !
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    68
698
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    69
!Boolean methodsFor:'binary storage'!
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    70
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    71
hasSpecialBinaryRepresentation
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    72
    "return true, if the receiver has a special binary representation"
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    73
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    74
	^true
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    75
! !
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    76
422
claus
parents: 384
diff changeset
    77
!Boolean methodsFor:'converting'!
claus
parents: 384
diff changeset
    78
claus
parents: 384
diff changeset
    79
literalArrayEncoding
claus
parents: 384
diff changeset
    80
    "encode myself as an array literal."
claus
parents: 384
diff changeset
    81
claus
parents: 384
diff changeset
    82
    ^ self
claus
parents: 384
diff changeset
    83
claus
parents: 384
diff changeset
    84
    "Modified: 5.9.1995 / 22:46:57 / claus"
claus
parents: 384
diff changeset
    85
! !
claus
parents: 384
diff changeset
    86
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    87
!Boolean methodsFor:'copying'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    88
159
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    89
copy
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    90
    "return a shallow copy of the receiver
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    91
     - since both true and false are unique, return the receiver"
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    92
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    93
    ^ self
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    94
!
514c749165c3 *** empty log message ***
claus
parents: 92
diff changeset
    95
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    96
deepCopy
a27a279701f8 Initial revision
claus
parents:
diff changeset
    97
    "return a deep copy of the receiver
a27a279701f8 Initial revision
claus
parents:
diff changeset
    98
     - since both true and false are unique, return the receiver"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    99
a27a279701f8 Initial revision
claus
parents:
diff changeset
   100
    ^ self
12
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   101
!
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   102
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   103
deepCopyUsing:aDictionary
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   104
    "return a deep copy of the receiver
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   105
     - since both true and false are unique, return the receiver"
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   106
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   107
    ^ self
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   108
!
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   109
698
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   110
shallowCopy
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   111
    "return a shallow copy of the receiver
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   112
     - since both true and false are unique, return the receiver"
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   113
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   114
    ^ self
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   115
!
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   116
12
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   117
simpleDeepCopy
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   118
    "return a deep copy of the receiver
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   119
     - since both true and false are unique, return the receiver"
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   120
8e03bd717355 *** empty log message ***
claus
parents: 5
diff changeset
   121
    ^ self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   122
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   123
698
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   124
!Boolean methodsFor:'printing & storing'!
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   125
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   126
printOn:aStream
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   127
    "append a character sequence representing the receiver to the argument,
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   128
     aStream"
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   129
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   130
    aStream nextPutAll:self printString
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   131
!
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   132
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   133
storeOn:aStream
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   134
    "append a character sequence to the argument, aStream from which the
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   135
     receiver can be reconstructed using readFrom:."
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   136
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   137
    ^ self printOn:aStream
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   138
!
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   139
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   140
storeString
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   141
    "return  a character sequence to the argument, aStream from which the
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   142
     receiver can be reconstructed using readFrom:."
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   143
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   144
    ^ self printString
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   145
! !
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   146
379
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   147
!Boolean methodsFor:'queries'!
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   148
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   149
isLiteral
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   150
    "return true, if the receiver can be used as a literal
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   151
     (i.e. can be used in constant arrays)"
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   152
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   153
    ^ true
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   154
! !
5b5a130ccd09 revision added
claus
parents: 281
diff changeset
   155
698
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   156
!Boolean class methodsFor:'documentation'!
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 37
diff changeset
   157
698
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   158
version
04533375e12c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   159
    ^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.16 1995-12-07 21:24:46 cg Exp $'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   160
! !