Skip to content

Commit ab1c9e6

Browse files
OlivierNicolehhugo
authored andcommitted
Compiler: Handle composite/Index sourcemaps
1 parent 95dafb1 commit ab1c9e6

File tree

20 files changed

+436
-256
lines changed

20 files changed

+436
-256
lines changed

compiler/bin-js_of_ocaml/build_fs.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function jsoo_create_file_extern(name,content){
7474
let code = Code.prepend Code.empty instr in
7575
Filename.gen_file output_file (fun chan ->
7676
let pfs_fmt = Pretty_print.to_out_channel chan in
77-
let (_ : Source_map.t option) =
77+
let (_ : Source_map.Standard.t option) =
7878
Driver.f
7979
~standalone:true
8080
~wrap_with_fun:`Iife

compiler/bin-js_of_ocaml/cmd_arg.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type t =
4343
{ common : Jsoo_cmdline.Arg.t
4444
; (* compile option *)
4545
profile : Driver.profile option
46-
; source_map : (string option * Source_map.t) option
46+
; source_map : (string option * Source_map.Standard.t) option
4747
; runtime_files : string list
4848
; no_runtime : bool
4949
; include_runtime : bool
@@ -308,7 +308,7 @@ let options =
308308
in
309309
Some
310310
( sm_output_file
311-
, { Source_map.version = 3
311+
, { Source_map.Standard.version = 3
312312
; file
313313
; sourceroot = sourcemap_root
314314
; sources = []
@@ -537,7 +537,7 @@ let options_runtime_only =
537537
in
538538
Some
539539
( sm_output_file
540-
, { Source_map.version = 3
540+
, { Source_map.Standard.version = 3
541541
; file
542542
; sourceroot = sourcemap_root
543543
; sources = []

compiler/bin-js_of_ocaml/cmd_arg.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type t =
2323
{ common : Jsoo_cmdline.Arg.t
2424
; (* compile option *)
2525
profile : Driver.profile option
26-
; source_map : (string option * Source_map.t) option
26+
; source_map : (string option * Source_map.Standard.t) option
2727
; runtime_files : string list
2828
; no_runtime : bool
2929
; include_runtime : bool

compiler/bin-js_of_ocaml/compile.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ let output_gen ~standalone ~custom_header ~build_info ~source_map output_file f
4747
match source_map, sm with
4848
| None, _ | _, None -> ()
4949
| Some (output_file, _), Some sm ->
50+
let sm = `Standard sm in
5051
let urlData =
5152
match output_file with
5253
| None ->

compiler/bin-js_of_ocaml/link.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ open Cmdliner
2323

2424
type t =
2525
{ common : Jsoo_cmdline.Arg.t
26-
; source_map : (string option * Source_map.t) option
26+
; source_map : (string option * Source_map.Standard.t) option
2727
; js_files : string list
2828
; output_file : string option
2929
; resolve_sourcemap_url : bool
@@ -102,7 +102,7 @@ let options =
102102
in
103103
Some
104104
( sm_output_file
105-
, { Source_map.version = 3
105+
, { Source_map.Standard.version = 3
106106
; file
107107
; sourceroot = sourcemap_root
108108
; sources = []

compiler/bin-jsoo_minify/jsoo_minify.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ let f { Cmd_arg.common; output_file; use_stdin; files } =
9292
if t () then (m ())#program p else p)
9393
in
9494
let p = Js_assign.program p in
95-
let (_ : Source_map.t option) = Js_output.program pp p in
95+
let (_ : Source_map.Standard.t option) = Js_output.program pp p in
9696
()
9797
in
9898
with_output (fun out_channel ->

compiler/lib/driver.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ let full ~standalone ~wrap_with_fun ~profile ~link ~source_map ~formatter d p =
713713
emit formatter optimized_code
714714

715715
let full_no_source_map ~formatter ~standalone ~wrap_with_fun ~profile ~link d p =
716-
let (_ : Source_map.t option) =
716+
let (_ : Source_map.Standard.t option) =
717717
full ~standalone ~wrap_with_fun ~profile ~link ~source_map:None ~formatter d p
718718
in
719719
()

compiler/lib/driver.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ val f :
3535
-> ?wrap_with_fun:[ `Iife | `Anonymous | `Named of string ]
3636
-> ?profile:profile
3737
-> link:[ `All | `All_from of string list | `Needed | `No ]
38-
-> ?source_map:Source_map.t
38+
-> ?source_map:Source_map.Standard.t
3939
-> formatter:Pretty_print.t
4040
-> Parse_bytecode.Debug.t
4141
-> Code.program
42-
-> Source_map.t option
42+
-> Source_map.Standard.t option
4343

4444
val f' :
4545
?standalone:bool

compiler/lib/js_assign.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ let program' (module Strategy : Strategy) p =
425425
"Some variables escaped (#%d). Use [--debug js_assign] for more info.@."
426426
(IdentSet.cardinal free)
427427
else
428-
let (_ : Source_map.t option) =
428+
let (_ : Source_map.Standard.t option) =
429429
Js_output.program
430430
~accept_unnamed_var:true
431431
(Pretty_print.to_out_channel stderr)

compiler/lib/js_output.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,8 +1905,8 @@ let program ?(accept_unnamed_var = false) f ?source_map p =
19051905
let names = Hashtbl.create 17 in
19061906
let contents : Source_map.Source_content.t option list ref option =
19071907
match source_map with
1908-
| None | Some { Source_map.sources_content = None; _ } -> None
1909-
| Some { Source_map.sources_content = Some _; _ } -> Some (ref [])
1908+
| None | Some { Source_map.Standard.sources_content = None; _ } -> None
1909+
| Some { Source_map.Standard.sources_content = Some _; _ } -> Some (ref [])
19101910
in
19111911
let push_mapping, get_file_index, get_name_index, source_map_enabled =
19121912
let source_map_enabled =
@@ -1926,7 +1926,7 @@ let program ?(accept_unnamed_var = false) f ?source_map p =
19261926
loop xs ys
19271927
in
19281928
loop sm.sources (Option.value ~default:[] sm.sources_content);
1929-
List.iter sm.Source_map.names ~f:(fun f ->
1929+
List.iter sm.Source_map.Standard.names ~f:(fun f ->
19301930
Hashtbl.add names f (Hashtbl.length names));
19311931
true
19321932
in
@@ -2014,7 +2014,7 @@ let program ?(accept_unnamed_var = false) f ?source_map p =
20142014
{ gen_line; gen_col; ori_source; ori_line; ori_col; ori_name })
20152015
in
20162016
let mappings = Source_map.Mappings.encode mappings in
2017-
Some { sm with Source_map.sources; names; sources_content; mappings }
2017+
Some { sm with Source_map.Standard.sources; names; sources_content; mappings }
20182018
in
20192019
PP.check f;
20202020
(if stats ()

0 commit comments

Comments
 (0)