heptagon/compiler/global/signature.ml

75 lines
2.2 KiB
OCaml
Raw Normal View History

(**************************************************************************)
(* *)
(* 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. *)
let interface_format_version = "20"
(** Node argument *)
type arg = { a_name : name option; a_type : ty }
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 }
(** Constraints on size expressions *)
2010-07-08 14:56:49 +02:00
type size_constraint =
| Cequal of static_exp * static_exp (* e1 = e2 *)
2010-07-08 14:56:49 +02:00
| Clequal of static_exp * static_exp (* e1 <= e2 *)
| Cfalse
(** Node signature *)
type node = {
node_inputs : arg list;
node_outputs : arg list;
2011-03-21 14:30:19 +01:00
node_stateful : bool;
node_params : param list;
node_params_constraints : size_constraint list }
type field = { f_name : field_name; f_type : ty }
type structure = field list
type type_def =
| Tabstract
| Talias of ty
| Tenum of constructor_name list
| Tstruct of structure
type const_def = { c_type : ty; c_value : static_exp }
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
let mk_arg name ty = { a_type = ty; a_name = name }
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 }
let mk_const_def ty value =
{ c_type = ty; c_value = value }
2011-03-21 14:30:19 +01:00
let mk_node ?(constraints = []) ins outs stateful params =
{ node_inputs = ins;
node_outputs = outs;
2011-03-21 14:30:19 +01:00
node_stateful = stateful;
node_params = params;
node_params_constraints = constraints }
2010-06-17 13:05:16 +02:00
let rec field_assoc f = function
| [] -> raise Not_found
| { f_name = n; f_type = ty }::l ->
if f = n then ty
2010-07-14 00:55:40 +02:00
else field_assoc f l