Is it possible to embed V as a library to a C++ program and use it to compile V to wasm at runtime? #24787
-
? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
It is possible, yes. At one time, we had a WASM playground, where that version of V was in WASM code. However, the WASM backend is incomplete, and is waiting for the new enhancements for the compiler to be finished before the WASM backend is worked on again. |
Beta Was this translation helpful? Give feedback.
-
Yes, you can embed V as a library in C++ by compiling the V compiler (written in V) to C code and linking it. Your C++ program would call the embedded V compiler functions to parse V source code and generate WebAssembly output using V's WASM backend. You'd need to manage memory carefully between C++ and V runtime, and handle dependencies like V's standard library. Runtime compilation adds overhead compared to pre-compiled WASM, so consider if JIT compilation is necessary. Alternative approaches include using V as a subprocess or pre-compiling V to WASM ahead of time. |
Beta Was this translation helpful? Give feedback.
It is possible, yes. At one time, we had a WASM playground, where that version of V was in WASM code.
However, the WASM backend is incomplete, and is waiting for the new enhancements for the compiler to be finished before the WASM backend is worked on again.