Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement parsing of tables with initializer expressions (#823)
The function references proposal adds initializer for tables when its type is non-nullable reference. The text format is extended with constant expression (which can have ref.func). The binary format adds `0x40 0x00` prefix to the table section entry to indicate expression presence. https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md
- Loading branch information
1 parent
e15e768
commit ebce499
Showing
5 changed files
with
55 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
;; Table initializer | ||
|
||
(module | ||
(type $dummy (func)) | ||
(func $dummy) | ||
|
||
(table $t1 10 funcref) | ||
(table $t2 10 funcref (ref.func $dummy)) | ||
(table $t3 10 (ref $dummy) (ref.func $dummy)) | ||
(table $t4 10 (ref func) (ref.func $dummy)) | ||
|
||
(func (export "get1") (result funcref) (table.get $t1 (i32.const 1))) | ||
(func (export "get2") (result funcref) (table.get $t2 (i32.const 4))) | ||
(func (export "get3") (result funcref) (table.get $t3 (i32.const 7))) | ||
) | ||
|
||
(assert_return (invoke "get1") (ref.null)) | ||
(assert_return (invoke "get2") (ref.func)) | ||
(assert_return (invoke "get3") (ref.func)) |