big map can be looked up
This commit is contained in:
parent
4fec6f1624
commit
25e3ab8e5d
@ -70,6 +70,7 @@ module Ty = struct
|
|||||||
| T_or _ -> fail (not_comparable "or")
|
| T_or _ -> fail (not_comparable "or")
|
||||||
| T_pair _ -> fail (not_comparable "pair")
|
| T_pair _ -> fail (not_comparable "pair")
|
||||||
| T_map _ -> fail (not_comparable "map")
|
| T_map _ -> fail (not_comparable "map")
|
||||||
|
| T_big_map _ -> fail (not_comparable "big_map")
|
||||||
| T_list _ -> fail (not_comparable "list")
|
| T_list _ -> fail (not_comparable "list")
|
||||||
| T_set _ -> fail (not_comparable "set")
|
| T_set _ -> fail (not_comparable "set")
|
||||||
| T_option _ -> fail (not_comparable "option")
|
| T_option _ -> fail (not_comparable "option")
|
||||||
@ -116,6 +117,10 @@ module Ty = struct
|
|||||||
let%bind (Ex_comparable_ty k') = comparable_type k in
|
let%bind (Ex_comparable_ty k') = comparable_type k in
|
||||||
let%bind (Ex_ty v') = type_ v in
|
let%bind (Ex_ty v') = type_ v in
|
||||||
ok @@ Ex_ty (map k' v')
|
ok @@ Ex_ty (map k' v')
|
||||||
|
| T_big_map (k, v) ->
|
||||||
|
let%bind (Ex_comparable_ty k') = comparable_type k in
|
||||||
|
let%bind (Ex_ty v') = type_ v in
|
||||||
|
ok @@ Ex_ty (big_map k' v')
|
||||||
| T_list t ->
|
| T_list t ->
|
||||||
let%bind (Ex_ty t') = type_ t in
|
let%bind (Ex_ty t') = type_ t in
|
||||||
ok @@ Ex_ty (list t')
|
ok @@ Ex_ty (list t')
|
||||||
@ -184,6 +189,9 @@ let rec type_ : type_value -> O.michelson result =
|
|||||||
| T_map kv ->
|
| T_map kv ->
|
||||||
let%bind (k', v') = bind_map_pair type_ kv in
|
let%bind (k', v') = bind_map_pair type_ kv in
|
||||||
ok @@ O.prim ~children:[k';v'] O.T_map
|
ok @@ O.prim ~children:[k';v'] O.T_map
|
||||||
|
| T_big_map kv ->
|
||||||
|
let%bind (k', v') = bind_map_pair type_ kv in
|
||||||
|
ok @@ O.prim ~children:[k';v'] O.T_big_map
|
||||||
| T_list t ->
|
| T_list t ->
|
||||||
let%bind t' = type_ t in
|
let%bind t' = type_ t in
|
||||||
ok @@ O.prim ~children:[t'] O.T_list
|
ok @@ O.prim ~children:[t'] O.T_list
|
||||||
|
@ -1,5 +1,18 @@
|
|||||||
type storage_ is big_map(int, int) * unit
|
// type storage_ is big_map(int, int) * unit
|
||||||
|
type storage_ is big_map(int, int)
|
||||||
|
|
||||||
|
// function main(const p : unit; const s : storage_) : list(operation) * storage_ is
|
||||||
|
// block { skip }
|
||||||
|
// with ((nil : list(operation)), s)
|
||||||
|
|
||||||
function main(const p : unit; const s : storage_) : list(operation) * storage_ is
|
function main(const p : unit; const s : storage_) : list(operation) * storage_ is
|
||||||
block { skip }
|
// var r : big_map(int, int) := s.0 ;
|
||||||
|
var r : big_map(int,int) := s ;
|
||||||
|
var toto : option (int) := Some(0);
|
||||||
|
block {
|
||||||
|
// r[23] := 2;
|
||||||
|
toto := r[23];
|
||||||
|
s := r;
|
||||||
|
// skip
|
||||||
|
}
|
||||||
with ((nil: list(operation)), s)
|
with ((nil: list(operation)), s)
|
@ -27,6 +27,7 @@ let rec type_ ppf : type_value -> _ = function
|
|||||||
| T_base b -> type_base ppf b
|
| T_base b -> type_base ppf b
|
||||||
| T_function(a, b) -> fprintf ppf "(%a) -> (%a)" type_ a type_ b
|
| T_function(a, b) -> fprintf ppf "(%a) -> (%a)" type_ a type_ b
|
||||||
| T_map(k, v) -> fprintf ppf "map(%a -> %a)" type_ k type_ v
|
| T_map(k, v) -> fprintf ppf "map(%a -> %a)" type_ k type_ v
|
||||||
|
| T_big_map(k, v) -> fprintf ppf "big_map(%a -> %a)" type_ k type_ v
|
||||||
| T_list(t) -> fprintf ppf "list(%a)" type_ t
|
| T_list(t) -> fprintf ppf "list(%a)" type_ t
|
||||||
| T_set(t) -> fprintf ppf "set(%a)" type_ t
|
| T_set(t) -> fprintf ppf "set(%a)" type_ t
|
||||||
| T_option(o) -> fprintf ppf "option(%a)" type_ o
|
| T_option(o) -> fprintf ppf "option(%a)" type_ o
|
||||||
|
@ -15,6 +15,7 @@ type type_value =
|
|||||||
| T_deep_closure of environment * type_value * type_value
|
| T_deep_closure of environment * type_value * type_value
|
||||||
| T_base of type_base
|
| T_base of type_base
|
||||||
| T_map of (type_value * type_value)
|
| T_map of (type_value * type_value)
|
||||||
|
| T_big_map of (type_value * type_value)
|
||||||
| T_list of type_value
|
| T_list of type_value
|
||||||
| T_set of type_value
|
| T_set of type_value
|
||||||
| T_contract of type_value
|
| T_contract of type_value
|
||||||
|
@ -115,7 +115,7 @@ let rec translate_type (t:AST.type_value) : type_value result =
|
|||||||
ok (T_map kv')
|
ok (T_map kv')
|
||||||
| T_constant ("big_map", [key;value] ) ->
|
| T_constant ("big_map", [key;value] ) ->
|
||||||
let%bind kv' = bind_map_pair translate_type (key, value) in
|
let%bind kv' = bind_map_pair translate_type (key, value) in
|
||||||
ok (T_map kv')
|
ok (T_big_map kv')
|
||||||
| T_constant ("list", [t]) ->
|
| T_constant ("list", [t]) ->
|
||||||
let%bind t' = translate_type t in
|
let%bind t' = translate_type t in
|
||||||
ok (T_list t')
|
ok (T_list t')
|
||||||
|
@ -614,7 +614,7 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a
|
|||||||
return (E_application (f' , arg)) tv
|
return (E_application (f' , arg)) tv
|
||||||
| E_look_up dsi ->
|
| E_look_up dsi ->
|
||||||
let%bind (ds, ind) = bind_map_pair (type_expression e) dsi in
|
let%bind (ds, ind) = bind_map_pair (type_expression e) dsi in
|
||||||
let%bind (src, dst) = get_t_map ds.type_annotation in
|
let%bind (src, dst) = bind_map_or (get_t_map , get_t_big_map) ds.type_annotation in
|
||||||
let%bind _ = O.assert_type_value_eq (ind.type_annotation, src) in
|
let%bind _ = O.assert_type_value_eq (ind.type_annotation, src) in
|
||||||
return (E_look_up (ds , ind)) (t_option dst ())
|
return (E_look_up (ds , ind)) (t_option dst ())
|
||||||
(* Advanced *)
|
(* Advanced *)
|
||||||
|
2
vendors/ligo-utils/simple-utils/trace.ml
vendored
2
vendors/ligo-utils/simple-utils/trace.ml
vendored
@ -639,6 +639,8 @@ let bind_or (a, b) =
|
|||||||
match a with
|
match a with
|
||||||
| Ok _ as o -> o
|
| Ok _ as o -> o
|
||||||
| _ -> b
|
| _ -> b
|
||||||
|
let bind_map_or (fa , fb) c =
|
||||||
|
bind_or (fa c , fb c)
|
||||||
|
|
||||||
let bind_lr (type a b) ((a : a result), (b:b result)) : [`Left of a | `Right of b] result =
|
let bind_lr (type a b) ((a : a result), (b:b result)) : [`Left of a | `Right of b] result =
|
||||||
match (a, b) with
|
match (a, b) with
|
||||||
|
Loading…
Reference in New Issue
Block a user