comparison src/monoize.sml @ 253:7f6620853c36

Monoized a WHERE clause with a comparison
author Adam Chlipala <adamc@hcoop.net>
date Sun, 31 Aug 2008 14:27:01 -0400
parents 7e9bd70ad3ce
children f8d9395575ec
comparison
equal deleted inserted replaced
252:7e9bd70ad3ce 253:7f6620853c36
610 (map (fn (x', _) => 610 (map (fn (x', _) =>
611 sc (x ^ "." ^ x')) 611 sc (x ^ "." ^ x'))
612 xts)) stables), 612 xts)) stables),
613 sc " FROM ", 613 sc " FROM ",
614 strcatComma loc (map (fn (x, _) => strcat loc [(L'.EField (gf "From", x), loc), 614 strcatComma loc (map (fn (x, _) => strcat loc [(L'.EField (gf "From", x), loc),
615 sc (" AS " ^ x)]) tables) 615 sc (" AS " ^ x)]) tables),
616 sc " WHERE ",
617 gf "Where"
616 ]), loc), 618 ]), loc),
617 fm) 619 fm)
618 | _ => poly () 620 | _ => poly ()
619 end 621 end
620 622
633 in 635 in
634 ((L'.EAbs ("f", (L'.TFun (t, s), loc), (L'.TFun (t, s), loc), 636 ((L'.EAbs ("f", (L'.TFun (t, s), loc), (L'.TFun (t, s), loc),
635 (L'.ERel 0, loc)), loc), fm) 637 (L'.ERel 0, loc)), loc), fm)
636 end 638 end
637 639
640 | L.EFfi ("Basis", "sql_int") =>
641 ((L'.EAbs ("x", (L'.TFfi ("Basis", "int"), loc), (L'.TFfi ("Basis", "string"), loc),
642 (L'.EFfiApp ("Basis", "sqlifyInt", [(L'.ERel 0, loc)]), loc)), loc),
643 fm)
644 | L.EFfi ("Basis", "sql_float") =>
645 ((L'.EAbs ("x", (L'.TFfi ("Basis", "float"), loc), (L'.TFfi ("Basis", "string"), loc),
646 (L'.EFfiApp ("Basis", "sqlifyFloat", [(L'.ERel 0, loc)]), loc)), loc),
647 fm)
648 | L.EFfi ("Basis", "sql_bool") =>
649 ((L'.EAbs ("x", (L'.TFfi ("Basis", "bool"), loc), (L'.TFfi ("Basis", "string"), loc),
650 (L'.EFfiApp ("Basis", "sqlifyBool", [(L'.ERel 0, loc)]), loc)), loc),
651 fm)
652 | L.EFfi ("Basis", "sql_string") =>
653 ((L'.EAbs ("x", (L'.TFfi ("Basis", "string"), loc), (L'.TFfi ("Basis", "string"), loc),
654 (L'.EFfiApp ("Basis", "sqlifyString", [(L'.ERel 0, loc)]), loc)), loc),
655 fm)
656
638 | L.ECApp ((L.EFfi ("Basis", "sql_subset"), _), _) => 657 | L.ECApp ((L.EFfi ("Basis", "sql_subset"), _), _) =>
639 ((L'.ERecord [], loc), fm) 658 ((L'.ERecord [], loc), fm)
640 | L.ECApp ((L.EFfi ("Basis", "sql_subset_all"), _), _) => 659 | L.ECApp ((L.EFfi ("Basis", "sql_subset_all"), _), _) =>
641 ((L'.ERecord [], loc), fm) 660 ((L'.ERecord [], loc), fm)
642 661
645 664
646 | L.EFfi ("Basis", "sql_no_limit") => 665 | L.EFfi ("Basis", "sql_no_limit") =>
647 ((L'.EPrim (Prim.String ""), loc), fm) 666 ((L'.EPrim (Prim.String ""), loc), fm)
648 | L.EFfi ("Basis", "sql_no_offset") => 667 | L.EFfi ("Basis", "sql_no_offset") =>
649 ((L'.EPrim (Prim.String ""), loc), fm) 668 ((L'.EPrim (Prim.String ""), loc), fm)
669
670 | L.EFfi ("Basis", "sql_eq") =>
671 ((L'.EPrim (Prim.String "="), loc), fm)
672 | L.EFfi ("Basis", "sql_ne") =>
673 ((L'.EPrim (Prim.String "<>"), loc), fm)
674 | L.EFfi ("Basis", "sql_lt") =>
675 ((L'.EPrim (Prim.String "<"), loc), fm)
676 | L.EFfi ("Basis", "sql_le") =>
677 ((L'.EPrim (Prim.String "<="), loc), fm)
678 | L.EFfi ("Basis", "sql_gt") =>
679 ((L'.EPrim (Prim.String ">"), loc), fm)
680 | L.EFfi ("Basis", "sql_ge") =>
681 ((L'.EPrim (Prim.String ">="), loc), fm)
682
683 | L.ECApp (
684 (L.ECApp (
685 (L.ECApp (
686 (L.ECApp (
687 (L.EFfi ("Basis", "sql_comparison"), _),
688 _), _),
689 _), _),
690 _), _),
691 _) =>
692 let
693 val s = (L'.TFfi ("Basis", "string"), loc)
694 fun sc s = (L'.EPrim (Prim.String s), loc)
695 in
696 ((L'.EAbs ("c", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc),
697 (L'.EAbs ("e1", s, (L'.TFun (s, s), loc),
698 (L'.EAbs ("e2", s, s,
699 strcat loc [(L'.ERel 1, loc),
700 sc " ",
701 (L'.ERel 2, loc),
702 sc " ",
703 (L'.ERel 0, loc)]), loc)), loc)), loc),
704 fm)
705 end
706
707 | L.ECApp (
708 (L.ECApp (
709 (L.ECApp (
710 (L.ECApp (
711 (L.ECApp (
712 (L.ECApp (
713 (L.ECApp (
714 (L.EFfi ("Basis", "sql_field"), _),
715 _), _),
716 _), _),
717 _), _),
718 _), _),
719 _), _),
720 (L.CName tab, _)), _),
721 (L.CName field, _)) => ((L'.EPrim (Prim.String (tab ^ "." ^ field)), loc), fm)
650 722
651 | L.EApp ( 723 | L.EApp (
652 (L.ECApp ( 724 (L.ECApp (
653 (L.ECApp ((L.EFfi ("Basis", "cdata"), _), _), _), 725 (L.ECApp ((L.EFfi ("Basis", "cdata"), _), _), _),
654 _), _), 726 _), _),