diff --git a/src/licDump.ml b/src/licDump.ml index 7e0dcc0ea40e49b0047155e8c8f598ffdd543cf0..072e73cb43c0bea3f6d921a9bcb1f407b8e3fe68 100644 --- a/src/licDump.ml +++ b/src/licDump.ml @@ -9,10 +9,14 @@ open Lv6MainArgs (* XXX changer le nom de cette fonction *) let (dump_long : Lv6Id.long -> string) = fun x -> - if global_opt.no_prefix then - Lv6Id.no_pack_string_of_long x - else - Lv6Id.string_of_long x + (*Ajout*) + if global_opt.kcg then + if global_opt.no_prefix then + Lv6Id.no_pack_string_of_long x + else + Lv6Id.string_of_long x + else "" + (* fun id -> *) (* let str = Lv6Id.string_of_long id in *) (* Str.global_replace (Str.regexp "::") "__" str *) @@ -47,6 +51,7 @@ let string_of_ident x = else Lv6Id.string_of_long2 x + let rec string_of_const_eff = function | Bool_const_eff true -> "true" @@ -151,6 +156,11 @@ and string_def_of_type_eff = function None -> "" | Some ce -> " = " ^ (string_of_const_eff ce) in + (*début modif type struct*) + if global_opt.kcg then + (List.fold_left (f "; ") (f "" " {" (List.hd fl)) (List.tl fl)) ^ "}" + else + (*fin modif*) "struct " ^ (List.fold_left (f "; ") (f "" " {" (List.hd fl)) (List.tl fl)) ^ "}" @@ -417,9 +427,20 @@ and (string_of_by_pos_op_eff: Lic.by_pos_op srcflagged -> Lic.val_exp list -> st ^ " -> pre " ^ (if is_a_tuple ve1 then tuple_par [ve2] else string_of_val_exp_eff ve2) else + (*ajout*) + if global_opt.kcg then ( + "fby (" ^ + (if is_a_tuple ve1 then tuple_par [ve2] else string_of_val_exp_eff ve2) + ^ ";1;" ^ + (if is_a_tuple ve1 then tuple_par [ve1] else string_of_val_exp_eff ve1) + + ) + else( + (*fin ajout*) (if is_a_tuple ve1 then tuple_par [ve1] else string_of_val_exp_eff ve1) ^ " fby " ^ (if is_a_tuple ve1 then tuple_par [ve2] else string_of_val_exp_eff ve2) + ) | WHEN clk, vel -> (tuple vel) ^ (string_of_clock clk) | CURRENT Some _,_ -> "current " ^ tuple_par (if global_opt.ec then List.tl vel else vel) @@ -485,10 +506,18 @@ and string_of_val_exp_eff_core ve_core = "if " ^ (string_of_val_exp_eff ve) ^ " then current (" ^ (string_of_val_exp_eff ct) ^ ") else current (" ^ (string_of_val_exp_eff cf) ^")" + ) else ( + (*modif*) + if global_opt.kcg then ( + "merge ( " ^ (string_of_val_exp_eff ve) ^ ";" ^ + (string_of_val_exp_eff ct) ^ "when true;" ^ + (string_of_val_exp_eff cf) ^"when false )" + (*fin modif*) ) else ( "merge " ^ (string_of_val_exp_eff ve) ^ " (true -> " ^ (string_of_val_exp_eff ct) ^ ") (false -> "^ (string_of_val_exp_eff cf) ^")" ) + ) | Merge (ve, cl) -> ( "merge " ^ (string_of_val_exp_eff ve) ^ " " ^ (String.concat " " @@ -554,6 +583,7 @@ and (string_of_eq : Lic.eq_info srcflagged -> string) = and wrap_long_profile str = + if String.length str < 75 then str else "\n"^( Str.global_replace (Str.regexp "returns") "\nreturns" @@ -562,8 +592,10 @@ and wrap_long_profile str = and (profile_of_node_exp_eff: Lic.node_exp -> string) = fun neff -> - ("(" ^ (string_of_type_decl_list neff.inlist_eff "; ") ^ ") returns (" ^ - (string_of_type_decl_list neff.outlist_eff "; ") ^ ")") + + ("(" ^ (string_of_type_decl_list neff.inlist_eff "; ") ^ ") returns (" ^ + (string_of_type_decl_list neff.outlist_eff "; ") ^ ")") + and (string_of_node_def : Lic.node_def -> string list) = function @@ -622,18 +654,23 @@ and node_of_node_exp_eff (neff: Lic.node_exp): string = (* no extern kwd in v4... *) then "extern " else "" )^( - if global_opt.lv4 then ( - (* node and function does not have the same meaning in v4... *) + (*modifié*) + if global_opt.lv4 || global_opt.kcg then ( + (* node and function does not have the same meaning in scade and in lv4... *) if neff.def_eff = ExternLic then "function " else "node " ) else ( if neff.has_mem_eff then "node " else "function " ) - )^( - string_of_node_key_rec global_opt.no_prefix neff.node_key_eff + )^( + if global_opt.kcg then + string_of_node_key_rec (not global_opt.no_prefix) neff.node_key_eff + else + string_of_node_key_rec global_opt.no_prefix neff.node_key_eff )^( profile_of_node_exp_eff neff - ) - )^( + ) + )^ + ( match neff.def_eff with | ExternLic -> ";\n" | MetaOpLic -> ( @@ -644,22 +681,19 @@ and node_of_node_exp_eff (neff: Lic.node_exp): string = ) | AbstractLic _ -> ";\n" | BodyLic _ -> ( - ";\n"^ - ( - match neff.loclist_eff with - | None -> "" - | Some [] -> "" - | Some l -> - "var\n " ^ (string_of_type_decl_list l ";\n ") ^ ";\n" - ) ^ - "let\n " ^ - (String.concat "\n " (string_of_node_def neff.def_eff)) ^ - "\ntel\n-- end of node " ^ - (string_of_node_key_rec global_opt.no_prefix neff.node_key_eff) ^ "\n" - ) + (if global_opt.kcg then "\n" else ";\n") ^ + (match neff.loclist_eff with + | None -> "" + | Some [] -> "" + | Some l -> + ("var\n " ^ (string_of_type_decl_list l ";\n ") ^ ";\n" + ) ^ + "let\n " ^ + (String.concat "\n " (string_of_node_def neff.def_eff)) ^ + "\ntel\n-- end of node " ^ + (string_of_node_key_rec global_opt.no_prefix neff.node_key_eff) ^ "\n") + ) ) - - and (string_of_clock_exp : AstCore.clock_exp -> string) = function | AstCore.Base -> "" diff --git a/src/lv6util.ml b/src/lv6util.ml index 24f7064f8b9d3fe926b7faa1feb848d580a36061..3cb9c4d440b7299f4d4b41965c9440594b610b0b 100644 --- a/src/lv6util.ml +++ b/src/lv6util.ml @@ -1,4 +1,6 @@ +open Lv6MainArgs + let my_string_of_float = string_of_float let (entete : out_channel -> string -> string -> unit) = @@ -11,7 +13,7 @@ let (entete : out_channel -> string -> string -> unit) = else acc ^ " " ^ x , (i+1+(String.length x)) ) - ("",0) + ("",0) Sys.argv and date = Printf.sprintf "%02d/%02d/%d" (time.Unix.tm_mday) @@ -33,8 +35,13 @@ let (entete : out_channel -> string -> string -> unit) = Printf.fprintf oc "%s %s %s\n" cb sys_call ce; Printf.fprintf oc "%s on %s the %s at %s %s\n" cb hostname date time_str ce + + let (dump_entete : out_channel -> unit) = - fun oc -> entete oc "(*" "*)" + fun oc -> if global_opt.kcg then + (entete oc "/*" "*/") + else + (entete oc "(*" "*)") let rec pos_in_list i x l = match l with