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
0826a0d7
Commit
0826a0d7
authored
8 months ago
by
Kilyan Le Gallic
Committed by
Allan Blanchard
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
[wp] Importing logic_info and logic_type_info from parsed @import clauses
parent
a909def1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/wp/Why3Import.ml
+64
-52
64 additions, 52 deletions
src/plugins/wp/Why3Import.ml
with
64 additions
and
52 deletions
src/plugins/wp/Why3Import.ml
+
64
−
52
View file @
0826a0d7
...
@@ -69,11 +69,11 @@ let pp_id fmt (id: W.Ident.ident) =
...
@@ -69,11 +69,11 @@ let pp_id fmt (id: W.Ident.ident) =
Format
.
pp_print_string
fmt
id
.
id_string
Format
.
pp_print_string
fmt
id
.
id_string
(* For debug only*)
(* For debug only*)
let
pp_tys
fmt
(
tys
:
W
.
Ty
.
tysymbol
)
=
let
_
pp_tys
fmt
(
tys
:
W
.
Ty
.
tysymbol
)
=
W
.
Pretty
.
print_ty_decl
fmt
tys
W
.
Pretty
.
print_ty_decl
fmt
tys
(* For debug only*)
(* For debug only*)
let
pp_ls
fmt
ls
=
let
_
pp_ls
fmt
ls
=
W
.
Pretty
.
print_ls
fmt
ls
W
.
Pretty
.
print_ls
fmt
ls
(* For debug only*)
(* For debug only*)
...
@@ -91,7 +91,7 @@ let pp_li fmt (li : C.logic_info) =
...
@@ -91,7 +91,7 @@ let pp_li fmt (li : C.logic_info) =
Cpp
.
pp_logic_info
fmt
li
Cpp
.
pp_logic_info
fmt
li
(* For debug only*)
(* For debug only*)
let
pp_lvs
fmt
(
lvs
:
C
.
logic_var
list
)
=
let
_
pp_lvs
fmt
(
lvs
:
C
.
logic_var
list
)
=
List
.
iter
(
fun
(
lv
:
C
.
logic_var
)
->
List
.
iter
(
fun
(
lv
:
C
.
logic_var
)
->
Format
.
fprintf
fmt
"@ %a: %a"
Format
.
fprintf
fmt
"@ %a: %a"
Cpp
.
pp_logic_var
lv
Cpp
.
pp_logic_type
lv
.
lv_type
Cpp
.
pp_logic_var
lv
Cpp
.
pp_logic_type
lv
.
lv_type
...
@@ -180,7 +180,7 @@ let convert_location (wloc : Why3.Loc.position option) : C.location =
...
@@ -180,7 +180,7 @@ let convert_location (wloc : Why3.Loc.position option) : C.location =
(* For debug use only *)
(* For debug use only *)
let
pp_cil_loc
fmt
(
id
:
W
.
Ident
.
ident
)
=
let
_
pp_cil_loc
fmt
(
id
:
W
.
Ident
.
ident
)
=
Cpp
.
pp_location
fmt
@@
convert_location
id
.
id_loc
Cpp
.
pp_location
fmt
@@
convert_location
id
.
id_loc
...
@@ -267,45 +267,50 @@ let li_of_ls (env:env) (menv : menv) (ls : W.Term.lsymbol) : C.logic_info =
...
@@ -267,45 +267,50 @@ let li_of_ls (env:env) (menv : menv) (ls : W.Term.lsymbol) : C.logic_info =
let
import_theory
(
env
:
env
)
thname
=
let
import_theory
(
env
:
env
)
thname
=
let
theory_name
,
theory_path
=
extract_path
thname
in
let
theory_name
,
theory_path
=
extract_path
thname
in
try
try
let
menv
:
menv
=
{
li
=
[]
;
lti
=
[]
}
in
if
not
(
Datatype
.
String
.
Hashtbl
.
mem
env
.
menv
thname
)
then
let
theory
=
W
.
Env
.
read_theory
env
.
wenv
theory_path
theory_name
in
begin
List
.
iter
(
fun
(
tdecl
:
T
.
tdecl
)
->
let
menv
:
menv
=
{
li
=
[]
;
lti
=
[]
}
in
match
tdecl
.
td_node
with
let
theory
=
W
.
Env
.
read_theory
env
.
wenv
theory_path
theory_name
in
|
Decl
decl
->
List
.
iter
(
fun
(
tdecl
:
T
.
tdecl
)
->
begin
match
tdecl
.
td_node
with
match
decl
.
d_node
with
|
Decl
decl
->
|
Dtype
ts
->
begin
L
.
debug
~
dkey
"Decl and type %a"
pp_id
ts
.
ts_name
;
match
decl
.
d_node
with
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ts
.
ts_name
;
|
Dtype
ts
->
let
lti
=
lti_of_ts
env
menv
ts
in
L
.
debug
~
dkey
"Decl and type %a"
pp_id
ts
.
ts_name
;
L
.
debug
~
dkey
"Correspondign LTI %a"
pp_lti
lti
;
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ts
.
ts_name
;
|
Ddata
ddatas
->
let
lti
=
lti_of_ts
env
menv
ts
in
List
.
iter
L
.
debug
~
dkey
"Correspondign LTI %a"
pp_lti
lti
;
(
fun
((
ts
,
_
)
:
W
.
Decl
.
data_decl
)
->
|
Ddata
ddatas
->
L
.
debug
~
dkey
"Decl and data %a"
pp_id
ts
.
ts_name
;
List
.
iter
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ts
.
ts_name
;
(
fun
((
ts
,
_
)
:
W
.
Decl
.
data_decl
)
->
let
lti
=
lti_of_ts
env
menv
ts
in
L
.
debug
~
dkey
"Decl and data %a"
pp_id
ts
.
ts_name
;
L
.
debug
~
dkey
"Correspondign data LTI %a"
pp_lti
lti
;
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ts
.
ts_name
;
)
ddatas
let
lti
=
lti_of_ts
env
menv
ts
in
|
Dparam
ls
->
L
.
debug
~
dkey
"Correspondign data LTI %a"
pp_lti
lti
;
L
.
debug
~
dkey
"Decl and dparam %a"
pp_id
ls
.
ls_name
;
)
ddatas
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ls
.
ls_name
|
Dparam
ls
->
|
Dlogic
dlogics
->
L
.
debug
~
dkey
"Decl and dparam %a"
pp_id
ls
.
ls_name
;
List
.
iter
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ls
.
ls_name
(
fun
((
ls
,_
)
:
W
.
Decl
.
logic_decl
)
->
|
Dlogic
dlogics
->
L
.
debug
~
dkey
"Decl and dlogic %a"
pp_id
ls
.
ls_name
;
List
.
iter
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ls
.
ls_name
;
(
fun
((
ls
,_
)
:
W
.
Decl
.
logic_decl
)
->
let
li
=
li_of_ls
env
menv
ls
in
L
.
debug
~
dkey
"Decl and dlogic %a"
pp_id
ls
.
ls_name
;
L
.
debug
~
dkey
"Corresponding dlogic LTI %a"
pp_li
li
;
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ls
.
ls_name
;
)
dlogics
let
li
=
li_of_ls
env
menv
ls
in
|
_
->
L
.
debug
~
dkey
"Other type of Decl"
L
.
debug
~
dkey
"Corresponding dlogic LTI %a"
pp_li
li
;
end
)
dlogics
|
Use
_
|
Clone
_
|
Meta
_
->
L
.
debug
~
dkey
""
|
_
->
L
.
debug
~
dkey
"Other type of Decl"
)
theory
.
th_decls
;
end
Datatype
.
String
.
Hashtbl
.
add
env
.
menv
thname
|
Use
_
|
Clone
_
|
Meta
_
->
L
.
debug
~
dkey
""
{
logics
=
List
.
rev
menv
.
li
;
)
theory
.
th_decls
;
types
=
List
.
rev
menv
.
lti
;
Datatype
.
String
.
Hashtbl
.
add
env
.
menv
thname
paths
=
theory_path
};
{
logics
=
List
.
rev
menv
.
li
;
types
=
List
.
rev
menv
.
lti
;
paths
=
theory_path
};
end
else
L
.
error
"Trying to register %s a second time, ignoring"
thname
;
with
W
.
Env
.
LibraryNotFound
_
->
with
W
.
Env
.
LibraryNotFound
_
->
L
.
error
"Library %s not found"
thname
L
.
error
"Library %s not found"
thname
...
@@ -324,21 +329,28 @@ module Env = WpContext.StaticGenerator
...
@@ -324,21 +329,28 @@ module Env = WpContext.StaticGenerator
add_builtins
env
;
env
add_builtins
env
;
env
end
)
end
)
let
loader
(
ctxt
:
Logic_typing
.
module_builder
)
(
loc
:
C
.
location
)
(
m
:
string
list
)
=
let
loader
(
ctxt
:
Logic_typing
.
module_builder
)
(
_
:
C
.
location
)
(
m
:
string
list
)
=
begin
begin
(* Use Env.get () to obtain the global env of the current project *)
(* Use Env.get () to obtain the global env of the current project *)
(* Use import_theory if the module is not in the hashtbl *)
(* Use import_theory if the module is not in the hashtbl *)
(* Register logics in ctxt for the imported (or cached) module *)
(* Register logics in ctxt for the imported (or cached) module *)
L
.
result
"[test-import:%d] Loading %s.@."
(
fst
loc
)
.
pos_lnum
(
String
.
concat
"::"
m
)
;
let
t
=
Cil_const
.
make_logic_type
"t"
in
L
.
result
"Importing Why3 theory %s.@."
(
String
.
concat
"::"
m
)
;
let
check
=
Cil_const
.
make_logic_info
"check"
in
let
thname
=
String
.
concat
"."
m
in
let
x
=
Cil_const
.
make_logic_var_formal
"x"
(
Ltype
(
t
,
[]
))
in
import_theory
(
Env
.
get
()
)
thname
;
let
k
=
Cil_const
.
make_logic_var_formal
"k"
Linteger
in
let
env
=
Env
.
get
()
in
check
.
l_profile
<-
[
x
;
k
]
;
let
current_module
=
Datatype
.
String
.
Hashtbl
.
find
env
.
menv
thname
in
ctxt
.
add_logic_type
loc
t
;
List
.
iter
(
fun
(
lti
,
loc
)
->
ctxt
.
add_logic_function
loc
check
;
ctxt
.
add_logic_type
loc
lti
;
)
current_module
.
types
;
List
.
iter
(
fun
(
li
,
loc
)
->
ctxt
.
add_logic_function
loc
li
;
)
current_module
.
logics
;
L
.
result
"Successfully imported theory at %s"
@@
String
.
concat
"::"
current_module
.
paths
;
end
end
let
()
=
let
()
=
...
...
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