mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			1 line
		
	
	
		
			10 KiB
		
	
	
	
		
			Smalltalk
		
	
	
	
	
	
			
		
		
	
	
			1 line
		
	
	
		
			10 KiB
		
	
	
	
		
			Smalltalk
		
	
	
	
	
	
'From Pharo4.0 of 18 March 2013 [Latest update: #40152] on 6 August 2014 at 10:12:19.27738 pm'!
 | 
						|
Object subclass: #Boolean
 | 
						|
	instanceVariableNames: ''
 | 
						|
	classVariableNames: ''
 | 
						|
	poolDictionaries: ''
 | 
						|
	category: 'Kernel-Objects'!
 | 
						|
Boolean subclass: #False
 | 
						|
	instanceVariableNames: ''
 | 
						|
	classVariableNames: ''
 | 
						|
	poolDictionaries: ''
 | 
						|
	category: 'Kernel-Objects'!
 | 
						|
Boolean subclass: #True
 | 
						|
	instanceVariableNames: ''
 | 
						|
	classVariableNames: ''
 | 
						|
	poolDictionaries: ''
 | 
						|
	category: 'Kernel-Objects'!
 | 
						|
 | 
						|
!Boolean methodsFor: '*monticellofiletree-core' stamp: 'dkh 4/6/2012 15:56:14'!
 | 
						|
writeCypressJsonOn: aStream forHtml: forHtml indent: startIndent
 | 
						|
    "by default ignore <forHtml> ... <forHtml> is used for Dictionary and Array, i.e., container objects and String which actually encodes itself differently for HTML"
 | 
						|
 | 
						|
    aStream nextPutAll: self printString! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'copying' stamp: 'tk 8/20/1998 16:07'!
 | 
						|
veryDeepCopyWith: deepCopier
 | 
						|
	"Return self.  I can't be copied.  Do not record me."! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'copying'!
 | 
						|
deepCopy 
 | 
						|
	"Receiver has two concrete subclasses, True and False.
 | 
						|
	Only one instance of each should be made, so return self."! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'copying'!
 | 
						|
shallowCopy 
 | 
						|
	"Receiver has two concrete subclasses, True and False.
 | 
						|
	Only one instance of each should be made, so return self."! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'logical operations'!
 | 
						|
not
 | 
						|
	"Negation. Answer true if the receiver is false, answer false if the 
 | 
						|
	receiver is true."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'logical operations'!
 | 
						|
& aBoolean 
 | 
						|
	"Evaluating conjunction. Evaluate the argument. Then answer true if 
 | 
						|
	both the receiver and the argument are true."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'logical operations'!
 | 
						|
| aBoolean 
 | 
						|
	"Evaluating disjunction (OR). Evaluate the argument. Then answer true 
 | 
						|
	if either the receiver or the argument is true."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'logical operations' stamp: 'stephane.ducasse 5/20/2009 21:28'!
 | 
						|
==> aBlock
 | 
						|
	"The material conditional, also known as the material implication or truth functional conditional.
 | 
						|
	Correspond to not ... or ... and does not correspond to the English if...then... construction.
 | 
						|
		
 | 
						|
	 known as:
 | 
						|
			b if a 
 | 
						|
			a implies b
 | 
						|
			if a then b
 | 
						|
			b is a consequence of a
 | 
						|
			a therefore b (but note: 'it is raining therefore it is cloudy' is implication; 'it is autumn therefore the leaves are falling' is equivalence).
 | 
						|
		
 | 
						|
	Here is the truth table for material implication:
 | 
						|
	
 | 
						|
	   p   |   q   |   p ==> q
 | 
						|
	-------|-------|-------------
 | 
						|
	   T   |   T   |      T
 | 
						|
	   T   |   F   |      F
 | 
						|
	   F   |   T   |      T
 | 
						|
	   F   |   F   |      T
 | 
						|
	"
 | 
						|
 | 
						|
	^self not or: [aBlock value]! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'logical operations'!
 | 
						|
eqv: aBoolean 
 | 
						|
	"Answer true if the receiver is equivalent to aBoolean."
 | 
						|
 | 
						|
	^self == aBoolean! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'controlling'!
 | 
						|
or: alternativeBlock 
 | 
						|
	"Nonevaluating disjunction. If the receiver is false, answer the value of 
 | 
						|
	the argument, alternativeBlock; otherwise answer true without 
 | 
						|
	evaluating the argument."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'controlling'!
 | 
						|
ifFalse: alternativeBlock 
 | 
						|
	"If the receiver is true (i.e., the condition is true), then the value is the 
 | 
						|
	true alternative, which is nil. Otherwise answer the result of evaluating 
 | 
						|
	the argument, alternativeBlock. Create an error notification if the 
 | 
						|
	receiver is nonBoolean. Execution does not actually reach here because 
 | 
						|
	the expression is compiled in-line."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'controlling'!
 | 
						|
ifTrue: trueAlternativeBlock ifFalse: falseAlternativeBlock
 | 
						|
	"If the receiver is true (i.e., the condition is true), then answer the value 
 | 
						|
	of the argument trueAlternativeBlock. If the receiver is false, answer the 
 | 
						|
	result of evaluating the argument falseAlternativeBlock. If the receiver 
 | 
						|
	is a nonBoolean then create an error notification. Execution does not 
 | 
						|
	actually reach here because the expression is compiled in-line."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'controlling'!
 | 
						|
ifFalse: falseAlternativeBlock ifTrue: trueAlternativeBlock 
 | 
						|
	"Same as ifTrue:ifFalse:."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'controlling'!
 | 
						|
ifTrue: alternativeBlock 
 | 
						|
	"If the receiver is false (i.e., the condition is false), then the value is the 
 | 
						|
	false alternative, which is nil. Otherwise answer the result of evaluating 
 | 
						|
	the argument, alternativeBlock. Create an error notification if the 
 | 
						|
	receiver is nonBoolean. Execution does not actually reach here because 
 | 
						|
	the expression is compiled in-line."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'controlling'!
 | 
						|
and: alternativeBlock 
 | 
						|
	"Nonevaluating conjunction. If the receiver is true, answer the value of 
 | 
						|
	the argument, alternativeBlock; otherwise answer false without 
 | 
						|
	evaluating the argument."
 | 
						|
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
!Boolean methodsFor: '*Fuel' stamp: 'MartinDias 2/21/2013 12:49'!
 | 
						|
fuelAccept: aGeneralMapper
 | 
						|
 | 
						|
	^aGeneralMapper visitHookPrimitive: self! !
 | 
						|
 | 
						|
!Boolean methodsFor: '*Fuel' stamp: 'MartinDias 2/21/2013 12:49'!
 | 
						|
serializeOn: anEncoder
 | 
						|
	"Do nothing"! !
 | 
						|
 | 
						|
!Boolean methodsFor: '*NativeBoost-Core' stamp: 'cb 4/22/2013 14:15'!
 | 
						|
asNBExternalType: gen
 | 
						|
	"boolean value in argument description array defines a simple 0 or 1 constant
 | 
						|
	
 | 
						|
	#( true false )  - turned into a 1 and 0
 | 
						|
	"
 | 
						|
	^ NBFFIConst value: self asBit! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'printing'!
 | 
						|
storeOn: aStream 
 | 
						|
	"Refer to the comment in Object|storeOn:."
 | 
						|
 | 
						|
	self printOn: aStream! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'printing' stamp: 'apb 4/21/2006 09:22'!
 | 
						|
isLiteral 
 | 
						|
	^ true! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'self evaluating' stamp: 'sd 7/31/2005 21:45'!
 | 
						|
isSelfEvaluating
 | 
						|
	^ true! !
 | 
						|
 | 
						|
!Boolean methodsFor: 'converting' stamp: 'CamilloBruni 3/27/2012 17:20'!
 | 
						|
asBit
 | 
						|
	"convert myself to an Integer representing 1 for true and 0 for false"
 | 
						|
	self subclassResponsibility! !
 | 
						|
 | 
						|
 | 
						|
!Boolean class methodsFor: '*System-Settings-Browser' stamp: 'alain.plantec 3/18/2009 14:48'!
 | 
						|
settingInputWidgetForNode: aSettingNode
 | 
						|
	^ aSettingNode inputWidgetForBoolean! !
 | 
						|
 | 
						|
!Boolean class methodsFor: '*NativeBoost-Core' stamp: 'IgorStasenko 8/13/2013 16:47'!
 | 
						|
asNBExternalType: gen
 | 
						|
	^ NBBool asNBExternalType: gen! !
 | 
						|
 | 
						|
!Boolean class methodsFor: 'instance creation'!
 | 
						|
new
 | 
						|
	self error: 'You may not create any more Booleans - this is two-valued logic'! !
 | 
						|
 | 
						|
 | 
						|
!False methodsFor: 'printing'!
 | 
						|
printOn: aStream 
 | 
						|
 | 
						|
	aStream nextPutAll: 'false'! !
 | 
						|
 | 
						|
!False methodsFor: 'logical operations'!
 | 
						|
not
 | 
						|
	"Negation -- answer true since the receiver is false."
 | 
						|
 | 
						|
	^true! !
 | 
						|
 | 
						|
!False methodsFor: 'logical operations' stamp: 'md 7/30/2005 18:05'!
 | 
						|
& aBoolean 
 | 
						|
	"Evaluating conjunction -- answer false since receiver is false."
 | 
						|
 | 
						|
	^self! !
 | 
						|
 | 
						|
!False methodsFor: 'logical operations'!
 | 
						|
| aBoolean 
 | 
						|
	"Evaluating disjunction (OR) -- answer with the argument, aBoolean."
 | 
						|
 | 
						|
	^aBoolean! !
 | 
						|
 | 
						|
!False methodsFor: 'logical operations' stamp: 'CamilloBruni 8/1/2012 16:25'!
 | 
						|
xor: aBoolean
 | 
						|
	^aBoolean value! !
 | 
						|
 | 
						|
!False methodsFor: 'controlling'!
 | 
						|
or: alternativeBlock 
 | 
						|
	"Nonevaluating disjunction -- answer value of alternativeBlock."
 | 
						|
 | 
						|
	^alternativeBlock value! !
 | 
						|
 | 
						|
!False methodsFor: 'controlling'!
 | 
						|
ifFalse: alternativeBlock 
 | 
						|
	"Answer the value of alternativeBlock. Execution does not actually
 | 
						|
	reach here because the expression is compiled in-line."
 | 
						|
 | 
						|
	^alternativeBlock value! !
 | 
						|
 | 
						|
!False methodsFor: 'controlling'!
 | 
						|
ifTrue: trueAlternativeBlock ifFalse: falseAlternativeBlock 
 | 
						|
	"Answer the value of falseAlternativeBlock. Execution does not
 | 
						|
	actually reach here because the expression is compiled in-line."
 | 
						|
 | 
						|
	^falseAlternativeBlock value! !
 | 
						|
 | 
						|
!False methodsFor: 'controlling'!
 | 
						|
ifFalse: falseAlternativeBlock ifTrue: trueAlternativeBlock 
 | 
						|
	"Answer the value of falseAlternativeBlock. Execution does not
 | 
						|
	actually reach here because the expression is compiled in-line."
 | 
						|
 | 
						|
	^falseAlternativeBlock value! !
 | 
						|
 | 
						|
!False methodsFor: 'controlling'!
 | 
						|
ifTrue: alternativeBlock 
 | 
						|
	"Since the condition is false, answer the value of the false alternative, 
 | 
						|
	which is nil. Execution does not actually reach here because the
 | 
						|
	expression is compiled in-line."
 | 
						|
 | 
						|
	^nil! !
 | 
						|
 | 
						|
!False methodsFor: 'controlling'!
 | 
						|
and: alternativeBlock 
 | 
						|
	"Nonevaluating conjunction -- answer with false since the receiver is false."
 | 
						|
 | 
						|
	^self! !
 | 
						|
 | 
						|
!False methodsFor: 'converting' stamp: 'IgorStasenko 12/28/2012 15:09'!
 | 
						|
asBit
 | 
						|
 | 
						|
	^ 0! !
 | 
						|
 | 
						|
 | 
						|
!True methodsFor: 'controlling'!
 | 
						|
or: alternativeBlock 
 | 
						|
	"Nonevaluating disjunction -- answer true since the receiver is true."
 | 
						|
 | 
						|
	^self! !
 | 
						|
 | 
						|
!True methodsFor: 'controlling'!
 | 
						|
ifFalse: alternativeBlock 
 | 
						|
	"Since the condition is true, the value is the true alternative, which is nil. 
 | 
						|
	Execution does not actually reach here because the expression is compiled 
 | 
						|
	in-line."
 | 
						|
 | 
						|
	^nil! !
 | 
						|
 | 
						|
!True methodsFor: 'controlling'!
 | 
						|
ifTrue: trueAlternativeBlock ifFalse: falseAlternativeBlock 
 | 
						|
	"Answer with the value of trueAlternativeBlock. Execution does not 
 | 
						|
	actually reach here because the expression is compiled in-line."
 | 
						|
 | 
						|
	^trueAlternativeBlock value! !
 | 
						|
 | 
						|
!True methodsFor: 'controlling'!
 | 
						|
ifFalse: falseAlternativeBlock ifTrue: trueAlternativeBlock 
 | 
						|
	"Answer the value of trueAlternativeBlock. Execution does not 
 | 
						|
	actually reach here because the expression is compiled in-line."
 | 
						|
 | 
						|
	^trueAlternativeBlock value! !
 | 
						|
 | 
						|
!True methodsFor: 'controlling'!
 | 
						|
ifTrue: alternativeBlock 
 | 
						|
	"Answer the value of alternativeBlock. Execution does not actually 
 | 
						|
	reach here because the expression is compiled in-line."
 | 
						|
 | 
						|
	^alternativeBlock value! !
 | 
						|
 | 
						|
!True methodsFor: 'controlling'!
 | 
						|
and: alternativeBlock 
 | 
						|
	"Nonevaluating conjunction -- answer the value of alternativeBlock since
 | 
						|
	the receiver is true."
 | 
						|
 | 
						|
	^alternativeBlock value! !
 | 
						|
 | 
						|
!True methodsFor: 'converting' stamp: 'IgorStasenko 12/28/2012 15:09'!
 | 
						|
asBit
 | 
						|
 | 
						|
	^ 1! !
 | 
						|
 | 
						|
!True methodsFor: 'printing'!
 | 
						|
printOn: aStream 
 | 
						|
 | 
						|
	aStream nextPutAll: 'true'! !
 | 
						|
 | 
						|
!True methodsFor: 'logical operations'!
 | 
						|
not
 | 
						|
	"Negation--answer false since the receiver is true."
 | 
						|
 | 
						|
	^false! !
 | 
						|
 | 
						|
!True methodsFor: 'logical operations' stamp: 'md 7/30/2005 18:04'!
 | 
						|
& aBoolean 
 | 
						|
	"Evaluating conjunction -- answer aBoolean since receiver is true."
 | 
						|
 | 
						|
	^aBoolean! !
 | 
						|
 | 
						|
!True methodsFor: 'logical operations'!
 | 
						|
| aBoolean 
 | 
						|
	"Evaluating disjunction (OR) -- answer true since the receiver is true."
 | 
						|
 | 
						|
	^self! !
 | 
						|
 | 
						|
!True methodsFor: 'logical operations' stamp: 'CamilloBruni 8/1/2012 16:25'!
 | 
						|
xor: aBoolean
 | 
						|
	^aBoolean value not! !
 | 
						|
 | 
						|
 | 
						|
!True class methodsFor: '*Fuel' stamp: 'MartinDias 2/21/2013 12:51'!
 | 
						|
materializeFrom: aDecoder
 | 
						|
	"Answer my unique instance"
 | 
						|
 | 
						|
	^ true! !
 | 
						|
 | 
						|
 | 
						|
!False class methodsFor: '*Fuel' stamp: 'MartinDias 2/21/2013 12:51'!
 | 
						|
materializeFrom: aDecoder
 | 
						|
	"Answer my unique instance"
 | 
						|
 | 
						|
	^ false! !
 | 
						|
 |