| ... | ... | @@ -2221,7 +2221,6 @@ const WasmDumper = struct { |
| 2221 | 2221 | const symtab_label = "symbols"; |
| 2222 | 2222 | |
| 2223 | 2223 | fn parseAndDump(step: *Step, kind: Check.Kind, bytes: []const u8) ![]const u8 { |
| 2224 | | _ = kind; |
| 2225 | 2224 | const gpa = step.owner.allocator; |
| 2226 | 2225 | var fbs = std.io.fixedBufferStream(bytes); |
| 2227 | 2226 | const reader = fbs.reader(); |
| ... | ... | @@ -2238,15 +2237,21 @@ const WasmDumper = struct { |
| 2238 | 2237 | errdefer output.deinit(); |
| 2239 | 2238 | const writer = output.writer(); |
| 2240 | 2239 | |
| 2241 | | while (reader.readByte()) |current_byte| { |
| 2242 | | const section = std.meta.intToEnum(std.wasm.Section, current_byte) catch { |
| 2243 | | return step.fail("Found invalid section id '{d}'", .{current_byte}); |
| 2244 | | }; |
| 2240 | switch (kind) { |
| 2241 | .headers => { |
| 2242 | while (reader.readByte()) |current_byte| { |
| 2243 | const section = std.meta.intToEnum(std.wasm.Section, current_byte) catch { |
| 2244 | return step.fail("Found invalid section id '{d}'", .{current_byte}); |
| 2245 | }; |
| 2245 | 2246 | |
| 2246 | | const section_length = try std.leb.readULEB128(u32, reader); |
| 2247 | | try parseAndDumpSection(step, section, bytes[fbs.pos..][0..section_length], writer); |
| 2248 | | fbs.pos += section_length; |
| 2249 | | } else |_| {} // reached end of stream |
| 2247 | const section_length = try std.leb.readULEB128(u32, reader); |
| 2248 | try parseAndDumpSection(step, section, bytes[fbs.pos..][0..section_length], writer); |
| 2249 | fbs.pos += section_length; |
| 2250 | } else |_| {} // reached end of stream |
| 2251 | }, |
| 2252 | |
| 2253 | else => return step.fail("invalid check kind for Wasm file format: {s}", .{@tagName(kind)}), |
| 2254 | } |
| 2250 | 2255 | |
| 2251 | 2256 | return output.toOwnedSlice(); |
| 2252 | 2257 | } |