-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement tables and call_indirect (#12)
* Implement tables and call_indirect * Restore comment about sig checking. * Widen callee index on 64bit platforms.
- Loading branch information
1 parent
e7c8d23
commit 7b22219
Showing
5 changed files
with
138 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
(module | ||
(type $indirect_sig (func (param i64) (result i64))) | ||
|
||
(func $assert (param i32) | ||
(block $ok | ||
(br_if $ok | ||
(get_local 0) | ||
) | ||
(unreachable) | ||
) | ||
) | ||
|
||
(func $plus_1 (param i64) (result i64) | ||
get_local 0 | ||
i64.const 1 | ||
i64.add | ||
) | ||
(func $minus_1 (param i64) (result i64) | ||
get_local 0 | ||
i64.const 1 | ||
i64.sub | ||
) | ||
|
||
(func $main | ||
(call $call_indirect | ||
(i32.const 0) | ||
(i64.const 2) | ||
) | ||
(call $call_indirect | ||
(i32.const 1) | ||
(i64.const 0) | ||
) | ||
) | ||
|
||
(func $call_indirect (param $func i32) (param $expected i64) | ||
(call $assert | ||
(i64.eq | ||
(call_indirect (type $indirect_sig) | ||
(i64.const 1) | ||
(get_local $func) | ||
) | ||
(get_local $expected) | ||
) | ||
) | ||
) | ||
(start $main) | ||
|
||
(table 2 2 anyfunc) | ||
(elem (i32.const 0) $plus_1 $minus_1) | ||
) |
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