comparison src/monoize.sml @ 266:7a7efbb3e354

Monoize aggregates
author Adam Chlipala <adamc@hcoop.net>
date Sun, 31 Aug 2008 16:26:50 -0400
parents b66e692422a4
children f31e8da68e90
comparison
equal deleted inserted replaced
265:b66e692422a4 266:7a7efbb3e354
923 _), _), 923 _), _),
924 _), _), 924 _), _),
925 _) => ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFfi ("Basis", "string"), loc), 925 _) => ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFfi ("Basis", "string"), loc),
926 (L'.EPrim (Prim.String "COUNT(*)"), loc)), loc), 926 (L'.EPrim (Prim.String "COUNT(*)"), loc)), loc),
927 fm) 927 fm)
928 928
929 | L.ECApp (
930 (L.ECApp (
931 (L.ECApp (
932 (L.ECApp (
933 (L.EFfi ("Basis", "sql_aggregate"), _),
934 _), _),
935 _), _),
936 _), _),
937 _) =>
938 let
939 val s = (L'.TFfi ("Basis", "string"), loc)
940 fun sc s = (L'.EPrim (Prim.String s), loc)
941 in
942 ((L'.EAbs ("c", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc),
943 (L'.EAbs ("e1", s, (L'.TFun (s, s), loc),
944 strcat loc [(L'.ERel 1, loc),
945 sc "(",
946 (L'.ERel 0, loc),
947 sc ")"]), loc)), loc),
948 fm)
949 end
950
951 | L.EFfi ("Basis", "sql_summable_int") => ((L'.ERecord [], loc), fm)
952 | L.EFfi ("Basis", "sql_summable_float") => ((L'.ERecord [], loc), fm)
953 | L.ECApp ((L.EFfi ("Basis", "sql_avg"), _), _) =>
954 ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFfi ("Basis", "string"), loc),
955 (L'.EPrim (Prim.String "AVG"), loc)), loc),
956 fm)
957 | L.ECApp ((L.EFfi ("Basis", "sql_sum"), _), _) =>
958 ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFfi ("Basis", "string"), loc),
959 (L'.EPrim (Prim.String "SUM"), loc)), loc),
960 fm)
961
962 | L.EFfi ("Basis", "sql_maxable_int") => ((L'.ERecord [], loc), fm)
963 | L.EFfi ("Basis", "sql_maxable_float") => ((L'.ERecord [], loc), fm)
964 | L.EFfi ("Basis", "sql_maxable_string") => ((L'.ERecord [], loc), fm)
965 | L.ECApp ((L.EFfi ("Basis", "sql_max"), _), _) =>
966 ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFfi ("Basis", "string"), loc),
967 (L'.EPrim (Prim.String "MAX"), loc)), loc),
968 fm)
969 | L.ECApp ((L.EFfi ("Basis", "sql_min"), _), _) =>
970 ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFfi ("Basis", "string"), loc),
971 (L'.EPrim (Prim.String "MIN"), loc)), loc),
972 fm)
973
929 | L.EApp ( 974 | L.EApp (
930 (L.ECApp ( 975 (L.ECApp (
931 (L.ECApp ((L.EFfi ("Basis", "cdata"), _), _), _), 976 (L.ECApp ((L.EFfi ("Basis", "cdata"), _), _), _),
932 _), _), 977 _), _),
933 se) => 978 se) =>