Skip to content

Commit 00ad78c

Browse files
authored
Merge pull request #3837 from BuckleScript/upgrade_debug_mode
Upgrade debug mode to adapt the changes of local module representation
2 parents 368f913 + 610d091 commit 00ad78c

File tree

12 files changed

+37
-134
lines changed

12 files changed

+37
-134
lines changed

jscomp/core/js_block_runtime.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ let tag_is_zero (tag : J.expression) =
3232
(tag : J.expression)
3333
(tag_info : J.tag_info) =
3434
match tag_info with
35-
| Blk_variant _
36-
| Blk_module _
35+
| Blk_variant _
3736
| Blk_record _
3837
| Blk_constructor _ -> true
3938
#if OCAML_VERSION =~ ">4.03.0" then
4039
| Blk_record_inlined _ -> true
4140
#end
42-
41+
| Blk_module _ -> false
4342
| Blk_tuple
4443
| Blk_array
4544
#if OCAML_VERSION =~ ">4.03.0" then

jscomp/core/js_dump.ml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ let dbg_record f =
115115
dbg_block_dot f ;
116116
P.string f L.block_record
117117

118-
let dbg_local_module f =
119-
dbg_block_dot f;
120-
P.string f L.block_local_module
121118

122119
let dbg_poly_var f =
123120
dbg_block_dot f;
@@ -893,13 +890,13 @@ and expression_desc cxt (level:int) f x : cxt =
893890
E.array mutable_flag
894891
(Ext_list.map el drop_comment) ]
895892
)
896-
| Blk_module labels ->
897-
dbg_local_module f;
898-
P.paren_group f 1 (fun _ -> arguments cxt f
899-
[E.array Immutable
900-
(Ext_list.map labels E.str);
901-
E.array mutable_flag
902-
(Ext_list.map el drop_comment)])
893+
| Blk_module labels ->
894+
assert false
895+
(*
896+
This can not happen, see the pattern match on previous branch
897+
TODO: we still need clean up local module compilation
898+
to make it more obvious
899+
*)
903900
| Blk_variant name ->
904901
dbg_poly_var f;
905902
P.paren_group f 1 (fun _ -> arguments cxt f [

jscomp/core/js_dump_lit.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let caml_block_create = "__"
9090

9191
(** debug symbols *)
9292
let block_record = "record"
93-
let block_local_module = "localModule"
93+
9494
let block_poly_var = "polyVar"
9595
let block_variant = "variant"
9696
let block_simple_variant = "simpleVariant"

jscomp/others/belt_Debug.mli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
val setupChromeDebugger : unit -> unit
4+
[@@ocaml.deprecated "This call is redundant, simply remove it"]

jscomp/runtime/block.ml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,5 @@ let __ tag block =
3535
Caml_obj_extern.set_tag block tag; block
3636

3737

38-
type symbol
39-
40-
41-
external cacheSymbol : string -> symbol = "for"
42-
[@@bs.scope "Symbol"] [@@bs.val]
43-
external addProp : 'a -> symbol -> <value: 'b> Js.t -> 'a =
44-
"defineProperty" [@@bs.scope "Object"] [@@bs.val]
45-
46-
47-
(* It won't affect [Object.keys] using [Object.defineProperty*)
48-
let record meta xs =
49-
xs |.addProp (cacheSymbol "BsRecord") [%obj {value = meta}]
50-
51-
let variant meta tag xs =
52-
xs |. Caml_obj_extern.set_tag tag;
53-
xs |. addProp (cacheSymbol "BsVariant") [%obj {value = meta }]
54-
55-
let simpleVariant meta xs =
56-
xs |. addProp (cacheSymbol "BsVariant") [%obj {value = meta }]
57-
58-
let localModule meta xs =
59-
xs |. addProp (cacheSymbol "BsLocalModule") [%obj {value = meta}]
60-
61-
let polyVar meta xs =
62-
xs |. addProp (cacheSymbol "BsPolyVar") [%obj {value = meta}]
6338

6439

jscomp/runtime/block.mli

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,4 @@ type obj = Caml_obj_extern.t
3131

3232
val __ : int -> obj -> obj
3333

34-
val record : 'a -> obj -> obj
35-
36-
val variant : 'a -> int -> obj -> obj
37-
38-
val simpleVariant : 'a -> obj -> obj
39-
40-
val localModule : 'a -> obj -> obj
41-
42-
val polyVar : 'a -> obj -> obj
4334

jscomp/runtime/caml_chrome_debugger.ml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ var formatter = {
128128
} else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined){
129129
return variantPreview(x, recordVariant)
130130
} else if (isOCamlExceptionOrExtension(x)){
131-
return ['div',{}, `${x[0][0]}(…)`]
132-
} else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined){
133-
return ['div', {}, 'Module' ]
131+
return ['div',{}, `${x[0][0]}(…)`]
134132
} else if ((recordPolyVar = x[Symbol.for('BsPolyVar')] ) !== undefined){
135133
return ['div', {}, `\`${recordPolyVar}#${x[0]}`]
136134
}
@@ -147,8 +145,6 @@ var formatter = {
147145
return recordVariant
148146
} else if(isOCamlExceptionOrExtension(x)){
149147
return true
150-
} else if ((recordModule = x[Symbol.for('BsLocalModule')] ) !== undefined){
151-
return true
152148
} else if( (recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined){
153149
return true
154150
}
@@ -220,9 +216,6 @@ let simpleVariant meta xs =
220216
setupOnce ();
221217
xs |. addProp (cacheSymbol "BsVariant") [%obj {value = meta }]
222218

223-
let localModule meta xs =
224-
setupOnce ();
225-
xs |. addProp (cacheSymbol "BsLocalModule") [%obj {value = meta}]
226219

227220
let polyVar meta xs =
228221
setupOnce ();

jscomp/runtime/caml_chrome_debugger.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ val variant : 'a -> int -> obj -> obj
3131

3232
val simpleVariant : 'a -> obj -> obj
3333

34-
val localModule : 'a -> obj -> obj
34+
3535

3636
val polyVar : 'a -> obj -> obj

lib/4.02.3/unstable/js_compiler.ml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80191,12 +80191,11 @@ let tag_is_zero (tag : J.expression) =
8019180191
(tag : J.expression)
8019280192
(tag_info : J.tag_info) =
8019380193
match tag_info with
80194-
| Blk_variant _
80195-
| Blk_module _
80194+
| Blk_variant _
8019680195
| Blk_record _
8019780196
| Blk_constructor _ -> true
8019880197

80199-
80198+
| Blk_module _ -> false
8020080199
| Blk_tuple
8020180200
| Blk_array
8020280201

@@ -80345,7 +80344,7 @@ let caml_block_create = "__"
8034580344

8034680345
(** debug symbols *)
8034780346
let block_record = "record"
80348-
let block_local_module = "localModule"
80347+
8034980348
let block_poly_var = "polyVar"
8035080349
let block_variant = "variant"
8035180350
let block_simple_variant = "simpleVariant"
@@ -84381,9 +84380,6 @@ let dbg_record f =
8438184380
dbg_block_dot f ;
8438284381
P.string f L.block_record
8438384382

84384-
let dbg_local_module f =
84385-
dbg_block_dot f;
84386-
P.string f L.block_local_module
8438784383

8438884384
let dbg_poly_var f =
8438984385
dbg_block_dot f;
@@ -85159,13 +85155,13 @@ and expression_desc cxt (level:int) f x : cxt =
8515985155
E.array mutable_flag
8516085156
(Ext_list.map el drop_comment) ]
8516185157
)
85162-
| Blk_module labels ->
85163-
dbg_local_module f;
85164-
P.paren_group f 1 (fun _ -> arguments cxt f
85165-
[E.array Immutable
85166-
(Ext_list.map labels E.str);
85167-
E.array mutable_flag
85168-
(Ext_list.map el drop_comment)])
85158+
| Blk_module labels ->
85159+
assert false
85160+
(*
85161+
This can not happen, see the pattern match on previous branch
85162+
TODO: we still need clean up local module compilation
85163+
to make it more obvious
85164+
*)
8516985165
| Blk_variant name ->
8517085166
dbg_poly_var f;
8517185167
P.paren_group f 1 (fun _ -> arguments cxt f [

lib/4.02.3/whole_compiler.ml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84846,12 +84846,11 @@ let tag_is_zero (tag : J.expression) =
8484684846
(tag : J.expression)
8484784847
(tag_info : J.tag_info) =
8484884848
match tag_info with
84849-
| Blk_variant _
84850-
| Blk_module _
84849+
| Blk_variant _
8485184850
| Blk_record _
8485284851
| Blk_constructor _ -> true
8485384852

84854-
84853+
| Blk_module _ -> false
8485584854
| Blk_tuple
8485684855
| Blk_array
8485784856

@@ -85000,7 +84999,7 @@ let caml_block_create = "__"
8500084999

8500185000
(** debug symbols *)
8500285001
let block_record = "record"
85003-
let block_local_module = "localModule"
85002+
8500485003
let block_poly_var = "polyVar"
8500585004
let block_variant = "variant"
8500685005
let block_simple_variant = "simpleVariant"
@@ -85593,9 +85592,6 @@ let dbg_record f =
8559385592
dbg_block_dot f ;
8559485593
P.string f L.block_record
8559585594

85596-
let dbg_local_module f =
85597-
dbg_block_dot f;
85598-
P.string f L.block_local_module
8559985595

8560085596
let dbg_poly_var f =
8560185597
dbg_block_dot f;
@@ -86371,13 +86367,13 @@ and expression_desc cxt (level:int) f x : cxt =
8637186367
E.array mutable_flag
8637286368
(Ext_list.map el drop_comment) ]
8637386369
)
86374-
| Blk_module labels ->
86375-
dbg_local_module f;
86376-
P.paren_group f 1 (fun _ -> arguments cxt f
86377-
[E.array Immutable
86378-
(Ext_list.map labels E.str);
86379-
E.array mutable_flag
86380-
(Ext_list.map el drop_comment)])
86370+
| Blk_module labels ->
86371+
assert false
86372+
(*
86373+
This can not happen, see the pattern match on previous branch
86374+
TODO: we still need clean up local module compilation
86375+
to make it more obvious
86376+
*)
8638186377
| Blk_variant name ->
8638286378
dbg_poly_var f;
8638386379
P.paren_group f 1 (fun _ -> arguments cxt f [

0 commit comments

Comments
 (0)