From e400ffd9a55a6cd6819279e31fcd0cbd077eab6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20G=C3=A9rard?= Date: Wed, 16 Jun 2010 19:30:37 +0200 Subject: [PATCH] AST change : op_desc becomes a record. --- heptagon/analysis/initialization.ml | 1 - heptagon/heptagon.ml | 2 +- heptagon/parsing/parser.mly | 2 +- heptagon/parsing/parsetree.ml | 7 +++++-- minils/minils.ml | 24 ++++++++++++------------ 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/heptagon/analysis/initialization.ml b/heptagon/analysis/initialization.ml index 9f9e054..1b551a3 100644 --- a/heptagon/analysis/initialization.ml +++ b/heptagon/analysis/initialization.ml @@ -212,7 +212,6 @@ let rec typing h e = skeleton i e.e_ty | Earray(e_list) -> product (List.map (typing h) e_list) - | Ereset_mem _ -> assert false (** Typing an application *) and apply h op e_list = diff --git a/heptagon/heptagon.ml b/heptagon/heptagon.ml index f1892b2..83697e1 100644 --- a/heptagon/heptagon.ml +++ b/heptagon/heptagon.ml @@ -57,7 +57,7 @@ type exp = | Eiterator of iterator_type * op_desc * exp option (** [op_desc] node to map [exp option] reset *) - and op_desc = longname * size_exp list * op_kind + and op_desc = { op_name : longname; op_params: size_exp list; op_kind: op_kind } and op_kind = | Eop | Enode and const = diff --git a/heptagon/parsing/parser.mly b/heptagon/parsing/parser.mly index 69fa7e5..4af55a9 100644 --- a/heptagon/parsing/parser.mly +++ b/heptagon/parsing/parser.mly @@ -407,7 +407,7 @@ simple_exp: node_name: | longname call_params - { $1, $2, Enode } + { mk_op_desc $1 $2 Enode } exp: | simple_exp { $1 } diff --git a/heptagon/parsing/parsetree.ml b/heptagon/parsing/parsetree.ml index 8ba4dd4..17291a8 100644 --- a/heptagon/parsing/parsetree.ml +++ b/heptagon/parsing/parsetree.ml @@ -53,7 +53,7 @@ and array_op = | Econcat | Eiterator of iterator_type * op_desc -and op_desc = longname * exp list * op_kind +and op_desc = { op_name : longname; op_params: exp list; op_kind: op_kind } and op_kind = | Eop | Enode and const = @@ -180,11 +180,14 @@ let mk_call desc exps = let mk_op_call s params exps = mk_call (Name s, params, Eop) exps +let mk_op_desc ln params kind = + { op_name = ln; op_params = params; op_kind = kind } + let mk_array_op_call op exps = Eapp (mk_app (Earray_op op), exps) let mk_iterator_call it ln params exps = - mk_array_op_call (Eiterator (it, (ln, params, Enode))) exps + mk_array_op_call (Eiterator (it, mk_op_desc ln params Enode)) exps let mk_type_dec name desc = { t_name = name; t_desc = desc; t_loc = Location.get_current_location () } diff --git a/minils/minils.ml b/minils/minils.ml index 4db8658..a86fea8 100644 --- a/minils/minils.ml +++ b/minils/minils.ml @@ -16,6 +16,7 @@ open Names open Ident open Signature open Static +open Types type iterator_type = | Imap @@ -33,12 +34,12 @@ and tdesc = | Type_struct of structure and exp = - { e_desc: desc; (* its descriptor *) + { e_desc: edesc; (* its descriptor *) mutable e_ck: ck; mutable e_ty: ty; e_loc: location } -and desc = +and edesc = | Econst of const | Evar of ident | Econstvar of name @@ -66,7 +67,7 @@ and array_op = | Econcat of exp * exp | Eiterator of iterator_name * longname * size_exp list * size_exp * exp list * ident option -and op_desc = longname * size_exp list * op_kind +and op_desc = { op_name: longname; op_params: size_exp list; op_kind: op_kind } and op_kind = | Eop | Enode and ct = @@ -95,7 +96,7 @@ and pat = type eq = { eq_lhs : pat; eq_rhs : exp; - eq_loc : loc } + eq_loc : location } type var_dec = { v_name : ident; @@ -135,20 +136,19 @@ type program = p_consts : const_dec list; } (*Helper functions to build the AST*) -let make_exp desc ty l ck loc = - { e_desc = desc; e_ty = ty; e_linearity = l; e_ck = ck; e_loc = loc } -let make_dummy_exp desc ty = - { e_desc = desc; e_ty = ty; e_linearity = NotLinear; - e_ck = Cbase; e_loc = no_location } + +let mk_exp ?(exp_ty = Tprod []) ?(clock = Cbase) ?(loc = no_location) desc = + { e_desc = desc; e_ty = exp_ty; e_ck = clock; e_loc = loc } + let rec size_exp_of_exp e = match e.e_desc with | Econstvar n -> SVar n | Econst (Cint i) -> SConst i - | Eop(op, _, [e1;e2]) -> - let sop = op_from_app_name op in - SOp(sop, size_exp_of_exp e1, size_exp_of_exp e2) + | Ecall(op, [e1;e2], _) -> + let sop = op_from_app_name op.op_name in + SOp(sop, size_exp_of_exp e1, size_exp_of_exp e2) | _ -> raise Not_static (*Returns the list of bounds of an array type*)