2010-06-15 14:05:26 +02:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon *)
|
|
|
|
(* *)
|
|
|
|
(* Author : Marc Pouzet *)
|
|
|
|
(* Organization : Demons, LRI, University of Paris-Sud, Orsay *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
(* global data in the symbol tables *)
|
|
|
|
open Names
|
|
|
|
open Types
|
|
|
|
|
|
|
|
(** Warning: Whenever these types are modified,
|
|
|
|
interface_format_version should be incremented. *)
|
2010-07-14 00:55:40 +02:00
|
|
|
let interface_format_version = "10"
|
2010-06-15 14:05:26 +02:00
|
|
|
|
|
|
|
(** Node argument *)
|
2010-06-17 16:08:35 +02:00
|
|
|
type arg = { a_name : name option; a_type : ty }
|
2010-06-15 14:05:26 +02:00
|
|
|
|
2010-07-07 12:15:02 +02:00
|
|
|
(** Node static parameters *)
|
2010-07-05 15:43:51 +02:00
|
|
|
type param = { p_name : name; p_type : ty }
|
2010-06-15 14:05:26 +02:00
|
|
|
|
2010-07-08 14:56:49 +02:00
|
|
|
(** Constraints on size expressions. *)
|
|
|
|
type size_constraint =
|
|
|
|
| Cequal of static_exp * static_exp (* e1 = e2*)
|
|
|
|
| Clequal of static_exp * static_exp (* e1 <= e2 *)
|
|
|
|
| Cfalse
|
|
|
|
|
2010-06-15 14:05:26 +02:00
|
|
|
(** Node signature *)
|
|
|
|
type node =
|
2010-06-29 11:18:50 +02:00
|
|
|
{ node_inputs : arg list;
|
|
|
|
node_outputs : arg list;
|
2010-06-30 10:22:31 +02:00
|
|
|
node_statefull : bool;
|
2010-06-29 11:18:50 +02:00
|
|
|
node_params : param list; (** Static parameters *)
|
2010-07-02 15:38:11 +02:00
|
|
|
node_params_constraints : size_constraint list }
|
2010-06-15 14:05:26 +02:00
|
|
|
|
2010-06-17 16:08:35 +02:00
|
|
|
type field = { f_name : name; f_type : ty }
|
|
|
|
type structure = field list
|
2010-06-15 14:05:26 +02:00
|
|
|
|
|
|
|
type type_def = | Tabstract | Tenum of name list | Tstruct of structure
|
|
|
|
|
2010-07-07 16:43:23 +02:00
|
|
|
type const_def = { c_name : name; c_type : ty; c_value : static_exp }
|
|
|
|
|
2010-06-15 14:05:26 +02:00
|
|
|
let names_of_arg_list l = List.map (fun ad -> ad.a_name) l
|
|
|
|
|
|
|
|
let types_of_arg_list l = List.map (fun ad -> ad.a_type) l
|
|
|
|
|
2010-06-27 17:24:31 +02:00
|
|
|
let mk_arg name ty = { a_type = ty; a_name = name }
|
2010-06-26 16:53:25 +02:00
|
|
|
|
2010-07-05 15:43:51 +02:00
|
|
|
let mk_param name ty = { p_name = name; p_type = ty }
|
2010-06-29 11:18:50 +02:00
|
|
|
|
2010-07-01 19:35:24 +02:00
|
|
|
let mk_field n ty = { f_name = n; f_type = ty }
|
|
|
|
|
2010-07-07 16:43:23 +02:00
|
|
|
let mk_const_def name ty value =
|
|
|
|
{ c_name = name; c_type = ty; c_value = value }
|
2010-06-17 16:09:32 +02:00
|
|
|
|
2010-06-17 13:05:16 +02:00
|
|
|
let rec field_assoc f = function
|
|
|
|
| [] -> raise Not_found
|
|
|
|
| { f_name = n; f_type = ty }::l ->
|
2010-07-14 00:55:40 +02:00
|
|
|
if shortname f = n then ty
|
|
|
|
else field_assoc f l
|
2010-07-07 15:11:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
open Format
|
|
|
|
|
|
|
|
let print_param ff p =
|
|
|
|
fprintf ff "%a:%a" Names.print_name p.p_name print_type p.p_type
|
|
|
|
|