Skip to content

Commit a4ccf25

Browse files
authored
Merge pull request #4919 from rescript-lang/bypass
bypass some types in monkey patching
2 parents db47e9e + bbf93c9 commit a4ccf25

31 files changed

+2170
-2486
lines changed

jscomp/core/j.ml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type property_name = Js_op.property_name
6161

6262
type label = string
6363

64-
and required_modules = module_id list
6564

6665
and ident = Ident.t (* we override `method ident` *)
6766

@@ -74,6 +73,7 @@ and ident = Ident.t (* we override `method ident` *)
7473
and module_id = {
7574
id : ident; kind : Js_op.kind
7675
}
76+
and required_modules = module_id list
7777
and vident =
7878
| Id of ident
7979
| Qualified of module_id * string option
@@ -273,7 +273,14 @@ and finish_ident_expression = expression (* pure *)
273273
}
274274
]}
275275
*)
276+
and case_clause = {
277+
switch_body : block ;
278+
should_break : bool ; (* true means break *)
279+
comment : string option ;
280+
}
276281

282+
and string_clause = string * case_clause
283+
and int_clause = int * case_clause
277284

278285
and statement_desc =
279286
| Block of block
@@ -325,13 +332,6 @@ and variable_declaration = {
325332
property : property;
326333
ident_info : ident_info;
327334
}
328-
and string_clause = string * case_clause
329-
and int_clause = int * case_clause
330-
and case_clause = {
331-
switch_body : block ;
332-
should_break : bool ; (* true means break *)
333-
comment : string option ;
334-
}
335335

336336
(* TODO: For efficency: block should not be a list, it should be able to
337337
be concatenated in both ways
@@ -350,4 +350,26 @@ and deps_program =
350350
modules : required_modules ;
351351
side_effect : string option (* None: no, Some reason *)
352352
}
353-
[@@deriving]
353+
[@@deriving {excludes = [|
354+
deps_program ;
355+
int_clause;
356+
string_clause ;
357+
for_direction;
358+
(* exception_ident; *)
359+
for_direction;
360+
expression_desc;
361+
statement_desc;
362+
for_ident_expression;
363+
label;
364+
finish_ident_expression;
365+
property_map;
366+
length_object;
367+
(* for_ident; *)
368+
required_modules;
369+
case_clause
370+
|] }]
371+
(*
372+
FIXME: customize for each code generator
373+
for each code generator, we can provide a white-list
374+
so that we can achieve the optimal
375+
*)

jscomp/core/js_fold.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
| [] -> _self
2121
| _x :: _x_i1 -> let _self = _f_a _self _x in let _self = _self#list _f_a _x_i1 in _self
2222
method label : label -> 'self_type = unknown _self
23-
method required_modules : required_modules -> 'self_type = list (fun _self -> _self#module_id) _self
2423
method ident : ident -> 'self_type = unknown _self
2524
method module_id : module_id -> 'self_type = fun { id = _x0;kind = _x1} -> let _self = _self#ident _x0 in _self
25+
method required_modules : required_modules -> 'self_type = list (fun _self -> _self#module_id) _self
2626
method vident : vident -> 'self_type = function
2727
| Id ( _x0) ->
2828
let _self = _self#ident _x0 in
@@ -127,6 +127,9 @@ let _self = _self#property_map _x0 in
127127
|Null -> _self
128128
method for_ident_expression : for_ident_expression -> 'self_type = _self#expression
129129
method finish_ident_expression : finish_ident_expression -> 'self_type = _self#expression
130+
method case_clause : case_clause -> 'self_type = fun { switch_body = _x0;should_break = _x1;comment = _x2} -> let _self = _self#block _x0 in _self
131+
method string_clause : string_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
132+
method int_clause : int_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
130133
method statement_desc : statement_desc -> 'self_type = function
131134
| Block ( _x0) ->
132135
let _self = _self#block _x0 in
@@ -184,9 +187,6 @@ method expression : expression -> 'self_type = fun { expression_desc = _x0;comme
184187
method statement : statement -> 'self_type = fun { statement_desc = _x0;comment = _x1} -> let _self = _self#statement_desc _x0 in _self
185188
method variable_declaration : variable_declaration -> 'self_type = fun { ident = _x0;value = _x1;property = _x2;ident_info = _x3} -> let _self = _self#ident _x0 in
186189
let _self = option (fun _self -> _self#expression) _self _x1 in _self
187-
method string_clause : string_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
188-
method int_clause : int_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
189-
method case_clause : case_clause -> 'self_type = fun { switch_body = _x0;should_break = _x1;comment = _x2} -> let _self = _self#block _x0 in _self
190190
method block : block -> 'self_type = list (fun _self -> _self#statement) _self
191191
method program : program -> 'self_type = fun { block = _x0;exports = _x1;export_set = _x2} -> let _self = _self#block _x0 in _self
192192
method deps_program : deps_program -> 'self_type = fun { program = _x0;modules = _x1;side_effect = _x2} -> let _self = _self#program _x0 in

jscomp/core/js_iter.ml

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)