diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-05-07 19:04:38 +0200 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-05-07 19:04:38 +0200 |
commit | d4ab85a1a6503cdbcb98c183c3357926d78da8a7 (patch) | |
tree | b28ac764dd21ca7225ee46c6f4a4686648511fa3 /abstract/nonrelational.ml | |
parent | 9ccef2c0850b73bf3d92f26bfa0aeacf933e1d17 (diff) | |
download | SemVerif-Projet-d4ab85a1a6503cdbcb98c183c3357926d78da8a7.tar.gz SemVerif-Projet-d4ab85a1a6503cdbcb98c183c3357926d78da8a7.zip |
implement assert, print
Diffstat (limited to 'abstract/nonrelational.ml')
-rw-r--r-- | abstract/nonrelational.ml | 26 |
1 files changed, 24 insertions, 2 deletions
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 |