Skip to content
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

Runtime: don't change the shape of bytes when converting to string #1712

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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 CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1)
* Runtime: allow dynlink of precompiled js with separate compilation (#1676)
* Runtime: reimplement the runtime of weak and ephemeron (#1707)
* Runtime: don't change the shape of mlbytes when converting to string
* Lib: Modify Typed_array API for compatibility with WebAssembly
* Lib: add details element and toggle event (#1728)
* Toplevel: no longer set globals for toplevel initialization
Expand Down
12 changes: 10 additions & 2 deletions runtime/js/mlBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,18 @@ function caml_string_lessthan(s1, s2) {

//Provides: caml_string_of_bytes
//Requires: caml_convert_string_to_bytes, caml_string_of_jsbytes
//Requires: caml_subarray_to_jsbytes
//If: js-string
function caml_string_of_bytes(s) {
s.t & 6 && caml_convert_string_to_bytes(s);
return caml_string_of_jsbytes(s.c);
switch (s.t & 6) {
case 0 /* BYTES */:
return caml_string_of_jsbytes(s.c);
case 2 /* PARTIAL */:
caml_convert_string_to_bytes(s);
return caml_string_of_jsbytes(s.c);
case 4 /* ARRAY */:
return caml_subarray_to_jsbytes(s.c, 0, s.c.length);
}
}

//Provides: caml_bytes_of_string const
Expand Down
Loading