Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit d28b65e

Browse files
[docs] Update syntax in examples (#1442)
1 parent f6ae547 commit d28b65e

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

proposals/multi-value/Overview.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@
4343
A simple swap function.
4444
```wasm
4545
(func $swap (param i32 i32) (result i32 i32)
46-
(get_local 1) (get_local 0)
46+
(local.get 1) (local.get 0)
4747
)
4848
```
4949

5050
An addition function returning an additional carry bit.
5151
```wasm
5252
(func $add64_u_with_carry (param $i i64) (param $j i64) (param $c i32) (result i64 i32)
5353
(local $k i64)
54-
(set_local $k
55-
(i64.add (i64.add (get_local $i) (get_local $j)) (i64.extend_u/i32 (get_local $c)))
54+
(local.set $k
55+
(i64.add (i64.add (local.get $i) (local.get $j)) (i64.extend_i32_u (local.get $c)))
5656
)
57-
(return (get_local $k) (i64.lt_u (get_local $k) (get_local $i)))
57+
(return (local.get $k) (i64.lt_u (local.get $k) (local.get $i)))
5858
)
5959
```
6060

@@ -71,7 +71,7 @@ An addition function returning an additional carry bit.
7171
Conditionally manipulating a stack operand without using a local.
7272
```wasm
7373
(func $add64_u_saturated (param i64 i64) (result i64)
74-
($i64.add_u_carry (get_local 0) (get_local 1) (i32.const 0))
74+
(call $add64_u_with_carry (local.get 0) (local.get 1) (i32.const 0))
7575
(if (param i64) (result i64)
7676
(then (drop) (i64.const 0xffff_ffff_ffff_ffff))
7777
)
@@ -80,14 +80,22 @@ Conditionally manipulating a stack operand without using a local.
8080

8181
An iterative factorial function whose loop doesn't use locals, but uses arguments like phis.
8282
```wasm
83+
(func $pick0 (param i64) (result i64 i64)
84+
(local.get 0) (local.get 0)
85+
)
86+
87+
(func $pick1 (param i64 i64) (result i64 i64 i64)
88+
(local.get 0) (local.get 1) (local.get 0)
89+
)
90+
8391
(func $fac (param i64) (result i64)
84-
(i64.const 1) (get_local 0)
92+
(i64.const 1) (local.get 0)
8593
(loop $l (param i64 i64) (result i64)
86-
(pick 1) (pick 1) (i64.mul)
87-
(pick 1) (i64.const 1) (i64.sub)
88-
(pick 0) (i64.const 0) (i64.gt_u)
94+
(call $pick1) (call $pick1) (i64.mul)
95+
(call $pick1) (i64.const 1) (i64.sub)
96+
(call $pick0) (i64.const 0) (i64.gt_u)
8997
(br_if $l)
90-
(pick 1) (return)
98+
(call $pick1) (return)
9199
)
92100
)
93101
```

0 commit comments

Comments
 (0)