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
6fee7b88
Commit
6fee7b88
authored
8 months ago
by
Kilyan Le Gallic
Committed by
Allan Blanchard
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
[wp] Maps for CIL locations of logic type and logic info
parent
46427f64
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/wp/Why3Import.ml
+41
-29
41 additions, 29 deletions
src/plugins/wp/Why3Import.ml
with
41 additions
and
29 deletions
src/plugins/wp/Why3Import.ml
+
41
−
29
View file @
6fee7b88
...
...
@@ -121,7 +121,9 @@ type env = {
lenv
:
C
.
logic_info
W
.
Term
.
Hls
.
t
;
lils
:
W
.
Term
.
lsymbol
Logic_info
.
Hashtbl
.
t
;
ltits
:
W
.
Ty
.
tysymbol
Logic_type_info
.
Hashtbl
.
t
;
menv
:
why3module
Datatype
.
String
.
Hashtbl
.
t
menv
:
why3module
Datatype
.
String
.
Hashtbl
.
t
;
tloc
:
C
.
logic_type_info
Location
.
Hashtbl
.
t
;
lloc
:
C
.
logic_info
Location
.
Hashtbl
.
t
;
}
type
menv
=
{
...
...
@@ -135,7 +137,9 @@ let create_empty_env wenv =
let
lils
=
Logic_info
.
Hashtbl
.
create
0
in
let
ltits
=
Logic_type_info
.
Hashtbl
.
create
0
in
let
menv
=
Datatype
.
String
.
Hashtbl
.
create
0
in
{
wenv
;
tenv
;
lenv
;
lils
;
ltits
;
menv
}
let
tloc
=
Location
.
Hashtbl
.
create
0
in
let
lloc
=
Location
.
Hashtbl
.
create
0
in
{
wenv
;
tenv
;
lenv
;
lils
;
ltits
;
menv
;
tloc
;
lloc
}
(* -------------------------------------------------------------------------- *)
...
...
@@ -166,34 +170,31 @@ let add_builtins env =
(* --- Location handling --- *)
(* -------------------------------------------------------------------------- *)
let
convert_location
(
wloc
:
Why3
.
Loc
.
position
)
:
C
.
location
=
let
(
file
,
lstart
,
cstart
,
lend
,
cend
)
=
Why3
.
Loc
.
get
wloc
in
let
pstart
=
{
Filepath
.
pos_path
=
F
.
of_string
file
;
pos_lnum
=
lstart
;
pos_bol
=
0
;
pos_cnum
=
cstart
;
}
in
let
pend
=
{
Filepath
.
pos_path
=
F
.
of_string
file
;
pos_lnum
=
lend
;
pos_bol
=
0
;
pos_cnum
=
cend
;
}
in
(
pstart
,
pend
)
let
convert_location
(
wloc
:
Why3
.
Loc
.
position
option
)
:
C
.
location
=
match
wloc
with
|
Some
loc
->
let
(
file
,
lstart
,
cstart
,
lend
,
cend
)
=
Why3
.
Loc
.
get
loc
in
let
pstart
=
{
Filepath
.
pos_path
=
F
.
of_string
file
;
pos_lnum
=
lstart
;
pos_bol
=
0
;
pos_cnum
=
cstart
;
}
in
let
pend
=
{
Filepath
.
pos_path
=
F
.
of_string
file
;
pos_lnum
=
lend
;
pos_bol
=
0
;
pos_cnum
=
cend
;
}
in
(
pstart
,
pend
)
|
None
->
(
Position
.
unknown
,
Position
.
unknown
)
(* For debug use only *)
let
pp_cil_loc
fmt
(
id
:
W
.
Ident
.
ident
)
=
match
id
.
id_loc
with
|
Some
loc
->
Cpp
.
pp_location
fmt
(
convert_location
loc
)
|
None
->
L
.
error
"No location found"
Cpp
.
pp_location
fmt
@@
convert_location
id
.
id_loc
let
pp_cil_loc_pos
fmt
(
id
:
W
.
Ident
.
ident
)
=
match
id
.
id_loc
with
|
Some
loc
->
let
(
ps
,
pe
)
=
convert_location
loc
in
Filepath
.
pp_pos
fmt
ps
;
Filepath
.
pp_pos
fmt
pe
;
|
None
->
L
.
error
"No location found"
(* -------------------------------------------------------------------------- *)
(* --- Type conversion --- *)
...
...
@@ -232,6 +233,7 @@ and lti_of_ts (env : env) (menv : menv) (ts : W.Ty.tysymbol) : C.logic_type_info
}
in
W
.
Ty
.
Hts
.
add
env
.
tenv
ts
lti
;
menv
.
lti
<-
lti
::
menv
.
lti
;
Location
.
Hashtbl
.
add
env
.
tloc
(
convert_location
ts
.
ts_name
.
id_loc
)
lti
;
Logic_type_info
.
Hashtbl
.
add
env
.
ltits
lti
ts
;
lti
...
...
@@ -267,7 +269,9 @@ let li_of_ls (env:env) (menv : menv) (ls : W.Term.lsymbol) : C.logic_info =
l_body
=
C
.
LBnone
;
}
in
W
.
Term
.
Hls
.
add
env
.
lenv
ls
li
;
menv
.
li
<-
li
::
menv
.
li
;
Logic_info
.
Hashtbl
.
add
env
.
lils
li
ls
;
li
Location
.
Hashtbl
.
add
env
.
lloc
(
convert_location
ls
.
ls_name
.
id_loc
)
li
;
Logic_info
.
Hashtbl
.
add
env
.
lils
li
ls
;
li
(* -------------------------------------------------------------------------- *)
(* --- Theory --- *)
...
...
@@ -357,15 +361,23 @@ let () =
pp_lti
lti
pp_tys
ts
;
L
.
result
"Logic type info located at : %a"
pp_id_loc
ts
.
ts_name
;
L
.
result
"CIL Location will be %a"
pp_cil_loc
ts
.
ts_name
;
L
.
result
"with positions %a"
pp_cil_loc_pos
ts
.
ts_name
)
)
env
.
ltits
;
Logic_info
.
Hashtbl
.
iter
(
fun
(
li
)
(
ls
)
->
L
.
result
"Logic info %a is associated to ls : %a "
pp_li
li
pp_ls
ls
;
L
.
result
"Logic info located at : %a"
pp_id_loc
ls
.
ls_name
;
L
.
result
"CIL Location will be %a"
pp_cil_loc
ls
.
ls_name
;
L
.
result
"with positions %a"
pp_cil_loc_pos
ls
.
ls_name
)
)
env
.
lils
;
Location
.
Hashtbl
.
iter
(
fun
(
loc
)
(
lti
)
->
L
.
result
"Logic info %a is associated to loc %a "
pp_lti
lti
Cpp
.
pp_location
loc
;
)
env
.
tloc
;
Location
.
Hashtbl
.
iter
(
fun
(
loc
)
(
li
)
->
L
.
result
"Logic info %a is associated to loc %a "
pp_li
li
Cpp
.
pp_location
loc
;
)
env
.
lloc
;
end
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