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
9828d551
"src/git@git.frama-c.com:pub/frama-c.git" did not exist on "41342b9bef554bdfaaa694f3eb56d89b70746d31"
Commit
9828d551
authored
2 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] Structure: implements iterators iter, fold and map.
parent
e026c8cc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/value/utils/structure.ml
+72
-0
72 additions, 0 deletions
src/plugins/value/utils/structure.ml
src/plugins/value/utils/structure.mli
+17
-0
17 additions, 0 deletions
src/plugins/value/utils/structure.mli
with
89 additions
and
0 deletions
src/plugins/value/utils/structure.ml
+
72
−
0
View file @
9828d551
...
...
@@ -147,6 +147,21 @@ module type External = sig
val
mem
:
'
a
key
->
bool
val
get
:
'
a
key
->
(
t
->
'
a
)
option
val
set
:
'
a
key
->
'
a
->
t
->
t
type
polymorphic_iter_fun
=
{
iter
:
'
a
.
'
a
key
->
'
a
data
->
'
a
->
unit
;
}
val
iter
:
polymorphic_iter_fun
->
t
->
unit
type
'
b
polymorphic_fold_fun
=
{
fold
:
'
a
.
'
a
key
->
'
a
data
->
'
a
->
'
b
->
'
b
;
}
val
fold
:
'
b
polymorphic_fold_fun
->
t
->
'
b
->
'
b
type
polymorphic_map_fun
=
{
map
:
'
a
.
'
a
key
->
'
a
data
->
'
a
->
'
a
;
}
val
map
:
polymorphic_map_fun
->
t
->
t
end
module
Open
...
...
@@ -228,4 +243,61 @@ module Open
|
Some
(
Set
(
k
,
set
))
->
match
Shape
.
eq_type
key
k
with
|
None
->
fun
_
t
->
t
|
Some
Eq
->
set
type
polymorphic_iter_fun
=
{
iter
:
'
a
.
'
a
Shape
.
key
->
'
a
Shape
.
data
->
'
a
->
unit
;
}
let
rec
iter
:
type
a
.
a
structure
->
(
polymorphic_iter_fun
->
a
->
unit
)
=
function
|
Unit
->
fun
_
()
->
()
|
Void
->
fun
_
_
->
()
|
Leaf
(
key
,
data
)
->
fun
poly
v
->
poly
.
iter
key
data
v
|
Node
(
left
,
right
)
->
let
left
=
iter
left
and
right
=
iter
right
in
fun
poly
(
a
,
b
)
->
left
poly
a
;
right
poly
b
;
|
Option
(
s
,
_
)
->
let
iter
=
iter
s
in
fun
poly
v
->
Option
.
iter
(
iter
poly
)
v
let
iter
=
iter
M
.
structure
type
'
b
polymorphic_fold_fun
=
{
fold
:
'
a
.
'
a
Shape
.
key
->
'
a
Shape
.
data
->
'
a
->
'
b
->
'
b
;
}
let
rec
fold
:
type
a
.
a
structure
->
(
'
b
polymorphic_fold_fun
->
a
->
'
b
->
'
b
)
=
function
|
Unit
->
fun
_
()
acc
->
acc
|
Void
->
fun
_
_
acc
->
acc
|
Leaf
(
key
,
data
)
->
fun
poly
v
acc
->
poly
.
fold
key
data
v
acc
|
Node
(
left
,
right
)
->
let
left
=
fold
left
and
right
=
fold
right
in
fun
poly
(
a
,
b
)
acc
->
right
poly
b
(
left
poly
a
acc
)
|
Option
(
s
,
_
)
->
let
fold
=
fold
s
in
fun
poly
v
acc
->
Option
.
fold
~
none
:
acc
~
some
:
(
fun
v
->
fold
poly
v
acc
)
v
let
fold
x
=
fold
M
.
structure
x
type
polymorphic_map_fun
=
{
map
:
'
a
.
'
a
Shape
.
key
->
'
a
Shape
.
data
->
'
a
->
'
a
;
}
let
rec
map
:
type
a
.
a
structure
->
(
polymorphic_map_fun
->
a
->
a
)
=
function
|
Unit
->
fun
_
()
->
()
|
Void
->
fun
_
x
->
x
|
Leaf
(
key
,
data
)
->
fun
poly
v
->
poly
.
map
key
data
v
|
Node
(
left
,
right
)
->
let
left
=
map
left
and
right
=
map
right
in
fun
poly
(
a
,
b
)
->
(
left
poly
a
,
right
poly
b
)
|
Option
(
s
,
_
)
->
let
map
=
map
s
in
fun
poly
v
->
Option
.
map
(
map
poly
)
v
let
map
=
map
M
.
structure
end
This diff is collapsed.
Click to expand it.
src/plugins/value/utils/structure.mli
+
17
−
0
View file @
9828d551
...
...
@@ -106,6 +106,23 @@ module type External = sig
this subpart has been replaced by [v].
- otherwise, [set key _] is the identity function. *)
val
set
:
'
a
key
->
'
a
->
t
->
t
(** Iterators on the components of a structure. *)
type
polymorphic_iter_fun
=
{
iter
:
'
a
.
'
a
key
->
'
a
data
->
'
a
->
unit
;
}
val
iter
:
polymorphic_iter_fun
->
t
->
unit
type
'
b
polymorphic_fold_fun
=
{
fold
:
'
a
.
'
a
key
->
'
a
data
->
'
a
->
'
b
->
'
b
;
}
val
fold
:
'
b
polymorphic_fold_fun
->
t
->
'
b
->
'
b
type
polymorphic_map_fun
=
{
map
:
'
a
.
'
a
key
->
'
a
data
->
'
a
->
'
a
;
}
val
map
:
polymorphic_map_fun
->
t
->
t
end
(** Opens an internal tree module into an external one. *)
...
...
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