changeset 322:aa89b73d83e4

Improve detection of opportunities for prepared statements with bool parameters
author Adam Chlipala <adamc@hcoop.net>
date Thu, 11 Sep 2008 12:22:06 -0400 (2008-09-11)
parents cd4cabaf3e52
children 5030e909fbf3
files src/cjr_print.sml src/prepare.sml
diffstat 2 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/cjr_print.sml	Thu Sep 11 12:12:22 2008 -0400
+++ b/src/cjr_print.sml	Thu Sep 11 12:22:06 2008 -0400
@@ -425,6 +425,7 @@
       | EFfiApp ("Basis", "sqlifyFloat", [e]) => [(e, Float)]
       | EFfiApp ("Basis", "sqlifyString", [e]) => [(e, String)]
       | EFfiApp ("Basis", "sqlifyBool", [e]) => [(e, Bool)]
+      | ECase (e, _, _) => [(e, Bool)]
 
       | _ => raise Fail "CjrPrint: getPargs"
 
--- a/src/prepare.sml	Thu Sep 11 12:12:22 2008 -0400
+++ b/src/prepare.sml	Thu Sep 11 12:22:06 2008 -0400
@@ -45,6 +45,12 @@
         SOME ("$" ^ Int.toString (n + 1) ^ "::text" :: ss, n + 1)
       | EFfiApp ("Basis", "sqlifyBool", [e]) =>
         SOME ("$" ^ Int.toString (n + 1) ^ "::bool" :: ss, n + 1)
+      | ECase (e,
+               [((PCon (_, PConFfi {mod = "Basis", con = "True", ...}, _), _),
+                 (EPrim (Prim.String "TRUE"), _)),
+                ((PCon (_, PConFfi {mod = "Basis", con = "False", ...}, _), _),
+                 (EPrim (Prim.String "FALSE"), _))],
+               _) => SOME ("$" ^ Int.toString (n + 1) ^ "::bool" :: ss, n + 1)
 
       | _ => NONE