WebAssembly Switch example with current LLVM wasm backend, compiled with -O2
October 31, 2016 · View on GitHub
"Desugared WebAssembly" (i.e. stack-machine style text format) (module ... types, imports, exports snipped... (func main (param \0 i32) (result i32) (local $1 i32) i32.const 10 set_local $1 block label\0 block label\1 block label\2 get_local $0 i32.const -1 i32.add tee_local $0 i32.const 10 i32.gt_u br_if label\2 block label\3 block label\4 block label\5 get_local $0 br_table label\1 label\5 label\4 label\3 label\2 label\2 label\2 label\2 label\2 label\2 label\0 label\1 end i32.const 13 return end i32.const 11 return end i32.const 102 return end i32.const 0 set_local $1 end get_local $1 return end i32.const 1040)