fix stuff

This commit is contained in:
Galfour 2019-05-13 12:20:23 +00:00
parent 1edfd8ea06
commit 8765e7258a
14 changed files with 35 additions and 30 deletions

View File

@ -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

View File

@ -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 ()

View File

@ -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

View File

@ -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

View File

@ -15,6 +15,7 @@ depends: [
"ppx_let"
"ppx_deriving"
"tezos-utils"
"proto-alpha-utils"
"yojson"
"alcotest" { with-test }
]

View File

@ -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

View File

@ -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

View File

@ -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 =

View File

@ -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

View File

@ -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 ;

View File

@ -4,6 +4,7 @@
(libraries
simple-utils
tezos-utils
proto-alpha-utils
michelson-parser
tezos-micheline
)

View File

@ -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

View File

@ -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

View File

@ -346,7 +346,7 @@ end
module Compiler = struct
module Michelson = Tezos_utils.Micheline.Michelson
module Michelson = Tezos_utils.Michelson
open Michelson
type predicate =