| author | |
| committer | |
| log | 642093e04bf10f6a9a7c23dfcf219bbbc7d51b54 |
| tree | a3945fb11a5a6f71834b9aae2d163dd67f14fa46 |
| parent | 0fcd59eadae468284943895f50bc9fc6d1924154 |
18 files changed, 465 insertions(+), 453 deletions(-)
lib/std/Build/Step/CheckObject.zig+64-64| ... | @@ -1229,17 +1229,17 @@ const MachODumper = struct { | ... | @@ -1229,17 +1229,17 @@ const MachODumper = struct { |
| 1229 | macho.REBASE_OPCODE_SET_TYPE_IMM => {}, | 1229 | macho.REBASE_OPCODE_SET_TYPE_IMM => {}, |
| 1230 | macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB => { | 1230 | macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB => { |
| 1231 | seg_id = imm; | 1231 | seg_id = imm; |
| 1232 | offset = try std.leb.readULEB128(u64, reader); | 1232 | offset = try std.leb.readUleb128(u64, reader); |
| 1233 | }, | 1233 | }, |
| 1234 | macho.REBASE_OPCODE_ADD_ADDR_IMM_SCALED => { | 1234 | macho.REBASE_OPCODE_ADD_ADDR_IMM_SCALED => { |
| 1235 | offset += imm * @sizeOf(u64); | 1235 | offset += imm * @sizeOf(u64); |
| 1236 | }, | 1236 | }, |
| 1237 | macho.REBASE_OPCODE_ADD_ADDR_ULEB => { | 1237 | macho.REBASE_OPCODE_ADD_ADDR_ULEB => { |
| 1238 | const addend = try std.leb.readULEB128(u64, reader); | 1238 | const addend = try std.leb.readUleb128(u64, reader); |
| 1239 | offset += addend; | 1239 | offset += addend; |
| 1240 | }, | 1240 | }, |
| 1241 | macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB => { | 1241 | macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB => { |
| 1242 | const addend = try std.leb.readULEB128(u64, reader); | 1242 | const addend = try std.leb.readUleb128(u64, reader); |
| 1243 | const seg = ctx.segments.items[seg_id.?]; | 1243 | const seg = ctx.segments.items[seg_id.?]; |
| 1244 | const addr = seg.vmaddr + offset; | 1244 | const addr = seg.vmaddr + offset; |
| 1245 | try rebases.append(addr); | 1245 | try rebases.append(addr); |
| ... | @@ -1256,11 +1256,11 @@ const MachODumper = struct { | ... | @@ -1256,11 +1256,11 @@ const MachODumper = struct { |
| 1256 | ntimes = imm; | 1256 | ntimes = imm; |
| 1257 | }, | 1257 | }, |
| 1258 | macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES => { | 1258 | macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES => { |
| 1259 | ntimes = try std.leb.readULEB128(u64, reader); | 1259 | ntimes = try std.leb.readUleb128(u64, reader); |
| 1260 | }, | 1260 | }, |
| 1261 | macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB => { | 1261 | macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB => { |
| 1262 | ntimes = try std.leb.readULEB128(u64, reader); | 1262 | ntimes = try std.leb.readUleb128(u64, reader); |
| 1263 | skip = try std.leb.readULEB128(u64, reader); | 1263 | skip = try std.leb.readUleb128(u64, reader); |
| 1264 | }, | 1264 | }, |
| 1265 | else => unreachable, | 1265 | else => unreachable, |
| 1266 | } | 1266 | } |
| ... | @@ -1361,7 +1361,7 @@ const MachODumper = struct { | ... | @@ -1361,7 +1361,7 @@ const MachODumper = struct { |
| 1361 | }, | 1361 | }, |
| 1362 | macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB => { | 1362 | macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB => { |
| 1363 | seg_id = imm; | 1363 | seg_id = imm; |
| 1364 | offset = try std.leb.readULEB128(u64, reader); | 1364 | offset = try std.leb.readUleb128(u64, reader); |
| 1365 | }, | 1365 | }, |
| 1366 | macho.BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM => { | 1366 | macho.BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM => { |
| 1367 | name_buf.clearRetainingCapacity(); | 1367 | name_buf.clearRetainingCapacity(); |
| ... | @@ -1369,10 +1369,10 @@ const MachODumper = struct { | ... | @@ -1369,10 +1369,10 @@ const MachODumper = struct { |
| 1369 | try name_buf.append(0); | 1369 | try name_buf.append(0); |
| 1370 | }, | 1370 | }, |
| 1371 | macho.BIND_OPCODE_SET_ADDEND_SLEB => { | 1371 | macho.BIND_OPCODE_SET_ADDEND_SLEB => { |
| 1372 | addend = try std.leb.readILEB128(i64, reader); | 1372 | addend = try std.leb.readIleb128(i64, reader); |
| 1373 | }, | 1373 | }, |
| 1374 | macho.BIND_OPCODE_ADD_ADDR_ULEB => { | 1374 | macho.BIND_OPCODE_ADD_ADDR_ULEB => { |
| 1375 | const x = try std.leb.readULEB128(u64, reader); | 1375 | const x = try std.leb.readUleb128(u64, reader); |
| 1376 | offset = @intCast(@as(i64, @intCast(offset)) + @as(i64, @bitCast(x))); | 1376 | offset = @intCast(@as(i64, @intCast(offset)) + @as(i64, @bitCast(x))); |
| 1377 | }, | 1377 | }, |
| 1378 | macho.BIND_OPCODE_DO_BIND, | 1378 | macho.BIND_OPCODE_DO_BIND, |
| ... | @@ -1387,14 +1387,14 @@ const MachODumper = struct { | ... | @@ -1387,14 +1387,14 @@ const MachODumper = struct { |
| 1387 | switch (opc) { | 1387 | switch (opc) { |
| 1388 | macho.BIND_OPCODE_DO_BIND => {}, | 1388 | macho.BIND_OPCODE_DO_BIND => {}, |
| 1389 | macho.BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB => { | 1389 | macho.BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB => { |
| 1390 | add_addr = try std.leb.readULEB128(u64, reader); | 1390 | add_addr = try std.leb.readUleb128(u64, reader); |
| 1391 | }, | 1391 | }, |
| 1392 | macho.BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED => { | 1392 | macho.BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED => { |
| 1393 | add_addr = imm * @sizeOf(u64); | 1393 | add_addr = imm * @sizeOf(u64); |
| 1394 | }, | 1394 | }, |
| 1395 | macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB => { | 1395 | macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB => { |
| 1396 | count = try std.leb.readULEB128(u64, reader); | 1396 | count = try std.leb.readUleb128(u64, reader); |
| 1397 | skip = try std.leb.readULEB128(u64, reader); | 1397 | skip = try std.leb.readUleb128(u64, reader); |
| 1398 | }, | 1398 | }, |
| 1399 | else => unreachable, | 1399 | else => unreachable, |
| 1400 | } | 1400 | } |
| ... | @@ -1463,11 +1463,11 @@ const MachODumper = struct { | ... | @@ -1463,11 +1463,11 @@ const MachODumper = struct { |
| 1463 | return std.io.fixedBufferStream(it.data[it.pos..]); | 1463 | return std.io.fixedBufferStream(it.data[it.pos..]); |
| 1464 | } | 1464 | } |
| 1465 | 1465 | ||
| 1466 | fn readULEB128(it: *TrieIterator) !u64 { | 1466 | fn readUleb128(it: *TrieIterator) !u64 { |
| 1467 | var stream = it.getStream(); | 1467 | var stream = it.getStream(); |
| 1468 | var creader = std.io.countingReader(stream.reader()); | 1468 | var creader = std.io.countingReader(stream.reader()); |
| 1469 | const reader = creader.reader(); | 1469 | const reader = creader.reader(); |
| 1470 | const value = try std.leb.readULEB128(u64, reader); | 1470 | const value = try std.leb.readUleb128(u64, reader); |
| 1471 | it.pos += creader.bytes_read; | 1471 | it.pos += creader.bytes_read; |
| 1472 | return value; | 1472 | return value; |
| 1473 | } | 1473 | } |
| ... | @@ -1538,12 +1538,12 @@ const MachODumper = struct { | ... | @@ -1538,12 +1538,12 @@ const MachODumper = struct { |
| 1538 | prefix: []const u8, | 1538 | prefix: []const u8, |
| 1539 | exports: *std.ArrayList(Export), | 1539 | exports: *std.ArrayList(Export), |
| 1540 | ) !void { | 1540 | ) !void { |
| 1541 | const size = try it.readULEB128(); | 1541 | const size = try it.readUleb128(); |
| 1542 | if (size > 0) { | 1542 | if (size > 0) { |
| 1543 | const flags = try it.readULEB128(); | 1543 | const flags = try it.readUleb128(); |
| 1544 | switch (flags) { | 1544 | switch (flags) { |
| 1545 | macho.EXPORT_SYMBOL_FLAGS_REEXPORT => { | 1545 | macho.EXPORT_SYMBOL_FLAGS_REEXPORT => { |
| 1546 | const ord = try it.readULEB128(); | 1546 | const ord = try it.readUleb128(); |
| 1547 | const name = try arena.dupe(u8, try it.readString()); | 1547 | const name = try arena.dupe(u8, try it.readString()); |
| 1548 | try exports.append(.{ | 1548 | try exports.append(.{ |
| 1549 | .name = if (name.len > 0) name else prefix, | 1549 | .name = if (name.len > 0) name else prefix, |
| ... | @@ -1552,8 +1552,8 @@ const MachODumper = struct { | ... | @@ -1552,8 +1552,8 @@ const MachODumper = struct { |
| 1552 | }); | 1552 | }); |
| 1553 | }, | 1553 | }, |
| 1554 | macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER => { | 1554 | macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER => { |
| 1555 | const stub_offset = try it.readULEB128(); | 1555 | const stub_offset = try it.readUleb128(); |
| 1556 | const resolver_offset = try it.readULEB128(); | 1556 | const resolver_offset = try it.readUleb128(); |
| 1557 | try exports.append(.{ | 1557 | try exports.append(.{ |
| 1558 | .name = prefix, | 1558 | .name = prefix, |
| 1559 | .tag = .stub_resolver, | 1559 | .tag = .stub_resolver, |
| ... | @@ -1564,7 +1564,7 @@ const MachODumper = struct { | ... | @@ -1564,7 +1564,7 @@ const MachODumper = struct { |
| 1564 | }); | 1564 | }); |
| 1565 | }, | 1565 | }, |
| 1566 | else => { | 1566 | else => { |
| 1567 | const vmoff = try it.readULEB128(); | 1567 | const vmoff = try it.readUleb128(); |
| 1568 | try exports.append(.{ | 1568 | try exports.append(.{ |
| 1569 | .name = prefix, | 1569 | .name = prefix, |
| 1570 | .tag = .@"export", | 1570 | .tag = .@"export", |
| ... | @@ -1586,7 +1586,7 @@ const MachODumper = struct { | ... | @@ -1586,7 +1586,7 @@ const MachODumper = struct { |
| 1586 | const nedges = try it.readByte(); | 1586 | const nedges = try it.readByte(); |
| 1587 | for (0..nedges) |_| { | 1587 | for (0..nedges) |_| { |
| 1588 | const label = try it.readString(); | 1588 | const label = try it.readString(); |
| 1589 | const off = try it.readULEB128(); | 1589 | const off = try it.readUleb128(); |
| 1590 | const prefix_label = try std.fmt.allocPrint(arena, "{s}{s}", .{ prefix, label }); | 1590 | const prefix_label = try std.fmt.allocPrint(arena, "{s}{s}", .{ prefix, label }); |
| 1591 | const curr = it.pos; | 1591 | const curr = it.pos; |
| 1592 | it.pos = off; | 1592 | it.pos = off; |
| ... | @@ -2413,7 +2413,7 @@ const WasmDumper = struct { | ... | @@ -2413,7 +2413,7 @@ const WasmDumper = struct { |
| 2413 | return step.fail("Found invalid section id '{d}'", .{current_byte}); | 2413 | return step.fail("Found invalid section id '{d}'", .{current_byte}); |
| 2414 | }; | 2414 | }; |
| 2415 | 2415 | ||
| 2416 | const section_length = try std.leb.readULEB128(u32, reader); | 2416 | const section_length = try std.leb.readUleb128(u32, reader); |
| 2417 | try parseAndDumpSection(step, section, bytes[fbs.pos..][0..section_length], writer); | 2417 | try parseAndDumpSection(step, section, bytes[fbs.pos..][0..section_length], writer); |
| 2418 | fbs.pos += section_length; | 2418 | fbs.pos += section_length; |
| 2419 | } else |_| {} // reached end of stream | 2419 | } else |_| {} // reached end of stream |
| ... | @@ -2451,12 +2451,12 @@ const WasmDumper = struct { | ... | @@ -2451,12 +2451,12 @@ const WasmDumper = struct { |
| 2451 | .code, | 2451 | .code, |
| 2452 | .data, | 2452 | .data, |
| 2453 | => { | 2453 | => { |
| 2454 | const entries = try std.leb.readULEB128(u32, reader); | 2454 | const entries = try std.leb.readUleb128(u32, reader); |
| 2455 | try writer.print("\nentries {d}\n", .{entries}); | 2455 | try writer.print("\nentries {d}\n", .{entries}); |
| 2456 | try parseSection(step, section, data[fbs.pos..], entries, writer); | 2456 | try parseSection(step, section, data[fbs.pos..], entries, writer); |
| 2457 | }, | 2457 | }, |
| 2458 | .custom => { | 2458 | .custom => { |
| 2459 | const name_length = try std.leb.readULEB128(u32, reader); | 2459 | const name_length = try std.leb.readUleb128(u32, reader); |
| 2460 | const name = data[fbs.pos..][0..name_length]; | 2460 | const name = data[fbs.pos..][0..name_length]; |
| 2461 | fbs.pos += name_length; | 2461 | fbs.pos += name_length; |
| 2462 | try writer.print("\nname {s}\n", .{name}); | 2462 | try writer.print("\nname {s}\n", .{name}); |
| ... | @@ -2471,11 +2471,11 @@ const WasmDumper = struct { | ... | @@ -2471,11 +2471,11 @@ const WasmDumper = struct { |
| 2471 | // TODO: Implement parsing and dumping other custom sections (such as relocations) | 2471 | // TODO: Implement parsing and dumping other custom sections (such as relocations) |
| 2472 | }, | 2472 | }, |
| 2473 | .start => { | 2473 | .start => { |
| 2474 | const start = try std.leb.readULEB128(u32, reader); | 2474 | const start = try std.leb.readUleb128(u32, reader); |
| 2475 | try writer.print("\nstart {d}\n", .{start}); | 2475 | try writer.print("\nstart {d}\n", .{start}); |
| 2476 | }, | 2476 | }, |
| 2477 | .data_count => { | 2477 | .data_count => { |
| 2478 | const count = try std.leb.readULEB128(u32, reader); | 2478 | const count = try std.leb.readUleb128(u32, reader); |
| 2479 | try writer.print("\ncount {d}\n", .{count}); | 2479 | try writer.print("\ncount {d}\n", .{count}); |
| 2480 | }, | 2480 | }, |
| 2481 | else => {}, // skip unknown sections | 2481 | else => {}, // skip unknown sections |
| ... | @@ -2494,13 +2494,13 @@ const WasmDumper = struct { | ... | @@ -2494,13 +2494,13 @@ const WasmDumper = struct { |
| 2494 | if (func_type != std.wasm.function_type) { | 2494 | if (func_type != std.wasm.function_type) { |
| 2495 | return step.fail("expected function type, found byte '{d}'", .{func_type}); | 2495 | return step.fail("expected function type, found byte '{d}'", .{func_type}); |
| 2496 | } | 2496 | } |
| 2497 | const params = try std.leb.readULEB128(u32, reader); | 2497 | const params = try std.leb.readUleb128(u32, reader); |
| 2498 | try writer.print("params {d}\n", .{params}); | 2498 | try writer.print("params {d}\n", .{params}); |
| 2499 | var index: u32 = 0; | 2499 | var index: u32 = 0; |
| 2500 | while (index < params) : (index += 1) { | 2500 | while (index < params) : (index += 1) { |
| 2501 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); | 2501 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); |
| 2502 | } else index = 0; | 2502 | } else index = 0; |
| 2503 | const returns = try std.leb.readULEB128(u32, reader); | 2503 | const returns = try std.leb.readUleb128(u32, reader); |
| 2504 | try writer.print("returns {d}\n", .{returns}); | 2504 | try writer.print("returns {d}\n", .{returns}); |
| 2505 | while (index < returns) : (index += 1) { | 2505 | while (index < returns) : (index += 1) { |
| 2506 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); | 2506 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); |
| ... | @@ -2510,10 +2510,10 @@ const WasmDumper = struct { | ... | @@ -2510,10 +2510,10 @@ const WasmDumper = struct { |
| 2510 | .import => { | 2510 | .import => { |
| 2511 | var i: u32 = 0; | 2511 | var i: u32 = 0; |
| 2512 | while (i < entries) : (i += 1) { | 2512 | while (i < entries) : (i += 1) { |
| 2513 | const module_name_len = try std.leb.readULEB128(u32, reader); | 2513 | const module_name_len = try std.leb.readUleb128(u32, reader); |
| 2514 | const module_name = data[fbs.pos..][0..module_name_len]; | 2514 | const module_name = data[fbs.pos..][0..module_name_len]; |
| 2515 | fbs.pos += module_name_len; | 2515 | fbs.pos += module_name_len; |
| 2516 | const name_len = try std.leb.readULEB128(u32, reader); | 2516 | const name_len = try std.leb.readUleb128(u32, reader); |
| 2517 | const name = data[fbs.pos..][0..name_len]; | 2517 | const name = data[fbs.pos..][0..name_len]; |
| 2518 | fbs.pos += name_len; | 2518 | fbs.pos += name_len; |
| 2519 | 2519 | ||
| ... | @@ -2529,14 +2529,14 @@ const WasmDumper = struct { | ... | @@ -2529,14 +2529,14 @@ const WasmDumper = struct { |
| 2529 | try writer.writeByte('\n'); | 2529 | try writer.writeByte('\n'); |
| 2530 | switch (kind) { | 2530 | switch (kind) { |
| 2531 | .function => { | 2531 | .function => { |
| 2532 | try writer.print("index {d}\n", .{try std.leb.readULEB128(u32, reader)}); | 2532 | try writer.print("index {d}\n", .{try std.leb.readUleb128(u32, reader)}); |
| 2533 | }, | 2533 | }, |
| 2534 | .memory => { | 2534 | .memory => { |
| 2535 | try parseDumpLimits(reader, writer); | 2535 | try parseDumpLimits(reader, writer); |
| 2536 | }, | 2536 | }, |
| 2537 | .global => { | 2537 | .global => { |
| 2538 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); | 2538 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); |
| 2539 | try writer.print("mutable {}\n", .{0x01 == try std.leb.readULEB128(u32, reader)}); | 2539 | try writer.print("mutable {}\n", .{0x01 == try std.leb.readUleb128(u32, reader)}); |
| 2540 | }, | 2540 | }, |
| 2541 | .table => { | 2541 | .table => { |
| 2542 | _ = try parseDumpType(step, std.wasm.RefType, reader, writer); | 2542 | _ = try parseDumpType(step, std.wasm.RefType, reader, writer); |
| ... | @@ -2548,7 +2548,7 @@ const WasmDumper = struct { | ... | @@ -2548,7 +2548,7 @@ const WasmDumper = struct { |
| 2548 | .function => { | 2548 | .function => { |
| 2549 | var i: u32 = 0; | 2549 | var i: u32 = 0; |
| 2550 | while (i < entries) : (i += 1) { | 2550 | while (i < entries) : (i += 1) { |
| 2551 | try writer.print("index {d}\n", .{try std.leb.readULEB128(u32, reader)}); | 2551 | try writer.print("index {d}\n", .{try std.leb.readUleb128(u32, reader)}); |
| 2552 | } | 2552 | } |
| 2553 | }, | 2553 | }, |
| 2554 | .table => { | 2554 | .table => { |
| ... | @@ -2568,21 +2568,21 @@ const WasmDumper = struct { | ... | @@ -2568,21 +2568,21 @@ const WasmDumper = struct { |
| 2568 | var i: u32 = 0; | 2568 | var i: u32 = 0; |
| 2569 | while (i < entries) : (i += 1) { | 2569 | while (i < entries) : (i += 1) { |
| 2570 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); | 2570 | _ = try parseDumpType(step, std.wasm.Valtype, reader, writer); |
| 2571 | try writer.print("mutable {}\n", .{0x01 == try std.leb.readULEB128(u1, reader)}); | 2571 | try writer.print("mutable {}\n", .{0x01 == try std.leb.readUleb128(u1, reader)}); |
| 2572 | try parseDumpInit(step, reader, writer); | 2572 | try parseDumpInit(step, reader, writer); |
| 2573 | } | 2573 | } |
| 2574 | }, | 2574 | }, |
| 2575 | .@"export" => { | 2575 | .@"export" => { |
| 2576 | var i: u32 = 0; | 2576 | var i: u32 = 0; |
| 2577 | while (i < entries) : (i += 1) { | 2577 | while (i < entries) : (i += 1) { |
| 2578 | const name_len = try std.leb.readULEB128(u32, reader); | 2578 | const name_len = try std.leb.readUleb128(u32, reader); |
| 2579 | const name = data[fbs.pos..][0..name_len]; | 2579 | const name = data[fbs.pos..][0..name_len]; |
| 2580 | fbs.pos += name_len; | 2580 | fbs.pos += name_len; |
| 2581 | const kind_byte = try std.leb.readULEB128(u8, reader); | 2581 | const kind_byte = try std.leb.readUleb128(u8, reader); |
| 2582 | const kind = std.meta.intToEnum(std.wasm.ExternalKind, kind_byte) catch { | 2582 | const kind = std.meta.intToEnum(std.wasm.ExternalKind, kind_byte) catch { |
| 2583 | return step.fail("invalid export kind value '{d}'", .{kind_byte}); | 2583 | return step.fail("invalid export kind value '{d}'", .{kind_byte}); |
| 2584 | }; | 2584 | }; |
| 2585 | const index = try std.leb.readULEB128(u32, reader); | 2585 | const index = try std.leb.readUleb128(u32, reader); |
| 2586 | try writer.print( | 2586 | try writer.print( |
| 2587 | \\name {s} | 2587 | \\name {s} |
| 2588 | \\kind {s} | 2588 | \\kind {s} |
| ... | @@ -2594,14 +2594,14 @@ const WasmDumper = struct { | ... | @@ -2594,14 +2594,14 @@ const WasmDumper = struct { |
| 2594 | .element => { | 2594 | .element => { |
| 2595 | var i: u32 = 0; | 2595 | var i: u32 = 0; |
| 2596 | while (i < entries) : (i += 1) { | 2596 | while (i < entries) : (i += 1) { |
| 2597 | try writer.print("table index {d}\n", .{try std.leb.readULEB128(u32, reader)}); | 2597 | try writer.print("table index {d}\n", .{try std.leb.readUleb128(u32, reader)}); |
| 2598 | try parseDumpInit(step, reader, writer); | 2598 | try parseDumpInit(step, reader, writer); |
| 2599 | 2599 | ||
| 2600 | const function_indexes = try std.leb.readULEB128(u32, reader); | 2600 | const function_indexes = try std.leb.readUleb128(u32, reader); |
| 2601 | var function_index: u32 = 0; | 2601 | var function_index: u32 = 0; |
| 2602 | try writer.print("indexes {d}\n", .{function_indexes}); | 2602 | try writer.print("indexes {d}\n", .{function_indexes}); |
| 2603 | while (function_index < function_indexes) : (function_index += 1) { | 2603 | while (function_index < function_indexes) : (function_index += 1) { |
| 2604 | try writer.print("index {d}\n", .{try std.leb.readULEB128(u32, reader)}); | 2604 | try writer.print("index {d}\n", .{try std.leb.readUleb128(u32, reader)}); |
| 2605 | } | 2605 | } |
| 2606 | } | 2606 | } |
| 2607 | }, | 2607 | }, |
| ... | @@ -2609,9 +2609,9 @@ const WasmDumper = struct { | ... | @@ -2609,9 +2609,9 @@ const WasmDumper = struct { |
| 2609 | .data => { | 2609 | .data => { |
| 2610 | var i: u32 = 0; | 2610 | var i: u32 = 0; |
| 2611 | while (i < entries) : (i += 1) { | 2611 | while (i < entries) : (i += 1) { |
| 2612 | const flags = try std.leb.readULEB128(u32, reader); | 2612 | const flags = try std.leb.readUleb128(u32, reader); |
| 2613 | const index = if (flags & 0x02 != 0) | 2613 | const index = if (flags & 0x02 != 0) |
| 2614 | try std.leb.readULEB128(u32, reader) | 2614 | try std.leb.readUleb128(u32, reader) |
| 2615 | else | 2615 | else |
| 2616 | 0; | 2616 | 0; |
| 2617 | try writer.print("memory index 0x{x}\n", .{index}); | 2617 | try writer.print("memory index 0x{x}\n", .{index}); |
| ... | @@ -2619,7 +2619,7 @@ const WasmDumper = struct { | ... | @@ -2619,7 +2619,7 @@ const WasmDumper = struct { |
| 2619 | try parseDumpInit(step, reader, writer); | 2619 | try parseDumpInit(step, reader, writer); |
| 2620 | } | 2620 | } |
| 2621 | 2621 | ||
| 2622 | const size = try std.leb.readULEB128(u32, reader); | 2622 | const size = try std.leb.readUleb128(u32, reader); |
| 2623 | try writer.print("size {d}\n", .{size}); | 2623 | try writer.print("size {d}\n", .{size}); |
| 2624 | try reader.skipBytes(size, .{}); // we do not care about the content of the segments | 2624 | try reader.skipBytes(size, .{}); // we do not care about the content of the segments |
| 2625 | } | 2625 | } |
| ... | @@ -2638,12 +2638,12 @@ const WasmDumper = struct { | ... | @@ -2638,12 +2638,12 @@ const WasmDumper = struct { |
| 2638 | } | 2638 | } |
| 2639 | 2639 | ||
| 2640 | fn parseDumpLimits(reader: anytype, writer: anytype) !void { | 2640 | fn parseDumpLimits(reader: anytype, writer: anytype) !void { |
| 2641 | const flags = try std.leb.readULEB128(u8, reader); | 2641 | const flags = try std.leb.readUleb128(u8, reader); |
| 2642 | const min = try std.leb.readULEB128(u32, reader); | 2642 | const min = try std.leb.readUleb128(u32, reader); |
| 2643 | 2643 | ||
| 2644 | try writer.print("min {x}\n", .{min}); | 2644 | try writer.print("min {x}\n", .{min}); |
| 2645 | if (flags != 0) { | 2645 | if (flags != 0) { |
| 2646 | try writer.print("max {x}\n", .{try std.leb.readULEB128(u32, reader)}); | 2646 | try writer.print("max {x}\n", .{try std.leb.readUleb128(u32, reader)}); |
| 2647 | } | 2647 | } |
| 2648 | } | 2648 | } |
| 2649 | 2649 | ||
| ... | @@ -2653,14 +2653,14 @@ const WasmDumper = struct { | ... | @@ -2653,14 +2653,14 @@ const WasmDumper = struct { |
| 2653 | return step.fail("invalid wasm opcode '{d}'", .{byte}); | 2653 | return step.fail("invalid wasm opcode '{d}'", .{byte}); |
| 2654 | }; | 2654 | }; |
| 2655 | switch (opcode) { | 2655 | switch (opcode) { |
| 2656 | .i32_const => try writer.print("i32.const {x}\n", .{try std.leb.readILEB128(i32, reader)}), | 2656 | .i32_const => try writer.print("i32.const {x}\n", .{try std.leb.readIleb128(i32, reader)}), |
| 2657 | .i64_const => try writer.print("i64.const {x}\n", .{try std.leb.readILEB128(i64, reader)}), | 2657 | .i64_const => try writer.print("i64.const {x}\n", .{try std.leb.readIleb128(i64, reader)}), |
| 2658 | .f32_const => try writer.print("f32.const {x}\n", .{@as(f32, @bitCast(try reader.readInt(u32, .little)))}), | 2658 | .f32_const => try writer.print("f32.const {x}\n", .{@as(f32, @bitCast(try reader.readInt(u32, .little)))}), |
| 2659 | .f64_const => try writer.print("f64.const {x}\n", .{@as(f64, @bitCast(try reader.readInt(u64, .little)))}), | 2659 | .f64_const => try writer.print("f64.const {x}\n", .{@as(f64, @bitCast(try reader.readInt(u64, .little)))}), |
| 2660 | .global_get => try writer.print("global.get {x}\n", .{try std.leb.readULEB128(u32, reader)}), | 2660 | .global_get => try writer.print("global.get {x}\n", .{try std.leb.readUleb128(u32, reader)}), |
| 2661 | else => unreachable, | 2661 | else => unreachable, |
| 2662 | } | 2662 | } |
| 2663 | const end_opcode = try std.leb.readULEB128(u8, reader); | 2663 | const end_opcode = try std.leb.readUleb128(u8, reader); |
| 2664 | if (end_opcode != std.wasm.opcode(.end)) { | 2664 | if (end_opcode != std.wasm.opcode(.end)) { |
| 2665 | return step.fail("expected 'end' opcode in init expression", .{}); | 2665 | return step.fail("expected 'end' opcode in init expression", .{}); |
| 2666 | } | 2666 | } |
| ... | @@ -2673,8 +2673,8 @@ const WasmDumper = struct { | ... | @@ -2673,8 +2673,8 @@ const WasmDumper = struct { |
| 2673 | // The module name subsection ... consists of a single name | 2673 | // The module name subsection ... consists of a single name |
| 2674 | // that is assigned to the module itself. | 2674 | // that is assigned to the module itself. |
| 2675 | .module => { | 2675 | .module => { |
| 2676 | const size = try std.leb.readULEB128(u32, reader); | 2676 | const size = try std.leb.readUleb128(u32, reader); |
| 2677 | const name_len = try std.leb.readULEB128(u32, reader); | 2677 | const name_len = try std.leb.readUleb128(u32, reader); |
| 2678 | if (size != name_len + 1) return error.BadSubsectionSize; | 2678 | if (size != name_len + 1) return error.BadSubsectionSize; |
| 2679 | if (reader.context.pos + name_len > data.len) return error.UnexpectedEndOfStream; | 2679 | if (reader.context.pos + name_len > data.len) return error.UnexpectedEndOfStream; |
| 2680 | try writer.print("name {s}\n", .{data[reader.context.pos..][0..name_len]}); | 2680 | try writer.print("name {s}\n", .{data[reader.context.pos..][0..name_len]}); |
| ... | @@ -2684,16 +2684,16 @@ const WasmDumper = struct { | ... | @@ -2684,16 +2684,16 @@ const WasmDumper = struct { |
| 2684 | // The function name subsection ... consists of a name map | 2684 | // The function name subsection ... consists of a name map |
| 2685 | // assigning function names to function indices. | 2685 | // assigning function names to function indices. |
| 2686 | .function, .global, .data_segment => { | 2686 | .function, .global, .data_segment => { |
| 2687 | const size = try std.leb.readULEB128(u32, reader); | 2687 | const size = try std.leb.readUleb128(u32, reader); |
| 2688 | const entries = try std.leb.readULEB128(u32, reader); | 2688 | const entries = try std.leb.readUleb128(u32, reader); |
| 2689 | try writer.print( | 2689 | try writer.print( |
| 2690 | \\size {d} | 2690 | \\size {d} |
| 2691 | \\names {d} | 2691 | \\names {d} |
| 2692 | \\ | 2692 | \\ |
| 2693 | , .{ size, entries }); | 2693 | , .{ size, entries }); |
| 2694 | for (0..entries) |_| { | 2694 | for (0..entries) |_| { |
| 2695 | const index = try std.leb.readULEB128(u32, reader); | 2695 | const index = try std.leb.readUleb128(u32, reader); |
| 2696 | const name_len = try std.leb.readULEB128(u32, reader); | 2696 | const name_len = try std.leb.readUleb128(u32, reader); |
| 2697 | if (reader.context.pos + name_len > data.len) return error.UnexpectedEndOfStream; | 2697 | if (reader.context.pos + name_len > data.len) return error.UnexpectedEndOfStream; |
| 2698 | const name = data[reader.context.pos..][0..name_len]; | 2698 | const name = data[reader.context.pos..][0..name_len]; |
| 2699 | reader.context.pos += name.len; | 2699 | reader.context.pos += name.len; |
| ... | @@ -2719,15 +2719,15 @@ const WasmDumper = struct { | ... | @@ -2719,15 +2719,15 @@ const WasmDumper = struct { |
| 2719 | } | 2719 | } |
| 2720 | 2720 | ||
| 2721 | fn parseDumpProducers(reader: anytype, writer: anytype, data: []const u8) !void { | 2721 | fn parseDumpProducers(reader: anytype, writer: anytype, data: []const u8) !void { |
| 2722 | const field_count = try std.leb.readULEB128(u32, reader); | 2722 | const field_count = try std.leb.readUleb128(u32, reader); |
| 2723 | try writer.print("fields {d}\n", .{field_count}); | 2723 | try writer.print("fields {d}\n", .{field_count}); |
| 2724 | var current_field: u32 = 0; | 2724 | var current_field: u32 = 0; |
| 2725 | while (current_field < field_count) : (current_field += 1) { | 2725 | while (current_field < field_count) : (current_field += 1) { |
| 2726 | const field_name_length = try std.leb.readULEB128(u32, reader); | 2726 | const field_name_length = try std.leb.readUleb128(u32, reader); |
| 2727 | const field_name = data[reader.context.pos..][0..field_name_length]; | 2727 | const field_name = data[reader.context.pos..][0..field_name_length]; |
| 2728 | reader.context.pos += field_name_length; | 2728 | reader.context.pos += field_name_length; |
| 2729 | 2729 | ||
| 2730 | const value_count = try std.leb.readULEB128(u32, reader); | 2730 | const value_count = try std.leb.readUleb128(u32, reader); |
| 2731 | try writer.print( | 2731 | try writer.print( |
| 2732 | \\field_name {s} | 2732 | \\field_name {s} |
| 2733 | \\values {d} | 2733 | \\values {d} |
| ... | @@ -2735,11 +2735,11 @@ const WasmDumper = struct { | ... | @@ -2735,11 +2735,11 @@ const WasmDumper = struct { |
| 2735 | try writer.writeByte('\n'); | 2735 | try writer.writeByte('\n'); |
| 2736 | var current_value: u32 = 0; | 2736 | var current_value: u32 = 0; |
| 2737 | while (current_value < value_count) : (current_value += 1) { | 2737 | while (current_value < value_count) : (current_value += 1) { |
| 2738 | const value_length = try std.leb.readULEB128(u32, reader); | 2738 | const value_length = try std.leb.readUleb128(u32, reader); |
| 2739 | const value = data[reader.context.pos..][0..value_length]; | 2739 | const value = data[reader.context.pos..][0..value_length]; |
| 2740 | reader.context.pos += value_length; | 2740 | reader.context.pos += value_length; |
| 2741 | 2741 | ||
| 2742 | const version_length = try std.leb.readULEB128(u32, reader); | 2742 | const version_length = try std.leb.readUleb128(u32, reader); |
| 2743 | const version = data[reader.context.pos..][0..version_length]; | 2743 | const version = data[reader.context.pos..][0..version_length]; |
| 2744 | reader.context.pos += version_length; | 2744 | reader.context.pos += version_length; |
| 2745 | 2745 | ||
| ... | @@ -2753,13 +2753,13 @@ const WasmDumper = struct { | ... | @@ -2753,13 +2753,13 @@ const WasmDumper = struct { |
| 2753 | } | 2753 | } |
| 2754 | 2754 | ||
| 2755 | fn parseDumpFeatures(reader: anytype, writer: anytype, data: []const u8) !void { | 2755 | fn parseDumpFeatures(reader: anytype, writer: anytype, data: []const u8) !void { |
| 2756 | const feature_count = try std.leb.readULEB128(u32, reader); | 2756 | const feature_count = try std.leb.readUleb128(u32, reader); |
| 2757 | try writer.print("features {d}\n", .{feature_count}); | 2757 | try writer.print("features {d}\n", .{feature_count}); |
| 2758 | 2758 | ||
| 2759 | var index: u32 = 0; | 2759 | var index: u32 = 0; |
| 2760 | while (index < feature_count) : (index += 1) { | 2760 | while (index < feature_count) : (index += 1) { |
| 2761 | const prefix_byte = try std.leb.readULEB128(u8, reader); | 2761 | const prefix_byte = try std.leb.readUleb128(u8, reader); |
| 2762 | const name_length = try std.leb.readULEB128(u32, reader); | 2762 | const name_length = try std.leb.readUleb128(u32, reader); |
| 2763 | const feature_name = data[reader.context.pos..][0..name_length]; | 2763 | const feature_name = data[reader.context.pos..][0..name_length]; |
| 2764 | reader.context.pos += name_length; | 2764 | reader.context.pos += name_length; |
| 2765 | 2765 |
lib/std/compress/xz.zig+3-3| ... | @@ -88,15 +88,15 @@ pub fn Decompress(comptime ReaderType: type) type { | ... | @@ -88,15 +88,15 @@ pub fn Decompress(comptime ReaderType: type) type { |
| 88 | 88 | ||
| 89 | const counting_reader = counter.reader(); | 89 | const counting_reader = counter.reader(); |
| 90 | 90 | ||
| 91 | const record_count = try std.leb.readULEB128(u64, counting_reader); | 91 | const record_count = try std.leb.readUleb128(u64, counting_reader); |
| 92 | if (record_count != self.block_decoder.block_count) | 92 | if (record_count != self.block_decoder.block_count) |
| 93 | return error.CorruptInput; | 93 | return error.CorruptInput; |
| 94 | 94 | ||
| 95 | var i: usize = 0; | 95 | var i: usize = 0; |
| 96 | while (i < record_count) : (i += 1) { | 96 | while (i < record_count) : (i += 1) { |
| 97 | // TODO: validate records | 97 | // TODO: validate records |
| 98 | _ = try std.leb.readULEB128(u64, counting_reader); | 98 | _ = try std.leb.readUleb128(u64, counting_reader); |
| 99 | _ = try std.leb.readULEB128(u64, counting_reader); | 99 | _ = try std.leb.readUleb128(u64, counting_reader); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | while (counter.bytes_read % 4 != 0) { | 102 | while (counter.bytes_read % 4 != 0) { |
lib/std/compress/xz/block.zig+4-4| ... | @@ -111,10 +111,10 @@ pub fn Decoder(comptime ReaderType: type) type { | ... | @@ -111,10 +111,10 @@ pub fn Decoder(comptime ReaderType: type) type { |
| 111 | return error.Unsupported; | 111 | return error.Unsupported; |
| 112 | 112 | ||
| 113 | if (flags.has_packed_size) | 113 | if (flags.has_packed_size) |
| 114 | packed_size = try std.leb.readULEB128(u64, header_reader); | 114 | packed_size = try std.leb.readUleb128(u64, header_reader); |
| 115 | 115 | ||
| 116 | if (flags.has_unpacked_size) | 116 | if (flags.has_unpacked_size) |
| 117 | unpacked_size = try std.leb.readULEB128(u64, header_reader); | 117 | unpacked_size = try std.leb.readUleb128(u64, header_reader); |
| 118 | 118 | ||
| 119 | const FilterId = enum(u64) { | 119 | const FilterId = enum(u64) { |
| 120 | lzma2 = 0x21, | 120 | lzma2 = 0x21, |
| ... | @@ -123,7 +123,7 @@ pub fn Decoder(comptime ReaderType: type) type { | ... | @@ -123,7 +123,7 @@ pub fn Decoder(comptime ReaderType: type) type { |
| 123 | 123 | ||
| 124 | const filter_id = @as( | 124 | const filter_id = @as( |
| 125 | FilterId, | 125 | FilterId, |
| 126 | @enumFromInt(try std.leb.readULEB128(u64, header_reader)), | 126 | @enumFromInt(try std.leb.readUleb128(u64, header_reader)), |
| 127 | ); | 127 | ); |
| 128 | 128 | ||
| 129 | if (@intFromEnum(filter_id) >= 0x4000_0000_0000_0000) | 129 | if (@intFromEnum(filter_id) >= 0x4000_0000_0000_0000) |
| ... | @@ -132,7 +132,7 @@ pub fn Decoder(comptime ReaderType: type) type { | ... | @@ -132,7 +132,7 @@ pub fn Decoder(comptime ReaderType: type) type { |
| 132 | if (filter_id != .lzma2) | 132 | if (filter_id != .lzma2) |
| 133 | return error.Unsupported; | 133 | return error.Unsupported; |
| 134 | 134 | ||
| 135 | const properties_size = try std.leb.readULEB128(u64, header_reader); | 135 | const properties_size = try std.leb.readUleb128(u64, header_reader); |
| 136 | if (properties_size != 1) | 136 | if (properties_size != 1) |
| 137 | return error.CorruptInput; | 137 | return error.CorruptInput; |
| 138 | 138 |
lib/std/dwarf.zig+2-2| ... | @@ -2762,11 +2762,11 @@ pub const FixedBufferReader = struct { | ... | @@ -2762,11 +2762,11 @@ pub const FixedBufferReader = struct { |
| 2762 | } | 2762 | } |
| 2763 | 2763 | ||
| 2764 | fn readUleb128(fbr: *FixedBufferReader, comptime T: type) Error!T { | 2764 | fn readUleb128(fbr: *FixedBufferReader, comptime T: type) Error!T { |
| 2765 | return std.leb.readULEB128(T, fbr); | 2765 | return std.leb.readUleb128(T, fbr); |
| 2766 | } | 2766 | } |
| 2767 | 2767 | ||
| 2768 | fn readIleb128(fbr: *FixedBufferReader, comptime T: type) Error!T { | 2768 | fn readIleb128(fbr: *FixedBufferReader, comptime T: type) Error!T { |
| 2769 | return std.leb.readILEB128(T, fbr); | 2769 | return std.leb.readIleb128(T, fbr); |
| 2770 | } | 2770 | } |
| 2771 | 2771 | ||
| 2772 | fn readAddress(fbr: *FixedBufferReader, format: Format) Error!u64 { | 2772 | fn readAddress(fbr: *FixedBufferReader, format: Format) Error!u64 { |
lib/std/dwarf/call_frame.zig+24-24| ... | @@ -53,7 +53,7 @@ const Opcode = enum(u8) { | ... | @@ -53,7 +53,7 @@ const Opcode = enum(u8) { |
| 53 | 53 | ||
| 54 | fn readBlock(stream: *std.io.FixedBufferStream([]const u8)) ![]const u8 { | 54 | fn readBlock(stream: *std.io.FixedBufferStream([]const u8)) ![]const u8 { |
| 55 | const reader = stream.reader(); | 55 | const reader = stream.reader(); |
| 56 | const block_len = try leb.readULEB128(usize, reader); | 56 | const block_len = try leb.readUleb128(usize, reader); |
| 57 | if (stream.pos + block_len > stream.buffer.len) return error.InvalidOperand; | 57 | if (stream.pos + block_len > stream.buffer.len) return error.InvalidOperand; |
| 58 | 58 | ||
| 59 | const block = stream.buffer[stream.pos..][0..block_len]; | 59 | const block = stream.buffer[stream.pos..][0..block_len]; |
| ... | @@ -163,7 +163,7 @@ pub const Instruction = union(Opcode) { | ... | @@ -163,7 +163,7 @@ pub const Instruction = union(Opcode) { |
| 163 | .offset => .{ | 163 | .offset => .{ |
| 164 | .offset = .{ | 164 | .offset = .{ |
| 165 | .register = value, | 165 | .register = value, |
| 166 | .offset = try leb.readULEB128(u64, reader), | 166 | .offset = try leb.readUleb128(u64, reader), |
| 167 | }, | 167 | }, |
| 168 | }, | 168 | }, |
| 169 | .restore => .{ | 169 | .restore => .{ |
| ... | @@ -201,47 +201,47 @@ pub const Instruction = union(Opcode) { | ... | @@ -201,47 +201,47 @@ pub const Instruction = union(Opcode) { |
| 201 | }, | 201 | }, |
| 202 | .offset_extended => .{ | 202 | .offset_extended => .{ |
| 203 | .offset_extended = .{ | 203 | .offset_extended = .{ |
| 204 | .register = try leb.readULEB128(u8, reader), | 204 | .register = try leb.readUleb128(u8, reader), |
| 205 | .offset = try leb.readULEB128(u64, reader), | 205 | .offset = try leb.readUleb128(u64, reader), |
| 206 | }, | 206 | }, |
| 207 | }, | 207 | }, |
| 208 | .restore_extended => .{ | 208 | .restore_extended => .{ |
| 209 | .restore_extended = .{ | 209 | .restore_extended = .{ |
| 210 | .register = try leb.readULEB128(u8, reader), | 210 | .register = try leb.readUleb128(u8, reader), |
| 211 | }, | 211 | }, |
| 212 | }, | 212 | }, |
| 213 | .undefined => .{ | 213 | .undefined => .{ |
| 214 | .undefined = .{ | 214 | .undefined = .{ |
| 215 | .register = try leb.readULEB128(u8, reader), | 215 | .register = try leb.readUleb128(u8, reader), |
| 216 | }, | 216 | }, |
| 217 | }, | 217 | }, |
| 218 | .same_value => .{ | 218 | .same_value => .{ |
| 219 | .same_value = .{ | 219 | .same_value = .{ |
| 220 | .register = try leb.readULEB128(u8, reader), | 220 | .register = try leb.readUleb128(u8, reader), |
| 221 | }, | 221 | }, |
| 222 | }, | 222 | }, |
| 223 | .register => .{ | 223 | .register => .{ |
| 224 | .register = .{ | 224 | .register = .{ |
| 225 | .register = try leb.readULEB128(u8, reader), | 225 | .register = try leb.readUleb128(u8, reader), |
| 226 | .target_register = try leb.readULEB128(u8, reader), | 226 | .target_register = try leb.readUleb128(u8, reader), |
| 227 | }, | 227 | }, |
| 228 | }, | 228 | }, |
| 229 | .remember_state => .{ .remember_state = {} }, | 229 | .remember_state => .{ .remember_state = {} }, |
| 230 | .restore_state => .{ .restore_state = {} }, | 230 | .restore_state => .{ .restore_state = {} }, |
| 231 | .def_cfa => .{ | 231 | .def_cfa => .{ |
| 232 | .def_cfa = .{ | 232 | .def_cfa = .{ |
| 233 | .register = try leb.readULEB128(u8, reader), | 233 | .register = try leb.readUleb128(u8, reader), |
| 234 | .offset = try leb.readULEB128(u64, reader), | 234 | .offset = try leb.readUleb128(u64, reader), |
| 235 | }, | 235 | }, |
| 236 | }, | 236 | }, |
| 237 | .def_cfa_register => .{ | 237 | .def_cfa_register => .{ |
| 238 | .def_cfa_register = .{ | 238 | .def_cfa_register = .{ |
| 239 | .register = try leb.readULEB128(u8, reader), | 239 | .register = try leb.readUleb128(u8, reader), |
| 240 | }, | 240 | }, |
| 241 | }, | 241 | }, |
| 242 | .def_cfa_offset => .{ | 242 | .def_cfa_offset => .{ |
| 243 | .def_cfa_offset = .{ | 243 | .def_cfa_offset = .{ |
| 244 | .offset = try leb.readULEB128(u64, reader), | 244 | .offset = try leb.readUleb128(u64, reader), |
| 245 | }, | 245 | }, |
| 246 | }, | 246 | }, |
| 247 | .def_cfa_expression => .{ | 247 | .def_cfa_expression => .{ |
| ... | @@ -251,42 +251,42 @@ pub const Instruction = union(Opcode) { | ... | @@ -251,42 +251,42 @@ pub const Instruction = union(Opcode) { |
| 251 | }, | 251 | }, |
| 252 | .expression => .{ | 252 | .expression => .{ |
| 253 | .expression = .{ | 253 | .expression = .{ |
| 254 | .register = try leb.readULEB128(u8, reader), | 254 | .register = try leb.readUleb128(u8, reader), |
| 255 | .block = try readBlock(stream), | 255 | .block = try readBlock(stream), |
| 256 | }, | 256 | }, |
| 257 | }, | 257 | }, |
| 258 | .offset_extended_sf => .{ | 258 | .offset_extended_sf => .{ |
| 259 | .offset_extended_sf = .{ | 259 | .offset_extended_sf = .{ |
| 260 | .register = try leb.readULEB128(u8, reader), | 260 | .register = try leb.readUleb128(u8, reader), |
| 261 | .offset = try leb.readILEB128(i64, reader), | 261 | .offset = try leb.readIleb128(i64, reader), |
| 262 | }, | 262 | }, |
| 263 | }, | 263 | }, |
| 264 | .def_cfa_sf => .{ | 264 | .def_cfa_sf => .{ |
| 265 | .def_cfa_sf = .{ | 265 | .def_cfa_sf = .{ |
| 266 | .register = try leb.readULEB128(u8, reader), | 266 | .register = try leb.readUleb128(u8, reader), |
| 267 | .offset = try leb.readILEB128(i64, reader), | 267 | .offset = try leb.readIleb128(i64, reader), |
| 268 | }, | 268 | }, |
| 269 | }, | 269 | }, |
| 270 | .def_cfa_offset_sf => .{ | 270 | .def_cfa_offset_sf => .{ |
| 271 | .def_cfa_offset_sf = .{ | 271 | .def_cfa_offset_sf = .{ |
| 272 | .offset = try leb.readILEB128(i64, reader), | 272 | .offset = try leb.readIleb128(i64, reader), |
| 273 | }, | 273 | }, |
| 274 | }, | 274 | }, |
| 275 | .val_offset => .{ | 275 | .val_offset => .{ |
| 276 | .val_offset = .{ | 276 | .val_offset = .{ |
| 277 | .register = try leb.readULEB128(u8, reader), | 277 | .register = try leb.readUleb128(u8, reader), |
| 278 | .offset = try leb.readULEB128(u64, reader), | 278 | .offset = try leb.readUleb128(u64, reader), |
| 279 | }, | 279 | }, |
| 280 | }, | 280 | }, |
| 281 | .val_offset_sf => .{ | 281 | .val_offset_sf => .{ |
| 282 | .val_offset_sf = .{ | 282 | .val_offset_sf = .{ |
| 283 | .register = try leb.readULEB128(u8, reader), | 283 | .register = try leb.readUleb128(u8, reader), |
| 284 | .offset = try leb.readILEB128(i64, reader), | 284 | .offset = try leb.readIleb128(i64, reader), |
| 285 | }, | 285 | }, |
| 286 | }, | 286 | }, |
| 287 | .val_expression => .{ | 287 | .val_expression => .{ |
| 288 | .val_expression = .{ | 288 | .val_expression = .{ |
| 289 | .register = try leb.readULEB128(u8, reader), | 289 | .register = try leb.readUleb128(u8, reader), |
| 290 | .block = try readBlock(stream), | 290 | .block = try readBlock(stream), |
| 291 | }, | 291 | }, |
| 292 | }, | 292 | }, |
lib/std/dwarf/expressions.zig+33-33| ... | @@ -219,28 +219,28 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { | ... | @@ -219,28 +219,28 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 219 | OP.constx, | 219 | OP.constx, |
| 220 | OP.convert, | 220 | OP.convert, |
| 221 | OP.reinterpret, | 221 | OP.reinterpret, |
| 222 | => generic(try leb.readULEB128(u64, reader)), | 222 | => generic(try leb.readUleb128(u64, reader)), |
| 223 | OP.consts, | 223 | OP.consts, |
| 224 | OP.fbreg, | 224 | OP.fbreg, |
| 225 | => generic(try leb.readILEB128(i64, reader)), | 225 | => generic(try leb.readIleb128(i64, reader)), |
| 226 | OP.lit0...OP.lit31 => |n| generic(n - OP.lit0), | 226 | OP.lit0...OP.lit31 => |n| generic(n - OP.lit0), |
| 227 | OP.reg0...OP.reg31 => |n| .{ .register = n - OP.reg0 }, | 227 | OP.reg0...OP.reg31 => |n| .{ .register = n - OP.reg0 }, |
| 228 | OP.breg0...OP.breg31 => |n| .{ .base_register = .{ | 228 | OP.breg0...OP.breg31 => |n| .{ .base_register = .{ |
| 229 | .base_register = n - OP.breg0, | 229 | .base_register = n - OP.breg0, |
| 230 | .offset = try leb.readILEB128(i64, reader), | 230 | .offset = try leb.readIleb128(i64, reader), |
| 231 | } }, | 231 | } }, |
| 232 | OP.regx => .{ .register = try leb.readULEB128(u8, reader) }, | 232 | OP.regx => .{ .register = try leb.readUleb128(u8, reader) }, |
| 233 | OP.bregx => blk: { | 233 | OP.bregx => blk: { |
| 234 | const base_register = try leb.readULEB128(u8, reader); | 234 | const base_register = try leb.readUleb128(u8, reader); |
| 235 | const offset = try leb.readILEB128(i64, reader); | 235 | const offset = try leb.readIleb128(i64, reader); |
| 236 | break :blk .{ .base_register = .{ | 236 | break :blk .{ .base_register = .{ |
| 237 | .base_register = base_register, | 237 | .base_register = base_register, |
| 238 | .offset = offset, | 238 | .offset = offset, |
| 239 | } }; | 239 | } }; |
| 240 | }, | 240 | }, |
| 241 | OP.regval_type => blk: { | 241 | OP.regval_type => blk: { |
| 242 | const register = try leb.readULEB128(u8, reader); | 242 | const register = try leb.readUleb128(u8, reader); |
| 243 | const type_offset = try leb.readULEB128(addr_type, reader); | 243 | const type_offset = try leb.readUleb128(addr_type, reader); |
| 244 | break :blk .{ .register_type = .{ | 244 | break :blk .{ .register_type = .{ |
| 245 | .register = register, | 245 | .register = register, |
| 246 | .type_offset = type_offset, | 246 | .type_offset = type_offset, |
| ... | @@ -248,20 +248,20 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { | ... | @@ -248,20 +248,20 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 248 | }, | 248 | }, |
| 249 | OP.piece => .{ | 249 | OP.piece => .{ |
| 250 | .composite_location = .{ | 250 | .composite_location = .{ |
| 251 | .size = try leb.readULEB128(u8, reader), | 251 | .size = try leb.readUleb128(u8, reader), |
| 252 | .offset = 0, | 252 | .offset = 0, |
| 253 | }, | 253 | }, |
| 254 | }, | 254 | }, |
| 255 | OP.bit_piece => blk: { | 255 | OP.bit_piece => blk: { |
| 256 | const size = try leb.readULEB128(u8, reader); | 256 | const size = try leb.readUleb128(u8, reader); |
| 257 | const offset = try leb.readILEB128(i64, reader); | 257 | const offset = try leb.readIleb128(i64, reader); |
| 258 | break :blk .{ .composite_location = .{ | 258 | break :blk .{ .composite_location = .{ |
| 259 | .size = size, | 259 | .size = size, |
| 260 | .offset = offset, | 260 | .offset = offset, |
| 261 | } }; | 261 | } }; |
| 262 | }, | 262 | }, |
| 263 | OP.implicit_value, OP.entry_value => blk: { | 263 | OP.implicit_value, OP.entry_value => blk: { |
| 264 | const size = try leb.readULEB128(u8, reader); | 264 | const size = try leb.readUleb128(u8, reader); |
| 265 | if (stream.pos + size > stream.buffer.len) return error.InvalidExpression; | 265 | if (stream.pos + size > stream.buffer.len) return error.InvalidExpression; |
| 266 | const block = stream.buffer[stream.pos..][0..size]; | 266 | const block = stream.buffer[stream.pos..][0..size]; |
| 267 | stream.pos += size; | 267 | stream.pos += size; |
| ... | @@ -270,7 +270,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { | ... | @@ -270,7 +270,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 270 | }; | 270 | }; |
| 271 | }, | 271 | }, |
| 272 | OP.const_type => blk: { | 272 | OP.const_type => blk: { |
| 273 | const type_offset = try leb.readULEB128(addr_type, reader); | 273 | const type_offset = try leb.readUleb128(addr_type, reader); |
| 274 | const size = try reader.readByte(); | 274 | const size = try reader.readByte(); |
| 275 | if (stream.pos + size > stream.buffer.len) return error.InvalidExpression; | 275 | if (stream.pos + size > stream.buffer.len) return error.InvalidExpression; |
| 276 | const value_bytes = stream.buffer[stream.pos..][0..size]; | 276 | const value_bytes = stream.buffer[stream.pos..][0..size]; |
| ... | @@ -285,7 +285,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { | ... | @@ -285,7 +285,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 285 | => .{ | 285 | => .{ |
| 286 | .deref_type = .{ | 286 | .deref_type = .{ |
| 287 | .size = try reader.readByte(), | 287 | .size = try reader.readByte(), |
| 288 | .type_offset = try leb.readULEB128(addr_type, reader), | 288 | .type_offset = try leb.readUleb128(addr_type, reader), |
| 289 | }, | 289 | }, |
| 290 | }, | 290 | }, |
| 291 | OP.lo_user...OP.hi_user => return error.UnimplementedUserOpcode, | 291 | OP.lo_user...OP.hi_user => return error.UnimplementedUserOpcode, |
| ... | @@ -863,11 +863,11 @@ pub fn Builder(comptime options: ExpressionOptions) type { | ... | @@ -863,11 +863,11 @@ pub fn Builder(comptime options: ExpressionOptions) type { |
| 863 | else => switch (@typeInfo(T).Int.signedness) { | 863 | else => switch (@typeInfo(T).Int.signedness) { |
| 864 | .unsigned => { | 864 | .unsigned => { |
| 865 | try writer.writeByte(OP.constu); | 865 | try writer.writeByte(OP.constu); |
| 866 | try leb.writeULEB128(writer, value); | 866 | try leb.writeUleb128(writer, value); |
| 867 | }, | 867 | }, |
| 868 | .signed => { | 868 | .signed => { |
| 869 | try writer.writeByte(OP.consts); | 869 | try writer.writeByte(OP.consts); |
| 870 | try leb.writeILEB128(writer, value); | 870 | try leb.writeIleb128(writer, value); |
| 871 | }, | 871 | }, |
| 872 | }, | 872 | }, |
| 873 | } | 873 | } |
| ... | @@ -875,14 +875,14 @@ pub fn Builder(comptime options: ExpressionOptions) type { | ... | @@ -875,14 +875,14 @@ pub fn Builder(comptime options: ExpressionOptions) type { |
| 875 | 875 | ||
| 876 | pub fn writeConstx(writer: anytype, debug_addr_offset: anytype) !void { | 876 | pub fn writeConstx(writer: anytype, debug_addr_offset: anytype) !void { |
| 877 | try writer.writeByte(OP.constx); | 877 | try writer.writeByte(OP.constx); |
| 878 | try leb.writeULEB128(writer, debug_addr_offset); | 878 | try leb.writeUleb128(writer, debug_addr_offset); |
| 879 | } | 879 | } |
| 880 | 880 | ||
| 881 | pub fn writeConstType(writer: anytype, die_offset: anytype, value_bytes: []const u8) !void { | 881 | pub fn writeConstType(writer: anytype, die_offset: anytype, value_bytes: []const u8) !void { |
| 882 | if (options.call_frame_context) return error.InvalidCFAOpcode; | 882 | if (options.call_frame_context) return error.InvalidCFAOpcode; |
| 883 | if (value_bytes.len > 0xff) return error.InvalidTypeLength; | 883 | if (value_bytes.len > 0xff) return error.InvalidTypeLength; |
| 884 | try writer.writeByte(OP.const_type); | 884 | try writer.writeByte(OP.const_type); |
| 885 | try leb.writeULEB128(writer, die_offset); | 885 | try leb.writeUleb128(writer, die_offset); |
| 886 | try writer.writeByte(@intCast(value_bytes.len)); | 886 | try writer.writeByte(@intCast(value_bytes.len)); |
| 887 | try writer.writeAll(value_bytes); | 887 | try writer.writeAll(value_bytes); |
| 888 | } | 888 | } |
| ... | @@ -895,32 +895,32 @@ pub fn Builder(comptime options: ExpressionOptions) type { | ... | @@ -895,32 +895,32 @@ pub fn Builder(comptime options: ExpressionOptions) type { |
| 895 | pub fn writeAddrx(writer: anytype, debug_addr_offset: anytype) !void { | 895 | pub fn writeAddrx(writer: anytype, debug_addr_offset: anytype) !void { |
| 896 | if (options.call_frame_context) return error.InvalidCFAOpcode; | 896 | if (options.call_frame_context) return error.InvalidCFAOpcode; |
| 897 | try writer.writeByte(OP.addrx); | 897 | try writer.writeByte(OP.addrx); |
| 898 | try leb.writeULEB128(writer, debug_addr_offset); | 898 | try leb.writeUleb128(writer, debug_addr_offset); |
| 899 | } | 899 | } |
| 900 | 900 | ||
| 901 | // 2.5.1.2: Register Values | 901 | // 2.5.1.2: Register Values |
| 902 | pub fn writeFbreg(writer: anytype, offset: anytype) !void { | 902 | pub fn writeFbreg(writer: anytype, offset: anytype) !void { |
| 903 | try writer.writeByte(OP.fbreg); | 903 | try writer.writeByte(OP.fbreg); |
| 904 | try leb.writeILEB128(writer, offset); | 904 | try leb.writeIleb128(writer, offset); |
| 905 | } | 905 | } |
| 906 | 906 | ||
| 907 | pub fn writeBreg(writer: anytype, register: u8, offset: anytype) !void { | 907 | pub fn writeBreg(writer: anytype, register: u8, offset: anytype) !void { |
| 908 | if (register > 31) return error.InvalidRegister; | 908 | if (register > 31) return error.InvalidRegister; |
| 909 | try writer.writeByte(OP.breg0 + register); | 909 | try writer.writeByte(OP.breg0 + register); |
| 910 | try leb.writeILEB128(writer, offset); | 910 | try leb.writeIleb128(writer, offset); |
| 911 | } | 911 | } |
| 912 | 912 | ||
| 913 | pub fn writeBregx(writer: anytype, register: anytype, offset: anytype) !void { | 913 | pub fn writeBregx(writer: anytype, register: anytype, offset: anytype) !void { |
| 914 | try writer.writeByte(OP.bregx); | 914 | try writer.writeByte(OP.bregx); |
| 915 | try leb.writeULEB128(writer, register); | 915 | try leb.writeUleb128(writer, register); |
| 916 | try leb.writeILEB128(writer, offset); | 916 | try leb.writeIleb128(writer, offset); |
| 917 | } | 917 | } |
| 918 | 918 | ||
| 919 | pub fn writeRegvalType(writer: anytype, register: anytype, offset: anytype) !void { | 919 | pub fn writeRegvalType(writer: anytype, register: anytype, offset: anytype) !void { |
| 920 | if (options.call_frame_context) return error.InvalidCFAOpcode; | 920 | if (options.call_frame_context) return error.InvalidCFAOpcode; |
| 921 | try writer.writeByte(OP.regval_type); | 921 | try writer.writeByte(OP.regval_type); |
| 922 | try leb.writeULEB128(writer, register); | 922 | try leb.writeUleb128(writer, register); |
| 923 | try leb.writeULEB128(writer, offset); | 923 | try leb.writeUleb128(writer, offset); |
| 924 | } | 924 | } |
| 925 | 925 | ||
| 926 | // 2.5.1.3: Stack Operations | 926 | // 2.5.1.3: Stack Operations |
| ... | @@ -943,20 +943,20 @@ pub fn Builder(comptime options: ExpressionOptions) type { | ... | @@ -943,20 +943,20 @@ pub fn Builder(comptime options: ExpressionOptions) type { |
| 943 | if (options.call_frame_context) return error.InvalidCFAOpcode; | 943 | if (options.call_frame_context) return error.InvalidCFAOpcode; |
| 944 | try writer.writeByte(OP.deref_type); | 944 | try writer.writeByte(OP.deref_type); |
| 945 | try writer.writeByte(size); | 945 | try writer.writeByte(size); |
| 946 | try leb.writeULEB128(writer, die_offset); | 946 | try leb.writeUleb128(writer, die_offset); |
| 947 | } | 947 | } |
| 948 | 948 | ||
| 949 | pub fn writeXDerefType(writer: anytype, size: u8, die_offset: anytype) !void { | 949 | pub fn writeXDerefType(writer: anytype, size: u8, die_offset: anytype) !void { |
| 950 | try writer.writeByte(OP.xderef_type); | 950 | try writer.writeByte(OP.xderef_type); |
| 951 | try writer.writeByte(size); | 951 | try writer.writeByte(size); |
| 952 | try leb.writeULEB128(writer, die_offset); | 952 | try leb.writeUleb128(writer, die_offset); |
| 953 | } | 953 | } |
| 954 | 954 | ||
| 955 | // 2.5.1.4: Arithmetic and Logical Operations | 955 | // 2.5.1.4: Arithmetic and Logical Operations |
| 956 | 956 | ||
| 957 | pub fn writePlusUconst(writer: anytype, uint_value: anytype) !void { | 957 | pub fn writePlusUconst(writer: anytype, uint_value: anytype) !void { |
| 958 | try writer.writeByte(OP.plus_uconst); | 958 | try writer.writeByte(OP.plus_uconst); |
| 959 | try leb.writeULEB128(writer, uint_value); | 959 | try leb.writeUleb128(writer, uint_value); |
| 960 | } | 960 | } |
| 961 | 961 | ||
| 962 | // 2.5.1.5: Control Flow Operations | 962 | // 2.5.1.5: Control Flow Operations |
| ... | @@ -991,20 +991,20 @@ pub fn Builder(comptime options: ExpressionOptions) type { | ... | @@ -991,20 +991,20 @@ pub fn Builder(comptime options: ExpressionOptions) type { |
| 991 | pub fn writeConvert(writer: anytype, die_offset: anytype) !void { | 991 | pub fn writeConvert(writer: anytype, die_offset: anytype) !void { |
| 992 | if (options.call_frame_context) return error.InvalidCFAOpcode; | 992 | if (options.call_frame_context) return error.InvalidCFAOpcode; |
| 993 | try writer.writeByte(OP.convert); | 993 | try writer.writeByte(OP.convert); |
| 994 | try leb.writeULEB128(writer, die_offset); | 994 | try leb.writeUleb128(writer, die_offset); |
| 995 | } | 995 | } |
| 996 | 996 | ||
| 997 | pub fn writeReinterpret(writer: anytype, die_offset: anytype) !void { | 997 | pub fn writeReinterpret(writer: anytype, die_offset: anytype) !void { |
| 998 | if (options.call_frame_context) return error.InvalidCFAOpcode; | 998 | if (options.call_frame_context) return error.InvalidCFAOpcode; |
| 999 | try writer.writeByte(OP.reinterpret); | 999 | try writer.writeByte(OP.reinterpret); |
| 1000 | try leb.writeULEB128(writer, die_offset); | 1000 | try leb.writeUleb128(writer, die_offset); |
| 1001 | } | 1001 | } |
| 1002 | 1002 | ||
| 1003 | // 2.5.1.7: Special Operations | 1003 | // 2.5.1.7: Special Operations |
| 1004 | 1004 | ||
| 1005 | pub fn writeEntryValue(writer: anytype, expression: []const u8) !void { | 1005 | pub fn writeEntryValue(writer: anytype, expression: []const u8) !void { |
| 1006 | try writer.writeByte(OP.entry_value); | 1006 | try writer.writeByte(OP.entry_value); |
| 1007 | try leb.writeULEB128(writer, expression.len); | 1007 | try leb.writeUleb128(writer, expression.len); |
| 1008 | try writer.writeAll(expression); | 1008 | try writer.writeAll(expression); |
| 1009 | } | 1009 | } |
| 1010 | 1010 | ||
| ... | @@ -1015,12 +1015,12 @@ pub fn Builder(comptime options: ExpressionOptions) type { | ... | @@ -1015,12 +1015,12 @@ pub fn Builder(comptime options: ExpressionOptions) type { |
| 1015 | 1015 | ||
| 1016 | pub fn writeRegx(writer: anytype, register: anytype) !void { | 1016 | pub fn writeRegx(writer: anytype, register: anytype) !void { |
| 1017 | try writer.writeByte(OP.regx); | 1017 | try writer.writeByte(OP.regx); |
| 1018 | try leb.writeULEB128(writer, register); | 1018 | try leb.writeUleb128(writer, register); |
| 1019 | } | 1019 | } |
| 1020 | 1020 | ||
| 1021 | pub fn writeImplicitValue(writer: anytype, value_bytes: []const u8) !void { | 1021 | pub fn writeImplicitValue(writer: anytype, value_bytes: []const u8) !void { |
| 1022 | try writer.writeByte(OP.implicit_value); | 1022 | try writer.writeByte(OP.implicit_value); |
| 1023 | try leb.writeULEB128(writer, value_bytes.len); | 1023 | try leb.writeUleb128(writer, value_bytes.len); |
| 1024 | try writer.writeAll(value_bytes); | 1024 | try writer.writeAll(value_bytes); |
| 1025 | } | 1025 | } |
| 1026 | }; | 1026 | }; |
lib/std/leb128.zig+24-12| ... | @@ -3,7 +3,7 @@ const testing = std.testing; | ... | @@ -3,7 +3,7 @@ const testing = std.testing; |
| 3 | 3 | ||
| 4 | /// Read a single unsigned LEB128 value from the given reader as type T, | 4 | /// Read a single unsigned LEB128 value from the given reader as type T, |
| 5 | /// or error.Overflow if the value cannot fit. | 5 | /// or error.Overflow if the value cannot fit. |
| 6 | pub fn readULEB128(comptime T: type, reader: anytype) !T { | 6 | pub fn readUleb128(comptime T: type, reader: anytype) !T { |
| 7 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; | 7 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; |
| 8 | const ShiftT = std.math.Log2Int(U); | 8 | const ShiftT = std.math.Log2Int(U); |
| 9 | 9 | ||
| ... | @@ -32,8 +32,11 @@ pub fn readULEB128(comptime T: type, reader: anytype) !T { | ... | @@ -32,8 +32,11 @@ pub fn readULEB128(comptime T: type, reader: anytype) !T { |
| 32 | return @as(T, @truncate(value)); | 32 | return @as(T, @truncate(value)); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | /// Deprecated: use `readUleb128` | ||
| 36 | pub const readULEB128 = readUleb128; | ||
| 37 | |||
| 35 | /// Write a single unsigned integer as unsigned LEB128 to the given writer. | 38 | /// Write a single unsigned integer as unsigned LEB128 to the given writer. |
| 36 | pub fn writeULEB128(writer: anytype, uint_value: anytype) !void { | 39 | pub fn writeUleb128(writer: anytype, uint_value: anytype) !void { |
| 37 | const T = @TypeOf(uint_value); | 40 | const T = @TypeOf(uint_value); |
| 38 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; | 41 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; |
| 39 | var value: U = @intCast(uint_value); | 42 | var value: U = @intCast(uint_value); |
| ... | @@ -50,9 +53,12 @@ pub fn writeULEB128(writer: anytype, uint_value: anytype) !void { | ... | @@ -50,9 +53,12 @@ pub fn writeULEB128(writer: anytype, uint_value: anytype) !void { |
| 50 | } | 53 | } |
| 51 | } | 54 | } |
| 52 | 55 | ||
| 56 | /// Deprecated: use `writeUleb128` | ||
| 57 | pub const writeULEB128 = writeUleb128; | ||
| 58 | |||
| 53 | /// Read a single signed LEB128 value from the given reader as type T, | 59 | /// Read a single signed LEB128 value from the given reader as type T, |
| 54 | /// or error.Overflow if the value cannot fit. | 60 | /// or error.Overflow if the value cannot fit. |
| 55 | pub fn readILEB128(comptime T: type, reader: anytype) !T { | 61 | pub fn readIleb128(comptime T: type, reader: anytype) !T { |
| 56 | const S = if (@typeInfo(T).Int.bits < 8) i8 else T; | 62 | const S = if (@typeInfo(T).Int.bits < 8) i8 else T; |
| 57 | const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits); | 63 | const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits); |
| 58 | const ShiftU = std.math.Log2Int(U); | 64 | const ShiftU = std.math.Log2Int(U); |
| ... | @@ -108,8 +114,11 @@ pub fn readILEB128(comptime T: type, reader: anytype) !T { | ... | @@ -108,8 +114,11 @@ pub fn readILEB128(comptime T: type, reader: anytype) !T { |
| 108 | return @as(T, @truncate(result)); | 114 | return @as(T, @truncate(result)); |
| 109 | } | 115 | } |
| 110 | 116 | ||
| 117 | /// Deprecated: use `readIleb128` | ||
| 118 | pub const readILEB128 = readIleb128; | ||
| 119 | |||
| 111 | /// Write a single signed integer as signed LEB128 to the given writer. | 120 | /// Write a single signed integer as signed LEB128 to the given writer. |
| 112 | pub fn writeILEB128(writer: anytype, int_value: anytype) !void { | 121 | pub fn writeIleb128(writer: anytype, int_value: anytype) !void { |
| 113 | const T = @TypeOf(int_value); | 122 | const T = @TypeOf(int_value); |
| 114 | const S = if (@typeInfo(T).Int.bits < 8) i8 else T; | 123 | const S = if (@typeInfo(T).Int.bits < 8) i8 else T; |
| 115 | const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits); | 124 | const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits); |
| ... | @@ -151,6 +160,9 @@ pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.uns | ... | @@ -151,6 +160,9 @@ pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.uns |
| 151 | ptr[i] = @truncate(value); | 160 | ptr[i] = @truncate(value); |
| 152 | } | 161 | } |
| 153 | 162 | ||
| 163 | /// Deprecated: use `writeIleb128` | ||
| 164 | pub const writeILEB128 = writeIleb128; | ||
| 165 | |||
| 154 | test writeUnsignedFixed { | 166 | test writeUnsignedFixed { |
| 155 | { | 167 | { |
| 156 | var buf: [4]u8 = undefined; | 168 | var buf: [4]u8 = undefined; |
| ... | @@ -236,23 +248,23 @@ test writeSignedFixed { | ... | @@ -236,23 +248,23 @@ test writeSignedFixed { |
| 236 | // tests | 248 | // tests |
| 237 | fn test_read_stream_ileb128(comptime T: type, encoded: []const u8) !T { | 249 | fn test_read_stream_ileb128(comptime T: type, encoded: []const u8) !T { |
| 238 | var reader = std.io.fixedBufferStream(encoded); | 250 | var reader = std.io.fixedBufferStream(encoded); |
| 239 | return try readILEB128(T, reader.reader()); | 251 | return try readIleb128(T, reader.reader()); |
| 240 | } | 252 | } |
| 241 | 253 | ||
| 242 | fn test_read_stream_uleb128(comptime T: type, encoded: []const u8) !T { | 254 | fn test_read_stream_uleb128(comptime T: type, encoded: []const u8) !T { |
| 243 | var reader = std.io.fixedBufferStream(encoded); | 255 | var reader = std.io.fixedBufferStream(encoded); |
| 244 | return try readULEB128(T, reader.reader()); | 256 | return try readUleb128(T, reader.reader()); |
| 245 | } | 257 | } |
| 246 | 258 | ||
| 247 | fn test_read_ileb128(comptime T: type, encoded: []const u8) !T { | 259 | fn test_read_ileb128(comptime T: type, encoded: []const u8) !T { |
| 248 | var reader = std.io.fixedBufferStream(encoded); | 260 | var reader = std.io.fixedBufferStream(encoded); |
| 249 | const v1 = try readILEB128(T, reader.reader()); | 261 | const v1 = try readIleb128(T, reader.reader()); |
| 250 | return v1; | 262 | return v1; |
| 251 | } | 263 | } |
| 252 | 264 | ||
| 253 | fn test_read_uleb128(comptime T: type, encoded: []const u8) !T { | 265 | fn test_read_uleb128(comptime T: type, encoded: []const u8) !T { |
| 254 | var reader = std.io.fixedBufferStream(encoded); | 266 | var reader = std.io.fixedBufferStream(encoded); |
| 255 | const v1 = try readULEB128(T, reader.reader()); | 267 | const v1 = try readUleb128(T, reader.reader()); |
| 256 | return v1; | 268 | return v1; |
| 257 | } | 269 | } |
| 258 | 270 | ||
| ... | @@ -260,7 +272,7 @@ fn test_read_ileb128_seq(comptime T: type, comptime N: usize, encoded: []const u | ... | @@ -260,7 +272,7 @@ fn test_read_ileb128_seq(comptime T: type, comptime N: usize, encoded: []const u |
| 260 | var reader = std.io.fixedBufferStream(encoded); | 272 | var reader = std.io.fixedBufferStream(encoded); |
| 261 | var i: usize = 0; | 273 | var i: usize = 0; |
| 262 | while (i < N) : (i += 1) { | 274 | while (i < N) : (i += 1) { |
| 263 | _ = try readILEB128(T, reader.reader()); | 275 | _ = try readIleb128(T, reader.reader()); |
| 264 | } | 276 | } |
| 265 | } | 277 | } |
| 266 | 278 | ||
| ... | @@ -268,7 +280,7 @@ fn test_read_uleb128_seq(comptime T: type, comptime N: usize, encoded: []const u | ... | @@ -268,7 +280,7 @@ fn test_read_uleb128_seq(comptime T: type, comptime N: usize, encoded: []const u |
| 268 | var reader = std.io.fixedBufferStream(encoded); | 280 | var reader = std.io.fixedBufferStream(encoded); |
| 269 | var i: usize = 0; | 281 | var i: usize = 0; |
| 270 | while (i < N) : (i += 1) { | 282 | while (i < N) : (i += 1) { |
| 271 | _ = try readULEB128(T, reader.reader()); | 283 | _ = try readUleb128(T, reader.reader()); |
| 272 | } | 284 | } |
| 273 | } | 285 | } |
| 274 | 286 | ||
| ... | @@ -364,8 +376,8 @@ fn test_write_leb128(value: anytype) !void { | ... | @@ -364,8 +376,8 @@ fn test_write_leb128(value: anytype) !void { |
| 364 | const signedness = @typeInfo(T).Int.signedness; | 376 | const signedness = @typeInfo(T).Int.signedness; |
| 365 | const t_signed = signedness == .signed; | 377 | const t_signed = signedness == .signed; |
| 366 | 378 | ||
| 367 | const writeStream = if (t_signed) writeILEB128 else writeULEB128; | 379 | const writeStream = if (t_signed) writeIleb128 else writeUleb128; |
| 368 | const readStream = if (t_signed) readILEB128 else readULEB128; | 380 | const readStream = if (t_signed) readIleb128 else readUleb128; |
| 369 | 381 | ||
| 370 | // decode to a larger bit size too, to ensure sign extension | 382 | // decode to a larger bit size too, to ensure sign extension |
| 371 | // is working as expected | 383 | // is working as expected |
src/arch/wasm/CodeGen.zig+18-18| ... | @@ -7374,7 +7374,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { | ... | @@ -7374,7 +7374,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { |
| 7374 | var writer = body_list.writer(); | 7374 | var writer = body_list.writer(); |
| 7375 | 7375 | ||
| 7376 | // The locals of the function body (always 0) | 7376 | // The locals of the function body (always 0) |
| 7377 | try leb.writeULEB128(writer, @as(u32, 0)); | 7377 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 7378 | 7378 | ||
| 7379 | // outer block | 7379 | // outer block |
| 7380 | try writer.writeByte(std.wasm.opcode(.block)); | 7380 | try writer.writeByte(std.wasm.opcode(.block)); |
| ... | @@ -7408,7 +7408,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { | ... | @@ -7408,7 +7408,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { |
| 7408 | 7408 | ||
| 7409 | // get actual tag value (stored in 2nd parameter); | 7409 | // get actual tag value (stored in 2nd parameter); |
| 7410 | try writer.writeByte(std.wasm.opcode(.local_get)); | 7410 | try writer.writeByte(std.wasm.opcode(.local_get)); |
| 7411 | try leb.writeULEB128(writer, @as(u32, 1)); | 7411 | try leb.writeUleb128(writer, @as(u32, 1)); |
| 7412 | 7412 | ||
| 7413 | const tag_val = try mod.enumValueFieldIndex(enum_ty, @intCast(tag_index)); | 7413 | const tag_val = try mod.enumValueFieldIndex(enum_ty, @intCast(tag_index)); |
| 7414 | const tag_value = try func.lowerConstant(tag_val, enum_ty); | 7414 | const tag_value = try func.lowerConstant(tag_val, enum_ty); |
| ... | @@ -7416,26 +7416,26 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { | ... | @@ -7416,26 +7416,26 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { |
| 7416 | switch (tag_value) { | 7416 | switch (tag_value) { |
| 7417 | .imm32 => |value| { | 7417 | .imm32 => |value| { |
| 7418 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 7418 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 7419 | try leb.writeILEB128(writer, @as(i32, @bitCast(value))); | 7419 | try leb.writeIleb128(writer, @as(i32, @bitCast(value))); |
| 7420 | try writer.writeByte(std.wasm.opcode(.i32_ne)); | 7420 | try writer.writeByte(std.wasm.opcode(.i32_ne)); |
| 7421 | }, | 7421 | }, |
| 7422 | .imm64 => |value| { | 7422 | .imm64 => |value| { |
| 7423 | try writer.writeByte(std.wasm.opcode(.i64_const)); | 7423 | try writer.writeByte(std.wasm.opcode(.i64_const)); |
| 7424 | try leb.writeILEB128(writer, @as(i64, @bitCast(value))); | 7424 | try leb.writeIleb128(writer, @as(i64, @bitCast(value))); |
| 7425 | try writer.writeByte(std.wasm.opcode(.i64_ne)); | 7425 | try writer.writeByte(std.wasm.opcode(.i64_ne)); |
| 7426 | }, | 7426 | }, |
| 7427 | else => unreachable, | 7427 | else => unreachable, |
| 7428 | } | 7428 | } |
| 7429 | // if they're not equal, break out of current branch | 7429 | // if they're not equal, break out of current branch |
| 7430 | try writer.writeByte(std.wasm.opcode(.br_if)); | 7430 | try writer.writeByte(std.wasm.opcode(.br_if)); |
| 7431 | try leb.writeULEB128(writer, @as(u32, 0)); | 7431 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 7432 | 7432 | ||
| 7433 | // store the address of the tagname in the pointer field of the slice | 7433 | // store the address of the tagname in the pointer field of the slice |
| 7434 | // get the address twice so we can also store the length. | 7434 | // get the address twice so we can also store the length. |
| 7435 | try writer.writeByte(std.wasm.opcode(.local_get)); | 7435 | try writer.writeByte(std.wasm.opcode(.local_get)); |
| 7436 | try leb.writeULEB128(writer, @as(u32, 0)); | 7436 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 7437 | try writer.writeByte(std.wasm.opcode(.local_get)); | 7437 | try writer.writeByte(std.wasm.opcode(.local_get)); |
| 7438 | try leb.writeULEB128(writer, @as(u32, 0)); | 7438 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 7439 | 7439 | ||
| 7440 | // get address of tagname and emit a relocation to it | 7440 | // get address of tagname and emit a relocation to it |
| 7441 | if (func.arch() == .wasm32) { | 7441 | if (func.arch() == .wasm32) { |
| ... | @@ -7450,15 +7450,15 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { | ... | @@ -7450,15 +7450,15 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { |
| 7450 | 7450 | ||
| 7451 | // store pointer | 7451 | // store pointer |
| 7452 | try writer.writeByte(std.wasm.opcode(.i32_store)); | 7452 | try writer.writeByte(std.wasm.opcode(.i32_store)); |
| 7453 | try leb.writeULEB128(writer, encoded_alignment); | 7453 | try leb.writeUleb128(writer, encoded_alignment); |
| 7454 | try leb.writeULEB128(writer, @as(u32, 0)); | 7454 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 7455 | 7455 | ||
| 7456 | // store length | 7456 | // store length |
| 7457 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 7457 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 7458 | try leb.writeULEB128(writer, @as(u32, @intCast(tag_name_len))); | 7458 | try leb.writeUleb128(writer, @as(u32, @intCast(tag_name_len))); |
| 7459 | try writer.writeByte(std.wasm.opcode(.i32_store)); | 7459 | try writer.writeByte(std.wasm.opcode(.i32_store)); |
| 7460 | try leb.writeULEB128(writer, encoded_alignment); | 7460 | try leb.writeUleb128(writer, encoded_alignment); |
| 7461 | try leb.writeULEB128(writer, @as(u32, 4)); | 7461 | try leb.writeUleb128(writer, @as(u32, 4)); |
| 7462 | } else { | 7462 | } else { |
| 7463 | const encoded_alignment = @ctz(@as(u32, 8)); | 7463 | const encoded_alignment = @ctz(@as(u32, 8)); |
| 7464 | try writer.writeByte(std.wasm.opcode(.i64_const)); | 7464 | try writer.writeByte(std.wasm.opcode(.i64_const)); |
| ... | @@ -7471,20 +7471,20 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { | ... | @@ -7471,20 +7471,20 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { |
| 7471 | 7471 | ||
| 7472 | // store pointer | 7472 | // store pointer |
| 7473 | try writer.writeByte(std.wasm.opcode(.i64_store)); | 7473 | try writer.writeByte(std.wasm.opcode(.i64_store)); |
| 7474 | try leb.writeULEB128(writer, encoded_alignment); | 7474 | try leb.writeUleb128(writer, encoded_alignment); |
| 7475 | try leb.writeULEB128(writer, @as(u32, 0)); | 7475 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 7476 | 7476 | ||
| 7477 | // store length | 7477 | // store length |
| 7478 | try writer.writeByte(std.wasm.opcode(.i64_const)); | 7478 | try writer.writeByte(std.wasm.opcode(.i64_const)); |
| 7479 | try leb.writeULEB128(writer, @as(u64, @intCast(tag_name_len))); | 7479 | try leb.writeUleb128(writer, @as(u64, @intCast(tag_name_len))); |
| 7480 | try writer.writeByte(std.wasm.opcode(.i64_store)); | 7480 | try writer.writeByte(std.wasm.opcode(.i64_store)); |
| 7481 | try leb.writeULEB128(writer, encoded_alignment); | 7481 | try leb.writeUleb128(writer, encoded_alignment); |
| 7482 | try leb.writeULEB128(writer, @as(u32, 8)); | 7482 | try leb.writeUleb128(writer, @as(u32, 8)); |
| 7483 | } | 7483 | } |
| 7484 | 7484 | ||
| 7485 | // break outside blocks | 7485 | // break outside blocks |
| 7486 | try writer.writeByte(std.wasm.opcode(.br)); | 7486 | try writer.writeByte(std.wasm.opcode(.br)); |
| 7487 | try leb.writeULEB128(writer, @as(u32, 1)); | 7487 | try leb.writeUleb128(writer, @as(u32, 1)); |
| 7488 | 7488 | ||
| 7489 | // end the block for this case | 7489 | // end the block for this case |
| 7490 | try writer.writeByte(std.wasm.opcode(.end)); | 7490 | try writer.writeByte(std.wasm.opcode(.end)); |
src/arch/wasm/Emit.zig+21-21| ... | @@ -265,10 +265,10 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError { | ... | @@ -265,10 +265,10 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError { |
| 265 | 265 | ||
| 266 | fn emitLocals(emit: *Emit) !void { | 266 | fn emitLocals(emit: *Emit) !void { |
| 267 | const writer = emit.code.writer(); | 267 | const writer = emit.code.writer(); |
| 268 | try leb128.writeULEB128(writer, @as(u32, @intCast(emit.locals.len))); | 268 | try leb128.writeUleb128(writer, @as(u32, @intCast(emit.locals.len))); |
| 269 | // emit the actual locals amount | 269 | // emit the actual locals amount |
| 270 | for (emit.locals) |local| { | 270 | for (emit.locals) |local| { |
| 271 | try leb128.writeULEB128(writer, @as(u32, 1)); | 271 | try leb128.writeUleb128(writer, @as(u32, 1)); |
| 272 | try writer.writeByte(local); | 272 | try writer.writeByte(local); |
| 273 | } | 273 | } |
| 274 | } | 274 | } |
| ... | @@ -290,16 +290,16 @@ fn emitBrTable(emit: *Emit, inst: Mir.Inst.Index) !void { | ... | @@ -290,16 +290,16 @@ fn emitBrTable(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 290 | const writer = emit.code.writer(); | 290 | const writer = emit.code.writer(); |
| 291 | 291 | ||
| 292 | try emit.code.append(std.wasm.opcode(.br_table)); | 292 | try emit.code.append(std.wasm.opcode(.br_table)); |
| 293 | try leb128.writeULEB128(writer, extra.data.length - 1); // Default label is not part of length/depth | 293 | try leb128.writeUleb128(writer, extra.data.length - 1); // Default label is not part of length/depth |
| 294 | for (labels) |label| { | 294 | for (labels) |label| { |
| 295 | try leb128.writeULEB128(writer, label); | 295 | try leb128.writeUleb128(writer, label); |
| 296 | } | 296 | } |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | fn emitLabel(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { | 299 | fn emitLabel(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { |
| 300 | const label = emit.mir.instructions.items(.data)[inst].label; | 300 | const label = emit.mir.instructions.items(.data)[inst].label; |
| 301 | try emit.code.append(@intFromEnum(tag)); | 301 | try emit.code.append(@intFromEnum(tag)); |
| 302 | try leb128.writeULEB128(emit.code.writer(), label); | 302 | try leb128.writeUleb128(emit.code.writer(), label); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { | 305 | fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { |
| ... | @@ -324,14 +324,14 @@ fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { | ... | @@ -324,14 +324,14 @@ fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { |
| 324 | fn emitImm32(emit: *Emit, inst: Mir.Inst.Index) !void { | 324 | fn emitImm32(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 325 | const value: i32 = emit.mir.instructions.items(.data)[inst].imm32; | 325 | const value: i32 = emit.mir.instructions.items(.data)[inst].imm32; |
| 326 | try emit.code.append(std.wasm.opcode(.i32_const)); | 326 | try emit.code.append(std.wasm.opcode(.i32_const)); |
| 327 | try leb128.writeILEB128(emit.code.writer(), value); | 327 | try leb128.writeIleb128(emit.code.writer(), value); |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | fn emitImm64(emit: *Emit, inst: Mir.Inst.Index) !void { | 330 | fn emitImm64(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 331 | const extra_index = emit.mir.instructions.items(.data)[inst].payload; | 331 | const extra_index = emit.mir.instructions.items(.data)[inst].payload; |
| 332 | const value = emit.mir.extraData(Mir.Imm64, extra_index); | 332 | const value = emit.mir.extraData(Mir.Imm64, extra_index); |
| 333 | try emit.code.append(std.wasm.opcode(.i64_const)); | 333 | try emit.code.append(std.wasm.opcode(.i64_const)); |
| 334 | try leb128.writeILEB128(emit.code.writer(), @as(i64, @bitCast(value.data.toU64()))); | 334 | try leb128.writeIleb128(emit.code.writer(), @as(i64, @bitCast(value.data.toU64()))); |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | fn emitFloat32(emit: *Emit, inst: Mir.Inst.Index) !void { | 337 | fn emitFloat32(emit: *Emit, inst: Mir.Inst.Index) !void { |
| ... | @@ -357,8 +357,8 @@ fn emitMemArg(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { | ... | @@ -357,8 +357,8 @@ fn emitMemArg(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { |
| 357 | fn encodeMemArg(mem_arg: Mir.MemArg, writer: anytype) !void { | 357 | fn encodeMemArg(mem_arg: Mir.MemArg, writer: anytype) !void { |
| 358 | // wasm encodes alignment as power of 2, rather than natural alignment | 358 | // wasm encodes alignment as power of 2, rather than natural alignment |
| 359 | const encoded_alignment = @ctz(mem_arg.alignment); | 359 | const encoded_alignment = @ctz(mem_arg.alignment); |
| 360 | try leb128.writeULEB128(writer, encoded_alignment); | 360 | try leb128.writeUleb128(writer, encoded_alignment); |
| 361 | try leb128.writeULEB128(writer, mem_arg.offset); | 361 | try leb128.writeUleb128(writer, mem_arg.offset); |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | fn emitCall(emit: *Emit, inst: Mir.Inst.Index) !void { | 364 | fn emitCall(emit: *Emit, inst: Mir.Inst.Index) !void { |
| ... | @@ -400,7 +400,7 @@ fn emitCallIndirect(emit: *Emit, inst: Mir.Inst.Index) !void { | ... | @@ -400,7 +400,7 @@ fn emitCallIndirect(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 400 | .relocation_type = .R_WASM_TYPE_INDEX_LEB, | 400 | .relocation_type = .R_WASM_TYPE_INDEX_LEB, |
| 401 | }); | 401 | }); |
| 402 | } | 402 | } |
| 403 | try leb128.writeULEB128(emit.code.writer(), @as(u32, 0)); // TODO: Emit relocation for table index | 403 | try leb128.writeUleb128(emit.code.writer(), @as(u32, 0)); // TODO: Emit relocation for table index |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | fn emitFunctionIndex(emit: *Emit, inst: Mir.Inst.Index) !void { | 406 | fn emitFunctionIndex(emit: *Emit, inst: Mir.Inst.Index) !void { |
| ... | @@ -461,24 +461,24 @@ fn emitExtended(emit: *Emit, inst: Mir.Inst.Index) !void { | ... | @@ -461,24 +461,24 @@ fn emitExtended(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 461 | const opcode = emit.mir.extra[extra_index]; | 461 | const opcode = emit.mir.extra[extra_index]; |
| 462 | const writer = emit.code.writer(); | 462 | const writer = emit.code.writer(); |
| 463 | try emit.code.append(std.wasm.opcode(.misc_prefix)); | 463 | try emit.code.append(std.wasm.opcode(.misc_prefix)); |
| 464 | try leb128.writeULEB128(writer, opcode); | 464 | try leb128.writeUleb128(writer, opcode); |
| 465 | switch (@as(std.wasm.MiscOpcode, @enumFromInt(opcode))) { | 465 | switch (@as(std.wasm.MiscOpcode, @enumFromInt(opcode))) { |
| 466 | // bulk-memory opcodes | 466 | // bulk-memory opcodes |
| 467 | .data_drop => { | 467 | .data_drop => { |
| 468 | const segment = emit.mir.extra[extra_index + 1]; | 468 | const segment = emit.mir.extra[extra_index + 1]; |
| 469 | try leb128.writeULEB128(writer, segment); | 469 | try leb128.writeUleb128(writer, segment); |
| 470 | }, | 470 | }, |
| 471 | .memory_init => { | 471 | .memory_init => { |
| 472 | const segment = emit.mir.extra[extra_index + 1]; | 472 | const segment = emit.mir.extra[extra_index + 1]; |
| 473 | try leb128.writeULEB128(writer, segment); | 473 | try leb128.writeUleb128(writer, segment); |
| 474 | try leb128.writeULEB128(writer, @as(u32, 0)); // memory index | 474 | try leb128.writeUleb128(writer, @as(u32, 0)); // memory index |
| 475 | }, | 475 | }, |
| 476 | .memory_fill => { | 476 | .memory_fill => { |
| 477 | try leb128.writeULEB128(writer, @as(u32, 0)); // memory index | 477 | try leb128.writeUleb128(writer, @as(u32, 0)); // memory index |
| 478 | }, | 478 | }, |
| 479 | .memory_copy => { | 479 | .memory_copy => { |
| 480 | try leb128.writeULEB128(writer, @as(u32, 0)); // dst memory index | 480 | try leb128.writeUleb128(writer, @as(u32, 0)); // dst memory index |
| 481 | try leb128.writeULEB128(writer, @as(u32, 0)); // src memory index | 481 | try leb128.writeUleb128(writer, @as(u32, 0)); // src memory index |
| 482 | }, | 482 | }, |
| 483 | 483 | ||
| 484 | // nontrapping-float-to-int-conversion opcodes | 484 | // nontrapping-float-to-int-conversion opcodes |
| ... | @@ -500,7 +500,7 @@ fn emitSimd(emit: *Emit, inst: Mir.Inst.Index) !void { | ... | @@ -500,7 +500,7 @@ fn emitSimd(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 500 | const opcode = emit.mir.extra[extra_index]; | 500 | const opcode = emit.mir.extra[extra_index]; |
| 501 | const writer = emit.code.writer(); | 501 | const writer = emit.code.writer(); |
| 502 | try emit.code.append(std.wasm.opcode(.simd_prefix)); | 502 | try emit.code.append(std.wasm.opcode(.simd_prefix)); |
| 503 | try leb128.writeULEB128(writer, opcode); | 503 | try leb128.writeUleb128(writer, opcode); |
| 504 | switch (@as(std.wasm.SimdOpcode, @enumFromInt(opcode))) { | 504 | switch (@as(std.wasm.SimdOpcode, @enumFromInt(opcode))) { |
| 505 | .v128_store, | 505 | .v128_store, |
| 506 | .v128_load, | 506 | .v128_load, |
| ... | @@ -551,7 +551,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void { | ... | @@ -551,7 +551,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 551 | const opcode = emit.mir.extra[extra_index]; | 551 | const opcode = emit.mir.extra[extra_index]; |
| 552 | const writer = emit.code.writer(); | 552 | const writer = emit.code.writer(); |
| 553 | try emit.code.append(std.wasm.opcode(.atomics_prefix)); | 553 | try emit.code.append(std.wasm.opcode(.atomics_prefix)); |
| 554 | try leb128.writeULEB128(writer, opcode); | 554 | try leb128.writeUleb128(writer, opcode); |
| 555 | switch (@as(std.wasm.AtomicsOpcode, @enumFromInt(opcode))) { | 555 | switch (@as(std.wasm.AtomicsOpcode, @enumFromInt(opcode))) { |
| 556 | .i32_atomic_load, | 556 | .i32_atomic_load, |
| 557 | .i64_atomic_load, | 557 | .i64_atomic_load, |
| ... | @@ -625,7 +625,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void { | ... | @@ -625,7 +625,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 625 | // TODO: When multi-memory proposal is accepted and implemented in the compiler, | 625 | // TODO: When multi-memory proposal is accepted and implemented in the compiler, |
| 626 | // change this to (user-)specified index, rather than hardcode it to memory index 0. | 626 | // change this to (user-)specified index, rather than hardcode it to memory index 0. |
| 627 | const memory_index: u32 = 0; | 627 | const memory_index: u32 = 0; |
| 628 | try leb128.writeULEB128(writer, memory_index); | 628 | try leb128.writeUleb128(writer, memory_index); |
| 629 | }, | 629 | }, |
| 630 | else => |tag| return emit.fail("TODO: Implement atomic instruction: {s}", .{@tagName(tag)}), | 630 | else => |tag| return emit.fail("TODO: Implement atomic instruction: {s}", .{@tagName(tag)}), |
| 631 | } | 631 | } |
| ... | @@ -637,7 +637,7 @@ fn emitMemFill(emit: *Emit) !void { | ... | @@ -637,7 +637,7 @@ fn emitMemFill(emit: *Emit) !void { |
| 637 | // When multi-memory proposal reaches phase 4, we | 637 | // When multi-memory proposal reaches phase 4, we |
| 638 | // can emit a different memory index here. | 638 | // can emit a different memory index here. |
| 639 | // For now we will always emit index 0. | 639 | // For now we will always emit index 0. |
| 640 | try leb128.writeULEB128(emit.code.writer(), @as(u32, 0)); | 640 | try leb128.writeUleb128(emit.code.writer(), @as(u32, 0)); |
| 641 | } | 641 | } |
| 642 | 642 | ||
| 643 | fn emitDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void { | 643 | fn emitDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void { |
src/link/Dwarf.zig+58-58| ... | @@ -148,7 +148,7 @@ pub const DeclState = struct { | ... | @@ -148,7 +148,7 @@ pub const DeclState = struct { |
| 148 | // DW.AT.encoding, DW.FORM.data1 | 148 | // DW.AT.encoding, DW.FORM.data1 |
| 149 | dbg_info_buffer.appendAssumeCapacity(DW.ATE.boolean); | 149 | dbg_info_buffer.appendAssumeCapacity(DW.ATE.boolean); |
| 150 | // DW.AT.byte_size, DW.FORM.udata | 150 | // DW.AT.byte_size, DW.FORM.udata |
| 151 | try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); | 151 | try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod)); |
| 152 | // DW.AT.name, DW.FORM.string | 152 | // DW.AT.name, DW.FORM.string |
| 153 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); | 153 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); |
| 154 | }, | 154 | }, |
| ... | @@ -162,7 +162,7 @@ pub const DeclState = struct { | ... | @@ -162,7 +162,7 @@ pub const DeclState = struct { |
| 162 | .unsigned => DW.ATE.unsigned, | 162 | .unsigned => DW.ATE.unsigned, |
| 163 | }); | 163 | }); |
| 164 | // DW.AT.byte_size, DW.FORM.udata | 164 | // DW.AT.byte_size, DW.FORM.udata |
| 165 | try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); | 165 | try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod)); |
| 166 | // DW.AT.name, DW.FORM.string | 166 | // DW.AT.name, DW.FORM.string |
| 167 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); | 167 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); |
| 168 | }, | 168 | }, |
| ... | @@ -173,7 +173,7 @@ pub const DeclState = struct { | ... | @@ -173,7 +173,7 @@ pub const DeclState = struct { |
| 173 | // DW.AT.encoding, DW.FORM.data1 | 173 | // DW.AT.encoding, DW.FORM.data1 |
| 174 | dbg_info_buffer.appendAssumeCapacity(DW.ATE.address); | 174 | dbg_info_buffer.appendAssumeCapacity(DW.ATE.address); |
| 175 | // DW.AT.byte_size, DW.FORM.udata | 175 | // DW.AT.byte_size, DW.FORM.udata |
| 176 | try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); | 176 | try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod)); |
| 177 | // DW.AT.name, DW.FORM.string | 177 | // DW.AT.name, DW.FORM.string |
| 178 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); | 178 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); |
| 179 | } else { | 179 | } else { |
| ... | @@ -183,7 +183,7 @@ pub const DeclState = struct { | ... | @@ -183,7 +183,7 @@ pub const DeclState = struct { |
| 183 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); | 183 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); |
| 184 | // DW.AT.byte_size, DW.FORM.udata | 184 | // DW.AT.byte_size, DW.FORM.udata |
| 185 | const abi_size = ty.abiSize(mod); | 185 | const abi_size = ty.abiSize(mod); |
| 186 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 186 | try leb128.writeUleb128(dbg_info_buffer.writer(), abi_size); |
| 187 | // DW.AT.name, DW.FORM.string | 187 | // DW.AT.name, DW.FORM.string |
| 188 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); | 188 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); |
| 189 | // DW.AT.member | 189 | // DW.AT.member |
| ... | @@ -209,7 +209,7 @@ pub const DeclState = struct { | ... | @@ -209,7 +209,7 @@ pub const DeclState = struct { |
| 209 | try self.addTypeRelocGlobal(atom_index, payload_ty, @intCast(index)); | 209 | try self.addTypeRelocGlobal(atom_index, payload_ty, @intCast(index)); |
| 210 | // DW.AT.data_member_location, DW.FORM.udata | 210 | // DW.AT.data_member_location, DW.FORM.udata |
| 211 | const offset = abi_size - payload_ty.abiSize(mod); | 211 | const offset = abi_size - payload_ty.abiSize(mod); |
| 212 | try leb128.writeULEB128(dbg_info_buffer.writer(), offset); | 212 | try leb128.writeUleb128(dbg_info_buffer.writer(), offset); |
| 213 | // DW.AT.structure_type delimit children | 213 | // DW.AT.structure_type delimit children |
| 214 | try dbg_info_buffer.append(0); | 214 | try dbg_info_buffer.append(0); |
| 215 | } | 215 | } |
| ... | @@ -223,7 +223,7 @@ pub const DeclState = struct { | ... | @@ -223,7 +223,7 @@ pub const DeclState = struct { |
| 223 | try dbg_info_buffer.ensureUnusedCapacity(2); | 223 | try dbg_info_buffer.ensureUnusedCapacity(2); |
| 224 | dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevCode.struct_type)); | 224 | dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevCode.struct_type)); |
| 225 | // DW.AT.byte_size, DW.FORM.udata | 225 | // DW.AT.byte_size, DW.FORM.udata |
| 226 | try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); | 226 | try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod)); |
| 227 | // DW.AT.name, DW.FORM.string | 227 | // DW.AT.name, DW.FORM.string |
| 228 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); | 228 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); |
| 229 | // DW.AT.member | 229 | // DW.AT.member |
| ... | @@ -279,7 +279,7 @@ pub const DeclState = struct { | ... | @@ -279,7 +279,7 @@ pub const DeclState = struct { |
| 279 | try self.addTypeRelocGlobal(atom_index, Type.usize, @intCast(index)); | 279 | try self.addTypeRelocGlobal(atom_index, Type.usize, @intCast(index)); |
| 280 | // DW.AT.count, DW.FORM.udata | 280 | // DW.AT.count, DW.FORM.udata |
| 281 | const len = ty.arrayLenIncludingSentinel(mod); | 281 | const len = ty.arrayLenIncludingSentinel(mod); |
| 282 | try leb128.writeULEB128(dbg_info_buffer.writer(), len); | 282 | try leb128.writeUleb128(dbg_info_buffer.writer(), len); |
| 283 | // DW.AT.array_type delimit children | 283 | // DW.AT.array_type delimit children |
| 284 | try dbg_info_buffer.append(0); | 284 | try dbg_info_buffer.append(0); |
| 285 | }, | 285 | }, |
| ... | @@ -287,7 +287,7 @@ pub const DeclState = struct { | ... | @@ -287,7 +287,7 @@ pub const DeclState = struct { |
| 287 | // DW.AT.structure_type | 287 | // DW.AT.structure_type |
| 288 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); | 288 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); |
| 289 | // DW.AT.byte_size, DW.FORM.udata | 289 | // DW.AT.byte_size, DW.FORM.udata |
| 290 | try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); | 290 | try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod)); |
| 291 | 291 | ||
| 292 | blk: { | 292 | blk: { |
| 293 | switch (ip.indexToKey(ty.ip_index)) { | 293 | switch (ip.indexToKey(ty.ip_index)) { |
| ... | @@ -306,7 +306,7 @@ pub const DeclState = struct { | ... | @@ -306,7 +306,7 @@ pub const DeclState = struct { |
| 306 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index)); | 306 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index)); |
| 307 | // DW.AT.data_member_location, DW.FORM.udata | 307 | // DW.AT.data_member_location, DW.FORM.udata |
| 308 | const field_off = ty.structFieldOffset(field_index, mod); | 308 | const field_off = ty.structFieldOffset(field_index, mod); |
| 309 | try leb128.writeULEB128(dbg_info_buffer.writer(), field_off); | 309 | try leb128.writeUleb128(dbg_info_buffer.writer(), field_off); |
| 310 | } | 310 | } |
| 311 | }, | 311 | }, |
| 312 | .struct_type => { | 312 | .struct_type => { |
| ... | @@ -332,7 +332,7 @@ pub const DeclState = struct { | ... | @@ -332,7 +332,7 @@ pub const DeclState = struct { |
| 332 | try dbg_info_buffer.appendNTimes(0, 4); | 332 | try dbg_info_buffer.appendNTimes(0, 4); |
| 333 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index)); | 333 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index)); |
| 334 | // DW.AT.data_member_location, DW.FORM.udata | 334 | // DW.AT.data_member_location, DW.FORM.udata |
| 335 | try leb128.writeULEB128(dbg_info_buffer.writer(), field_off); | 335 | try leb128.writeUleb128(dbg_info_buffer.writer(), field_off); |
| 336 | } | 336 | } |
| 337 | } else { | 337 | } else { |
| 338 | for ( | 338 | for ( |
| ... | @@ -352,7 +352,7 @@ pub const DeclState = struct { | ... | @@ -352,7 +352,7 @@ pub const DeclState = struct { |
| 352 | try dbg_info_buffer.appendNTimes(0, 4); | 352 | try dbg_info_buffer.appendNTimes(0, 4); |
| 353 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index)); | 353 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index)); |
| 354 | // DW.AT.data_member_location, DW.FORM.udata | 354 | // DW.AT.data_member_location, DW.FORM.udata |
| 355 | try leb128.writeULEB128(dbg_info_buffer.writer(), field_off); | 355 | try leb128.writeUleb128(dbg_info_buffer.writer(), field_off); |
| 356 | } | 356 | } |
| 357 | } | 357 | } |
| 358 | }, | 358 | }, |
| ... | @@ -367,7 +367,7 @@ pub const DeclState = struct { | ... | @@ -367,7 +367,7 @@ pub const DeclState = struct { |
| 367 | // DW.AT.enumeration_type | 367 | // DW.AT.enumeration_type |
| 368 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.enum_type)); | 368 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.enum_type)); |
| 369 | // DW.AT.byte_size, DW.FORM.udata | 369 | // DW.AT.byte_size, DW.FORM.udata |
| 370 | try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); | 370 | try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod)); |
| 371 | // DW.AT.name, DW.FORM.string | 371 | // DW.AT.name, DW.FORM.string |
| 372 | try ty.print(dbg_info_buffer.writer(), mod); | 372 | try ty.print(dbg_info_buffer.writer(), mod); |
| 373 | try dbg_info_buffer.append(0); | 373 | try dbg_info_buffer.append(0); |
| ... | @@ -408,7 +408,7 @@ pub const DeclState = struct { | ... | @@ -408,7 +408,7 @@ pub const DeclState = struct { |
| 408 | // DW.AT.structure_type | 408 | // DW.AT.structure_type |
| 409 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); | 409 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); |
| 410 | // DW.AT.byte_size, DW.FORM.udata | 410 | // DW.AT.byte_size, DW.FORM.udata |
| 411 | try leb128.writeULEB128(dbg_info_buffer.writer(), layout.abi_size); | 411 | try leb128.writeUleb128(dbg_info_buffer.writer(), layout.abi_size); |
| 412 | // DW.AT.name, DW.FORM.string | 412 | // DW.AT.name, DW.FORM.string |
| 413 | try ty.print(dbg_info_buffer.writer(), mod); | 413 | try ty.print(dbg_info_buffer.writer(), mod); |
| 414 | try dbg_info_buffer.append(0); | 414 | try dbg_info_buffer.append(0); |
| ... | @@ -424,13 +424,13 @@ pub const DeclState = struct { | ... | @@ -424,13 +424,13 @@ pub const DeclState = struct { |
| 424 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); | 424 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); |
| 425 | try self.addTypeRelocLocal(atom_index, @intCast(inner_union_index), 5); | 425 | try self.addTypeRelocLocal(atom_index, @intCast(inner_union_index), 5); |
| 426 | // DW.AT.data_member_location, DW.FORM.udata | 426 | // DW.AT.data_member_location, DW.FORM.udata |
| 427 | try leb128.writeULEB128(dbg_info_buffer.writer(), payload_offset); | 427 | try leb128.writeUleb128(dbg_info_buffer.writer(), payload_offset); |
| 428 | } | 428 | } |
| 429 | 429 | ||
| 430 | // DW.AT.union_type | 430 | // DW.AT.union_type |
| 431 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.union_type)); | 431 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.union_type)); |
| 432 | // DW.AT.byte_size, DW.FORM.udata, | 432 | // DW.AT.byte_size, DW.FORM.udata, |
| 433 | try leb128.writeULEB128(dbg_info_buffer.writer(), layout.payload_size); | 433 | try leb128.writeUleb128(dbg_info_buffer.writer(), layout.payload_size); |
| 434 | // DW.AT.name, DW.FORM.string | 434 | // DW.AT.name, DW.FORM.string |
| 435 | if (is_tagged) { | 435 | if (is_tagged) { |
| 436 | try dbg_info_buffer.writer().print("AnonUnion\x00", .{}); | 436 | try dbg_info_buffer.writer().print("AnonUnion\x00", .{}); |
| ... | @@ -468,7 +468,7 @@ pub const DeclState = struct { | ... | @@ -468,7 +468,7 @@ pub const DeclState = struct { |
| 468 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); | 468 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); |
| 469 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(union_obj.enum_tag_ty), @intCast(index)); | 469 | try self.addTypeRelocGlobal(atom_index, Type.fromInterned(union_obj.enum_tag_ty), @intCast(index)); |
| 470 | // DW.AT.data_member_location, DW.FORM.udata | 470 | // DW.AT.data_member_location, DW.FORM.udata |
| 471 | try leb128.writeULEB128(dbg_info_buffer.writer(), tag_offset); | 471 | try leb128.writeUleb128(dbg_info_buffer.writer(), tag_offset); |
| 472 | 472 | ||
| 473 | // DW.AT.structure_type delimit children | 473 | // DW.AT.structure_type delimit children |
| 474 | try dbg_info_buffer.append(0); | 474 | try dbg_info_buffer.append(0); |
| ... | @@ -487,7 +487,7 @@ pub const DeclState = struct { | ... | @@ -487,7 +487,7 @@ pub const DeclState = struct { |
| 487 | // DW.AT.structure_type | 487 | // DW.AT.structure_type |
| 488 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); | 488 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type)); |
| 489 | // DW.AT.byte_size, DW.FORM.udata | 489 | // DW.AT.byte_size, DW.FORM.udata |
| 490 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 490 | try leb128.writeUleb128(dbg_info_buffer.writer(), abi_size); |
| 491 | // DW.AT.name, DW.FORM.string | 491 | // DW.AT.name, DW.FORM.string |
| 492 | try ty.print(dbg_info_buffer.writer(), mod); | 492 | try ty.print(dbg_info_buffer.writer(), mod); |
| 493 | try dbg_info_buffer.append(0); | 493 | try dbg_info_buffer.append(0); |
| ... | @@ -504,7 +504,7 @@ pub const DeclState = struct { | ... | @@ -504,7 +504,7 @@ pub const DeclState = struct { |
| 504 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); | 504 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); |
| 505 | try self.addTypeRelocGlobal(atom_index, payload_ty, @intCast(index)); | 505 | try self.addTypeRelocGlobal(atom_index, payload_ty, @intCast(index)); |
| 506 | // DW.AT.data_member_location, DW.FORM.udata | 506 | // DW.AT.data_member_location, DW.FORM.udata |
| 507 | try leb128.writeULEB128(dbg_info_buffer.writer(), payload_off); | 507 | try leb128.writeUleb128(dbg_info_buffer.writer(), payload_off); |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | { | 510 | { |
| ... | @@ -519,7 +519,7 @@ pub const DeclState = struct { | ... | @@ -519,7 +519,7 @@ pub const DeclState = struct { |
| 519 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); | 519 | dbg_info_buffer.appendNTimesAssumeCapacity(0, 4); |
| 520 | try self.addTypeRelocGlobal(atom_index, error_ty, @intCast(index)); | 520 | try self.addTypeRelocGlobal(atom_index, error_ty, @intCast(index)); |
| 521 | // DW.AT.data_member_location, DW.FORM.udata | 521 | // DW.AT.data_member_location, DW.FORM.udata |
| 522 | try leb128.writeULEB128(dbg_info_buffer.writer(), error_off); | 522 | try leb128.writeUleb128(dbg_info_buffer.writer(), error_off); |
| 523 | } | 523 | } |
| 524 | 524 | ||
| 525 | // DW.AT.structure_type delimit children | 525 | // DW.AT.structure_type delimit children |
| ... | @@ -569,14 +569,14 @@ pub const DeclState = struct { | ... | @@ -569,14 +569,14 @@ pub const DeclState = struct { |
| 569 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; | 569 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; |
| 570 | } else { | 570 | } else { |
| 571 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; | 571 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; |
| 572 | leb128.writeULEB128(expr_len.writer(), reg) catch unreachable; | 572 | leb128.writeUleb128(expr_len.writer(), reg) catch unreachable; |
| 573 | } | 573 | } |
| 574 | leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; | 574 | leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; |
| 575 | if (reg < 32) { | 575 | if (reg < 32) { |
| 576 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); | 576 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); |
| 577 | } else { | 577 | } else { |
| 578 | dbg_info.appendAssumeCapacity(DW.OP.regx); | 578 | dbg_info.appendAssumeCapacity(DW.OP.regx); |
| 579 | leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable; | 579 | leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable; |
| 580 | } | 580 | } |
| 581 | }, | 581 | }, |
| 582 | .register_pair => |regs| { | 582 | .register_pair => |regs| { |
| ... | @@ -592,24 +592,24 @@ pub const DeclState = struct { | ... | @@ -592,24 +592,24 @@ pub const DeclState = struct { |
| 592 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; | 592 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; |
| 593 | } else { | 593 | } else { |
| 594 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; | 594 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; |
| 595 | leb128.writeULEB128(expr_len.writer(), reg) catch unreachable; | 595 | leb128.writeUleb128(expr_len.writer(), reg) catch unreachable; |
| 596 | } | 596 | } |
| 597 | expr_len.writer().writeByte(DW.OP.piece) catch unreachable; | 597 | expr_len.writer().writeByte(DW.OP.piece) catch unreachable; |
| 598 | leb128.writeULEB128( | 598 | leb128.writeUleb128( |
| 599 | expr_len.writer(), | 599 | expr_len.writer(), |
| 600 | @min(abi_size - reg_i * reg_bytes, reg_bytes), | 600 | @min(abi_size - reg_i * reg_bytes, reg_bytes), |
| 601 | ) catch unreachable; | 601 | ) catch unreachable; |
| 602 | } | 602 | } |
| 603 | leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; | 603 | leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; |
| 604 | for (regs, 0..) |reg, reg_i| { | 604 | for (regs, 0..) |reg, reg_i| { |
| 605 | if (reg < 32) { | 605 | if (reg < 32) { |
| 606 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); | 606 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); |
| 607 | } else { | 607 | } else { |
| 608 | dbg_info.appendAssumeCapacity(DW.OP.regx); | 608 | dbg_info.appendAssumeCapacity(DW.OP.regx); |
| 609 | leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable; | 609 | leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable; |
| 610 | } | 610 | } |
| 611 | dbg_info.appendAssumeCapacity(DW.OP.piece); | 611 | dbg_info.appendAssumeCapacity(DW.OP.piece); |
| 612 | leb128.writeULEB128( | 612 | leb128.writeUleb128( |
| 613 | dbg_info.writer(), | 613 | dbg_info.writer(), |
| 614 | @min(abi_size - reg_i * reg_bytes, reg_bytes), | 614 | @min(abi_size - reg_i * reg_bytes, reg_bytes), |
| 615 | ) catch unreachable; | 615 | ) catch unreachable; |
| ... | @@ -624,20 +624,20 @@ pub const DeclState = struct { | ... | @@ -624,20 +624,20 @@ pub const DeclState = struct { |
| 624 | expr_len.writer().writeByte(DW.OP.breg0 + info.fp_register) catch unreachable; | 624 | expr_len.writer().writeByte(DW.OP.breg0 + info.fp_register) catch unreachable; |
| 625 | } else { | 625 | } else { |
| 626 | expr_len.writer().writeByte(DW.OP.bregx) catch unreachable; | 626 | expr_len.writer().writeByte(DW.OP.bregx) catch unreachable; |
| 627 | leb128.writeULEB128(expr_len.writer(), info.fp_register) catch unreachable; | 627 | leb128.writeUleb128(expr_len.writer(), info.fp_register) catch unreachable; |
| 628 | } | 628 | } |
| 629 | leb128.writeILEB128(expr_len.writer(), info.offset) catch unreachable; | 629 | leb128.writeIleb128(expr_len.writer(), info.offset) catch unreachable; |
| 630 | leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; | 630 | leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; |
| 631 | if (info.fp_register < 32) { | 631 | if (info.fp_register < 32) { |
| 632 | dbg_info.appendAssumeCapacity(DW.OP.breg0 + info.fp_register); | 632 | dbg_info.appendAssumeCapacity(DW.OP.breg0 + info.fp_register); |
| 633 | } else { | 633 | } else { |
| 634 | dbg_info.appendAssumeCapacity(DW.OP.bregx); | 634 | dbg_info.appendAssumeCapacity(DW.OP.bregx); |
| 635 | leb128.writeULEB128(dbg_info.writer(), info.fp_register) catch unreachable; | 635 | leb128.writeUleb128(dbg_info.writer(), info.fp_register) catch unreachable; |
| 636 | } | 636 | } |
| 637 | leb128.writeILEB128(dbg_info.writer(), info.offset) catch unreachable; | 637 | leb128.writeIleb128(dbg_info.writer(), info.offset) catch unreachable; |
| 638 | }, | 638 | }, |
| 639 | .wasm_local => |value| { | 639 | .wasm_local => |value| { |
| 640 | const leb_size = link.File.Wasm.getULEB128Size(value); | 640 | const leb_size = link.File.Wasm.getUleb128Size(value); |
| 641 | try dbg_info.ensureUnusedCapacity(3 + leb_size); | 641 | try dbg_info.ensureUnusedCapacity(3 + leb_size); |
| 642 | // wasm locations are encoded as follow: | 642 | // wasm locations are encoded as follow: |
| 643 | // DW_OP_WASM_location wasm-op | 643 | // DW_OP_WASM_location wasm-op |
| ... | @@ -650,7 +650,7 @@ pub const DeclState = struct { | ... | @@ -650,7 +650,7 @@ pub const DeclState = struct { |
| 650 | DW.OP.WASM_location, | 650 | DW.OP.WASM_location, |
| 651 | DW.OP.WASM_local, | 651 | DW.OP.WASM_local, |
| 652 | }); | 652 | }); |
| 653 | leb128.writeULEB128(dbg_info.writer(), value) catch unreachable; | 653 | leb128.writeUleb128(dbg_info.writer(), value) catch unreachable; |
| 654 | }, | 654 | }, |
| 655 | else => unreachable, | 655 | else => unreachable, |
| 656 | } | 656 | } |
| ... | @@ -689,14 +689,14 @@ pub const DeclState = struct { | ... | @@ -689,14 +689,14 @@ pub const DeclState = struct { |
| 689 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; | 689 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; |
| 690 | } else { | 690 | } else { |
| 691 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; | 691 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; |
| 692 | leb128.writeULEB128(expr_len.writer(), reg) catch unreachable; | 692 | leb128.writeUleb128(expr_len.writer(), reg) catch unreachable; |
| 693 | } | 693 | } |
| 694 | leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; | 694 | leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; |
| 695 | if (reg < 32) { | 695 | if (reg < 32) { |
| 696 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); | 696 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); |
| 697 | } else { | 697 | } else { |
| 698 | dbg_info.appendAssumeCapacity(DW.OP.regx); | 698 | dbg_info.appendAssumeCapacity(DW.OP.regx); |
| 699 | leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable; | 699 | leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable; |
| 700 | } | 700 | } |
| 701 | }, | 701 | }, |
| 702 | 702 | ||
| ... | @@ -712,24 +712,24 @@ pub const DeclState = struct { | ... | @@ -712,24 +712,24 @@ pub const DeclState = struct { |
| 712 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; | 712 | expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable; |
| 713 | } else { | 713 | } else { |
| 714 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; | 714 | expr_len.writer().writeByte(DW.OP.regx) catch unreachable; |
| 715 | leb128.writeULEB128(expr_len.writer(), reg) catch unreachable; | 715 | leb128.writeUleb128(expr_len.writer(), reg) catch unreachable; |
| 716 | } | 716 | } |
| 717 | expr_len.writer().writeByte(DW.OP.piece) catch unreachable; | 717 | expr_len.writer().writeByte(DW.OP.piece) catch unreachable; |
| 718 | leb128.writeULEB128( | 718 | leb128.writeUleb128( |
| 719 | expr_len.writer(), | 719 | expr_len.writer(), |
| 720 | @min(abi_size - reg_i * reg_bytes, reg_bytes), | 720 | @min(abi_size - reg_i * reg_bytes, reg_bytes), |
| 721 | ) catch unreachable; | 721 | ) catch unreachable; |
| 722 | } | 722 | } |
| 723 | leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; | 723 | leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; |
| 724 | for (regs, 0..) |reg, reg_i| { | 724 | for (regs, 0..) |reg, reg_i| { |
| 725 | if (reg < 32) { | 725 | if (reg < 32) { |
| 726 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); | 726 | dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg); |
| 727 | } else { | 727 | } else { |
| 728 | dbg_info.appendAssumeCapacity(DW.OP.regx); | 728 | dbg_info.appendAssumeCapacity(DW.OP.regx); |
| 729 | leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable; | 729 | leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable; |
| 730 | } | 730 | } |
| 731 | dbg_info.appendAssumeCapacity(DW.OP.piece); | 731 | dbg_info.appendAssumeCapacity(DW.OP.piece); |
| 732 | leb128.writeULEB128( | 732 | leb128.writeUleb128( |
| 733 | dbg_info.writer(), | 733 | dbg_info.writer(), |
| 734 | @min(abi_size - reg_i * reg_bytes, reg_bytes), | 734 | @min(abi_size - reg_i * reg_bytes, reg_bytes), |
| 735 | ) catch unreachable; | 735 | ) catch unreachable; |
| ... | @@ -744,21 +744,21 @@ pub const DeclState = struct { | ... | @@ -744,21 +744,21 @@ pub const DeclState = struct { |
| 744 | expr_len.writer().writeByte(DW.OP.breg0 + info.fp_register) catch unreachable; | 744 | expr_len.writer().writeByte(DW.OP.breg0 + info.fp_register) catch unreachable; |
| 745 | } else { | 745 | } else { |
| 746 | expr_len.writer().writeByte(DW.OP.bregx) catch unreachable; | 746 | expr_len.writer().writeByte(DW.OP.bregx) catch unreachable; |
| 747 | leb128.writeULEB128(expr_len.writer(), info.fp_register) catch unreachable; | 747 | leb128.writeUleb128(expr_len.writer(), info.fp_register) catch unreachable; |
| 748 | } | 748 | } |
| 749 | leb128.writeILEB128(expr_len.writer(), info.offset) catch unreachable; | 749 | leb128.writeIleb128(expr_len.writer(), info.offset) catch unreachable; |
| 750 | leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; | 750 | leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable; |
| 751 | if (info.fp_register < 32) { | 751 | if (info.fp_register < 32) { |
| 752 | dbg_info.appendAssumeCapacity(DW.OP.breg0 + info.fp_register); | 752 | dbg_info.appendAssumeCapacity(DW.OP.breg0 + info.fp_register); |
| 753 | } else { | 753 | } else { |
| 754 | dbg_info.appendAssumeCapacity(DW.OP.bregx); | 754 | dbg_info.appendAssumeCapacity(DW.OP.bregx); |
| 755 | leb128.writeULEB128(dbg_info.writer(), info.fp_register) catch unreachable; | 755 | leb128.writeUleb128(dbg_info.writer(), info.fp_register) catch unreachable; |
| 756 | } | 756 | } |
| 757 | leb128.writeILEB128(dbg_info.writer(), info.offset) catch unreachable; | 757 | leb128.writeIleb128(dbg_info.writer(), info.offset) catch unreachable; |
| 758 | }, | 758 | }, |
| 759 | 759 | ||
| 760 | .wasm_local => |value| { | 760 | .wasm_local => |value| { |
| 761 | const leb_size = link.File.Wasm.getULEB128Size(value); | 761 | const leb_size = link.File.Wasm.getUleb128Size(value); |
| 762 | try dbg_info.ensureUnusedCapacity(2 + leb_size); | 762 | try dbg_info.ensureUnusedCapacity(2 + leb_size); |
| 763 | // wasm locals are encoded as follow: | 763 | // wasm locals are encoded as follow: |
| 764 | // DW_OP_WASM_location wasm-op | 764 | // DW_OP_WASM_location wasm-op |
| ... | @@ -770,7 +770,7 @@ pub const DeclState = struct { | ... | @@ -770,7 +770,7 @@ pub const DeclState = struct { |
| 770 | DW.OP.WASM_location, | 770 | DW.OP.WASM_location, |
| 771 | DW.OP.WASM_local, | 771 | DW.OP.WASM_local, |
| 772 | }); | 772 | }); |
| 773 | leb128.writeULEB128(dbg_info.writer(), value) catch unreachable; | 773 | leb128.writeUleb128(dbg_info.writer(), value) catch unreachable; |
| 774 | }, | 774 | }, |
| 775 | 775 | ||
| 776 | .memory, | 776 | .memory, |
| ... | @@ -832,9 +832,9 @@ pub const DeclState = struct { | ... | @@ -832,9 +832,9 @@ pub const DeclState = struct { |
| 832 | if (child_ty.isSignedInt(mod)) DW.OP.consts else DW.OP.constu, | 832 | if (child_ty.isSignedInt(mod)) DW.OP.consts else DW.OP.constu, |
| 833 | }); | 833 | }); |
| 834 | if (child_ty.isSignedInt(mod)) { | 834 | if (child_ty.isSignedInt(mod)) { |
| 835 | try leb128.writeILEB128(dbg_info.writer(), @as(i64, @bitCast(x))); | 835 | try leb128.writeIleb128(dbg_info.writer(), @as(i64, @bitCast(x))); |
| 836 | } else { | 836 | } else { |
| 837 | try leb128.writeULEB128(dbg_info.writer(), x); | 837 | try leb128.writeUleb128(dbg_info.writer(), x); |
| 838 | } | 838 | } |
| 839 | try dbg_info.append(DW.OP.stack_value); | 839 | try dbg_info.append(DW.OP.stack_value); |
| 840 | dbg_info.items[fixup] += @intCast(dbg_info.items.len - fixup - 2); | 840 | dbg_info.items[fixup] += @intCast(dbg_info.items.len - fixup - 2); |
| ... | @@ -847,9 +847,9 @@ pub const DeclState = struct { | ... | @@ -847,9 +847,9 @@ pub const DeclState = struct { |
| 847 | const abi_size: u32 = @intCast(child_ty.abiSize(mod)); | 847 | const abi_size: u32 = @intCast(child_ty.abiSize(mod)); |
| 848 | var implicit_value_len = std.ArrayList(u8).init(gpa); | 848 | var implicit_value_len = std.ArrayList(u8).init(gpa); |
| 849 | defer implicit_value_len.deinit(); | 849 | defer implicit_value_len.deinit(); |
| 850 | try leb128.writeULEB128(implicit_value_len.writer(), abi_size); | 850 | try leb128.writeUleb128(implicit_value_len.writer(), abi_size); |
| 851 | const total_exprloc_len = 1 + implicit_value_len.items.len + abi_size; | 851 | const total_exprloc_len = 1 + implicit_value_len.items.len + abi_size; |
| 852 | try leb128.writeULEB128(dbg_info.writer(), total_exprloc_len); | 852 | try leb128.writeUleb128(dbg_info.writer(), total_exprloc_len); |
| 853 | try dbg_info.ensureUnusedCapacity(total_exprloc_len); | 853 | try dbg_info.ensureUnusedCapacity(total_exprloc_len); |
| 854 | dbg_info.appendAssumeCapacity(DW.OP.implicit_value); | 854 | dbg_info.appendAssumeCapacity(DW.OP.implicit_value); |
| 855 | dbg_info.appendSliceAssumeCapacity(implicit_value_len.items); | 855 | dbg_info.appendSliceAssumeCapacity(implicit_value_len.items); |
| ... | @@ -895,7 +895,7 @@ pub const DeclState = struct { | ... | @@ -895,7 +895,7 @@ pub const DeclState = struct { |
| 895 | remaining: { | 895 | remaining: { |
| 896 | assert(delta_line != 0); | 896 | assert(delta_line != 0); |
| 897 | dbg_line.appendAssumeCapacity(DW.LNS.advance_line); | 897 | dbg_line.appendAssumeCapacity(DW.LNS.advance_line); |
| 898 | leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable; | 898 | leb128.writeIleb128(dbg_line.writer(), delta_line) catch unreachable; |
| 899 | break :remaining 0; | 899 | break :remaining 0; |
| 900 | } else delta_line); | 900 | } else delta_line); |
| 901 | 901 | ||
| ... | @@ -904,7 +904,7 @@ pub const DeclState = struct { | ... | @@ -904,7 +904,7 @@ pub const DeclState = struct { |
| 904 | const max_op_advance: u9 = (std.math.maxInt(u8) - header.opcode_base) / header.line_range; | 904 | const max_op_advance: u9 = (std.math.maxInt(u8) - header.opcode_base) / header.line_range; |
| 905 | const remaining_op_advance: u8 = @intCast(if (op_advance >= 2 * max_op_advance) remaining: { | 905 | const remaining_op_advance: u8 = @intCast(if (op_advance >= 2 * max_op_advance) remaining: { |
| 906 | dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); | 906 | dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); |
| 907 | leb128.writeULEB128(dbg_line.writer(), op_advance) catch unreachable; | 907 | leb128.writeUleb128(dbg_line.writer(), op_advance) catch unreachable; |
| 908 | break :remaining 0; | 908 | break :remaining 0; |
| 909 | } else if (op_advance >= max_op_advance) remaining: { | 909 | } else if (op_advance >= max_op_advance) remaining: { |
| 910 | dbg_line.appendAssumeCapacity(DW.LNS.const_add_pc); | 910 | dbg_line.appendAssumeCapacity(DW.LNS.const_add_pc); |
| ... | @@ -922,7 +922,7 @@ pub const DeclState = struct { | ... | @@ -922,7 +922,7 @@ pub const DeclState = struct { |
| 922 | pub fn setColumn(self: *DeclState, column: u32) error{OutOfMemory}!void { | 922 | pub fn setColumn(self: *DeclState, column: u32) error{OutOfMemory}!void { |
| 923 | try self.dbg_line.ensureUnusedCapacity(1 + 5); | 923 | try self.dbg_line.ensureUnusedCapacity(1 + 5); |
| 924 | self.dbg_line.appendAssumeCapacity(DW.LNS.set_column); | 924 | self.dbg_line.appendAssumeCapacity(DW.LNS.set_column); |
| 925 | leb128.writeULEB128(self.dbg_line.writer(), column + 1) catch unreachable; | 925 | leb128.writeUleb128(self.dbg_line.writer(), column + 1) catch unreachable; |
| 926 | } | 926 | } |
| 927 | 927 | ||
| 928 | pub fn setPrologueEnd(self: *DeclState) error{OutOfMemory}!void { | 928 | pub fn setPrologueEnd(self: *DeclState) error{OutOfMemory}!void { |
| ... | @@ -1146,7 +1146,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclInde | ... | @@ -1146,7 +1146,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclInde |
| 1146 | leb128.writeUnsignedFixed(4, dbg_line_buffer.addManyAsArrayAssumeCapacity(4), file_index); | 1146 | leb128.writeUnsignedFixed(4, dbg_line_buffer.addManyAsArrayAssumeCapacity(4), file_index); |
| 1147 | 1147 | ||
| 1148 | dbg_line_buffer.appendAssumeCapacity(DW.LNS.set_column); | 1148 | dbg_line_buffer.appendAssumeCapacity(DW.LNS.set_column); |
| 1149 | leb128.writeULEB128(dbg_line_buffer.writer(), func.lbrace_column + 1) catch unreachable; | 1149 | leb128.writeUleb128(dbg_line_buffer.writer(), func.lbrace_column + 1) catch unreachable; |
| 1150 | 1150 | ||
| 1151 | // Emit a line for the begin curly with prologue_end=false. The codegen will | 1151 | // Emit a line for the begin curly with prologue_end=false. The codegen will |
| 1152 | // do the work of setting prologue_end=true and epilogue_begin=true. | 1152 | // do the work of setting prologue_end=true and epilogue_begin=true. |
| ... | @@ -2849,7 +2849,7 @@ fn addDbgInfoErrorSetNames( | ... | @@ -2849,7 +2849,7 @@ fn addDbgInfoErrorSetNames( |
| 2849 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.enum_type)); | 2849 | try dbg_info_buffer.append(@intFromEnum(AbbrevCode.enum_type)); |
| 2850 | // DW.AT.byte_size, DW.FORM.udata | 2850 | // DW.AT.byte_size, DW.FORM.udata |
| 2851 | const abi_size = Type.anyerror.abiSize(mod); | 2851 | const abi_size = Type.anyerror.abiSize(mod); |
| 2852 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 2852 | try leb128.writeUleb128(dbg_info_buffer.writer(), abi_size); |
| 2853 | // DW.AT.name, DW.FORM.string | 2853 | // DW.AT.name, DW.FORM.string |
| 2854 | try ty.print(dbg_info_buffer.writer(), mod); | 2854 | try ty.print(dbg_info_buffer.writer(), mod); |
| 2855 | try dbg_info_buffer.append(0); | 2855 | try dbg_info_buffer.append(0); |
src/link/MachO/Dylib.zig+9-9| ... | @@ -159,11 +159,11 @@ const TrieIterator = struct { | ... | @@ -159,11 +159,11 @@ const TrieIterator = struct { |
| 159 | return std.io.fixedBufferStream(it.data[it.pos..]); | 159 | return std.io.fixedBufferStream(it.data[it.pos..]); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | fn readULEB128(it: *TrieIterator) !u64 { | 162 | fn readUleb128(it: *TrieIterator) !u64 { |
| 163 | var stream = it.getStream(); | 163 | var stream = it.getStream(); |
| 164 | var creader = std.io.countingReader(stream.reader()); | 164 | var creader = std.io.countingReader(stream.reader()); |
| 165 | const reader = creader.reader(); | 165 | const reader = creader.reader(); |
| 166 | const value = try std.leb.readULEB128(u64, reader); | 166 | const value = try std.leb.readUleb128(u64, reader); |
| 167 | it.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; | 167 | it.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; |
| 168 | return value; | 168 | return value; |
| 169 | } | 169 | } |
| ... | @@ -207,9 +207,9 @@ fn parseTrieNode( | ... | @@ -207,9 +207,9 @@ fn parseTrieNode( |
| 207 | ) !void { | 207 | ) !void { |
| 208 | const tracy = trace(@src()); | 208 | const tracy = trace(@src()); |
| 209 | defer tracy.end(); | 209 | defer tracy.end(); |
| 210 | const size = try it.readULEB128(); | 210 | const size = try it.readUleb128(); |
| 211 | if (size > 0) { | 211 | if (size > 0) { |
| 212 | const flags = try it.readULEB128(); | 212 | const flags = try it.readUleb128(); |
| 213 | const kind = flags & macho.EXPORT_SYMBOL_FLAGS_KIND_MASK; | 213 | const kind = flags & macho.EXPORT_SYMBOL_FLAGS_KIND_MASK; |
| 214 | const out_flags = Export.Flags{ | 214 | const out_flags = Export.Flags{ |
| 215 | .abs = kind == macho.EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE, | 215 | .abs = kind == macho.EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE, |
| ... | @@ -217,15 +217,15 @@ fn parseTrieNode( | ... | @@ -217,15 +217,15 @@ fn parseTrieNode( |
| 217 | .weak = flags & macho.EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION != 0, | 217 | .weak = flags & macho.EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION != 0, |
| 218 | }; | 218 | }; |
| 219 | if (flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT != 0) { | 219 | if (flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT != 0) { |
| 220 | _ = try it.readULEB128(); // dylib ordinal | 220 | _ = try it.readUleb128(); // dylib ordinal |
| 221 | const name = try it.readString(); | 221 | const name = try it.readString(); |
| 222 | try self.addExport(allocator, if (name.len > 0) name else prefix, out_flags); | 222 | try self.addExport(allocator, if (name.len > 0) name else prefix, out_flags); |
| 223 | } else if (flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER != 0) { | 223 | } else if (flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER != 0) { |
| 224 | _ = try it.readULEB128(); // stub offset | 224 | _ = try it.readUleb128(); // stub offset |
| 225 | _ = try it.readULEB128(); // resolver offset | 225 | _ = try it.readUleb128(); // resolver offset |
| 226 | try self.addExport(allocator, prefix, out_flags); | 226 | try self.addExport(allocator, prefix, out_flags); |
| 227 | } else { | 227 | } else { |
| 228 | _ = try it.readULEB128(); // VM offset | 228 | _ = try it.readUleb128(); // VM offset |
| 229 | try self.addExport(allocator, prefix, out_flags); | 229 | try self.addExport(allocator, prefix, out_flags); |
| 230 | } | 230 | } |
| 231 | } | 231 | } |
| ... | @@ -234,7 +234,7 @@ fn parseTrieNode( | ... | @@ -234,7 +234,7 @@ fn parseTrieNode( |
| 234 | 234 | ||
| 235 | for (0..nedges) |_| { | 235 | for (0..nedges) |_| { |
| 236 | const label = try it.readString(); | 236 | const label = try it.readString(); |
| 237 | const off = try it.readULEB128(); | 237 | const off = try it.readUleb128(); |
| 238 | const prefix_label = try std.fmt.allocPrint(arena, "{s}{s}", .{ prefix, label }); | 238 | const prefix_label = try std.fmt.allocPrint(arena, "{s}{s}", .{ prefix, label }); |
| 239 | const curr = it.pos; | 239 | const curr = it.pos; |
| 240 | it.pos = math.cast(usize, off) orelse return error.Overflow; | 240 | it.pos = math.cast(usize, off) orelse return error.Overflow; |
src/link/MachO/dwarf.zig+15-15| ... | @@ -26,7 +26,7 @@ pub const InfoReader = struct { | ... | @@ -26,7 +26,7 @@ pub const InfoReader = struct { |
| 26 | .dwarf64 => 12, | 26 | .dwarf64 => 12, |
| 27 | } + cuh_length; | 27 | } + cuh_length; |
| 28 | while (p.pos < end_pos) { | 28 | while (p.pos < end_pos) { |
| 29 | const di_code = try p.readULEB128(u64); | 29 | const di_code = try p.readUleb128(u64); |
| 30 | if (di_code == 0) return error.Eof; | 30 | if (di_code == 0) return error.Eof; |
| 31 | if (di_code == code) return; | 31 | if (di_code == code) return; |
| 32 | 32 | ||
| ... | @@ -92,14 +92,14 @@ pub const InfoReader = struct { | ... | @@ -92,14 +92,14 @@ pub const InfoReader = struct { |
| 92 | dwarf.FORM.block1 => try p.readByte(), | 92 | dwarf.FORM.block1 => try p.readByte(), |
| 93 | dwarf.FORM.block2 => try p.readInt(u16), | 93 | dwarf.FORM.block2 => try p.readInt(u16), |
| 94 | dwarf.FORM.block4 => try p.readInt(u32), | 94 | dwarf.FORM.block4 => try p.readInt(u32), |
| 95 | dwarf.FORM.block => try p.readULEB128(u64), | 95 | dwarf.FORM.block => try p.readUleb128(u64), |
| 96 | else => unreachable, | 96 | else => unreachable, |
| 97 | }; | 97 | }; |
| 98 | return p.readNBytes(len); | 98 | return p.readNBytes(len); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | pub fn readExprLoc(p: *InfoReader) ![]const u8 { | 101 | pub fn readExprLoc(p: *InfoReader) ![]const u8 { |
| 102 | const len: u64 = try p.readULEB128(u64); | 102 | const len: u64 = try p.readUleb128(u64); |
| 103 | return p.readNBytes(len); | 103 | return p.readNBytes(len); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| ... | @@ -109,8 +109,8 @@ pub const InfoReader = struct { | ... | @@ -109,8 +109,8 @@ pub const InfoReader = struct { |
| 109 | dwarf.FORM.data2, dwarf.FORM.ref2 => try p.readInt(u16), | 109 | dwarf.FORM.data2, dwarf.FORM.ref2 => try p.readInt(u16), |
| 110 | dwarf.FORM.data4, dwarf.FORM.ref4 => try p.readInt(u32), | 110 | dwarf.FORM.data4, dwarf.FORM.ref4 => try p.readInt(u32), |
| 111 | dwarf.FORM.data8, dwarf.FORM.ref8, dwarf.FORM.ref_sig8 => try p.readInt(u64), | 111 | dwarf.FORM.data8, dwarf.FORM.ref8, dwarf.FORM.ref_sig8 => try p.readInt(u64), |
| 112 | dwarf.FORM.udata, dwarf.FORM.ref_udata => try p.readULEB128(u64), | 112 | dwarf.FORM.udata, dwarf.FORM.ref_udata => try p.readUleb128(u64), |
| 113 | dwarf.FORM.sdata => @bitCast(try p.readILEB128(i64)), | 113 | dwarf.FORM.sdata => @bitCast(try p.readIleb128(i64)), |
| 114 | else => return error.UnhandledConstantForm, | 114 | else => return error.UnhandledConstantForm, |
| 115 | }; | 115 | }; |
| 116 | } | 116 | } |
| ... | @@ -160,18 +160,18 @@ pub const InfoReader = struct { | ... | @@ -160,18 +160,18 @@ pub const InfoReader = struct { |
| 160 | }; | 160 | }; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | pub fn readULEB128(p: *InfoReader, comptime Type: type) !Type { | 163 | pub fn readUleb128(p: *InfoReader, comptime Type: type) !Type { |
| 164 | var stream = std.io.fixedBufferStream(p.bytes[p.pos..]); | 164 | var stream = std.io.fixedBufferStream(p.bytes[p.pos..]); |
| 165 | var creader = std.io.countingReader(stream.reader()); | 165 | var creader = std.io.countingReader(stream.reader()); |
| 166 | const value: Type = try leb.readULEB128(Type, creader.reader()); | 166 | const value: Type = try leb.readUleb128(Type, creader.reader()); |
| 167 | p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; | 167 | p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; |
| 168 | return value; | 168 | return value; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | pub fn readILEB128(p: *InfoReader, comptime Type: type) !Type { | 171 | pub fn readIleb128(p: *InfoReader, comptime Type: type) !Type { |
| 172 | var stream = std.io.fixedBufferStream(p.bytes[p.pos..]); | 172 | var stream = std.io.fixedBufferStream(p.bytes[p.pos..]); |
| 173 | var creader = std.io.countingReader(stream.reader()); | 173 | var creader = std.io.countingReader(stream.reader()); |
| 174 | const value: Type = try leb.readILEB128(Type, creader.reader()); | 174 | const value: Type = try leb.readIleb128(Type, creader.reader()); |
| 175 | p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; | 175 | p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; |
| 176 | return value; | 176 | return value; |
| 177 | } | 177 | } |
| ... | @@ -191,10 +191,10 @@ pub const AbbrevReader = struct { | ... | @@ -191,10 +191,10 @@ pub const AbbrevReader = struct { |
| 191 | 191 | ||
| 192 | pub fn readDecl(p: *AbbrevReader) !?AbbrevDecl { | 192 | pub fn readDecl(p: *AbbrevReader) !?AbbrevDecl { |
| 193 | const pos = p.pos; | 193 | const pos = p.pos; |
| 194 | const code = try p.readULEB128(Code); | 194 | const code = try p.readUleb128(Code); |
| 195 | if (code == 0) return null; | 195 | if (code == 0) return null; |
| 196 | 196 | ||
| 197 | const tag = try p.readULEB128(Tag); | 197 | const tag = try p.readUleb128(Tag); |
| 198 | const has_children = (try p.readByte()) > 0; | 198 | const has_children = (try p.readByte()) > 0; |
| 199 | return .{ | 199 | return .{ |
| 200 | .code = code, | 200 | .code = code, |
| ... | @@ -207,8 +207,8 @@ pub const AbbrevReader = struct { | ... | @@ -207,8 +207,8 @@ pub const AbbrevReader = struct { |
| 207 | 207 | ||
| 208 | pub fn readAttr(p: *AbbrevReader) !?AbbrevAttr { | 208 | pub fn readAttr(p: *AbbrevReader) !?AbbrevAttr { |
| 209 | const pos = p.pos; | 209 | const pos = p.pos; |
| 210 | const at = try p.readULEB128(At); | 210 | const at = try p.readUleb128(At); |
| 211 | const form = try p.readULEB128(Form); | 211 | const form = try p.readUleb128(Form); |
| 212 | return if (at == 0 and form == 0) null else .{ | 212 | return if (at == 0 and form == 0) null else .{ |
| 213 | .at = at, | 213 | .at = at, |
| 214 | .form = form, | 214 | .form = form, |
| ... | @@ -223,10 +223,10 @@ pub const AbbrevReader = struct { | ... | @@ -223,10 +223,10 @@ pub const AbbrevReader = struct { |
| 223 | return p.bytes[p.pos]; | 223 | return p.bytes[p.pos]; |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | pub fn readULEB128(p: *AbbrevReader, comptime Type: type) !Type { | 226 | pub fn readUleb128(p: *AbbrevReader, comptime Type: type) !Type { |
| 227 | var stream = std.io.fixedBufferStream(p.bytes[p.pos..]); | 227 | var stream = std.io.fixedBufferStream(p.bytes[p.pos..]); |
| 228 | var creader = std.io.countingReader(stream.reader()); | 228 | var creader = std.io.countingReader(stream.reader()); |
| 229 | const value: Type = try leb.readULEB128(Type, creader.reader()); | 229 | const value: Type = try leb.readUleb128(Type, creader.reader()); |
| 230 | p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; | 230 | p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow; |
| 231 | return value; | 231 | return value; |
| 232 | } | 232 | } |
src/link/MachO/dyld_info/Rebase.zig+6-6| ... | @@ -153,13 +153,13 @@ fn setTypePointer(writer: anytype) !void { | ... | @@ -153,13 +153,13 @@ fn setTypePointer(writer: anytype) !void { |
| 153 | fn setSegmentOffset(segment_id: u8, offset: u64, writer: anytype) !void { | 153 | fn setSegmentOffset(segment_id: u8, offset: u64, writer: anytype) !void { |
| 154 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); | 154 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); |
| 155 | try writer.writeByte(macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id))); | 155 | try writer.writeByte(macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id))); |
| 156 | try std.leb.writeULEB128(writer, offset); | 156 | try std.leb.writeUleb128(writer, offset); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | fn rebaseAddAddr(addr: u64, writer: anytype) !void { | 159 | fn rebaseAddAddr(addr: u64, writer: anytype) !void { |
| 160 | log.debug(">>> rebase with add: {x}", .{addr}); | 160 | log.debug(">>> rebase with add: {x}", .{addr}); |
| 161 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB); | 161 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB); |
| 162 | try std.leb.writeULEB128(writer, addr); | 162 | try std.leb.writeUleb128(writer, addr); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | fn rebaseTimes(count: usize, writer: anytype) !void { | 165 | fn rebaseTimes(count: usize, writer: anytype) !void { |
| ... | @@ -168,15 +168,15 @@ fn rebaseTimes(count: usize, writer: anytype) !void { | ... | @@ -168,15 +168,15 @@ fn rebaseTimes(count: usize, writer: anytype) !void { |
| 168 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_IMM_TIMES | @as(u4, @truncate(count))); | 168 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_IMM_TIMES | @as(u4, @truncate(count))); |
| 169 | } else { | 169 | } else { |
| 170 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES); | 170 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES); |
| 171 | try std.leb.writeULEB128(writer, count); | 171 | try std.leb.writeUleb128(writer, count); |
| 172 | } | 172 | } |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | fn rebaseTimesSkip(count: usize, skip: u64, writer: anytype) !void { | 175 | fn rebaseTimesSkip(count: usize, skip: u64, writer: anytype) !void { |
| 176 | log.debug(">>> rebase with count: {d} and skip: {x}", .{ count, skip }); | 176 | log.debug(">>> rebase with count: {d} and skip: {x}", .{ count, skip }); |
| 177 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB); | 177 | try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB); |
| 178 | try std.leb.writeULEB128(writer, count); | 178 | try std.leb.writeUleb128(writer, count); |
| 179 | try std.leb.writeULEB128(writer, skip); | 179 | try std.leb.writeUleb128(writer, skip); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | fn addAddr(addr: u64, writer: anytype) !void { | 182 | fn addAddr(addr: u64, writer: anytype) !void { |
| ... | @@ -189,7 +189,7 @@ fn addAddr(addr: u64, writer: anytype) !void { | ... | @@ -189,7 +189,7 @@ fn addAddr(addr: u64, writer: anytype) !void { |
| 189 | } | 189 | } |
| 190 | } | 190 | } |
| 191 | try writer.writeByte(macho.REBASE_OPCODE_ADD_ADDR_ULEB); | 191 | try writer.writeByte(macho.REBASE_OPCODE_ADD_ADDR_ULEB); |
| 192 | try std.leb.writeULEB128(writer, addr); | 192 | try std.leb.writeUleb128(writer, addr); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | fn done(writer: anytype) !void { | 195 | fn done(writer: anytype) !void { |
src/link/MachO/dyld_info/Trie.zig+12-12| ... | @@ -133,14 +133,14 @@ pub const Node = struct { | ... | @@ -133,14 +133,14 @@ pub const Node = struct { |
| 133 | 133 | ||
| 134 | var nread: usize = 0; | 134 | var nread: usize = 0; |
| 135 | 135 | ||
| 136 | const node_size = try leb.readULEB128(u64, reader); | 136 | const node_size = try leb.readUleb128(u64, reader); |
| 137 | if (node_size > 0) { | 137 | if (node_size > 0) { |
| 138 | const export_flags = try leb.readULEB128(u64, reader); | 138 | const export_flags = try leb.readUleb128(u64, reader); |
| 139 | // TODO Parse special flags. | 139 | // TODO Parse special flags. |
| 140 | assert(export_flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT == 0 and | 140 | assert(export_flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT == 0 and |
| 141 | export_flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER == 0); | 141 | export_flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER == 0); |
| 142 | 142 | ||
| 143 | const vmaddr_offset = try leb.readULEB128(u64, reader); | 143 | const vmaddr_offset = try leb.readUleb128(u64, reader); |
| 144 | 144 | ||
| 145 | self.terminal_info = .{ | 145 | self.terminal_info = .{ |
| 146 | .export_flags = export_flags, | 146 | .export_flags = export_flags, |
| ... | @@ -168,7 +168,7 @@ pub const Node = struct { | ... | @@ -168,7 +168,7 @@ pub const Node = struct { |
| 168 | break :blk try label_buf.toOwnedSlice(); | 168 | break :blk try label_buf.toOwnedSlice(); |
| 169 | }; | 169 | }; |
| 170 | 170 | ||
| 171 | const seek_to = try leb.readULEB128(u64, reader); | 171 | const seek_to = try leb.readUleb128(u64, reader); |
| 172 | const return_pos = try reader.context.getPos(); | 172 | const return_pos = try reader.context.getPos(); |
| 173 | 173 | ||
| 174 | nread += return_pos - edge_start_pos; | 174 | nread += return_pos - edge_start_pos; |
| ... | @@ -204,13 +204,13 @@ pub const Node = struct { | ... | @@ -204,13 +204,13 @@ pub const Node = struct { |
| 204 | // TODO Implement for special flags. | 204 | // TODO Implement for special flags. |
| 205 | assert(info.export_flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT == 0 and | 205 | assert(info.export_flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT == 0 and |
| 206 | info.export_flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER == 0); | 206 | info.export_flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER == 0); |
| 207 | try leb.writeULEB128(info_stream.writer(), info.export_flags); | 207 | try leb.writeUleb128(info_stream.writer(), info.export_flags); |
| 208 | try leb.writeULEB128(info_stream.writer(), info.vmaddr_offset); | 208 | try leb.writeUleb128(info_stream.writer(), info.vmaddr_offset); |
| 209 | 209 | ||
| 210 | // Encode the size of the terminal node info. | 210 | // Encode the size of the terminal node info. |
| 211 | var size_buf: [@sizeOf(u64)]u8 = undefined; | 211 | var size_buf: [@sizeOf(u64)]u8 = undefined; |
| 212 | var size_stream = std.io.fixedBufferStream(&size_buf); | 212 | var size_stream = std.io.fixedBufferStream(&size_buf); |
| 213 | try leb.writeULEB128(size_stream.writer(), info_stream.pos); | 213 | try leb.writeUleb128(size_stream.writer(), info_stream.pos); |
| 214 | 214 | ||
| 215 | // Now, write them to the output stream. | 215 | // Now, write them to the output stream. |
| 216 | try writer.writeAll(size_buf[0..size_stream.pos]); | 216 | try writer.writeAll(size_buf[0..size_stream.pos]); |
| ... | @@ -226,7 +226,7 @@ pub const Node = struct { | ... | @@ -226,7 +226,7 @@ pub const Node = struct { |
| 226 | // Write edge label and offset to next node in trie. | 226 | // Write edge label and offset to next node in trie. |
| 227 | try writer.writeAll(edge.label); | 227 | try writer.writeAll(edge.label); |
| 228 | try writer.writeByte(0); | 228 | try writer.writeByte(0); |
| 229 | try leb.writeULEB128(writer, edge.to.trie_offset.?); | 229 | try leb.writeUleb128(writer, edge.to.trie_offset.?); |
| 230 | } | 230 | } |
| 231 | } | 231 | } |
| 232 | 232 | ||
| ... | @@ -246,9 +246,9 @@ pub const Node = struct { | ... | @@ -246,9 +246,9 @@ pub const Node = struct { |
| 246 | 246 | ||
| 247 | var node_size: u64 = 0; | 247 | var node_size: u64 = 0; |
| 248 | if (self.terminal_info) |info| { | 248 | if (self.terminal_info) |info| { |
| 249 | try leb.writeULEB128(writer, info.export_flags); | 249 | try leb.writeUleb128(writer, info.export_flags); |
| 250 | try leb.writeULEB128(writer, info.vmaddr_offset); | 250 | try leb.writeUleb128(writer, info.vmaddr_offset); |
| 251 | try leb.writeULEB128(writer, stream.bytes_written); | 251 | try leb.writeUleb128(writer, stream.bytes_written); |
| 252 | } else { | 252 | } else { |
| 253 | node_size += 1; // 0x0 for non-terminal nodes | 253 | node_size += 1; // 0x0 for non-terminal nodes |
| 254 | } | 254 | } |
| ... | @@ -257,7 +257,7 @@ pub const Node = struct { | ... | @@ -257,7 +257,7 @@ pub const Node = struct { |
| 257 | for (self.edges.items) |edge| { | 257 | for (self.edges.items) |edge| { |
| 258 | const next_node_offset = edge.to.trie_offset orelse 0; | 258 | const next_node_offset = edge.to.trie_offset orelse 0; |
| 259 | node_size += edge.label.len + 1; | 259 | node_size += edge.label.len + 1; |
| 260 | try leb.writeULEB128(writer, next_node_offset); | 260 | try leb.writeUleb128(writer, next_node_offset); |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | const trie_offset = self.trie_offset orelse 0; | 263 | const trie_offset = self.trie_offset orelse 0; |
src/link/MachO/dyld_info/bind.zig+7-7| ... | @@ -392,7 +392,7 @@ pub const LazyBind = struct { | ... | @@ -392,7 +392,7 @@ pub const LazyBind = struct { |
| 392 | fn setSegmentOffset(segment_id: u8, offset: u64, writer: anytype) !void { | 392 | fn setSegmentOffset(segment_id: u8, offset: u64, writer: anytype) !void { |
| 393 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); | 393 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); |
| 394 | try writer.writeByte(macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id))); | 394 | try writer.writeByte(macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id))); |
| 395 | try std.leb.writeULEB128(writer, offset); | 395 | try std.leb.writeUleb128(writer, offset); |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | fn setSymbol(name: []const u8, flags: u8, writer: anytype) !void { | 398 | fn setSymbol(name: []const u8, flags: u8, writer: anytype) !void { |
| ... | @@ -426,7 +426,7 @@ fn setDylibOrdinal(ordinal: i16, writer: anytype) !void { | ... | @@ -426,7 +426,7 @@ fn setDylibOrdinal(ordinal: i16, writer: anytype) !void { |
| 426 | try writer.writeByte(macho.BIND_OPCODE_SET_DYLIB_ORDINAL_IMM | @as(u4, @truncate(cast))); | 426 | try writer.writeByte(macho.BIND_OPCODE_SET_DYLIB_ORDINAL_IMM | @as(u4, @truncate(cast))); |
| 427 | } else { | 427 | } else { |
| 428 | try writer.writeByte(macho.BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB); | 428 | try writer.writeByte(macho.BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB); |
| 429 | try std.leb.writeULEB128(writer, cast); | 429 | try std.leb.writeUleb128(writer, cast); |
| 430 | } | 430 | } |
| 431 | } | 431 | } |
| 432 | } | 432 | } |
| ... | @@ -434,7 +434,7 @@ fn setDylibOrdinal(ordinal: i16, writer: anytype) !void { | ... | @@ -434,7 +434,7 @@ fn setDylibOrdinal(ordinal: i16, writer: anytype) !void { |
| 434 | fn setAddend(addend: i64, writer: anytype) !void { | 434 | fn setAddend(addend: i64, writer: anytype) !void { |
| 435 | log.debug(">>> set addend: {x}", .{addend}); | 435 | log.debug(">>> set addend: {x}", .{addend}); |
| 436 | try writer.writeByte(macho.BIND_OPCODE_SET_ADDEND_SLEB); | 436 | try writer.writeByte(macho.BIND_OPCODE_SET_ADDEND_SLEB); |
| 437 | try std.leb.writeILEB128(writer, addend); | 437 | try std.leb.writeIleb128(writer, addend); |
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | fn doBind(writer: anytype) !void { | 440 | fn doBind(writer: anytype) !void { |
| ... | @@ -454,20 +454,20 @@ fn doBindAddAddr(addr: u64, writer: anytype) !void { | ... | @@ -454,20 +454,20 @@ fn doBindAddAddr(addr: u64, writer: anytype) !void { |
| 454 | } | 454 | } |
| 455 | } | 455 | } |
| 456 | try writer.writeByte(macho.BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB); | 456 | try writer.writeByte(macho.BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB); |
| 457 | try std.leb.writeULEB128(writer, addr); | 457 | try std.leb.writeUleb128(writer, addr); |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | fn doBindTimesSkip(count: usize, skip: u64, writer: anytype) !void { | 460 | fn doBindTimesSkip(count: usize, skip: u64, writer: anytype) !void { |
| 461 | log.debug(">>> bind with count: {d} and skip: {x}", .{ count, skip }); | 461 | log.debug(">>> bind with count: {d} and skip: {x}", .{ count, skip }); |
| 462 | try writer.writeByte(macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB); | 462 | try writer.writeByte(macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB); |
| 463 | try std.leb.writeULEB128(writer, count); | 463 | try std.leb.writeUleb128(writer, count); |
| 464 | try std.leb.writeULEB128(writer, skip); | 464 | try std.leb.writeUleb128(writer, skip); |
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | fn addAddr(addr: u64, writer: anytype) !void { | 467 | fn addAddr(addr: u64, writer: anytype) !void { |
| 468 | log.debug(">>> add: {x}", .{addr}); | 468 | log.debug(">>> add: {x}", .{addr}); |
| 469 | try writer.writeByte(macho.BIND_OPCODE_ADD_ADDR_ULEB); | 469 | try writer.writeByte(macho.BIND_OPCODE_ADD_ADDR_ULEB); |
| 470 | try std.leb.writeULEB128(writer, addr); | 470 | try std.leb.writeUleb128(writer, addr); |
| 471 | } | 471 | } |
| 472 | 472 | ||
| 473 | fn done(writer: anytype) !void { | 473 | fn done(writer: anytype) !void { |
src/link/MachO/eh_frame.zig+5-5| ... | @@ -21,10 +21,10 @@ pub const Cie = struct { | ... | @@ -21,10 +21,10 @@ pub const Cie = struct { |
| 21 | var creader = std.io.countingReader(stream.reader()); | 21 | var creader = std.io.countingReader(stream.reader()); |
| 22 | const reader = creader.reader(); | 22 | const reader = creader.reader(); |
| 23 | 23 | ||
| 24 | _ = try leb.readULEB128(u64, reader); // code alignment factor | 24 | _ = try leb.readUleb128(u64, reader); // code alignment factor |
| 25 | _ = try leb.readULEB128(u64, reader); // data alignment factor | 25 | _ = try leb.readUleb128(u64, reader); // data alignment factor |
| 26 | _ = try leb.readULEB128(u64, reader); // return address register | 26 | _ = try leb.readUleb128(u64, reader); // return address register |
| 27 | _ = try leb.readULEB128(u64, reader); // augmentation data length | 27 | _ = try leb.readUleb128(u64, reader); // augmentation data length |
| 28 | 28 | ||
| 29 | for (aug[1..]) |ch| switch (ch) { | 29 | for (aug[1..]) |ch| switch (ch) { |
| 30 | 'R' => { | 30 | 'R' => { |
| ... | @@ -185,7 +185,7 @@ pub const Fde = struct { | ... | @@ -185,7 +185,7 @@ pub const Fde = struct { |
| 185 | var stream = std.io.fixedBufferStream(data[24..]); | 185 | var stream = std.io.fixedBufferStream(data[24..]); |
| 186 | var creader = std.io.countingReader(stream.reader()); | 186 | var creader = std.io.countingReader(stream.reader()); |
| 187 | const reader = creader.reader(); | 187 | const reader = creader.reader(); |
| 188 | _ = try leb.readULEB128(u64, reader); // augmentation length | 188 | _ = try leb.readUleb128(u64, reader); // augmentation length |
| 189 | fde.lsda_ptr_offset = @intCast(creader.bytes_read + 24); | 189 | fde.lsda_ptr_offset = @intCast(creader.bytes_read + 24); |
| 190 | const lsda_ptr = switch (lsda_size) { | 190 | const lsda_ptr = switch (lsda_size) { |
| 191 | .p32 => try reader.readInt(i32, .little), | 191 | .p32 => try reader.readInt(i32, .little), |
src/link/Wasm.zig+128-128| ... | @@ -952,7 +952,7 @@ fn resolveSymbolsInArchives(wasm: *Wasm) !void { | ... | @@ -952,7 +952,7 @@ fn resolveSymbolsInArchives(wasm: *Wasm) !void { |
| 952 | /// Writes an unsigned 32-bit integer as a LEB128-encoded 'i32.const' value. | 952 | /// Writes an unsigned 32-bit integer as a LEB128-encoded 'i32.const' value. |
| 953 | fn writeI32Const(writer: anytype, val: u32) !void { | 953 | fn writeI32Const(writer: anytype, val: u32) !void { |
| 954 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 954 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 955 | try leb.writeILEB128(writer, @as(i32, @bitCast(val))); | 955 | try leb.writeIleb128(writer, @as(i32, @bitCast(val))); |
| 956 | } | 956 | } |
| 957 | 957 | ||
| 958 | fn setupInitMemoryFunction(wasm: *Wasm) !void { | 958 | fn setupInitMemoryFunction(wasm: *Wasm) !void { |
| ... | @@ -984,7 +984,7 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { | ... | @@ -984,7 +984,7 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { |
| 984 | const writer = function_body.writer(); | 984 | const writer = function_body.writer(); |
| 985 | 985 | ||
| 986 | // we have 0 locals | 986 | // we have 0 locals |
| 987 | try leb.writeULEB128(writer, @as(u32, 0)); | 987 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 988 | 988 | ||
| 989 | if (shared_memory) { | 989 | if (shared_memory) { |
| 990 | // destination blocks | 990 | // destination blocks |
| ... | @@ -1003,16 +1003,16 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { | ... | @@ -1003,16 +1003,16 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { |
| 1003 | try writeI32Const(writer, 0); | 1003 | try writeI32Const(writer, 0); |
| 1004 | try writeI32Const(writer, 1); | 1004 | try writeI32Const(writer, 1); |
| 1005 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); | 1005 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); |
| 1006 | try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.i32_atomic_rmw_cmpxchg)); | 1006 | try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.i32_atomic_rmw_cmpxchg)); |
| 1007 | try leb.writeULEB128(writer, @as(u32, 2)); // alignment | 1007 | try leb.writeUleb128(writer, @as(u32, 2)); // alignment |
| 1008 | try leb.writeULEB128(writer, @as(u32, 0)); // offset | 1008 | try leb.writeUleb128(writer, @as(u32, 0)); // offset |
| 1009 | 1009 | ||
| 1010 | // based on the value from the atomic check, jump to the label. | 1010 | // based on the value from the atomic check, jump to the label. |
| 1011 | try writer.writeByte(std.wasm.opcode(.br_table)); | 1011 | try writer.writeByte(std.wasm.opcode(.br_table)); |
| 1012 | try leb.writeULEB128(writer, @as(u32, 2)); // length of the table (we have 3 blocks but because of the mandatory default the length is 2). | 1012 | try leb.writeUleb128(writer, @as(u32, 2)); // length of the table (we have 3 blocks but because of the mandatory default the length is 2). |
| 1013 | try leb.writeULEB128(writer, @as(u32, 0)); // $init | 1013 | try leb.writeUleb128(writer, @as(u32, 0)); // $init |
| 1014 | try leb.writeULEB128(writer, @as(u32, 1)); // $wait | 1014 | try leb.writeUleb128(writer, @as(u32, 1)); // $wait |
| 1015 | try leb.writeULEB128(writer, @as(u32, 2)); // $drop | 1015 | try leb.writeUleb128(writer, @as(u32, 2)); // $drop |
| 1016 | try writer.writeByte(std.wasm.opcode(.end)); | 1016 | try writer.writeByte(std.wasm.opcode(.end)); |
| 1017 | } | 1017 | } |
| 1018 | 1018 | ||
| ... | @@ -1034,7 +1034,7 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { | ... | @@ -1034,7 +1034,7 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { |
| 1034 | try writeI32Const(writer, segment.offset); | 1034 | try writeI32Const(writer, segment.offset); |
| 1035 | try writer.writeByte(std.wasm.opcode(.global_set)); | 1035 | try writer.writeByte(std.wasm.opcode(.global_set)); |
| 1036 | const loc = wasm.findGlobalSymbol("__tls_base").?; | 1036 | const loc = wasm.findGlobalSymbol("__tls_base").?; |
| 1037 | try leb.writeULEB128(writer, loc.getSymbol(wasm).index); | 1037 | try leb.writeUleb128(writer, loc.getSymbol(wasm).index); |
| 1038 | } | 1038 | } |
| 1039 | 1039 | ||
| 1040 | try writeI32Const(writer, 0); | 1040 | try writeI32Const(writer, 0); |
| ... | @@ -1042,11 +1042,11 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { | ... | @@ -1042,11 +1042,11 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { |
| 1042 | try writer.writeByte(std.wasm.opcode(.misc_prefix)); | 1042 | try writer.writeByte(std.wasm.opcode(.misc_prefix)); |
| 1043 | if (std.mem.eql(u8, entry.key_ptr.*, ".bss")) { | 1043 | if (std.mem.eql(u8, entry.key_ptr.*, ".bss")) { |
| 1044 | // fill bss segment with zeroes | 1044 | // fill bss segment with zeroes |
| 1045 | try leb.writeULEB128(writer, std.wasm.miscOpcode(.memory_fill)); | 1045 | try leb.writeUleb128(writer, std.wasm.miscOpcode(.memory_fill)); |
| 1046 | } else { | 1046 | } else { |
| 1047 | // initialize the segment | 1047 | // initialize the segment |
| 1048 | try leb.writeULEB128(writer, std.wasm.miscOpcode(.memory_init)); | 1048 | try leb.writeUleb128(writer, std.wasm.miscOpcode(.memory_init)); |
| 1049 | try leb.writeULEB128(writer, segment_index); | 1049 | try leb.writeUleb128(writer, segment_index); |
| 1050 | } | 1050 | } |
| 1051 | try writer.writeByte(0); // memory index immediate | 1051 | try writer.writeByte(0); // memory index immediate |
| 1052 | } | 1052 | } |
| ... | @@ -1057,34 +1057,34 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { | ... | @@ -1057,34 +1057,34 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { |
| 1057 | try writeI32Const(writer, flag_address); | 1057 | try writeI32Const(writer, flag_address); |
| 1058 | try writeI32Const(writer, 2); | 1058 | try writeI32Const(writer, 2); |
| 1059 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); | 1059 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); |
| 1060 | try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.i32_atomic_store)); | 1060 | try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.i32_atomic_store)); |
| 1061 | try leb.writeULEB128(writer, @as(u32, 2)); // alignment | 1061 | try leb.writeUleb128(writer, @as(u32, 2)); // alignment |
| 1062 | try leb.writeULEB128(writer, @as(u32, 0)); // offset | 1062 | try leb.writeUleb128(writer, @as(u32, 0)); // offset |
| 1063 | 1063 | ||
| 1064 | // notify any waiters for segment initialization completion | 1064 | // notify any waiters for segment initialization completion |
| 1065 | try writeI32Const(writer, flag_address); | 1065 | try writeI32Const(writer, flag_address); |
| 1066 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 1066 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 1067 | try leb.writeILEB128(writer, @as(i32, -1)); // number of waiters | 1067 | try leb.writeIleb128(writer, @as(i32, -1)); // number of waiters |
| 1068 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); | 1068 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); |
| 1069 | try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.memory_atomic_notify)); | 1069 | try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.memory_atomic_notify)); |
| 1070 | try leb.writeULEB128(writer, @as(u32, 2)); // alignment | 1070 | try leb.writeUleb128(writer, @as(u32, 2)); // alignment |
| 1071 | try leb.writeULEB128(writer, @as(u32, 0)); // offset | 1071 | try leb.writeUleb128(writer, @as(u32, 0)); // offset |
| 1072 | try writer.writeByte(std.wasm.opcode(.drop)); | 1072 | try writer.writeByte(std.wasm.opcode(.drop)); |
| 1073 | 1073 | ||
| 1074 | // branch and drop segments | 1074 | // branch and drop segments |
| 1075 | try writer.writeByte(std.wasm.opcode(.br)); | 1075 | try writer.writeByte(std.wasm.opcode(.br)); |
| 1076 | try leb.writeULEB128(writer, @as(u32, 1)); | 1076 | try leb.writeUleb128(writer, @as(u32, 1)); |
| 1077 | 1077 | ||
| 1078 | // wait for thread to initialize memory segments | 1078 | // wait for thread to initialize memory segments |
| 1079 | try writer.writeByte(std.wasm.opcode(.end)); // end $wait | 1079 | try writer.writeByte(std.wasm.opcode(.end)); // end $wait |
| 1080 | try writeI32Const(writer, flag_address); | 1080 | try writeI32Const(writer, flag_address); |
| 1081 | try writeI32Const(writer, 1); // expected flag value | 1081 | try writeI32Const(writer, 1); // expected flag value |
| 1082 | try writer.writeByte(std.wasm.opcode(.i64_const)); | 1082 | try writer.writeByte(std.wasm.opcode(.i64_const)); |
| 1083 | try leb.writeILEB128(writer, @as(i64, -1)); // timeout | 1083 | try leb.writeIleb128(writer, @as(i64, -1)); // timeout |
| 1084 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); | 1084 | try writer.writeByte(std.wasm.opcode(.atomics_prefix)); |
| 1085 | try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.memory_atomic_wait32)); | 1085 | try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.memory_atomic_wait32)); |
| 1086 | try leb.writeULEB128(writer, @as(u32, 2)); // alignment | 1086 | try leb.writeUleb128(writer, @as(u32, 2)); // alignment |
| 1087 | try leb.writeULEB128(writer, @as(u32, 0)); // offset | 1087 | try leb.writeUleb128(writer, @as(u32, 0)); // offset |
| 1088 | try writer.writeByte(std.wasm.opcode(.drop)); | 1088 | try writer.writeByte(std.wasm.opcode(.drop)); |
| 1089 | 1089 | ||
| 1090 | try writer.writeByte(std.wasm.opcode(.end)); // end $drop | 1090 | try writer.writeByte(std.wasm.opcode(.end)); // end $drop |
| ... | @@ -1105,8 +1105,8 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { | ... | @@ -1105,8 +1105,8 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void { |
| 1105 | } | 1105 | } |
| 1106 | 1106 | ||
| 1107 | try writer.writeByte(std.wasm.opcode(.misc_prefix)); | 1107 | try writer.writeByte(std.wasm.opcode(.misc_prefix)); |
| 1108 | try leb.writeULEB128(writer, std.wasm.miscOpcode(.data_drop)); | 1108 | try leb.writeUleb128(writer, std.wasm.miscOpcode(.data_drop)); |
| 1109 | try leb.writeULEB128(writer, segment_index); | 1109 | try leb.writeUleb128(writer, segment_index); |
| 1110 | } | 1110 | } |
| 1111 | } | 1111 | } |
| 1112 | 1112 | ||
| ... | @@ -1147,18 +1147,18 @@ fn setupTLSRelocationsFunction(wasm: *Wasm) !void { | ... | @@ -1147,18 +1147,18 @@ fn setupTLSRelocationsFunction(wasm: *Wasm) !void { |
| 1147 | if (sym.tag == .data and sym.isDefined()) { | 1147 | if (sym.tag == .data and sym.isDefined()) { |
| 1148 | // get __tls_base | 1148 | // get __tls_base |
| 1149 | try writer.writeByte(std.wasm.opcode(.global_get)); | 1149 | try writer.writeByte(std.wasm.opcode(.global_get)); |
| 1150 | try leb.writeULEB128(writer, wasm.findGlobalSymbol("__tls_base").?.getSymbol(wasm).index); | 1150 | try leb.writeUleb128(writer, wasm.findGlobalSymbol("__tls_base").?.getSymbol(wasm).index); |
| 1151 | 1151 | ||
| 1152 | // add the virtual address of the symbol | 1152 | // add the virtual address of the symbol |
| 1153 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 1153 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 1154 | try leb.writeULEB128(writer, sym.virtual_address); | 1154 | try leb.writeUleb128(writer, sym.virtual_address); |
| 1155 | } else if (sym.tag == .function) { | 1155 | } else if (sym.tag == .function) { |
| 1156 | @panic("TODO: relocate GOT entry of function"); | 1156 | @panic("TODO: relocate GOT entry of function"); |
| 1157 | } else continue; | 1157 | } else continue; |
| 1158 | 1158 | ||
| 1159 | try writer.writeByte(std.wasm.opcode(.i32_add)); | 1159 | try writer.writeByte(std.wasm.opcode(.i32_add)); |
| 1160 | try writer.writeByte(std.wasm.opcode(.global_set)); | 1160 | try writer.writeByte(std.wasm.opcode(.global_set)); |
| 1161 | try leb.writeULEB128(writer, wasm.imported_globals_count + @as(u32, @intCast(wasm.wasm_globals.items.len + got_index))); | 1161 | try leb.writeUleb128(writer, wasm.imported_globals_count + @as(u32, @intCast(wasm.wasm_globals.items.len + got_index))); |
| 1162 | } | 1162 | } |
| 1163 | try writer.writeByte(std.wasm.opcode(.end)); | 1163 | try writer.writeByte(std.wasm.opcode(.end)); |
| 1164 | 1164 | ||
| ... | @@ -1801,7 +1801,7 @@ fn initializeCallCtorsFunction(wasm: *Wasm) !void { | ... | @@ -1801,7 +1801,7 @@ fn initializeCallCtorsFunction(wasm: *Wasm) !void { |
| 1801 | // Create the function body | 1801 | // Create the function body |
| 1802 | { | 1802 | { |
| 1803 | // Write locals count (we have none) | 1803 | // Write locals count (we have none) |
| 1804 | try leb.writeULEB128(writer, @as(u32, 0)); | 1804 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 1805 | 1805 | ||
| 1806 | // call constructors | 1806 | // call constructors |
| 1807 | for (wasm.init_funcs.items) |init_func_loc| { | 1807 | for (wasm.init_funcs.items) |init_func_loc| { |
| ... | @@ -1811,7 +1811,7 @@ fn initializeCallCtorsFunction(wasm: *Wasm) !void { | ... | @@ -1811,7 +1811,7 @@ fn initializeCallCtorsFunction(wasm: *Wasm) !void { |
| 1811 | 1811 | ||
| 1812 | // Call function by its function index | 1812 | // Call function by its function index |
| 1813 | try writer.writeByte(std.wasm.opcode(.call)); | 1813 | try writer.writeByte(std.wasm.opcode(.call)); |
| 1814 | try leb.writeULEB128(writer, symbol.index); | 1814 | try leb.writeUleb128(writer, symbol.index); |
| 1815 | 1815 | ||
| 1816 | // drop all returned values from the stack as __wasm_call_ctors has no return value | 1816 | // drop all returned values from the stack as __wasm_call_ctors has no return value |
| 1817 | for (ty.returns) |_| { | 1817 | for (ty.returns) |_| { |
| ... | @@ -1905,31 +1905,31 @@ fn initializeTLSFunction(wasm: *Wasm) !void { | ... | @@ -1905,31 +1905,31 @@ fn initializeTLSFunction(wasm: *Wasm) !void { |
| 1905 | const param_local: u32 = 0; | 1905 | const param_local: u32 = 0; |
| 1906 | 1906 | ||
| 1907 | try writer.writeByte(std.wasm.opcode(.local_get)); | 1907 | try writer.writeByte(std.wasm.opcode(.local_get)); |
| 1908 | try leb.writeULEB128(writer, param_local); | 1908 | try leb.writeUleb128(writer, param_local); |
| 1909 | 1909 | ||
| 1910 | const tls_base_loc = wasm.findGlobalSymbol("__tls_base").?; | 1910 | const tls_base_loc = wasm.findGlobalSymbol("__tls_base").?; |
| 1911 | try writer.writeByte(std.wasm.opcode(.global_set)); | 1911 | try writer.writeByte(std.wasm.opcode(.global_set)); |
| 1912 | try leb.writeULEB128(writer, tls_base_loc.getSymbol(wasm).index); | 1912 | try leb.writeUleb128(writer, tls_base_loc.getSymbol(wasm).index); |
| 1913 | 1913 | ||
| 1914 | // load stack values for the bulk-memory operation | 1914 | // load stack values for the bulk-memory operation |
| 1915 | { | 1915 | { |
| 1916 | try writer.writeByte(std.wasm.opcode(.local_get)); | 1916 | try writer.writeByte(std.wasm.opcode(.local_get)); |
| 1917 | try leb.writeULEB128(writer, param_local); | 1917 | try leb.writeUleb128(writer, param_local); |
| 1918 | 1918 | ||
| 1919 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 1919 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 1920 | try leb.writeULEB128(writer, @as(u32, 0)); //segment offset | 1920 | try leb.writeUleb128(writer, @as(u32, 0)); //segment offset |
| 1921 | 1921 | ||
| 1922 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 1922 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 1923 | try leb.writeULEB128(writer, @as(u32, segment.size)); //segment offset | 1923 | try leb.writeUleb128(writer, @as(u32, segment.size)); //segment offset |
| 1924 | } | 1924 | } |
| 1925 | 1925 | ||
| 1926 | // perform the bulk-memory operation to initialize the data segment | 1926 | // perform the bulk-memory operation to initialize the data segment |
| 1927 | try writer.writeByte(std.wasm.opcode(.misc_prefix)); | 1927 | try writer.writeByte(std.wasm.opcode(.misc_prefix)); |
| 1928 | try leb.writeULEB128(writer, std.wasm.miscOpcode(.memory_init)); | 1928 | try leb.writeUleb128(writer, std.wasm.miscOpcode(.memory_init)); |
| 1929 | // segment immediate | 1929 | // segment immediate |
| 1930 | try leb.writeULEB128(writer, @as(u32, @intCast(data_index))); | 1930 | try leb.writeUleb128(writer, @as(u32, @intCast(data_index))); |
| 1931 | // memory index immediate (always 0) | 1931 | // memory index immediate (always 0) |
| 1932 | try leb.writeULEB128(writer, @as(u32, 0)); | 1932 | try leb.writeUleb128(writer, @as(u32, 0)); |
| 1933 | } | 1933 | } |
| 1934 | 1934 | ||
| 1935 | // If we have to perform any TLS relocations, call the corresponding function | 1935 | // If we have to perform any TLS relocations, call the corresponding function |
| ... | @@ -1937,7 +1937,7 @@ fn initializeTLSFunction(wasm: *Wasm) !void { | ... | @@ -1937,7 +1937,7 @@ fn initializeTLSFunction(wasm: *Wasm) !void { |
| 1937 | // generated by the linker. | 1937 | // generated by the linker. |
| 1938 | if (wasm.findGlobalSymbol("__wasm_apply_global_tls_relocs")) |loc| { | 1938 | if (wasm.findGlobalSymbol("__wasm_apply_global_tls_relocs")) |loc| { |
| 1939 | try writer.writeByte(std.wasm.opcode(.call)); | 1939 | try writer.writeByte(std.wasm.opcode(.call)); |
| 1940 | try leb.writeULEB128(writer, loc.getSymbol(wasm).index); | 1940 | try leb.writeUleb128(writer, loc.getSymbol(wasm).index); |
| 1941 | loc.getSymbol(wasm).mark(); | 1941 | loc.getSymbol(wasm).mark(); |
| 1942 | } | 1942 | } |
| 1943 | 1943 | ||
| ... | @@ -2642,14 +2642,14 @@ fn writeToFile( | ... | @@ -2642,14 +2642,14 @@ fn writeToFile( |
| 2642 | const header_offset = try reserveVecSectionHeader(&binary_bytes); | 2642 | const header_offset = try reserveVecSectionHeader(&binary_bytes); |
| 2643 | log.debug("Writing type section. Count: ({d})", .{wasm.func_types.items.len}); | 2643 | log.debug("Writing type section. Count: ({d})", .{wasm.func_types.items.len}); |
| 2644 | for (wasm.func_types.items) |func_type| { | 2644 | for (wasm.func_types.items) |func_type| { |
| 2645 | try leb.writeULEB128(binary_writer, std.wasm.function_type); | 2645 | try leb.writeUleb128(binary_writer, std.wasm.function_type); |
| 2646 | try leb.writeULEB128(binary_writer, @as(u32, @intCast(func_type.params.len))); | 2646 | try leb.writeUleb128(binary_writer, @as(u32, @intCast(func_type.params.len))); |
| 2647 | for (func_type.params) |param_ty| { | 2647 | for (func_type.params) |param_ty| { |
| 2648 | try leb.writeULEB128(binary_writer, std.wasm.valtype(param_ty)); | 2648 | try leb.writeUleb128(binary_writer, std.wasm.valtype(param_ty)); |
| 2649 | } | 2649 | } |
| 2650 | try leb.writeULEB128(binary_writer, @as(u32, @intCast(func_type.returns.len))); | 2650 | try leb.writeUleb128(binary_writer, @as(u32, @intCast(func_type.returns.len))); |
| 2651 | for (func_type.returns) |ret_ty| { | 2651 | for (func_type.returns) |ret_ty| { |
| 2652 | try leb.writeULEB128(binary_writer, std.wasm.valtype(ret_ty)); | 2652 | try leb.writeUleb128(binary_writer, std.wasm.valtype(ret_ty)); |
| 2653 | } | 2653 | } |
| 2654 | } | 2654 | } |
| 2655 | 2655 | ||
| ... | @@ -2698,7 +2698,7 @@ fn writeToFile( | ... | @@ -2698,7 +2698,7 @@ fn writeToFile( |
| 2698 | if (wasm.functions.count() != 0) { | 2698 | if (wasm.functions.count() != 0) { |
| 2699 | const header_offset = try reserveVecSectionHeader(&binary_bytes); | 2699 | const header_offset = try reserveVecSectionHeader(&binary_bytes); |
| 2700 | for (wasm.functions.values()) |function| { | 2700 | for (wasm.functions.values()) |function| { |
| 2701 | try leb.writeULEB128(binary_writer, function.func.type_index); | 2701 | try leb.writeUleb128(binary_writer, function.func.type_index); |
| 2702 | } | 2702 | } |
| 2703 | 2703 | ||
| 2704 | try writeVecSectionHeader( | 2704 | try writeVecSectionHeader( |
| ... | @@ -2716,7 +2716,7 @@ fn writeToFile( | ... | @@ -2716,7 +2716,7 @@ fn writeToFile( |
| 2716 | const header_offset = try reserveVecSectionHeader(&binary_bytes); | 2716 | const header_offset = try reserveVecSectionHeader(&binary_bytes); |
| 2717 | 2717 | ||
| 2718 | for (wasm.tables.items) |table| { | 2718 | for (wasm.tables.items) |table| { |
| 2719 | try leb.writeULEB128(binary_writer, std.wasm.reftype(table.reftype)); | 2719 | try leb.writeUleb128(binary_writer, std.wasm.reftype(table.reftype)); |
| 2720 | try emitLimits(binary_writer, table.limits); | 2720 | try emitLimits(binary_writer, table.limits); |
| 2721 | } | 2721 | } |
| 2722 | 2722 | ||
| ... | @@ -2771,17 +2771,17 @@ fn writeToFile( | ... | @@ -2771,17 +2771,17 @@ fn writeToFile( |
| 2771 | 2771 | ||
| 2772 | for (wasm.exports.items) |exp| { | 2772 | for (wasm.exports.items) |exp| { |
| 2773 | const name = wasm.string_table.get(exp.name); | 2773 | const name = wasm.string_table.get(exp.name); |
| 2774 | try leb.writeULEB128(binary_writer, @as(u32, @intCast(name.len))); | 2774 | try leb.writeUleb128(binary_writer, @as(u32, @intCast(name.len))); |
| 2775 | try binary_writer.writeAll(name); | 2775 | try binary_writer.writeAll(name); |
| 2776 | try leb.writeULEB128(binary_writer, @intFromEnum(exp.kind)); | 2776 | try leb.writeUleb128(binary_writer, @intFromEnum(exp.kind)); |
| 2777 | try leb.writeULEB128(binary_writer, exp.index); | 2777 | try leb.writeUleb128(binary_writer, exp.index); |
| 2778 | } | 2778 | } |
| 2779 | 2779 | ||
| 2780 | if (export_memory) { | 2780 | if (export_memory) { |
| 2781 | try leb.writeULEB128(binary_writer, @as(u32, @intCast("memory".len))); | 2781 | try leb.writeUleb128(binary_writer, @as(u32, @intCast("memory".len))); |
| 2782 | try binary_writer.writeAll("memory"); | 2782 | try binary_writer.writeAll("memory"); |
| 2783 | try binary_writer.writeByte(std.wasm.externalKind(.memory)); | 2783 | try binary_writer.writeByte(std.wasm.externalKind(.memory)); |
| 2784 | try leb.writeULEB128(binary_writer, @as(u32, 0)); | 2784 | try leb.writeUleb128(binary_writer, @as(u32, 0)); |
| 2785 | } | 2785 | } |
| 2786 | 2786 | ||
| 2787 | try writeVecSectionHeader( | 2787 | try writeVecSectionHeader( |
| ... | @@ -2813,21 +2813,21 @@ fn writeToFile( | ... | @@ -2813,21 +2813,21 @@ fn writeToFile( |
| 2813 | const table_sym = table_loc.getSymbol(wasm); | 2813 | const table_sym = table_loc.getSymbol(wasm); |
| 2814 | 2814 | ||
| 2815 | const flags: u32 = if (table_sym.index == 0) 0x0 else 0x02; // passive with implicit 0-index table or set table index manually | 2815 | const flags: u32 = if (table_sym.index == 0) 0x0 else 0x02; // passive with implicit 0-index table or set table index manually |
| 2816 | try leb.writeULEB128(binary_writer, flags); | 2816 | try leb.writeUleb128(binary_writer, flags); |
| 2817 | if (flags == 0x02) { | 2817 | if (flags == 0x02) { |
| 2818 | try leb.writeULEB128(binary_writer, table_sym.index); | 2818 | try leb.writeUleb128(binary_writer, table_sym.index); |
| 2819 | } | 2819 | } |
| 2820 | try emitInit(binary_writer, .{ .i32_const = 1 }); // We start at index 1, so unresolved function pointers are invalid | 2820 | try emitInit(binary_writer, .{ .i32_const = 1 }); // We start at index 1, so unresolved function pointers are invalid |
| 2821 | if (flags == 0x02) { | 2821 | if (flags == 0x02) { |
| 2822 | try leb.writeULEB128(binary_writer, @as(u8, 0)); // represents funcref | 2822 | try leb.writeUleb128(binary_writer, @as(u8, 0)); // represents funcref |
| 2823 | } | 2823 | } |
| 2824 | try leb.writeULEB128(binary_writer, @as(u32, @intCast(wasm.function_table.count()))); | 2824 | try leb.writeUleb128(binary_writer, @as(u32, @intCast(wasm.function_table.count()))); |
| 2825 | var symbol_it = wasm.function_table.keyIterator(); | 2825 | var symbol_it = wasm.function_table.keyIterator(); |
| 2826 | while (symbol_it.next()) |symbol_loc_ptr| { | 2826 | while (symbol_it.next()) |symbol_loc_ptr| { |
| 2827 | const sym = symbol_loc_ptr.getSymbol(wasm); | 2827 | const sym = symbol_loc_ptr.getSymbol(wasm); |
| 2828 | std.debug.assert(sym.isAlive()); | 2828 | std.debug.assert(sym.isAlive()); |
| 2829 | std.debug.assert(sym.index < wasm.functions.count() + wasm.imported_functions_count); | 2829 | std.debug.assert(sym.index < wasm.functions.count() + wasm.imported_functions_count); |
| 2830 | try leb.writeULEB128(binary_writer, sym.index); | 2830 | try leb.writeUleb128(binary_writer, sym.index); |
| 2831 | } | 2831 | } |
| 2832 | 2832 | ||
| 2833 | try writeVecSectionHeader( | 2833 | try writeVecSectionHeader( |
| ... | @@ -2868,7 +2868,7 @@ fn writeToFile( | ... | @@ -2868,7 +2868,7 @@ fn writeToFile( |
| 2868 | atom.resolveRelocs(wasm); | 2868 | atom.resolveRelocs(wasm); |
| 2869 | } | 2869 | } |
| 2870 | atom.offset = @intCast(binary_bytes.items.len - start_offset); | 2870 | atom.offset = @intCast(binary_bytes.items.len - start_offset); |
| 2871 | try leb.writeULEB128(binary_writer, atom.size); | 2871 | try leb.writeUleb128(binary_writer, atom.size); |
| 2872 | try binary_writer.writeAll(atom.code.items); | 2872 | try binary_writer.writeAll(atom.code.items); |
| 2873 | } | 2873 | } |
| 2874 | 2874 | ||
| ... | @@ -2899,16 +2899,16 @@ fn writeToFile( | ... | @@ -2899,16 +2899,16 @@ fn writeToFile( |
| 2899 | segment_count += 1; | 2899 | segment_count += 1; |
| 2900 | var atom_index = wasm.atoms.get(segment_index).?; | 2900 | var atom_index = wasm.atoms.get(segment_index).?; |
| 2901 | 2901 | ||
| 2902 | try leb.writeULEB128(binary_writer, segment.flags); | 2902 | try leb.writeUleb128(binary_writer, segment.flags); |
| 2903 | if (segment.flags & @intFromEnum(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) { | 2903 | if (segment.flags & @intFromEnum(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) { |
| 2904 | try leb.writeULEB128(binary_writer, @as(u32, 0)); // memory is always index 0 as we only have 1 memory entry | 2904 | try leb.writeUleb128(binary_writer, @as(u32, 0)); // memory is always index 0 as we only have 1 memory entry |
| 2905 | } | 2905 | } |
| 2906 | // when a segment is passive, it's initialized during runtime. | 2906 | // when a segment is passive, it's initialized during runtime. |
| 2907 | if (!segment.isPassive()) { | 2907 | if (!segment.isPassive()) { |
| 2908 | try emitInit(binary_writer, .{ .i32_const = @as(i32, @bitCast(segment.offset)) }); | 2908 | try emitInit(binary_writer, .{ .i32_const = @as(i32, @bitCast(segment.offset)) }); |
| 2909 | } | 2909 | } |
| 2910 | // offset into data section | 2910 | // offset into data section |
| 2911 | try leb.writeULEB128(binary_writer, segment.size); | 2911 | try leb.writeUleb128(binary_writer, segment.size); |
| 2912 | 2912 | ||
| 2913 | // fill in the offset table and the data segments | 2913 | // fill in the offset table and the data segments |
| 2914 | var current_offset: u32 = 0; | 2914 | var current_offset: u32 = 0; |
| ... | @@ -3058,7 +3058,7 @@ fn emitDebugSection(binary_bytes: *std.ArrayList(u8), data: []const u8, name: [] | ... | @@ -3058,7 +3058,7 @@ fn emitDebugSection(binary_bytes: *std.ArrayList(u8), data: []const u8, name: [] |
| 3058 | if (data.len == 0) return; | 3058 | if (data.len == 0) return; |
| 3059 | const header_offset = try reserveCustomSectionHeader(binary_bytes); | 3059 | const header_offset = try reserveCustomSectionHeader(binary_bytes); |
| 3060 | const writer = binary_bytes.writer(); | 3060 | const writer = binary_bytes.writer(); |
| 3061 | try leb.writeULEB128(writer, @as(u32, @intCast(name.len))); | 3061 | try leb.writeUleb128(writer, @as(u32, @intCast(name.len))); |
| 3062 | try writer.writeAll(name); | 3062 | try writer.writeAll(name); |
| 3063 | 3063 | ||
| 3064 | const start = binary_bytes.items.len - header_offset; | 3064 | const start = binary_bytes.items.len - header_offset; |
| ... | @@ -3077,10 +3077,10 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void { | ... | @@ -3077,10 +3077,10 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void { |
| 3077 | 3077 | ||
| 3078 | const writer = binary_bytes.writer(); | 3078 | const writer = binary_bytes.writer(); |
| 3079 | const producers = "producers"; | 3079 | const producers = "producers"; |
| 3080 | try leb.writeULEB128(writer, @as(u32, @intCast(producers.len))); | 3080 | try leb.writeUleb128(writer, @as(u32, @intCast(producers.len))); |
| 3081 | try writer.writeAll(producers); | 3081 | try writer.writeAll(producers); |
| 3082 | 3082 | ||
| 3083 | try leb.writeULEB128(writer, @as(u32, 2)); // 2 fields: Language + processed-by | 3083 | try leb.writeUleb128(writer, @as(u32, 2)); // 2 fields: Language + processed-by |
| 3084 | 3084 | ||
| 3085 | // used for the Zig version | 3085 | // used for the Zig version |
| 3086 | var version_buf: [100]u8 = undefined; | 3086 | var version_buf: [100]u8 = undefined; |
| ... | @@ -3089,18 +3089,18 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void { | ... | @@ -3089,18 +3089,18 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void { |
| 3089 | // language field | 3089 | // language field |
| 3090 | { | 3090 | { |
| 3091 | const language = "language"; | 3091 | const language = "language"; |
| 3092 | try leb.writeULEB128(writer, @as(u32, @intCast(language.len))); | 3092 | try leb.writeUleb128(writer, @as(u32, @intCast(language.len))); |
| 3093 | try writer.writeAll(language); | 3093 | try writer.writeAll(language); |
| 3094 | 3094 | ||
| 3095 | // field_value_count (TODO: Parse object files for producer sections to detect their language) | 3095 | // field_value_count (TODO: Parse object files for producer sections to detect their language) |
| 3096 | try leb.writeULEB128(writer, @as(u32, 1)); | 3096 | try leb.writeUleb128(writer, @as(u32, 1)); |
| 3097 | 3097 | ||
| 3098 | // versioned name | 3098 | // versioned name |
| 3099 | { | 3099 | { |
| 3100 | try leb.writeULEB128(writer, @as(u32, 3)); // len of "Zig" | 3100 | try leb.writeUleb128(writer, @as(u32, 3)); // len of "Zig" |
| 3101 | try writer.writeAll("Zig"); | 3101 | try writer.writeAll("Zig"); |
| 3102 | 3102 | ||
| 3103 | try leb.writeULEB128(writer, @as(u32, @intCast(version.len))); | 3103 | try leb.writeUleb128(writer, @as(u32, @intCast(version.len))); |
| 3104 | try writer.writeAll(version); | 3104 | try writer.writeAll(version); |
| 3105 | } | 3105 | } |
| 3106 | } | 3106 | } |
| ... | @@ -3108,18 +3108,18 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void { | ... | @@ -3108,18 +3108,18 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void { |
| 3108 | // processed-by field | 3108 | // processed-by field |
| 3109 | { | 3109 | { |
| 3110 | const processed_by = "processed-by"; | 3110 | const processed_by = "processed-by"; |
| 3111 | try leb.writeULEB128(writer, @as(u32, @intCast(processed_by.len))); | 3111 | try leb.writeUleb128(writer, @as(u32, @intCast(processed_by.len))); |
| 3112 | try writer.writeAll(processed_by); | 3112 | try writer.writeAll(processed_by); |
| 3113 | 3113 | ||
| 3114 | // field_value_count (TODO: Parse object files for producer sections to detect other used tools) | 3114 | // field_value_count (TODO: Parse object files for producer sections to detect other used tools) |
| 3115 | try leb.writeULEB128(writer, @as(u32, 1)); | 3115 | try leb.writeUleb128(writer, @as(u32, 1)); |
| 3116 | 3116 | ||
| 3117 | // versioned name | 3117 | // versioned name |
| 3118 | { | 3118 | { |
| 3119 | try leb.writeULEB128(writer, @as(u32, 3)); // len of "Zig" | 3119 | try leb.writeUleb128(writer, @as(u32, 3)); // len of "Zig" |
| 3120 | try writer.writeAll("Zig"); | 3120 | try writer.writeAll("Zig"); |
| 3121 | 3121 | ||
| 3122 | try leb.writeULEB128(writer, @as(u32, @intCast(version.len))); | 3122 | try leb.writeUleb128(writer, @as(u32, @intCast(version.len))); |
| 3123 | try writer.writeAll(version); | 3123 | try writer.writeAll(version); |
| 3124 | } | 3124 | } |
| 3125 | } | 3125 | } |
| ... | @@ -3136,11 +3136,11 @@ fn emitBuildIdSection(binary_bytes: *std.ArrayList(u8), build_id: []const u8) !v | ... | @@ -3136,11 +3136,11 @@ fn emitBuildIdSection(binary_bytes: *std.ArrayList(u8), build_id: []const u8) !v |
| 3136 | 3136 | ||
| 3137 | const writer = binary_bytes.writer(); | 3137 | const writer = binary_bytes.writer(); |
| 3138 | const hdr_build_id = "build_id"; | 3138 | const hdr_build_id = "build_id"; |
| 3139 | try leb.writeULEB128(writer, @as(u32, @intCast(hdr_build_id.len))); | 3139 | try leb.writeUleb128(writer, @as(u32, @intCast(hdr_build_id.len))); |
| 3140 | try writer.writeAll(hdr_build_id); | 3140 | try writer.writeAll(hdr_build_id); |
| 3141 | 3141 | ||
| 3142 | try leb.writeULEB128(writer, @as(u32, 1)); | 3142 | try leb.writeUleb128(writer, @as(u32, 1)); |
| 3143 | try leb.writeULEB128(writer, @as(u32, @intCast(build_id.len))); | 3143 | try leb.writeUleb128(writer, @as(u32, @intCast(build_id.len))); |
| 3144 | try writer.writeAll(build_id); | 3144 | try writer.writeAll(build_id); |
| 3145 | 3145 | ||
| 3146 | try writeCustomSectionHeader( | 3146 | try writeCustomSectionHeader( |
| ... | @@ -3155,17 +3155,17 @@ fn emitFeaturesSection(binary_bytes: *std.ArrayList(u8), enabled_features: []con | ... | @@ -3155,17 +3155,17 @@ fn emitFeaturesSection(binary_bytes: *std.ArrayList(u8), enabled_features: []con |
| 3155 | 3155 | ||
| 3156 | const writer = binary_bytes.writer(); | 3156 | const writer = binary_bytes.writer(); |
| 3157 | const target_features = "target_features"; | 3157 | const target_features = "target_features"; |
| 3158 | try leb.writeULEB128(writer, @as(u32, @intCast(target_features.len))); | 3158 | try leb.writeUleb128(writer, @as(u32, @intCast(target_features.len))); |
| 3159 | try writer.writeAll(target_features); | 3159 | try writer.writeAll(target_features); |
| 3160 | 3160 | ||
| 3161 | try leb.writeULEB128(writer, features_count); | 3161 | try leb.writeUleb128(writer, features_count); |
| 3162 | for (enabled_features, 0..) |enabled, feature_index| { | 3162 | for (enabled_features, 0..) |enabled, feature_index| { |
| 3163 | if (enabled) { | 3163 | if (enabled) { |
| 3164 | const feature: types.Feature = .{ .prefix = .used, .tag = @as(types.Feature.Tag, @enumFromInt(feature_index)) }; | 3164 | const feature: types.Feature = .{ .prefix = .used, .tag = @as(types.Feature.Tag, @enumFromInt(feature_index)) }; |
| 3165 | try leb.writeULEB128(writer, @intFromEnum(feature.prefix)); | 3165 | try leb.writeUleb128(writer, @intFromEnum(feature.prefix)); |
| 3166 | var buf: [100]u8 = undefined; | 3166 | var buf: [100]u8 = undefined; |
| 3167 | const string = try std.fmt.bufPrint(&buf, "{}", .{feature.tag}); | 3167 | const string = try std.fmt.bufPrint(&buf, "{}", .{feature.tag}); |
| 3168 | try leb.writeULEB128(writer, @as(u32, @intCast(string.len))); | 3168 | try leb.writeUleb128(writer, @as(u32, @intCast(string.len))); |
| 3169 | try writer.writeAll(string); | 3169 | try writer.writeAll(string); |
| 3170 | } | 3170 | } |
| 3171 | } | 3171 | } |
| ... | @@ -3228,7 +3228,7 @@ fn emitNameSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), arena: std.mem | ... | @@ -3228,7 +3228,7 @@ fn emitNameSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), arena: std.mem |
| 3228 | 3228 | ||
| 3229 | const header_offset = try reserveCustomSectionHeader(binary_bytes); | 3229 | const header_offset = try reserveCustomSectionHeader(binary_bytes); |
| 3230 | const writer = binary_bytes.writer(); | 3230 | const writer = binary_bytes.writer(); |
| 3231 | try leb.writeULEB128(writer, @as(u32, @intCast("name".len))); | 3231 | try leb.writeUleb128(writer, @as(u32, @intCast("name".len))); |
| 3232 | try writer.writeAll("name"); | 3232 | try writer.writeAll("name"); |
| 3233 | 3233 | ||
| 3234 | try wasm.emitNameSubsection(.function, funcs.values(), writer); | 3234 | try wasm.emitNameSubsection(.function, funcs.values(), writer); |
| ... | @@ -3250,25 +3250,25 @@ fn emitNameSubsection(wasm: *Wasm, section_id: std.wasm.NameSubsection, names: a | ... | @@ -3250,25 +3250,25 @@ fn emitNameSubsection(wasm: *Wasm, section_id: std.wasm.NameSubsection, names: a |
| 3250 | defer section_list.deinit(); | 3250 | defer section_list.deinit(); |
| 3251 | const sub_writer = section_list.writer(); | 3251 | const sub_writer = section_list.writer(); |
| 3252 | 3252 | ||
| 3253 | try leb.writeULEB128(sub_writer, @as(u32, @intCast(names.len))); | 3253 | try leb.writeUleb128(sub_writer, @as(u32, @intCast(names.len))); |
| 3254 | for (names) |name| { | 3254 | for (names) |name| { |
| 3255 | log.debug("Emit symbol '{s}' type({s})", .{ name.name, @tagName(section_id) }); | 3255 | log.debug("Emit symbol '{s}' type({s})", .{ name.name, @tagName(section_id) }); |
| 3256 | try leb.writeULEB128(sub_writer, name.index); | 3256 | try leb.writeUleb128(sub_writer, name.index); |
| 3257 | try leb.writeULEB128(sub_writer, @as(u32, @intCast(name.name.len))); | 3257 | try leb.writeUleb128(sub_writer, @as(u32, @intCast(name.name.len))); |
| 3258 | try sub_writer.writeAll(name.name); | 3258 | try sub_writer.writeAll(name.name); |
| 3259 | } | 3259 | } |
| 3260 | 3260 | ||
| 3261 | // From now, write to the actual writer | 3261 | // From now, write to the actual writer |
| 3262 | try leb.writeULEB128(writer, @intFromEnum(section_id)); | 3262 | try leb.writeUleb128(writer, @intFromEnum(section_id)); |
| 3263 | try leb.writeULEB128(writer, @as(u32, @intCast(section_list.items.len))); | 3263 | try leb.writeUleb128(writer, @as(u32, @intCast(section_list.items.len))); |
| 3264 | try writer.writeAll(section_list.items); | 3264 | try writer.writeAll(section_list.items); |
| 3265 | } | 3265 | } |
| 3266 | 3266 | ||
| 3267 | fn emitLimits(writer: anytype, limits: std.wasm.Limits) !void { | 3267 | fn emitLimits(writer: anytype, limits: std.wasm.Limits) !void { |
| 3268 | try writer.writeByte(limits.flags); | 3268 | try writer.writeByte(limits.flags); |
| 3269 | try leb.writeULEB128(writer, limits.min); | 3269 | try leb.writeUleb128(writer, limits.min); |
| 3270 | if (limits.hasFlag(.WASM_LIMITS_FLAG_HAS_MAX)) { | 3270 | if (limits.hasFlag(.WASM_LIMITS_FLAG_HAS_MAX)) { |
| 3271 | try leb.writeULEB128(writer, limits.max); | 3271 | try leb.writeUleb128(writer, limits.max); |
| 3272 | } | 3272 | } |
| 3273 | } | 3273 | } |
| 3274 | 3274 | ||
| ... | @@ -3276,11 +3276,11 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void { | ... | @@ -3276,11 +3276,11 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void { |
| 3276 | switch (init_expr) { | 3276 | switch (init_expr) { |
| 3277 | .i32_const => |val| { | 3277 | .i32_const => |val| { |
| 3278 | try writer.writeByte(std.wasm.opcode(.i32_const)); | 3278 | try writer.writeByte(std.wasm.opcode(.i32_const)); |
| 3279 | try leb.writeILEB128(writer, val); | 3279 | try leb.writeIleb128(writer, val); |
| 3280 | }, | 3280 | }, |
| 3281 | .i64_const => |val| { | 3281 | .i64_const => |val| { |
| 3282 | try writer.writeByte(std.wasm.opcode(.i64_const)); | 3282 | try writer.writeByte(std.wasm.opcode(.i64_const)); |
| 3283 | try leb.writeILEB128(writer, val); | 3283 | try leb.writeIleb128(writer, val); |
| 3284 | }, | 3284 | }, |
| 3285 | .f32_const => |val| { | 3285 | .f32_const => |val| { |
| 3286 | try writer.writeByte(std.wasm.opcode(.f32_const)); | 3286 | try writer.writeByte(std.wasm.opcode(.f32_const)); |
| ... | @@ -3292,7 +3292,7 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void { | ... | @@ -3292,7 +3292,7 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void { |
| 3292 | }, | 3292 | }, |
| 3293 | .global_get => |val| { | 3293 | .global_get => |val| { |
| 3294 | try writer.writeByte(std.wasm.opcode(.global_get)); | 3294 | try writer.writeByte(std.wasm.opcode(.global_get)); |
| 3295 | try leb.writeULEB128(writer, val); | 3295 | try leb.writeUleb128(writer, val); |
| 3296 | }, | 3296 | }, |
| 3297 | } | 3297 | } |
| 3298 | try writer.writeByte(std.wasm.opcode(.end)); | 3298 | try writer.writeByte(std.wasm.opcode(.end)); |
| ... | @@ -3300,22 +3300,22 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void { | ... | @@ -3300,22 +3300,22 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void { |
| 3300 | 3300 | ||
| 3301 | fn emitImport(wasm: *Wasm, writer: anytype, import: types.Import) !void { | 3301 | fn emitImport(wasm: *Wasm, writer: anytype, import: types.Import) !void { |
| 3302 | const module_name = wasm.string_table.get(import.module_name); | 3302 | const module_name = wasm.string_table.get(import.module_name); |
| 3303 | try leb.writeULEB128(writer, @as(u32, @intCast(module_name.len))); | 3303 | try leb.writeUleb128(writer, @as(u32, @intCast(module_name.len))); |
| 3304 | try writer.writeAll(module_name); | 3304 | try writer.writeAll(module_name); |
| 3305 | 3305 | ||
| 3306 | const name = wasm.string_table.get(import.name); | 3306 | const name = wasm.string_table.get(import.name); |
| 3307 | try leb.writeULEB128(writer, @as(u32, @intCast(name.len))); | 3307 | try leb.writeUleb128(writer, @as(u32, @intCast(name.len))); |
| 3308 | try writer.writeAll(name); | 3308 | try writer.writeAll(name); |
| 3309 | 3309 | ||
| 3310 | try writer.writeByte(@intFromEnum(import.kind)); | 3310 | try writer.writeByte(@intFromEnum(import.kind)); |
| 3311 | switch (import.kind) { | 3311 | switch (import.kind) { |
| 3312 | .function => |type_index| try leb.writeULEB128(writer, type_index), | 3312 | .function => |type_index| try leb.writeUleb128(writer, type_index), |
| 3313 | .global => |global_type| { | 3313 | .global => |global_type| { |
| 3314 | try leb.writeULEB128(writer, std.wasm.valtype(global_type.valtype)); | 3314 | try leb.writeUleb128(writer, std.wasm.valtype(global_type.valtype)); |
| 3315 | try writer.writeByte(@intFromBool(global_type.mutable)); | 3315 | try writer.writeByte(@intFromBool(global_type.mutable)); |
| 3316 | }, | 3316 | }, |
| 3317 | .table => |table| { | 3317 | .table => |table| { |
| 3318 | try leb.writeULEB128(writer, std.wasm.reftype(table.reftype)); | 3318 | try leb.writeUleb128(writer, std.wasm.reftype(table.reftype)); |
| 3319 | try emitLimits(writer, table.limits); | 3319 | try emitLimits(writer, table.limits); |
| 3320 | }, | 3320 | }, |
| 3321 | .memory => |limits| { | 3321 | .memory => |limits| { |
| ... | @@ -3767,11 +3767,11 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: | ... | @@ -3767,11 +3767,11 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: |
| 3767 | const writer = binary_bytes.writer(); | 3767 | const writer = binary_bytes.writer(); |
| 3768 | // emit "linking" custom section name | 3768 | // emit "linking" custom section name |
| 3769 | const section_name = "linking"; | 3769 | const section_name = "linking"; |
| 3770 | try leb.writeULEB128(writer, section_name.len); | 3770 | try leb.writeUleb128(writer, section_name.len); |
| 3771 | try writer.writeAll(section_name); | 3771 | try writer.writeAll(section_name); |
| 3772 | 3772 | ||
| 3773 | // meta data version, which is currently '2' | 3773 | // meta data version, which is currently '2' |
| 3774 | try leb.writeULEB128(writer, @as(u32, 2)); | 3774 | try leb.writeUleb128(writer, @as(u32, 2)); |
| 3775 | 3775 | ||
| 3776 | // For each subsection type (found in types.Subsection) we can emit a section. | 3776 | // For each subsection type (found in types.Subsection) we can emit a section. |
| 3777 | // Currently, we only support emitting segment info and the symbol table. | 3777 | // Currently, we only support emitting segment info and the symbol table. |
| ... | @@ -3785,7 +3785,7 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: | ... | @@ -3785,7 +3785,7 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: |
| 3785 | fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: *std.AutoArrayHashMap(SymbolLoc, u32)) !void { | 3785 | fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: *std.AutoArrayHashMap(SymbolLoc, u32)) !void { |
| 3786 | const writer = binary_bytes.writer(); | 3786 | const writer = binary_bytes.writer(); |
| 3787 | 3787 | ||
| 3788 | try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SYMBOL_TABLE)); | 3788 | try leb.writeUleb128(writer, @intFromEnum(types.SubsectionType.WASM_SYMBOL_TABLE)); |
| 3789 | const table_offset = binary_bytes.items.len; | 3789 | const table_offset = binary_bytes.items.len; |
| 3790 | 3790 | ||
| 3791 | var symbol_count: u32 = 0; | 3791 | var symbol_count: u32 = 0; |
| ... | @@ -3795,30 +3795,30 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: | ... | @@ -3795,30 +3795,30 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: |
| 3795 | try symbol_table.putNoClobber(sym_loc, symbol_count); | 3795 | try symbol_table.putNoClobber(sym_loc, symbol_count); |
| 3796 | symbol_count += 1; | 3796 | symbol_count += 1; |
| 3797 | log.debug("Emit symbol: {}", .{symbol}); | 3797 | log.debug("Emit symbol: {}", .{symbol}); |
| 3798 | try leb.writeULEB128(writer, @intFromEnum(symbol.tag)); | 3798 | try leb.writeUleb128(writer, @intFromEnum(symbol.tag)); |
| 3799 | try leb.writeULEB128(writer, symbol.flags); | 3799 | try leb.writeUleb128(writer, symbol.flags); |
| 3800 | 3800 | ||
| 3801 | const sym_name = sym_loc.getName(wasm); | 3801 | const sym_name = sym_loc.getName(wasm); |
| 3802 | switch (symbol.tag) { | 3802 | switch (symbol.tag) { |
| 3803 | .data => { | 3803 | .data => { |
| 3804 | try leb.writeULEB128(writer, @as(u32, @intCast(sym_name.len))); | 3804 | try leb.writeUleb128(writer, @as(u32, @intCast(sym_name.len))); |
| 3805 | try writer.writeAll(sym_name); | 3805 | try writer.writeAll(sym_name); |
| 3806 | 3806 | ||
| 3807 | if (symbol.isDefined()) { | 3807 | if (symbol.isDefined()) { |
| 3808 | try leb.writeULEB128(writer, symbol.index); | 3808 | try leb.writeUleb128(writer, symbol.index); |
| 3809 | const atom_index = wasm.symbol_atom.get(sym_loc).?; | 3809 | const atom_index = wasm.symbol_atom.get(sym_loc).?; |
| 3810 | const atom = wasm.getAtom(atom_index); | 3810 | const atom = wasm.getAtom(atom_index); |
| 3811 | try leb.writeULEB128(writer, @as(u32, atom.offset)); | 3811 | try leb.writeUleb128(writer, @as(u32, atom.offset)); |
| 3812 | try leb.writeULEB128(writer, @as(u32, atom.size)); | 3812 | try leb.writeUleb128(writer, @as(u32, atom.size)); |
| 3813 | } | 3813 | } |
| 3814 | }, | 3814 | }, |
| 3815 | .section => { | 3815 | .section => { |
| 3816 | try leb.writeULEB128(writer, symbol.index); | 3816 | try leb.writeUleb128(writer, symbol.index); |
| 3817 | }, | 3817 | }, |
| 3818 | else => { | 3818 | else => { |
| 3819 | try leb.writeULEB128(writer, symbol.index); | 3819 | try leb.writeUleb128(writer, symbol.index); |
| 3820 | if (symbol.isDefined()) { | 3820 | if (symbol.isDefined()) { |
| 3821 | try leb.writeULEB128(writer, @as(u32, @intCast(sym_name.len))); | 3821 | try leb.writeUleb128(writer, @as(u32, @intCast(sym_name.len))); |
| 3822 | try writer.writeAll(sym_name); | 3822 | try writer.writeAll(sym_name); |
| 3823 | } | 3823 | } |
| 3824 | }, | 3824 | }, |
| ... | @@ -3833,20 +3833,20 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: | ... | @@ -3833,20 +3833,20 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: |
| 3833 | 3833 | ||
| 3834 | fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void { | 3834 | fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void { |
| 3835 | const writer = binary_bytes.writer(); | 3835 | const writer = binary_bytes.writer(); |
| 3836 | try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SEGMENT_INFO)); | 3836 | try leb.writeUleb128(writer, @intFromEnum(types.SubsectionType.WASM_SEGMENT_INFO)); |
| 3837 | const segment_offset = binary_bytes.items.len; | 3837 | const segment_offset = binary_bytes.items.len; |
| 3838 | 3838 | ||
| 3839 | try leb.writeULEB128(writer, @as(u32, @intCast(wasm.segment_info.count()))); | 3839 | try leb.writeUleb128(writer, @as(u32, @intCast(wasm.segment_info.count()))); |
| 3840 | for (wasm.segment_info.values()) |segment_info| { | 3840 | for (wasm.segment_info.values()) |segment_info| { |
| 3841 | log.debug("Emit segment: {s} align({d}) flags({b})", .{ | 3841 | log.debug("Emit segment: {s} align({d}) flags({b})", .{ |
| 3842 | segment_info.name, | 3842 | segment_info.name, |
| 3843 | segment_info.alignment, | 3843 | segment_info.alignment, |
| 3844 | segment_info.flags, | 3844 | segment_info.flags, |
| 3845 | }); | 3845 | }); |
| 3846 | try leb.writeULEB128(writer, @as(u32, @intCast(segment_info.name.len))); | 3846 | try leb.writeUleb128(writer, @as(u32, @intCast(segment_info.name.len))); |
| 3847 | try writer.writeAll(segment_info.name); | 3847 | try writer.writeAll(segment_info.name); |
| 3848 | try leb.writeULEB128(writer, segment_info.alignment.toLog2Units()); | 3848 | try leb.writeUleb128(writer, segment_info.alignment.toLog2Units()); |
| 3849 | try leb.writeULEB128(writer, segment_info.flags); | 3849 | try leb.writeUleb128(writer, segment_info.flags); |
| 3850 | } | 3850 | } |
| 3851 | 3851 | ||
| 3852 | var buf: [5]u8 = undefined; | 3852 | var buf: [5]u8 = undefined; |
| ... | @@ -3854,7 +3854,7 @@ fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void { | ... | @@ -3854,7 +3854,7 @@ fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void { |
| 3854 | try binary_bytes.insertSlice(segment_offset, &buf); | 3854 | try binary_bytes.insertSlice(segment_offset, &buf); |
| 3855 | } | 3855 | } |
| 3856 | 3856 | ||
| 3857 | pub fn getULEB128Size(uint_value: anytype) u32 { | 3857 | pub fn getUleb128Size(uint_value: anytype) u32 { |
| 3858 | const T = @TypeOf(uint_value); | 3858 | const T = @TypeOf(uint_value); |
| 3859 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; | 3859 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; |
| 3860 | var value = @as(U, @intCast(uint_value)); | 3860 | var value = @as(U, @intCast(uint_value)); |
| ... | @@ -3879,9 +3879,9 @@ fn emitCodeRelocations( | ... | @@ -3879,9 +3879,9 @@ fn emitCodeRelocations( |
| 3879 | 3879 | ||
| 3880 | // write custom section information | 3880 | // write custom section information |
| 3881 | const name = "reloc.CODE"; | 3881 | const name = "reloc.CODE"; |
| 3882 | try leb.writeULEB128(writer, @as(u32, @intCast(name.len))); | 3882 | try leb.writeUleb128(writer, @as(u32, @intCast(name.len))); |
| 3883 | try writer.writeAll(name); | 3883 | try writer.writeAll(name); |
| 3884 | try leb.writeULEB128(writer, section_index); | 3884 | try leb.writeUleb128(writer, section_index); |
| 3885 | const reloc_start = binary_bytes.items.len; | 3885 | const reloc_start = binary_bytes.items.len; |
| 3886 | 3886 | ||
| 3887 | var count: u32 = 0; | 3887 | var count: u32 = 0; |
| ... | @@ -3889,17 +3889,17 @@ fn emitCodeRelocations( | ... | @@ -3889,17 +3889,17 @@ fn emitCodeRelocations( |
| 3889 | // for each atom, we calculate the uleb size and append that | 3889 | // for each atom, we calculate the uleb size and append that |
| 3890 | var size_offset: u32 = 5; // account for code section size leb128 | 3890 | var size_offset: u32 = 5; // account for code section size leb128 |
| 3891 | while (true) { | 3891 | while (true) { |
| 3892 | size_offset += getULEB128Size(atom.size); | 3892 | size_offset += getUleb128Size(atom.size); |
| 3893 | for (atom.relocs.items) |relocation| { | 3893 | for (atom.relocs.items) |relocation| { |
| 3894 | count += 1; | 3894 | count += 1; |
| 3895 | const sym_loc: SymbolLoc = .{ .file = atom.file, .index = @enumFromInt(relocation.index) }; | 3895 | const sym_loc: SymbolLoc = .{ .file = atom.file, .index = @enumFromInt(relocation.index) }; |
| 3896 | const symbol_index = symbol_table.get(sym_loc).?; | 3896 | const symbol_index = symbol_table.get(sym_loc).?; |
| 3897 | try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type)); | 3897 | try leb.writeUleb128(writer, @intFromEnum(relocation.relocation_type)); |
| 3898 | const offset = atom.offset + relocation.offset + size_offset; | 3898 | const offset = atom.offset + relocation.offset + size_offset; |
| 3899 | try leb.writeULEB128(writer, offset); | 3899 | try leb.writeUleb128(writer, offset); |
| 3900 | try leb.writeULEB128(writer, symbol_index); | 3900 | try leb.writeUleb128(writer, symbol_index); |
| 3901 | if (relocation.relocation_type.addendIsPresent()) { | 3901 | if (relocation.relocation_type.addendIsPresent()) { |
| 3902 | try leb.writeILEB128(writer, relocation.addend); | 3902 | try leb.writeIleb128(writer, relocation.addend); |
| 3903 | } | 3903 | } |
| 3904 | log.debug("Emit relocation: {}", .{relocation}); | 3904 | log.debug("Emit relocation: {}", .{relocation}); |
| 3905 | } | 3905 | } |
| ... | @@ -3926,9 +3926,9 @@ fn emitDataRelocations( | ... | @@ -3926,9 +3926,9 @@ fn emitDataRelocations( |
| 3926 | 3926 | ||
| 3927 | // write custom section information | 3927 | // write custom section information |
| 3928 | const name = "reloc.DATA"; | 3928 | const name = "reloc.DATA"; |
| 3929 | try leb.writeULEB128(writer, @as(u32, @intCast(name.len))); | 3929 | try leb.writeUleb128(writer, @as(u32, @intCast(name.len))); |
| 3930 | try writer.writeAll(name); | 3930 | try writer.writeAll(name); |
| 3931 | try leb.writeULEB128(writer, section_index); | 3931 | try leb.writeUleb128(writer, section_index); |
| 3932 | const reloc_start = binary_bytes.items.len; | 3932 | const reloc_start = binary_bytes.items.len; |
| 3933 | 3933 | ||
| 3934 | var count: u32 = 0; | 3934 | var count: u32 = 0; |
| ... | @@ -3937,17 +3937,17 @@ fn emitDataRelocations( | ... | @@ -3937,17 +3937,17 @@ fn emitDataRelocations( |
| 3937 | for (wasm.data_segments.values()) |segment_index| { | 3937 | for (wasm.data_segments.values()) |segment_index| { |
| 3938 | var atom: *Atom = wasm.getAtomPtr(wasm.atoms.get(segment_index).?); | 3938 | var atom: *Atom = wasm.getAtomPtr(wasm.atoms.get(segment_index).?); |
| 3939 | while (true) { | 3939 | while (true) { |
| 3940 | size_offset += getULEB128Size(atom.size); | 3940 | size_offset += getUleb128Size(atom.size); |
| 3941 | for (atom.relocs.items) |relocation| { | 3941 | for (atom.relocs.items) |relocation| { |
| 3942 | count += 1; | 3942 | count += 1; |
| 3943 | const sym_loc: SymbolLoc = .{ .file = atom.file, .index = @enumFromInt(relocation.index) }; | 3943 | const sym_loc: SymbolLoc = .{ .file = atom.file, .index = @enumFromInt(relocation.index) }; |
| 3944 | const symbol_index = symbol_table.get(sym_loc).?; | 3944 | const symbol_index = symbol_table.get(sym_loc).?; |
| 3945 | try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type)); | 3945 | try leb.writeUleb128(writer, @intFromEnum(relocation.relocation_type)); |
| 3946 | const offset = atom.offset + relocation.offset + size_offset; | 3946 | const offset = atom.offset + relocation.offset + size_offset; |
| 3947 | try leb.writeULEB128(writer, offset); | 3947 | try leb.writeUleb128(writer, offset); |
| 3948 | try leb.writeULEB128(writer, symbol_index); | 3948 | try leb.writeUleb128(writer, symbol_index); |
| 3949 | if (relocation.relocation_type.addendIsPresent()) { | 3949 | if (relocation.relocation_type.addendIsPresent()) { |
| 3950 | try leb.writeILEB128(writer, relocation.addend); | 3950 | try leb.writeIleb128(writer, relocation.addend); |
| 3951 | } | 3951 | } |
| 3952 | log.debug("Emit relocation: {}", .{relocation}); | 3952 | log.debug("Emit relocation: {}", .{relocation}); |
| 3953 | } | 3953 | } |
src/link/Wasm/Object.zig+32-32| ... | @@ -590,7 +590,7 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -590,7 +590,7 @@ fn Parser(comptime ReaderType: type) type { |
| 590 | const reader = parser.reader.reader(); | 590 | const reader = parser.reader.reader(); |
| 591 | for (try readVec(&parser.object.features, reader, gpa)) |*feature| { | 591 | for (try readVec(&parser.object.features, reader, gpa)) |*feature| { |
| 592 | const prefix = try readEnum(types.Feature.Prefix, reader); | 592 | const prefix = try readEnum(types.Feature.Prefix, reader); |
| 593 | const name_len = try leb.readULEB128(u32, reader); | 593 | const name_len = try leb.readUleb128(u32, reader); |
| 594 | const name = try gpa.alloc(u8, name_len); | 594 | const name = try gpa.alloc(u8, name_len); |
| 595 | defer gpa.free(name); | 595 | defer gpa.free(name); |
| 596 | try reader.readNoEof(name); | 596 | try reader.readNoEof(name); |
| ... | @@ -613,8 +613,8 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -613,8 +613,8 @@ fn Parser(comptime ReaderType: type) type { |
| 613 | /// they apply to. | 613 | /// they apply to. |
| 614 | fn parseRelocations(parser: *ObjectParser, gpa: Allocator) !void { | 614 | fn parseRelocations(parser: *ObjectParser, gpa: Allocator) !void { |
| 615 | const reader = parser.reader.reader(); | 615 | const reader = parser.reader.reader(); |
| 616 | const section = try leb.readULEB128(u32, reader); | 616 | const section = try leb.readUleb128(u32, reader); |
| 617 | const count = try leb.readULEB128(u32, reader); | 617 | const count = try leb.readUleb128(u32, reader); |
| 618 | const relocations = try gpa.alloc(types.Relocation, count); | 618 | const relocations = try gpa.alloc(types.Relocation, count); |
| 619 | errdefer gpa.free(relocations); | 619 | errdefer gpa.free(relocations); |
| 620 | 620 | ||
| ... | @@ -628,9 +628,9 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -628,9 +628,9 @@ fn Parser(comptime ReaderType: type) type { |
| 628 | const rel_type_enum = std.meta.intToEnum(types.Relocation.RelocationType, rel_type) catch return error.MalformedSection; | 628 | const rel_type_enum = std.meta.intToEnum(types.Relocation.RelocationType, rel_type) catch return error.MalformedSection; |
| 629 | relocation.* = .{ | 629 | relocation.* = .{ |
| 630 | .relocation_type = rel_type_enum, | 630 | .relocation_type = rel_type_enum, |
| 631 | .offset = try leb.readULEB128(u32, reader), | 631 | .offset = try leb.readUleb128(u32, reader), |
| 632 | .index = try leb.readULEB128(u32, reader), | 632 | .index = try leb.readUleb128(u32, reader), |
| 633 | .addend = if (rel_type_enum.addendIsPresent()) try leb.readILEB128(i32, reader) else 0, | 633 | .addend = if (rel_type_enum.addendIsPresent()) try leb.readIleb128(i32, reader) else 0, |
| 634 | }; | 634 | }; |
| 635 | log.debug("Found relocation: type({s}) offset({d}) index({d}) addend({?d})", .{ | 635 | log.debug("Found relocation: type({s}) offset({d}) index({d}) addend({?d})", .{ |
| 636 | @tagName(relocation.relocation_type), | 636 | @tagName(relocation.relocation_type), |
| ... | @@ -651,7 +651,7 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -651,7 +651,7 @@ fn Parser(comptime ReaderType: type) type { |
| 651 | var limited = std.io.limitedReader(parser.reader.reader(), payload_size); | 651 | var limited = std.io.limitedReader(parser.reader.reader(), payload_size); |
| 652 | const limited_reader = limited.reader(); | 652 | const limited_reader = limited.reader(); |
| 653 | 653 | ||
| 654 | const version = try leb.readULEB128(u32, limited_reader); | 654 | const version = try leb.readUleb128(u32, limited_reader); |
| 655 | log.debug("Link meta data version: {d}", .{version}); | 655 | log.debug("Link meta data version: {d}", .{version}); |
| 656 | if (version != 2) return error.UnsupportedVersion; | 656 | if (version != 2) return error.UnsupportedVersion; |
| 657 | 657 | ||
| ... | @@ -667,30 +667,30 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -667,30 +667,30 @@ fn Parser(comptime ReaderType: type) type { |
| 667 | /// `parser` is used to provide access to other sections that may be needed, | 667 | /// `parser` is used to provide access to other sections that may be needed, |
| 668 | /// such as access to the `import` section to find the name of a symbol. | 668 | /// such as access to the `import` section to find the name of a symbol. |
| 669 | fn parseSubsection(parser: *ObjectParser, gpa: Allocator, reader: anytype) !void { | 669 | fn parseSubsection(parser: *ObjectParser, gpa: Allocator, reader: anytype) !void { |
| 670 | const sub_type = try leb.readULEB128(u8, reader); | 670 | const sub_type = try leb.readUleb128(u8, reader); |
| 671 | log.debug("Found subsection: {s}", .{@tagName(@as(types.SubsectionType, @enumFromInt(sub_type)))}); | 671 | log.debug("Found subsection: {s}", .{@tagName(@as(types.SubsectionType, @enumFromInt(sub_type)))}); |
| 672 | const payload_len = try leb.readULEB128(u32, reader); | 672 | const payload_len = try leb.readUleb128(u32, reader); |
| 673 | if (payload_len == 0) return; | 673 | if (payload_len == 0) return; |
| 674 | 674 | ||
| 675 | var limited = std.io.limitedReader(reader, payload_len); | 675 | var limited = std.io.limitedReader(reader, payload_len); |
| 676 | const limited_reader = limited.reader(); | 676 | const limited_reader = limited.reader(); |
| 677 | 677 | ||
| 678 | // every subsection contains a 'count' field | 678 | // every subsection contains a 'count' field |
| 679 | const count = try leb.readULEB128(u32, limited_reader); | 679 | const count = try leb.readUleb128(u32, limited_reader); |
| 680 | 680 | ||
| 681 | switch (@as(types.SubsectionType, @enumFromInt(sub_type))) { | 681 | switch (@as(types.SubsectionType, @enumFromInt(sub_type))) { |
| 682 | .WASM_SEGMENT_INFO => { | 682 | .WASM_SEGMENT_INFO => { |
| 683 | const segments = try gpa.alloc(types.Segment, count); | 683 | const segments = try gpa.alloc(types.Segment, count); |
| 684 | errdefer gpa.free(segments); | 684 | errdefer gpa.free(segments); |
| 685 | for (segments) |*segment| { | 685 | for (segments) |*segment| { |
| 686 | const name_len = try leb.readULEB128(u32, reader); | 686 | const name_len = try leb.readUleb128(u32, reader); |
| 687 | const name = try gpa.alloc(u8, name_len); | 687 | const name = try gpa.alloc(u8, name_len); |
| 688 | errdefer gpa.free(name); | 688 | errdefer gpa.free(name); |
| 689 | try reader.readNoEof(name); | 689 | try reader.readNoEof(name); |
| 690 | segment.* = .{ | 690 | segment.* = .{ |
| 691 | .name = name, | 691 | .name = name, |
| 692 | .alignment = @enumFromInt(try leb.readULEB128(u32, reader)), | 692 | .alignment = @enumFromInt(try leb.readUleb128(u32, reader)), |
| 693 | .flags = try leb.readULEB128(u32, reader), | 693 | .flags = try leb.readUleb128(u32, reader), |
| 694 | }; | 694 | }; |
| 695 | log.debug("Found segment: {s} align({d}) flags({b})", .{ | 695 | log.debug("Found segment: {s} align({d}) flags({b})", .{ |
| 696 | segment.name, | 696 | segment.name, |
| ... | @@ -711,8 +711,8 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -711,8 +711,8 @@ fn Parser(comptime ReaderType: type) type { |
| 711 | errdefer gpa.free(funcs); | 711 | errdefer gpa.free(funcs); |
| 712 | for (funcs) |*func| { | 712 | for (funcs) |*func| { |
| 713 | func.* = .{ | 713 | func.* = .{ |
| 714 | .priority = try leb.readULEB128(u32, reader), | 714 | .priority = try leb.readUleb128(u32, reader), |
| 715 | .symbol_index = try leb.readULEB128(u32, reader), | 715 | .symbol_index = try leb.readUleb128(u32, reader), |
| 716 | }; | 716 | }; |
| 717 | log.debug("Found function - prio: {d}, index: {d}", .{ func.priority, func.symbol_index }); | 717 | log.debug("Found function - prio: {d}, index: {d}", .{ func.priority, func.symbol_index }); |
| 718 | } | 718 | } |
| ... | @@ -722,23 +722,23 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -722,23 +722,23 @@ fn Parser(comptime ReaderType: type) type { |
| 722 | const comdats = try gpa.alloc(types.Comdat, count); | 722 | const comdats = try gpa.alloc(types.Comdat, count); |
| 723 | errdefer gpa.free(comdats); | 723 | errdefer gpa.free(comdats); |
| 724 | for (comdats) |*comdat| { | 724 | for (comdats) |*comdat| { |
| 725 | const name_len = try leb.readULEB128(u32, reader); | 725 | const name_len = try leb.readUleb128(u32, reader); |
| 726 | const name = try gpa.alloc(u8, name_len); | 726 | const name = try gpa.alloc(u8, name_len); |
| 727 | errdefer gpa.free(name); | 727 | errdefer gpa.free(name); |
| 728 | try reader.readNoEof(name); | 728 | try reader.readNoEof(name); |
| 729 | 729 | ||
| 730 | const flags = try leb.readULEB128(u32, reader); | 730 | const flags = try leb.readUleb128(u32, reader); |
| 731 | if (flags != 0) { | 731 | if (flags != 0) { |
| 732 | return error.UnexpectedValue; | 732 | return error.UnexpectedValue; |
| 733 | } | 733 | } |
| 734 | 734 | ||
| 735 | const symbol_count = try leb.readULEB128(u32, reader); | 735 | const symbol_count = try leb.readUleb128(u32, reader); |
| 736 | const symbols = try gpa.alloc(types.ComdatSym, symbol_count); | 736 | const symbols = try gpa.alloc(types.ComdatSym, symbol_count); |
| 737 | errdefer gpa.free(symbols); | 737 | errdefer gpa.free(symbols); |
| 738 | for (symbols) |*symbol| { | 738 | for (symbols) |*symbol| { |
| 739 | symbol.* = .{ | 739 | symbol.* = .{ |
| 740 | .kind = @as(types.ComdatSym.Type, @enumFromInt(try leb.readULEB128(u8, reader))), | 740 | .kind = @as(types.ComdatSym.Type, @enumFromInt(try leb.readUleb128(u8, reader))), |
| 741 | .index = try leb.readULEB128(u32, reader), | 741 | .index = try leb.readUleb128(u32, reader), |
| 742 | }; | 742 | }; |
| 743 | } | 743 | } |
| 744 | 744 | ||
| ... | @@ -799,8 +799,8 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -799,8 +799,8 @@ fn Parser(comptime ReaderType: type) type { |
| 799 | /// requires access to `Object` to find the name of a symbol when it's | 799 | /// requires access to `Object` to find the name of a symbol when it's |
| 800 | /// an import and flag `WASM_SYM_EXPLICIT_NAME` is not set. | 800 | /// an import and flag `WASM_SYM_EXPLICIT_NAME` is not set. |
| 801 | fn parseSymbol(parser: *ObjectParser, gpa: Allocator, reader: anytype) !Symbol { | 801 | fn parseSymbol(parser: *ObjectParser, gpa: Allocator, reader: anytype) !Symbol { |
| 802 | const tag = @as(Symbol.Tag, @enumFromInt(try leb.readULEB128(u8, reader))); | 802 | const tag = @as(Symbol.Tag, @enumFromInt(try leb.readUleb128(u8, reader))); |
| 803 | const flags = try leb.readULEB128(u32, reader); | 803 | const flags = try leb.readUleb128(u32, reader); |
| 804 | var symbol: Symbol = .{ | 804 | var symbol: Symbol = .{ |
| 805 | .flags = flags, | 805 | .flags = flags, |
| 806 | .tag = tag, | 806 | .tag = tag, |
| ... | @@ -811,7 +811,7 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -811,7 +811,7 @@ fn Parser(comptime ReaderType: type) type { |
| 811 | 811 | ||
| 812 | switch (tag) { | 812 | switch (tag) { |
| 813 | .data => { | 813 | .data => { |
| 814 | const name_len = try leb.readULEB128(u32, reader); | 814 | const name_len = try leb.readUleb128(u32, reader); |
| 815 | const name = try gpa.alloc(u8, name_len); | 815 | const name = try gpa.alloc(u8, name_len); |
| 816 | defer gpa.free(name); | 816 | defer gpa.free(name); |
| 817 | try reader.readNoEof(name); | 817 | try reader.readNoEof(name); |
| ... | @@ -819,14 +819,14 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -819,14 +819,14 @@ fn Parser(comptime ReaderType: type) type { |
| 819 | 819 | ||
| 820 | // Data symbols only have the following fields if the symbol is defined | 820 | // Data symbols only have the following fields if the symbol is defined |
| 821 | if (symbol.isDefined()) { | 821 | if (symbol.isDefined()) { |
| 822 | symbol.index = try leb.readULEB128(u32, reader); | 822 | symbol.index = try leb.readUleb128(u32, reader); |
| 823 | // @TODO: We should verify those values | 823 | // @TODO: We should verify those values |
| 824 | _ = try leb.readULEB128(u32, reader); | 824 | _ = try leb.readUleb128(u32, reader); |
| 825 | _ = try leb.readULEB128(u32, reader); | 825 | _ = try leb.readUleb128(u32, reader); |
| 826 | } | 826 | } |
| 827 | }, | 827 | }, |
| 828 | .section => { | 828 | .section => { |
| 829 | symbol.index = try leb.readULEB128(u32, reader); | 829 | symbol.index = try leb.readUleb128(u32, reader); |
| 830 | const section_data = parser.object.relocatable_data.get(.custom).?; | 830 | const section_data = parser.object.relocatable_data.get(.custom).?; |
| 831 | for (section_data) |*data| { | 831 | for (section_data) |*data| { |
| 832 | if (data.section_index == symbol.index) { | 832 | if (data.section_index == symbol.index) { |
| ... | @@ -837,11 +837,11 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -837,11 +837,11 @@ fn Parser(comptime ReaderType: type) type { |
| 837 | } | 837 | } |
| 838 | }, | 838 | }, |
| 839 | else => { | 839 | else => { |
| 840 | symbol.index = try leb.readULEB128(u32, reader); | 840 | symbol.index = try leb.readUleb128(u32, reader); |
| 841 | const is_undefined = symbol.isUndefined(); | 841 | const is_undefined = symbol.isUndefined(); |
| 842 | const explicit_name = symbol.hasFlag(.WASM_SYM_EXPLICIT_NAME); | 842 | const explicit_name = symbol.hasFlag(.WASM_SYM_EXPLICIT_NAME); |
| 843 | symbol.name = if (!is_undefined or (is_undefined and explicit_name)) name: { | 843 | symbol.name = if (!is_undefined or (is_undefined and explicit_name)) name: { |
| 844 | const name_len = try leb.readULEB128(u32, reader); | 844 | const name_len = try leb.readUleb128(u32, reader); |
| 845 | const name = try gpa.alloc(u8, name_len); | 845 | const name = try gpa.alloc(u8, name_len); |
| 846 | defer gpa.free(name); | 846 | defer gpa.free(name); |
| 847 | try reader.readNoEof(name); | 847 | try reader.readNoEof(name); |
| ... | @@ -867,13 +867,13 @@ fn ElementType(comptime ptr: type) type { | ... | @@ -867,13 +867,13 @@ fn ElementType(comptime ptr: type) type { |
| 867 | return meta.Elem(meta.Child(ptr)); | 867 | return meta.Elem(meta.Child(ptr)); |
| 868 | } | 868 | } |
| 869 | 869 | ||
| 870 | /// Uses either `readILEB128` or `readULEB128` depending on the | 870 | /// Uses either `readIleb128` or `readUleb128` depending on the |
| 871 | /// signedness of the given type `T`. | 871 | /// signedness of the given type `T`. |
| 872 | /// Asserts `T` is an integer. | 872 | /// Asserts `T` is an integer. |
| 873 | fn readLeb(comptime T: type, reader: anytype) !T { | 873 | fn readLeb(comptime T: type, reader: anytype) !T { |
| 874 | return switch (@typeInfo(T).Int.signedness) { | 874 | return switch (@typeInfo(T).Int.signedness) { |
| 875 | .signed => try leb.readILEB128(T, reader), | 875 | .signed => try leb.readIleb128(T, reader), |
| 876 | .unsigned => try leb.readULEB128(T, reader), | 876 | .unsigned => try leb.readUleb128(T, reader), |
| 877 | }; | 877 | }; |
| 878 | } | 878 | } |
| 879 | 879 |