diff --git a/src/passes/3-self_ast_simplified/literals.ml b/src/passes/3-self_ast_simplified/literals.ml index 5d7be25b6..154851601 100644 --- a/src/passes/3-self_ast_simplified/literals.ml +++ b/src/passes/3-self_ast_simplified/literals.ml @@ -4,6 +4,27 @@ open Trace let peephole_expression : expression -> expression result = fun e -> let return expression = ok { e with expression } in match e.expression with + | E_constant ("BIG_MAP_LITERAL" , lst) -> ( + let%bind elt = + trace_option (simple_error "big_map literal expects a single parameter") @@ + List.to_singleton lst + in + let%bind lst = + trace (simple_error "big_map literal expects a list as parameter") @@ + get_e_list elt.expression + in + let aux = fun (e : expression) -> + trace (simple_error "big_map literal expects a list of pairs as parameter") @@ + let%bind tpl = get_e_tuple e.expression in + let%bind (a , b) = + trace_option (simple_error "of pairs") @@ + List.to_pair tpl + in + ok (a , b) + in + let%bind pairs = bind_map_list aux lst in + return @@ E_big_map pairs + ) | E_constant ("MAP_LITERAL" , lst) -> ( let%bind elt = trace_option (simple_error "map literal expects a single parameter") @@ @@ -25,6 +46,13 @@ let peephole_expression : expression -> expression result = fun e -> let%bind pairs = bind_map_list aux lst in return @@ E_map pairs ) + | E_constant ("BIG_MAP_EMPTY" , lst) -> ( + let%bind () = + trace_strong (simple_error "BIG_MAP_EMPTY expects no parameter") @@ + Assert.assert_list_empty lst + in + return @@ E_big_map [] + ) | E_constant ("MAP_EMPTY" , lst) -> ( let%bind () = trace_strong (simple_error "MAP_EMPTY expects no parameter") @@ diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml index 65b55c18e..13510fedc 100644 --- a/src/passes/operators/operators.ml +++ b/src/passes/operators/operators.ml @@ -85,6 +85,7 @@ module Simplify = struct ("list_iter" , "LIST_ITER") ; ("list_fold" , "LIST_FOLD") ; ("list_map" , "LIST_MAP") ; + (*ici*) ("map_iter" , "MAP_ITER") ; ("map_map" , "MAP_MAP") ; ("map_fold" , "MAP_FOLD") ; @@ -167,6 +168,14 @@ module Simplify = struct ("Map.literal" , "MAP_LITERAL" ) ; ("Map.size" , "SIZE" ) ; + ("Big_map.find_opt" , "MAP_FIND_OPT") ; + ("Big_map.find" , "MAP_FIND") ; + ("Big_map.update" , "MAP_UPDATE") ; + ("Big_map.add" , "MAP_ADD") ; + ("Big_map.remove" , "MAP_REMOVE") ; + ("Big_map.literal" , "BIG_MAP_LITERAL" ) ; + ("Big_map.empty" , "BIG_MAP_EMPTY" ) ; + ("String.length", "SIZE") ; ("String.size", "SIZE") ; ("String.slice", "SLICE") ;