summaryrefslogtreecommitdiff
path: root/src/cjrize.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-07-13 20:24:05 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-07-13 20:24:05 -0400
commitcf6caf0383daf8cb576edf5c1f0f736d2f4c85bd (patch)
tree5ddacbdd84964c107c03a631bf221d4fb9072691 /src/cjrize.sml
parent811a3831805bf7a87ed3a64156f4ac6f6246edb9 (diff)
Multiple arguments to web functions
Diffstat (limited to 'src/cjrize.sml')
-rw-r--r--src/cjrize.sml31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/cjrize.sml b/src/cjrize.sml
index e14f7db1..dcbfbce3 100644
--- a/src/cjrize.sml
+++ b/src/cjrize.sml
@@ -165,16 +165,27 @@ fun cifyDecl ((d, loc), sm) =
val (t, sm) = cifyTyp (t, sm)
val (d, sm) = case #1 t of
- L'.TFun (dom, ran) =>
- (case #1 e of
- L.EAbs (ax, _, _, e) =>
- let
- val (e, sm) = cifyExp (e, sm)
- in
- (L'.DFun (x, n, ax, dom, ran, e), sm)
- end
- | _ => (ErrorMsg.errorAt loc "Function isn't explicit at code generation";
- (L'.DVal ("", 0, t, (L'.EPrim (Prim.Int 0), ErrorMsg.dummySpan)), sm)))
+ L'.TFun _ =>
+ let
+ 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
+ (L'.DFun (x, n, args, ran, e), sm)
+ end
+
| _ =>
let
val (e, sm) = cifyExp (e, sm)