Skip to content

Commit 87ce37a

Browse files
committed
add DEBUG support, and %%debugger.chrome for reason users
1 parent f872eb5 commit 87ce37a

File tree

10 files changed

+72
-14
lines changed

10 files changed

+72
-14
lines changed

jscomp/all.depend

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ syntax/external_arg_spec.cmx : ext/ext_position.cmx ext/ext_json_parse.cmx \
190190
syntax/ast_payload.cmx : ext/string_map.cmx ext/ext_list.cmx \
191191
ext/ext_js_regex.cmx syntax/ast_payload.cmi
192192
syntax/ast_signature.cmx : syntax/ast_signature.cmi
193-
syntax/ast_structure.cmx : syntax/ast_signature.cmx syntax/ast_structure.cmi
193+
syntax/ast_structure.cmx : syntax/ast_signature.cmx syntax/ast_literal.cmx \
194+
syntax/ast_structure.cmi
194195
syntax/bs_ast_iterator.cmx : syntax/bs_ast_iterator.cmi
195196
syntax/bs_ast_mapper.cmx : syntax/bs_ast_mapper.cmi
196197
syntax/ast_derive.cmx : ext/string_map.cmx ext/literals.cmx \
@@ -264,14 +265,15 @@ syntax/ast_core_type_class_type.cmx : ext/literals.cmx ext/ext_ref.cmx \
264265
syntax/ast_literal.cmx syntax/ast_comb.cmx syntax/ast_attributes.cmx \
265266
syntax/ast_core_type_class_type.cmi
266267
syntax/ppx_entry.cmx : ext/string_map.cmx ext/literals.cmx \
267-
ext/ext_string.cmx syntax/bs_ast_mapper.cmx syntax/bs_ast_invariant.cmx \
268-
syntax/ast_util.cmx syntax/ast_utf8_string_interp.cmx \
269-
syntax/ast_utf8_string.cmx syntax/ast_tuple_pattern_flatten.cmx \
270-
syntax/ast_tdcls.cmx syntax/ast_primitive.cmx syntax/ast_payload.cmx \
271-
syntax/ast_exp_extension.cmx syntax/ast_exp_apply.cmx \
272-
syntax/ast_derive_projector.cmx syntax/ast_derive_js_mapper.cmx \
273-
syntax/ast_core_type_class_type.cmx syntax/ast_attributes.cmx \
274-
syntax/ppx_entry.cmi
268+
common/js_config.cmx ext/ext_string.cmx syntax/bs_ast_mapper.cmx \
269+
syntax/bs_ast_invariant.cmx syntax/ast_util.cmx \
270+
syntax/ast_utf8_string_interp.cmx syntax/ast_utf8_string.cmx \
271+
syntax/ast_tuple_pattern_flatten.cmx syntax/ast_tdcls.cmx \
272+
syntax/ast_structure.cmx syntax/ast_primitive.cmx syntax/ast_payload.cmx \
273+
syntax/ast_literal.cmx syntax/ast_exp_extension.cmx \
274+
syntax/ast_exp_apply.cmx syntax/ast_derive_projector.cmx \
275+
syntax/ast_derive_js_mapper.cmx syntax/ast_core_type_class_type.cmx \
276+
syntax/ast_attributes.cmx syntax/ppx_entry.cmi
275277
syntax/bs_syntaxerr.cmi :
276278
syntax/ast_utf8_string.cmi :
277279
syntax/ast_utf8_string_interp.cmi :

jscomp/core/js_main.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ let buckle_script_flags : (string * Arg.spec * string) list =
146146
)
147147
::
148148
("-bs-g",
149-
Arg.Set Js_config.debug,
149+
Arg.Unit
150+
(fun _ -> Js_config.debug := true;
151+
Lexer.replace_directive_bool "DEBUG" true
152+
),
150153
" debug mode"
151154
)
152155
::

jscomp/outcome_printer/outcome_printer_ns.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ let out_ident ppf s =
113113
| "Belt_HashMap" -> "Belt.HashMap"
114114
| "Belt_HashMapString" -> "Belt.HashMap.String"
115115
| "Belt_HashMapInt" -> "Belt.HashMap.Int"
116-
116+
| "Belt_Debug" -> "Belt.Debug"
117117
| s ->
118118
(match Ext_namespace.try_split_module_name s with
119119
| None -> s

jscomp/syntax/ast_structure.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ let constraint_ ?(loc=Location.none) (stru : t) (sign : Ast_signature.t) =
5151
Str.include_ ~loc
5252
(Incl.mk ~loc
5353
(Mod.constraint_ ~loc (Mod.structure ~loc stru) (Mty.signature ~loc sign)))
54+
55+
let dummy_item loc : item =
56+
Str.eval ~loc (Ast_literal.val_unit ~loc ())

jscomp/syntax/ast_structure.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ val fuseAll: ?loc:Ast_helper.loc -> t -> item
3838
item *)
3939

4040
val constraint_ : ?loc:Ast_helper.loc -> t -> Ast_signature.t -> item
41+
42+
val dummy_item : Location.t -> item

jscomp/syntax/ppx_entry.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ let rec unsafe_mapper : Bs_ast_mapper.mapper =
211211
| Pstr_extension ( ({txt = ("bs.raw"| "raw") ; loc}, payload), _attrs)
212212
->
213213
Ast_util.handle_raw_structure loc payload
214+
| Pstr_extension (({txt = ("bs.debugger.chrome" | "debugger.chrome") ;loc}, payload),_)
215+
->
216+
if !Js_config.debug then
217+
let open Ast_helper in
218+
Str.eval ~loc (Exp.apply ~loc
219+
(Exp.ident ~loc {txt = Ldot(Ldot (Lident"Belt","Debug"), "setupChromeDebugger");loc} )
220+
["", Ast_literal.val_unit ~loc ()]
221+
)
222+
else Ast_structure.dummy_item loc
214223
| Pstr_type (_ :: _ as tdcls ) (* [ {ptype_attributes} as tdcl ] *)->
215224
Ast_tdcls.handleTdclsInStru self str tdcls
216225
| Pstr_primitive prim

jscomp/test/.depend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ bs_unwrap_test.cmj :
129129
buffer_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/bytes.cmj \
130130
../stdlib/buffer.cmj
131131
bytes_split_gpr_743_test.cmj : mt.cmj ../runtime/js.cmj ../stdlib/bytes.cmj
132-
caml_compare_test.cmj : mt.cmj
132+
caml_compare_test.cmj : mt.cmj ../runtime/js.cmj
133133
caml_format_test.cmj : ../stdlib/printf.cmj mt.cmj ../stdlib/int64.cmj \
134134
../stdlib/format.cmj ../stdlib/buffer.cmj ../stdlib/array.cmj
135135
caml_sys_poly_fill_test.cmj : ../stdlib/sys.cmj ../others/node_process.cmj \

lib/bsdep.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34830,6 +34830,7 @@ val fuseAll: ?loc:Ast_helper.loc -> t -> item
3483034830

3483134831
val constraint_ : ?loc:Ast_helper.loc -> t -> Ast_signature.t -> item
3483234832

34833+
val dummy_item : Location.t -> item
3483334834
end = struct
3483434835
#1 "ast_structure.ml"
3483534836
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -34886,6 +34887,8 @@ let constraint_ ?(loc=Location.none) (stru : t) (sign : Ast_signature.t) =
3488634887
(Incl.mk ~loc
3488734888
(Mod.constraint_ ~loc (Mod.structure ~loc stru) (Mty.signature ~loc sign)))
3488834889

34890+
let dummy_item loc : item =
34891+
Str.eval ~loc (Ast_literal.val_unit ~loc ())
3488934892
end
3489034893
module Ast_derive : sig
3489134894
#1 "ast_derive.mli"
@@ -38305,6 +38308,15 @@ let rec unsafe_mapper : Bs_ast_mapper.mapper =
3830538308
| Pstr_extension ( ({txt = ("bs.raw"| "raw") ; loc}, payload), _attrs)
3830638309
->
3830738310
Ast_util.handle_raw_structure loc payload
38311+
| Pstr_extension (({txt = ("bs.debugger.chrome" | "debugger.chrome") ;loc}, payload),_)
38312+
->
38313+
if !Js_config.debug then
38314+
let open Ast_helper in
38315+
Str.eval ~loc (Exp.apply ~loc
38316+
(Exp.ident ~loc {txt = Ldot(Ldot (Lident"Belt","Debug"), "setupChromeDebugger");loc} )
38317+
["", Ast_literal.val_unit ~loc ()]
38318+
)
38319+
else Ast_structure.dummy_item loc
3830838320
| Pstr_type (_ :: _ as tdcls ) (* [ {ptype_attributes} as tdcl ] *)->
3830938321
Ast_tdcls.handleTdclsInStru self str tdcls
3831038322
| Pstr_primitive prim

lib/bsppx.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16835,6 +16835,7 @@ val fuseAll: ?loc:Ast_helper.loc -> t -> item
1683516835

1683616836
val constraint_ : ?loc:Ast_helper.loc -> t -> Ast_signature.t -> item
1683716837

16838+
val dummy_item : Location.t -> item
1683816839
end = struct
1683916840
#1 "ast_structure.ml"
1684016841
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -16891,6 +16892,8 @@ let constraint_ ?(loc=Location.none) (stru : t) (sign : Ast_signature.t) =
1689116892
(Incl.mk ~loc
1689216893
(Mod.constraint_ ~loc (Mod.structure ~loc stru) (Mty.signature ~loc sign)))
1689316894

16895+
let dummy_item loc : item =
16896+
Str.eval ~loc (Ast_literal.val_unit ~loc ())
1689416897
end
1689516898
module Ast_derive : sig
1689616899
#1 "ast_derive.mli"
@@ -20310,6 +20313,15 @@ let rec unsafe_mapper : Bs_ast_mapper.mapper =
2031020313
| Pstr_extension ( ({txt = ("bs.raw"| "raw") ; loc}, payload), _attrs)
2031120314
->
2031220315
Ast_util.handle_raw_structure loc payload
20316+
| Pstr_extension (({txt = ("bs.debugger.chrome" | "debugger.chrome") ;loc}, payload),_)
20317+
->
20318+
if !Js_config.debug then
20319+
let open Ast_helper in
20320+
Str.eval ~loc (Exp.apply ~loc
20321+
(Exp.ident ~loc {txt = Ldot(Ldot (Lident"Belt","Debug"), "setupChromeDebugger");loc} )
20322+
["", Ast_literal.val_unit ~loc ()]
20323+
)
20324+
else Ast_structure.dummy_item loc
2031320325
| Pstr_type (_ :: _ as tdcls ) (* [ {ptype_attributes} as tdcl ] *)->
2031420326
Ast_tdcls.handleTdclsInStru self str tdcls
2031520327
| Pstr_primitive prim

lib/whole_compiler.ml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65592,6 +65592,7 @@ val fuseAll: ?loc:Ast_helper.loc -> t -> item
6559265592

6559365593
val constraint_ : ?loc:Ast_helper.loc -> t -> Ast_signature.t -> item
6559465594

65595+
val dummy_item : Location.t -> item
6559565596
end = struct
6559665597
#1 "ast_structure.ml"
6559765598
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -65648,6 +65649,8 @@ let constraint_ ?(loc=Location.none) (stru : t) (sign : Ast_signature.t) =
6564865649
(Incl.mk ~loc
6564965650
(Mod.constraint_ ~loc (Mod.structure ~loc stru) (Mty.signature ~loc sign)))
6565065651

65652+
let dummy_item loc : item =
65653+
Str.eval ~loc (Ast_literal.val_unit ~loc ())
6565165654
end
6565265655
module Ast_derive : sig
6565365656
#1 "ast_derive.mli"
@@ -112560,6 +112563,15 @@ let rec unsafe_mapper : Bs_ast_mapper.mapper =
112560112563
| Pstr_extension ( ({txt = ("bs.raw"| "raw") ; loc}, payload), _attrs)
112561112564
->
112562112565
Ast_util.handle_raw_structure loc payload
112566+
| Pstr_extension (({txt = ("bs.debugger.chrome" | "debugger.chrome") ;loc}, payload),_)
112567+
->
112568+
if !Js_config.debug then
112569+
let open Ast_helper in
112570+
Str.eval ~loc (Exp.apply ~loc
112571+
(Exp.ident ~loc {txt = Ldot(Ldot (Lident"Belt","Debug"), "setupChromeDebugger");loc} )
112572+
["", Ast_literal.val_unit ~loc ()]
112573+
)
112574+
else Ast_structure.dummy_item loc
112563112575
| Pstr_type (_ :: _ as tdcls ) (* [ {ptype_attributes} as tdcl ] *)->
112564112576
Ast_tdcls.handleTdclsInStru self str tdcls
112565112577
| Pstr_primitive prim
@@ -117127,7 +117139,7 @@ let out_ident ppf s =
117127117139
| "Belt_HashMap" -> "Belt.HashMap"
117128117140
| "Belt_HashMapString" -> "Belt.HashMap.String"
117129117141
| "Belt_HashMapInt" -> "Belt.HashMap.Int"
117130-
117142+
| "Belt_Debug" -> "Belt.Debug"
117131117143
| s ->
117132117144
(match Ext_namespace.try_split_module_name s with
117133117145
| None -> s
@@ -119811,7 +119823,10 @@ let buckle_script_flags : (string * Arg.spec * string) list =
119811119823
)
119812119824
::
119813119825
("-bs-g",
119814-
Arg.Set Js_config.debug,
119826+
Arg.Unit
119827+
(fun _ -> Js_config.debug := true;
119828+
Lexer.replace_directive_bool "DEBUG" true
119829+
),
119815119830
" debug mode"
119816119831
)
119817119832
::

0 commit comments

Comments
 (0)