ModuleValidator
        object ModuleValidator
      
Methods
visit
        fun visit(node: WasmModule, context: Module): Module
      
Validates the given node, and if necessary: its children (recursively, using other ValidationVisitor instances).
Parameters
| Name | Description | 
|---|---|
| node: WasmModule | |
| context: Module | 
ReturnValue
| Name | Description | 
|---|---|
| Module | 
Validator of WasmModules.
From the docs:
Modules are classified by their mapping from the external types of their imports to those of their exports.
A module is entirely closed, that is, its components can only refer to definitions that appear in the module itself. Consequently, no initial context is required. Instead, the context
Cfor validation of the module’s content is constructed from the definitions in the module.KWasm Note: The validation context will be passed to the ModuleValidator
modulebe the module to validate.Let
Cbe a context where:C.typesismodule.types,C.funcsisfuncs(it*)concatenated withft*, with the import’s external typesit*and the internal function typesft*as determined below,C.tablesistables(it*)concatenated withtt*, with the import’s external typesit*and the internal table typestt*as determined below,C.memsismems(it*)concatenated withmt*, with the import’s external typesit*and the internal memory typesmt*as determined below,C.globalsisglobals(it*)concatenated withgt*, with the import’s external typesit*and the internal global typesgt*as determined below,C.localsis empty,C.labelsis empty,C.returnis empty.C′be the context whereC′.globalsis the sequenceglobals(it*)and all other fields are empty.C:functype_iinmodule.types, the function typefunctype_imust be valid.func_iinmodule.funcs, the definitionfunc_imust be valid with a function typeft_i.table_iinmodule.tables, the definitiontable_imust be valid with a table typett_i.mem_iinmodule.mems, the definitionmem_imust be valid with a memory typemt_i.global_iinmodule.globals:Under the contextC′, the definitionglobal_imust be valid with a global typegt_i.elem_iinmodule.elem, the segmentelem_imust be valid.data_iinmodule.data, the segmentdata_imust be valid.module.startis non-empty, thenmodule.startmust be valid.import_iinmodule.imports, the segmentimport_imust be valid with an external typeit_i.export_iinmodule.exports, the segmentexport_imust be valid with external typeet_i.C.tablesmust not be larger than1.C.memsmust not be larger than1.export_i.namemust be different.ft*be the concatenation of the internal function typesft_i, in index order.tt*be the concatenation of the internal table typestt_i, in index order.mt*be the concatenation of the internal memory typesmt_i, in index order.gt*be the concatenation of the internal global typesgt_i, in index order.it*be the concatenation of external typesit_iof the imports, in index order.et*be the concatenation of external typeset_iof the exports, in index order.it* => et*.