Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
why3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nils Fitinghoff
why3
Commits
7b61959d
Commit
7b61959d
authored
Sep 7, 2018
by
nilfit
Browse files
Options
Downloads
Patches
Plain Diff
some comments
parent
5b19e8af
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mlw/rust_printer.ml
+10
-5
10 additions, 5 deletions
src/mlw/rust_printer.ml
with
10 additions
and
5 deletions
src/mlw/rust_printer.ml
+
10
−
5
View file @
7b61959d
...
@@ -19,6 +19,7 @@ module Rust = struct
...
@@ -19,6 +19,7 @@ module Rust = struct
type
pat
=
type
pat
=
|
Pwild
(* _ *)
|
Pwild
(* _ *)
|
Pvar
of
vsymbol
(* vs *)
|
Pvar
of
vsymbol
(* vs *)
(* TODO mut? ref? maybe we need to wrap all out vsymbols *)
|
Pde_str
of
rsymbol
list
*
pat
list
(* destructure struct *)
|
Pde_str
of
rsymbol
list
*
pat
list
(* destructure struct *)
(* { l1: p1, l2: p2; .. } rust *)
(* { l1: p1, l2: p2; .. } rust *)
|
Pde_enum
of
lsymbol
*
pat
list
(* destructure enum *)
|
Pde_enum
of
lsymbol
*
pat
list
(* destructure enum *)
...
@@ -210,7 +211,9 @@ module MLToRust = struct
...
@@ -210,7 +211,9 @@ module MLToRust = struct
Rust
.
Eif
(
translate_expr
info
ei
,
translate_expr
info
et
,
Rust
.
Eif
(
translate_expr
info
ei
,
translate_expr
info
et
,
translate_expr
info
ee
)
translate_expr
info
ee
)
(* TODO special cases *)
(* TODO special cases *)
|
Mltree
.
Eassign
_
->
raise
(
TODO
"Eassign"
)
|
Mltree
.
Eassign
_
->
(* struct field assignment *)
raise
(
TODO
"Eassign"
)
|
Ematch
(
e1
,
[(
p
,
e2
)]
,
[]
)
->
|
Ematch
(
e1
,
[(
p
,
e2
)]
,
[]
)
->
(* TODO is this always irrefutable? *)
(* TODO is this always irrefutable? *)
Rust
.
Elet
(
translate_pat
info
p
,
translate_expr
info
e1
,
Rust
.
Elet
(
translate_pat
info
p
,
translate_expr
info
e1
,
...
@@ -227,8 +230,8 @@ module MLToRust = struct
...
@@ -227,8 +230,8 @@ module MLToRust = struct
|
Efor
(
pv1
,
pv2
,
dir
,
pv3
,
e
)
->
|
Efor
(
pv1
,
pv2
,
dir
,
pv3
,
e
)
->
let
b
=
translate_expr
info
e
in
let
b
=
translate_expr
info
e
in
let
r
=
(
match
dir
with
let
r
=
(
match
dir
with
|
Mltree
.
To
->
Rust
.
Erange_inc
(
Rust
.
Evar
pv2
,
Rust
.
Evar
pv3
)
|
To
->
Rust
.
Erange_inc
(
Rust
.
Evar
pv2
,
Rust
.
Evar
pv3
)
|
Mltree
.
DownTo
->
|
DownTo
->
(* (pv3..pv2).rev() *)
(* (pv3..pv2).rev() *)
let
range
=
Rust
.
Erange_inc
(
Rust
.
Evar
pv3
,
Rust
.
Evar
pv2
)
in
let
range
=
Rust
.
Erange_inc
(
Rust
.
Evar
pv3
,
Rust
.
Evar
pv2
)
in
Rust
.
Ecall
(
RSsyn
"(%1).rev()"
,
[
range
])
Rust
.
Ecall
(
RSsyn
"(%1).rev()"
,
[
range
])
...
@@ -236,7 +239,9 @@ module MLToRust = struct
...
@@ -236,7 +239,9 @@ module MLToRust = struct
Rust
.
Efor
(
pv1
,
r
,
Rust
.
Eblock
[
b
])
Rust
.
Efor
(
pv1
,
r
,
Rust
.
Eblock
[
b
])
|
Mltree
.
Eraise
(
_
,
_
)
->
raise
(
TODO
"Eraise"
)
|
Mltree
.
Eraise
(
_
,
_
)
->
raise
(
TODO
"Eraise"
)
|
Mltree
.
Eexn
(
_
,
_
,
_
)
->
raise
(
TODO
"Eexn"
)
|
Mltree
.
Eexn
(
_
,
_
,
_
)
->
raise
(
TODO
"Eexn"
)
|
Mltree
.
Eignore
_
->
raise
(
TODO
"Eignore"
)
|
Mltree
.
Eignore
_
->
raise
(
TODO
"Eignore"
)
(* let _ = e, or do we need a _name to avoid dropping early? *)
|
Mltree
.
Eany
_
->
raise
(
TODO
"Eany"
)
|
Mltree
.
Eany
_
->
raise
(
TODO
"Eany"
)
|
Eabsurd
->
Rust
.
Eunreachable
|
Eabsurd
->
Rust
.
Eunreachable
|
Mltree
.
Ehole
->
raise
(
TODO
"Ehole"
)
|
Mltree
.
Ehole
->
raise
(
TODO
"Ehole"
)
...
@@ -490,7 +495,7 @@ module Print = struct
...
@@ -490,7 +495,7 @@ module Print = struct
|
None
->
|
None
->
(* print_slt_stv fmt (lts, (Stv.of_list tl)) *)
(* tl is ty not tvsymbol *)
(* print_slt_stv fmt (lts, (Stv.of_list tl)) *)
(* tl is ty not tvsymbol *)
match
tl
with
match
tl
with
(* TODO make a function
that
print_slt_ty handles <> *)
(* TODO make a function print_slt_ty
that
handles <> *)
|
[]
->
(
print_uident
info
)
fmt
ts
|
[]
->
(
print_uident
info
)
fmt
ts
|
tl
->
|
tl
->
fprintf
fmt
"%a<%a>"
(
print_uident
info
)
ts
fprintf
fmt
"%a<%a>"
(
print_uident
info
)
ts
...
...
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