Changeset 758 for src/Cminor


Ignore:
Timestamp:
Apr 18, 2011, 12:33:35 PM (9 years ago)
Author:
campbell
Message:

Implement replacement of global var initialisation data by code in Cminor.

Location:
src/Cminor
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/Cminor/cminorMatitaPrinter.ml

    r751 r758  
    1616let print_data = function
    1717  | Data_reserve n -> Printf.sprintf "Init_space %d" n
    18   | Data_int8 i -> Printf.sprintf "Init_int8 %d" i
    19   | Data_int16 i -> Printf.sprintf "Init_int16 %d" i
    20   | Data_int32 i -> Printf.sprintf "Init_int32 %d" i
     18  | Data_int8 i -> Printf.sprintf "Init_int8 (repr %d)" i
     19  | Data_int16 i -> Printf.sprintf "Init_int16 (repr %d)" i
     20  | Data_int32 i -> Printf.sprintf "Init_int32 (repr %d)" i
    2121  | Data_float32 f -> Printf.sprintf "Init_float32 %f" f
    2222  | Data_float64 f -> Printf.sprintf "Init_float64 %f" f
    2323
    2424let print_var n (id, init) =
    25   Printf.sprintf "(pair ?? (pair ?? (pair ?? %s [%s]) Any) it)"
     25  Printf.sprintf "(pair ?? (pair ?? (pair ?? id_%s [%s]) Any) it)"
    2626    id
    2727    (MiscPottier.string_of_list ";" print_data init)
     
    298298    (match main with Some f -> "id_" ^ f | None -> "ident_of_nat 0 (* None! *)")
    299299
     300let define_var_id (id,_) =
     301  Printf.sprintf "definition id_%s := ident_of_nat %d.\n" id (fresh ())
     302
     303let define_var_ids =
     304  List.fold_left (fun s v -> s ^ (define_var_id v)) ""
     305
    300306let print_program p =
    301   Printf.sprintf "include \"Cminor/semantics.ma\".\ninclude \"common/Animation.ma\".\n\n%s\n\ndefinition myprog : Cminor_program :=\nmk_program ?? [\n%s\n]%s\n[%s]\n.\n"
     307  Printf.sprintf "include \"Cminor/semantics.ma\".\ninclude \"common/Animation.ma\".\n\n%s\n\n%s\n\ndefinition myprog : Cminor_program :=\nmk_program ?? [\n%s\n]%s\n[%s]\n.\n"
     308    (define_var_ids p.Cminor.vars)
    302309    (print_functs p.Cminor.functs)
    303310    (print_fun' 2 p.Cminor.functs)
Note: See TracChangeset for help on using the changeset viewer.