Skip to content

bypass some types in monkey patching #4919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions jscomp/core/j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type property_name = Js_op.property_name

type label = string

and required_modules = module_id list

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

Expand All @@ -74,6 +73,7 @@ and ident = Ident.t (* we override `method ident` *)
and module_id = {
id : ident; kind : Js_op.kind
}
and required_modules = module_id list
and vident =
| Id of ident
| Qualified of module_id * string option
Expand Down Expand Up @@ -273,7 +273,14 @@ and finish_ident_expression = expression (* pure *)
}
]}
*)
and case_clause = {
switch_body : block ;
should_break : bool ; (* true means break *)
comment : string option ;
}

and string_clause = string * case_clause
and int_clause = int * case_clause

and statement_desc =
| Block of block
Expand Down Expand Up @@ -325,13 +332,6 @@ and variable_declaration = {
property : property;
ident_info : ident_info;
}
and string_clause = string * case_clause
and int_clause = int * case_clause
and case_clause = {
switch_body : block ;
should_break : bool ; (* true means break *)
comment : string option ;
}

(* TODO: For efficency: block should not be a list, it should be able to
be concatenated in both ways
Expand All @@ -350,4 +350,26 @@ and deps_program =
modules : required_modules ;
side_effect : string option (* None: no, Some reason *)
}
[@@deriving]
[@@deriving {excludes = [|
deps_program ;
int_clause;
string_clause ;
for_direction;
(* exception_ident; *)
for_direction;
expression_desc;
statement_desc;
for_ident_expression;
label;
finish_ident_expression;
property_map;
length_object;
(* for_ident; *)
required_modules;
case_clause
|] }]
(*
FIXME: customize for each code generator
for each code generator, we can provide a white-list
so that we can achieve the optimal
*)
8 changes: 4 additions & 4 deletions jscomp/core/js_fold.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
| [] -> _self
| _x :: _x_i1 -> let _self = _f_a _self _x in let _self = _self#list _f_a _x_i1 in _self
method label : label -> 'self_type = unknown _self
method required_modules : required_modules -> 'self_type = list (fun _self -> _self#module_id) _self
method ident : ident -> 'self_type = unknown _self
method module_id : module_id -> 'self_type = fun { id = _x0;kind = _x1} -> let _self = _self#ident _x0 in _self
method required_modules : required_modules -> 'self_type = list (fun _self -> _self#module_id) _self
method vident : vident -> 'self_type = function
| Id ( _x0) ->
let _self = _self#ident _x0 in
Expand Down Expand Up @@ -127,6 +127,9 @@ let _self = _self#property_map _x0 in
|Null -> _self
method for_ident_expression : for_ident_expression -> 'self_type = _self#expression
method finish_ident_expression : finish_ident_expression -> 'self_type = _self#expression
method case_clause : case_clause -> 'self_type = fun { switch_body = _x0;should_break = _x1;comment = _x2} -> let _self = _self#block _x0 in _self
method string_clause : string_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
method int_clause : int_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
method statement_desc : statement_desc -> 'self_type = function
| Block ( _x0) ->
let _self = _self#block _x0 in
Expand Down Expand Up @@ -184,9 +187,6 @@ method expression : expression -> 'self_type = fun { expression_desc = _x0;comme
method statement : statement -> 'self_type = fun { statement_desc = _x0;comment = _x1} -> let _self = _self#statement_desc _x0 in _self
method variable_declaration : variable_declaration -> 'self_type = fun { ident = _x0;value = _x1;property = _x2;ident_info = _x3} -> let _self = _self#ident _x0 in
let _self = option (fun _self -> _self#expression) _self _x1 in _self
method string_clause : string_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
method int_clause : int_clause -> 'self_type = fun ( _x0,_x1) -> let _self = _self#case_clause _x1 in _self
method case_clause : case_clause -> 'self_type = fun { switch_body = _x0;should_break = _x1;comment = _x2} -> let _self = _self#block _x0 in _self
method block : block -> 'self_type = list (fun _self -> _self#statement) _self
method program : program -> 'self_type = fun { block = _x0;exports = _x1;export_set = _x2} -> let _self = _self#block _x0 in _self
method deps_program : deps_program -> 'self_type = fun { program = _x0;modules = _x1;side_effect = _x2} -> let _self = _self#program _x0 in
Expand Down
120 changes: 0 additions & 120 deletions jscomp/core/js_iter.ml

This file was deleted.

Loading