From 5907823bde96901eadc02983428464803658b47e Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 23 Sep 2024 13:11:25 +0200 Subject: [PATCH] WIP --- .github/workflows/build.yml | 14 +++++------- compiler/lib/magic_number.ml | 2 +- ppx/ppx_js/tests/ppx.mlt | 18 +++++++-------- runtime/array.js | 43 ++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c917e1f5a..31ed27ce87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,17 +49,17 @@ jobs: skip-test: false skip-doc: true - os: ubuntu-latest - ocaml-compiler: "ocaml-variants.5.3.0+trunk" + ocaml-compiler: "ocaml-variants.5.3.0~alpha1" skip-effects: false skip-test: false skip-doc: false - os: macos-latest - ocaml-compiler: "ocaml-variants.5.3.0+trunk" + ocaml-compiler: "ocaml-variants.5.3.0~alpha1" skip-effects: true skip-test: false skip-doc: true - os: windows-latest - ocaml-compiler: "ocaml-variants.5.3.0+trunk" + ocaml-compiler: "ocaml-variants.5.3.0~alpha1" skip-effects: false skip-test: false skip-doc: true @@ -92,12 +92,10 @@ jobs: - run: opam install conf-pkg-config if: runner.os == 'Windows' - - run: opam pin add ppxlib git+https://github.com/NathanReb/ppxlib.git#trunk-support-503 --no-action - if: ${{ matrix.ocaml-compiler == 'ocaml-variants.5.3.0+trunk' }} - - run: opam pin add base git+https://github.com/hhugo/base.git#trunk-support-503 --no-action - if: ${{ matrix.ocaml-compiler == 'ocaml-variants.5.3.0+trunk' }} + - run: opam pin add ppxlib --dev --no-action + if: ${{ matrix.ocaml-compiler == 'ocaml-variants.5.3.0~alpha1' }} - run: opam pin add ppxlib_jane git+https://github.com/hhugo/ppxlib_jane.git#trunk-support-503 --no-action - if: ${{ matrix.ocaml-compiler == 'ocaml-variants.5.3.0+trunk' }} + if: ${{ matrix.ocaml-compiler == 'ocaml-variants.5.3.0~alpha1' }} - run: opam pin add ./ --no-action diff --git a/compiler/lib/magic_number.ml b/compiler/lib/magic_number.ml index 26c9d53dea..e476410004 100644 --- a/compiler/lib/magic_number.ml +++ b/compiler/lib/magic_number.ml @@ -79,7 +79,7 @@ let v = | 5 :: 02 :: _ -> 34 | 5 :: 03 :: _ -> 35 | _ -> - if Ocaml_version.compare current [ 4; 08 ] < 0 + if Ocaml_version.compare current [ 4; 8 ] < 0 then failwith "OCaml version unsupported. Upgrade to OCaml 4.08 or newer." else ( assert (Ocaml_version.compare current [ 5; 4 ] >= 0); diff --git a/ppx/ppx_js/tests/ppx.mlt b/ppx/ppx_js/tests/ppx.mlt index e1c1510135..02d7850ebf 100644 --- a/ppx/ppx_js/tests/ppx.mlt +++ b/ppx/ppx_js/tests/ppx.mlt @@ -102,7 +102,7 @@ fun (obj : int) -> obj##m [%%expect {| Line _, characters 19-22: -Error: This expression has type int but an expression was expected of type +Error: The value obj has type int but an expression was expected of type < .. > Js_of_ocaml.Js.t |}] @@ -122,7 +122,7 @@ fun (obj : < m : float Js.prop > Js.t) -> obj##m [%%expect {| Line _, characters 42-48: -Error: This expression has type +Error: The method call x#m has type float Js_of_ocaml.Js.prop = < get : float; set : float -> unit > Js_of_ocaml.Js.gen_prop but an expression was expected of type 'res Js_of_ocaml.Js.meth @@ -144,7 +144,7 @@ fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m + 1 [%%expect {| Line _, characters 47-53: -Error: This expression has type int -> int Js_of_ocaml.Js.meth +Error: The method call x#m has type int -> int Js_of_ocaml.Js.meth but an expression was expected of type 'res Js_of_ocaml.Js.meth |}] @@ -154,7 +154,7 @@ fun (obj : < m : int Js.meth > Js.t) -> obj##m 1 [%%expect {| Line _, characters 40-46: -Error: This expression has type int Js_of_ocaml.Js.meth +Error: The method call x#m has type int Js_of_ocaml.Js.meth but an expression was expected of type int -> 'res Js_of_ocaml.Js.meth |}] @@ -189,7 +189,7 @@ fun (obj : int) -> obj##.p [%%expect {| Line _, characters 19-22: -Error: This expression has type int but an expression was expected of type +Error: The value obj has type int but an expression was expected of type < .. > Js_of_ocaml.Js.t |}] @@ -209,7 +209,7 @@ fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##.p + 1 [%%expect {| Line _, characters 58-59: -Error: This expression has type +Error: The method call x#p has type float Js_of_ocaml.Js.writeonly_prop = < set : float -> unit > Js_of_ocaml.Js.gen_prop but an expression was expected of type @@ -235,7 +235,7 @@ fun (obj : int) -> obj##.p := 2 [%%expect {| Line _, characters 19-22: -Error: This expression has type int but an expression was expected of type +Error: The value obj has type int but an expression was expected of type < .. > Js_of_ocaml.Js.t |}] @@ -255,7 +255,7 @@ fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##.p := 1 [%%expect {| Line _, characters 51-58: -Error: This expression has type +Error: The method call x#p has type float Js_of_ocaml.Js.readonly_prop = < get : float > Js_of_ocaml.Js.gen_prop but an expression was expected of type @@ -269,7 +269,7 @@ fun (obj : < p : float Js.prop > Js.t) -> obj##.p := 1 [%%expect {| Line _, characters 42-49: -Error: This expression has type +Error: The method call x#p has type float Js_of_ocaml.Js.prop = < get : float; set : float -> unit > Js_of_ocaml.Js.gen_prop but an expression was expected of type diff --git a/runtime/array.js b/runtime/array.js index fb027359d7..8672f15660 100644 --- a/runtime/array.js +++ b/runtime/array.js @@ -27,6 +27,17 @@ function caml_array_sub(a, i, len) { return a2; } +//Provides: caml_floatarray_sub mutable +//Version: >= 5.3 +function caml_floatarray_sub(a, i, len) { + var a2 = new Array(len + 1); + a2[0] = 0; + for (var i2 = 1, i1 = i + 1; i2 <= len; i2++, i1++) { + a2[i2] = a[i1]; + } + return a2; +} + //Provides: caml_array_append mutable function caml_array_append(a1, a2) { var l1 = a1.length, @@ -41,6 +52,21 @@ function caml_array_append(a1, a2) { return a; } +//Provides: caml_floatarray_append mutable +//Version: >= 5.3 +function caml_floatarray_append(a1, a2) { + var l1 = a1.length, + l2 = a2.length; + var l = l1 + l2 - 1; + var a = new Array(l); + a[0] = 0; + var i = 1, + j = 1; + for (; i < l1; i++) a[i] = a1[i]; + for (; i < l; i++, j++) a[i] = a2[j]; + return a; +} + //Provides: caml_array_concat mutable function caml_array_concat(l) { var a = [0]; @@ -96,6 +122,15 @@ function caml_array_fill(array, ofs, len, v) { return 0; } +//Provides: caml_floatarray_fill +//Version: >= 5.3 +function caml_floatarray_fill(array, ofs, len, v) { + for (var i = 0; i < len; i++) { + array[ofs + i + 1] = v; + } + return 0; +} + //Provides: caml_check_bound (mutable, const) //Requires: caml_array_bound_error function caml_check_bound(array, index) { @@ -133,6 +168,7 @@ function caml_array_create_float(len) { } //Provides: caml_floatarray_create const (const) //Requires: caml_array_bound_error +//Version: >= 5.3 function caml_floatarray_create(len) { if (len < 0) caml_array_bound_error(); var len = (len + 1) | 0; @@ -141,3 +177,10 @@ function caml_floatarray_create(len) { for (var i = 1; i < len; i++) b[i] = 0; return b; } + +//Provides: caml_floatarray_make const (const) +//Requires: caml_array_make +//Version: >= 5.3 +function caml_floatarray_make(len,init) { + return caml_array_make(len,init); +}