From d4ab85a1a6503cdbcb98c183c3357926d78da8a7 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Wed, 7 May 2014 19:04:38 +0200 Subject: implement assert, print --- abstract/nonrelational.ml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'abstract/nonrelational.ml') diff --git a/abstract/nonrelational.ml b/abstract/nonrelational.ml index 6e2ff2b..d4118da 100644 --- a/abstract/nonrelational.ml +++ b/abstract/nonrelational.ml @@ -16,8 +16,7 @@ module NonRelational (V : VALUE_DOMAIN) : ENVIRONMENT_DOMAIN = struct let get_var env id = try VarMap.find id env with Not_found -> V.top - - + (* utilities *) let rec eval env expr = @@ -52,6 +51,10 @@ module NonRelational (V : VALUE_DOMAIN) : ENVIRONMENT_DOMAIN = struct (* implementation *) + let is_bot env = match env with + | Bot -> true + | Env env -> strict env = Bot + let addvar x id = strict_apply (fun y -> Env (VarMap.add id V.top y)) x let rmvar x id = strict_apply (fun y -> Env (VarMap.remove id y)) x @@ -100,4 +103,23 @@ module NonRelational (V : VALUE_DOMAIN) : ENVIRONMENT_DOMAIN = struct (fun _ a b -> V.subset a b) m n + (* pretty-printing *) + let var_str env vars = + match env with + | Bot -> "bot" + | Env env -> + let v = List.fold_left + (fun s id -> + (if s = "" then s else s ^ ", ") ^ + id ^ " in " ^ (V.to_string (get_var env id)) + ) + "" + vars + in + "[ " ^ v ^ " ]" + + let all_vars_str env = + match env with + | Bot -> "bot" + | Env map -> var_str env (List.map fst (VarMap.bindings map)) end -- cgit v1.2.3