-
Notifications
You must be signed in to change notification settings - Fork 517
Description
It's unclear how to use call_indirect and it doesn't seem to align well with the design repo.
As far as I can tell, call_indirect has roughly this syntax in spec right now:
(call_indirect <table_number> <function_index> <args>), where:
table_numberis an integer literal - symbols don't work for some non-obvious reasonfunction_indexis an expression that evaluates to an integerargsis obvious
The addressof primitive expected for getting function indices does not appear to exist. My assumption is that the code generator is expected to hard-code an index as it exists in the tables defined by the module.
The syntax for defining a function table appears to be (table <table_number> <function> <function>) where:
table_numberis an integer literal - symbols fail to parse, as do bare words and quoted stringsfunctionis just a symbol or function index, like inexport.
Presumably this generates a function table with idtable_numbercontaining the provided functions in order, starting at 0 (1?)
Various questions remain that I can't easily figure out from reading the source:
- What happens if the signature of
call_indirectis a mismatch from the signature of the function the pointer is aimed at? - Are tables allowed to be heterogeneous?
- Why do we have multiple tables in a single module to begin with?
I am probably wrong about some of this since I still haven't managed to write a functioning module that uses call_indirect, but I'll update once I do.