3 ms·
How did you find the experience of compiling to wasm? Do you build an IR first at all or just ast -> wasm?
by insanitybit 3y ago
How did you find the experience of compiling to wasm? Do you build an IR first at all or just ast -> wasm?
- brendanfh 3y agoI found it relatively easy. I planned a lot of things out of whiteboards and notebooks, but the actual code writing was mostly straight forward. For Onyx, I went straight from AST to WASM. The trickiest part was probably deciding how non-primitive things would be represented in WASM, like structures and tagged unions. But all of that came later after I had the basics down. I started with the simplest little compiler that could only compile binary operations on integers, and basic function calls. Then I expanded the compiler outward once I had the underlying data structures and code paths figured out.