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