add big_map injection

This commit is contained in:
Lesenechal Remi 2019-10-21 13:04:28 +02:00
parent 5d040220c0
commit cefac0d8e7
5 changed files with 19 additions and 2 deletions

View File

@ -490,6 +490,7 @@ and closing =
and map_expr = and map_expr =
MapLookUp of map_lookup reg MapLookUp of map_lookup reg
| MapInj of binding reg injection reg | MapInj of binding reg injection reg
| BigMapInj of binding reg injection reg
and map_lookup = { and map_lookup = {
path : path; path : path;
@ -647,6 +648,7 @@ and tuple_expr_to_region {region; _} = region
and map_expr_to_region = function and map_expr_to_region = function
MapLookUp {region; _} MapLookUp {region; _}
| MapInj {region; _} -> region | MapInj {region; _} -> region
| BigMapInj {region; _} -> region
and set_expr_to_region = function and set_expr_to_region = function
SetInj {region; _} SetInj {region; _}

View File

@ -481,6 +481,7 @@ and closing =
and map_expr = and map_expr =
MapLookUp of map_lookup reg MapLookUp of map_lookup reg
| MapInj of binding reg injection reg | MapInj of binding reg injection reg
| BigMapInj of binding reg injection reg
and map_lookup = { and map_lookup = {
path : path; path : path;

View File

@ -877,6 +877,7 @@ set_expr:
map_expr: map_expr:
map_lookup { MapLookUp $1 } map_lookup { MapLookUp $1 }
| injection(Map,binding) { MapInj $1 } | injection(Map,binding) { MapInj $1 }
| injection(BigMap,binding) { BigMapInj $1 }
map_lookup: map_lookup:
path brackets(expr) { path brackets(expr) {

View File

@ -434,6 +434,7 @@ and print_case_clause_expr buffer {value; _} =
and print_map_expr buffer = function and print_map_expr buffer = function
MapLookUp {value; _} -> print_map_lookup buffer value MapLookUp {value; _} -> print_map_lookup buffer value
| MapInj inj -> print_injection buffer "map" print_binding inj | MapInj inj -> print_injection buffer "map" print_binding inj
| BigMapInj inj -> print_injection buffer "big_map" print_binding inj
and print_set_expr buffer = function and print_set_expr buffer = function
SetInj inj -> print_injection buffer "set" print_expr inj SetInj inj -> print_injection buffer "set" print_expr inj
@ -1445,7 +1446,7 @@ and pp_map_expr buffer ~pad = function
MapLookUp {value; _} -> MapLookUp {value; _} ->
pp_node buffer ~pad "MapLookUp"; pp_node buffer ~pad "MapLookUp";
pp_map_lookup buffer ~pad value pp_map_lookup buffer ~pad value
| MapInj {value; _} -> | MapInj {value; _} | BigMapInj {value; _} ->
pp_node buffer ~pad "MapInj"; pp_node buffer ~pad "MapInj";
pp_injection pp_binding buffer ~pad value pp_injection pp_binding buffer ~pad value

View File

@ -411,6 +411,18 @@ let rec simpl_expression (t:Raw.expr) : expr result =
bind_map_list aux lst in bind_map_list aux lst in
return @@ e_map ~loc lst return @@ e_map ~loc lst
) )
| EMap (BigMapInj mi) -> (
let (mi , loc) = r_split mi in
let%bind lst =
let lst = List.map get_value @@ pseq_to_list mi.elements in
let aux : Raw.binding -> (expression * expression) result =
fun b ->
let%bind src = simpl_expression b.source in
let%bind dst = simpl_expression b.image in
ok (src, dst) in
bind_map_list aux lst in
return @@ e_big_map ~loc lst
)
| EMap (MapLookUp lu) -> ( | EMap (MapLookUp lu) -> (
let (lu , loc) = r_split lu in let (lu , loc) = r_split lu in
let%bind path = match lu.path with let%bind path = match lu.path with