Project

General

Profile

Revision eb9a8c3c

View differences:

src/corelang.ml
1199 1199
  }
1200 1200
  in aux ()
1201 1201

  
1202

  
1203
let find_eq xl eqs =
1204
  let rec aux accu eqs =
1205
    match eqs with
1206
	| [] ->
1207
	  begin
1208
	    Format.eprintf "Looking for variables %a in the following equations@.%a@."
1209
	      (Utils.fprintf_list ~sep:" , " (fun fmt v -> Format.fprintf fmt "%s" v)) xl
1210
	      Printers.pp_node_eqs eqs;
1211
	    assert false
1212
	  end
1213
	| hd::tl ->
1214
	  if List.exists (fun x -> List.mem x hd.eq_lhs) xl then hd, accu@tl else aux (hd::accu) tl
1215
    in
1216
    aux [] eqs
1217

  
1202 1218
(* Local Variables: *)
1203 1219
(* compile-command:"make -C .." *)
1204 1220
(* End: *)
src/corelang.mli
165 165

  
166 166
val reset_cpt_fresh: unit -> unit
167 167
val mk_fresh_var: node_desc -> Location.t -> Types.type_expr ->  Clocks.clock_expr -> var_decl
168
(* Local Variables: *)
168

  
169
val find_eq: ident list -> eq list -> eq * eq list
170
                                                                                        (* Local Variables: *)
169 171
(* compile-command:"make -C .." *)
170 172
(* End: *)
src/machine_code.ml
226 226
       assert false
227 227
     end
228 228

  
229
let find_eq xl eqs =
230
  let rec aux accu eqs =
231
      match eqs with
232
	| [] ->
233
	  begin
234
	    Format.eprintf "Looking for variables %a in the following equations@.%a@."
235
	      (Utils.fprintf_list ~sep:" , " (fun fmt v -> Format.fprintf fmt "%s" v)) xl
236
	      Printers.pp_node_eqs eqs;
237
	    assert false
238
	  end
239
	| hd::tl ->
240
	  if List.exists (fun x -> List.mem x hd.eq_lhs) xl then hd, accu@tl else aux (hd::accu) tl
241
    in
242
    aux [] eqs
243 229

  
244
(* Sort the set of equations of node [nd] according
245
   to the computed schedule [sch]
246
*)
247
let sort_equations_from_schedule nd sch =
248
  (* Format.eprintf "%s schedule: %a@." *)
249
  (* 		 nd.node_id *)
250
  (* 		 (Utils.fprintf_list ~sep:" ; " Scheduling.pp_eq_schedule) sch; *)
251
  let eqs, auts = get_node_eqs nd in
252
  assert (auts = []); (* Automata should be expanded by now *)
253
  let split_eqs = Splitting.tuple_split_eq_list eqs in
254
  let eqs_rev, remainder =
255
    List.fold_left
256
      (fun (accu, node_eqs_remainder) vl ->
257
       if List.exists (fun eq -> List.exists (fun v -> List.mem v eq.eq_lhs) vl) accu
258
       then
259
	 (accu, node_eqs_remainder)
260
       else
261
	 let eq_v, remainder = find_eq vl node_eqs_remainder in
262
	 eq_v::accu, remainder
263
      )
264
      ([], split_eqs)
265
      sch
266
  in
267
  begin
268
    if List.length remainder > 0 then (
269
      let eqs, auts = get_node_eqs nd in
270
      assert (auts = []); (* Automata should be expanded by now *)
271
      Format.eprintf "Equations not used are@.%a@.Full equation set is:@.%a@.@?"
272
		     Printers.pp_node_eqs remainder
273
      		     Printers.pp_node_eqs eqs;
274
      assert false);
275
    List.rev eqs_rev
276
  end
277 230

  
278 231
let constant_equations nd =
279 232
 List.fold_right (fun vdecl eqs ->
......
292 245
let translate_decl nd sch =
293 246
  (*Log.report ~level:1 (fun fmt -> Printers.pp_node fmt nd);*)
294 247
  let schedule = sch.Scheduling_type.schedule in
295
  let sorted_eqs = sort_equations_from_schedule nd schedule in
248
  let sorted_eqs = Scheduling.sort_equations_from_schedule nd schedule in
296 249
  let constant_eqs = constant_equations nd in
297 250

  
298 251
  (* In case of non functional backend (eg. C), additional local variables have
src/scheduling.ml
245 245
   node_schs
246 246

  
247 247

  
248
   (* Sort eqs according to schedule *)
249
(* Sort the set of equations of node [nd] according
250
   to the computed schedule [sch]
251
*)
252
let sort_equations_from_schedule nd sch =
253
  (* Format.eprintf "%s schedule: %a@." *)
254
  (* 		 nd.node_id *)
255
  (* 		 (Utils.fprintf_list ~sep:" ; " Scheduling.pp_eq_schedule) sch; *)
256
  let eqs, auts = get_node_eqs nd in
257
  assert (auts = []); (* Automata should be expanded by now *)
258
  let split_eqs = Splitting.tuple_split_eq_list eqs in
259
  let eqs_rev, remainder =
260
    List.fold_left
261
      (fun (accu, node_eqs_remainder) vl ->
262
       if List.exists (fun eq -> List.exists (fun v -> List.mem v eq.eq_lhs) vl) accu
263
       then
264
	 (accu, node_eqs_remainder)
265
       else
266
	 let eq_v, remainder = find_eq vl node_eqs_remainder in
267
	 eq_v::accu, remainder
268
      )
269
      ([], split_eqs)
270
      sch
271
  in
272
  begin
273
    if List.length remainder > 0 then (
274
      let eqs, auts = get_node_eqs nd in
275
      assert (auts = []); (* Automata should be expanded by now *)
276
      Format.eprintf "Equations not used are@.%a@.Full equation set is:@.%a@.@?"
277
		     Printers.pp_node_eqs remainder
278
      		     Printers.pp_node_eqs eqs;
279
      assert false);
280
    List.rev eqs_rev
281
  end
282

  
248 283
(* Local Variables: *)
249 284
(* compile-command:"make -C .." *)
250 285
(* End: *)

Also available in: Unified diff