Created
April 30, 2020 03:58
-
-
Save dominictarr/7a767dc3ec80ebbaa472ea30cdcd8b47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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