| ... | @@ -2424,7 +2424,22 @@ const WasmDumper = struct { | ... | @@ -2424,7 +2424,22 @@ const WasmDumper = struct { |
| 2424 | } | 2424 | } |
| 2425 | | 2425 | |
| 2426 | var output = std.ArrayList(u8).init(gpa); | 2426 | var output = std.ArrayList(u8).init(gpa); |
| 2427 | errdefer output.deinit(); | 2427 | defer output.deinit(); |
| | 2428 | parseAndDumpInner(step, check, bytes, &fbs, &output) catch |err| switch (err) { |
| | 2429 | error.EndOfStream => try output.appendSlice("\n<UnexpectedEndOfStream>"), |
| | 2430 | else => |e| return e, |
| | 2431 | }; |
| | 2432 | return output.toOwnedSlice(); |
| | 2433 | } |
| | 2434 | |
| | 2435 | fn parseAndDumpInner( |
| | 2436 | step: *Step, |
| | 2437 | check: Check, |
| | 2438 | bytes: []const u8, |
| | 2439 | fbs: *std.io.FixedBufferStream([]const u8), |
| | 2440 | output: *std.ArrayList(u8), |
| | 2441 | ) !void { |
| | 2442 | const reader = fbs.reader(); |
| 2428 | const writer = output.writer(); | 2443 | const writer = output.writer(); |
| 2429 | | 2444 | |
| 2430 | switch (check.kind) { | 2445 | switch (check.kind) { |
| ... | @@ -2442,8 +2457,6 @@ const WasmDumper = struct { | ... | @@ -2442,8 +2457,6 @@ const WasmDumper = struct { |
| 2442 | | 2457 | |
| 2443 | else => return step.fail("invalid check kind for Wasm file format: {s}", .{@tagName(check.kind)}), | 2458 | else => return step.fail("invalid check kind for Wasm file format: {s}", .{@tagName(check.kind)}), |
| 2444 | } | 2459 | } |
| 2445 | | | |
| 2446 | return output.toOwnedSlice(); | | |
| 2447 | } | 2460 | } |
| 2448 | | 2461 | |
| 2449 | fn parseAndDumpSection( | 2462 | fn parseAndDumpSection( |