comparison src/flat_util.sml @ 52:198172560b73

FFI through cloconv
author Adam Chlipala <adamc@hcoop.net>
date Sun, 22 Jun 2008 10:17:34 -0400
parents 537db4ee89f4
children 5182f0c80d2e
comparison
equal deleted inserted replaced
51:92361a008a10 52:198172560b73
59 val xts2 = sortFields xts2 59 val xts2 = sortFields xts2
60 in 60 in
61 joinL compareFields (xts1, xts2) 61 joinL compareFields (xts1, xts2)
62 end 62 end
63 | (TNamed n1, TNamed n2) => Int.compare (n1, n2) 63 | (TNamed n1, TNamed n2) => Int.compare (n1, n2)
64 | (TFfi (m1, x1), TFfi (m2, x2)) => join (String.compare (m1, m2), fn () => String.compare (x1, x2))
64 65
65 | (TTop, _) => LESS 66 | (TTop, _) => LESS
66 | (_, TTop) => GREATER 67 | (_, TTop) => GREATER
67 68
68 | (TFun _, _) => LESS 69 | (TFun _, _) => LESS
71 | (TCode _, _) => LESS 72 | (TCode _, _) => LESS
72 | (_, TCode _) => GREATER 73 | (_, TCode _) => GREATER
73 74
74 | (TRecord _, _) => LESS 75 | (TRecord _, _) => LESS
75 | (_, TRecord _) => GREATER 76 | (_, TRecord _) => GREATER
77
78 | (TNamed _, _) => LESS
79 | (_, TNamed _) => GREATER
76 80
77 and compareFields ((x1, t1), (x2, t2)) = 81 and compareFields ((x1, t1), (x2, t2)) =
78 join (String.compare (x1, x2), 82 join (String.compare (x1, x2),
79 fn () => compare (t1, t2)) 83 fn () => compare (t1, t2))
80 84
106 fn t' => 110 fn t' =>
107 (x, t'))) 111 (x, t')))
108 xts, 112 xts,
109 fn xts' => (TRecord xts', loc)) 113 fn xts' => (TRecord xts', loc))
110 | TNamed _ => S.return2 cAll 114 | TNamed _ => S.return2 cAll
115 | TFfi _ => S.return2 cAll
111 in 116 in
112 mft 117 mft
113 end 118 end
114 119
115 fun map typ c = 120 fun map typ c =
150 and mfe' ctx (eAll as (e, loc)) = 155 and mfe' ctx (eAll as (e, loc)) =
151 case e of 156 case e of
152 EPrim _ => S.return2 eAll 157 EPrim _ => S.return2 eAll
153 | ERel _ => S.return2 eAll 158 | ERel _ => S.return2 eAll
154 | ENamed _ => S.return2 eAll 159 | ENamed _ => S.return2 eAll
160 | EFfi _ => S.return2 eAll
161 | EFfiApp (m, x, es) =>
162 S.map2 (ListUtil.mapfold (fn e => mfe ctx e) es,
163 fn es' =>
164 (EFfiApp (m, x, es'), loc))
155 | ECode _ => S.return2 eAll 165 | ECode _ => S.return2 eAll
156 | EApp (e1, e2) => 166 | EApp (e1, e2) =>
157 S.bind2 (mfe ctx e1, 167 S.bind2 (mfe ctx e1,
158 fn e1' => 168 fn e1' =>
159 S.map2 (mfe ctx e2, 169 S.map2 (mfe ctx e2,