Mercurial > urweb
comparison src/rpcify.sml @ 608:330a7de47914
Export RPC functions and push RPC calls through to Mono
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 15 Feb 2009 09:27:36 -0500 |
parents | 0dd40b6bfdf3 |
children | 56aaa1941dad |
comparison
equal
deleted
inserted
replaced
607:0dd40b6bfdf3 | 608:330a7de47914 |
---|---|
51 "get", | 51 "get", |
52 "set", | 52 "set", |
53 "alert"]) | 53 "alert"]) |
54 | 54 |
55 type state = { | 55 type state = { |
56 exps : int IM.map, | 56 cpsed : int IM.map, |
57 decls : (string * int * con * exp * string) list | 57 cps_decls : (string * int * con * exp * string) list, |
58 | |
59 exported : IS.set, | |
60 export_decls : decl list | |
58 } | 61 } |
59 | 62 |
60 fun frob file = | 63 fun frob file = |
61 let | 64 let |
62 fun sideish (basis, ssids) = | 65 fun sideish (basis, ssids) = |
112 | EApp (e1, e2) => getApp (e1, e2 :: args) | 115 | EApp (e1, e2) => getApp (e1, e2 :: args) |
113 | _ => (ErrorMsg.errorAt loc "Mixed client/server code doesn't use a named function for server part"; | 116 | _ => (ErrorMsg.errorAt loc "Mixed client/server code doesn't use a named function for server part"; |
114 (0, [])) | 117 (0, [])) |
115 | 118 |
116 val (n, args) = getApp (trans1, []) | 119 val (n, args) = getApp (trans1, []) |
120 | |
121 val (exported, export_decls) = | |
122 if IS.member (#exported st, n) then | |
123 (#exported st, #export_decls st) | |
124 else | |
125 (IS.add (#exported st, n), | |
126 (DExport (Rpc, n), loc) :: #export_decls st) | |
127 | |
128 val st = {cpsed = #cpsed st, | |
129 cps_decls = #cps_decls st, | |
130 | |
131 exported = exported, | |
132 export_decls = export_decls} | |
117 in | 133 in |
118 (EServerCall (n, args, trans2), st) | 134 (EServerCall (n, args, trans2), st) |
119 end | 135 end |
120 | _ => (e, st)) | 136 | _ => (e, st)) |
121 | _ => (e, st) | 137 | _ => (e, st) |
126 con = fn x => x, | 142 con = fn x => x, |
127 exp = exp, | 143 exp = exp, |
128 decl = fn x => x} | 144 decl = fn x => x} |
129 st d | 145 st d |
130 in | 146 in |
131 (case #decls st of | 147 (List.revAppend (case #cps_decls st of |
132 [] => [d] | 148 [] => [d] |
133 | ds => | 149 | ds => |
134 case d of | 150 case d of |
135 (DValRec vis, loc) => [(DValRec (ds @ vis), loc)] | 151 (DValRec vis, loc) => [(DValRec (ds @ vis), loc)] |
136 | (_, loc) => [(DValRec ds, loc), d], | 152 | (_, loc) => [d, (DValRec ds, loc)], |
137 {decls = [], | 153 #export_decls st), |
138 exps = #exps st}) | 154 {cpsed = #cpsed st, |
155 cps_decls = [], | |
156 | |
157 exported = #exported st, | |
158 export_decls = []}) | |
139 end | 159 end |
140 | 160 |
141 val (file, _) = ListUtil.foldlMapConcat decl | 161 val (file, _) = ListUtil.foldlMapConcat decl |
142 {decls = [], | 162 {cpsed = IM.empty, |
143 exps = IM.empty} | 163 cps_decls = [], |
164 | |
165 exported = IS.empty, | |
166 export_decls = []} | |
144 file | 167 file |
145 in | 168 in |
146 file | 169 file |
147 end | 170 end |
148 | 171 |