Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Sep 23, 2024
1 parent 5a539f7 commit 5907823
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 18 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/magic_number.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions ppx/ppx_js/tests/ppx.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -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
|}]

Expand All @@ -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
Expand All @@ -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
|}]

Expand All @@ -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
|}]

Expand Down Expand Up @@ -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
|}]

Expand All @@ -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
Expand All @@ -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
|}]

Expand All @@ -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
Expand All @@ -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
Expand Down
43 changes: 43 additions & 0 deletions runtime/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

0 comments on commit 5907823

Please sign in to comment.