changeset 98:dcc5dda1645c

Fill in more types during closure conversion
author Adam Chlipala <adamc@hcoop.net>
date Thu, 10 Jul 2008 09:10:56 -0400
parents 713e01fd7924
children 5182f0c80d2e
files src/cloconv.sml tests/html_fn.lac
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/cloconv.sml	Thu Jul 03 18:11:14 2008 -0400
+++ b/src/cloconv.sml	Thu Jul 10 09:10:56 2008 -0400
@@ -140,6 +140,8 @@
             val ns = List.filter (fn n => n <> 0) ns
             val D = Ds.leave D
 
+            val envT = (L'.TRecord (map (fn n => ("fv" ^ Int.toString n, #2 (E.lookupERel env (n-1)))) ns), loc)
+
             (*val () = Print.preface ("Before", FlatPrint.p_exp FlatEnv.basis e)
             val () = List.app (fn (x, t) => preface ("Bound", box [string x,
                                                                    space,
@@ -153,11 +155,11 @@
                                  subExpInExp (n, (L'.EField ((L'.ERel 1, loc), "fv" ^ Int.toString n), loc)) e)
                              e ns
             (*val () = Print.preface (" After", FlatPrint.p_exp FlatEnv.basis body)*)
-            val body = (L'.ELet ([("env", (L'.TTop, loc), (L'.EField ((L'.ERel 0, loc), "env"), loc)),
-                                  ("arg", (L'.TTop, loc), (L'.EField ((L'.ERel 1, loc), "arg"), loc))],
+            val body = (L'.ELet ([("env", envT, (L'.EField ((L'.ERel 0, loc), "env"), loc)),
+                                  ("arg", dom, (L'.EField ((L'.ERel 1, loc), "arg"), loc))],
                                  body), loc)
                               
-            val envT = (L'.TRecord (map (fn n => ("fv" ^ Int.toString n, #2 (E.lookupERel env (n-1)))) ns), loc)
+
             val (D, fi) = Ds.func D (x, (L'.TRecord [("env", envT), ("arg", dom)], loc), ran, body)
         in
             ((L'.ERecord [("code", (L'.ECode fi, loc), (L'.TTop, loc)),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/html_fn.lac	Thu Jul 10 09:10:56 2008 -0400
@@ -0,0 +1,9 @@
+val main = fn () => <html>
+        <head>
+                <title>Hello World!</title>
+        </head>
+
+        <body>
+                <b>Hello</b> <i>World</i>!
+        </body>
+</html>