authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-12-13 11:41:51+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-12-13 11:41:51+01:00
logc4519d6bbae661b2e569b9b86887020a3013414e
treeed4f4e8480992bee90361031a8d52c2017e78a41
parent92cca7fbf155602584dee294d04ee0b33135a25e

lib/std/Build/CheckObject: implement for Wasm


1 files changed, 14 insertions(+), 9 deletions(-)

lib/std/Build/Step/CheckObject.zig+14-9
......@@ -2221,7 +2221,6 @@ const WasmDumper = struct {
22212221 const symtab_label = "symbols";
22222222
22232223 fn parseAndDump(step: *Step, kind: Check.Kind, bytes: []const u8) ![]const u8 {
2224 _ = kind;
22252224 const gpa = step.owner.allocator;
22262225 var fbs = std.io.fixedBufferStream(bytes);
22272226 const reader = fbs.reader();
......@@ -2238,15 +2237,21 @@ const WasmDumper = struct {
22382237 errdefer output.deinit();
22392238 const writer = output.writer();
22402239
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 };
22452246
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 }
22502255
22512256 return output.toOwnedSlice();
22522257 }