forked from tetratelabs/wazero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
w_config.go
42 lines (36 loc) · 1.12 KB
/
w_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package wazero
import "github.com/tetratelabs/wazero/api"
type WATERExtendedCompiledModule interface {
// AllImports returns name and type of all imported functions, tables,
// memories or globals required for instantiation, per module name.
AllImports() map[string]map[string]api.ExternType
// AllExports returns name and type of all exported functions, tables,
// memories or globals from this module.
AllExports() map[string]api.ExternType
}
// Implements WATERExtendedCompiledModule.
func (c *compiledModule) AllExports() map[string]api.ExternType {
var ret = make(map[string]api.ExternType)
for name, f := range c.module.Exports {
if f != nil {
ret[name] = f.Type
}
}
return ret
}
// Implements WATERExtendedCompiledModule.
func (c *compiledModule) AllImports() map[string]map[string]api.ExternType {
var ret = make(map[string]map[string]api.ExternType)
for module, imports := range c.module.ImportPerModule {
if len(imports) == 0 {
continue
}
if _, ok := ret[module]; !ok {
ret[module] = make(map[string]api.ExternType)
}
for _, f := range imports {
ret[module][f.Name] = f.Type
}
}
return ret
}