Project

General

Profile

Revision 3769b712 src/expand.ml

View differences:

src/expand.ml
9 9
(*                                                                  *)
10 10
(********************************************************************)
11 11

  
12
open Clocks
13
open Corelang
12
open Lustrec.Clocks
13
open Lustrec.Corelang
14 14

  
15 15
(* Applies variable substitutions *)
16 16
let subst_var var_substs vid =
......
56 56
   "instance" of expressions [e] of expression [e], where [edesc] is the
57 57
   expanded version of [e]. *)
58 58
let new_expr_instance ck_substs var_substs e edesc =
59
  {expr_tag = Utils.new_tag ();
59
  {expr_tag = Lustrec.Utils.new_tag ();
60 60
   expr_desc = edesc;
61 61
   expr_type = e.expr_type;
62 62
   expr_clock = subst_ck ck_substs var_substs e.expr_clock;
63
   expr_delay = Delay.new_var ();
63
   expr_delay = Lustrec.Delay.new_var ();
64 64
   expr_loc = e.expr_loc;
65 65
   expr_annot = e.expr_annot}
66 66
  
......
83 83

  
84 84
(* Returns an expression correponding to variable v *)
85 85
let expr_of_var v =
86
  {expr_tag = Utils.new_tag ();
86
  {expr_tag = Lustrec.Utils.new_tag ();
87 87
   expr_desc = Expr_ident v.var_id;
88 88
   expr_type = v.var_type;
89 89
   expr_clock = v.var_clock;
90
   expr_delay = Delay.new_var ();
90
   expr_delay = Lustrec.Delay.new_var ();
91 91
   expr_loc = v.var_loc;
92 92
   expr_annot = None}
93 93

  
......
96 96
let build_ck_substs ck for_ck =
97 97
  let substs = Hashtbl.create 10 in
98 98
  let rec aux ck for_ck =
99
    let ck, for_ck = Clocks.repr ck, Clocks.repr for_ck in
100
    match ck.Clocks.cdesc, for_ck.Clocks.cdesc with
101
    | Clocks.Ctuple cklist1, Clocks.Ctuple cklist2 ->
99
    let ck, for_ck = Lustrec.Clocks.repr ck, Lustrec.Clocks.repr for_ck in
100
    match ck.Lustrec.Clocks.cdesc, for_ck.Lustrec.Clocks.cdesc with
101
    | Lustrec.Clocks.Ctuple cklist1, Lustrec.Clocks.Ctuple cklist2 ->
102 102
        List.iter2 aux cklist1 cklist2
103
    | _, Clocks.Cunivar _ ->
103
    | _, Lustrec.Clocks.Cunivar _ ->
104 104
        Hashtbl.add substs for_ck ck
105 105
    | _,_ ->
106 106
        ()
......
123 123
    expand_expr parent_ck_substs parent_vsubsts args in
124 124
  (* Compute clock substitutions to apply inside node's body *)
125 125
  let ck_ins = args'.expr_clock in
126
  let for_ck_ins,_ = Clocks.split_arrow nd.node_clock in
126
  let for_ck_ins,_ = Lustrec.Clocks.split_arrow nd.node_clock in
127 127
  let ck_substs = build_ck_substs ck_ins for_ck_ins in
128 128
  (* Compute variable substitutions to apply inside node's body, due
129 129
     to the transformation of node variables into local variables of the
......
271 271
   node_annot = nd.node_annot}
272 272

  
273 273
let expand_program () =
274
  if !Options.main_node = "" then
275
    raise (Corelang.Error No_main_specified);
274
  if !Lustrec.Options.main_node = "" then
275
    raise (Lustrec.Corelang.Error No_main_specified);
276 276
  let main =
277 277
    try
278
      Hashtbl.find node_table !Options.main_node
278
      Hashtbl.find node_table !Lustrec.Options.main_node
279 279
    with Not_found ->
280
      raise (Corelang.Error Main_not_found)
280
      raise (Lustrec.Corelang.Error Main_not_found)
281 281
  in
282 282
  match main.top_decl_desc with
283 283
  | Include _ | Consts _ | ImportedNode _ | SensorDecl _ | ActuatorDecl _ ->
284
      raise (Corelang.Error Main_wrong_kind)
284
      raise (Lustrec.Corelang.Error Main_wrong_kind)
285 285
  | Node nd ->
286 286
      expand_node nd
287 287

  

Also available in: Unified diff