Skip to content

Compiler libs uncurry ready #6861

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 3 commits into from
Jul 7, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- Convert `caml_format` and `js_math` to `.res`. https://github.com/rescript-lang/rescript-compiler/pull/6834
- Convert `js.ml` files to `.res`. https://github.com/rescript-lang/rescript-compiler/pull/6835
- Remove old `.ml` tests. https://github.com/rescript-lang/rescript-compiler/pull/6847
- Make compiler libs ready for uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6861

#### :nail_care: Polish

Expand Down
4 changes: 2 additions & 2 deletions jscomp/runtime/caml_obj.res
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ and aux_obj_compare = (a: Obj.t, b: Obj.t) => {
}
}

let do_key_a = do_key((a, b, min_key_rhs))
let do_key_b = do_key((b, a, min_key_lhs))
let do_key_a = key => do_key((a, b, min_key_rhs), key)
let do_key_b = key => do_key((b, a, min_key_lhs), key)
O.for_in(a, do_key_a)
O.for_in(b, do_key_b)
let res = switch (min_key_lhs.contents, min_key_rhs.contents) {
Expand Down
80 changes: 52 additions & 28 deletions jscomp/runtime/curry.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

@@uncurried

/* Generated by scripts/curry_gen.ml */
external function_length: 'a => int = "#function_length"
external apply_args: ('a => 'b, array<_>) => 'b = "#apply"
Expand Down Expand Up @@ -89,12 +91,20 @@ external apply8: (
let curry_1 = (o, a0, arity) =>
switch arity {
| 1 => apply1(Obj.magic(o), a0)
| 2 => apply2(Obj.magic(o), a0)
| 3 => apply3(Obj.magic(o), a0)
| 4 => apply4(Obj.magic(o), a0)
| 5 => apply5(Obj.magic(o), a0)
| 6 => apply6(Obj.magic(o), a0)
| 7 => apply7(Obj.magic(o), a0)
| 2 => param => apply2(Obj.magic(o), a0, param)
| 3 => Obj.magic((param, \"param$1") => apply3(Obj.magic(o), a0, param, \"param$1"))
| 4 => Obj.magic((param, \"param$1", \"param$2") =>
apply4(Obj.magic(o), a0, param, \"param$1", \"param$2")
)
| 5 => Obj.magic((param, \"param$1", \"param$2", \"param$3") =>
apply5(Obj.magic(o), a0, param, \"param$1", \"param$2", \"param$3")
)
| 6 => Obj.magic((param, \"param$1", \"param$2", \"param$3", \"param$4") =>
apply6(Obj.magic(o), a0, param, \"param$1", \"param$2", \"param$3", \"param$4")
)
| 7 => Obj.magic((param, \"param$1", \"param$2", \"param$3", \"param$4", \"param$5") =>
apply7(Obj.magic(o), a0, param, \"param$1", \"param$2", \"param$3", \"param$4", \"param$5")
)
| _ => Obj.magic(app(o, [a0]))
}
)
Expand Down Expand Up @@ -124,11 +134,17 @@ let __1 = o => {
switch arity {
| 1 => app(apply1(Obj.magic(o), a0), [a1])
| 2 => apply2(Obj.magic(o), a0, a1)
| 3 => apply3(Obj.magic(o), a0, a1)
| 4 => apply4(Obj.magic(o), a0, a1)
| 5 => apply5(Obj.magic(o), a0, a1)
| 6 => apply6(Obj.magic(o), a0, a1)
| 7 => apply7(Obj.magic(o), a0, a1)
| 3 => param => apply3(Obj.magic(o), a0, a1, param)
| 4 => Obj.magic((param, \"param$1") => apply4(Obj.magic(o), a0, a1, param, \"param$1"))
| 5 => Obj.magic((param, \"param$1", \"param$2") =>
apply5(Obj.magic(o), a0, a1, param, \"param$1", \"param$2")
)
| 6 => Obj.magic((param, \"param$1", \"param$2", \"param$3") =>
apply6(Obj.magic(o), a0, a1, param, \"param$1", \"param$2", \"param$3")
)
| 7 => Obj.magic((param, \"param$1", \"param$2", \"param$3", \"param$4") =>
apply7(Obj.magic(o), a0, a1, param, \"param$1", \"param$2", \"param$3", \"param$4")
)
| _ => Obj.magic(app(o, [a0, a1]))
}
)
Expand All @@ -139,7 +155,7 @@ let _2 = (o, a0, a1) => {
if arity == 2 {
apply2(o, a0, a1)
} else {
curry_2(o, a0, a1, arity)
curry_2(Obj.magic(o), a0, a1, arity)
}
}

Expand All @@ -159,10 +175,14 @@ let __2 = o => {
| 1 => app(apply1(Obj.magic(o), a0), [a1, a2])
| 2 => app(apply2(Obj.magic(o), a0, a1), [a2])
| 3 => apply3(Obj.magic(o), a0, a1, a2)
| 4 => apply4(Obj.magic(o), a0, a1, a2)
| 5 => apply5(Obj.magic(o), a0, a1, a2)
| 6 => apply6(Obj.magic(o), a0, a1, a2)
| 7 => apply7(Obj.magic(o), a0, a1, a2)
| 4 => param => apply4(Obj.magic(o), a0, a1, a2, param)
| 5 => Obj.magic((param, \"param$1") => apply5(Obj.magic(o), a0, a1, a2, param, \"param$1"))
| 6 => Obj.magic((param, \"param$1", \"param$2") =>
apply6(Obj.magic(o), a0, a1, a2, param, \"param$1", \"param$2")
)
| 7 => Obj.magic((param, \"param$1", \"param$2", \"param$3") =>
apply7(Obj.magic(o), a0, a1, a2, param, \"param$1", \"param$2", \"param$3")
)
| _ => Obj.magic(app(o, [a0, a1, a2]))
}
)
Expand All @@ -173,7 +193,7 @@ let _3 = (o, a0, a1, a2) => {
if arity == 3 {
apply3(o, a0, a1, a2)
} else {
curry_3(o, a0, a1, a2, arity)
curry_3(Obj.magic(o), a0, a1, a2, arity)
}
}

Expand All @@ -194,9 +214,11 @@ let __3 = o => {
| 2 => app(apply2(Obj.magic(o), a0, a1), [a2, a3])
| 3 => app(apply3(Obj.magic(o), a0, a1, a2), [a3])
| 4 => apply4(Obj.magic(o), a0, a1, a2, a3)
| 5 => apply5(Obj.magic(o), a0, a1, a2, a3)
| 6 => apply6(Obj.magic(o), a0, a1, a2, a3)
| 7 => apply7(Obj.magic(o), a0, a1, a2, a3)
| 5 => param => apply5(Obj.magic(o), a0, a1, a2, a3, param)
| 6 => Obj.magic((param, \"param$1") => apply6(Obj.magic(o), a0, a1, a2, a3, param, \"param$1"))
| 7 => Obj.magic((param, \"param$1", \"param$2") =>
apply7(Obj.magic(o), a0, a1, a2, a3, param, \"param$1", \"param$2")
)
| _ => Obj.magic(app(o, [a0, a1, a2, a3]))
}
)
Expand All @@ -207,7 +229,7 @@ let _4 = (o, a0, a1, a2, a3) => {
if arity == 4 {
apply4(o, a0, a1, a2, a3)
} else {
curry_4(o, a0, a1, a2, a3, arity)
curry_4(Obj.magic(o), a0, a1, a2, a3, arity)
}
}

Expand All @@ -229,8 +251,10 @@ let __4 = o => {
| 3 => app(apply3(Obj.magic(o), a0, a1, a2), [a3, a4])
| 4 => app(apply4(Obj.magic(o), a0, a1, a2, a3), [a4])
| 5 => apply5(Obj.magic(o), a0, a1, a2, a3, a4)
| 6 => apply6(Obj.magic(o), a0, a1, a2, a3, a4)
| 7 => apply7(Obj.magic(o), a0, a1, a2, a3, a4)
| 6 => param => apply6(Obj.magic(o), a0, a1, a2, a3, a4, param)
| 7 => Obj.magic((param, \"param$1") =>
apply7(Obj.magic(o), a0, a1, a2, a3, a4, param, \"param$1")
)
| _ => Obj.magic(app(o, [a0, a1, a2, a3, a4]))
}
)
Expand All @@ -241,7 +265,7 @@ let _5 = (o, a0, a1, a2, a3, a4) => {
if arity == 5 {
apply5(o, a0, a1, a2, a3, a4)
} else {
curry_5(o, a0, a1, a2, a3, a4, arity)
curry_5(Obj.magic(o), a0, a1, a2, a3, a4, arity)
}
}

Expand All @@ -264,7 +288,7 @@ let __5 = o => {
| 4 => app(apply4(Obj.magic(o), a0, a1, a2, a3), [a4, a5])
| 5 => app(apply5(Obj.magic(o), a0, a1, a2, a3, a4), [a5])
| 6 => apply6(Obj.magic(o), a0, a1, a2, a3, a4, a5)
| 7 => apply7(Obj.magic(o), a0, a1, a2, a3, a4, a5)
| 7 => param => apply7(Obj.magic(o), a0, a1, a2, a3, a4, a5, param)
| _ => Obj.magic(app(o, [a0, a1, a2, a3, a4, a5]))
}
)
Expand All @@ -275,7 +299,7 @@ let _6 = (o, a0, a1, a2, a3, a4, a5) => {
if arity == 6 {
apply6(o, a0, a1, a2, a3, a4, a5)
} else {
curry_6(o, a0, a1, a2, a3, a4, a5, arity)
curry_6(Obj.magic(o), a0, a1, a2, a3, a4, a5, arity)
}
}

Expand Down Expand Up @@ -309,7 +333,7 @@ let _7 = (o, a0, a1, a2, a3, a4, a5, a6) => {
if arity == 7 {
apply7(o, a0, a1, a2, a3, a4, a5, a6)
} else {
curry_7(o, a0, a1, a2, a3, a4, a5, a6, arity)
curry_7(Obj.magic(o), a0, a1, a2, a3, a4, a5, a6, arity)
}
}

Expand Down Expand Up @@ -343,7 +367,7 @@ let _8 = (o, a0, a1, a2, a3, a4, a5, a6, a7) => {
if arity == 8 {
apply8(o, a0, a1, a2, a3, a4, a5, a6, a7)
} else {
curry_8(o, a0, a1, a2, a3, a4, a5, a6, a7, arity)
curry_8(Obj.magic(o), a0, a1, a2, a3, a4, a5, a6, a7, arity)
}
}

Expand Down
4 changes: 2 additions & 2 deletions jscomp/stdlib-406/arg.res
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ let add_help = speclist => {

let usage_b = (buf, speclist, errmsg) => {
Buffer.add_string(buf, `${errmsg}\n`)
List.iter(print_spec(buf), add_help(speclist))
List.iter(x => print_spec(buf, x), add_help(speclist))
}

let usage_string = (speclist, errmsg) => {
Expand Down Expand Up @@ -423,5 +423,5 @@ let align = (~limit=max_int, speclist) => {
let completed = add_help(speclist)
let len = List.fold_left(max_arg_len, 0, completed)
let len = min(len, limit)
List.map(add_padding(len), completed)
List.map(x => add_padding(len, x), completed)
}
10 changes: 5 additions & 5 deletions jscomp/stdlib-406/filename.res
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ module Unix = {
let temp_dir_name = try Sys.getenv("TMPDIR") catch {
| Not_found => "/tmp"
}
let quote = generic_quote("'\\''")
let basename = generic_basename(is_dir_sep, current_dir_name)
let dirname = generic_dirname(is_dir_sep, current_dir_name)
let quote = x => generic_quote("'\\''", x)
let basename = x => generic_basename(is_dir_sep, current_dir_name, x)
let dirname = x => generic_dirname(is_dir_sep, current_dir_name, x)
}

module Win32 = {
Expand Down Expand Up @@ -221,8 +221,8 @@ module Cygwin = {
let check_suffix = Win32.check_suffix
let temp_dir_name = Unix.temp_dir_name
let quote = Unix.quote
let basename = generic_basename(is_dir_sep, current_dir_name)
let dirname = generic_dirname(is_dir_sep, current_dir_name)
let basename = x => generic_basename(is_dir_sep, current_dir_name, x)
let dirname = x => generic_dirname(is_dir_sep, current_dir_name, x)
}

let (
Expand Down
2 changes: 1 addition & 1 deletion jscomp/stdlib-406/genlex.resi
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ type token =
Blanks and newlines are skipped. Comments delimited by [(*] and [*)]
are skipped as well, and can be nested. A {!Stream.Failure} exception
is raised if end of stream is unexpectedly reached.*/
let make_lexer: (list<string>, Stream.t<char>) => Stream.t<token>
let make_lexer: list<string> => (Stream.t<char> => Stream.t<token>)
2 changes: 1 addition & 1 deletion jscomp/stdlib-406/lexing.res
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ let zero_pos = {
}

let from_function = f => {
refill_buff: lex_refill(f, Bytes.create(512)),
refill_buff: x => lex_refill(f, Bytes.create(512), x),
lex_buffer: Bytes.create(1024),
lex_buffer_len: 0,
lex_abs_pos: 0,
Expand Down
4 changes: 2 additions & 2 deletions jscomp/stdlib-406/list.res
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ let rec find_opt = (p, param) =>
}
}

let find_all = p => {
let find_all = (p, l) => {
let rec find = (accu, param) =>
switch param {
| list{} => rev(accu)
Expand All @@ -363,7 +363,7 @@ let find_all = p => {
find(accu, l)
}
}
find(list{})
find(list{}, l)
}

let filter = find_all
Expand Down
4 changes: 2 additions & 2 deletions jscomp/stdlib-406/listLabels.res
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ let rec find_opt = (~f as p, param) =>
}
}

let find_all = (~f as p) => {
let find_all = (~f as p, l) => {
let rec find = (accu, param) =>
switch param {
| list{} => rev(accu)
Expand All @@ -363,7 +363,7 @@ let find_all = (~f as p) => {
find(accu, l)
}
}
find(list{})
find(list{}, l)
}

let filter = find_all
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/a_string_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions jscomp/test/gpr_2608_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jscomp/test/mario_game.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading