Skip to content

Commit f8d9e35

Browse files
Validation: Multiple memories are not permitted for now
1 parent 7e46572 commit f8d9e35

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Sources/WasmKit/Module.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ public struct Module {
129129
/// > Note:
130130
/// <https://webassembly.github.io/spec/core/exec/modules.html#instantiation>
131131
private func instantiateHandle(store: Store, imports: Imports) throws -> InternalInstance {
132+
try ModuleValidator().validate(self)
133+
132134
// Steps 5-8.
133135

134136
// Step 9.

Sources/WasmKit/Validator.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,11 @@ struct InstructionValidator {
2424
}
2525
}
2626
}
27+
28+
struct ModuleValidator {
29+
func validate(_ module: Module) throws {
30+
if module.memoryTypes.count > 1 {
31+
throw ValidationError("Multiple memories are not permitted")
32+
}
33+
}
34+
}

Tests/WasmKitTests/SpectestTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ final class SpectestTests: XCTestCase {
2222
path: Self.testPaths,
2323
include: [],
2424
exclude: [
25-
"imports.wast",
2625
"labels.wast",
2726
"load.wast",
2827
"local_get.wast",

0 commit comments

Comments
 (0)