Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
why3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Why3
why3
Commits
c1cb1717
Commit
c1cb1717
authored
11 years ago
by
MARCHE Claude
Browse files
Options
Downloads
Patches
Plain Diff
Exec: support for the "for" loop
parent
880a4418
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/whyml/mlw_interp.ml
+21
-1
21 additions, 1 deletion
src/whyml/mlw_interp.ml
tests/test_exec.mlw
+29
-0
29 additions, 0 deletions
tests/test_exec.mlw
with
50 additions
and
1 deletion
src/whyml/mlw_interp.ml
+
21
−
1
View file @
c1cb1717
...
...
@@ -461,6 +461,27 @@ let rec eval_expr env (s:state) (e : expr) : result * state =
|
Normal
_
,
s'
->
eval_expr
env
s'
e
|
_
->
r
end
|
Efor
(
pvs
,
(
pvs1
,
dir
,
pvs2
)
,_
inv
,
e1
)
->
begin
try
let
a
=
big_int_of_term
(
Mvs
.
find
pvs1
.
pv_vs
env
.
vsenv
)
in
let
b
=
big_int_of_term
(
Mvs
.
find
pvs2
.
pv_vs
env
.
vsenv
)
in
let
le
,
suc
=
match
dir
with
|
To
->
Big_int
.
le_big_int
,
Big_int
.
succ_big_int
|
DownTo
->
Big_int
.
ge_big_int
,
Big_int
.
pred_big_int
in
let
rec
iter
i
s
=
if
le
i
b
then
let
env'
=
bind_vs
pvs
.
pv_vs
(
term_of_big_int
i
)
env
in
match
eval_expr
env'
s
e1
with
|
Normal
_
,
s'
->
iter
(
suc
i
)
s'
|
r
->
r
else
Normal
t_void
,
s
in
iter
a
s
with
NotNum
->
Irred
e
,
s
end
|
Ecase
(
e1
,
ebl
)
->
begin
match
eval_expr
env
s
e1
with
...
...
@@ -474,7 +495,6 @@ let rec eval_expr env (s:state) (e : expr) : result * state =
|
Eassign
_
|
Eghost
_
|
Eany
_
|
Efor
_
|
Eabstr
_
|
Eassert
_
|
Eabsurd
->
...
...
This diff is collapsed.
Click to expand it.
tests/test_exec.mlw
+
29
−
0
View file @
c1cb1717
...
...
@@ -11,6 +11,35 @@ module M
let y () : list int =
Cons 12 (Cons 34 (Cons 56 Nil)) ++ Cons 78 (Cons 90 Nil)
end
module Map
use import int.Int
use import map.Map
exception Found int
let search (t:map int int) (len:int) (v:int) : int =
try
for i=0 to len-1 do
if t[i] = v then raise (Found i)
done;
-1
with Found i -> i
end
constant t : map int int = (const 0)[0 <- 12][1 <- 42][2 <- 67]
let test12 () = search t 3 12
let test42 () = search t 3 42
let test67 () = search t 3 67
let test0 () = search t 3 0
end
module Ref
use import ref.Ref
val r: ref int
...
...
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