Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
a0d331fd
Commit
a0d331fd
authored
3 years ago
by
Valentin Perrelle
Committed by
David Bühler
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] api: Add a result conversion helper
parent
fa1206aa
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/plugins/value/Eva.mli
+7
-1
7 additions, 1 deletion
src/plugins/value/Eva.mli
src/plugins/value/utils/results.ml
+6
-0
6 additions, 0 deletions
src/plugins/value/utils/results.ml
src/plugins/value/utils/results.mli
+7
-1
7 additions, 1 deletion
src/plugins/value/utils/results.mli
with
20 additions
and
2 deletions
src/plugins/value/Eva.mli
+
7
−
1
View file @
a0d331fd
...
...
@@ -20,7 +20,7 @@ end
module
Results
:
sig
(* Usage sketch :
Eva.Results.(before stmt |> in_callstack cs |> eval_var vi |> as_int)
Eva.Results.(before stmt |> in_callstack cs |> eval_var vi |> as_int
|> value ~default:0
)
or, if you prefer
...
...
@@ -124,6 +124,12 @@ module Results: sig
Raises [Stdlib.Invalid_argument] if the statement is not a [Call]
instruction or a [Local_init] with [ConsInit] initializer. *)
val
callee
:
Cil_types
.
stmt
->
Kernel_function
.
t
list
(* Result conversion *)
(** [default d r] extract the value of r if r is Ok or use the default value d
otherwise.
Equivalent to [Result.value ~default:d r] *)
val
default
:
'
a
->
'
a
result
->
'
a
end
module
Value_results
:
sig
...
...
This diff is collapsed.
Click to expand it.
src/plugins/value/utils/results.ml
+
6
−
0
View file @
a0d331fd
...
...
@@ -756,3 +756,9 @@ let callsites kf =
at_start_of
kf
|>
callstacks
|>
List
.
fold_left
f
Map
.
empty
|>
Map
.
to_seq
|>
List
.
of_seq
|>
List
.
map
(
fun
(
kf
,
sites
)
->
kf
,
uniq_sites
sites
)
(* Result conversion *)
let
default
default_value
result
=
Result
.
value
~
default
:
default_value
result
This diff is collapsed.
Click to expand it.
src/plugins/value/utils/results.mli
+
7
−
1
View file @
a0d331fd
...
...
@@ -23,7 +23,7 @@
[
@@@
api_start
]
(* Usage sketch :
Eva.Results.(before stmt |> in_callstack cs |> eval_var vi |> as_int)
Eva.Results.(before stmt |> in_callstack cs |> eval_var vi |> as_int
|> value ~default:0
)
or, if you prefer
...
...
@@ -127,4 +127,10 @@ val callsites : Cil_types.kernel_function ->
Raises [Stdlib.Invalid_argument] if the statement is not a [Call]
instruction or a [Local_init] with [ConsInit] initializer. *)
val
callee
:
Cil_types
.
stmt
->
Kernel_function
.
t
list
(* Result conversion *)
(** [default d r] extract the value of r if r is Ok or use the default value d
otherwise.
Equivalent to [Result.value ~default:d r] *)
val
default
:
'
a
->
'
a
result
->
'
a
[
@@@
api_end
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment