@@ -590,6 +590,7 @@ module State = struct
590590 ; handlers : handler list
591591 ; globals : globals
592592 ; immutable : Code.Var.Set .t ref
593+ ; includes : string list
593594 }
594595
595596 let fresh_var state loc =
@@ -695,14 +696,15 @@ module State = struct
695696
696697 let pop_handler state = { state with handlers = List. tl state.handlers }
697698
698- let initial g immutable =
699+ let initial includes g immutable =
699700 { accu = Unset
700701 ; stack = []
701702 ; env = [||]
702703 ; env_offset = 0
703704 ; handlers = []
704705 ; globals = g
705706 ; immutable
707+ ; includes
706708 }
707709
708710 let rec print_stack f l =
@@ -818,7 +820,7 @@ let get_global state instrs i loc =
818820 (match g.named_value.(i) with
819821 | None -> ()
820822 | Some name -> (
821- match Shape.Store. get ~name with
823+ match Shape.Store. load ~name state.includes with
822824 | None -> ()
823825 | Some shape -> Shape.State. assign x shape));
824826
@@ -2534,9 +2536,9 @@ type one =
25342536 ; debug : Debug .t
25352537 }
25362538
2537- let parse_bytecode code globals debug_data =
2539+ let parse_bytecode ~ includes code globals debug_data =
25382540 let immutable = ref Code.Var.Set. empty in
2539- let state = State. initial globals immutable in
2541+ let state = State. initial includes globals immutable in
25402542 Code.Var. reset () ;
25412543 Shape.State. reset () ;
25422544 let blocks = Blocks. analyse debug_data code in
@@ -2748,7 +2750,7 @@ let from_exe
27482750 Ocaml_compiler.Symtable.GlobalMap. iter symbols ~f: (fun id n ->
27492751 globals.named_value.(n) < - Some (Ocaml_compiler.Symtable.Global. name id);
27502752 globals.is_exported.(n) < - true );
2751- let p = parse_bytecode code globals debug_data in
2753+ let p = parse_bytecode ~includes code globals debug_data in
27522754 (* register predefined exception *)
27532755 let body =
27542756 List. fold_left predefined_exceptions ~init: [] ~f: (fun body (i , name ) ->
@@ -2872,7 +2874,7 @@ let from_bytes ~prims ~debug (code : bytecode) =
28722874 t
28732875 in
28742876 let globals = make_globals 0 [||] prims in
2875- let p = parse_bytecode code globals debug_data in
2877+ let p = parse_bytecode ~includes: [] code globals debug_data in
28762878 let gdata = Var. fresh_n " global_data" in
28772879 let need_gdata = ref false in
28782880 let find_name i =
@@ -3011,7 +3013,7 @@ module Reloc = struct
30113013 globals
30123014end
30133015
3014- let from_compilation_units ~includes : _ ~include_cmis ~debug_data l =
3016+ let from_compilation_units ~includes ~include_cmis ~debug_data l =
30153017 let reloc = Reloc. create () in
30163018 List. iter l ~f: (fun (compunit , code ) -> Reloc. step1 reloc compunit code);
30173019 List. iter l ~f: (fun (compunit , code ) -> Reloc. step2 reloc compunit code);
@@ -3020,7 +3022,7 @@ let from_compilation_units ~includes:_ ~include_cmis ~debug_data l =
30203022 let l = List. map l ~f: (fun (_ , c ) -> Bytes. to_string c) in
30213023 String. concat ~sep: " " l
30223024 in
3023- let prog = parse_bytecode code globals debug_data in
3025+ let prog = parse_bytecode ~includes code globals debug_data in
30243026 let gdata = Var. fresh_n " global_data" in
30253027 let need_gdata = ref false in
30263028 let body =
0 commit comments