Skip to content
Snippets Groups Projects
Commit 7b61959d authored by nilfit's avatar nilfit
Browse files

some comments

parent 5b19e8af
No related branches found
No related tags found
No related merge requests found
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment