From b54bcb8db7c1311491c2f9e6be522242b650c452 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Tue, 28 Apr 2020 21:29:21 +0200 Subject: [PATCH] rename 'michelson_right/left_comb' to 'michelson_pair_right/left_comb' --- .../imperative_to_sugar.ml | 16 +++++++-------- src/passes/6-sugar_to_core/sugar_to_core.ml | 16 +++++++-------- src/passes/8-typer-new/typer.ml | 2 +- src/passes/8-typer-new/wrap.ml | 4 ++-- src/passes/8-typer-old/typer.ml | 8 ++++---- src/passes/operators/helpers.ml | 4 ++-- src/passes/operators/operators.ml | 4 ++-- src/stages/1-ast_imperative/PP.ml | 4 ++-- src/stages/1-ast_imperative/combinators.ml | 8 ++++---- src/stages/1-ast_imperative/types.ml | 4 ++-- src/stages/2-ast_sugar/PP.ml | 4 ++-- src/stages/2-ast_sugar/types.ml | 4 ++-- src/stages/common/PP.ml | 4 ++-- src/stages/common/types.ml | 20 +++++++++---------- .../michelson_comb_type_operators.mligo | 4 ++-- src/test/contracts/michelson_converter.mligo | 4 ++-- 16 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml b/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml index 84cbe11d4..44f498807 100644 --- a/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml +++ b/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml @@ -201,12 +201,12 @@ and compile_type_operator : I.type_operator -> O.type_operator result = let%bind (k,v) = bind_map_pair compile_type_expression (k,v) in ok @@ O.TC_big_map (k,v) | TC_michelson_or _ | TC_michelson_pair _ -> fail @@ Errors.corner_case __LOC__ - | TC_michelson_right_comb c -> + | TC_michelson_pair_right_comb c -> let%bind c = compile_type_expression c in - ok @@ O.TC_michelson_right_comb c - | TC_michelson_left_comb c -> + ok @@ O.TC_michelson_pair_right_comb c + | TC_michelson_pair_left_comb c -> let%bind c = compile_type_expression c in - ok @@ O.TC_michelson_left_comb c + ok @@ O.TC_michelson_pair_left_comb c let rec compile_expression : I.expression -> O.expression result = fun e -> @@ -646,12 +646,12 @@ and uncompile_type_operator : O.type_operator -> I.type_operator result = | TC_big_map (k,v) -> let%bind (k,v) = bind_map_pair uncompile_type_expression (k,v) in ok @@ I.TC_big_map (k,v) - | TC_michelson_right_comb c -> + | TC_michelson_pair_right_comb c -> let%bind c = uncompile_type_expression c in - ok @@ I.TC_michelson_right_comb c - | TC_michelson_left_comb c -> + ok @@ I.TC_michelson_pair_right_comb c + | TC_michelson_pair_left_comb c -> let%bind c = uncompile_type_expression c in - ok @@ I.TC_michelson_left_comb c + ok @@ I.TC_michelson_pair_left_comb c let rec uncompile_expression' : O.expression -> I.expression result = fun e -> diff --git a/src/passes/6-sugar_to_core/sugar_to_core.ml b/src/passes/6-sugar_to_core/sugar_to_core.ml index 659af246e..6d2a4de47 100644 --- a/src/passes/6-sugar_to_core/sugar_to_core.ml +++ b/src/passes/6-sugar_to_core/sugar_to_core.ml @@ -66,12 +66,12 @@ and idle_type_operator : I.type_operator -> O.type_operator result = | TC_big_map (k,v) -> let%bind (k,v) = bind_map_pair idle_type_expression (k,v) in ok @@ O.TC_big_map (k,v) - | TC_michelson_right_comb c -> + | TC_michelson_pair_right_comb c -> let%bind c = idle_type_expression c in - ok @@ O.TC_michelson_right_comb c - | TC_michelson_left_comb c -> + ok @@ O.TC_michelson_pair_right_comb c + | TC_michelson_pair_left_comb c -> let%bind c = idle_type_expression c in - ok @@ O.TC_michelson_left_comb c + ok @@ O.TC_michelson_pair_left_comb c let rec compile_expression : I.expression -> O.expression result = fun e -> @@ -294,12 +294,12 @@ and uncompile_type_operator : O.type_operator -> I.type_operator result = let%bind (k,v) = bind_map_pair uncompile_type_expression (k,v) in ok @@ I.TC_big_map (k,v) | TC_map_or_big_map _ -> failwith "TC_map_or_big_map shouldn't be uncompiled" - | TC_michelson_right_comb c -> + | TC_michelson_pair_right_comb c -> let%bind c = uncompile_type_expression c in - ok @@ I.TC_michelson_right_comb c - | TC_michelson_left_comb c -> + ok @@ I.TC_michelson_pair_right_comb c + | TC_michelson_pair_left_comb c -> let%bind c = uncompile_type_expression c in - ok @@ I.TC_michelson_left_comb c + ok @@ I.TC_michelson_pair_left_comb c let rec uncompile_expression : O.expression -> I.expression result = fun e -> diff --git a/src/passes/8-typer-new/typer.ml b/src/passes/8-typer-new/typer.ml index 4a9343463..309d0b81b 100644 --- a/src/passes/8-typer-new/typer.ml +++ b/src/passes/8-typer-new/typer.ml @@ -181,7 +181,7 @@ and evaluate_type (e:environment) (t:I.type_expression) : O.type_expression resu | TC_contract c -> let%bind c = evaluate_type e c in ok @@ O.TC_contract c - | TC_michelson_right_comb _c | TC_michelson_left_comb _c -> + | TC_michelson_pair_right_comb _c | TC_michelson_pair_left_comb _c -> (* not really sure what to do in the new typer, should be converted to a pair using functions defined in Helpers.Typer.Converter *) simple_fail "to be implemented" in diff --git a/src/passes/8-typer-new/wrap.ml b/src/passes/8-typer-new/wrap.ml index 8e61b5048..8e98e2c4c 100644 --- a/src/passes/8-typer-new/wrap.ml +++ b/src/passes/8-typer-new/wrap.ml @@ -106,8 +106,8 @@ let rec type_expression_to_type_value_copypasted : I.type_expression -> O.type_v | TC_big_map ( k , v ) -> (C_big_map, [k;v]) | TC_map_or_big_map ( k , v) -> (C_map, [k;v]) | TC_contract c -> (C_contract, [c]) - | TC_michelson_right_comb c -> (C_record, [c]) - | TC_michelson_left_comb c -> (C_record, [c]) + | TC_michelson_pair_right_comb c -> (C_record, [c]) + | TC_michelson_pair_left_comb c -> (C_record, [c]) ) in p_constant csttag (List.map type_expression_to_type_value_copypasted args) diff --git a/src/passes/8-typer-old/typer.ml b/src/passes/8-typer-old/typer.ml index 916286e27..90e73ce12 100644 --- a/src/passes/8-typer-old/typer.ml +++ b/src/passes/8-typer-old/typer.ml @@ -13,8 +13,8 @@ type environment = Environment.t module Errors = struct let michelson_comb_no_record (loc:Location.t) () = - let title = (thunk "bad michelson_right_comb type parameter") in - let message () = "michelson_right_comb type operator must be used on a record type" in + let title = (thunk "bad michelson_pair_right_comb type parameter") in + let message () = "michelson_pair_right_comb type operator must be used on a record type" in let data = [ ("location" , fun () -> Format.asprintf "%a" Location.pp loc) ; ] in @@ -660,14 +660,14 @@ and evaluate_type (e:environment) (t:I.type_expression) : O.type_expression resu | TC_contract c -> let%bind c = evaluate_type e c in return @@ T_operator (O.TC_contract c) - | TC_michelson_right_comb c -> + | TC_michelson_pair_right_comb c -> let%bind c' = evaluate_type e c in let%bind lmap = match c'.type_content with | T_record lmap when (not (Ast_typed.Helpers.is_tuple_lmap lmap)) -> ok lmap | _ -> fail (michelson_comb_no_record t.location) in let record = Operators.Typer.Converter.convert_type_to_right_comb (Ast_typed.LMap.to_kv_list lmap) in return @@ record - | TC_michelson_left_comb c -> + | TC_michelson_pair_left_comb c -> let%bind c' = evaluate_type e c in let%bind lmap = match c'.type_content with | T_record lmap when (not (Ast_typed.Helpers.is_tuple_lmap lmap)) -> ok lmap diff --git a/src/passes/operators/helpers.ml b/src/passes/operators/helpers.ml index 1df202339..988185692 100644 --- a/src/passes/operators/helpers.ml +++ b/src/passes/operators/helpers.ml @@ -199,7 +199,7 @@ module Typer = struct let%bind comb_lmap = get_t_record tr in let%bind next = from_right_comb comb_lmap (size-1) in ok (l :: next) - | _ -> simple_fail "Could not convert michelson_right_comb pair to a record" + | _ -> simple_fail "Could not convert michelson_pair_right_comb pair to a record" let rec from_left_comb (l:field_content label_map) (size:int) : (field_content list) result = let l' = List.rev @@ LMap.to_kv_list l in @@ -209,7 +209,7 @@ module Typer = struct let%bind comb_lmap = get_t_record tl in let%bind next = from_left_comb comb_lmap (size-1) in ok (List.append next [r]) - | _ -> simple_fail "Could not convert michelson_left_comb pair to a record" + | _ -> simple_fail "Could not convert michelson_pair_left_comb pair to a record" let convert_from_right_comb (src: field_content label_map) (dst: field_content label_map) : type_content result = let%bind fields = from_right_comb src (LMap.cardinal dst) in diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml index 3eb629da9..582f5d1f4 100644 --- a/src/passes/operators/operators.ml +++ b/src/passes/operators/operators.ml @@ -59,8 +59,8 @@ module Concrete_to_imperative = struct | "map" -> Some (TC_map (unit_expr,unit_expr)) | "big_map" -> Some (TC_big_map (unit_expr,unit_expr)) | "contract" -> Some (TC_contract unit_expr) - | "michelson_right_comb" -> Some (TC_michelson_right_comb unit_expr) - | "michelson_left_comb" -> Some (TC_michelson_left_comb unit_expr) + | "michelson_pair_right_comb" -> Some (TC_michelson_pair_right_comb unit_expr) + | "michelson_pair_left_comb" -> Some (TC_michelson_pair_left_comb unit_expr) | _ -> None let pseudo_modules = function diff --git a/src/stages/1-ast_imperative/PP.ml b/src/stages/1-ast_imperative/PP.ml index a90d067fa..47c19ecba 100644 --- a/src/stages/1-ast_imperative/PP.ml +++ b/src/stages/1-ast_imperative/PP.ml @@ -61,8 +61,8 @@ and type_operator : | TC_big_map (k, v) -> Format.asprintf "Big Map (%a,%a)" f k f v | TC_michelson_or (l,_, r,_) -> Format.asprintf "Michelson_or (%a,%a)" f l f r | TC_michelson_pair (l,_, r,_) -> Format.asprintf "Michelson_pair (%a,%a)" f l f r - | TC_michelson_right_comb e -> Format.asprintf "Michelson_right_comb (%a)" f e - | TC_michelson_left_comb e -> Format.asprintf "Michelson_left_comb (%a)" f e + | TC_michelson_pair_right_comb e -> Format.asprintf "michelson_pair_right_comb (%a)" f e + | TC_michelson_pair_left_comb e -> Format.asprintf "michelson_pair_left_comb (%a)" f e | TC_contract te -> Format.asprintf "Contract (%a)" f te in fprintf ppf "(TO_%s)" s diff --git a/src/stages/1-ast_imperative/combinators.ml b/src/stages/1-ast_imperative/combinators.ml index 9f4e866d5..515bf3b0c 100644 --- a/src/stages/1-ast_imperative/combinators.ml +++ b/src/stages/1-ast_imperative/combinators.ml @@ -63,8 +63,8 @@ let t_set ?loc key : type_expression = make_t ?loc @@ T_operator ( let t_contract ?loc contract : type_expression = make_t ?loc @@ T_operator (TC_contract contract) let t_michelson_or ?loc l l_ann r r_ann : type_expression = make_t ?loc @@ T_operator (TC_michelson_or (l, l_ann, r, r_ann)) let t_michelson_pair ?loc l l_ann r r_ann : type_expression = make_t ?loc @@ T_operator (TC_michelson_pair (l, l_ann, r, r_ann)) -let t_michelson_right_comb ?loc c : type_expression = make_t ?loc @@ T_operator (TC_michelson_right_comb c) -let t_michelson_left_comb ?loc c : type_expression = make_t ?loc @@ T_operator (TC_michelson_left_comb c) +let t_michelson_pair_right_comb ?loc c : type_expression = make_t ?loc @@ T_operator (TC_michelson_pair_right_comb c) +let t_michelson_pair_left_comb ?loc c : type_expression = make_t ?loc @@ T_operator (TC_michelson_pair_left_comb c) (* TODO find a better way than using list*) let t_operator ?loc op lst: type_expression result = @@ -76,8 +76,8 @@ let t_operator ?loc op lst: type_expression result = | TC_big_map (_,_) , [kt;vt] -> ok @@ t_big_map ?loc kt vt | TC_michelson_or (_,l_ann,_,r_ann) , [l;r] -> ok @@ t_michelson_or ?loc l l_ann r r_ann | TC_contract _ , [t] -> ok @@ t_contract t - | TC_michelson_right_comb _ , [c] -> ok @@ t_michelson_right_comb c - | TC_michelson_left_comb _ , [c] -> ok @@ t_michelson_left_comb c + | TC_michelson_pair_right_comb _ , [c] -> ok @@ t_michelson_pair_right_comb c + | TC_michelson_pair_left_comb _ , [c] -> ok @@ t_michelson_pair_left_comb c | _ , _ -> fail @@ bad_type_operator op let make_e ?(loc = Location.generated) expression_content = diff --git a/src/stages/1-ast_imperative/types.ml b/src/stages/1-ast_imperative/types.ml index 3cf403f1a..56c039f06 100644 --- a/src/stages/1-ast_imperative/types.ml +++ b/src/stages/1-ast_imperative/types.ml @@ -28,8 +28,8 @@ and type_operator = | TC_big_map of type_expression * type_expression | TC_michelson_or of type_expression * michelson_prct_annotation * type_expression * michelson_prct_annotation | TC_michelson_pair of type_expression * michelson_prct_annotation * type_expression * michelson_prct_annotation - | TC_michelson_right_comb of type_expression - | TC_michelson_left_comb of type_expression + | TC_michelson_pair_right_comb of type_expression + | TC_michelson_pair_left_comb of type_expression and type_expression = {type_content: type_content; location: Location.t} diff --git a/src/stages/2-ast_sugar/PP.ml b/src/stages/2-ast_sugar/PP.ml index 933d09ee4..6525f2451 100644 --- a/src/stages/2-ast_sugar/PP.ml +++ b/src/stages/2-ast_sugar/PP.ml @@ -52,8 +52,8 @@ and type_operator : (formatter -> type_expression -> unit) -> formatter -> type_ | TC_map (k, v) -> Format.asprintf "Map (%a,%a)" f k f v | TC_big_map (k, v) -> Format.asprintf "Big Map (%a,%a)" f k f v | TC_contract te -> Format.asprintf "Contract (%a)" f te - | TC_michelson_right_comb c -> Format.asprintf "michelson_right_comb (%a)" f c - | TC_michelson_left_comb c -> Format.asprintf "michelson_left_comb (%a)" f c + | TC_michelson_pair_right_comb c -> Format.asprintf "michelson_pair_right_comb (%a)" f c + | TC_michelson_pair_left_comb c -> Format.asprintf "michelson_pair_left_comb (%a)" f c in fprintf ppf "(TO_%s)" s diff --git a/src/stages/2-ast_sugar/types.ml b/src/stages/2-ast_sugar/types.ml index 83f44daf7..4fe98986b 100644 --- a/src/stages/2-ast_sugar/types.ml +++ b/src/stages/2-ast_sugar/types.ml @@ -30,8 +30,8 @@ and type_operator = | TC_set of type_expression | TC_map of type_expression * type_expression | TC_big_map of type_expression * type_expression - | TC_michelson_right_comb of type_expression - | TC_michelson_left_comb of type_expression + | TC_michelson_pair_right_comb of type_expression + | TC_michelson_pair_left_comb of type_expression and type_expression = {type_content: type_content; location: Location.t} diff --git a/src/stages/common/PP.ml b/src/stages/common/PP.ml index b35efeb8f..0789d5a44 100644 --- a/src/stages/common/PP.ml +++ b/src/stages/common/PP.ml @@ -254,8 +254,8 @@ module Ast_PP_type (PARAMETER : AST_PARAMETER_TYPE) = struct | TC_big_map (k, v) -> Format.asprintf "Big Map (%a,%a)" f k f v | TC_map_or_big_map (k, v) -> Format.asprintf "Map Or Big Map (%a,%a)" f k f v | TC_contract te -> Format.asprintf "Contract (%a)" f te - | TC_michelson_right_comb c -> Format.asprintf "Michelson_right_comb (%a)" f c - | TC_michelson_left_comb c -> Format.asprintf "Michelson_left_comb (%a)" f c + | TC_michelson_pair_right_comb c -> Format.asprintf "michelson_pair_right_comb (%a)" f c + | TC_michelson_pair_left_comb c -> Format.asprintf "michelson_pair_left_comb (%a)" f c in fprintf ppf "(type_operator: %s)" s end diff --git a/src/stages/common/types.ml b/src/stages/common/types.ml index c77652945..505e60d2d 100644 --- a/src/stages/common/types.ml +++ b/src/stages/common/types.ml @@ -59,8 +59,8 @@ module Ast_generic_type (PARAMETER : AST_PARAMETER_TYPE) = struct | TC_map of type_expression * type_expression | TC_big_map of type_expression * type_expression | TC_map_or_big_map of type_expression * type_expression - | TC_michelson_right_comb of type_expression - | TC_michelson_left_comb of type_expression + | TC_michelson_pair_right_comb of type_expression + | TC_michelson_pair_left_comb of type_expression and type_expression = {type_content: type_content; location: Location.t; type_meta: type_meta} @@ -74,8 +74,8 @@ module Ast_generic_type (PARAMETER : AST_PARAMETER_TYPE) = struct | TC_map (x , y) -> TC_map (f x , f y) | TC_big_map (x , y)-> TC_big_map (f x , f y) | TC_map_or_big_map (x , y)-> TC_map_or_big_map (f x , f y) - | TC_michelson_right_comb c -> TC_michelson_right_comb (f c) - | TC_michelson_left_comb c -> TC_michelson_left_comb (f c) + | TC_michelson_pair_right_comb c -> TC_michelson_pair_right_comb (f c) + | TC_michelson_pair_left_comb c -> TC_michelson_pair_left_comb (f c) let bind_map_type_operator f = function TC_contract x -> let%bind x = f x in ok @@ TC_contract x @@ -85,8 +85,8 @@ module Ast_generic_type (PARAMETER : AST_PARAMETER_TYPE) = struct | TC_map (x , y) -> let%bind x = f x in let%bind y = f y in ok @@ TC_map (x , y) | TC_big_map (x , y)-> let%bind x = f x in let%bind y = f y in ok @@ TC_big_map (x , y) | TC_map_or_big_map (x , y)-> let%bind x = f x in let%bind y = f y in ok @@ TC_map_or_big_map (x , y) - | TC_michelson_right_comb c -> let%bind c = f c in ok @@ TC_michelson_right_comb c - | TC_michelson_left_comb c -> let%bind c = f c in ok @@ TC_michelson_left_comb c + | TC_michelson_pair_right_comb c -> let%bind c = f c in ok @@ TC_michelson_pair_right_comb c + | TC_michelson_pair_left_comb c -> let%bind c = f c in ok @@ TC_michelson_pair_left_comb c let type_operator_name = function TC_contract _ -> "TC_contract" @@ -96,8 +96,8 @@ module Ast_generic_type (PARAMETER : AST_PARAMETER_TYPE) = struct | TC_map _ -> "TC_map" | TC_big_map _ -> "TC_big_map" | TC_map_or_big_map _ -> "TC_map_or_big_map" - | TC_michelson_right_comb _ -> "TC_michelson_right_comb" - | TC_michelson_left_comb _ -> "TC_michelson_left_comb" + | TC_michelson_pair_right_comb _ -> "TC_michelson_pair_right_comb" + | TC_michelson_pair_left_comb _ -> "TC_michelson_pair_left_comb" let type_expression'_of_string = function | "TC_contract" , [x] -> ok @@ T_operator(TC_contract x) @@ -135,8 +135,8 @@ module Ast_generic_type (PARAMETER : AST_PARAMETER_TYPE) = struct | TC_map (x , y) -> "TC_map" , [x ; y] | TC_big_map (x , y) -> "TC_big_map" , [x ; y] | TC_map_or_big_map (x , y) -> "TC_map_or_big_map" , [x ; y] - | TC_michelson_right_comb c -> "TC_michelson_right_comb" , [c] - | TC_michelson_left_comb c -> "TC_michelson_left_comb" , [c] + | TC_michelson_pair_right_comb c -> "TC_michelson_pair_right_comb" , [c] + | TC_michelson_pair_left_comb c -> "TC_michelson_pair_left_comb" , [c] let string_of_type_constant = function | TC_unit -> "TC_unit", [] diff --git a/src/test/contracts/michelson_comb_type_operators.mligo b/src/test/contracts/michelson_comb_type_operators.mligo index 63af653e1..36dd2c2af 100644 --- a/src/test/contracts/michelson_comb_type_operators.mligo +++ b/src/test/contracts/michelson_comb_type_operators.mligo @@ -1,7 +1,7 @@ type t3 = { foo : int ; bar : nat ; baz : string} -type param_r = t3 michelson_right_comb -type param_l = t3 michelson_left_comb +type param_r = t3 michelson_pair_right_comb +type param_l = t3 michelson_pair_left_comb let main_r (action, store : param_r * unit) : (operation list * unit) = ([] : operation list), unit diff --git a/src/test/contracts/michelson_converter.mligo b/src/test/contracts/michelson_converter.mligo index 064de13f9..a7d573d55 100644 --- a/src/test/contracts/michelson_converter.mligo +++ b/src/test/contracts/michelson_converter.mligo @@ -17,8 +17,8 @@ let l4 = Layout.convert_to_left_comb (v4:t4) let s = "eq" let test_input_pair_r = (1,(2n,(s,true))) let test_input_pair_l = (((1,2n), s), true) -type param_r = t4 michelson_right_comb -type param_l = t4 michelson_left_comb +type param_r = t4 michelson_pair_right_comb +type param_l = t4 michelson_pair_left_comb let main_r (p, s : param_r * string) : (operation list * string) = let r4 : t4 = Layout.convert_from_right_comb p in