This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNCCE.ml
72 lines (66 loc) · 2.55 KB
/
NCCE.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
type var_state = string * string * string
type var_states = var_state Datatype.String.Hashtbl.t
type t = Property.t * string * string * var_states
let all_for prop =
let on_nc k (a, b) acc = (prop, k, a, b) :: acc in
try
let t = States.NC_counter_examples.find prop in
Datatype.String.Hashtbl.fold on_nc t []
with Not_found -> []
let one_for prop =
let on_nc k (a, b) = function None -> Some (prop, k, a, b) | x -> x in
try
let t = States.NC_counter_examples.find prop in
Datatype.String.Hashtbl.fold on_nc t None
with Not_found -> None
let register ignore_var kind prop str_tc msg list_entries =
let file_tbl =
try States.NC_counter_examples.find prop with Not_found ->
Datatype.String.Hashtbl.create 16
in
let msg, var_tbl =
try Datatype.String.Hashtbl.find file_tbl str_tc with Not_found ->
(msg, Datatype.String.Hashtbl.create 16)
in
let on_pair (var, value) =
let i, c, s =
try Datatype.String.Hashtbl.find var_tbl var with Not_found ->
("", "", "")
in
let i, c, s =
if kind = "IN" then (value, c, s)
else if kind = "OUTCONC" then (i, value, s)
else (i, c, value)
in
if ignore_var var then ()
else Datatype.String.Hashtbl.replace var_tbl var (i, c, s)
in
List.iter on_pair list_entries ;
Datatype.String.Hashtbl.replace file_tbl str_tc (msg, var_tbl) ;
States.NC_counter_examples.replace prop file_tbl
let pretty fmt (p, f, msg, var_states) =
let pp_msg fmt = function "" -> () | x -> Format.fprintf fmt "(%s)" x in
let pp_loc = Cil_datatype.Location.pretty in
let on_var var (input, con, sym) =
match (con, sym) with
| "", "" -> Format.fprintf fmt "%s = %s@\n" var input
| "", x | x, "" ->
if input = "" then Format.fprintf fmt "%s = %s@\n" var x
else Format.fprintf fmt "%s = %s (in) ; %s (out)@\n" var input x
| x, y ->
if input = "" then
if x = y then Format.fprintf fmt "%s = %s@\n" var x
else
Format.fprintf fmt "%s = %s (concrete) ; %s (symbolic)@\n" var x y
else if x = y then
Format.fprintf fmt "%s = %s (in) ; %s (out)@\n" var input x
else
Format.fprintf fmt
"%s = %s (in) ; %s (concrete out) ; %s (symbolic out)@\n" var input
x y
in
Format.fprintf fmt "Non-Compliance@\n" ;
Format.fprintf fmt "of : @[%a@] %a@\n" Property.pretty p pp_msg msg ;
Format.fprintf fmt "location : @[%a@]@\n" pp_loc (Property.location p) ;
Format.fprintf fmt "TEST DRIVER: %s@\n" f ;
Datatype.String.Hashtbl.iter_sorted on_var var_states