I can't seem to find much info on if this is per MVP spec or if its a hack for emscripten but should a root module instantiate its own table/memory when an imported module has these entries? Or am I missing something. I've played with various hacks..like inserting
//while resolving imports wasm/imports.go 209
case ExternalTable:
if int(index) >= len(importedModule.TableIndexSpace) {
return InvalidTableIndexError(index)
}
//Inserted to setup module.Table if not already setup since import requires it
if module.Table==nil{
module.Table=importedModule.Table
moudile.TableIndexSpace=importedModule.TableIndexSpace
}
//end insert
module.TableIndexSpace[0] = importedModule.TableIndexSpace[0]
module.imports.Tables++
which seems to give me the correct functionality.
If I'm on the right path I can prep a PR...if I'm way off base I can accept that also (:
Related to work for #163
In a pretty standard (from what i can tell) wasm generated with emscripten it has the following imports
and has no memory/table statement for the root module
This results in
the LinearMemory space gets instantiated automatically https://github.com/go-interpreter/wagon/blob/3fd36533bb90cbfea01da645a92b1a7e828ea336/wasm/module.go#L140
while the TableIndexSpace does not (as there is no Table Section) https://github.com/go-interpreter/wagon/blob/3fd36533bb90cbfea01da645a92b1a7e828ea336/wasm/module.go#L141-L143
Which causes a fault when importing the "env" modules table definition (line 213) as module.TableIndexSpace is undefnied https://github.com/go-interpreter/wagon/blob/3fd36533bb90cbfea01da645a92b1a7e828ea336/wasm/imports.go#L209-L214
I can't seem to find much info on if this is per MVP spec or if its a hack for emscripten but should a root module instantiate its own table/memory when an imported module has these entries? Or am I missing something. I've played with various hacks..like inserting
which seems to give me the correct functionality.
If I'm on the right path I can prep a PR...if I'm way off base I can accept that also (:
Looking for insight. Thanks!