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
9694a20b
Commit
9694a20b
authored
8 months ago
by
Kilyan Le Gallic
Committed by
Loïc Correnson
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
[wp] Changed temp_menv to menv for clarity
parent
1a3579e4
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
+25
-29
25 additions, 29 deletions
src/plugins/wp/Why3Import.ml
with
25 additions
and
29 deletions
src/plugins/wp/Why3Import.ml
+
25
−
29
View file @
9694a20b
...
...
@@ -97,11 +97,11 @@ let pp_lvs fmt (lvs : C.logic_var list) =
List
.
iter
(
fun
(
lv
:
C
.
logic_var
)
->
Format
.
fprintf
fmt
"@ %a: %a"
Cpp
.
pp_logic_var
lv
Cpp
.
pp_logic_type
lv
.
lv_type
)
lvs
;
)
lvs
(* -------------------------------------------------------------------------*)
(* --- Types - *)
(* -------------------------------------------------------------------------*)
(* -------------------------------------------------------------------------*)
(* --- Types - *)
(* -------------------------------------------------------------------------*)
type
tvars
=
C
.
logic_type
W
.
Ty
.
Mtv
.
t
...
...
@@ -121,7 +121,7 @@ type env = {
menv
:
why3module
Datatype
.
String
.
Hashtbl
.
t
}
type
temp_
menv
=
{
type
menv
=
{
mutable
lti
:
C
.
logic_type_info
list
;
mutable
li
:
C
.
logic_info
list
;
}
...
...
@@ -133,6 +133,7 @@ let create_empty_env wenv =
let
ltits
=
Logic_type_info
.
Hashtbl
.
create
0
in
let
menv
=
Datatype
.
String
.
Hashtbl
.
create
0
in
{
wenv
;
tenv
;
lenv
;
lils
;
ltits
;
menv
}
(* -------------------------------------------------------------------------- *)
(* --- Built-in --- *)
(* -------------------------------------------------------------------------- *)
...
...
@@ -171,21 +172,21 @@ let tvars_of_txs (txs: W.Ty.tvsymbol list) : string list * tvars =
x
::
txs
,
W
.
Ty
.
Mtv
.
add
tv
(
C
.
Lvar
x
)
tvs
)
txs
([]
,
W
.
Ty
.
Mtv
.
empty
)
let
rec
lt_of_ty
(
env
:
env
)
(
temp_
menv
)
(
tvs
:
tvars
)
(
ty
:
W
.
Ty
.
ty
)
:
C
.
logic_type
=
let
rec
lt_of_ty
(
env
:
env
)
(
menv
)
(
tvs
:
tvars
)
(
ty
:
W
.
Ty
.
ty
)
:
C
.
logic_type
=
match
ty
.
ty_node
with
|
Tyvar
x
->
W
.
Ty
.
Mtv
.
find
x
tvs
|
Tyapp
(
s
,
[]
)
when
W
.
Ty
.(
ts_equal
s
ts_int
)
->
C
.
Linteger
|
Tyapp
(
s
,
[]
)
when
W
.
Ty
.(
ts_equal
s
ts_real
)
->
C
.
Lreal
|
Tyapp
(
s
,
ts
)
->
C
.
Ltype
(
lti_of_ts
env
temp_
menv
s
,
List
.
map
(
lt_of_ty
env
temp_
menv
tvs
)
ts
)
|
Tyapp
(
s
,
ts
)
->
C
.
Ltype
(
lti_of_ts
env
menv
s
,
List
.
map
(
lt_of_ty
env
menv
tvs
)
ts
)
and
lti_of_ts
(
env
:
env
)
(
temp_
menv
:
temp_
menv
)
(
ts
:
W
.
Ty
.
tysymbol
)
:
C
.
logic_type_info
=
and
lti_of_ts
(
env
:
env
)
(
menv
:
menv
)
(
ts
:
W
.
Ty
.
tysymbol
)
:
C
.
logic_type_info
=
try
W
.
Ty
.
Hts
.
find
env
.
tenv
ts
with
Not_found
->
let
(
lt_params
,
tvars
)
=
tvars_of_txs
ts
.
ts_args
in
let
lt_def
=
match
ts
.
ts_def
with
|
NoDef
|
Range
_
|
Float
_
->
None
|
Alias
ty
->
Some
(
C
.
LTsyn
(
lt_of_ty
env
temp_
menv
tvars
ty
))
|
Alias
ty
->
Some
(
C
.
LTsyn
(
lt_of_ty
env
menv
tvars
ty
))
in
let
lti
=
C
.{
...
...
@@ -194,29 +195,28 @@ and lti_of_ts (env : env) (temp_menv : temp_menv) (ts : W.Ty.tysymbol) : C.logic
lt_attr
=
[]
;
}
in
W
.
Ty
.
Hts
.
add
env
.
tenv
ts
lti
;
temp_
menv
.
lti
<-
lti
::
temp_
menv
.
lti
;
menv
.
lti
<-
lti
::
menv
.
lti
;
Logic_type_info
.
Hashtbl
.
add
env
.
ltits
lti
ts
;
lti
(* -------------------------------------------------------------------------- *)
(* --- Functions conversion --- *)
(* -------------------------------------------------------------------------- *)
let
lv_of_ty
(
env
:
env
)
(
temp_
menv
:
temp_
menv
)
(
tvars
:
tvars
)
(
index
)
(
ty
:
W
.
Ty
.
ty
)
:
C
.
logic_var
=
let
lv_of_ty
(
env
:
env
)
(
menv
:
menv
)
(
tvars
:
tvars
)
(
index
)
(
ty
:
W
.
Ty
.
ty
)
:
C
.
logic_var
=
Cil_const
.
make_logic_var_formal
(
Printf
.
sprintf
"x%d"
index
)
@@
(
lt_of_ty
env
temp_
menv
tvars
ty
)
@@
(
lt_of_ty
env
menv
tvars
ty
)
let
lt_of_ty_opt
(
lt_opt
)
=
match
lt_opt
with
|
None
->
C
.
Ctype
(
C
.
TVoid
[]
)
(* Same as logic_typing *)
|
Some
tr
->
tr
let
li_of_ls
(
env
:
env
)
(
temp_
menv
:
temp_
menv
)
(
ls
:
W
.
Term
.
lsymbol
)
:
C
.
logic_info
=
let
li_of_ls
(
env
:
env
)
(
menv
:
menv
)
(
ls
:
W
.
Term
.
lsymbol
)
:
C
.
logic_info
=
let
l_tparams
,
tvars
=
tvars_of_txs
@@
W
.
Ty
.
Stv
.
elements
@@
W
.
Term
.
ls_ty_freevars
ls
in
let
l_type
=
Option
.
map
(
lt_of_ty
env
temp_
menv
tvars
)
ls
.
ls_value
in
let
l_profile
=
List
.
mapi
(
lv_of_ty
env
temp_
menv
tvars
)
ls
.
ls_args
in
let
l_type
=
Option
.
map
(
lt_of_ty
env
menv
tvars
)
ls
.
ls_value
in
let
l_profile
=
List
.
mapi
(
lv_of_ty
env
menv
tvars
)
ls
.
ls_args
in
let
l_args
=
List
.
map
(
fun
(
lv
:
C
.
logic_var
)
->
lv
.
lv_type
)
l_profile
in
let
signature
=
C
.
Larrow
(
l_args
,
lt_of_ty_opt
l_type
)
in
let
li
=
...
...
@@ -230,10 +230,8 @@ let li_of_ls (env:env) (temp_menv : temp_menv) (ls : W.Term.lsymbol) : C.logic_
l_profile
;
l_body
=
C
.
LBnone
;
}
in
W
.
Term
.
Hls
.
add
env
.
lenv
ls
li
;
temp_menv
.
li
<-
li
::
temp_menv
.
li
;
Logic_info
.
Hashtbl
.
add
env
.
lils
li
ls
;
li
menv
.
li
<-
li
::
menv
.
li
;
Logic_info
.
Hashtbl
.
add
env
.
lils
li
ls
;
li
(* -------------------------------------------------------------------------- *)
(* --- Theory --- *)
...
...
@@ -242,7 +240,7 @@ let li_of_ls (env:env) (temp_menv : temp_menv) (ls : W.Term.lsymbol) : C.logic_
let
import_theory
(
env
:
env
)
thname
=
let
theory_name
,
theory_path
=
extract_path
thname
in
try
let
temp_
menv
:
temp_
menv
=
{
li
=
[]
;
lti
=
[]
}
in
let
menv
:
menv
=
{
li
=
[]
;
lti
=
[]
}
in
let
theory
=
W
.
Env
.
read_theory
env
.
wenv
theory_path
theory_name
in
List
.
iter
(
fun
(
tdecl
:
T
.
tdecl
)
->
match
tdecl
.
td_node
with
...
...
@@ -252,14 +250,14 @@ let import_theory (env : env) thname =
|
Dtype
ts
->
L
.
debug
~
dkey
"Decl and type %a"
pp_id
ts
.
ts_name
;
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ts
.
ts_name
;
let
lti
=
lti_of_ts
env
temp_
menv
ts
in
let
lti
=
lti_of_ts
env
menv
ts
in
L
.
debug
~
dkey
"Correspondign LTI %a"
pp_lti
lti
;
|
Ddata
ddatas
->
List
.
iter
(
fun
((
ts
,
_
)
:
W
.
Decl
.
data_decl
)
->
L
.
debug
~
dkey
"Decl and data %a"
pp_id
ts
.
ts_name
;
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ts
.
ts_name
;
let
lti
=
lti_of_ts
env
temp_
menv
ts
in
let
lti
=
lti_of_ts
env
menv
ts
in
L
.
debug
~
dkey
"Correspondign data LTI %a"
pp_lti
lti
;
)
ddatas
|
Dparam
ls
->
...
...
@@ -270,7 +268,7 @@ let import_theory (env : env) thname =
(
fun
((
ls
,_
)
:
W
.
Decl
.
logic_decl
)
->
L
.
debug
~
dkey
"Decl and dlogic %a"
pp_id
ls
.
ls_name
;
L
.
debug
~
dkey
"Location %a"
pp_id_loc
ls
.
ls_name
;
let
li
=
li_of_ls
env
temp_
menv
ls
in
let
li
=
li_of_ls
env
menv
ls
in
L
.
debug
~
dkey
"Corresponding dlogic LTI %a"
pp_li
li
;
)
dlogics
|
_
->
L
.
debug
~
dkey
"Other type of Decl"
...
...
@@ -278,13 +276,12 @@ let import_theory (env : env) thname =
|
Use
_
|
Clone
_
|
Meta
_
->
L
.
debug
~
dkey
""
)
theory
.
th_decls
;
Datatype
.
String
.
Hashtbl
.
add
env
.
menv
thname
{
logics
=
List
.
rev
temp_
menv
.
li
;
types
=
List
.
rev
temp_
menv
.
lti
;
{
logics
=
List
.
rev
menv
.
li
;
types
=
List
.
rev
menv
.
lti
;
paths
=
theory_path
};
with
W
.
Env
.
LibraryNotFound
_
->
L
.
error
"Library %s not found"
thname
(* -------------------------------------------------------------------------- *)
(* --- Main --- *)
(* -------------------------------------------------------------------------- *)
...
...
@@ -327,7 +324,6 @@ let () =
pp_li
li
pp_ls
ls
)
env
.
lils
;
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