WIP on integrating typer with the bin / CLI, fixed last API change

This commit is contained in:
Suzanne Dupéron 2019-10-11 04:08:12 -04:00
parent 2a39aa2949
commit 1356159281
2 changed files with 16 additions and 7 deletions

View File

@ -14,12 +14,17 @@ let compile_expression_as_function_entry (program : program) entry_point : _ res
let%bind typed_program = Typer.type_program program in let%bind typed_program = Typer.type_program program in
Of_typed.compile_expression_as_function_entry typed_program entry_point Of_typed.compile_expression_as_function_entry typed_program entry_point
let compile_expression_as_value ?(env = Ast_typed.Environment.full_empty) ae : Michelson.t result = (* TODO: do we need to thread the state here? Also, make the state arg. optional. *)
let%bind typed = Typer.type_expression env ae in let compile_expression_as_value ?(env = Ast_typed.Environment.full_empty) ~(state : Typer.Solver.state) ae : Michelson.t result =
let%bind (typed , state) = Typer.type_expression env state ae in
(* TODO: move this to typer.ml *)
let typed = let () = failwith "TODO : subst all" in let _todo = ignore (env, state) in typed in
Of_typed.compile_expression_as_value typed Of_typed.compile_expression_as_value typed
let compile_expression_as_function ?(env = Ast_typed.Environment.full_empty) ae : _ result = let compile_expression_as_function ?(env = Ast_typed.Environment.full_empty) ~(state : Typer.Solver.state) ae : _ result =
let%bind typed = Typer.type_expression env ae in let%bind (typed , state) = Typer.type_expression env state ae in
(* TODO: move this to typer.ml *)
let typed = let () = failwith "TODO : subst all" in let _todo = ignore (env, state) in typed in
Of_typed.compile_expression_as_function typed Of_typed.compile_expression_as_function typed
let uncompile_typed_program_entry_expression_result program entry ex_ty_value = let uncompile_typed_program_entry_expression_result program entry ex_ty_value =

View File

@ -871,10 +871,9 @@ and type_expression : environment -> Solver.state -> I.expression -> (O.annotate
let e' = Environment.add_ez_binder (fst binder) fresh e in let e' = Environment.add_ez_binder (fst binder) fresh e in
let%bind (result , state') = type_expression e' state result in let%bind (result , state') = type_expression e' state result in
let output_type = result.type_annotation in
let wrapped = Wrap.lambda fresh input_type' output_type' in let wrapped = Wrap.lambda fresh input_type' output_type' in
return_wrapped return_wrapped
(E_lambda {binder = fst binder; input_type=fresh;output_type; body=result}) (E_lambda {binder = fst binder; body=result}) (* TODO: is the type of the entire lambda enough to access the input_type=fresh; ? *)
state' wrapped state' wrapped
) )
@ -923,7 +922,7 @@ let untype_type_value (t:O.type_value) : (I.type_expression) result =
(* (*
Apply type_declaration on all the node of the AST_simplified from the root p Apply type_declaration on all the node of the AST_simplified from the root p
*) *)
let type_program (p:I.program) : (environment * Solver.state * O.program) result = let type_program_returns_state (p:I.program) : (environment * Solver.state * O.program) result =
let env = Ast_typed.Environment.full_empty in let env = Ast_typed.Environment.full_empty in
let state = Solver.initial_state in let state = Solver.initial_state in
let aux ((e : environment), (s : Solver.state) , (ds : O.declaration Location.wrap list)) (d:I.declaration Location.wrap) = let aux ((e : environment), (s : Solver.state) , (ds : O.declaration Location.wrap list)) (d:I.declaration Location.wrap) =
@ -940,6 +939,11 @@ let type_program (p:I.program) : (environment * Solver.state * O.program) result
let () = ignore (env' , state') in let () = ignore (env' , state') in
ok (env', state', declarations) ok (env', state', declarations)
let type_program (p : I.program) : O.program result =
let%bind (env, state, program) = type_program_returns_state p in
let program = let () = failwith "TODO : subst all" in let _todo = ignore (env, state) in program in
ok program
(* (*
Similar to type_program but use a fold_map_list and List.fold_left and add element to the left or the list which gives a better complexity Similar to type_program but use a fold_map_list and List.fold_left and add element to the left or the list which gives a better complexity
*) *)