comparison src/sqlcache.sml @ 2260:03b10c7fab9a

Begin work on cache merging.
author Ziv Scully <ziv@mit.edu>
date Mon, 28 Sep 2015 22:16:51 -0400
parents 6951a645ccdf
children f81f1930c5d6
comparison
equal deleted inserted replaced
2259:6951a645ccdf 2260:03b10c7fab9a
797 0 797 0
798 IS.empty 798 IS.empty
799 799
800 val expSize = MonoUtil.Exp.fold {typ = #2, exp = fn (_, n) => n+1} 0 800 val expSize = MonoUtil.Exp.fold {typ = #2, exp = fn (_, n) => n+1} 0
801 801
802 structure InvalidationInfo :> sig
803 type t
804 val fromList : int list -> t
805 val toList : t -> int list
806 val union : t * t -> t
807 val unbind : t * int -> t option
808 end = struct
809
810 (* Keep track of the minimum explicitly. NONE is the empty set. *)
811 type t = (int * IS.set) option
812
813 val fromList =
814 List.foldl
815 (fn (n, NONE) => SOME (n, IS.singleton n)
816 | (n', SOME (n, ns)) => SOME (Int.min (n, n'), IS.add (ns, n')))
817 NONE
818
819 val toList =
820 fn NONE => []
821 | SOME (_, ns) => IS.listItems ns
822
823 val union =
824 fn (SOME (n1, ns1), SOME (n2, ns2)) => SOME (Int.min (n1, n2), IS.union (ns1, ns2))
825 | (NONE, x) => x
826 | (x, NONE) => x
827
828 val unbind =
829 fn (SOME (n, ns), unbound) =>
830 let
831 val n = n - unbound
832 in
833 if n < 0
834 then NONE
835 else SOME (SOME (n, IS.map (fn n => n - unbound) ns))
836 end
837 | _ => SOME NONE
838
839 end
840
802 datatype subexp = Pure of unit -> exp | Impure of exp 841 datatype subexp = Pure of unit -> exp | Impure of exp
803 842
804 val isImpure = 843 val isImpure =
805 fn Pure _ => false 844 fn Pure _ => false
806 | Impure _ => true 845 | Impure _ => true