Project

General

Profile

Revision 70be4acf

View differences:

src/corelang.ml
1239 1239
  }
1240 1240
  in aux ()
1241 1241

  
1242
       
1243
let get_node name prog =
1244
  let node_opt = List.fold_left
1245
    (fun res top -> 
1246
      match res, top.top_decl_desc with
1247
      | Some _, _ -> res
1248
      | None, Node nd -> 
1249
	(* Format.eprintf "Checking node %s = %s: %b@." nd.node_id name (nd.node_id = name); *)
1250
	if nd.node_id = name then Some nd else res
1251
      | _ -> None) 
1252
    None prog 
1253
  in
1254
  try 
1255
    Utils.desome node_opt
1256
  with Utils.DeSome -> raise Not_found
1257

  
1242 1258
(* Local Variables: *)
1243 1259
(* compile-command:"make -C .." *)
1244 1260
(* End: *)
src/corelang.mli
132 132
val get_dependencies : program -> top_decl list
133 133
(* val prog_unfold_consts: program -> program *)
134 134

  
135
(** Returns the node named ident in the provided program. Raise Not_found *)
136
val get_node : ident -> program -> node_desc
137

  
138
  
135 139
val rename_static: (ident -> Dimension.dim_expr) -> type_dec_desc -> type_dec_desc
136 140
val rename_carrier: (ident -> ident) -> clock_dec_desc -> clock_dec_desc
137 141

  
src/machine_code.ml
372 372
    ) nodes
373 373

  
374 374

  
375

  
375 376
(* Local Variables: *)
376 377
(* compile-command:"make -C .." *)
377 378
(* End: *)
src/machine_code.mli
1 1
val translate_prog: Lustre_types.program -> Scheduling.schedule_report Utils.IMap.t  -> Machine_code_types.machine_t list
2

  
src/machine_code_common.ml
5 5
let print_statelocaltag = true
6 6

  
7 7
let is_memory m id =
8
  List.exists (fun o -> o.var_id = id.var_id) m.mmemory
8
  (List.exists (fun o -> o.var_id = id.var_id) m.mmemory) 
9 9

  
10 10
let rec pp_val m fmt v =
11 11
  let pp_val = pp_val m in
......
235 235
      | None -> if m.mname.node_id = name then Some m else None)
236 236
    None machines
237 237

  
238
    
239
let get_machine name machines =
240
  try
241
    Utils.desome (get_machine_opt name machines) 
242
  with Utils.DeSome -> raise Not_found
243
  
238 244
let get_const_assign m id =
239 245
  try
240 246
    match get_instr_desc (List.find
src/machine_code_common.mli
15 15
val pp_instrs: Machine_code_types.machine_t -> Format.formatter -> Machine_code_types.instr_t list -> unit
16 16
val pp_machines: Format.formatter -> Machine_code_types.machine_t list -> unit
17 17
val get_machine_opt: string -> Machine_code_types.machine_t list -> Machine_code_types.machine_t option
18

  
19
(** Return the machine of node ident. Raise Not_found *)
20
val get_machine: Lustre_types.ident -> Machine_code_types.machine_t list -> Machine_code_types.machine_t 
21

  
18 22
val get_node_def: string -> Machine_code_types.machine_t -> Lustre_types.node_desc
19 23
val join_guards_list: Machine_code_types.instr_t list -> Machine_code_types.instr_t list
src/plugins.ml
11 11
	(M.name, M.activate, M.options)
12 12
      ) plugins
13 13
    ))
14

  
14
  
15 15
let check_force_stateful () =
16 16
  List.exists (fun m ->
17 17
	let module M = (val m : PluginType.PluginType) in
src/plugins/scopes/scopes.ml
6 6
(* (variable, node name, node instance) *)
7 7
type scope_t = (var_decl * string * string option) list * var_decl
8 8

  
9

  
9
(* Scope to string list *)
10 10
let scope_to_sl ((sl, v) : scope_t) : string list=
11 11
  List.fold_right (
12 12
    fun (v, nodename, _) accu -> 
13 13
      v.var_id :: nodename :: accu
14 14
  ) sl [v.var_id]
15 15

  
16
let get_node name prog =
17
  let node_opt = List.fold_left
18
    (fun res top -> 
19
      match res, top.top_decl_desc with
20
      | Some _, _ -> res
21
      | None, Node nd -> 
22
	(* Format.eprintf "Checking node %s = %s: %b@." nd.node_id name (nd.node_id = name); *)
23
	if nd.node_id = name then Some nd else res
24
      | _ -> None) 
25
    None prog 
26
  in
27
  try 
28
    Utils.desome node_opt
29
  with Utils.DeSome -> raise Not_found
30

  
31
let get_machine name machines =
32
  try
33
    List.find (fun m -> m.mname.node_id = name) machines
34
  with Not_found -> raise Not_found
35

  
36 16

  
37 17
let rec compute_scopes ?(first=true) prog root_node : scope_t list =
38 18
  let compute_scopes = compute_scopes ~first:false in
......
93 73
    Format.eprintf "Cannot find variable %s in node %s@." name node.node_id;
94 74
    assert false
95 75

  
96
let scope_path main_node_name prog machines all_scopes sl : scope_t =
97
  let rec get_path node id_list accu =
98
    match id_list, accu with
99
    | [id], (_, last_node, _)::_ -> (* last item, it should denote a local
76
let rec get_path prog machines node id_list accu =
77
  let get_path = get_path prog machines in
78
  match id_list, accu with
79
  | [flow], [] ->  (* Special treatment of first level flow: node is here main_node *)
80
     let flow_var = get_node_vdecl_of_name flow node in
81
     [], flow_var, node.node_id
82
  | [id], (_, last_node, _)::_ -> (* last item, it should denote a local
100 83
				       memory variable (local var, memory or input *)
101
      let id_vdecl = 
102
	get_node_vdecl_of_name id (get_node last_node prog) 
103
      in
104
      List.rev accu, id_vdecl
105
    | varid::nodename::id_list_tl, _ -> (
106
      let e_machine = get_machine node.node_id machines in 
107
      (* Format.eprintf "Looking for def %s in call %s in machine %a@."  *)
108
      (* 	varid nodename *)
109
      (* 	Machine_code.pp_machine e_machine; *)
110
      let find_var = (fun v -> v.var_id = varid) in
111
      let instance = 
112
	List.find 
113
	  (fun i -> match get_instr_desc i with 
114
	  | MStep(p, o, _) -> List.exists find_var p 
115
	  | _ -> false
116
	  ) 
117
	  e_machine.mstep.step_instrs 
84
     let id_vdecl = 
85
       get_node_vdecl_of_name id (get_node last_node prog) 
86
     in
87
     List.rev accu, id_vdecl, last_node
88
  | varid::nodename::id_list_tl, _ -> (
89
    let e_machine = get_machine node.node_id machines in 
90
    (* Format.eprintf "Looking for def %s in call %s in machine %a@."  *)
91
    (* 	varid nodename *)
92
    (* 	Machine_code.pp_machine e_machine; *)
93
    let find_var = (fun v -> v.var_id = varid) in
94
    let instance = 
95
      List.find 
96
	(fun i -> match get_instr_desc i with 
97
	          | MStep(p, o, _) -> List.exists find_var p 
98
	          | _ -> false
99
	) 
100
	e_machine.mstep.step_instrs 
101
    in
102
    try
103
      let variable, instance_node, instance_id = 
104
	match get_instr_desc instance with 
105
	| MStep(p, o, _) -> 
106
	   (* Format.eprintf "Looking for machine %s@.@?" o; *)
107
	   let o_fun, _ = List.assoc o e_machine.mcalls in
108
	   if node_name o_fun = nodename then
109
	     List.hd p, o_fun, o 
110
	   else 
111
	     assert false
112
	| _ -> assert false
118 113
      in
119
      try
120
	let variable, instance_node, instance_id = 
121
	  match get_instr_desc instance with 
122
	  | MStep(p, o, _) -> 
123
	    (* Format.eprintf "Looking for machine %s@.@?" o; *)
124
	    let o_fun, _ = List.assoc o e_machine.mcalls in
125
	    if node_name o_fun = nodename then
126
	      List.hd p, o_fun, o 
127
	    else 
128
	      assert false
129
	  | _ -> assert false
130
	in
131
	let next_node = node_of_top instance_node in
132
	let accu = (variable, nodename, Some instance_id)::accu in
133
	(* Format.eprintf "Calling get path on %s@.@?" next_node.node_id; *)
134
	get_path next_node id_list_tl accu
135
      with Not_found -> Format.eprintf "toto@."; assert false
136
    )
137
    | _ -> assert false
138
  in
114
      let next_node = node_of_top instance_node in
115
      let accu = (variable, nodename, Some instance_id)::accu in
116
      (* Format.eprintf "Calling get path on %s@.@?" next_node.node_id; *)
117
      get_path next_node id_list_tl accu
118
    with Not_found -> Format.eprintf "toto@."; assert false
119
  )
120
  | _ -> assert false
121

  
122
    
123
let check_scope all_scopes  =
139 124
  let all_scopes_as_sl = List.map scope_to_sl all_scopes in
125
  fun prog machines main_node_name sl ->
140 126
  if not (List.mem sl all_scopes_as_sl) then (
141 127
    Format.eprintf "%s is an invalid scope.@." (String.concat "." sl);
142 128
    exit 1
......
144 130
  else (
145 131
    (* Format.eprintf "@.@.Required path: %s@." (String.concat "." sl) ;  *)
146 132
    let main_node = get_node main_node_name prog in
147
    let path, flow = (* Special treatment of first level flow *)
148
      match sl with 
149
      | [flow] -> let flow_var = get_node_vdecl_of_name flow main_node in
150
		  [], flow_var 
151
      | _ -> get_path main_node sl [] 
152
	
153
    in
133
    let path, flow, mid = get_path prog machines main_node sl [] in
154 134
    (* Format.eprintf "computed path: %a.%s@." print_path path flow.var_id; *)
155
    path, flow
156

  
135
    path, flow, mid
157 136
  )
158 137

  
159
let check_scopes main_node_name prog machines all_scopes scopes =
160
  List.map
161
    (fun sl ->
162
      sl, scope_path main_node_name prog machines all_scopes sl 
163
    ) scopes
164

  
165
let scopes_def : string list list ref = ref []
166
let inputs = ref []
167

  
168
let option_show_scopes = ref false
169
let option_scopes = ref false
170
let option_all_scopes = ref false
171
(* let option_mems_scopes = ref false 
172
 * let option_input_scopes = ref false *)
173 138

  
174
let scopes_map : (Lustre_types.ident list  * scope_t) list ref  = ref []
139
                                                                
140
(* Build the two maps 
141
   - (scope_name, variable)
142
   - (machine_name, list of selected variables)
143
 *)
144
let check_scopes main_node_name prog machines all_scopes scopes =
145
  let check_scope = check_scope all_scopes prog machines in
146
  List.fold_left
147
    (fun (accu_sl, accu_m) sl ->
148
      let path, flow, mid = check_scope main_node_name sl in
149
      let accu_sl = (sl, (path, flow))::accu_sl in
150
      let accu_m =
151
        let flow_id = flow.var_id in
152
        if List.mem_assoc mid accu_m then
153
          (mid, flow_id::(List.assoc mid accu_m)) :: 
154
            (List.remove_assoc mid accu_m)
155
        else
156
          (mid, [flow_id])::accu_m
157
      in
158
      accu_sl, accu_m
159
    ) ([], []) scopes
160
  
161
  
175 162

  
176
let register_scopes s = 
177
  option_scopes := true;
178
  option_all_scopes:=false; 
179
  let scope_list = Str.split (Str.regexp ", *") s in
180
  let scope_list = List.map (fun scope -> Str.split (Str.regexp "\\.") scope) scope_list in
181
  scopes_def := scope_list
182 163

  
183
let register_inputs s = 
184
  option_scopes := true;
185
  let input_list = Str.split (Str.regexp "[;]") s in
186
  let input_list = List.map (fun s -> match Str.split (Str.regexp "=") s with | [v;e] -> v, e | _ -> raise (Invalid_argument ("Input list error: " ^ s))) input_list in
187
  let input_list = List.map (fun (v, e) -> v, Str.split (Str.regexp "[;]") e) input_list in
188
  inputs := input_list
164
let scope_var_name vid =  vid ^ "__scope"
189 165

  
166
(**********************************************************************)
167
(* The following three functions are used in the main function to print
168
   the value of the new memories, storing scopes values               *)
169
(**********************************************************************)
190 170

  
191 171
(* TODO: recuperer le type de "flow" et appeler le print correspondant 
192 172
   iterer sur path pour construire la suite des xx_mem._reg.yy_mem._reg......flow
193 173
par ex main_mem->n8->n9->_reg.flow
194 174
*)
195 175
let extract_scopes_defs scopes =
196
  let rec scope_path (path, flow) accu = 
176
  let rec scope_path_name (path, flow) accu = 
197 177
    match path with 
198
    | [] -> accu ^ "_reg." ^ flow.var_id, flow.var_type
199
    | (_, _, Some instance_id)::tl -> scope_path (tl, flow) ( accu ^ instance_id ^ "->" ) 
178
    | [] -> accu ^ "_reg." ^ (scope_var_name flow.var_id), flow.var_type
179
    | (_, _, Some instance_id)::tl -> scope_path_name (tl, flow) ( accu ^ instance_id ^ "->" ) 
200 180
    | _ -> assert false
201 181
  in
202 182
  let scopes_vars = 
203 183
    List.map 
204 184
      (fun (sl, scope) -> 
205
	String.concat "." sl, scope_path scope "main_mem.") 
185
	String.concat "." sl, scope_path_name scope "main_mem.") 
206 186
      scopes 
207 187
  in
208 188
  scopes_vars
209

  
189
  
210 190
let pp_scopes_files basename mname fmt scopes =
211 191
  let scopes_vars = extract_scopes_defs scopes in
212 192
  List.iteri (fun idx _ (* (id, (var, typ)) *) ->
213
    Format.fprintf fmt "FILE *f_out_scopes_%i;@ " (idx+1); (* we start from 1: in1, in2, ... *)
214
    Format.fprintf fmt "f_out_scopes_%i = fopen(\"%s_%s_simu.scope%i\", \"w\");@ " (idx+1) basename mname (idx+1);
193
      Format.fprintf fmt "FILE *f_out_scopes_%i;@ " (idx+1);
194
      (* we start from 1: in1, in2, ... *)
195
    Format.fprintf fmt
196
      "f_out_scopes_%i = fopen(\"%s_%s_simu.scope%i\", \"w\");@ "
197
      (idx+1) basename mname (idx+1);
215 198
  ) scopes_vars
216 199

  
217 200
  
......
219 202
  let scopes_vars = extract_scopes_defs scopes in
220 203
  List.iteri (fun idx (id, (var, typ)) ->
221 204
    Format.fprintf fmt "@ %t;" 
222
      (fun fmt -> C_backend_common.print_put_var fmt ("_scopes_" ^ string_of_int (idx+1)) id (*var*) typ var)
205
      (fun fmt -> C_backend_common.print_put_var fmt
206
                    ("_scopes_" ^ string_of_int (idx+1))
207
                    id (*var*) typ var)
223 208
  ) scopes_vars
224 209

  
225
let update_machine main_node machine =
226
  let stateassign vdecl =
210
(**********************************************************************)
211
                        
212
let update_machine main_node machine scopes =
213
  let stateassign (vdecl_mem, vdecl_orig) =
227 214
    mkinstr 
228
    (MStateAssign (vdecl, mk_val (Var vdecl) vdecl.var_type))
215
    (MStateAssign (vdecl_mem, mk_val (Var vdecl_orig) vdecl_orig.var_type))
229 216
  in
230
  let local_decls =
217
  let selection =
231 218
    (* We only register inputs for non root node *)
232 219
    (if machine.mname.node_id = main_node then
233 220
      []
......
235 222
      machine.mstep.step_inputs
236 223
    )
237 224
    (* @ machine.mstep.step_outputs   *)
225
    @ machine.mmemory 
238 226
    @ machine.mstep.step_locals
239 227
  in
228
  let selection = List.filter (fun v -> List.exists (fun vid -> vid = v.var_id) scopes) selection in
229
  let new_mems = List.map (fun v ->
230
                     (* We could copy the variable but then we need to update its type 
231
                        let new_v = copy_var_decl v in
232
                      *)
233
                     let new_v = { v with var_id = scope_var_name v.var_id }  in
234
                     new_v, v
235
                   ) selection
236
  in
240 237
  { machine with
241
    mmemory = machine.mmemory @ local_decls;
238
    mmemory = machine.mmemory @ (List.map fst new_mems);
242 239
    mstep = { 
243 240
      machine.mstep with 
244 241
        step_instrs = machine.mstep.step_instrs
245
        @ (mkinstr (MComment "Registering all flows"))::(List.map stateassign local_decls)
242
        @ (mkinstr (MComment "Registering all flows"))::(List.map stateassign new_mems)
246 243
          
247 244
    }
248 245
  }
249 246
    
247
let rec is_valid_path path nodename prog machines =
248
  let nodescopes = compute_scopes prog nodename in
249
  let m = get_machine nodename machines in
250
  match path with
251
  | [] -> assert false
252
  | [vid] -> let res = List.exists (fun v -> v.var_id = vid) (m.mmemory @ m.mstep.step_inputs @ m.mstep.step_locals) in
253
	     (* if not res then  *)
254
	     (* 	 Format.eprintf "Variable %s cannot be found in machine %s@.Local vars are %a@." vid m.mname.node_id *)
255
	     (* 	   (Utils.fprintf_list ~sep:", " Printers.pp_var) (m.mmemory @ m.mstep.step_inputs @ m.mstep.step_locals) *)
256
	     (* ; *)
257
	     res
258
	     
259
  | inst::nodename::path' -> (* We use the scopes computed on the prog artifact *)
260
     (* Format.eprintf "Path is %a@ Local scopes: @[<v>%a@ @]@."  *)
261
     (* 	(Utils.fprintf_list ~sep:"." Format.pp_print_string) path *)
262
     (* 	(Utils.fprintf_list ~sep:";@ " *)
263
     (* 	   (fun fmt scope ->  *)
264
     (* 	     Utils.fprintf_list ~sep:"." Format.pp_print_string fmt (scope_to_sl scope)) *)
265
     (* 	)  *)
266
     (* 	nodescopes; *)
267
     if List.mem path (List.map scope_to_sl nodescopes) then (
268
       (* Format.eprintf "Valid local path, checking underneath@."; *)
269
       is_valid_path path' nodename prog machines
270
     )
271
     else
272
       false
273

  
274
      (* let instok = List.exists (fun (inst', node) -> inst' = inst) m.minstances in *)
275
      (* if not instok then Format.eprintf "inst = %s@." inst; *)
276
      (* instok &&  *)
277
      (* let instnode = fst (snd (List.find (fun (inst', node) -> inst' = inst) m.minstances)) in *)
278
      (* is_valid_path path' (Corelang.node_of_top instnode).node_id prog machines *)
279

  
280

  
281

  
282
(****************************************************)
283
      
284
let scopes_def : string list list ref = ref []
285
let inputs = ref []
286

  
287
let option_show_scopes = ref false
288
let option_scopes = ref false
289
let option_all_scopes = ref false
290
(* let option_mems_scopes = ref false 
291
 * let option_input_scopes = ref false *)
292

  
293
let scopes_map : (Lustre_types.ident list  * scope_t) list ref  = ref []
294
      
295
let process_scopes main_node prog machines =
296
  let all_scopes = compute_scopes prog !Options.main_node in
297
  let selected_scopes = if !option_all_scopes then
298
	                  List.map (fun s -> scope_to_sl s) all_scopes
299
                        else
300
	                  !scopes_def
301
  in
302
  (* Making sure all scopes are defined and were not removed by various
303
       optmizationq *)
304
  let selected_scopes = 
305
    List.filter 
306
      (fun sl -> 
307
	let res = is_valid_path sl main_node prog machines in
308
	if not res then
309
	  Format.eprintf "Scope %a is cancelled due to variable removal@." (Utils.fprintf_list ~sep:"." Format.pp_print_string) sl; 
310
	res
311
      ) 
312
      selected_scopes 
313
  in
314
  let scopes_map', machines_scopes = check_scopes main_node prog machines all_scopes selected_scopes in
315
  scopes_map := scopes_map';
316
  (* Each machine is updated with fresh memories and declared as stateful  *)
317
  let machines = List.map (fun m ->
318
                     let mid = m.mname.node_id in
319
                     if List.mem_assoc mid machines_scopes then
320
                       let machine_scopes = List.assoc mid machines_scopes in
321
                       update_machine main_node m machine_scopes
322
                     else
323
                       m) machines in
324
  machines
325

  
326
let activate () = 
327
  option_scopes := true;
328
  Options.optimization := 0; (* no optimization *)
329
  ()
330
  
331
let register_scopes s = 
332
  activate ();
333
  option_all_scopes:=false; 
334
  let scope_list = Str.split (Str.regexp ", *") s in
335
  let scope_list = List.map (fun scope -> Str.split (Str.regexp "\\.") scope) scope_list in
336
  scopes_def := scope_list
250 337

  
338
let register_inputs s = 
339
  activate ();
340
  let input_list = Str.split (Str.regexp "[;]") s in
341
  let input_list = List.map (fun s -> match Str.split (Str.regexp "=") s with | [v;e] -> v, e | _ -> raise (Invalid_argument ("Input list error: " ^ s))) input_list in
342
  let input_list = List.map (fun (v, e) -> v, Str.split (Str.regexp "[;]") e) input_list in
343
  inputs := input_list
344

  
345
let register_all_scopes () =
346
  activate ();
347
  option_all_scopes:= true
348
  
251 349
module Plugin : (
252 350
  sig
253 351
    include PluginType.PluginType
......
268 366
    "-select", Arg.String register_scopes, "specifies which variables to log";
269 367
    "-input", Arg.String register_inputs, "specifies the simulation input";
270 368
    "-show-possible-scopes", Arg.Set option_show_scopes, "list possible variables to log";
271
    "-select-all", Arg.Set option_all_scopes, "select all possible variables to log";
369
    "-select-all", Arg.Unit register_all_scopes, "select all possible variables to log";
272 370
    (* "-select-mems", Arg.Set option_mems_scopes, "select all memory variables to log";
273 371
     * "-select-inputs", Arg.Set option_input_scopes, "select all input variables to log"; *)
274 372
  ]
275 373

  
276
  let activate () = 
277
    option_scopes := true;
278
    Options.optimization := 0; (* no optimization *)
279
    
280
    (* Options.salsa_enabled := false; (\* No salsa *\) TODO *)
281
    ()
282

  
283
  let rec is_valid_path path nodename prog machines =
284
    let nodescopes = compute_scopes prog nodename in
285
    let m = get_machine nodename machines in
286
    match path with
287
    | [] -> assert false
288
    | [vid] -> let res = List.exists (fun v -> v.var_id = vid) (m.mmemory @ m.mstep.step_inputs @ m.mstep.step_locals) in
289
	       (* if not res then  *)
290
	       (* 	 Format.eprintf "Variable %s cannot be found in machine %s@.Local vars are %a@." vid m.mname.node_id *)
291
	       (* 	   (Utils.fprintf_list ~sep:", " Printers.pp_var) (m.mmemory @ m.mstep.step_inputs @ m.mstep.step_locals) *)
292
	       (* ; *)
293
	       res
294
	       
295
    | inst::nodename::path' -> (* We use the scopes computed on the prog artifact *)
296
      (* Format.eprintf "Path is %a@ Local scopes: @[<v>%a@ @]@."  *)
297
      (* 	(Utils.fprintf_list ~sep:"." Format.pp_print_string) path *)
298
      (* 	(Utils.fprintf_list ~sep:";@ " *)
299
      (* 	   (fun fmt scope ->  *)
300
      (* 	     Utils.fprintf_list ~sep:"." Format.pp_print_string fmt (scope_to_sl scope)) *)
301
      (* 	)  *)
302
      (* 	nodescopes; *)
303
      if List.mem path (List.map scope_to_sl nodescopes) then (
304
	(* Format.eprintf "Valid local path, checking underneath@."; *)
305
	is_valid_path path' nodename prog machines
306
      )
307
      else
308
	false
309

  
310
      (* let instok = List.exists (fun (inst', node) -> inst' = inst) m.minstances in *)
311
      (* if not instok then Format.eprintf "inst = %s@." inst; *)
312
      (* instok &&  *)
313
      (* let instnode = fst (snd (List.find (fun (inst', node) -> inst' = inst) m.minstances)) in *)
314
      (* is_valid_path path' (Corelang.node_of_top instnode).node_id prog machines *)
315

  
316
  let process_scopes main_node prog machines =
317
    let all_scopes = compute_scopes prog !Options.main_node in
318
    let selected_scopes = if !option_all_scopes then
319
	List.map (fun s -> scope_to_sl s) all_scopes
320
      else
321
	!scopes_def
322
    in
323
    (* Making sure all scopes are defined and were not removed by various
324
       optmizationq *)
325
    let selected_scopes = 
326
      List.filter 
327
	(fun sl -> 
328
	  let res = is_valid_path sl main_node prog machines in
329
	  if not res then
330
	    Format.eprintf "Scope %a is cancelled due to variable removal@." (Utils.fprintf_list ~sep:"." Format.pp_print_string) sl; 
331
	  res
332
	) 
333
	selected_scopes 
334
    in
335
    scopes_map := check_scopes main_node prog machines all_scopes selected_scopes;
336
    (* Each machine is updated with fresh memories and declared as stateful  *)
337
    let machines = List.map (update_machine main_node) machines in
338
     machines
339

  
340
  (* let pp fmt = pp_scopes fmt !scopes_map *)
374
  let activate = activate
341 375

  
342 376
  let check_force_stateful () = is_active()
343 377

  

Also available in: Unified diff