comparison src/rpcify.sml @ 613:c5991cdb0c4b

Initial parsing of RPC results
author Adam Chlipala <adamc@hcoop.net>
date Sun, 15 Feb 2009 12:33:41 -0500
parents 56aaa1941dad
children 4a125bbc602d
comparison
equal deleted inserted replaced
612:d80256efc160 613:c5991cdb0c4b
101 val tfuncs = foldl 101 val tfuncs = foldl
102 (fn ((d, _), tfuncs) => 102 (fn ((d, _), tfuncs) =>
103 let 103 let
104 fun doOne ((_, n, t, _, _), tfuncs) = 104 fun doOne ((_, n, t, _, _), tfuncs) =
105 let 105 let
106 fun crawl ((t, _), args) = 106 fun crawl (t, args) =
107 case t of 107 case #1 t of
108 CApp ((CFfi ("Basis", "transaction"), _), ran) => SOME (rev args, ran) 108 CApp ((CFfi ("Basis", "transaction"), _), ran) => SOME (rev args, ran)
109 | TFun (arg, rest) => crawl (rest, arg :: args) 109 | TFun (arg, rest) => crawl (rest, arg :: args)
110 | _ => NONE 110 | _ => NONE
111 in 111 in
112 case crawl (t, []) of 112 case crawl (t, []) of
128 ((EApp ((ECApp ((ECApp ((ECApp ((EFfi ("Basis", "bind"), loc), _), _), t1), _), t2), _), 128 ((EApp ((ECApp ((ECApp ((ECApp ((EFfi ("Basis", "bind"), loc), _), _), t1), _), t2), _),
129 (EFfi ("Basis", "transaction_monad"), _)), _), 129 (EFfi ("Basis", "transaction_monad"), _)), _),
130 trans1), _), 130 trans1), _),
131 trans2) => 131 trans2) =>
132 (case (serverSide trans1, clientSide trans1, serverSide trans2, clientSide trans2) of 132 (case (serverSide trans1, clientSide trans1, serverSide trans2, clientSide trans2) of
133 (true, false, false, _) => 133 (true, false, false, true) =>
134 let 134 let
135 fun getApp (e, args) = 135 fun getApp (e, args) =
136 case #1 e of 136 case #1 e of
137 ENamed n => (n, args) 137 ENamed n => (n, args)
138 | EApp (e1, e2) => getApp (e1, e2 :: args) 138 | EApp (e1, e2) => getApp (e1, e2 :: args)
154 exported = exported, 154 exported = exported,
155 export_decls = export_decls} 155 export_decls = export_decls}
156 156
157 val ran = 157 val ran =
158 case IM.find (tfuncs, n) of 158 case IM.find (tfuncs, n) of
159 NONE => raise Fail "Rpcify: Undetected transaction function" 159 NONE => (Print.prefaces "BAD" [("e", CorePrint.p_exp CoreEnv.empty (e, loc))];
160 raise Fail "Rpcify: Undetected transaction function")
160 | SOME (_, ran) => ran 161 | SOME (_, ran) => ran
161 in 162 in
162 (EServerCall (n, args, trans2, ran), st) 163 (EServerCall (n, args, trans2, ran), st)
163 end 164 end
164 | _ => (e, st)) 165 | _ => (e, st))