Skip to content

Commit

Permalink
Wasm runtime file
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Dec 20, 2024
1 parent e475b15 commit 045094d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
(:standard
(:include cflags.sexp))))
(js_of_ocaml
(javascript_files runtime.js)))
(javascript_files runtime.js))
(wasm_of_ocaml
(javascript_files runtime.js)
(wasm_files runtime.wat)))

(rule
(targets cflags.sexp)
Expand Down
38 changes: 38 additions & 0 deletions lib/runtime.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(module
(import "env" "caml_bigstring_blit_ba_to_ba"
(func $bigstringaf_blit_to_bigstring
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_blit_bytes_to_ba"
(func $bigstringaf_blit_from_bytes
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_blit_ba_to_bytes"
(func $bigstringaf_blit_to_bytes
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_memcmp"
(func $bigstringaf_memcmp_bigstring
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_memcmp_string"
(func $bigstringaf_memcmp_string
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_memchr"
(func $caml_bigstring_memchr
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(result (ref eq))))

(export "bigstringaf_blit_to_bytes" (func $bigstringaf_blit_to_bytes))
(export "bigstringaf_blit_to_bigstring" (func $bigstringaf_blit_to_bigstring))
(export "bigstringaf_blit_from_bytes" (func $bigstringaf_blit_from_bytes))
(export "bigstringaf_memcmp_bigstring" (func $bigstringaf_memcmp_bigstring))
(export "bigstringaf_memcmp_string" (func $bigstringaf_memcmp_string))

(func (export "bigstringaf_memchr")
(param $ba (ref eq)) (param $off (ref eq)) (param $chr (ref eq))
(param $len (ref eq)) (result (ref eq))
(return_call $caml_bigstring_memchr
(local.get $ba) (local.get $chr) (local.get $off) (local.get $len)))
)

0 comments on commit 045094d

Please sign in to comment.