Issue
In C#, IL allows linear branching, meaning you can arbitrarily jump to any instruction. However, WAT/WASM uses structured control flow, requiring explicit block, if, loop structures to define valid jump targets. This makes compiling IL to WASM a bit tricky since we have to convert the arbitrary jumps to explicitly declared jumps.
Right now we have a barebones branching conversion system in CompilerVisitor but it's very basic and brittle. We should probably rewrite it entirely and ideally move branching logic out of the CompilerVisitor class.
Resources
Issue
In C#, IL allows linear branching, meaning you can arbitrarily jump to any instruction. However, WAT/WASM uses structured control flow, requiring explicit
block,if,loopstructures to define valid jump targets. This makes compiling IL to WASM a bit tricky since we have to convert the arbitrary jumps to explicitly declared jumps.Right now we have a barebones branching conversion system in
CompilerVisitorbut it's very basic and brittle. We should probably rewrite it entirely and ideally move branching logic out of theCompilerVisitorclass.Resources