Remove annotations from michelson or.

This commit is contained in:
Sander Spies 2020-04-13 10:59:36 +02:00
parent 42b05c0437
commit 6a6c8468a6
4 changed files with 14 additions and 3 deletions

View File

@ -17,7 +17,7 @@ let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "michelson_or_tree.mligo" ; "main" ] ;
[%expect {|
{ parameter unit ;
storage (or (int %m_left) (or %m_right (int %m_left) (nat %m_right))) ;
storage (or int (or int nat)) ;
code { PUSH int 1 ;
LEFT nat ;
RIGHT int ;

View File

@ -163,6 +163,7 @@ let rec transpile_type (t:AST.type_expression) : type_value result =
)
(* TODO hmm *)
| T_sum m ->
let is_michelson_or = Stage_common.Helpers.is_michelson_or m in
let node = Append_tree.of_list @@ kv_list_of_cmap m in
let aux a b : type_value annotated result =
let%bind a = a in
@ -172,7 +173,12 @@ let rec transpile_type (t:AST.type_expression) : type_value result =
let%bind m' = Append_tree.fold_ne
(fun (Stage_common.Types.Constructor ann, a) ->
let%bind a = transpile_type a in
ok (Some (String.uncapitalize_ascii ann), a))
ok ((
if is_michelson_or then
None
else
Some (String.uncapitalize_ascii ann)),
a))
aux node in
ok @@ snd m'
| T_record m ->

View File

@ -66,3 +66,8 @@ let kv_list_of_record_or_tuple (m: _ LMap.t) =
tuple_of_record m
else
List.rev @@ LMap.to_kv_list m
let is_michelson_or (t: _ constructor_map) =
CMap.cardinal t = 2 &&
(CMap.mem (Constructor "M_left") t) &&
(CMap.mem (Constructor "M_right") t)

View File

@ -24,7 +24,7 @@ val get_pair :
val tuple_of_record : 'a LMap.t -> (label * 'a) list
val list_of_record_or_tuple : 'a LMap.t -> 'a list
val kv_list_of_record_or_tuple : 'a LMap.t -> (label * 'a) list
val is_michelson_or : 'a Types.constructor_map -> bool
val bind_map_lmapi :