forked from bytecodealliance/wasm-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up parsing
(if ...)
(bytecodealliance#1215)
* Clean up parsing `(if ...)` Much of this code dates back to when this crate was trying to parse all of WABT's tests as well as the upstream test suite. WABT at the time had syntactical forms that weren't technically supposed to be valid given the upstream test suite, so at the time more was accepted than should be. This commit fixes how `(if ...)` is parsed to require `(then ..)` and `(else ..)` wrappers. Previously these were mistakenly only optional. Additionally this fixes bytecodealliance#1213 by allowing multiple condition-related folded expressions before `(then ..)`. This updates a few of the golden outputs for the spec test suites, notably those that use `(if (foo) (then) (else))` where previously `wast` would erroneously not emit an `else` instruction but now it does. Closes bytecodealliance#1213 * Fix some test syntax
- Loading branch information
1 parent
9affab2
commit 585a0bd
Showing
10 changed files
with
130 additions
and
79 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(module | ||
(func $a1 | ||
i32.const 0 | ||
(if (then) (else)) | ||
) | ||
(func $a2 | ||
(if (i32.const 1) (i32.eqz) (then) (else)) | ||
) | ||
(func $a3 | ||
(if (i32.const 1) (i32.eqz) (then)) | ||
) | ||
(func $a4 | ||
(if (i32.const 1) (i32.eqz) (then nop)) | ||
) | ||
) | ||
(assert_invalid | ||
(module quote | ||
"(func (if))" | ||
) | ||
"no `then`") | ||
|
||
(assert_invalid | ||
(module quote | ||
"(func (if (else)))" | ||
) | ||
"no `then`") | ||
|
||
(assert_invalid | ||
(module quote | ||
"(func (if nop (else)))" | ||
) | ||
"expected `(`") | ||
(assert_invalid | ||
(module quote | ||
"(func (if (nop) (else)))" | ||
) | ||
"no `then`") | ||
(assert_invalid | ||
(module quote | ||
"(func (if (nop) nop (then)))" | ||
) | ||
"expected `(`") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(module | ||
(type (;0;) (func)) | ||
(func $a1 (;0;) (type 0) | ||
i32.const 0 | ||
if ;; label = @1 | ||
else | ||
end | ||
) | ||
(func $a2 (;1;) (type 0) | ||
i32.const 1 | ||
i32.eqz | ||
if ;; label = @1 | ||
else | ||
end | ||
) | ||
(func $a3 (;2;) (type 0) | ||
i32.const 1 | ||
i32.eqz | ||
if ;; label = @1 | ||
end | ||
) | ||
(func $a4 (;3;) (type 0) | ||
i32.const 1 | ||
i32.eqz | ||
if ;; label = @1 | ||
nop | ||
end | ||
) | ||
) |
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
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
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