2019-09-10 17:19:15 +04:00
|
|
|
open Ast_simplified
|
|
|
|
open Trace
|
2019-09-11 15:56:39 +04:00
|
|
|
open Tezos_utils
|
2019-09-10 17:19:15 +04:00
|
|
|
|
2019-09-20 20:56:55 +04:00
|
|
|
let compile_contract_entry (program : program) entry_point =
|
|
|
|
let%bind prog_typed = Typer.type_program program in
|
|
|
|
Of_typed.compile_contract_entry prog_typed entry_point
|
|
|
|
|
2019-09-19 03:34:37 +04:00
|
|
|
let compile_function_entry (program : program) entry_point : _ result =
|
|
|
|
let%bind prog_typed = Typer.type_program program in
|
|
|
|
Of_typed.compile_function_entry prog_typed entry_point
|
2019-09-11 15:56:39 +04:00
|
|
|
|
2019-09-19 03:34:37 +04:00
|
|
|
let compile_expression_as_function_entry (program : program) entry_point : _ result =
|
2019-09-11 15:56:39 +04:00
|
|
|
let%bind typed_program = Typer.type_program program in
|
2019-09-19 03:34:37 +04:00
|
|
|
Of_typed.compile_expression_as_function_entry typed_program entry_point
|
2019-09-11 15:56:39 +04:00
|
|
|
|
2019-09-23 00:44:50 +04:00
|
|
|
let compile_expression ?(env = Ast_typed.Environment.full_empty) ?value ae : Michelson.t result =
|
2019-09-15 15:12:19 +04:00
|
|
|
let%bind typed = Typer.type_expression env ae in
|
2019-09-23 00:44:50 +04:00
|
|
|
Of_typed.compile_expression ?value typed
|
2019-09-15 15:12:19 +04:00
|
|
|
|
|
|
|
let uncompile_typed_program_entry_expression_result program entry ex_ty_value =
|
|
|
|
let%bind output_type =
|
2019-09-19 03:34:37 +04:00
|
|
|
let%bind entry_expression = Ast_typed.get_entry program entry in
|
2019-09-15 15:12:19 +04:00
|
|
|
ok entry_expression.type_annotation
|
|
|
|
in
|
|
|
|
let%bind typed = Of_typed.uncompile_value ex_ty_value output_type in
|
|
|
|
Typer.untype_expression typed
|
|
|
|
|
|
|
|
let uncompile_typed_program_entry_function_result program entry ex_ty_value =
|
|
|
|
let%bind output_type =
|
2019-09-19 03:34:37 +04:00
|
|
|
let%bind entry_expression = Ast_typed.get_entry program entry in
|
2019-09-15 15:12:19 +04:00
|
|
|
let%bind (_ , output_type) = Ast_typed.get_t_function entry_expression.type_annotation in
|
|
|
|
ok output_type
|
|
|
|
in
|
|
|
|
let%bind typed = Of_typed.uncompile_value ex_ty_value output_type in
|
|
|
|
Typer.untype_expression typed
|