AST change : op_desc becomes a record.

This commit is contained in:
Léonard Gérard 2010-06-16 19:30:37 +02:00
parent 3d2e449cbe
commit e400ffd9a5
5 changed files with 19 additions and 17 deletions

View file

@ -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 =

View file

@ -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 =

View file

@ -407,7 +407,7 @@ simple_exp:
node_name:
| longname call_params
{ $1, $2, Enode }
{ mk_op_desc $1 $2 Enode }
exp:
| simple_exp { $1 }

View file

@ -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 () }

View file

@ -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*)