Conversation
a572bd0 to
b17477e
Compare
runtime/stubs.js
Outdated
| //Provides: ml_z_of_int | ||
| //Requires: ml_z_of_int64, ml_z_to_int64 | ||
| function ml_z_of_int(x) { | ||
| return ml_z_of_int64(ml_z_to_int64(x)); | ||
| } |
There was a problem hiding this comment.
Is this right? The name suggests a conversion int → Z.t, but the implementation does Z.t → int64 → Z.t. Shouldn't it be int → int64 → Z.t instead, where the first half is some standard OCaml conversion?
Actually I'm kind of confused about this function altogether. ml_z_of_int is defined in Zarith's C code, but never actually used, so how come we need it for JS? Since it's not used by Zarith's OCaml interface, zarith_stubs_js probably doesn't have it for that reason.
There was a problem hiding this comment.
You are right, there seems to be a mistake in the stub's implementation. I guess, the js_of_ocaml version for OCamls Int64.of_int would be the right thing to call instead?
I am also not sure were it is required, but it throws this error when one tries to run Gobview:
Uncaught TypeError: runtime.ml_z_of_int is not a function
at _b_ (findlib_config.ml:0:0)
at _q_ (findlib_config.ml:0:0)
at caml_call2 (findlib_config.ml:0:0)
at eval (cilint.ml:25:11)
at eval (findlib_config.ml:0:0)
at ./src/App.bc.js (main.js:7891:1)
at __webpack_require__ (main.js:8006:42)
at main.js:8254:37
at main.js:8256:12
There was a problem hiding this comment.
I figured out where it's being used from. Our Gobview-compatible Zarith restores its usage: goblint/Zarith@db75b80#diff-2f0def1d12de7f2f0820477b20db522ead8e232b5327b3b81273f00ab32d0662R126.
Prior to it being changed in Zarith (ocaml/Zarith@2933e9a), zarith_stubs_js had an implementation for it, which I suppose we could just copy for our own usage: janestreet/zarith_stubs_js@0484894#diff-620d8f84607e4a3c91579ab868c89080849559f6533315da0c0ec092f9899a11L182-L188.
There was a problem hiding this comment.
I have added the implementation you suggested. I am still wondering a little though, because it is the same as for of_int32 but different from the one for of_int64.
There was a problem hiding this comment.
I think that might just be because int64 doesn't fit into JavaScript's number type, which is a double, but int32 does. And AFAIK js_of_ocaml's int is 31-bit (hence the whole business with our custom Zarith to marshal things specially for js_of_ocaml) and thus directly fits.
bb80b64 to
b14df8b
Compare
This PR fixes issues that emerged when building and using Gobview:
Depends on goblint/analyzer#993
Fixes #2