diff src/cjrize.sml @ 316:04ebfe929a98

Unpolyed a polymorphic function of two arguments
author Adam Chlipala <adamc@hcoop.net>
date Thu, 11 Sep 2008 10:14:59 -0400
parents 52d4c60518d4
children e976b187d73a
line wrap: on
line diff
--- a/src/cjrize.sml	Thu Sep 11 09:36:47 2008 -0400
+++ b/src/cjrize.sml	Thu Sep 11 10:14:59 2008 -0400
@@ -233,10 +233,17 @@
         end
       | L.EApp (e1, e2) =>
         let
-            val (e1, sm) = cifyExp (e1, sm)
-            val (e2, sm) = cifyExp (e2, sm)
+            fun unravel (e, args) =
+                case e of
+                    (L.EApp (e1, e2), _) => unravel (e1, e2 :: args)
+                  | _ => (e, args)
+
+            val (f, es) = unravel (e1, [e2])
+
+            val (f, sm) = cifyExp (f, sm)
+            val (es, sm) = ListUtil.foldlMap cifyExp sm es
         in
-            ((L'.EApp (e1, e2), loc), sm)
+            ((L'.EApp (f, es), loc), sm)
         end
       | L.EAbs _ => (ErrorMsg.errorAt loc "Anonymous function remains at code generation";
                      Print.prefaces' [("Function", MonoPrint.p_exp MonoEnv.empty eAll)];