ligo/src/main/compile/of_simplified.ml

47 lines
2.0 KiB
OCaml
Raw Normal View History

2019-09-10 17:19:15 +04:00
open Ast_simplified
open Trace
2019-09-20 20:56:55 +04:00
let compile_contract_entry (program : program) entry_point =
let%bind (prog_typed , state) = Typer.type_program program in
let () = Typer.Solver.discard_state state in
2019-09-20 20:56:55 +04:00
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 , state) = Typer.type_program program in
let () = Typer.Solver.discard_state state in
2019-09-19 03:34:37 +04:00
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 =
let%bind (typed_program , state) = Typer.type_program program in
let () = Typer.Solver.discard_state state 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
(* TODO: do we need to thread the state here? Also, make the state arg. optional. *)
let compile_expression_as_function ?(env = Ast_typed.Environment.full_empty) ~(state : Typer.Solver.state) (ae : Ast_simplified.expression) : _ result =
let%bind (typed , state) = Typer.type_expression env state ae in
(* TODO: move this to typer.ml *)
2019-11-01 17:48:09 +04:00
let typed =
if false then
let () = failwith "TODO : subst all" in let _todo = ignore (env, state) in typed
else
typed
in
2019-09-25 12:49:14 +04:00
Of_typed.compile_expression_as_function 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