From 8765e7258aacab8ba7d1102500c13840c967f629 Mon Sep 17 00:00:00 2001 From: Galfour Date: Mon, 13 May 2019 12:20:23 +0000 Subject: [PATCH] fix stuff --- compiler/compiler_environment.ml | 9 +++++---- compiler/compiler_program.ml | 11 ++++++----- compiler/compiler_type.ml | 4 ++-- compiler/uncompiler.ml | 6 +++--- ligo.opam | 1 + main/contract.ml | 6 +++--- main/main.ml | 2 +- main/run_mini_c.ml | 9 +++++---- meta_michelson/alpha_wrap.ml | 4 ++-- meta_michelson/contract.ml | 4 ++-- meta_michelson/dune | 1 + meta_michelson/michelson_wrap.ml | 2 +- meta_michelson/misc.ml | 4 ++-- operators/operators.ml | 2 +- 14 files changed, 35 insertions(+), 30 deletions(-) diff --git a/compiler/compiler_environment.ml b/compiler/compiler_environment.ml index c6980ee06..2ea43b621 100644 --- a/compiler/compiler_environment.ml +++ b/compiler/compiler_environment.ml @@ -1,7 +1,8 @@ +open Proto_alpha_utils open Trace open Mini_c open Environment -open Micheline.Michelson +open Michelson open Memory_proto_alpha.Script_ir_translator module Stack = Meta_michelson.Stack @@ -121,7 +122,7 @@ let select : environment -> string list -> michelson result = fun e lst -> PP.environment e PP.environment e' PP_helpers.(list_sep (pair PP.environment_element bool) (const " || ")) e_lst - Micheline.Michelson.pp code + Michelson.pp code (L.get ()) in ok @@ (error title content) in @@ -190,7 +191,7 @@ let unpack : environment -> michelson result = fun e -> let content () = Format.asprintf "\nEnvironment:%a\nType Representation:%a\nCode:%a\n" PP.environment e PP.type_ repr - Micheline.Michelson.pp code + Michelson.pp code in ok @@ (error title content) in let%bind _ = @@ -243,7 +244,7 @@ let pack_select : environment -> string list -> michelson result = fun e lst -> PP.environment e PP.environment e' PP_helpers.(list_sep (pair PP.environment_element bool) (const " || ")) e_lst - Micheline.Michelson.pp code + Michelson.pp code (L.get ()) in ok @@ (error title content) in diff --git a/compiler/compiler_program.ml b/compiler/compiler_program.ml index 48a67ae65..174f5d684 100644 --- a/compiler/compiler_program.ml +++ b/compiler/compiler_program.ml @@ -1,7 +1,6 @@ open Trace open Mini_c -module Michelson = Micheline.Michelson open Michelson module Stack = Meta_michelson.Stack module Contract_types = Meta_michelson.Types @@ -10,6 +9,8 @@ open Memory_proto_alpha.Script_ir_translator open Operators.Compiler +open Proto_alpha_utils + let get_predicate : string -> type_value -> expression list -> predicate result = fun s ty lst -> match Map.String.find_opt s Operators.Compiler.predicates with | Some x -> ok x @@ -108,7 +109,7 @@ and translate_expression ?(first=false) (expr:expression) (env:environment) : (m ok @@ (fun () -> error (thunk "error parsing expression code") (fun () -> error_message) ())) @@ - Tezos_utils.Memory_proto_alpha.parse_michelson code + Memory_proto_alpha.parse_michelson code input_stack_ty output_stack_ty in ok (code , env') @@ -302,7 +303,7 @@ and translate_statement ((s', w_env) as s:statement) : michelson result = ok (fun () -> error (thunk "error parsing statement code") (fun () -> error_message) ())) @@ - Tezos_utils.Memory_proto_alpha.parse_michelson_fail code + Proto_alpha_utils.Memory_proto_alpha.parse_michelson_fail code input_stack_ty output_stack_ty in ok code @@ -477,7 +478,7 @@ and translate_quote_body ({body;result} as f:anon_function) : michelson result = let error_message () = Format.asprintf "\ncode : %a\ninput : %a\noutput : %a\nenv : %a\n" - Tezos_utils.Micheline.Michelson.pp code + Michelson.pp code PP.type_ f.input PP.type_ f.output PP.environment (snd body).post_environment @@ -486,7 +487,7 @@ and translate_quote_body ({body;result} as f:anon_function) : michelson result = Trace.trace_tzresult_lwt ( error (thunk "error parsing quote code") error_message ) @@ - Tezos_utils.Memory_proto_alpha.parse_michelson code + Proto_alpha_utils.Memory_proto_alpha.parse_michelson code input_stack_ty output_stack_ty in ok () diff --git a/compiler/compiler_type.ml b/compiler/compiler_type.ml index bfa6cd12f..20daf075c 100644 --- a/compiler/compiler_type.ml +++ b/compiler/compiler_type.ml @@ -1,10 +1,10 @@ open Trace open Mini_c.Types -open Tezos_utils.Memory_proto_alpha +open Proto_alpha_utils.Memory_proto_alpha open Script_ir_translator -module O = Tezos_utils.Micheline.Michelson +module O = Tezos_utils.Michelson module Contract_types = Meta_michelson.Types module Ty = struct diff --git a/compiler/uncompiler.ml b/compiler/uncompiler.ml index 4f4b24cfb..ebf9f4028 100644 --- a/compiler/uncompiler.ml +++ b/compiler/uncompiler.ml @@ -1,6 +1,6 @@ -open Trace open Mini_c.Types open Memory_proto_alpha +open Proto_alpha_utils.Trace open Script_typed_ir open Script_ir_translator @@ -78,10 +78,10 @@ let rec translate_value (Ex_typed_value (ty, value)) : value result = let%bind error = let%bind m_data = trace_tzresult_lwt (simple_error "unparsing unrecognized data") @@ - Tezos_utils.Memory_proto_alpha.unparse_michelson_data ty v in + Proto_alpha_utils.Memory_proto_alpha.unparse_michelson_data ty v in let%bind m_ty = trace_tzresult_lwt (simple_error "unparsing unrecognized data") @@ - Tezos_utils.Memory_proto_alpha.unparse_michelson_ty ty in + Proto_alpha_utils.Memory_proto_alpha.unparse_michelson_ty ty in let error_content () = Format.asprintf "%a : %a" Michelson.pp m_data diff --git a/ligo.opam b/ligo.opam index 9294b375f..38a2a9087 100644 --- a/ligo.opam +++ b/ligo.opam @@ -15,6 +15,7 @@ depends: [ "ppx_let" "ppx_deriving" "tezos-utils" + "proto-alpha-utils" "yojson" "alcotest" { with-test } ] diff --git a/main/contract.ml b/main/contract.ml index ff3f8a98b..e41d689f5 100644 --- a/main/contract.ml +++ b/main/contract.ml @@ -79,7 +79,7 @@ let compile_contract_file : string -> string -> string result = fun source entry trace (simple_error "compiling") @@ Compiler.translate_contract mini_c in let str = - Format.asprintf "%a" Micheline.Michelson.pp_stripped michelson in + Format.asprintf "%a" Michelson.pp_stripped michelson in ok str let compile_contract_parameter : string -> string -> string -> string result = fun source entry_point expression -> @@ -124,7 +124,7 @@ let compile_contract_parameter : string -> string -> string -> string result = f trace (simple_error "compiling expression") @@ Compiler.translate_value mini_c in let str = - Format.asprintf "%a" Micheline.Michelson.pp_stripped michelson in + Format.asprintf "%a" Michelson.pp_stripped michelson in ok str in ok expr @@ -172,7 +172,7 @@ let compile_contract_storage : string -> string -> string -> string result = fun trace (simple_error "compiling expression") @@ Compiler.translate_value mini_c in let str = - Format.asprintf "%a" Micheline.Michelson.pp_stripped michelson in + Format.asprintf "%a" Michelson.pp_stripped michelson in ok str in ok expr diff --git a/main/main.ml b/main/main.ml index 34bd70fe1..f0f9ca758 100644 --- a/main/main.ml +++ b/main/main.ml @@ -176,7 +176,7 @@ let easy_run_main (path:string) (input:string) : AST_Typed.annotated_expression let%bind typed_expr = type_expression simpl_expr in easy_run_main_typed typed typed_expr -let compile_file (source: string) (entry_point:string) : Micheline.Michelson.t result = +let compile_file (source: string) (entry_point:string) : Michelson.t result = let%bind raw = trace (simple_error "parsing") @@ Parser.parse_file source in diff --git a/main/run_mini_c.ml b/main/run_mini_c.ml index 5fb8d908f..adad4c05c 100644 --- a/main/run_mini_c.ml +++ b/main/run_mini_c.ml @@ -1,3 +1,4 @@ +open Proto_alpha_utils open Trace open Mini_c open! Compiler.Program @@ -9,16 +10,16 @@ let run_aux ?options (program:compiled_program) (input_michelson:Michelson.t) : let (Ex_ty output_ty) = output in let%bind input = Trace.trace_tzresult_lwt (simple_error "error parsing input") @@ - Tezos_utils.Memory_proto_alpha.parse_michelson_data input_michelson input_ty in + Memory_proto_alpha.parse_michelson_data input_michelson input_ty in let body = Michelson.strip_annots body in let%bind descr = Trace.trace_tzresult_lwt (simple_error "error parsing program code") @@ - Tezos_utils.Memory_proto_alpha.parse_michelson body + Memory_proto_alpha.parse_michelson body (Stack.(input_ty @: nil)) (Stack.(output_ty @: nil)) in let open! Memory_proto_alpha.Script_interpreter in let%bind (Item(output, Empty)) = Trace.trace_tzresult_lwt (simple_error "error of execution") @@ - Tezos_utils.Memory_proto_alpha.interpret ?options descr (Item(input, Empty)) in + Memory_proto_alpha.interpret ?options descr (Item(input, Empty)) in ok (Ex_typed_value (output_ty, output)) let run_node (program:program) (input:Michelson.t) : Michelson.t result = @@ -26,7 +27,7 @@ let run_node (program:program) (input:Michelson.t) : Michelson.t result = let%bind (Ex_typed_value (output_ty, output)) = run_aux compiled input in let%bind output = Trace.trace_tzresult_lwt (simple_error "error unparsing output") @@ - Tezos_utils.Memory_proto_alpha.unparse_michelson_data output_ty output in + Memory_proto_alpha.unparse_michelson_data output_ty output in ok output let run_entry ?(debug_michelson = false) ?options (entry:anon_function) (input:value) : value result = diff --git a/meta_michelson/alpha_wrap.ml b/meta_michelson/alpha_wrap.ml index 196f6a9c4..b456ea335 100644 --- a/meta_michelson/alpha_wrap.ml +++ b/meta_michelson/alpha_wrap.ml @@ -1,10 +1,10 @@ -open Tezos_utils.Error_monad +open Proto_alpha_utils.Error_monad let dummy_environment = force_lwt ~msg:"getting dummy env" @@ Misc.init_environment () let tc = dummy_environment.tezos_context -module Proto_alpha = Tezos_utils.Memory_proto_alpha +module Proto_alpha = Proto_alpha_utils.Memory_proto_alpha open Proto_alpha open Alpha_context open Alpha_environment diff --git a/meta_michelson/contract.ml b/meta_michelson/contract.ml index 1c1b7ccd8..4d8d13d22 100644 --- a/meta_michelson/contract.ml +++ b/meta_michelson/contract.ml @@ -1,6 +1,6 @@ open Misc -open Tezos_utils.Error_monad +open Proto_alpha_utils.Error_monad open Memory_proto_alpha open Alpha_context @@ -8,7 +8,7 @@ open Script_ir_translator open Script_typed_ir module Option = Simple_utils.Option -module Cast = Tezos_utils.Cast +module Cast = Proto_alpha_utils.Cast type ('param, 'storage) toplevel = { param_type : 'param ty ; diff --git a/meta_michelson/dune b/meta_michelson/dune index ba6c4d95f..2ba2a8ae8 100644 --- a/meta_michelson/dune +++ b/meta_michelson/dune @@ -4,6 +4,7 @@ (libraries simple-utils tezos-utils + proto-alpha-utils michelson-parser tezos-micheline ) diff --git a/meta_michelson/michelson_wrap.ml b/meta_michelson/michelson_wrap.ml index c53378c89..ae3034779 100644 --- a/meta_michelson/michelson_wrap.ml +++ b/meta_michelson/michelson_wrap.ml @@ -1,4 +1,4 @@ -open Tezos_utils.Memory_proto_alpha +open Proto_alpha_utils.Memory_proto_alpha module AC = Alpha_context module Types = Contract.Types diff --git a/meta_michelson/misc.ml b/meta_michelson/misc.ml index 5fa0357c3..af5385c14 100644 --- a/meta_michelson/misc.ml +++ b/meta_michelson/misc.ml @@ -1,8 +1,8 @@ module Signature = Tezos_base.TzPervasives.Signature -open Tezos_utils.Memory_proto_alpha +open Proto_alpha_utils.Memory_proto_alpha module Data_encoding = Alpha_environment.Data_encoding module MBytes = Alpha_environment.MBytes -module Error_monad = Tezos_utils.Error_monad +module Error_monad = Proto_alpha_utils.Error_monad open Error_monad module Context_init = struct diff --git a/operators/operators.ml b/operators/operators.ml index 827c42bc6..11596e0a2 100644 --- a/operators/operators.ml +++ b/operators/operators.ml @@ -346,7 +346,7 @@ end module Compiler = struct - module Michelson = Tezos_utils.Micheline.Michelson + module Michelson = Tezos_utils.Michelson open Michelson type predicate =