Added typing of signatures

This fixes a bug where mapfold would insert 
untyped constants in the code.
This commit is contained in:
Cédric Pasteur 2011-09-05 14:50:49 +02:00
parent 626b6cad3f
commit 379f509dfc
3 changed files with 29 additions and 1 deletions

View file

@ -1197,6 +1197,15 @@ let typing_typedec td =
in
{ td with t_desc = tydesc }
let typing_signature s =
let typing_arg cenv a =
{ a with a_type = check_type cenv a.a_type }
in
let typed_params, cenv = build_node_params QualEnv.empty s.sig_params in
{ s with sig_params = typed_params;
sig_inputs = List.map (typing_arg cenv) s.sig_inputs;
sig_outputs = List.map (typing_arg cenv) s.sig_outputs; }
let program p =
let program_desc pd = match pd with
| Pnode n -> Pnode (node n)
@ -1204,3 +1213,15 @@ let program p =
| Ptype t -> Ptype (typing_typedec t)
in
{ p with p_desc = List.map program_desc p.p_desc }
let interface i =
let interface_decl i =
let desc = match i.interf_desc with
| Iconstdef c -> Iconstdef (typing_const_dec c)
| Itypedef t -> Itypedef (typing_typedec t)
| Isignature i -> Isignature (typing_signature i)
| id -> id
in
{ i with interf_desc = desc }
in
List.map interface_decl i

View file

@ -71,3 +71,6 @@ let compile_program p =
p
let compile_interface i =
let i = silent_pass "Typing" true Typing.interface i in
i

View file

@ -28,8 +28,12 @@ let compile_interface modname source_f =
try
(* Process the [lexbuf] to an Heptagon AST *)
let _ = Hept_parser_scoper.parse_interface modname lexbuf in
let p = Hept_parser_scoper.parse_interface modname lexbuf in
if !print_types then Global_printer.print_interface Format.std_formatter;
(* Process the interface *)
let _ = Hept_compiler.compile_interface p in
(* Output the .epci *)
output_value epci_c (Modules.current_module ());
close_all_files ()