diff src/compiler.sml @ 1362:fd34210bc3e5

Add an extra Especialize pass before Rpcify
author Adam Chlipala <adam@chlipala.net>
date Fri, 24 Dec 2010 12:51:46 -0500
parents 0a2b630f2463
children b2bc8bcd546f
line wrap: on
line diff
--- a/src/compiler.sml	Thu Dec 23 18:07:05 2010 -0500
+++ b/src/compiler.sml	Fri Dec 24 12:51:46 2010 -0500
@@ -133,6 +133,21 @@
           Print.print (#print tr v);
           print "\n"))
 
+fun runPrintToFile (tr : ('src, 'dst) transform) input fname =
+    (ErrorMsg.resetErrors ();
+     case #func tr input of
+         NONE => print "Failure\n"
+       | SOME v =>
+         let
+             val outf = TextIO.openOut fname
+             val str = Print.openOut {dst = outf, wid = 80}
+         in
+             print "Success\n";
+             Print.fprint str (#print tr v);
+             Print.PD.PPS.closeStream str;
+             TextIO.closeOut outf
+         end)
+
 fun time (tr : ('src, 'dst) transform) input =
     let
         val (_, pmap) = #time tr (input, [])
@@ -159,6 +174,18 @@
              print "\n")
     end
 
+fun runPrintCoreFuncs (tr : ('src, Core.file) transform) input =
+    (ErrorMsg.resetErrors ();
+     case #func tr input of
+         NONE => print "Failure\n"
+       | SOME file =>
+         (print "Success\n";
+          app (fn (d, _) =>
+                  case d of
+                      Core.DVal (x, _, t, _, _) => Print.preface(x, CorePrint.p_con CoreEnv.empty t)
+                    | Core.DValRec xts => app (fn (x, _, t, _, _) => Print.preface(x, CorePrint.p_con CoreEnv.empty t)) xts
+                    | _ => ()) file))
+
 val parseUrs =
     {func = fn filename => let
                    val fname = OS.FileSys.tmpName ()
@@ -1060,12 +1087,15 @@
 
 val toShake1 = transform shake "shake1" o toCore_untangle
 
+val toEspecialize1' = transform especialize "especialize1'" o toShake1
+val toShake1' = transform shake "shake1'" o toEspecialize1'
+
 val rpcify = {
     func = Rpcify.frob,
     print = CorePrint.p_file CoreEnv.empty
 }
 
-val toRpcify = transform rpcify "rpcify" o toShake1
+val toRpcify = transform rpcify "rpcify" o toShake1'
 
 val toCore_untangle2 = transform core_untangle "core_untangle2" o toRpcify
 val toShake2 = transform shake "shake2" o toCore_untangle2
@@ -1264,7 +1294,7 @@
                       ^ " " ^ #compile proto
                       ^ " -c " ^ cname ^ " -o " ^ oname
 
-        val link = "gcc -Werror -O3 -lm -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ lib ^ " " ^ mhash ^ " " ^ oname
+        val link = "gcc -Werror -O3 -lm -lcrypt -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ lib ^ " " ^ mhash ^ " " ^ oname
                    ^ " -o " ^ ename
 
         val (compile, link) =