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
9372a84f
Commit
9372a84f
authored
6 years ago
by
nilfit
Browse files
Options
Downloads
Patches
Plain Diff
fix printing of enum expressions
parent
81de7472
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
-8
10 additions, 8 deletions
src/mlw/rust_printer.ml
with
10 additions
and
8 deletions
src/mlw/rust_printer.ml
+
10
−
8
View file @
9372a84f
...
...
@@ -50,6 +50,8 @@ module Rust = struct
|
Eassign
of
pvsymbol
*
rsymbol
*
pvsymbol
|
Etup
of
expr
list
|
Eenum
of
rsymbol
*
expr
list
(* TODO change the rsymbol for Estruct to just an ident so the printer
* doesn't have to do anything smart *)
|
Estruct
of
rsymbol
*
rsymbol
list
*
expr
list
(* Rs { r1: e1, r2: e2 } *)
|
Eblock
of
expr
list
|
Ecall
of
rsymbol
*
expr
list
...
...
@@ -281,6 +283,7 @@ module MLToRust = struct
else
e
in
let
el
=
List
.
mapi
(
maybe_box
rs
)
el
in
Rust
.
Eenum
(
rs
,
el
)
(* FIXME seems to use the name of the type instead of the variant *)
|
rsl
->
let
maybe_box
(
rs
:
rsymbol
)
(
e
:
Rust
.
expr
)
=
if
Sid
.
contains
boxes
.
box_fields
rs
.
rs_name
then
box_expr
e
...
...
@@ -720,13 +723,12 @@ 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
=
(* find ident of a struct type by its rsymbol *)
let
rs_type_ident
rs
=
(
match
rs
.
rs_cty
.
cty_result
.
ity_node
with
|
Ity
.
Ityreg
reg
->
reg
.
reg_its
.
its_ts
.
ts_name
|
Ity
.
Ityapp
(
its
,
_
,
_
)
->
its
.
its_ts
.
ts_name
|
Ity
.
Ityvar
_
->
raise
(
TODO
"
struct_id
: var"
))
|
Ity
.
Ityvar
_
->
raise
(
TODO
"
rs_type_ident
: var"
))
let
rec
print_pat
info
fmt
pat
=
match
pat
with
...
...
@@ -735,7 +737,7 @@ module Print = struct
fprintf
fmt
"%s%a"
(
if
mut
then
"mut "
else
""
)
(
print_lident
info
)
id
(* TODO ref are still not mut *)
|
Pde_str
(
rs
,
rsl
,
pl
)
->
fprintf
fmt
"@[<hov 2>%a { %a }@]"
(
print_uident
info
)
(
struct_id
rs
)
fprintf
fmt
"@[<hov 2>%a { %a }@]"
(
print_uident
info
)
(
rs_type_ident
rs
)
(
print_list2
comma
colon
(
print_rs
info
)
(
print_pat
info
))
(
rsl
,
pl
)
|
Pde_enum
(
ls
,
[]
)
->
fprintf
fmt
"%a"
(
print_uident
info
)
ls
.
ls_name
...
...
@@ -772,12 +774,12 @@ module Print = struct
fprintf
fmt
"%a.%a = %a"
(
print_lident
info
)
(
pv_name
rho
)
(
print_lident
info
)
rs
.
rs_name
(
print_lident
info
)
(
pv_name
pv
)
|
Etup
el
->
fprintf
fmt
"(%a)"
(
print_list
comma
(
print_expr
info
))
el
|
Eenum
(
rs
,
[]
)
->
print_uident
info
fmt
(
struct_id
rs
)
|
Eenum
(
rs
,
[]
)
->
print_uident
info
fmt
rs
.
rs_name
|
Eenum
(
rs
,
el
)
->
fprintf
fmt
"%a (%a)"
(
print_uident
info
)
(
struct_id
rs
)
fprintf
fmt
"%a (%a)"
(
print_uident
info
)
rs
.
rs_name
(
print_list
comma
(
print_expr
info
))
el
|
Estruct
(
rs
,
fl
,
el
)
->
fprintf
fmt
"@[<hov 2>%a { %a }@]"
(
print_uident
info
)
(
struct_id
rs
)
fprintf
fmt
"@[<hov 2>%a { %a }@]"
(
print_uident
info
)
(
rs_type_ident
rs
)
(
print_list2
comma
colon
(
print_rs
info
)
(
print_expr
info
))
(
fl
,
el
)
|
Eblock
el
->
fprintf
fmt
"@[<hov 2>{@
\n
%a@]@
\n
}"
(
print_list
semi
(
print_expr
info
))
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