StdString.icl 1.7 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
implementation module StdString

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

import	StdOverloaded

instance == {#Char}
where
 (==) :: !{#Char} !{#Char} -> Bool
 (==) a b
	= code inline {
		.d 2 0
			jsr eqAC
		.o 0 1 b	
	}

instance < {#Char}
where
 (<) :: !{#Char} !{#Char} -> Bool
 (<) a b
	= code inline {
		.d 2 0
			jsr cmpAC
		.o 0 1 i
			pushI 0
			gtI
	}

instance toString Int
where
 toString a
	= code inline {
		.d 0 1 i
			jsr ItoAC
		.o 1 0
	}

instance toString Char
where
 toString a
	= code inline {
			CtoAC
	}

instance toString Real
where
 toString a
	= code inline {
		.d 0 2 r
			jsr RtoAC
		.o 1 0
	}
instance toString Bool
where
 toString :: !Bool -> {#Char}
 toString a
	= code inline {
		.d 0 1 b
			jsr BtoAC
		.o 1 0
	}

instance toString {#Char}
where
 toString :: !{#Char} -> {#Char} //	dummy
 toString a
	= code inline {
		no_op
	}

instance fromString {#Char}
where
 fromString :: !{#Char} -> {#Char} //	dummy
 fromString a
	= code inline {
		no_op
	}

instance % {#Char}
where
 (%) ::!{#Char} !(!Int,!Int) -> {#Char}
 (%) str (a,b)
	= code inline {
		.d 1 2 ii
			jsr sliceAC
		.o 1 0
	}

instance +++ {#Char}
where
 (+++) :: !{#Char} !{#Char} -> {#Char}
 (+++) a b
	= code inline {
		.d 2 0
			jsr catAC
		.o 1 0
	}

(+++.) infixr 5 :: !{#Char} !{#Char} -> .{#Char}
(+++.) a b
	= code inline {
		.d 2 0
			jsr catAC
		.o 1 0
	}

(:=) infixl 9 :: !{#Char} !(!Int,!Char) -> {#Char}	//	update i-th element
(:=) s (i,c)
	= code inline {
		.d 1 2 ic
			jsr updateAC
		.o 1 0
	}