Skip to content

Commit faa7363

Browse files
committed
Turn on new uncurried representation for all arities.
1 parent 022f2ee commit faa7363

File tree

17 files changed

+977
-1118
lines changed

17 files changed

+977
-1118
lines changed

jscomp/ml/ast_uncurried.ml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(* Untyped AST *)
22

3-
let new_representation arity = arity = 0 || arity = 5
43

54
let encode_arity_string arity = "Has_arity" ^ string_of_int arity
65
let decode_arity_string arity_s = int_of_string ((String.sub [@doesNotRaise]) arity_s 9 (String.length arity_s - 9))
@@ -11,18 +10,10 @@ let arityType ~loc arity =
1110
Closed None
1211

1312
let uncurriedType ~loc ~arity tArg =
14-
if new_representation arity then
1513
let tArity = arityType ~loc arity in
1614
Ast_helper.Typ.constr ~loc
1715
{ txt = Lident "function$"; loc }
1816
[ tArg; tArity ]
19-
else
20-
Ast_helper.Typ.constr ~loc
21-
{
22-
txt = Ldot (Ldot (Lident "Js", "Fn"), "arity" ^ string_of_int arity);
23-
loc;
24-
}
25-
[ tArg ]
2617

2718
let arity_to_attributes arity =
2819
[
@@ -52,34 +43,18 @@ let rec attributes_to_arity (attrs : Parsetree.attributes) =
5243
| _ -> assert false
5344

5445
let uncurriedFun ~loc ~arity funExpr =
55-
if new_representation arity then
5646
Ast_helper.Exp.construct ~loc
5747
~attrs:(arity_to_attributes arity)
5848
{ txt = Lident "Function$"; loc }
5949
(Some funExpr)
60-
else
61-
Ast_helper.Exp.record ~loc
62-
[
63-
( {
64-
txt = Ldot (Ldot (Lident "Js", "Fn"), "I" ^ string_of_int arity);
65-
loc;
66-
},
67-
funExpr );
68-
]
69-
None
7050

7151
let exprIsUncurriedFun (expr : Parsetree.expression) =
7252
match expr.pexp_desc with
73-
| Pexp_record ([ ({ txt = Ldot (Ldot (Lident "Js", "Fn"), _) }, _e) ], None)
74-
->
75-
true
7653
| Pexp_construct ({ txt = Lident "Function$" }, Some _) -> true
7754
| _ -> false
7855

7956
let exprExtractUncurriedFun (expr : Parsetree.expression) =
8057
match expr.pexp_desc with
81-
| Pexp_record ([ ({ txt = Ldot (Ldot (Lident "Js", "Fn"), _) }, e) ], None) ->
82-
e
8358
| Pexp_construct ({ txt = Lident "Function$" }, Some e) -> e
8459
| _ -> assert false
8560

jscomp/ml/typecore.ml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,14 +2982,6 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex
29822982
tvar || List.mem l ls
29832983
in
29842984
let ignored = ref [] in
2985-
let mk_js_fn arity t =
2986-
if Ast_uncurried.new_representation arity then
2987-
Ast_uncurried.mk_js_fn ~env ~arity t
2988-
else
2989-
let a = "arity" ^ string_of_int arity in
2990-
let lid:Longident.t = Ldot (Ldot (Lident "Js", "Fn"), a) in
2991-
let path = Env.lookup_type lid env in
2992-
newconstr path [t] in
29932985
let has_uncurried_type t =
29942986
match (expand_head env t).desc with
29952987
| Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),a,_),[t],_) ->
@@ -3006,7 +2998,7 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex
30062998
match has_uncurried_type funct.exp_type with
30072999
| None ->
30083000
let arity = List.length sargs in
3009-
let js_fn = mk_js_fn arity (newvar()) in
3001+
let js_fn = Ast_uncurried.mk_js_fn ~env ~arity (newvar()) in
30103002
unify_exp env funct js_fn
30113003
| Some _ -> () in
30123004
let extract_uncurried_type t =
@@ -3025,7 +3017,7 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex
30253017
if uncurried && not fully_applied then
30263018
raise(Error(funct.exp_loc, env,
30273019
Uncurried_arity_mismatch (t, arity, List.length sargs)));
3028-
let newT = if fully_applied then newT else mk_js_fn newarity newT in
3020+
let newT = if fully_applied then newT else Ast_uncurried.mk_js_fn ~env ~arity:newarity newT in
30293021
(fully_applied, newT)
30303022
| _ -> (false, newT)
30313023
in

jscomp/others/js.ml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,39 +74,6 @@
7474
type 'a t = < .. > as 'a
7575
(** JS object type *)
7676

77-
(**/**)
78-
79-
(* internal types for FFI, these types are not used by normal users
80-
Absent cmi file when looking up module alias.
81-
*)
82-
83-
module Fn = struct
84-
type 'a arity1 = { i1 : 'a [@internal] }
85-
type 'a arity2 = { i2 : 'a [@internal] }
86-
type 'a arity3 = { i3 : 'a [@internal] }
87-
type 'a arity4 = { i4 : 'a [@internal] }
88-
type 'a arity5 = { i5 : 'a [@internal] }
89-
type 'a arity6 = { i6 : 'a [@internal] }
90-
type 'a arity7 = { i7 : 'a [@internal] }
91-
type 'a arity8 = { i8 : 'a [@internal] }
92-
type 'a arity9 = { i9 : 'a [@internal] }
93-
type 'a arity10 = { i10 : 'a [@internal] }
94-
type 'a arity11 = { i11 : 'a [@internal] }
95-
type 'a arity12 = { i12 : 'a [@internal] }
96-
type 'a arity13 = { i13 : 'a [@internal] }
97-
type 'a arity14 = { i14 : 'a [@internal] }
98-
type 'a arity15 = { i15 : 'a [@internal] }
99-
type 'a arity16 = { i16 : 'a [@internal] }
100-
type 'a arity17 = { i17 : 'a [@internal] }
101-
type 'a arity18 = { i18 : 'a [@internal] }
102-
type 'a arity19 = { i19 : 'a [@internal] }
103-
type 'a arity20 = { i20 : 'a [@internal] }
104-
type 'a arity21 = { i21 : 'a [@internal] }
105-
type 'a arity22 = { i22 : 'a [@internal] }
106-
end
107-
108-
(**/**)
109-
11077
module MapperRt = Js_mapperRt
11178

11279
module Internal = struct

jscomp/others/release.ninja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ o others/js_obj.cmi others/js_obj.cmj : cc others/js_obj.ml | others/belt_intern
4747
o others/js_option.cmj : cc_cmi others/js_option.ml | others/belt_internals.cmi others/js.cmi others/js_exn.cmj others/js_option.cmi $bsc
4848
o others/js_option.cmi : cc others/js_option.mli | others/belt_internals.cmi others/js.cmi $bsc
4949
o others/js_promise.cmi others/js_promise.cmj : cc others/js_promise.ml | others/belt_internals.cmi others/js.cmi others/js_promise2.cmj $bsc
50-
o others/js_promise2.cmi others/js_promise2.cmj : cc others/js_promise2.res | others/belt_internals.cmi others/js.cmi others/js.cmj $bsc
50+
o others/js_promise2.cmi others/js_promise2.cmj : cc others/js_promise2.res | others/belt_internals.cmi others/js.cmi $bsc
5151
o others/js_re.cmi others/js_re.cmj : cc others/js_re.ml | others/belt_internals.cmi others/js.cmi others/js.cmj $bsc
5252
o others/js_result.cmj : cc_cmi others/js_result.ml | others/belt_internals.cmi others/js.cmi others/js_result.cmi $bsc
5353
o others/js_result.cmi : cc others/js_result.mli | others/belt_internals.cmi others/js.cmi $bsc

jscomp/runtime/js.ml

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -44,81 +44,7 @@
4444
(**/**)
4545
(** Types for JS objects *)
4646
type 'a t = < .. > as 'a
47-
(**/**)
48-
49-
(* internal types for FFI, these types are not used by normal users
50-
Absent cmi file when looking up module alias.
51-
*)
52-
module Fn = struct
53-
type 'a arity1 = {
54-
i1 : 'a [@internal]
55-
}
56-
type 'a arity2 = {
57-
i2 : 'a [@internal]
58-
}
59-
type 'a arity3 = {
60-
i3 : 'a [@internal]
61-
}
62-
type 'a arity4 = {
63-
i4 : 'a [@internal]
64-
}
65-
type 'a arity5 = {
66-
i5 : 'a [@internal]
67-
}
68-
type 'a arity6 = {
69-
i6 : 'a [@internal]
70-
}
71-
type 'a arity7 = {
72-
i7 : 'a [@internal]
73-
}
74-
type 'a arity8 = {
75-
i8 : 'a [@internal]
76-
}
77-
type 'a arity9 = {
78-
i9 : 'a [@internal]
79-
}
80-
type 'a arity10 = {
81-
i10 : 'a [@internal]
82-
}
83-
type 'a arity11 = {
84-
i11 : 'a [@internal]
85-
}
86-
type 'a arity12 = {
87-
i12 : 'a [@internal]
88-
}
89-
type 'a arity13 = {
90-
i13 : 'a [@internal]
91-
}
92-
type 'a arity14 = {
93-
i14 : 'a [@internal]
94-
}
95-
type 'a arity15 = {
96-
i15 : 'a [@internal]
97-
}
98-
type 'a arity16 = {
99-
i16 : 'a [@internal]
100-
}
101-
type 'a arity17 = {
102-
i17 : 'a [@internal]
103-
}
104-
type 'a arity18 = {
105-
i18 : 'a [@internal]
106-
}
107-
type 'a arity19 = {
108-
i19 : 'a [@internal]
109-
}
110-
type 'a arity20 = {
111-
i20 : 'a [@internal]
112-
}
113-
type 'a arity21 = {
114-
i21 : 'a [@internal]
115-
}
116-
type 'a arity22 = {
117-
i22 : 'a [@internal]
118-
}
119-
end
12047

121-
(**/**)
12248
module MapperRt = Js_mapperRt
12349
module Internal = struct
12450
external opaqueFullApply : 'a -> 'a = "%uncurried_apply"

0 commit comments

Comments
 (0)