Mercurial > urweb
comparison src/iflow.sml @ 1224:3950cf1f5736
Complete update records with fields that are not being set
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 11 Apr 2010 13:18:32 -0400 |
parents | 62af4cacd191 |
children | df5bd4115267 |
comparison
equal
deleted
inserted
replaced
1223:62af4cacd191 | 1224:3950cf1f5736 |
---|---|
1832 Delete = #Delete t, | 1832 Delete = #Delete t, |
1833 Update = c :: #Update t} | 1833 Update = c :: #Update t} |
1834 | 1834 |
1835 end | 1835 end |
1836 | 1836 |
1837 val tabs = ref (SM.empty : string list SM.map) | |
1838 | |
1837 fun evalExp env (e as (_, loc), st) = | 1839 fun evalExp env (e as (_, loc), st) = |
1838 let | 1840 let |
1839 fun default () = | 1841 fun default () = |
1840 let | 1842 let |
1841 val (st, nv) = St.nextVar st | 1843 val (st, nv) = St.nextVar st |
2137 in | 2139 in |
2138 ((x, e), st) | 2140 ((x, e), st) |
2139 end) | 2141 end) |
2140 st fs | 2142 st fs |
2141 | 2143 |
2144 val fs' = case SM.find (!tabs, "uw_" ^ tab) of | |
2145 NONE => raise Fail "Iflow.evalExp: Updating unknown table" | |
2146 | SOME fs' => fs' | |
2147 | |
2148 val fs = foldl (fn (f, fs) => | |
2149 if List.exists (fn (f', _) => f' = f) fs then | |
2150 fs | |
2151 else | |
2152 (f, Proj (Var old, f)) :: fs) fs fs' | |
2153 | |
2142 val (p, st) = case expIn (e, st) of | 2154 val (p, st) = case expIn (e, st) of |
2143 (inl e, _) => raise Fail "Iflow.evalExp: UPDATE with non-boolean" | 2155 (inl e, _) => raise Fail "Iflow.evalExp: UPDATE with non-boolean" |
2144 | (inr p, st) => (p, st) | 2156 | (inr p, st) => (p, st) |
2145 | 2157 |
2146 val p = And (p, | 2158 val p = And (p, |
2186 DExport (_, _, n, _, _, _) => IS.add (exptd, n) | 2198 DExport (_, _, n, _, _, _) => IS.add (exptd, n) |
2187 | _ => exptd) IS.empty file | 2199 | _ => exptd) IS.empty file |
2188 | 2200 |
2189 fun decl ((d, _), (vals, inserts, deletes, updates, client, insert, delete, update)) = | 2201 fun decl ((d, _), (vals, inserts, deletes, updates, client, insert, delete, update)) = |
2190 case d of | 2202 case d of |
2191 DVal (_, n, _, e, _) => | 2203 DTable (tab, fs, _, _) => |
2204 (tabs := SM.insert (!tabs, tab, map #1 fs); | |
2205 (vals, inserts, deletes, updates, client, insert, delete, update)) | |
2206 | DVal (_, n, _, e, _) => | |
2192 let | 2207 let |
2193 val isExptd = IS.member (exptd, n) | 2208 val isExptd = IS.member (exptd, n) |
2194 | 2209 |
2195 fun deAbs (e, env, nv, p) = | 2210 fun deAbs (e, env, nv, p) = |
2196 case #1 e of | 2211 case #1 e of |
2246 val () = reset () | 2261 val () = reset () |
2247 | 2262 |
2248 val (vals, inserts, deletes, updates, client, insert, delete, update) = | 2263 val (vals, inserts, deletes, updates, client, insert, delete, update) = |
2249 foldl decl ([], [], [], [], [], [], [], []) file | 2264 foldl decl ([], [], [], [], [], [], [], []) file |
2250 | 2265 |
2266 | |
2251 val decompH = decomp true (fn (e1, e2) => e1 andalso e2 ()) | 2267 val decompH = decomp true (fn (e1, e2) => e1 andalso e2 ()) |
2252 val decompG = decomp false (fn (e1, e2) => e1 orelse e2 ()) | 2268 val decompG = decomp false (fn (e1, e2) => e1 orelse e2 ()) |
2253 | 2269 |
2254 fun doDml (cmds, pols) = | 2270 fun doDml (cmds, pols) = |
2255 app (fn (loc, p) => | 2271 app (fn (loc, p) => |