StdBool.icl 1.15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
implementation module StdBool

// ****************************************************************************************
//	Concurrent Clean Standard Library Module Version 2.0
//	Copyright 1998 University of Nijmegen
// ****************************************************************************************

import StdOverloaded

instance == Bool
where
 (==) :: !Bool !Bool -> Bool
 (==) a b
	= code inline {
			eqB
	}

instance toBool Bool
where
 toBool :: !Bool -> Bool
 toBool a
	= code inline {
			no_op
	}

instance fromBool Bool
where
 fromBool :: !Bool -> Bool
 fromBool a
	= code inline {
			no_op
	}

instance fromBool {#Char}
where
 fromBool :: !Bool -> {#Char}
 fromBool a
	= code inline {
		.d 0 1 b
			jsr BtoAC
		.o 1 0
	}

//	Logical Operators:
    
not :: !Bool -> Bool
not	a
	= code inline {
			notB
	}

(&&) infixr 3 :: !Bool Bool -> Bool
(&&) a b
	= code {
		push_b 0
		jmp_false l1
		pop_b 1
		jsr_eval 0
		pushB_a 0
		pop_a 1
	.d 0 1 b
		rtn
	:l1
		pop_a 1
	.d 0 1 b
		rtn
	}

(||) infixr 2 :: !Bool Bool -> Bool
(||) a b
	= code {
		push_b 0
		jmp_true l2
		pop_b 1
		jsr_eval 0
		pushB_a 0
		pop_a 1
	.d 0 1 b
		rtn
	:l2
		pop_a 1
	.d 0 1 b
		rtn
	}