Skip to content

Commit a749c75

Browse files
committed
OxCaml support: some runtime changes
1 parent 14fe3f4 commit a749c75

File tree

9 files changed

+32
-1
lines changed

9 files changed

+32
-1
lines changed

compiler/lib-runtime-files/js_of_ocaml_compiler_runtime_files.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ let runtime =
3333
; graphics
3434
; hash
3535
; ieee_754
36+
; float32
3637
; int64
3738
; ints
3839
; io

compiler/lib-runtime-files/tests/all.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let%expect_test _ =
2121
+dynlink.js
2222
+effect.js
2323
+fail.js
24+
+float32.js
2425
+format.js
2526
+fs.js
2627
+fs_fake.js
@@ -64,6 +65,7 @@ let%expect_test _ =
6465
+domain.js
6566
+effect.js
6667
+fail.js
68+
+float32.js
6769
+format.js
6870
+fs.js
6971
+fs_fake.js

runtime/js/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
gc.js
1212
graphics.js
1313
ieee_754.js
14+
float32.js
1415
int64.js
1516
io.js
1617
jslib.js

runtime/js/float32.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//Provides: caml_is_boot_compiler
2+
//Version: >= 5.2, < 5.3
3+
//OxCaml
4+
function caml_is_boot_compiler(_unit) {
5+
return 0;
6+
}

runtime/js/hash.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ function caml_hash(count, limit, seed, obj) {
221221
return h & 0x3fffffff;
222222
}
223223

224+
//Provides: caml_hash_exn
225+
//Requires: caml_hash
226+
//Version: >= 5.2, < 5.3
227+
//OxCaml
228+
var caml_hash_exn = caml_hash;
229+
224230
//Provides: caml_string_hash
225231
//Requires: caml_hash_mix_final, caml_hash_mix_string
226232
//Version: >= 5.0

runtime/js/sys.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ function caml_sys_isatty(_chan) {
311311
return 0;
312312
}
313313

314+
//Provides: caml_sys_const_runtime5 const
315+
//Version: >= 5.2, < 5.3
316+
//OxCaml
317+
function caml_sys_const_runtime5(_unit) {
318+
return 1;
319+
}
320+
314321
//Provides: caml_runtime_variant
315322
//Requires: caml_string_of_jsbytes
316323
function caml_runtime_variant(_unit) {

runtime/wasm/float32.wat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(module
2+
(func (export "caml_is_boot_compiler") (param (ref eq)) (result (ref eq))
3+
(ref.i31 (i32.const 0)))
4+
)

runtime/wasm/hash.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
(global $caml_hash_queue (ref $block)
175175
(array.new $block (ref.i31 (i32.const 0)) (global.get $HASH_QUEUE_SIZE)))
176176

177-
(func (export "caml_hash")
177+
(func (export "caml_hash") (export "caml_hash_exn")
178178
(param $count (ref eq)) (param $limit (ref eq)) (param $seed (ref eq))
179179
(param $obj (ref eq)) (result (ref eq))
180180
(local $sz i32) (local $num i32) (local $h i32)

runtime/wasm/sys.wat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@
174174
(param $ch (ref eq)) (result (ref eq))
175175
(return_call $isatty (call $caml_channel_descriptor (local.get $ch))))
176176

177+
(func (export "caml_sys_const_runtime5")
178+
(param (ref eq)) (result (ref eq))
179+
(ref.i31 (i32.const 1)))
180+
177181
(func (export "caml_runtime_variant") (param (ref eq)) (result (ref eq))
178182
(@string ""))
179183

0 commit comments

Comments
 (0)