Skip to content

Instantly share code, notes, and snippets.

@dominictarr
Created April 30, 2020 03:58
Show Gist options
  • Save dominictarr/7a767dc3ec80ebbaa472ea30cdcd8b47 to your computer and use it in GitHub Desktop.
Save dominictarr/7a767dc3ec80ebbaa472ea30cdcd8b47 to your computer and use it in GitHub Desktop.
(module
(func (export "foo") (param $foo i32) (result i32)
(local $x i32)
;;if blocks (if, block, loop, etc) have a (result x) then they return a value!
(if (result i32) (local.get $foo)
(if (result i32)
(i32.gt_s (local.get $foo) (i32.const 10))
(i32.const 10)
(block (result i32) (i32.const 1))
)
(loop $loop (result i32)
(local.tee $x (i32.add (local.get $x) (i32.const 3) ))
(br_if $loop (i32.lt_s (local.get $x) (i32.const 100)))
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment