Commit 79ce2417 authored by Kim Nguyễn's avatar Kim Nguyễn

Re-factor the BoolVar module. Move it to bool.ml and factor as much code as possible with Bool

parent 5cace08c
......@@ -161,9 +161,9 @@ OBJECTS = \
driver/cduce_config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo misc/utils.cmo \
\
types/compunit.cmo types/sortedList.cmo misc/bool.cmo types/ident.cmo \
types/compunit.cmo types/sortedList.cmo types/ident.cmo types/var.cmo misc/bool.cmo \
types/intervals.cmo types/chars.cmo types/atoms.cmo types/normal.cmo \
types/var.cmo types/boolVar.cmo types/types.cmo compile/auto_pat.cmo \
types/types.cmo compile/auto_pat.cmo \
types/sequence.cmo types/builtin_defs.cmo \
\
runtime/value.cmo \
......@@ -347,9 +347,6 @@ misc/q_symbol.cmo: misc/q_symbol.ml
$(HIDE) $(CAMLC) -c -pp camlp4orf $<
types/boolVar.cmo: SYNTAX_PARSER=
types/boolVar.cmi: SYNTAX_PARSER=
types/boolVar.cmx: SYNTAX_PARSER=
parser/parser.$(EXTENSION): PACKAGES += camlp4.extend
.ml.cmo:
......
......@@ -22,12 +22,16 @@ types/compunit.cmo : types/compunit.cmi
types/compunit.cmx : types/compunit.cmi
types/sortedList.cmo : misc/custom.cmo types/sortedList.cmi
types/sortedList.cmx : misc/custom.cmx types/sortedList.cmi
misc/bool.cmo : misc/custom.cmo misc/bool.cmi
misc/bool.cmx : misc/custom.cmx misc/bool.cmi
types/ident.cmo : misc/utils.cmo types/sortedList.cmi misc/ns.cmi \
misc/encodings.cmi
types/ident.cmx : misc/utils.cmx types/sortedList.cmx misc/ns.cmx \
misc/encodings.cmx
types/var.cmo : misc/utils.cmo types/sortedList.cmi types/ident.cmo \
misc/custom.cmo types/var.cmi
types/var.cmx : misc/utils.cmx types/sortedList.cmx types/ident.cmx \
misc/custom.cmx types/var.cmi
misc/bool.cmo : types/var.cmi misc/custom.cmo misc/bool.cmi
misc/bool.cmx : types/var.cmx misc/custom.cmx misc/bool.cmi
types/intervals.cmo : types/intervals.cmi
types/intervals.cmx : types/intervals.cmi
types/chars.cmo : misc/custom.cmo types/chars.cmi
......@@ -38,24 +42,16 @@ types/atoms.cmx : misc/upool.cmx types/sortedList.cmx misc/ns.cmx \
misc/imap.cmx misc/encodings.cmx types/atoms.cmi
types/normal.cmo : types/normal.cmi
types/normal.cmx : types/normal.cmi
types/var.cmo : misc/utils.cmo types/sortedList.cmi types/ident.cmo \
misc/custom.cmo types/var.cmi
types/var.cmx : misc/utils.cmx types/sortedList.cmx types/ident.cmx \
misc/custom.cmx types/var.cmi
types/boolVar.cmo : types/var.cmi misc/custom.cmo misc/bool.cmi \
types/boolVar.cmi
types/boolVar.cmx : types/var.cmx misc/custom.cmx misc/bool.cmx \
types/boolVar.cmi
types/types.cmo : types/var.cmi misc/utils.cmo misc/stats.cmi \
types/sortedList.cmi misc/pretty.cmi misc/ns.cmi types/normal.cmi \
types/intervals.cmi types/ident.cmo misc/encodings.cmi misc/custom.cmo \
types/compunit.cmi types/chars.cmi types/boolVar.cmi misc/bool.cmi \
types/atoms.cmi types/types.cmi
types/compunit.cmi types/chars.cmi misc/bool.cmi types/atoms.cmi \
types/types.cmi
types/types.cmx : types/var.cmx misc/utils.cmx misc/stats.cmx \
types/sortedList.cmx misc/pretty.cmx misc/ns.cmx types/normal.cmx \
types/intervals.cmx types/ident.cmx misc/encodings.cmx misc/custom.cmx \
types/compunit.cmx types/chars.cmx types/boolVar.cmx misc/bool.cmx \
types/atoms.cmx types/types.cmi
types/compunit.cmx types/chars.cmx misc/bool.cmx types/atoms.cmx \
types/types.cmi
compile/auto_pat.cmo : types/types.cmi types/ident.cmo types/chars.cmi \
types/atoms.cmi compile/auto_pat.cmi
compile/auto_pat.cmx : types/types.cmx types/ident.cmx types/chars.cmx \
......@@ -368,16 +364,15 @@ misc/imap.cmi :
misc/html.cmi :
types/compunit.cmi :
types/sortedList.cmi : misc/custom.cmo
misc/bool.cmi : misc/custom.cmo
types/var.cmi : types/sortedList.cmi misc/custom.cmo
misc/bool.cmi : types/var.cmi misc/custom.cmo
types/intervals.cmi : misc/custom.cmo misc/bool.cmi
types/chars.cmi : misc/custom.cmo misc/bool.cmi
types/atoms.cmi : misc/ns.cmi misc/encodings.cmi misc/custom.cmo \
misc/bool.cmi
types/normal.cmi :
types/var.cmi : types/sortedList.cmi misc/custom.cmo
types/boolVar.cmi : types/var.cmi misc/custom.cmo misc/bool.cmi
types/types.cmi : types/var.cmi misc/ns.cmi types/intervals.cmi \
types/ident.cmo misc/custom.cmo types/chars.cmi types/boolVar.cmi \
types/ident.cmo misc/custom.cmo types/chars.cmi misc/bool.cmi \
types/atoms.cmi
compile/auto_pat.cmi : types/types.cmi types/ident.cmo types/chars.cmi \
types/atoms.cmi
......
This diff is collapsed.
......@@ -21,23 +21,25 @@ sig
val trivially_disjoint : t -> t -> bool
end
module type MAKE = functor (X : Custom.T) -> S with type elem = X.t
module Make (X : Custom.T) : S with type elem = X.t
module Make : MAKE
module type V =
sig
(*
module type S' = sig
include S
type bdd = False | True | Br of elem * t * t
val br: t -> bdd
end
module Atom : S
include S with type elem = Atom.t Var.var_or_atom
val var : Var.t -> t
(** returns the union of all leaves in the BDD *)
val leafconj: t -> Atom.t
val is_empty : t -> bool
module MakeBdd(X : Custom.T) : S' with type elem = X.t
val extract : t -> [ `Empty | `Full | `Split of (elem * t * t * t) ]
module type S'' = sig
include S
val dnf: (elem list -> (elem list) list -> unit) -> t -> unit
end
module Make2(X : Custom.T) : S'' with type elem = X.t
*)
module MakeVar (T : S) : V with module Atom = T and type elem = T.t Var.var_or_atom
This diff is collapsed.
module type S = sig
module Atom : Bool.S
include Bool.S with type elem = Atom.t Var.var_or_atom
val var : Var.t -> t
(** returns the union of all leaves in the BDD *)
val leafconj: t -> Atom.t
val is_empty : t -> bool
val pp_print : Format.formatter -> t -> unit
val print : ?f:(Format.formatter -> elem -> unit) -> t -> (Format.formatter -> unit) list
val extract : t -> [ `Empty | `Full | `Split of (elem * t * t * t) ]
end
module Make : functor (T : Bool.S) -> S with module Atom = T and type elem = T.t Var.var_or_atom
......@@ -134,10 +134,10 @@ end
type pair_kind = [ `Normal | `XML ]
module BoolAtoms = BoolVar.Make(Atoms)
module BoolIntervals = BoolVar.Make(Intervals)
module BoolChars = BoolVar.Make(Chars)
module BoolAbstracts = BoolVar.Make(Abstracts)
module BoolAtoms = Bool.MakeVar(Atoms)
module BoolIntervals = Bool.MakeVar(Intervals)
module BoolChars = Bool.MakeVar(Chars)
module BoolAbstracts = Bool.MakeVar(Abstracts)
module rec Descr :
sig
......@@ -305,14 +305,16 @@ end
and Pair : Bool.S with type elem = (Node.t * Node.t) =
Bool.Make(Custom.Pair(Node)(Node))
and BoolPair : BoolVar.S with module Atom = Pair = BoolVar.Make(Pair)
and BoolPair : Bool.V with module Atom = Pair = Bool.MakeVar(Pair)
(* bool = true means that the record is open that is, that
* the labels that are not in the domain of the map are
* equal to "any" *)
and Rec : Bool.S with type elem = bool * Node.t Ident.label_map =
Bool.Make(Custom.Pair(Custom.Bool)(LabelSet.MakeMap(Node)))
and BoolRec : BoolVar.S with module Atom = Rec = BoolVar.Make(Rec)
and BoolRec : Bool.V with module Atom = Rec = Bool.MakeVar(Rec)
module DescrHash = Hashtbl.Make(Descr)
module DescrMap = Map.Make(Descr)
......@@ -1571,7 +1573,7 @@ module Iter =
let memo = DescrHash.create 17 in
let aux (type bdd) (type atom)
inj
(module BV : BoolVar.S with type t = bdd and type Atom.t = atom ) b
(module BV : Bool.V with type t = bdd and type Atom.t = atom ) b
=
let clean b =
if is_empty (inj b) then BV.empty else b
......@@ -1658,7 +1660,7 @@ module Iter =
let cplx_bdd (type bdd) (type atom) (type atom2)
any
do_atom
(module BV : BoolVar.S with type t = bdd and type Atom.t = atom and type Atom.elem = atom2)
(module BV : Bool.V with type t = bdd and type Atom.t = atom and type Atom.elem = atom2)
acc
bdd
=
......@@ -2142,7 +2144,7 @@ module Print = struct
) (Var.Set.empty, init) l
in
let fill_line (type s)
(module BV : BoolVar.S with type t = s) table get set t =
(module BV : Bool.V with type t = s) table get set t =
List.iter (fun (p, n) ->
let v1, a1 = split_var_atom (fun a b -> BV.(cap (atom a) b)) BV.full p in
let v2, a2 = split_var_atom (fun a b -> BV.(cup (atom a) b)) BV.empty n in
......@@ -2165,7 +2167,7 @@ module Print = struct
let h =
try
let no_var = VarTable.find h Key.empty in
let update_field (type s) (module BV : BoolVar.S with type t = s) get set d1 d2 =
let update_field (type s) (module BV : Bool.V with type t = s) get set d1 d2 =
let bdd = get d1 in
if BV.(is_empty (diff full bdd)) then set d2 bdd else d2
in
......
......@@ -69,13 +69,13 @@ end
(** Algebra **)
module BoolAtoms : BoolVar.S with type Atom.t = Atoms.t
module BoolAtoms : Bool.V with type Atom.t = Atoms.t
module BoolIntervals : BoolVar.S with type Atom.t = Intervals.t
module BoolIntervals : Bool.V with type Atom.t = Intervals.t
module BoolChars : BoolVar.S with type Atom.t = Chars.t
module BoolChars : Bool.V with type Atom.t = Chars.t
module BoolAbstracts: BoolVar.S with type Atom.t = Abstracts.t
module BoolAbstracts: Bool.V with type Atom.t = Abstracts.t
include Custom.T
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment