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
8e0823a8
Commit
8e0823a8
authored
Oct 2, 2018
by
nilfit
Browse files
Options
Downloads
Patches
Plain Diff
add translation of non-struct constructor expressions
parent
c1344915
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
+15
-2
15 additions, 2 deletions
src/mlw/rust_printer.ml
with
15 additions
and
2 deletions
src/mlw/rust_printer.ml
+
15
−
2
View file @
8e0823a8
...
...
@@ -48,6 +48,7 @@ module Rust = struct
|
Evar
of
pvsymbol
|
Efield
of
expr
*
ident
|
Etup
of
expr
list
|
Eenum
of
rsymbol
*
expr
list
|
Estruct
of
rsymbol
*
rsymbol
list
*
expr
list
(* Rs { r1: e1, r2: e2 } *)
|
Eblock
of
expr
list
|
Ecall
of
rsymbol
*
expr
list
...
...
@@ -105,6 +106,7 @@ module Rust = struct
|
Elet
(
p
,
e1
,
e2
)
->
Elet
(
p
,
clean_expr
e1
,
clean_expr
e2
)
|
Efield
(
e
,
id
)
->
Efield
(
clean_expr
e
,
id
)
|
Etup
el
->
Etup
(
clean_list
el
)
|
Eenum
(
rs
,
el
)
->
Eenum
(
rs
,
clean_list
el
)
|
Estruct
(
rs
,
fl
,
el
)
->
Estruct
(
rs
,
fl
,
clean_list
el
)
|
Ematch
(
e
,
bl
)
->
let
clean_bl
=
List
.
map
(
fun
(
p
,
e
)
->
(
p
,
clean_expr
e
))
bl
in
...
...
@@ -269,9 +271,14 @@ module MLToRust = struct
|
None
,
None
,
_
when
is_rs_tuple
rs
->
Rust
.
Etup
(
el
)
|
None
,
None
,
[
e1
]
when
isfield
->
Rust
.
Efield
(
e1
,
rs
.
rs_name
)
|
None
,
None
,
_
when
isconstructor
()
->
|
None
,
None
,
el
when
isconstructor
()
->
(
match
get_record
info
rs
with
|
[]
->
raise
(
TODO
"Constructor (el)"
)
|
[]
->
let
maybe_box
rs
i
e
=
if
Sbe
.
contains
boxes
.
box_enum
(
rs
.
rs_name
,
i
)
then
box_expr
e
else
e
in
let
el
=
List
.
mapi
(
maybe_box
rs
)
el
in
Rust
.
Eenum
(
rs
,
el
)
|
rsl
->
let
maybe_box
(
rs
:
rsymbol
)
(
e
:
Rust
.
expr
)
=
if
Sid
.
contains
boxes
.
box_fields
rs
.
rs_name
then
box_expr
e
...
...
@@ -364,6 +371,7 @@ module MLToRust = struct
|
Rust
.
Elet
(
_
,
e1
,
e2
)
->
map_and_union
[
e1
;
e2
]
|
Rust
.
Efield
(
e
,
_
)
->
discover_lts_tvs_expr
e
|
Rust
.
Etup
el
->
map_and_union
el
|
Rust
.
Eenum
(
_
,
el
)
->
map_and_union
el
|
Rust
.
Estruct
(
_
,
_
,
el
)
->
map_and_union
el
(* TODO check rsymbols*)
|
Rust
.
Ematch
(
e
,
bl
)
->
let
bel
=
List
.
map
(
fun
(
_
,
e
)
->
e
)
bl
in
...
...
@@ -707,6 +715,7 @@ module Print = struct
(
print_list
comma
(
print_ty
info
))
argl
(
print_ty
info
)
res
(* TODO why not use rs.rs_name? *)
(* find ident of a struct by its rsymbol *)
let
struct_id
rs
=
(
match
rs
.
rs_cty
.
cty_result
.
ity_node
with
...
...
@@ -755,6 +764,10 @@ module Print = struct
|
Efield
(
e
,
id
)
->
fprintf
fmt
"%a.%a"
(
print_expr
info
)
e
(
print_lident
info
)
id
|
Etup
el
->
fprintf
fmt
"(%a)"
(
print_list
comma
(
print_expr
info
))
el
|
Eenum
(
rs
,
[]
)
->
print_uident
info
fmt
(
struct_id
rs
)
|
Eenum
(
rs
,
el
)
->
fprintf
fmt
"%a (%a)"
(
print_uident
info
)
(
struct_id
rs
)
(
print_list
comma
(
print_expr
info
))
el
|
Estruct
(
rs
,
fl
,
el
)
->
fprintf
fmt
"@[<hov 2>%a { %a }@]"
(
print_uident
info
)
(
struct_id
rs
)
(
print_list2
semi
colon
(
print_rs
info
)
(
print_expr
info
))
(
fl
,
el
)
...
...
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