Newer
Older
(* Time-stamp: <modified the 11/03/2013 (at 09:23) by Erwan Jahier> *)
(** Synchronous Object Component *)
(* Just a string because :
- it's more ocamldebug-friendly
- Name clashing issues ougth to have been fixed before
*)
type ident = string
type var_type =
| Bool | Int | Real
| Extern of ident
| Enum of (ident * ident list)
| Struct of ident * (ident * var_type) list
| Array of (var_type * int)
| Alpha of int
type var = ident * var_type
ident *
var_type list * (* I/O type list *)
(int * int * int) option (* to deal with slices (useful?) *)
Erwan Jahier
committed
type instance = ident * key
(* Variable denotation *)
type var_expr =
| Var of var
| Const of var (* useful? *)
| Field of var_expr * var
| Index of var_expr * int * var_type
type atomic_operation =
| Assign (* Wire *)
Erwan Jahier
committed
| Method of instance (* node step call *)
| Procedure of key (* memoryless method made explicit (a good idea?) *)
(* Guarded Atomic Operation *)
type gao =
| Case of ident (* enum var *) * (ident (* enum value *) * gao list) list
| Call of var_expr list * atomic_operation * var_expr list
(* outputs * op * inputs *)
name : ident;
lxm : Lxm.t;
idx_ins : int list; (* input index in the profile *)
idx_outs : int list; (* output index in the profile *)
impl : (var list * gao list) option; (* local vars + body ; None for predef op *)
}
type precedence = ident * ident list
(* Partial order over step members. Maps a step method name with
the list of step methods that should be called _before_.
nb : steps in step are already ordered ; this partial order
can be useful to find another (better) total order w.r.t. test
opening.
*)
Erwan Jahier
committed
type t = {
(* les memoires de l'objet sont calculées par l'interpreteur (ou l'objet C) *)
key : key;
profile : var list * var list;
instances : instance list;
init : step_method option;
step : step_method list; (* the order in the list is a valid w.r.t.
the partial order defined in precedences *)
precedences : precedence list; (* partial order over step methods *)
Erwan Jahier
committed
(* SocKeyMap ? *)
module SocMap = Map.Make(
struct
type t = key
let compare = compare
end
)
Erwan Jahier
committed
Erwan Jahier
committed
let cpt = ref 0
let (make: key -> instance) =
fun sk ->
let (id,_,_) = sk in
let instance = Printf.sprintf "%s%03d" id !cpt in
incr cpt;
instance,sk