Project

General

Profile

« Previous | Next » 

Revision f0a067e9

Added by Pierre-Loïc Garoche almost 3 years ago

Better production of trace files.
By default traces are not produced. Requires the option -t to produce them

View differences:

src/plugins/scopes/scopes.ml
175 175
let extract_scopes_defs scopes =
176 176
  let rec scope_path_name (path, flow) accu = 
177 177
    match path with 
178
    | [] -> accu ^ "_reg." ^ (scope_var_name flow.var_id), flow.var_type
178
    | [] -> accu ^ "_reg." ^ (scope_var_name flow.var_id), flow
179 179
    | (_, _, Some instance_id)::tl -> scope_path_name (tl, flow) ( accu ^ instance_id ^ "->" ) 
180 180
    | _ -> assert false
181 181
  in
......
189 189
  
190 190
let pp_scopes_files basename mname fmt scopes =
191 191
  let scopes_vars = extract_scopes_defs scopes in
192
  List.iteri (fun idx _ (* (id, (var, typ)) *) ->
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);
198
  ) scopes_vars
199

  
192
  List.iteri (fun idx  _(*(id, (var_path, var))*)  ->
193
      C_backend_common.pp_file_decl fmt "out_scopes" idx)
194
    scopes_vars;
195
  Format.fprintf fmt "@[<v 2>if (traces) {@ ";
196
  List.iteri (fun idx  (id, (var_path, var))  ->
197
      let file = C_backend_common.pp_file_open fmt "out_scopes" idx in
198
      Format.fprintf fmt
199
        "fprintf(%s, \"# scope: %s\\n\");@ "
200
        file id;
201
      Format.fprintf fmt
202
        "fprintf(%s, \"# node: %s\\n\");@ "
203
        file (Utils.desome var.var_parent_nodeid);
204
      Format.fprintf fmt
205
        "fprintf(%s, \"# variable: %s\\n\");@ "
206
        file var.var_id
207
    ) scopes_vars;
208
  Format.fprintf fmt "@]}@ "
209
    
200 210
  
201 211
let pp_scopes fmt scopes = 
202 212
  let scopes_vars = extract_scopes_defs scopes in
203
  List.iteri (fun idx (id, (var, typ)) ->
213
  List.iteri (fun idx (id, (var_path, var)) ->
204 214
    Format.fprintf fmt "@ %t;" 
205 215
      (fun fmt -> C_backend_common.print_put_var fmt
206
                    ("_scopes_" ^ string_of_int (idx+1))
207
                    id (*var*) typ var)
216
                    ("_scopes" ^ string_of_int (idx+1))
217
                    id (*var*) var.var_type var_path)
208 218
  ) scopes_vars
209 219

  
210 220
(**********************************************************************)

Also available in: Unified diff