Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
122
Issues
122
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
2fba6975
Commit
2fba6975
authored
Feb 01, 2013
by
MARCHE Claude
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended the use_api example and fixed the bench
parent
70badf6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
20 deletions
+28
-20
Makefile.in
Makefile.in
+7
-4
examples/use_api/use_api.ml
examples/use_api/use_api.ml
+18
-16
src/whyml/mlw_ty.mli
src/whyml/mlw_ty.mli
+3
-0
No files found.
Makefile.in
View file @
2fba6975
...
...
@@ -1141,13 +1141,14 @@ testl-type: bin/why3.byte
test-api.byte
:
examples/use_api/use_api.ml lib/why3/why3.cma
$(
if
$(QUIET)
,@echo
'Ocaml $<'
&&
)
\
ocaml
-I
lib/why3
$(INCLUDES)
$(EXTCMA)
lib/why3/why3.cma
$<
\
||
(
printf
"Test of Why API calls failed. Please fix it"
;
exit
2
)
||
(
rm
-f
test-api.byte
;
printf
"Test of Why API calls failed. Please fix it"
;
exit
2
)
@
rm
-f
test-api.byte
;
test-api.opt
:
examples/use_api/use_api.ml lib/why3/why3.cmxa
$(
if
$(QUIET)
,@echo
'Ocamlopt $<'
&&
)
\
(
$(OCAMLOPT)
-o
$@
-I
lib/why3
$(INCLUDES)
$(EXTCMXA)
lib/why3/why3.cmxa
$<
\
&&
./test-api.opt
)
\
||
(
printf
"Test of Why API calls failed. Please fix it"
;
exit
2
)
||
(
rm
-f
test-api.opt
;
printf
"Test of Why API calls failed. Please fix it"
;
exit
2
)
@
rm
-f
test-api.opt
#test-shape: lib/why3/why3.cma
...
...
@@ -1156,14 +1157,16 @@ test-api.opt: examples/use_api/use_api.ml lib/why3/why3.cmxa
test-session.byte
:
examples/use_api/create_session.ml lib/why3/why3.cma
$(
if
$(QUIET)
,@echo
'Ocaml $<'
&&
)
\
ocaml
-I
lib/why3
$(INCLUDES)
$(EXTCMA)
lib/why3/why3.cma
$<
\
||
(
printf
"Test of Why API calls for Session module failed. Please fix it"
;
exit
2
)
||
(
rm
-f
why3session.xml
;
\
printf
"Test of Why API calls for Session module failed. Please fix it"
;
exit
2
)
@
rm
-f
why3session.xml
test-session.opt
:
examples/use_api/create_session.ml lib/why3/why3.cmxa
$(
if
$(QUIET)
,@echo
'Ocamlopt $<'
&&
)
\
(
$(OCAMLOPT)
-o
$@
-I
lib/why3
$(INCLUDES)
$(EXTCMXA)
lib/why3/why3.cmxa
$<
\
&&
./test-session.opt
)
\
||
(
printf
"Test of Why API calls for Session module failed. Please fix it"
;
exit
2
)
||
(
rm
-f
test-session.opt why3session.xml
;
\
printf
"Test of Why API calls for Session module failed. Please fix it"
;
exit
2
)
@
rm
-f
test-session.opt why3session.xml
...
...
examples/use_api/use_api.ml
View file @
2fba6975
...
...
@@ -351,40 +351,42 @@ let d2 =
}
in
let
body
=
(*
ref 0
*)
(*
building expression "ref 0"
*)
let
e
=
(* recall that "ref" has type
forall 'a, 'a -> ref 'a *)
(* (???) we built the instance of 'a by in
t *)
(*
(???) or we built a dummy effective parameter of type int ?
*)
(* recall that "ref" has type
"(v:'a) -> ref 'a". We need to build an
instance of i
t *)
(*
we first built a dummy effective parameter v of type int
*)
let
pv
=
Mlw_ty
.
create_pvsymbol
(
Ident
.
id_fresh
"
a
"
)
(
Mlw_ty
.
vty_value
Mlw_ty
.
ity_int
)
(
Ident
.
id_fresh
"
v
"
)
(
Mlw_ty
.
vty_value
Mlw_ty
.
ity_int
)
in
(*
ity is (ref int)
with a *fresh* region *)
(*
we build "ref int"
with a *fresh* region *)
let
ity
=
Mlw_ty
.
ity_app_fresh
ref_type
[
Mlw_ty
.
ity_int
]
in
(*
??? the type (int -> ref <fresh region> int) ?
*)
(*
we build the type "(v:int) -> ref <fresh region> int)"
*)
let
vta
=
Mlw_ty
.
vty_arrow
[
pv
]
(
Mlw_ty
.
VTvalue
(
Mlw_ty
.
vty_value
ity
))
in
(* e1 : the appropriate instance of "ref" *)
let
e1
=
Mlw_expr
.
e_arrow
ref_fun
vta
in
(* we apply it to 0 *)
let
c0
=
Mlw_expr
.
e_const
(
Number
.
ConstInt
(
Number
.
int_const_dec
"0"
))
in
Mlw_expr
.
e_app
e1
[
c0
]
in
(* let x = ref 0 *)
(*
building the first part of the
let x = ref 0 *)
let
letdef
=
Mlw_expr
.
create_let_defn
(
Ident
.
id_fresh
"x"
)
e
in
(* get back the variable x *)
let
var_x
=
match
letdef
.
Mlw_expr
.
let_sym
with
|
Mlw_expr
.
LetV
vs
->
vs
|
Mlw_expr
.
LetA
_
->
assert
false
in
(*
!x
*)
(*
building expression "!x"
*)
let
bang_x
=
(* recall that "!" as type forall 'a. ref 'a -> 'a *)
let
pv
=
Mlw_ty
.
create_pvsymbol
(
Ident
.
id_fresh
"r"
)
var_x
.
Mlw_ty
.
pv_vtv
in
(* recall that "!" as type "ref 'a -> 'a" *)
(* we build a dummy parameter r of the same type as x *)
let
vta
=
Mlw_ty
.
vty_arrow
[
pv
]
Mlw_ty
.
vty_arrow
[
var_x
]
(
Mlw_ty
.
VTvalue
(
Mlw_ty
.
vty_value
Mlw_ty
.
ity_int
))
in
Mlw_expr
.
e_arrow
get_fun
vta
let
e1
=
Mlw_expr
.
e_arrow
get_fun
vta
in
Mlw_expr
.
e_app
e1
[
Mlw_expr
.
e_value
var_x
]
in
(* the complete body *)
Mlw_expr
.
e_let
letdef
bang_x
...
...
@@ -420,5 +422,5 @@ let () =
(*
ocaml
c -I ../../lib/why3 -c use_api.ml
ocaml
-I ../../lib/why3 unix.cma nums.cma str.cma dynlink.cma ../../lib/why3/why3.cma use_api.ml
*)
src/whyml/mlw_ty.mli
View file @
2fba6975
...
...
@@ -34,6 +34,7 @@ module rec T : sig
its_priv
:
bool
;
}
(** ity = individual type in programs, first-order, i.e. no functions *)
and
ity
=
private
{
ity_node
:
ity_node
;
ity_vars
:
varset
;
...
...
@@ -85,6 +86,8 @@ exception UnboundRegion of region
val
create_region
:
preid
->
ity
->
region
(** creation of a symbol for type in programs *)
val
create_itysymbol
:
preid
->
?
abst
:
bool
->
?
priv
:
bool
->
?
inv
:
bool
->
tvsymbol
list
->
region
list
->
ity
option
->
itysymbol
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment