File tree Expand file tree Collapse file tree 6 files changed +25
-26
lines changed Expand file tree Collapse file tree 6 files changed +25
-26
lines changed Original file line number Diff line number Diff line change @@ -860,11 +860,12 @@ let rec get_source_map_files files src_index =
860860 if Zip. has_entry z ~name: " source_map.map"
861861 then
862862 let data = Zip. read_entry z ~name: " source_map.map" in
863- let sm = Source_map. of_string data in
863+ let sm = Source_map.Standard. of_string data in
864864 if not (Wasm_source_map. is_empty sm)
865865 then (
866866 let l = ref [] in
867- Wasm_source_map. iter_sources sm (fun i j file -> l := source_name i j file :: ! l);
867+ Wasm_source_map. iter_sources (Standard sm) (fun i j file ->
868+ l := source_name i j file :: ! l);
868869 if not (List. is_empty ! l)
869870 then z, Array. of_list (List. rev ! l)
870871 else (
Original file line number Diff line number Diff line change @@ -1497,7 +1497,7 @@ type t =
14971497 { module_name : string
14981498 ; file : string
14991499 ; contents : Read .t
1500- ; source_map_contents : Source_map .t option
1500+ ; source_map_contents : Source_map.Standard . t option
15011501 }
15021502
15031503type import_status =
@@ -1877,8 +1877,8 @@ let f files ~output_file ~opt_output_sourcemap_file =
18771877 Option. map
18781878 ~f: (fun src ->
18791879 match src with
1880- | `File file -> Source_map. of_file ~tmp_buf file
1881- | `Data data -> Source_map. of_string ~tmp_buf data)
1880+ | `File file -> Source_map.Standard. of_file ~tmp_buf file
1881+ | `Data data -> Source_map.Standard. of_string ~tmp_buf data)
18821882 opt_source_map
18831883 })
18841884 (Array. of_list files)
Original file line number Diff line number Diff line change @@ -82,31 +82,21 @@ let resize_mappings (resize_data : resize_data) mappings =
8282 0 ;
8383 Buffer. contents buf
8484
85- let resize resize_data sm =
86- match sm with
87- | Source_map. Index _ -> assert false
88- | Standard sm ->
89- let mappings = Source_map.Mappings. to_string sm.mappings in
90- let mappings = resize_mappings resize_data mappings in
91- Source_map. Standard
92- { sm with mappings = Source_map.Mappings. of_string_unsafe mappings }
93-
94- let is_empty sm =
95- match sm with
96- | Source_map. Standard { mappings; _ } -> Source_map.Mappings. is_empty mappings
97- | _ -> assert false
85+ let resize resize_data (sm : Source_map.Standard.t ) =
86+ let mappings = Source_map.Mappings. to_string sm.mappings in
87+ let mappings = resize_mappings resize_data mappings in
88+ { sm with mappings = Source_map.Mappings. of_string_unsafe mappings }
89+
90+ let is_empty { Source_map.Standard. mappings; _ } = Source_map.Mappings. is_empty mappings
9891
9992let concatenate l =
10093 Source_map. Index
10194 { version = 3
10295 ; file = None
10396 ; sections =
10497 List. map
105- ~f: (fun (ofs , sm ) ->
106- match sm with
107- | Source_map. Index _ -> assert false
108- | Standard map ->
109- { Source_map.Index. offset = { gen_line = 0 ; gen_column = ofs }; map })
98+ ~f: (fun (ofs , map ) ->
99+ { Source_map.Index. offset = { gen_line = 0 ; gen_column = ofs }; map })
110100 l
111101 }
112102
Original file line number Diff line number Diff line change 11type t
22
3- val is_empty : Source_map .t -> bool
3+ val is_empty : Source_map.Standard . t -> bool
44
55type resize_data =
66 { mutable i : int
77 ; mutable pos : int array
88 ; mutable delta : int array
99 }
1010
11- val resize : resize_data -> Source_map .t -> Source_map .t
11+ val resize : resize_data -> Source_map.Standard . t -> Source_map.Standard .t
1212
13- val concatenate : (int * Source_map .t ) list -> Source_map .t
13+ val concatenate : (int * Source_map.Standard . t ) list -> Source_map .t
1414
1515val iter_sources : Source_map .t -> (int option -> int option -> string -> unit ) -> unit
1616
Original file line number Diff line number Diff line change @@ -564,6 +564,10 @@ module Standard = struct
564564 }
565565 | _ -> invalid ()
566566
567+ let of_string ?tmp_buf s = of_json ?tmp_buf (Yojson.Raw. from_string ?buf:tmp_buf s )
568+
569+ let of_file ?tmp_buf f = of_json ?tmp_buf (Yojson.Raw. from_file ?buf:tmp_buf f )
570+
567571 let to_string m = Yojson.Raw. to_string (json m)
568572
569573 let to_file m file = Yojson.Raw. to_file file (json m)
Original file line number Diff line number Diff line change @@ -116,6 +116,10 @@ module Standard : sig
116116 linear in function of the size of the input mappings. *)
117117
118118 val empty : inline_source_content :bool -> t
119+
120+ val of_string : ?tmp_buf : Buffer .t -> string -> t
121+
122+ val of_file : ?tmp_buf : Buffer .t -> string -> t
119123end
120124
121125module Index : sig
You can’t perform that action at this time.
0 commit comments