block
block creates a labeled scope. Branching to its label exits the block. It can optionally produce results.
(module (func (param $n i32) (result i32) (block $out (br_if $out (i32.eqz (local.get $n))) (return (i32.const 42))) (i32.const 0)))- Label names are optional — you can also target blocks by relative depth index.
- A block with
(result ...)must leave that typed value on the stack on all exits.
Instruction Reference
Section titled “Instruction Reference”- Control Flow Instructions —
block,loop,if,br,br_if