summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Torres <torres@sideros.org>2025-03-19 20:33:13 +0100
committerLorenzo Torres <torres@sideros.org>2025-03-19 20:33:13 +0100
commitd5d2f1b8d237ed47b3f65aa4f28290c734d41dae (patch)
tree9c458a5733c49d6b373696cea22d6049f5b5ca9c
parente8b4a131a96b87ef1b5aba57ffc4eb5d855160a2 (diff)
Fixed import section parsing
-rw-r--r--src/mods/parse.zig23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/mods/parse.zig b/src/mods/parse.zig
index 7080e66..f125303 100644
--- a/src/mods/parse.zig
+++ b/src/mods/parse.zig
@@ -206,18 +206,21 @@ pub fn parseWasm(allocator: Allocator, stream: anytype) !Module {
const b = try stream.readByte();
switch (@as(std.wasm.ExternalKind, @enumFromInt(b))) {
- std.wasm.ExternalKind.function => try funcs.append(.{ .external = @intCast(i) }),
+ std.wasm.ExternalKind.function => {
+ try funcs.append(.{ .external = @intCast(i) });
+
+ const idx = try std.leb.readULEB128(u32, stream);
+ try imports.append(.{
+ .module = mod,
+ .name = nm,
+ .signature = idx,
+ });
+ },
// TODO: not implemented
- std.wasm.ExternalKind.table => {},
- std.wasm.ExternalKind.memory => {},
- std.wasm.ExternalKind.global => {},
+ std.wasm.ExternalKind.table => try stream.skipBytes(3, .{}),
+ std.wasm.ExternalKind.memory => try stream.skipBytes(2, .{}),
+ std.wasm.ExternalKind.global => try stream.skipBytes(2, .{}),
}
- const idx = try std.leb.readULEB128(u32, stream);
- try imports.append(.{
- .module = mod,
- .name = nm,
- .signature = idx,
- });
}
},
std.wasm.Section.function => {