Fix bug for compile-parameter and compile-storage
This commit is contained in:
parent
be75fd4830
commit
8a04ee8097
@ -1,11 +1,6 @@
|
|||||||
open Trace
|
open Trace
|
||||||
open Ast_simplified
|
open Ast_simplified
|
||||||
|
|
||||||
let get_final_environment program =
|
|
||||||
let last_declaration = Location.unwrap List.(hd @@ rev program) in
|
|
||||||
let (Ast_typed.Declaration_constant (_ , (_ , post_env))) = last_declaration in
|
|
||||||
post_env
|
|
||||||
|
|
||||||
let compile_expression ?(value = false) ?env expr =
|
let compile_expression ?(value = false) ?env expr =
|
||||||
if value
|
if value
|
||||||
then (
|
then (
|
||||||
@ -22,7 +17,7 @@ let run_typed_program
|
|||||||
(input : expression) : expression result =
|
(input : expression) : expression result =
|
||||||
let%bind code = Compile.Of_typed.compile_function_entry program entry in
|
let%bind code = Compile.Of_typed.compile_function_entry program entry in
|
||||||
let%bind input =
|
let%bind input =
|
||||||
let env = get_final_environment program in
|
let env = Ast_typed.program_environment program in
|
||||||
compile_expression ?value:input_to_value ~env input
|
compile_expression ?value:input_to_value ~env input
|
||||||
in
|
in
|
||||||
let%bind ex_ty_value = Of_michelson.run ?options code input in
|
let%bind ex_ty_value = Of_michelson.run ?options code input in
|
||||||
|
@ -50,15 +50,19 @@ end
|
|||||||
|
|
||||||
let compile_file_contract_parameter : string -> string -> string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
let compile_file_contract_parameter : string -> string -> string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
||||||
fun source_filename _entry_point expression syntax ->
|
fun source_filename _entry_point expression syntax ->
|
||||||
|
let%bind program = Compile.Of_source.type_file syntax source_filename in
|
||||||
|
let env = Ast_typed.program_environment program in
|
||||||
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
||||||
let%bind simplified = Compile.Helpers.parsify_expression syntax expression in
|
let%bind simplified = Compile.Helpers.parsify_expression syntax expression in
|
||||||
Of_simplified.compile_expression simplified
|
Of_simplified.compile_expression simplified ~env
|
||||||
|
|
||||||
let compile_file_expression : string -> string -> string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
let compile_file_expression : string -> string -> string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
||||||
fun source_filename _entry_point expression syntax ->
|
fun source_filename _entry_point expression syntax ->
|
||||||
|
let%bind program = Compile.Of_source.type_file syntax source_filename in
|
||||||
|
let env = Ast_typed.program_environment program in
|
||||||
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
||||||
let%bind simplified = Compile.Helpers.parsify_expression syntax expression in
|
let%bind simplified = Compile.Helpers.parsify_expression syntax expression in
|
||||||
Of_simplified.compile_expression simplified
|
Of_simplified.compile_expression simplified ~env
|
||||||
|
|
||||||
let compile_expression : string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
let compile_expression : string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
||||||
fun expression syntax ->
|
fun expression syntax ->
|
||||||
@ -68,17 +72,21 @@ let compile_expression : string -> Compile.Helpers.s_syntax -> Michelson.t resul
|
|||||||
|
|
||||||
let compile_file_contract_storage ~value : string -> string -> string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
let compile_file_contract_storage ~value : string -> string -> string -> Compile.Helpers.s_syntax -> Michelson.t result =
|
||||||
fun source_filename _entry_point expression syntax ->
|
fun source_filename _entry_point expression syntax ->
|
||||||
|
let%bind program = Compile.Of_source.type_file syntax source_filename in
|
||||||
|
let env = Ast_typed.program_environment program in
|
||||||
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
||||||
let%bind simplified = Compile.Helpers.parsify_expression syntax expression in
|
let%bind simplified = Compile.Helpers.parsify_expression syntax expression in
|
||||||
Of_simplified.compile_expression ~value simplified
|
Of_simplified.compile_expression ~value simplified ~env
|
||||||
|
|
||||||
let compile_file_contract_args =
|
let compile_file_contract_args =
|
||||||
fun ?value source_filename _entry_point storage parameter syntax ->
|
fun ?value source_filename _entry_point storage parameter syntax ->
|
||||||
|
let%bind program = Compile.Of_source.type_file syntax source_filename in
|
||||||
|
let env = Ast_typed.program_environment program in
|
||||||
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
let%bind syntax = Compile.Helpers.syntax_to_variant syntax (Some source_filename) in
|
||||||
let%bind storage_simplified = Compile.Helpers.parsify_expression syntax storage in
|
let%bind storage_simplified = Compile.Helpers.parsify_expression syntax storage in
|
||||||
let%bind parameter_simplified = Compile.Helpers.parsify_expression syntax parameter in
|
let%bind parameter_simplified = Compile.Helpers.parsify_expression syntax parameter in
|
||||||
let args = Ast_simplified.e_pair storage_simplified parameter_simplified in
|
let args = Ast_simplified.e_pair storage_simplified parameter_simplified in
|
||||||
Of_simplified.compile_expression ?value args
|
Of_simplified.compile_expression ?value args ~env
|
||||||
|
|
||||||
|
|
||||||
let run_contract ?amount ?storage_value source_filename entry_point storage parameter syntax =
|
let run_contract ?amount ?storage_value source_filename entry_point storage parameter syntax =
|
||||||
|
@ -500,3 +500,8 @@ let get_entry (lst : program) (name : string) : annotated_expression result =
|
|||||||
else None
|
else None
|
||||||
in
|
in
|
||||||
List.find_map aux lst
|
List.find_map aux lst
|
||||||
|
|
||||||
|
let program_environment (program : program) : full_environment =
|
||||||
|
let last_declaration = Location.unwrap List.(hd @@ rev program) in
|
||||||
|
match last_declaration with
|
||||||
|
| Declaration_constant (_ , (_ , post_env)) -> post_env
|
||||||
|
Loading…
Reference in New Issue
Block a user