Michelson: remove instruction MAP on sets
This commit is contained in:
parent
024738e0b6
commit
3d0ec5deb4
@ -838,24 +838,6 @@ Operations on sets
|
|||||||
|
|
||||||
:: 'elt : bool : set 'elt : 'S -> set 'elt : 'S
|
:: '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
|
- ``REDUCE``: Apply a function on a set passing the result of each
|
||||||
application to the next one and return the last.
|
application to the next one and return the last.
|
||||||
|
|
||||||
|
@ -318,18 +318,6 @@ let rec interp
|
|||||||
(* sets *)
|
(* sets *)
|
||||||
| Empty_set t, rest ->
|
| Empty_set t, rest ->
|
||||||
logged_return (Item (empty_set t, rest), Gas.consume gas Gas.Cost_of.empty_set, ctxt)
|
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))) ->
|
| Set_reduce, Item (lam, Item (set, Item (init, rest))) ->
|
||||||
let gas = Gas.consume gas (Gas.Cost_of.set_to_list set) in
|
let gas = Gas.consume gas (Gas.Cost_of.set_to_list set) in
|
||||||
Gas.check gas >>=? fun () ->
|
Gas.check gas >>=? fun () ->
|
||||||
|
@ -117,7 +117,6 @@ let number_of_generated_growing_types : type b a. (b, a) instr -> int = function
|
|||||||
| List_size -> 0
|
| List_size -> 0
|
||||||
| List_iter _ -> 1
|
| List_iter _ -> 1
|
||||||
| Empty_set _ -> 1
|
| Empty_set _ -> 1
|
||||||
| Set_map _ -> 1
|
|
||||||
| Set_reduce -> 0
|
| Set_reduce -> 0
|
||||||
| Set_iter _ -> 0
|
| Set_iter _ -> 0
|
||||||
| Set_mem -> 0
|
| Set_mem -> 0
|
||||||
@ -1337,12 +1336,6 @@ and parse_instr
|
|||||||
rest ->
|
rest ->
|
||||||
(Lwt.return (parse_comparable_ty t)) >>=? fun (Ex_comparable_ty t) ->
|
(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)))
|
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),
|
| Prim (loc, I_REDUCE, [], instr_annot),
|
||||||
Item_t (Lambda_t (Pair_t ((pelt, _), (pr, _)), r),
|
Item_t (Lambda_t (Pair_t ((pelt, _), (pr, _)), r),
|
||||||
Item_t (Set_t elt, Item_t (init, rest, _), _), _) ->
|
Item_t (Set_t elt, Item_t (init, rest, _), _), _) ->
|
||||||
|
@ -147,8 +147,6 @@ and ('bef, 'aft) instr =
|
|||||||
(* sets *)
|
(* sets *)
|
||||||
| Empty_set : 'a comparable_ty ->
|
| Empty_set : 'a comparable_ty ->
|
||||||
('rest, 'a set * 'rest) instr
|
('rest, 'a set * 'rest) instr
|
||||||
| Set_map : 'ret comparable_ty ->
|
|
||||||
(('param, 'ret) lambda * ('param set * 'rest), 'ret set * 'rest) instr
|
|
||||||
| Set_reduce :
|
| Set_reduce :
|
||||||
(('param * 'res, 'res) lambda *
|
(('param * 'res, 'res) lambda *
|
||||||
('param set * ('res * 'rest)), 'res * 'rest) instr
|
('param set * ('res * 'rest)), 'res * 'rest) instr
|
||||||
|
Loading…
Reference in New Issue
Block a user