diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-07-17 11:02:10 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-07-17 11:02:10 -0400 |
commit | f97f99744f08737c22c83d17b77449c78213b3f8 (patch) | |
tree | 94d7c5f9dc6a1b5643ce7c2b385d687df6399931 /src/cjrize.sml | |
parent | 555eacbc718a0fdaa7b539ab082a4e834ca583b1 (diff) |
Compiled (non-mutual) 'val rec'
Diffstat (limited to 'src/cjrize.sml')
-rw-r--r-- | src/cjrize.sml | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/cjrize.sml b/src/cjrize.sml index 5f2f69c0..cb2557f6 100644 --- a/src/cjrize.sml +++ b/src/cjrize.sml @@ -195,7 +195,36 @@ fun cifyDecl ((d, loc), sm) = in (SOME (d, loc), NONE, sm) end - | L.DValRec _ => raise Fail "Cjrize DValRec" + | L.DValRec vis => + let + val (vis, sm) = ListUtil.foldlMap + (fn ((x, n, t, e, _), sm) => + let + val (t, sm) = cifyTyp (t, sm) + + fun unravel (tAll as (t, _), eAll as (e, _)) = + case (t, e) of + (L'.TFun (dom, ran), L.EAbs (ax, _, _, e)) => + let + val (args, t, e) = unravel (ran, e) + in + ((ax, dom) :: args, t, e) + end + | (L'.TFun _, _) => + (ErrorMsg.errorAt loc "Function isn't explicit at code generation"; + ([], tAll, eAll)) + | _ => ([], tAll, eAll) + + val (args, ran, e) = unravel (t, e) + val (e, sm) = cifyExp (e, sm) + in + ((x, n, args, ran, e), sm) + end) + sm vis + in + (SOME (L'.DFunRec vis, loc), NONE, sm) + end + | L.DExport (s, n, ts) => let val (ts, sm) = ListUtil.foldlMap cifyTyp sm ts |