package lustre-v6

  1. Overview
  2. Docs

Define the Data Structure representing Compiled programs. By compiled we mean that constant are propagated, packages are instanciated, recursive node are inlined, etc.

lic = lustre internal code

Basically it is Lustre with all the suggar removed.

Définition des structures de données utilisée pour la compil, plus des utilitaires pour les messages d'erreurs, de bug etc. N.B. on utilise beaucoup l'adjectif "effectif", qui signifie simplement "correct" (c'est bizzare mais c'est ainsi.

REMARQUE GENERALE :

D'une manière générale, la compil d'une entité syntaxique "toto" est implémentée par une fonction check_toto, qui prend en entrée (entr'autre) un toto et renvoie un toto.

TYPES DE DONNEES :

  • type_ : dénotation de type effectif, implémente l'équivalence des types, construit à partir d'une type_exp.
  • const : dénotation de constante effective, construit à partir d'une val_exp => IL S'AGIT DE LA REPRESENTATION INTERNE DES CONSTANTES STATIQUES
  • var_info : déclaration de variable, construit à partir de var_info.
  • val : union entre const et var_info.
  • slice_info : dénotation de tranche de tableau, construit à partir de slice_info.
  • left : version compilée de left_part
  • eq_info : version compilée de eq_info
  • node_exp : dénotation d'opération, peut être predef ou utilisateur, construit à partir de node_exp.
  • static_arg : déclaration d'un static arg
  • pack_env : la "grosse" structure de données qui gère la compilation des packages => implémentée dans CheckGlobal pour la partie type/const/function (initialisation) et dans CheckNode pour la partie node/template qui est faite à la demande.

UTILITAIRES :

  • type_of_const : renvoie le type d'une const
  • string_of_type : pretty-print d'un type
  • string_of_const : pretty-print d'une const
  • string_of_node_key : pretty-print d'un node_key _ string_of_slice :

----------------------------------------------------------------------

val _dbg : Lv6Verbose.flag
type type_ =
  1. | Bool_type_eff
  2. | Int_type_eff
  3. | Real_type_eff
  4. | External_type_eff of Lv6Id.long
  5. | Abstract_type_eff of Lv6Id.long * type_
  6. | Enum_type_eff of Lv6Id.long * Lv6Id.long list
  7. | Array_type_eff of type_ * int
  8. | Struct_type_eff of Lv6Id.long * (Lv6Id.t * (type_ * const option)) list
  9. | TypeVar of type_var
and type_var =
  1. | Any
  2. | AnyNum
and node_profile = (Lv6Id.t * type_) list * (Lv6Id.t * type_) list
and profile = type_ list * type_ list
and slice_info = {
  1. se_first : int;
  2. se_last : int;
  3. se_step : int;
  4. se_width : int;
}
and left =
  1. | LeftVarLic of var_info * Lxm.t
  2. | LeftFieldLic of left * Lv6Id.t * type_
  3. | LeftArrayLic of left * int * type_
  4. | LeftSliceLic of left * slice_info * type_
and eq_info = left list * val_exp
and val_exp = {
  1. ve_core : val_exp_core;
  2. ve_typ : type_ list;
  3. ve_clk : clock list;
  4. ve_src : Lxm.t;
}
and val_exp_core =
  1. | CallByPosLic of by_pos_op Lxm.srcflagged * val_exp list
  2. | CallByNameLic of by_name_op Lxm.srcflagged * (Lv6Id.t Lxm.srcflagged * val_exp) list
  3. | Merge of val_exp * (const Lxm.srcflagged * val_exp) list
and by_name_op =
  1. | STRUCT of Lv6Id.long
  2. | STRUCT_with of Lv6Id.long * Lv6Id.t
  3. | STRUCT_anonymous
and by_pos_op =
  1. | PREDEF_CALL of node_key Lxm.srcflagged
  2. | CALL of node_key Lxm.srcflagged
  3. | CONST_REF of Lv6Id.long
  4. | CONST of const
  5. | VAR_REF of Lv6Id.t
  6. | PRE
  7. | ARROW
  8. | FBY
  9. | CURRENT of Lv6Id.long option
  10. | WHEN of clock
  11. | TUPLE
  12. | CONCAT
  13. | HAT of int
  14. | ARRAY
  15. | STRUCT_ACCESS of Lv6Id.t
  16. | ARRAY_ACCES of int
  17. | ARRAY_SLICE of slice_info
and const =
  1. | Bool_const_eff of bool
  2. | Int_const_eff of string
  3. | Real_const_eff of string
  4. | Extern_const_eff of Lv6Id.long * type_
  5. | Abstract_const_eff of Lv6Id.long * type_ * const * bool
  6. | Enum_const_eff of Lv6Id.long * type_
  7. | Struct_const_eff of (Lv6Id.t * const) list * type_
  8. | Array_const_eff of const list * type_
  9. | Tuple_const_eff of const list
and var_info = {
  1. var_name_eff : Lv6Id.t;
  2. var_nature_eff : AstCore.var_nature;
  3. var_number_eff : int;
  4. var_type_eff : type_;
  5. var_clock_eff : id_clock;
}
and id_clock = Lv6Id.t * clock
and clock =
  1. | BaseLic
  2. | ClockVar of int
  3. | On of Lv6Id.long * Lv6Id.t * type_ * clock
and node_exp = {
  1. node_key_eff : node_key;
  2. inlist_eff : var_info list;
  3. outlist_eff : var_info list;
  4. loclist_eff : var_info list option;
  5. def_eff : node_def;
  6. has_mem_eff : bool;
  7. is_safe_eff : bool;
  8. lxm : Lxm.t;
}

node_exp correspond à une instance de template (ou, cas limite, de noeud sans param statique).

La clé est un couple ident/liste d'arguments statiques effectifs

N.B. une horloge formelle est soit None (base) soit l'index d'une entrée (0..nb entrées-1). Les formal-clocks sont créées au cours du type-checking (et pas du clock-checking)

and type_matches = (type_var * type_) list
and node_def =
  1. | ExternLic
  2. | MetaOpLic
  3. | AbstractLic of node_exp option
  4. | BodyLic of node_body
and node_body = {
  1. asserts_eff : val_exp Lxm.srcflagged list;
  2. eqs_eff : eq_info Lxm.srcflagged list;
}
and item_key = Lv6Id.long
and node_key = item_key * static_arg list
and static_arg =
  1. | ConstStaticArgLic of Lv6Id.t * const
  2. | TypeStaticArgLic of Lv6Id.t * type_
  3. | NodeStaticArgLic of Lv6Id.t * node_key
and sarg_node_eff = node_key * var_info list * var_info list
val compare_var_info : var_info -> var_info -> int
type 'a check_flag =
  1. | Checking
  2. | Checked of 'a
  3. | Incorrect

Type check_flag

Au cours du check, on conserve le statut des idents :

  • Checking => en cours de traitement, permet de lever les récursions
  • Checked => traité et correct
  • Incorrect => déjà marqué comme incorrect (pas besoin d'un nouveau message d'erreur)
val profile_of_node_exp : node_exp -> profile
val type_are_compatible : type_ -> type_ -> bool

type_are_compatible t1 t2 checks that t1 is compatible with t2, i.e., if t1 = t2 or t1 is abstract and not t2.

val is_extern_type : type_ -> bool
val clock_are_equals : clock -> clock -> bool
val var_are_compatible : var_info -> var_info -> bool
val ident_of_type : type_ -> Lv6Id.long
val node_key_of_idref : Lv6Id.idref -> node_key
val node_key_of_ident : string -> node_key
val subst_type : type_ -> type_ -> type_
val subst_matches : type_matches -> type_ -> type_
val apply_type_matches : type_matches -> type_ list -> type_ list
val type_is_poly : type_ -> bool
val node_is_poly : node_exp -> bool
val node_is_extern : node_exp -> bool
val is_extern_const : const -> bool
val val_exp_is_constant : val_exp -> bool
val type_of_val_exp : val_exp -> type_ list
val lxm_of_val_exp : val_exp -> Lxm.t
val min_lxm : Lxm.t -> Lxm.t -> Lxm.t
val max_lxm : Lxm.t -> Lxm.t -> Lxm.t
val type_of_const : const -> type_
val types_of_const : const -> type_ list
val true_type_of_const : const -> type_
val type_of_left : left -> type_
val lxm_of_left : left -> Lxm.t
val var_info_of_left : left -> var_info
val clock_of_left : left -> clock
val string_of_ident : Lv6Id.long -> string
val string_of_type : type_ -> string
val string_of_type_list : type_ list -> string
val string_of_type_profile : (type_ list * type_ list) -> string
val string_of_clock : clock -> string
val enum_to_string : Lv6Id.long -> Lv6Id.long list -> string
val string_of_const : const -> string
val string_of_var_info : var_info -> string
val string_of_var_list : var_info list -> string
val string_of_node_key : node_key -> string
val string_of_static_arg : static_arg -> string
val string_of_type_var : type_var -> string
val string_of_type_matches : (type_var * type_) list -> string
val string_of_node_exp : node_exp -> string
val create_var_list : AstCore.var_nature -> type_ list -> var_info list
val create_var : AstCore.var_nature -> type_ -> Lv6Id.t -> var_info
exception Compile_node_error of node_key * Lxm.t * string
exception Global_node_error of node_key * string
module TopoSortVarInfo : sig ... end
val sort_var_info : var_info list -> var_info list