123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219(* Time-stamp: <modified the 29/08/2019 (at 14:41) by Erwan Jahier> *)(** (Raw) Abstract syntax tree of source Lustre Core programs. *)openLxm(**********************************************************************************)typeclock_exp=|Base|NamedClockofLv6Id.clksrcflagged(**********************************************************************************)(** [type_exp] is used to type flow, parameters, constants. *)typetype_exp=type_exp_coresrcflaggedandtype_exp_core=|Bool_type_exp|Int_type_exp|Real_type_exp|Named_type_expofLv6Id.idref|Array_type_expof(type_exp*val_exp)andnode_info={name:Lv6Id.t;static_params:static_paramsrcflaggedlist;vars:node_varsoption;(* aliased node may have no i/o decl *)(* consts : ICI A FAIRE *)loc_consts:(Lxm.t*const_info)list;def:node_def;has_mem:bool;is_safe:bool;(* safe <=> no side-effect are performed *)}andstatic_param=|StaticParamTypeofLv6Id.t|StaticParamConstofLv6Id.t*type_exp|StaticParamNodeof(Lv6Id.t*var_infosrcflaggedlist*var_infosrcflaggedlist*has_mem_flag*is_safe_flag)andnode_vars={inlist:Lv6Id.tlist;outlist:Lv6Id.tlist;loclist:Lv6Id.tlistoption;(* abstract/ext node have no body *)vartable:var_info_table;}andvar_info_table=(Lv6Id.t,var_infosrcflagged)Hashtbl.tandvar_info={var_nature:var_nature;var_name:Lv6Id.t;var_number:int;var_type:type_exp;var_clock:clock_exp}andvar_nature=|VarInput|VarOutput|VarLocalandnode_def=|Extern|Abstract|Bodyofnode_body|Aliasofby_pos_opsrcflaggedandnode_body={asserts:(val_expsrcflagged)list;eqs:(eq_infosrcflagged)list;}andhas_mem_flag=boolandis_safe_flag=boolandeq_info=(left_partlist*val_exp)andleft_part=|LeftVarof(Lv6Id.tsrcflagged)|LeftFieldof(left_part*(Lv6Id.tsrcflagged))|LeftArrayof(left_part*(val_expsrcflagged))|LeftSliceof(left_part*(slice_infosrcflagged))andslice_info={si_first:val_exp;si_last:val_exp;si_step:val_expoption;}andby_pos_op=(* zeroaire *)|Predef_nofAstPredef.opsrcflagged|CALL_nofnode_expsrcflagged(* e.g., a_node<<xx>> *)|IDENT_nofLv6Id.idref(* constant or variable *)|PRE_n|ARROW_n|FBY_n|CURRENT_n|WHEN_nofclock_exp|TUPLE_n|WITH_nofval_exp*val_exp*val_exp|CONCAT_n|HAT_n|ARRAY_n|STRUCT_ACCESS_nofLv6Id.t|ARRAY_ACCES_nofval_exp|ARRAY_SLICE_nofslice_info(************************************************)(* Info associées aux expressions *)(************************************************)(* Vision "fonctionnelle" des val_exp : *)(* Une exp. est une application d'operation : *)(* - avec passage par position, auquel cas les *)(* opérandes sont des val_exp *)(* - avec passage par nom, auquel cas les *)(* opérandes sont des Lv6Id.t * val_exp *)(************************************************)(* and val_exp = by_pos_op srcflagged * operands *)andval_exp=|CallByPosof(by_pos_opsrcflagged*operands)|CallByNameof(by_name_opsrcflagged*(Lv6Id.tsrcflagged*val_exp)list)|Merge_nofval_expsrcflagged*(Lv6Id.idrefsrcflagged*val_exp)list|Merge_bool_nofval_expsrcflagged*val_exp*val_expandoperands=Operofval_explist(* Virer cet Oper ? Non, sinon ca boucle... *)andby_name_op=|STRUCT_nofLv6Id.idref|STRUCT_WITH_nofLv6Id.idref*Lv6Id.idref|STRUCT_anonymous_n(* for backward compatibility with lv4 *)andnode_exp=(Lv6Id.idref*(static_argsrcflaggedlist))(** Params statiques effectifs :
- val_exp (pour les constantes)
- type_exp (pour les types)
- node_exp (pour les node)
- ident : a résoudre, peut etre const, type ou node
*)andstatic_arg=|StaticArgLv6IdofLv6Id.idref|StaticArgConstofval_exp|StaticArgTypeoftype_exp|StaticArgNodeofby_pos_op(* | StaticArgFunc of node_exp *)(**********************************************************************************)(** constant *)andconst_info=|ExternalConstof(Lv6Id.t*type_exp*val_expoption)|EnumConstof(Lv6Id.t*type_exp)|DefinedConstof(Lv6Id.t*type_expoption*val_exp)(** Type *)typefield_info={fd_name:Lv6Id.t;fd_type:type_exp;fd_value:val_expoption}typestruct_type_info={st_name:Lv6Id.t;st_flist:Lv6Id.tlist;(* field name list *)st_ftable:(Lv6Id.t,field_infosrcflagged)Hashtbl.t}typetype_info=|ExternalTypeof(Lv6Id.t)|AliasedTypeof(Lv6Id.t*type_exp)|EnumTypeof(Lv6Id.t*Lv6Id.tsrcflaggedlist)|StructTypeofstruct_type_info|ArrayTypeof(Lv6Id.t*type_exp*val_exp)(** Operator *)typeitem_ident=|ConstItemofLv6Id.t|TypeItemofLv6Id.t|NodeItemofLv6Id.t*static_paramsrcflaggedlisttypeitem_info=ConstInfoofconst_info|TypeInfooftype_info|NodeInfoofnode_info(* to be used for error msgs only...*)letrecstring_of_type_expx=matchx.itwith|Bool_type_exp->"bool"|Int_type_exp->"int"|Real_type_exp->"real"|Named_type_expid->(Lv6Id.string_of_idreffalseid)|Array_type_exp(te,_sz)->(string_of_type_expte)^"^ ..."letstring_of_var_nature=function|VarInput->"input"|VarOutput->"output"|VarLocal->"local"letlxm_of_val_exp=function|CallByPos(op,_)->op.src|CallByName(op,_)->op.src|Merge_n(ve,_)->ve.src|Merge_bool_n(id,_,_)->id.src