@@ -2457,14 +2457,38 @@ let from_exe
24572457(* As input: list of primitives + size of global table *)
24582458let from_bytes primitives (code : bytecode ) =
24592459 let debug_data = Debug. create ~include_cmis: false false in
2460+ let ident_table =
2461+ let t = Hashtbl. create 17 in
2462+ if Debug. names debug_data
2463+ then
2464+ Symtable. iter_global_map
2465+ (fun id pos' -> Hashtbl. add t pos' id)
2466+ (Symtable. current_state () );
2467+ t
2468+ in
24602469 let globals = make_globals 0 [||] primitives in
24612470 let p = parse_bytecode code globals debug_data in
2462- let gdata = Var. fresh () in
2471+ let gdata = Var. fresh_n " global_data " in
24632472 let need_gdata = ref false in
2473+ let find_name i =
2474+ let value = (Meta. global_data () ).(i) in
2475+ let tag = Obj. tag value in
2476+ if tag = Obj. string_tag
2477+ then Some (" cst_" ^ Obj. magic value : string )
2478+ else
2479+ match Hashtbl. find ident_table i with
2480+ | exception Not_found -> None
2481+ | ident -> Some (Ident. name ident)
2482+ in
24642483 let body =
24652484 Array. fold_right_i globals.vars ~init: [] ~f: (fun i var l ->
24662485 match var with
24672486 | Some x when globals.is_const.(i) ->
2487+ (if Debug. names debug_data
2488+ then
2489+ match find_name i with
2490+ | None -> ()
2491+ | Some name -> Code.Var. name x name);
24682492 need_gdata := true ;
24692493 Let (x, Field (gdata, i)) :: l
24702494 | _ -> l)
0 commit comments