diff options
author | Thomas Lively <tlively@google.com> | 2024-01-04 14:25:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-04 14:25:18 -0800 |
commit | a58281ca114359cd6e65f5daaf086636aa18b0b0 (patch) | |
tree | ff98bd31d1c87b598027c2303b17855a44346515 /test/spec/old_call_indirect.wast | |
parent | 0ed42cf976ce9a3dfbe9cbb0885122e8fb6a377b (diff) | |
download | binaryen-a58281ca114359cd6e65f5daaf086636aa18b0b0.tar.gz binaryen-a58281ca114359cd6e65f5daaf086636aa18b0b0.tar.bz2 binaryen-a58281ca114359cd6e65f5daaf086636aa18b0b0.zip |
Require `then` and `else` with `if` (#6201)
We previously supported (and primarily used) a non-standard text format for
conditionals in which the condition, if-true expression, and if-false expression
were all simply s-expression children of the `if` expression. The standard text
format, however, requires the use of `then` and `else` forms to introduce the
if-true and if-false arms of the conditional. Update the legacy text parser to
require the standard format and update all tests to match. Update the printer to
print the standard format as well.
The .wast and .wat test inputs were mechanically updated with this script:
https://gist.github.com/tlively/85ae7f01f92f772241ec994c840ccbb1
Diffstat (limited to 'test/spec/old_call_indirect.wast')
-rw-r--r-- | test/spec/old_call_indirect.wast | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/test/spec/old_call_indirect.wast b/test/spec/old_call_indirect.wast index 41f4316f6..00ecd0863 100644 --- a/test/spec/old_call_indirect.wast +++ b/test/spec/old_call_indirect.wast @@ -103,12 +103,16 @@ (func $fac (export "fac") (type $over-i64) (if i64 (i64.eqz (local.get 0)) - (i64.const 1) - (i64.mul - (local.get 0) - (call_indirect (type $over-i64) - (i64.sub (local.get 0) (i64.const 1)) - (i32.const 12) + (then + (i64.const 1) + ) + (else + (i64.mul + (local.get 0) + (call_indirect (type $over-i64) + (i64.sub (local.get 0) (i64.const 1)) + (i32.const 12) + ) ) ) ) @@ -116,15 +120,19 @@ (func $fib (export "fib") (type $over-i64) (if i64 (i64.le_u (local.get 0) (i64.const 1)) - (i64.const 1) - (i64.add - (call_indirect (type $over-i64) - (i64.sub (local.get 0) (i64.const 2)) - (i32.const 13) - ) - (call_indirect (type $over-i64) - (i64.sub (local.get 0) (i64.const 1)) - (i32.const 13) + (then + (i64.const 1) + ) + (else + (i64.add + (call_indirect (type $over-i64) + (i64.sub (local.get 0) (i64.const 2)) + (i32.const 13) + ) + (call_indirect (type $over-i64) + (i64.sub (local.get 0) (i64.const 1)) + (i32.const 13) + ) ) ) ) @@ -132,19 +140,27 @@ (func $even (export "even") (param i32) (result i32) (if i32 (i32.eqz (local.get 0)) - (i32.const 44) - (call_indirect (type $over-i32) - (i32.sub (local.get 0) (i32.const 1)) - (i32.const 15) + (then + (i32.const 44) + ) + (else + (call_indirect (type $over-i32) + (i32.sub (local.get 0) (i32.const 1)) + (i32.const 15) + ) ) ) ) (func $odd (export "odd") (param i32) (result i32) (if i32 (i32.eqz (local.get 0)) - (i32.const 99) - (call_indirect (type $over-i32) - (i32.sub (local.get 0) (i32.const 1)) - (i32.const 14) + (then + (i32.const 99) + ) + (else + (call_indirect (type $over-i32) + (i32.sub (local.get 0) (i32.const 1)) + (i32.const 14) + ) ) ) ) |