Project

General

Profile

« Previous | Next » 

Revision aaa8e454

Added by LĂ©lio Brun 7 months ago

it works

View differences:

src/backends/EMF/EMF_backend.ml
248 248
  | MNoReset ni ->
249 249
    let write = ISet.singleton (reset_name ni) in
250 250
    write, write, VSet.empty
251
  (* TODO: handle clear_reset *)
252
  | MClearReset -> ISet.empty, ISet.empty, VSet.empty
251
  (* TODO: handle clear_reset and reset flag *)
252
  | MClearReset | MResetAssign _ -> ISet.empty, ISet.empty, VSet.empty
253 253
  | MSpec _ | MComment _ -> assert false (* not  available for EMF output *)
254 254
     
255 255
(* A kind of super join_guards: all MBranch are postponed and sorted by
......
274 274
let rec pp_emf_instr m fmt i =
275 275
  let pp_content fmt i =
276 276
    match Corelang.get_instr_desc i with
277
    | MLocalAssign(lhs, expr)
278
      -> (
279
	(match expr.value_desc with
280
	| Fun (fun_id, vl) -> (
281
	  (* Thanks to normalization, vl shall only contain constant or
282
	     local/state vars but not calls to other functions *)
283
	  fprintf fmt "\"kind\": \"operator\",@ ";
284
	  fprintf fmt "\"lhs\": \"%a\",@ " pp_var_name lhs;
285
	  fprintf fmt "\"name\": \"%s\",@ \"args\": [@[%a@]]"
286
	    fun_id
287
	    (pp_emf_cst_or_var_list m) vl
288
	)	 
289
	| Array _ | Access _ | Power _ 
290
	| Cst _ 
291
	| Var _ -> (
292
	  fprintf fmt "\"kind\": \"local_assign\",@ \"lhs\": \"%a\",@ \"rhs\": %a"
293
	    pp_var_name lhs
294
	    (pp_emf_cst_or_var m) expr
295
	))    )
277
    | MLocalAssign(lhs, expr) ->
278
      begin match expr.value_desc with
279
        | Fun (fun_id, vl) ->
280
          (* Thanks to normalization, vl shall only contain constant or
281
             local/state vars but not calls to other functions *)
282
          fprintf fmt "\"kind\": \"operator\",@ ";
283
          fprintf fmt "\"lhs\": \"%a\",@ " pp_var_name lhs;
284
          fprintf fmt "\"name\": \"%s\",@ \"args\": [@[%a@]]"
285
            fun_id
286
            (pp_emf_cst_or_var_list m) vl
287
        | Array _ | Access _ | Power _
288
        | Cst _
289
        | Var _ ->
290
          fprintf fmt "\"kind\": \"local_assign\",@ \"lhs\": \"%a\",@ \"rhs\": %a"
291
            pp_var_name lhs
292
            (pp_emf_cst_or_var m) expr
293
        | ResetFlag ->
294
          (* TODO: handle reset flag *)
295
          assert false
296
      end
296 297

  
297 298
    | MStateAssign(lhs, expr) (* a Pre construct Shall only be defined by a
298
				 variable or a constant, no function anymore! *)
299
                                 variable or a constant, no function anymore! *)
299 300
      -> (
300
	fprintf fmt "\"kind\": \"pre\",@ \"lhs\": \"%a\",@ \"rhs\": %a"
301
	  pp_var_name lhs
302
	  (pp_emf_cst_or_var m) expr
303
      )
304
       
301
          fprintf fmt "\"kind\": \"pre\",@ \"lhs\": \"%a\",@ \"rhs\": %a"
302
            pp_var_name lhs
303
            (pp_emf_cst_or_var m) expr
304
        )
305

  
305 306
    | MSetReset id
306 307
      -> (
307
	fprintf fmt "\"kind\": \"reset\",@ \"lhs\": \"%s\",@ \"rhs\": \"true\""
308
	  (reset_name id)
309
      )
308
          fprintf fmt "\"kind\": \"reset\",@ \"lhs\": \"%s\",@ \"rhs\": \"true\""
309
            (reset_name id)
310
        )
310 311
    | MNoReset id           
311 312
      -> (
312
	fprintf fmt "\"kind\": \"reset\",@ \"lhs\": \"%s\",@ \"rhs\": \"false\""
313
	  (reset_name id)
314
      )
315
  (* TODO: handle clear_reset *)
316
  | MClearReset -> ()
317
       
318
    | MBranch (g, hl) -> (
319
      let all_outputs, outputs, inputs = branch_instr_vars m i in
320
      (* Format.eprintf "Mbranch %a@.vars: all_out: %a, out:%a, in:%a@.@." *)
321
      (* 	Machine_code.pp_instr i *)
322
      (* 	(fprintf_list ~sep:", " pp_var_string) (ISet.elements all_outputs) *)
323
      (* 	(fprintf_list ~sep:", " pp_var_string) (ISet.elements outputs) *)
324
      (* 	pp_emf_vars_decl *)
325
      (* 	(VSet.elements inputs) *)
313
          fprintf fmt "\"kind\": \"reset\",@ \"lhs\": \"%s\",@ \"rhs\": \"false\""
314
            (reset_name id)
315
        )
316
    (* TODO: handle clear_reset and reset flag *)
317
    | MClearReset | MResetAssign _ -> ()
326 318

  
327
      (* ; *)
328
      let inputs = VSet.filter (fun v -> not (ISet.mem v.var_id all_outputs)) inputs in
319
    | MBranch (g, hl) -> (
320
        let all_outputs, outputs, inputs = branch_instr_vars m i in
321
        (* Format.eprintf "Mbranch %a@.vars: all_out: %a, out:%a, in:%a@.@." *)
322
        (* 	Machine_code.pp_instr i *)
323
        (* 	(fprintf_list ~sep:", " pp_var_string) (ISet.elements all_outputs) *)
324
        (* 	(fprintf_list ~sep:", " pp_var_string) (ISet.elements outputs) *)
325
        (* 	pp_emf_vars_decl *)
326
        (* 	(VSet.elements inputs) *)
327

  
328
        (* ; *)
329
        let inputs = VSet.filter (fun v -> not (ISet.mem v.var_id all_outputs)) inputs in
329 330
      (* Format.eprintf "Filtering in: %a@.@." *)
330 331
      (* 	pp_emf_vars_decl *)
331 332
      (* 	(VSet.elements inputs) *)

Also available in: Unified diff