From 9a69c30dc56f96aca6f2c81233f4edb22d7f26ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20G=C3=A9rard?= Date: Tue, 23 Nov 2010 17:13:33 +0100 Subject: [PATCH] Clock annotation in Hept AST --- compiler/heptagon/heptagon.ml | 13 +++++++------ compiler/heptagon/parsing/hept_parsetree.ml | 5 +++-- compiler/heptagon/parsing/hept_scoping.ml | 1 + compiler/main/mls2obc.ml | 2 +- compiler/minils/main/mls_compiler.ml | 18 +----------------- compiler/minils/minils.ml | 4 ++-- todo.txt | 4 ++++ 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/compiler/heptagon/heptagon.ml b/compiler/heptagon/heptagon.ml index 2c5361f..f3335be 100644 --- a/compiler/heptagon/heptagon.ml +++ b/compiler/heptagon/heptagon.ml @@ -1,4 +1,4 @@ - (**************************************************************************) +(**************************************************************************) (* *) (* Heptagon *) (* *) @@ -26,9 +26,10 @@ type iterator_type = | Imapfold type exp = { - e_desc : desc; - e_ty : ty; - e_loc : location } + e_desc : desc; + e_ty : ty; + e_ct_annot : ct; + e_loc : location } and desc = | Econst of static_exp @@ -179,8 +180,8 @@ and interface_desc = | Isignature of signature (* Helper functions to create AST. *) -let mk_exp desc ty = - { e_desc = desc; e_ty = ty; e_loc = no_location; } +let mk_exp desc ?(ct_annot = Clocks.invalid_clock) ty = + { e_desc = desc; e_ty = ty; e_ct_annot = ct_annot; e_loc = no_location; } let mk_op ?(params=[]) ?(unsafe=false) op = { a_op = op; a_params = params; a_unsafe = unsafe } diff --git a/compiler/heptagon/parsing/hept_parsetree.ml b/compiler/heptagon/parsing/hept_parsetree.ml index 3d50d6a..854fca2 100644 --- a/compiler/heptagon/parsing/hept_parsetree.ml +++ b/compiler/heptagon/parsing/hept_parsetree.ml @@ -59,6 +59,7 @@ type ty = and exp = { e_desc : edesc; + e_ct_annot : Clocks.ct; e_loc : location } and edesc = @@ -206,8 +207,8 @@ and interface_desc = (* {3 Helper functions to create AST} *) -let mk_exp desc loc = - { e_desc = desc; e_loc = loc } +let mk_exp desc ?(ct_annot = Clocks.invalid_clock) loc = + { e_desc = desc; e_ct_annot = ct_annot; e_loc = loc } let mk_app op params = { a_op = op; a_params = params } diff --git a/compiler/heptagon/parsing/hept_scoping.ml b/compiler/heptagon/parsing/hept_scoping.ml index e8d66d7..f84b39e 100644 --- a/compiler/heptagon/parsing/hept_scoping.ml +++ b/compiler/heptagon/parsing/hept_scoping.ml @@ -222,6 +222,7 @@ let rec translate_exp env e = try { Heptagon.e_desc = translate_desc e.e_loc env e.e_desc; Heptagon.e_ty = Types.invalid_type; + Heptagon.e_ct_annot = e.e_ct_annot; Heptagon.e_loc = e.e_loc } with ScopingError(error) -> message e.e_loc error diff --git a/compiler/main/mls2obc.ml b/compiler/main/mls2obc.ml index 56337eb..2fd1acc 100644 --- a/compiler/main/mls2obc.ml +++ b/compiler/main/mls2obc.ml @@ -63,7 +63,7 @@ let rec translate_pat map = function List.fold_right (fun pat acc -> (translate_pat map pat) @ acc) pat_list [] -let translate_var_dec l = (*TODO bug map unused ?*) +let translate_var_dec l = let one_var { Minils.v_ident = x; Minils.v_type = t; v_loc = loc } = mk_var_dec ~loc:loc x t in diff --git a/compiler/minils/main/mls_compiler.ml b/compiler/minils/main/mls_compiler.ml index cd2d32b..f305d39 100644 --- a/compiler/minils/main/mls_compiler.ml +++ b/compiler/minils/main/mls_compiler.ml @@ -12,23 +12,7 @@ open Compiler_utils open Compiler_options let pp p = if !verbose then Mls_printer.print stdout p -(* -let parse parsing_fun lexing_fun lexbuf = - try - parsing_fun lexing_fun lexbuf - with - | Mls_lexer.Lexical_error(err, loc) -> - lexical_error err loc - | Mls_parser.Error -> - let pos1 = Lexing.lexeme_start_p lexbuf - and pos2 = Lexing.lexeme_end_p lexbuf in - let l = Loc(pos1,pos2) in - syntax_error l - -let parse_implementation prog_name lexbuf = - let p = parse Mls_parser.program Mls_lexer.token lexbuf in - { p with Mls_parsetree.p_modname = prog_name } -*) + let compile pp p = (* Clocking *) let p = pass "Clocking" true Clocking.program p pp in diff --git a/compiler/minils/minils.ml b/compiler/minils/minils.ml index 41c1a24..286a0f8 100644 --- a/compiler/minils/minils.ml +++ b/compiler/minils/minils.ml @@ -39,10 +39,10 @@ and tdesc = | Type_struct of structure and exp = { - e_desc: edesc; + e_desc : edesc; mutable e_ck: ck; mutable e_ty: ty; - e_loc: location } + e_loc : location } and edesc = | Econst of static_exp diff --git a/todo.txt b/todo.txt index e42266b..53d2ea0 100644 --- a/todo.txt +++ b/todo.txt @@ -7,4 +7,8 @@ Plus ou moins ordonné du plus urgent au moins urgent. *- Compléter la passe "static.ml" pour gérer l'ensemble des opérateurs de pervasives +*- Permettre les déclarations des types et des noeuds et des constantes dans un ordre quelconque. + +*- Permettre la définition de constantes locales. + *- Optimiser le reset en utilisant un memcopy ?