From 3d0ec5deb4e147bfc8b10a324eb83e7128194063 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Fri, 26 Jan 2018 16:46:25 +0100 Subject: [PATCH] Michelson: remove instruction MAP on sets --- docs/whitedoc/michelson.rst | 18 ------------------ .../lib_protocol/src/script_interpreter.ml | 12 ------------ .../lib_protocol/src/script_ir_translator.ml | 7 ------- .../lib_protocol/src/script_typed_ir.ml | 2 -- 4 files changed, 39 deletions(-) diff --git a/docs/whitedoc/michelson.rst b/docs/whitedoc/michelson.rst index 40f1bebd3..91b9df21a 100644 --- a/docs/whitedoc/michelson.rst +++ b/docs/whitedoc/michelson.rst @@ -838,24 +838,6 @@ Operations on sets :: 'elt : bool : set 'elt : 'S -> set 'elt : 'S -- ``MAP``: Apply a function on a map and return the map of results - under the same bindings. - - The ``'b`` type must be comparable (the ``COMPARE`` primitive must be - defined over it). - -:: - - :: lambda 'elt 'b : set 'elt : 'S -> set 'b : 'S - -- ``MAP body``: Apply the body expression to each element of the set. - The body sequence has access to the stack. - -:: - - :: (set 'elt) : 'A -> (set 'b) : 'A - iff body :: [ 'elt : 'A -> 'b : 'A ] - - ``REDUCE``: Apply a function on a set passing the result of each application to the next one and return the last. diff --git a/src/proto_alpha/lib_protocol/src/script_interpreter.ml b/src/proto_alpha/lib_protocol/src/script_interpreter.ml index 20fa7ee75..17f48cc1b 100644 --- a/src/proto_alpha/lib_protocol/src/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/src/script_interpreter.ml @@ -318,18 +318,6 @@ let rec interp (* sets *) | Empty_set t, rest -> logged_return (Item (empty_set t, rest), Gas.consume gas Gas.Cost_of.empty_set, ctxt) - | Set_map t, Item (lam, Item (set, rest)) -> - let gas = Gas.consume gas (Gas.Cost_of.set_to_list set) in - Gas.check gas >>=? fun () -> - let items = - List.rev (set_fold (fun e acc -> e :: acc) set []) in - fold_left_s - (fun (res, gas, ctxt, origination) arg -> - interp ?log origination gas orig source amount ctxt lam arg >>=? - fun (ret, gas, ctxt, origination) -> - return (set_update ret true res, gas, ctxt, origination)) - (empty_set t, gas, ctxt, origination) items >>=? fun (res, gas, ctxt, origination) -> - logged_return ~origination (Item (res, rest), gas, ctxt) | Set_reduce, Item (lam, Item (set, Item (init, rest))) -> let gas = Gas.consume gas (Gas.Cost_of.set_to_list set) in Gas.check gas >>=? fun () -> diff --git a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml index d3fe50429..6bcdc2b04 100644 --- a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml @@ -117,7 +117,6 @@ let number_of_generated_growing_types : type b a. (b, a) instr -> int = function | List_size -> 0 | List_iter _ -> 1 | Empty_set _ -> 1 - | Set_map _ -> 1 | Set_reduce -> 0 | Set_iter _ -> 0 | Set_mem -> 0 @@ -1337,12 +1336,6 @@ and parse_instr rest -> (Lwt.return (parse_comparable_ty t)) >>=? fun (Ex_comparable_ty t) -> return (typed loc (Empty_set t, Item_t (Set_t t, rest, instr_annot))) - | Prim (loc, I_MAP, [], instr_annot), - Item_t (Lambda_t (param, ret), Item_t (Set_t elt, rest, _), _) -> - let elt = ty_of_comparable_ty elt in - (Lwt.return (comparable_ty_of_ty loc ret)) >>=? fun ret -> - check_item_ty elt param loc I_MAP 1 2 >>=? fun Eq -> - return (typed loc (Set_map ret, Item_t (Set_t ret, rest, instr_annot))) | Prim (loc, I_REDUCE, [], instr_annot), Item_t (Lambda_t (Pair_t ((pelt, _), (pr, _)), r), Item_t (Set_t elt, Item_t (init, rest, _), _), _) -> diff --git a/src/proto_alpha/lib_protocol/src/script_typed_ir.ml b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml index 49348b40b..10e16c2b9 100644 --- a/src/proto_alpha/lib_protocol/src/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml @@ -147,8 +147,6 @@ and ('bef, 'aft) instr = (* sets *) | Empty_set : 'a comparable_ty -> ('rest, 'a set * 'rest) instr - | Set_map : 'ret comparable_ty -> - (('param, 'ret) lambda * ('param set * 'rest), 'ret set * 'rest) instr | Set_reduce : (('param * 'res, 'res) lambda * ('param set * ('res * 'rest)), 'res * 'rest) instr