Skip to content

Commit 1dd34f1

Browse files
authored
Merge pull request #4969 from rescript-lang/clean_downgrade
continue clean up since removal of classes
2 parents 1fe7d23 + 760c74c commit 1dd34f1

File tree

7 files changed

+67
-1304
lines changed

7 files changed

+67
-1304
lines changed

jscomp/core/lam_convert.ml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
701701

702702
| "#fn_mk" -> Pjs_fn_make (Ext_pervasives.nat_of_string_exn p.prim_native_name)
703703
| "#fn_method" -> Pjs_fn_method
704-
| "#unsafe_downgrade" -> Pjs_unsafe_downgrade {name = Ext_string.empty; loc ; setter = false}
704+
| "#unsafe_downgrade" -> Pjs_unsafe_downgrade {name = Ext_string.empty; setter = false}
705705
| _ -> Location.raise_errorf ~loc
706706
"@{<error>Error:@} internal error, using unrecognized primitive %s" s
707707
in
@@ -816,27 +816,23 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
816816
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
817817
| Lassign (id, body) ->
818818
Lam.assign id (convert_aux body)
819-
| Lsend (kind, _,b,ls, _loc) ->
819+
| Lsend (Public(Some name), _, obj, _, _loc) ->
820820
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
821-
(match convert_aux b with
822-
| Lprim {primitive = Pjs_unsafe_downgrade {loc}; args}
821+
(match convert_aux obj with
822+
| Lprim {primitive = Pjs_unsafe_downgrade _; args;loc}
823823
->
824-
begin match kind, ls with
825-
| Public (Some name), [] ->
826824
let setter = Ext_string.ends_with name Literals.setter_suffix in
827825
let property =
828826
if setter then
829827
Lam_methname.translate
830828
(String.sub name 0
831829
(String.length name - Literals.setter_suffix_len))
832830
else Lam_methname.translate name in
833-
prim ~primitive:(Pjs_unsafe_downgrade {name = property;loc; setter})
834-
~args loc
835-
| _ -> assert false
836-
end
831+
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
832+
~args loc
837833
| _ ->
838834
assert false)
839-
835+
| Lsend _ -> assert false
840836
| Levent _ ->
841837
(* disabled by upstream*)
842838
assert false

jscomp/core/lam_primitive.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ type t =
115115
{
116116
name : string ;
117117
setter : bool;
118-
loc : Location.t;
119118
}
120119
| Pinit_mod
121120
| Pupdate_mod
@@ -280,7 +279,7 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
280279
| Pasrint64 -> rhs = Pasrint64
281280
| Pint64comp ( comparison) -> (match rhs with Pint64comp(comparison1) -> Lam_compat.eq_comparison comparison comparison1 | _ -> false)
282281
| Pctconst compile_time_constant -> (match rhs with Pctconst compile_time_constant1 -> Lam_compat.eq_compile_time_constant compile_time_constant compile_time_constant1 | _ -> false)
283-
| Pjs_unsafe_downgrade {name; loc=_; setter } -> (match rhs with Pjs_unsafe_downgrade rhs -> name = rhs.name && setter = rhs.setter | _ -> false)
282+
| Pjs_unsafe_downgrade {name; setter } -> (match rhs with Pjs_unsafe_downgrade rhs -> name = rhs.name && setter = rhs.setter | _ -> false)
284283
| Pjs_fn_make i -> (match rhs with Pjs_fn_make i1 -> i = i1 | _ -> false)
285284
| Pvoid_run -> rhs = Pvoid_run
286285
| Pfull_apply -> rhs = Pfull_apply

jscomp/core/lam_primitive.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ type t =
112112
{
113113
name : string ;
114114
setter : bool;
115-
loc : Location.t;
116115
}
117116
| Pinit_mod
118117
| Pupdate_mod

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72685,6 +72685,7 @@ let try_ids = Hashtbl.create 8
7268572685

7268672686
let rec transl_exp e =
7268772687
List.iter (Translattribute.check_attribute e) e.exp_attributes;
72688+
7268872689
let eval_once =
7268972690
(* Whether classes for immediate objects must be cached *)
7269072691
match e.exp_desc with
@@ -73008,6 +73009,7 @@ and transl_exp0 e =
7300873009
| Texp_for(param, _, low, high, dir, body) ->
7300973010
Lfor(param, transl_exp low, transl_exp high, dir,
7301073011
event_before body (transl_exp body))
73012+
7301173013
| Texp_send(_, _, Some exp) -> transl_exp exp
7301273014
| Texp_send(expr, met, None) ->
7301373015
let obj = transl_exp expr in
@@ -73020,6 +73022,7 @@ and transl_exp0 e =
7302073022
Lsend (kind, tag, obj, cache, e.exp_loc)
7302173023
in
7302273024
event_after e lam
73025+
7302373026
| Texp_new (cl, {Location.loc=loc}, _) ->
7302473027
Lapply{ap_should_be_tailcall=false;
7302573028
ap_loc=loc;
@@ -73033,6 +73036,7 @@ and transl_exp0 e =
7303373036
| Texp_setinstvar(path_self, path, _, expr) ->
7303473037
transl_setinstvar e.exp_loc (transl_normal_path path_self) path expr
7303573038
| Texp_override(path_self, modifs) ->
73039+
7303673040
let cpy = Ident.create "copy" in
7303773041
Llet(Strict, Pgenval, cpy,
7303873042
Lapply{ap_should_be_tailcall=false;
@@ -73047,6 +73051,7 @@ and transl_exp0 e =
7304773051
(Lvar cpy) path expr, rem))
7304873052
modifs
7304973053
(Lvar cpy))
73054+
7305073055
| Texp_letmodule(id, loc, modl, body) ->
7305173056
let defining_expr =
7305273057

@@ -80216,7 +80221,7 @@ open Typedtree
8021680221
open Lambda
8021780222
open Translobj
8021880223
open Translcore
80219-
open Translclass
80224+
8022080225

8022180226
type error =
8022280227
Circular_dependency of Ident.t
@@ -80561,7 +80566,7 @@ let transl_class_bindings cl_list =
8056180566
(ids,
8056280567
List.map
8056380568
(fun ({ci_id_class=id; ci_expr=cl; ci_virt=vf}, meths) ->
80564-
(id, transl_class ids id meths cl vf))
80569+
(id, Translclass.transl_class ids id meths cl vf))
8056580570
cl_list)
8056680571

8056780572
(* Compile one or more functors, merging curried functors to produce
@@ -80823,13 +80828,15 @@ and transl_structure loc fields cc rootpath final_env = function
8082380828
body
8082480829
in
8082580830
lam, size
80831+
8082680832
| Tstr_class cl_list ->
8082780833
let (ids, class_bindings) = transl_class_bindings cl_list in
8082880834
let body, size =
8082980835
transl_structure loc (List.rev_append ids fields)
8083080836
cc rootpath final_env rem
8083180837
in
8083280838
Lletrec(class_bindings, body), size
80839+
8083380840
| Tstr_include incl ->
8083480841
let ids = bound_value_identifiers incl.incl_type in
8083580842
let modl = incl.incl_mod in
@@ -81163,6 +81170,7 @@ let transl_store_structure glob map prims str =
8116381170
bindings
8116481171
(Lsequence(store_idents Location.none ids,
8116581172
transl_store rootpath (add_idents true ids subst) rem))
81173+
8116681174
| Tstr_class cl_list ->
8116781175
let (ids, class_bindings) = transl_class_bindings cl_list in
8116881176
let lam =
@@ -81426,12 +81434,14 @@ let transl_toplevel_item item =
8142681434
(fun id modl _loc -> transl_module Tcoerce_none (Some(Pident id)) modl)
8142781435
bindings
8142881436
(make_sequence toploop_setvalue_id idents)
81437+
8142981438
| Tstr_class cl_list ->
8143081439
(* we need to use unique names for the classes because there might
8143181440
be a value named identically *)
8143281441
let (ids, class_bindings) = transl_class_bindings cl_list in
8143381442
List.iter set_toplevel_unique_name ids;
8143481443
Lletrec(class_bindings, make_sequence toploop_setvalue_id ids)
81444+
8143581445
| Tstr_include incl ->
8143681446
let ids = bound_value_identifiers incl.incl_type in
8143781447
let modl = incl.incl_mod in
@@ -95427,7 +95437,6 @@ type t =
9542795437
{
9542895438
name : string ;
9542995439
setter : bool;
95430-
loc : Location.t;
9543195440
}
9543295441
| Pinit_mod
9543395442
| Pupdate_mod
@@ -95580,7 +95589,6 @@ type t =
9558095589
{
9558195590
name : string ;
9558295591
setter : bool;
95583-
loc : Location.t;
9558495592
}
9558595593
| Pinit_mod
9558695594
| Pupdate_mod
@@ -95745,7 +95753,7 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
9574595753
| Pasrint64 -> rhs = Pasrint64
9574695754
| Pint64comp ( comparison) -> (match rhs with Pint64comp(comparison1) -> Lam_compat.eq_comparison comparison comparison1 | _ -> false)
9574795755
| Pctconst compile_time_constant -> (match rhs with Pctconst compile_time_constant1 -> Lam_compat.eq_compile_time_constant compile_time_constant compile_time_constant1 | _ -> false)
95748-
| Pjs_unsafe_downgrade {name; loc=_; setter } -> (match rhs with Pjs_unsafe_downgrade rhs -> name = rhs.name && setter = rhs.setter | _ -> false)
95756+
| Pjs_unsafe_downgrade {name; setter } -> (match rhs with Pjs_unsafe_downgrade rhs -> name = rhs.name && setter = rhs.setter | _ -> false)
9574995757
| Pjs_fn_make i -> (match rhs with Pjs_fn_make i1 -> i = i1 | _ -> false)
9575095758
| Pvoid_run -> rhs = Pvoid_run
9575195759
| Pfull_apply -> rhs = Pfull_apply
@@ -395027,7 +395035,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
395027395035

395028395036
| "#fn_mk" -> Pjs_fn_make (Ext_pervasives.nat_of_string_exn p.prim_native_name)
395029395037
| "#fn_method" -> Pjs_fn_method
395030-
| "#unsafe_downgrade" -> Pjs_unsafe_downgrade {name = Ext_string.empty; loc ; setter = false}
395038+
| "#unsafe_downgrade" -> Pjs_unsafe_downgrade {name = Ext_string.empty; setter = false}
395031395039
| _ -> Location.raise_errorf ~loc
395032395040
"@{<error>Error:@} internal error, using unrecognized primitive %s" s
395033395041
in
@@ -395142,27 +395150,23 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
395142395150
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
395143395151
| Lassign (id, body) ->
395144395152
Lam.assign id (convert_aux body)
395145-
| Lsend (kind, _,b,ls, _loc) ->
395153+
| Lsend (Public(Some name), _, obj, _, _loc) ->
395146395154
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
395147-
(match convert_aux b with
395148-
| Lprim {primitive = Pjs_unsafe_downgrade {loc}; args}
395155+
(match convert_aux obj with
395156+
| Lprim {primitive = Pjs_unsafe_downgrade _; args;loc}
395149395157
->
395150-
begin match kind, ls with
395151-
| Public (Some name), [] ->
395152395158
let setter = Ext_string.ends_with name Literals.setter_suffix in
395153395159
let property =
395154395160
if setter then
395155395161
Lam_methname.translate
395156395162
(String.sub name 0
395157395163
(String.length name - Literals.setter_suffix_len))
395158395164
else Lam_methname.translate name in
395159-
prim ~primitive:(Pjs_unsafe_downgrade {name = property;loc; setter})
395160-
~args loc
395161-
| _ -> assert false
395162-
end
395165+
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
395166+
~args loc
395163395167
| _ ->
395164395168
assert false)
395165-
395169+
| Lsend _ -> assert false
395166395170
| Levent _ ->
395167395171
(* disabled by upstream*)
395168395172
assert false

0 commit comments

Comments
 (0)