Project

General

Profile

« Previous | Next » 

Revision 7f03f62d

Added by LĂ©lio Brun 9 months ago

first version that is parsed correctly by Frama-C

View differences:

src/backends/C/c_backend_common.ml
216 216
  else
217 217
    assert false (* Not a basic C type. Do not handle arrays or pointers *)
218 218

  
219
let pp_basic_c_type ?(var_opt=None) fmt t =
219
let pp_basic_c_type ?(pp_c_basic_type_desc=pp_c_basic_type_desc) ?(var_opt=None) fmt t =
220 220
  match var_opt with
221 221
  | Some v when Machine_types.is_exportable v ->
222 222
     Machine_types.pp_c_var_type fmt v
223 223
  | _ ->
224 224
     fprintf fmt "%s" (pp_c_basic_type_desc t)
225 225

  
226
let pp_c_type ?var_opt var_id fmt t =
226
let pp_c_type ?pp_c_basic_type_desc ?var_opt var_id fmt t =
227 227
  let rec aux t pp_suffix =
228 228
    if is_basic_c_type  t then
229 229
       fprintf fmt "%a %s%a"
230
         (pp_basic_c_type ~var_opt) t
230
         (pp_basic_c_type ?pp_c_basic_type_desc ~var_opt) t
231 231
         var_id
232 232
         pp_suffix ()
233 233
    else
......
383 383
     known in order to statically allocate memory, 
384 384
     so we print the full type
385 385
*)
386
let pp_c_decl_local_var m fmt id =
386
let pp_c_decl_local_var ?pp_c_basic_type_desc m fmt id =
387 387
  if id.var_dec_const
388 388
  then
389 389
    fprintf fmt "%a = %a"
390
      (pp_c_type ~var_opt:id id.var_id)
390
      (pp_c_type ?pp_c_basic_type_desc ~var_opt:id id.var_id)
391 391
      id.var_type
392 392
      (pp_c_val m "" (pp_c_var_read m))
393 393
      (Machine_code_common.get_const_assign m id)
394 394
  else
395 395
    fprintf fmt "%a"
396
      (pp_c_type ~var_opt:id id.var_id) id.var_type
396
      (pp_c_type ?pp_c_basic_type_desc ~var_opt:id id.var_id) id.var_type
397 397

  
398 398
(* Declaration of a struct variable:
399 399
   - if it's an array/matrix/etc, we declare it as a pointer

Also available in: Unified diff