@ -287,7 +287,7 @@ module Symbol = struct
(* NOTE: non_int represents the symbols that are not integer type,
(* NOTE: non_int represents the symbols that are not integer type,
so that their ranges are not used in the cost checker . * )
so that their ranges are not used in the cost checker . * )
type t =
type t =
| PulseValue of PulseAbstractValue . t
| ForeignVariable of { id : int }
| OneValue of { unsigned : extra_bool ; non_int : extra_bool ; path : SymbolPath . t }
| OneValue of { unsigned : extra_bool ; non_int : extra_bool ; path : SymbolPath . t }
| BoundEnd of
| BoundEnd of
{ unsigned : extra_bool ; non_int : extra_bool ; path : SymbolPath . t ; bound_end : BoundEnd . t }
{ unsigned : extra_bool ; non_int : extra_bool ; path : SymbolPath . t ; bound_end : BoundEnd . t }
@ -296,15 +296,15 @@ module Symbol = struct
let pp : F . formatter -> t -> unit =
let pp : F . formatter -> t -> unit =
fun fmt s ->
fun fmt s ->
match s with
match s with
| PulseValue v ->
| ForeignVariable { id } ->
PulseAbstractValue. pp fmt v
F. fprintf fmt " v%d " id
| OneValue { unsigned ; non_int ; path } | BoundEnd { unsigned ; non_int ; path } ->
| OneValue { unsigned ; non_int ; path } | BoundEnd { unsigned ; non_int ; path } ->
SymbolPath . pp fmt path ;
SymbolPath . pp fmt path ;
( if Config . developer_mode then
( if Config . developer_mode then
match s with
match s with
| BoundEnd { bound_end } ->
| BoundEnd { bound_end } ->
Format . fprintf fmt " .%s " ( BoundEnd . to_string bound_end )
Format . fprintf fmt " .%s " ( BoundEnd . to_string bound_end )
| PulseValu e _ | OneValue _ ->
| ForeignVariabl e _ | OneValue _ ->
() ) ;
() ) ;
if Config . bo_debug > 1 then
if Config . bo_debug > 1 then
F . fprintf fmt " (%c%s) " ( if unsigned then 'u' else 's' ) ( if non_int then " n " else " " )
F . fprintf fmt " (%c%s) " ( if unsigned then 'u' else 's' ) ( if non_int then " n " else " " )
@ -312,12 +312,12 @@ module Symbol = struct
let compare s1 s2 =
let compare s1 s2 =
match ( s1 , s2 ) with
match ( s1 , s2 ) with
| PulseValu e _ , ( OneValue _ | BoundEnd _ ) ->
| ForeignVariabl e _ , ( OneValue _ | BoundEnd _ ) ->
- 1
- 1
| ( OneValue _ | BoundEnd _ ) , PulseValu e _ ->
| ( OneValue _ | BoundEnd _ ) , ForeignVariabl e _ ->
1
1
| PulseValue x , PulseValue y ->
| ForeignVariable { id = x } , ForeignVariable { id = y } ->
PulseAbstractValue . compare x y
compare _int x y
| OneValue _ , BoundEnd _ ->
| OneValue _ , BoundEnd _ ->
- 1
- 1
| BoundEnd _ , OneValue _ ->
| BoundEnd _ , OneValue _ ->
@ -337,7 +337,8 @@ module Symbol = struct
let paths_equal s1 s2 =
let paths_equal s1 s2 =
match ( s1 , s2 ) with
match ( s1 , s2 ) with
| PulseValue _ , _ | _ , PulseValue _ | OneValue _ , BoundEnd _ | BoundEnd _ , OneValue _ ->
| ForeignVariable _ , _ | _ , ForeignVariable _ | OneValue _ , BoundEnd _ | BoundEnd _ , OneValue _
->
false
false
| OneValue { path = path1 } , OneValue { path = path2 } | BoundEnd { path = path1 } , BoundEnd { path = path2 }
| OneValue { path = path1 } , OneValue { path = path2 } | BoundEnd { path = path1 } , BoundEnd { path = path2 }
->
->
@ -354,46 +355,51 @@ module Symbol = struct
fun bound_end ~ unsigned ? ( non_int = false ) path -> BoundEnd { unsigned ; non_int ; path ; bound_end }
fun bound_end ~ unsigned ? ( non_int = false ) path -> BoundEnd { unsigned ; non_int ; path ; bound_end }
let of_pulse_value v = PulseValue v
let pp_mark ~ markup = if markup then MarkupFormatter . wrap_monospaced pp else pp
let pp_mark ~ markup = if markup then MarkupFormatter . wrap_monospaced pp else pp
let is_unsigned : t -> bool = function
let is_unsigned : t -> bool = function
| PulseValu e _ ->
| ForeignVariabl e _ ->
false
false
| OneValue { unsigned } | BoundEnd { unsigned } ->
| OneValue { unsigned } | BoundEnd { unsigned } ->
unsigned
unsigned
let is_non_int : t -> bool = function
let is_non_int : t -> bool = function
| PulseValu e _ ->
| ForeignVariabl e _ ->
false
false
| OneValue { non_int } | BoundEnd { non_int } ->
| OneValue { non_int } | BoundEnd { non_int } ->
non_int
non_int
let is_global : t -> bool = function
let is_global : t -> bool = function
| PulseValu e _ ->
| ForeignVariabl e _ ->
false
false
| OneValue { path } | BoundEnd { path } ->
| OneValue { path } | BoundEnd { path } ->
SymbolPath . is_global path
SymbolPath . is_global path
let get_pulse_value_exn : t -> PulseAbstractValue . t = function
let of_foreign_id id = ForeignVariable { id }
| PulseValue v ->
v
let get_foreign_id_exn : t -> int = function
| ForeignVariable { id } ->
id
| OneValue _ | BoundEnd _ ->
| OneValue _ | BoundEnd _ ->
assert false
assert false
(* This should be called on non-pulse bound as of now. *)
(* This should be called on non-pulse bound as of now. *)
let path = function PulseValue _ -> assert false | OneValue { path } | BoundEnd { path } -> path
let path = function
| ForeignVariable _ ->
assert false
| OneValue { path } | BoundEnd { path } ->
path
(* NOTE: This may not be satisfied in the cost checker for simplifying its results. *)
(* NOTE: This may not be satisfied in the cost checker for simplifying its results. *)
let check_bound_end s be =
let check_bound_end s be =
if Config . bo_debug > = 3 then
if Config . bo_debug > = 3 then
match s with
match s with
| PulseValu e _ | OneValue _ ->
| ForeignVariabl e _ | OneValue _ ->
()
()
| BoundEnd { bound_end } ->
| BoundEnd { bound_end } ->
if not ( BoundEnd . equal be bound_end ) then
if not ( BoundEnd . equal be bound_end ) then
@ -403,7 +409,7 @@ module Symbol = struct
let exists_str ~ f = function
let exists_str ~ f = function
| PulseValu e _ ->
| ForeignVariabl e _ ->
false
false
| OneValue { path } | BoundEnd { path } ->
| OneValue { path } | BoundEnd { path } ->
SymbolPath . exists_str ~ f path
SymbolPath . exists_str ~ f path