diff options
author | Son Ho | 2022-02-08 17:51:04 +0100 |
---|---|---|
committer | Son Ho | 2022-02-08 17:51:04 +0100 |
commit | 1e6f3fb7d8ac8e72ca38f08d7e4be5c835e3443a (patch) | |
tree | 5959874115481303a6f662ec4c1244307f1ee089 /src/PrintPure.ml | |
parent | b583d18a8336b137b445cc01b713767f354168f4 (diff) |
Make progress on implementing support for types and functions like
Option and Vec
Diffstat (limited to 'src/PrintPure.ml')
-rw-r--r-- | src/PrintPure.ml | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/PrintPure.ml b/src/PrintPure.ml index 5c25f2bd..f0e5df77 100644 --- a/src/PrintPure.ml +++ b/src/PrintPure.ml @@ -265,7 +265,23 @@ let adt_g_value_to_string (fmt : value_formatter) else if variant_id = result_fail_id then ( assert (field_values = []); "@Result::Fail") - else failwith "Unreachable: improper variant id for result type") + else failwith "Unreachable: improper variant id for result type" + | Option -> + let variant_id = Option.get variant_id in + if variant_id = option_some_id then + match field_values with + | [ v ] -> "@Option::Some " ^ v + | _ -> failwith "Option::Some takes exactly one value" + else if variant_id = option_none_id then ( + assert (field_values = []); + "@Option::None") + else failwith "Unreachable: improper variant id for result type" + | Vec -> + assert (variant_id = None); + let field_values = + List.mapi (fun i v -> string_of_int i ^ " -> " ^ v) field_values + in + "Vec [" ^ String.concat "; " field_values ^ "]") | _ -> failwith "Inconsistent typed value" let rec typed_lvalue_to_string (fmt : value_formatter) (v : typed_lvalue) : |