Project

General

Profile

Revision 1b683c9a

View differences:

src/corelang.ml
181 181
  { e with expr_annot = merge_expr_annot e.expr_annot (Some annot) }
182 182

  
183 183

  
184
let mkinstr ?(lustre_expr=None) ?(lustre_eq=None) i =
184
let mkinstr ?lustre_expr ?lustre_eq i =
185 185
  {
186 186
    instr_desc = i;
187 187
    (* lustre_expr = lustre_expr; *)
src/corelang.mli
32 32
val mktop: top_decl_desc -> top_decl
33 33

  
34 34
(* constructor for machine types *)
35
val mkinstr: ?lustre_expr:expr option -> ?lustre_eq: eq option -> instr_t_desc -> instr_t
35
val mkinstr: ?lustre_expr:expr -> ?lustre_eq: eq -> instr_t_desc -> instr_t
36 36
val get_instr_desc: instr_t -> instr_t_desc
37 37
val update_instr_desc: instr_t -> instr_t_desc -> instr_t
38 38
  
src/machine_code.ml
423 423
  let eq = Corelang.mkeq Location.dummy_loc ([y.var_id], expr) in
424 424
  match expr.expr_desc with
425 425
  | Expr_ite   (c, t, e) -> let g = translate_guard node args c in
426
			    conditional ?lustre_eq:(Some (Some eq)) g
426
			    conditional ?lustre_eq:(Some eq) g
427 427
                              [translate_act node args (y, t)]
428 428
                              [translate_act node args (y, e)]
429
  | Expr_merge (x, hl)   -> mkinstr ?lustre_eq:(Some (Some eq)) (MBranch (translate_ident node args x,
429
  | Expr_merge (x, hl)   -> mkinstr ?lustre_eq:(Some eq) (MBranch (translate_ident node args x,
430 430
                                     List.map (fun (t,  h) -> t, [translate_act node args (y, h)]) hl))
431
  | _                    -> mkinstr ?lustre_eq:(Some (Some eq))  (MLocalAssign (y, translate_expr node args expr))
431
  | _                    -> mkinstr ?lustre_eq:(Some eq)  (MLocalAssign (y, translate_expr node args expr))
432 432

  
433 433
let reset_instance node args i r c =
434 434
  match r with
......
448 448
      mkinstr (MReset o) :: si,
449 449
      Utils.IMap.add o (arrow_top_decl, []) j,
450 450
      d,
451
      (control_on_clock node args eq.eq_rhs.expr_clock (mkinstr ?lustre_eq:(Some (Some eq)) (MStep ([var_x], o, [c1;c2])))) :: s)
451
      (control_on_clock node args eq.eq_rhs.expr_clock (mkinstr ?lustre_eq:(Some eq) (MStep ([var_x], o, [c1;c2])))) :: s)
452 452
  | [x], Expr_pre e1 when ISet.mem (get_node_var x node) d     ->
453 453
     let var_x = get_node_var x node in
454 454
     (ISet.add var_x m,
455 455
      si,
456 456
      j,
457 457
      d,
458
      control_on_clock node args eq.eq_rhs.expr_clock (mkinstr ?lustre_eq:(Some (Some eq)) (MStateAssign (var_x, translate_expr node args e1))) :: s)
458
      control_on_clock node args eq.eq_rhs.expr_clock (mkinstr ?lustre_eq:(Some eq) (MStateAssign (var_x, translate_expr node args e1))) :: s)
459 459
  | [x], Expr_fby (e1, e2) when ISet.mem (get_node_var x node) d ->
460 460
     let var_x = get_node_var x node in
461 461
     (ISet.add var_x m,
462
      mkinstr ?lustre_eq:(Some (Some eq)) (MStateAssign (var_x, translate_expr node args e1)) :: si,
462
      mkinstr ?lustre_eq:(Some eq) (MStateAssign (var_x, translate_expr node args e1)) :: si,
463 463
      j,
464 464
      d,
465
      control_on_clock node args eq.eq_rhs.expr_clock (mkinstr ?lustre_eq:(Some (Some eq)) (MStateAssign (var_x, translate_expr node args e2))) :: s)
465
      control_on_clock node args eq.eq_rhs.expr_clock (mkinstr ?lustre_eq:(Some eq) (MStateAssign (var_x, translate_expr node args e2))) :: s)
466 466

  
467 467
  | p  , Expr_appl (f, arg, r) when not (Basic_library.is_expr_internal_fun eq.eq_rhs) ->
468 468
     let var_p = List.map (fun v -> get_node_var v node) p in
......
485 485
      (if Stateless.check_node node_f
486 486
       then []
487 487
       else reset_instance node args o r call_ck) @
488
	(control_on_clock node args call_ck (mkinstr ?lustre_eq:(Some (Some eq)) (MStep (var_p, o, vl)))) :: s)
488
	(control_on_clock node args call_ck (mkinstr ?lustre_eq:(Some eq) (MStep (var_p, o, vl)))) :: s)
489 489
  (*
490 490
    (* special treatment depending on the active backend. For horn backend, x = ite (g,t,e)
491 491
    are preserved. While they are replaced as if g then x = t else x = e in  C or Java

Also available in: Unified diff