Seeing as both the OCaml compiler and js_of_ocaml are written in OCaml, it seems reasonable (to me) that I should be able to write a wrapper that uses:
- the OCaml
compilerlibs
to compile OCaml source into, sayInstruct.instruction list
(usingBytegen.compile_implementation
), and - js_of_ocaml to compile the instruction list into JavaScript, thereby bypassing the
Parse_bytecode
.
I would therefore keep all data in memory, avoiding writing and then reading the cmo
file(s). I expect I could write the cmo
to a buffer and have js_of_ocaml process that, but it seems at best inefficient.
Is this realistic/has it been done before, or am I just trying to join the two components in the wrong place/way?