stevenvar / OMicroB

An OCaml generic virtual machine for microcontrollers
Other
138 stars 23 forks source link

newbie question: can this turn an ocaml program into some C code? #5

Closed UnixJunkie closed 6 years ago

UnixJunkie commented 6 years ago

and, can it be used to minimize the size of regular ocaml programs? Sorry for the beginner questions, I'm not using microcontrollers, I'm just curious about the general usefulness of this project.

And anyway, it looks like a great step forward for people using microcontrollers.

stevenvar commented 6 years ago

Yes, the idea is to "transform" an OCaml bytecode file into a C file : the generated C file is not a transcompilation of the OCaml program, but a file containing the encoded bytecode into a C array, as well as variables representing the stack, heap, etc. At compile-time it is linked with an interpreter.

We use https://github.com/bvaugon/ocamlclean which reduces the size of the ocaml bytecode (and can be use in regular - for PCs - programs), and then apply some static analyses in order to reduce the produced C file (for example, partial evaluation is done upto the first I/O)

UnixJunkie commented 6 years ago

ok, thanks!