adding Big_map.* operators for cameligo
This commit is contained in:
parent
cefac0d8e7
commit
2a2c708b54
@ -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") @@
|
||||
|
@ -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") ;
|
||||
|
Loading…
Reference in New Issue
Block a user