diff src/cjr_print.sml @ 280:fdd7a698be01

Compiling a parametrized query the inefficient way
author Adam Chlipala <adamc@hcoop.net>
date Tue, 02 Sep 2008 17:31:45 -0400
parents 137744c5b1ae
children 0236d9412ad2
line wrap: on
line diff
--- a/src/cjr_print.sml	Tue Sep 02 16:18:05 2008 -0400
+++ b/src/cjr_print.sml	Tue Sep 02 17:31:45 2008 -0400
@@ -881,7 +881,7 @@
                                case ek of
                                    Core.Link => fields
                                  | Core.Action =>
-                                   case List.last ts of
+                                   case List.nth (ts, length ts - 2) of
                                        (TRecord i, _) =>
                                        let
                                            val xts = E.lookupStruct env i
@@ -1222,12 +1222,12 @@
                     case ek of
                         Core.Link => (ts, string "", string "")
                       | Core.Action =>
-                        case List.last ts of
+                        case List.nth (ts, length ts - 2) of
                             (TRecord i, _) =>
                             let
                                 val xts = E.lookupStruct env i
                             in
-                                (List.drop (ts, 1),
+                                (List.take (ts, length ts - 2),
                                  box [box (map (fn (x, t) => box [p_typ env t,
                                                                   space,
                                                                   string "lw_input_",
@@ -1324,10 +1324,9 @@
                           p_list_sep (box [string ",", space])
                                      (fn x => x)
                                      (string "ctx"
-                                      :: ListUtil.mapi (fn (i, _) => string ("arg" ^ Int.toString i)) ts
-                                      @ [string "lw_unit_v"]),
+                                      :: ListUtil.mapi (fn (i, _) => string ("arg" ^ Int.toString i)) ts),
                           inputsVar,
-                          string ");",
+                          string ", lw_unit_v);",
                           newline,
                           string "return;",
                           newline,