package mopsa
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500
doc/core/Core/Cases/index.html
Module Core.Cases
Source
Cases - data structure for case-based transfer functions.
Transfer functions use Cases
to return partitioned results. Cases are encoded as DNF formulas. Each individual case comes with a flow, a set of alarms, computation changes and cleaner statements. To represent suspended computations, the result of a case can be empty.
type 'r case =
| Result of 'r * Change.change_map * cleaners
(*Actual result of the computation, with changes and cleaners
*)| Empty
(*Empty results due to non-terminating computations (e.g. alarms)
*)| NotHandled
(*This means that the domain can't process this case. The analyzer can ask other domains to handle it.
*)
A single case of a computation
Cases of results 'r
over an abstraction 'a
val return :
?changes:Change.change_map ->
?cleaners:Ast.Stmt.stmt list ->
'r ->
'a Flow.flow ->
('a, 'r) cases
val singleton :
?changes:Change.change_map ->
?cleaners:Ast.Stmt.stmt list ->
'r ->
'a Flow.flow ->
('a, 'r) cases
Create a case with a single non-empty result.
Create a non-handled case to be forwarded to other domains
val remove_duplicate_results :
?equal:('r -> 'r -> bool) ->
'a Lattice.lattice ->
('a, 'r) cases ->
('a, 'r) cases
Remove duplicate results
Cleaners
************
Option to apply cleaners on T_cur only
add_cleaners block c
adds cleaner statements block
to cases c
.
Set the set of cleaners attached to a case
Set the same cleaners for all cases
Context
***********
get_ctx c
returns the context of cases c
.
set_ctx ctx c
changes the context of cases c
to ctx
.
copy_ctx c1 c2
changes the context of cases c2
to the context of c1
.
get_callstack c
returns the callstack of cases c
.
set_callstack cs c
returns a copy of c
with callstack cs
.
Changes
***********
Get the changes attached to a case
Set the changes attached to a case
val map_changes :
(Change.change_map -> 'a Flow.flow -> Change.change_map) ->
('a, 'r) cases ->
('a, 'r) cases
map_changes f c
replaces each changes l
in c
with f l
.
Set the same changes for all cases
Lattice operators
*********************
Join a list of cases.
Meet a list of cases.
Iterators
*************
val map :
('r case -> 'a Flow.flow -> 's case * 'a Flow.flow) ->
('a, 'r) cases ->
('a, 's) cases
map f c
replaces each case ci*flow
in c
with f ci flow
map_result f c
is similar to map f c
, except that empty and not-handled cases are kept unmodified.
val map_conjunction :
(('r case * 'a Flow.flow) list -> ('s case * 'a Flow.flow) list) ->
('a, 'r) cases ->
('a, 's) cases
map_conjunction f c
replaces each conjunction conj
in c
with f conj
val map_disjunction :
(('r case * 'a Flow.flow) list -> ('s case * 'a Flow.flow) list) ->
('a, 'r) cases ->
('a, 's) cases
map_disjunction f c
replaces each disjunction disj
in c
with f disj
val reduce :
('r case -> 'a Flow.flow -> 'b) ->
join:('b -> 'b -> 'b) ->
meet:('b -> 'b -> 'b) ->
('a, 'r) cases ->
'b
reduce f ~join ~meet c
collapses cases in c
to a single value by applying f
on each case and merging outputs using join
and meet
.
val reduce_result :
('r -> 'a Flow.flow -> 'b) ->
join:('b -> 'b -> 'b) ->
meet:('b -> 'b -> 'b) ->
bottom:(unit -> 'b) ->
('a, 'r) cases ->
'b
reduce_result f ~join ~meet bottom c
is similar to reduce f join meet c
, except that empty and not-handled cases are replaced with bottom
.
Fold over the flattened list of cases
Fold over the flattened list of results
Iterate over the flattened list of cases
Iterate over the flattened list of results
val partition :
('r case -> 'a Flow.flow -> bool) ->
('a, 'r) cases ->
('a, 'r) cases option * ('a, 'r) cases option
partition f cases
separates cases that verify or not predicate f
Check whether a predicate is valid over all cases
Check whether a predicate is valid over all results
Check whether a predicate is valid for at least one case
Check whether a predicate is valid for at least one result
val print :
(Stdlib.Format.formatter -> 'r case -> 'a Flow.flow -> unit) ->
Stdlib.Format.formatter ->
('a, 'r) cases ->
unit
Pretty printer of cases
val print_result :
(Stdlib.Format.formatter -> 'r -> 'a Flow.flow -> unit) ->
Stdlib.Format.formatter ->
('a, 'r) cases ->
unit
Pretty printer of results
Monadic binders
val bind_opt :
('r case -> 'a Flow.flow -> ('a, 's) cases option) ->
('a, 'r) cases ->
('a, 's) cases option
bind_opt f cases
substitutes each case (c,flow)
in cases
with f c flow
. If the function returns None
, the case becomes NotHandled
. Changes and cleaners returned by f
are concatenated with the previous ones in cases
.
val (>>=?) :
('a, 'r) cases ->
('r case -> 'a Flow.flow -> ('a, 's) cases option) ->
('a, 's) cases option
Bind operator for bind_opt
bind f cases
substitutes each case (c,flow)
in cases
with f c flow
. Changes and cleaners returned by f
are concatenated with the previous ones in cases
.
Bind operator for bind
val bind_result_opt :
('r -> 'a Flow.flow -> ('a, 's) cases option) ->
('a, 'r) cases ->
('a, 's) cases option
Same as bind_opt
, but empty and not-handled cases are preserved and are not passed to f
.
val (>>$?) :
('a, 'r) cases ->
('r -> 'a Flow.flow -> ('a, 's) cases option) ->
('a, 's) cases option
Bind operator for bind_result_opt
Same as bind
, but empty and not-handled cases are preserved and are not passed to f
.
Bind operator for bind_result
val bind_conjunction :
(('r case * 'a Flow.flow) list -> ('a, 's) cases) ->
('a, 'r) cases ->
('a, 's) cases
bind_conjunction f cases
substitutes each conjunction of cases conj
in cases
with f conj
. Changes and cleaners returned by f
are concatenated with the previous ones in cases
.
val bind_conjunction_result :
('r list -> 'a Flow.flow -> ('a, 's) cases) ->
'a Lattice.lattice ->
('a, 'r) cases ->
('a, 's) cases
Same as bind_conjunction
f cases] but empty and not-handled cases are preserved and are not passed to f
.
val bind_disjunction :
(('r case * 'a Flow.flow) list -> ('a, 's) cases) ->
('a, 'r) cases ->
('a, 's) cases
bind_disjunction f cases
substitutes each disjunction of cases disj
in cases
with f disj
. Changes and cleaners returned by f
are concatenated with the previous ones in cases
.
val bind_disjunction_result :
('r list -> 'a Flow.flow -> ('a, 's) cases) ->
'a Lattice.lattice ->
('a, 'r) cases ->
('a, 's) cases
Same as bind_disjunction
f cases] but empty and not-handled cases are preserved and are not passed to f
.