2010-06-15 10:49:03 +02:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon *)
|
|
|
|
(* *)
|
|
|
|
(* Author : Marc Pouzet *)
|
|
|
|
(* Organization : Demons, LRI, University of Paris-Sud, Orsay *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
(* The internal MiniLustre representation *)
|
|
|
|
|
|
|
|
open Location
|
|
|
|
open Names
|
|
|
|
open Ident
|
2010-06-15 15:08:14 +02:00
|
|
|
open Signature
|
2010-06-15 10:49:03 +02:00
|
|
|
open Static
|
2010-06-16 19:30:37 +02:00
|
|
|
open Types
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2010-06-26 16:53:25 +02:00
|
|
|
type iterator_type =
|
2010-06-15 14:05:26 +02:00
|
|
|
| Imap
|
|
|
|
| Ifold
|
|
|
|
| Imapfold
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
type type_dec =
|
|
|
|
{ t_name: name;
|
|
|
|
t_desc: tdesc;
|
|
|
|
t_loc: location }
|
|
|
|
|
|
|
|
and tdesc =
|
|
|
|
| Type_abs
|
|
|
|
| Type_enum of name list
|
2010-06-15 15:08:14 +02:00
|
|
|
| Type_struct of structure
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
and exp =
|
2010-06-16 19:30:37 +02:00
|
|
|
{ e_desc: edesc; (* its descriptor *)
|
2010-06-15 10:49:03 +02:00
|
|
|
mutable e_ck: ck;
|
|
|
|
mutable e_ty: ty;
|
2010-06-15 15:08:14 +02:00
|
|
|
e_loc: location }
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2010-06-16 19:30:37 +02:00
|
|
|
and edesc =
|
2010-06-15 10:49:03 +02:00
|
|
|
| Econst of const
|
|
|
|
| Evar of ident
|
|
|
|
| Econstvar of name
|
|
|
|
| Efby of const option * exp
|
|
|
|
| Etuple of exp list
|
2010-06-29 11:18:50 +02:00
|
|
|
| Ecall of op_desc * exp list * ident option (** [op_desc] is the function
|
|
|
|
called [exp list] is the
|
|
|
|
passed arguments [ident
|
|
|
|
option] is the optional reset
|
|
|
|
condition *)
|
2010-06-15 15:08:14 +02:00
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
| Ewhen of exp * longname * ident
|
|
|
|
| Emerge of ident * (longname * exp) list
|
|
|
|
| Eifthenelse of exp * exp * exp
|
|
|
|
| Efield of exp * longname
|
2010-06-15 15:08:14 +02:00
|
|
|
| Efield_update of longname * exp * exp (*field, record, value*)
|
2010-06-15 10:49:03 +02:00
|
|
|
| Estruct of (longname * exp) list
|
|
|
|
| Earray of exp list
|
2010-06-15 15:08:14 +02:00
|
|
|
| Earray_op of array_op
|
|
|
|
|
|
|
|
and array_op =
|
2010-06-15 10:49:03 +02:00
|
|
|
| Erepeat of size_exp * exp
|
|
|
|
| Eselect of size_exp list * exp (*indices, array*)
|
2010-06-30 15:44:56 +02:00
|
|
|
| Eselect_dyn of exp list * exp * exp (* indices, array, default*)
|
2010-06-15 10:49:03 +02:00
|
|
|
| Eupdate of size_exp list * exp * exp (*indices, array, value*)
|
2010-06-26 16:53:25 +02:00
|
|
|
| Eselect_slice of size_exp * size_exp * exp (*lower bound, upper bound,
|
|
|
|
array*)
|
2010-06-15 10:49:03 +02:00
|
|
|
| Econcat of exp * exp
|
2010-06-29 11:18:50 +02:00
|
|
|
| Eiterator of iterator_type * op_desc * size_exp * exp list * ident option
|
|
|
|
(** [op_desc] is the function iterated, [size_exp] is the size of the
|
|
|
|
iteration, [exp list] is the passed arguments, [ident option] is the
|
|
|
|
optional reset condition *)
|
2010-06-26 16:53:25 +02:00
|
|
|
|
2010-06-16 19:30:37 +02:00
|
|
|
and op_desc = { op_name: longname; op_params: size_exp list; op_kind: op_kind }
|
2010-06-30 10:22:31 +02:00
|
|
|
and op_kind = | Efun | Enode
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
and ct =
|
|
|
|
| Ck of ck
|
|
|
|
| Cprod of ct list
|
|
|
|
|
|
|
|
and ck =
|
|
|
|
| Cbase
|
|
|
|
| Cvar of link ref
|
|
|
|
| Con of ck * longname * ident
|
|
|
|
|
|
|
|
and link =
|
|
|
|
| Cindex of int
|
|
|
|
| Clink of ck
|
|
|
|
|
|
|
|
and const =
|
|
|
|
| Cint of int
|
|
|
|
| Cfloat of float
|
|
|
|
| Cconstr of longname
|
2010-06-26 16:53:25 +02:00
|
|
|
| Carray of size_exp * const
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
and pat =
|
|
|
|
| Etuplepat of pat list
|
|
|
|
| Evarpat of ident
|
|
|
|
|
|
|
|
type eq =
|
2010-06-15 15:08:14 +02:00
|
|
|
{ eq_lhs : pat;
|
|
|
|
eq_rhs : exp;
|
2010-06-16 19:30:37 +02:00
|
|
|
eq_loc : location }
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
type var_dec =
|
2010-06-27 17:24:31 +02:00
|
|
|
{ v_ident : ident;
|
2010-06-15 14:05:26 +02:00
|
|
|
v_type : ty;
|
2010-06-15 10:49:03 +02:00
|
|
|
v_clock : ck }
|
|
|
|
|
|
|
|
type contract =
|
|
|
|
{ c_assume : exp;
|
|
|
|
c_enforce : exp;
|
|
|
|
c_controllables : var_dec list;
|
|
|
|
c_local : var_dec list;
|
|
|
|
c_eq : eq list;
|
|
|
|
}
|
|
|
|
|
|
|
|
type node_dec =
|
|
|
|
{ n_name : name;
|
|
|
|
n_input : var_dec list;
|
|
|
|
n_output : var_dec list;
|
|
|
|
n_contract : contract option;
|
|
|
|
n_local : var_dec list;
|
|
|
|
n_equs : eq list;
|
2010-06-15 15:08:14 +02:00
|
|
|
n_loc : location;
|
2010-06-26 16:53:25 +02:00
|
|
|
n_params : param list;
|
2010-07-02 15:38:11 +02:00
|
|
|
n_params_constraints : size_constraint list;
|
2010-06-15 15:08:14 +02:00
|
|
|
n_params_instances : (int list) list; }(*TODO commenter ou passer en env*)
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
type const_dec =
|
|
|
|
{ c_name : name;
|
|
|
|
c_value : size_exp;
|
|
|
|
c_loc : location; }
|
|
|
|
|
|
|
|
type program =
|
|
|
|
{ p_pragmas: (name * string) list;
|
|
|
|
p_opened : name list;
|
|
|
|
p_types : type_dec list;
|
|
|
|
p_nodes : node_dec list;
|
|
|
|
p_consts : const_dec list; }
|
|
|
|
|
2010-06-16 19:31:51 +02:00
|
|
|
|
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
(*Helper functions to build the AST*)
|
|
|
|
|
2010-06-16 19:30:37 +02:00
|
|
|
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 }
|
|
|
|
|
2010-06-27 17:24:31 +02:00
|
|
|
let mk_var_dec ?(clock = Cbase) ident ty =
|
|
|
|
{ v_ident = ident; v_type = ty;
|
2010-06-22 09:18:01 +02:00
|
|
|
v_clock = clock }
|
2010-06-18 11:46:57 +02:00
|
|
|
|
2010-06-18 14:59:10 +02:00
|
|
|
let mk_equation ?(loc = no_location) pat exp =
|
|
|
|
{ eq_lhs = pat; eq_rhs = exp; eq_loc = loc }
|
2010-06-26 16:53:25 +02:00
|
|
|
|
2010-06-21 18:19:58 +02:00
|
|
|
let mk_node
|
2010-06-29 11:18:50 +02:00
|
|
|
?(input = []) ?(output = []) ?(contract = None) ?(local = []) ?(eq = [])
|
|
|
|
?(loc = no_location) ?(param = []) ?(constraints = []) ?(pinst = []) name =
|
|
|
|
{ n_name = name;
|
|
|
|
n_input = input;
|
|
|
|
n_output = output;
|
|
|
|
n_contract = contract;
|
|
|
|
n_local = local;
|
|
|
|
n_equs = eq;
|
|
|
|
n_loc = loc;
|
|
|
|
n_params = param;
|
|
|
|
n_params_constraints = constraints;
|
|
|
|
n_params_instances = pinst; }
|
2010-06-21 18:19:58 +02:00
|
|
|
|
|
|
|
let mk_type_dec ?(type_desc = Type_abs) ?(loc = no_location) name =
|
|
|
|
{ t_name = name; t_desc = type_desc; t_loc = loc }
|
|
|
|
|
2010-06-27 17:24:31 +02:00
|
|
|
let mk_op ?(op_params = []) ?(op_kind = Enode) lname =
|
2010-06-29 11:18:50 +02:00
|
|
|
{ op_name = lname; op_params = op_params; op_kind = op_kind }
|
|
|
|
|
2010-06-27 17:24:31 +02:00
|
|
|
let void = mk_exp (Etuple [])
|
2010-06-15 10:49:03 +02:00
|
|
|
|