diff options
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 |