@zigc/lib 0.17.0-dev.644 → 0.17.0-dev.667
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/Maker/ScannedConfig.zig +4 -3
- package/compiler/Maker/Step/FindProgram.zig +2 -2
- package/compiler/Maker/Watch/FsEvents.zig +3 -2
- package/compiler/Maker.zig +2 -2
- package/compiler/aro/aro/Attribute.zig +52 -51
- package/compiler/aro/aro/Compilation.zig +5 -5
- package/compiler/aro/aro/Diagnostics.zig +7 -7
- package/compiler/aro/aro/Parser.zig +2 -2
- package/compiler/aro/aro/Tree.zig +11 -11
- package/compiler/aro/aro/features.zig +4 -4
- package/compiler/aro/aro/text_literal.zig +2 -2
- package/compiler/aro/backend/Interner.zig +14 -13
- package/compiler/configurer.zig +2 -2
- package/compiler/resinator/bmp.zig +3 -2
- package/compiler/resinator/code_pages.zig +14 -12
- package/compiler/resinator/cvtres.zig +11 -10
- package/compiler/resinator/errors.zig +18 -22
- package/compiler/resinator/lang.zig +7 -7
- package/compiler/resinator/parse.zig +1 -1
- package/compiler/translate-c/ast.zig +6 -6
- package/docs/wasm/markdown/Document.zig +3 -3
- package/docs/wasm/markdown/Parser.zig +3 -3
- package/libc/include/powerpc-linux-gnu/bits/struct_mutex.h +2 -2
- package/libc/include/s390x-linux-gnu/bits/fenv.h +2 -2
- package/libc/include/s390x-linux-gnu/bits/struct_mutex.h +2 -2
- package/libc/include/x86-linux-gnu/bits/struct_mutex.h +2 -2
- package/package.json +1 -1
- package/std/Build/Cache.zig +2 -2
- package/std/Build/Configuration.zig +19 -16
- package/std/Build/Step/ConfigHeader.zig +3 -2
- package/std/Build/Step/Options.zig +28 -22
- package/std/Build.zig +52 -53
- package/std/Io/Kqueue.zig +2 -2
- package/std/Io/Reader.zig +1 -1
- package/std/Io/Threaded.zig +18 -15
- package/std/Io/Uring.zig +2 -2
- package/std/Io/Writer.zig +18 -18
- package/std/Io/net.zig +3 -1
- package/std/Io.zig +7 -6
- package/std/Progress.zig +2 -2
- package/std/Target/aarch64.zig +2 -2
- package/std/Target/alpha.zig +2 -2
- package/std/Target/amdgcn.zig +2 -2
- package/std/Target/arc.zig +2 -2
- package/std/Target/arm.zig +2 -2
- package/std/Target/avr.zig +2 -2
- package/std/Target/bpf.zig +2 -2
- package/std/Target/csky.zig +2 -2
- package/std/Target/hexagon.zig +2 -2
- package/std/Target/hppa.zig +2 -2
- package/std/Target/kvx.zig +2 -2
- package/std/Target/lanai.zig +2 -2
- package/std/Target/loongarch.zig +2 -2
- package/std/Target/m68k.zig +2 -2
- package/std/Target/mips.zig +2 -2
- package/std/Target/msp430.zig +2 -2
- package/std/Target/nvptx.zig +2 -2
- package/std/Target/powerpc.zig +2 -2
- package/std/Target/propeller.zig +2 -2
- package/std/Target/riscv.zig +2 -2
- package/std/Target/s390x.zig +2 -2
- package/std/Target/sparc.zig +2 -2
- package/std/Target/spirv.zig +2 -2
- package/std/Target/ve.zig +2 -2
- package/std/Target/wasm.zig +2 -2
- package/std/Target/x86.zig +2 -2
- package/std/Target/xcore.zig +2 -2
- package/std/Target/xtensa.zig +2 -2
- package/std/Target.zig +4 -4
- package/std/c/darwin.zig +1 -1
- package/std/coff.zig +1 -1
- package/std/crypto/aes/aesni.zig +1 -1
- package/std/crypto/aes/armcrypto.zig +4 -4
- package/std/crypto/aes/soft.zig +4 -4
- package/std/crypto/aes.zig +12 -0
- package/std/crypto/codecs/asn1/Oid.zig +8 -8
- package/std/crypto/codecs/asn1/der/Decoder.zig +7 -7
- package/std/crypto/codecs/asn1/der/Encoder.zig +10 -8
- package/std/crypto/phc_encoding.zig +23 -20
- package/std/crypto/timing_safe.zig +1 -1
- package/std/crypto/tls/Client.zig +3 -3
- package/std/crypto/tls.zig +1 -1
- package/std/debug/Dwarf/Unwind/VirtualMachine.zig +11 -5
- package/std/debug/ElfFile.zig +12 -8
- package/std/debug/MachOFile.zig +2 -2
- package/std/debug/SelfInfo/MachO.zig +44 -17
- package/std/debug/SelfInfo/Windows.zig +2 -2
- package/std/elf.zig +7 -7
- package/std/enums.zig +66 -67
- package/std/gpu.zig +1 -1
- package/std/hash/auto_hash.zig +8 -8
- package/std/hash/verify.zig +3 -3
- package/std/http/Client.zig +2 -2
- package/std/json/Stringify.zig +14 -14
- package/std/json/static.zig +47 -31
- package/std/lang.zig +65 -97
- package/std/math.zig +2 -2
- package/std/mem/Allocator.zig +9 -9
- package/std/mem.zig +86 -102
- package/std/meta/trailer_flags.zig +26 -19
- package/std/meta.zig +131 -171
- package/std/multi_array_list.zig +49 -57
- package/std/os/uefi/protocol/device_path.zig +8 -7
- package/std/os/uefi/tables/boot_services.zig +1 -1
- package/std/os/windows.zig +9 -15
- package/std/sort/pdq.zig +22 -5
- package/std/start.zig +6 -6
- package/std/testing/Smith.zig +35 -21
- package/std/testing.zig +15 -15
- package/std/zig/Ast.zig +4 -4
- package/std/zig/AstGen.zig +42 -42
- package/std/zig/ErrorBundle.zig +16 -13
- package/std/zig/LibCInstallation.zig +11 -11
- package/std/zig/Parse.zig +6 -6
- package/std/zig/Zir.zig +10 -10
- package/std/zig/c_translation/helpers.zig +2 -2
- package/std/zig/llvm/BitcodeReader.zig +3 -3
- package/std/zig/llvm/Builder.zig +124 -93
- package/std/zig/llvm/bitcode_writer.zig +4 -4
- package/std/zig/system/windows.zig +11 -11
- package/std/zig/system.zig +4 -4
- package/std/zig.zig +4 -4
- package/std/zon/Serializer.zig +28 -23
- package/std/zon/parse.zig +83 -61
|
@@ -282,7 +282,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void {
|
|
|
282
282
|
};
|
|
283
283
|
try state.abbrevs.abbrevs.ensureTotalCapacity(
|
|
284
284
|
bc.allocator,
|
|
285
|
-
@typeInfo(Abbrev.Builtin).@"enum".
|
|
285
|
+
@typeInfo(Abbrev.Builtin).@"enum".field_names.len + abbrevs.len,
|
|
286
286
|
);
|
|
287
287
|
|
|
288
288
|
assert(state.abbrevs.abbrevs.items.len == @intFromEnum(Abbrev.Builtin.end_block));
|
|
@@ -318,7 +318,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void {
|
|
|
318
318
|
.{ .encoding = .{ .vbr = 6 } }, // ops
|
|
319
319
|
},
|
|
320
320
|
});
|
|
321
|
-
assert(state.abbrevs.abbrevs.items.len == @typeInfo(Abbrev.Builtin).@"enum".
|
|
321
|
+
assert(state.abbrevs.abbrevs.items.len == @typeInfo(Abbrev.Builtin).@"enum".field_names.len);
|
|
322
322
|
for (abbrevs) |abbrev| try state.abbrevs.addAbbrevAssumeCapacity(bc.allocator, abbrev);
|
|
323
323
|
}
|
|
324
324
|
|
|
@@ -457,7 +457,7 @@ const Abbrev = struct {
|
|
|
457
457
|
define_abbrev,
|
|
458
458
|
unabbrev_record,
|
|
459
459
|
|
|
460
|
-
const first_record_id: u32 = std.math.maxInt(u32) - @typeInfo(Builtin).@"enum".
|
|
460
|
+
const first_record_id: u32 = std.math.maxInt(u32) - @typeInfo(Builtin).@"enum".field_names.len + 1;
|
|
461
461
|
fn toRecordId(builtin: Builtin) u32 {
|
|
462
462
|
return first_record_id + @intFromEnum(builtin);
|
|
463
463
|
}
|
package/std/zig/llvm/Builder.zig
CHANGED
|
@@ -1137,21 +1137,22 @@ pub const Attribute = union(Kind) {
|
|
|
1137
1137
|
.no_sanitize_hwaddress,
|
|
1138
1138
|
.sanitize_address_dyninit,
|
|
1139
1139
|
=> |kind| {
|
|
1140
|
-
const
|
|
1140
|
+
const field_name, const field_type = comptime blk: {
|
|
1141
1141
|
@setEvalBranchQuota(10_000);
|
|
1142
|
-
|
|
1143
|
-
|
|
1142
|
+
const info = @typeInfo(Attribute).@"union";
|
|
1143
|
+
for (info.field_names, info.field_types) |field_name, field_type| {
|
|
1144
|
+
if (std.mem.eql(u8, field_name, @tagName(kind))) break :blk .{ field_name, field_type };
|
|
1144
1145
|
}
|
|
1145
1146
|
unreachable;
|
|
1146
1147
|
};
|
|
1147
|
-
comptime assert(std.mem.eql(u8, @tagName(kind),
|
|
1148
|
-
return @unionInit(Attribute,
|
|
1148
|
+
comptime assert(std.mem.eql(u8, @tagName(kind), field_name));
|
|
1149
|
+
return @unionInit(Attribute, field_name, switch (field_type) {
|
|
1149
1150
|
void => {},
|
|
1150
1151
|
u32 => storage.value,
|
|
1151
1152
|
Alignment.Lazy, String, Type, UwTable => @enumFromInt(storage.value),
|
|
1152
1153
|
AllocKind, AllocSize, FpClass, Memory, VScaleRange => @bitCast(storage.value),
|
|
1153
|
-
else => @compileError("bad payload type: " ++
|
|
1154
|
-
@typeName(
|
|
1154
|
+
else => @compileError("bad payload type: " ++ field_name ++ ": " ++
|
|
1155
|
+
@typeName(field_type)),
|
|
1155
1156
|
});
|
|
1156
1157
|
},
|
|
1157
1158
|
.string, .none => unreachable,
|
|
@@ -1258,14 +1259,14 @@ pub const Attribute = union(Kind) {
|
|
|
1258
1259
|
try w.print(" {s}(", .{@tagName(attribute)});
|
|
1259
1260
|
var any = false;
|
|
1260
1261
|
var remaining: Int = @bitCast(fpclass);
|
|
1261
|
-
inline for (@typeInfo(FpClass).@"struct".
|
|
1262
|
-
const pattern: Int = @bitCast(@field(FpClass,
|
|
1262
|
+
inline for (@typeInfo(FpClass).@"struct".decl_names) |decl_name| {
|
|
1263
|
+
const pattern: Int = @bitCast(@field(FpClass, decl_name));
|
|
1263
1264
|
if (remaining & pattern == pattern) {
|
|
1264
1265
|
if (!any) {
|
|
1265
1266
|
try w.writeByte(' ');
|
|
1266
1267
|
any = true;
|
|
1267
1268
|
}
|
|
1268
|
-
try w.writeAll(
|
|
1269
|
+
try w.writeAll(decl_name);
|
|
1269
1270
|
remaining &= ~pattern;
|
|
1270
1271
|
}
|
|
1271
1272
|
}
|
|
@@ -1283,14 +1284,14 @@ pub const Attribute = union(Kind) {
|
|
|
1283
1284
|
.allockind => |allockind| {
|
|
1284
1285
|
try w.print(" {t}(\"", .{attribute});
|
|
1285
1286
|
var any = false;
|
|
1286
|
-
inline for (@typeInfo(AllocKind).@"struct".
|
|
1287
|
-
if (comptime std.mem.eql(u8,
|
|
1288
|
-
if (@field(allockind,
|
|
1287
|
+
inline for (@typeInfo(AllocKind).@"struct".field_names) |field_name| {
|
|
1288
|
+
if (comptime std.mem.eql(u8, field_name, "_")) continue;
|
|
1289
|
+
if (@field(allockind, field_name)) {
|
|
1289
1290
|
if (!any) {
|
|
1290
1291
|
try w.writeByte(',');
|
|
1291
1292
|
any = true;
|
|
1292
1293
|
}
|
|
1293
|
-
try w.writeAll(
|
|
1294
|
+
try w.writeAll(field_name);
|
|
1294
1295
|
}
|
|
1295
1296
|
}
|
|
1296
1297
|
try w.writeAll("\")");
|
|
@@ -1442,7 +1443,7 @@ pub const Attribute = union(Kind) {
|
|
|
1442
1443
|
none = maxInt(u32),
|
|
1443
1444
|
_,
|
|
1444
1445
|
|
|
1445
|
-
pub const len = @typeInfo(Kind).@"enum".
|
|
1446
|
+
pub const len = @typeInfo(Kind).@"enum".field_names.len - 2;
|
|
1446
1447
|
|
|
1447
1448
|
pub fn fromString(str: String) Kind {
|
|
1448
1449
|
assert(!str.isAnon());
|
|
@@ -5167,9 +5168,13 @@ pub const Function = struct {
|
|
|
5167
5168
|
index: Instruction.ExtraIndex,
|
|
5168
5169
|
) struct { data: T, trail: ExtraDataTrail } {
|
|
5169
5170
|
var result: T = undefined;
|
|
5170
|
-
const
|
|
5171
|
-
inline for (
|
|
5172
|
-
|
|
5171
|
+
const info = @typeInfo(T).@"struct";
|
|
5172
|
+
inline for (
|
|
5173
|
+
info.field_names,
|
|
5174
|
+
info.field_types,
|
|
5175
|
+
self.extra[index..][0..info.field_names.len],
|
|
5176
|
+
) |field_name, field_type, value|
|
|
5177
|
+
@field(result, field_name) = switch (field_type) {
|
|
5173
5178
|
u32 => value,
|
|
5174
5179
|
Alignment,
|
|
5175
5180
|
AtomicOrdering,
|
|
@@ -5183,11 +5188,11 @@ pub const Function = struct {
|
|
|
5183
5188
|
Instruction.Alloca.Info,
|
|
5184
5189
|
Instruction.Call.Info,
|
|
5185
5190
|
=> @bitCast(value),
|
|
5186
|
-
else => @compileError("bad field type: " ++
|
|
5191
|
+
else => @compileError("bad field type: " ++ field_name ++ ": " ++ @typeName(field_type)),
|
|
5187
5192
|
};
|
|
5188
5193
|
return .{
|
|
5189
5194
|
.data = result,
|
|
5190
|
-
.trail = .{ .index = index + @as(Type.Item.ExtraIndex, @intCast(
|
|
5195
|
+
.trail = .{ .index = index + @as(Type.Item.ExtraIndex, @intCast(info.field_names.len)) },
|
|
5191
5196
|
};
|
|
5192
5197
|
}
|
|
5193
5198
|
|
|
@@ -6327,9 +6332,10 @@ pub const WipFunction = struct {
|
|
|
6327
6332
|
|
|
6328
6333
|
fn addExtra(wip_extra: *@This(), extra: anytype) Instruction.ExtraIndex {
|
|
6329
6334
|
const result = wip_extra.index;
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6335
|
+
const info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
6336
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
6337
|
+
const value = @field(extra, field_name);
|
|
6338
|
+
wip_extra.items[wip_extra.index] = switch (field_type) {
|
|
6333
6339
|
u32 => value,
|
|
6334
6340
|
Alignment,
|
|
6335
6341
|
AtomicOrdering,
|
|
@@ -6343,7 +6349,7 @@ pub const WipFunction = struct {
|
|
|
6343
6349
|
Instruction.Alloca.Info,
|
|
6344
6350
|
Instruction.Call.Info,
|
|
6345
6351
|
=> @bitCast(value),
|
|
6346
|
-
else => @compileError("bad field type: " ++
|
|
6352
|
+
else => @compileError("bad field type: " ++ field_name ++ ": " ++ @typeName(field_type)),
|
|
6347
6353
|
};
|
|
6348
6354
|
wip_extra.index += 1;
|
|
6349
6355
|
}
|
|
@@ -6944,7 +6950,7 @@ pub const WipFunction = struct {
|
|
|
6944
6950
|
) Allocator.Error!void {
|
|
6945
6951
|
try self.extra.ensureUnusedCapacity(
|
|
6946
6952
|
self.builder.gpa,
|
|
6947
|
-
count * (@typeInfo(Extra).@"struct".
|
|
6953
|
+
count * (@typeInfo(Extra).@"struct".field_names.len + trail_len),
|
|
6948
6954
|
);
|
|
6949
6955
|
}
|
|
6950
6956
|
|
|
@@ -6983,9 +6989,10 @@ pub const WipFunction = struct {
|
|
|
6983
6989
|
|
|
6984
6990
|
fn addExtraAssumeCapacity(self: *WipFunction, extra: anytype) Instruction.ExtraIndex {
|
|
6985
6991
|
const result: Instruction.ExtraIndex = @intCast(self.extra.items.len);
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6992
|
+
const info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
6993
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
6994
|
+
const value = @field(extra, field_name);
|
|
6995
|
+
self.extra.appendAssumeCapacity(switch (field_type) {
|
|
6989
6996
|
u32 => value,
|
|
6990
6997
|
Alignment,
|
|
6991
6998
|
AtomicOrdering,
|
|
@@ -6999,7 +7006,7 @@ pub const WipFunction = struct {
|
|
|
6999
7006
|
Instruction.Alloca.Info,
|
|
7000
7007
|
Instruction.Call.Info,
|
|
7001
7008
|
=> @bitCast(value),
|
|
7002
|
-
else => @compileError("bad field type: " ++
|
|
7009
|
+
else => @compileError("bad field type: " ++ field_name ++ ": " ++ @typeName(field_type)),
|
|
7003
7010
|
});
|
|
7004
7011
|
}
|
|
7005
7012
|
return result;
|
|
@@ -7032,9 +7039,13 @@ pub const WipFunction = struct {
|
|
|
7032
7039
|
index: Instruction.ExtraIndex,
|
|
7033
7040
|
) struct { data: T, trail: ExtraDataTrail } {
|
|
7034
7041
|
var result: T = undefined;
|
|
7035
|
-
const
|
|
7036
|
-
inline for (
|
|
7037
|
-
|
|
7042
|
+
const info = @typeInfo(T).@"struct";
|
|
7043
|
+
inline for (
|
|
7044
|
+
info.field_names,
|
|
7045
|
+
info.field_types,
|
|
7046
|
+
self.extra.items[index..][0..info.field_names.len],
|
|
7047
|
+
) |field_name, field_type, value|
|
|
7048
|
+
@field(result, field_name) = switch (field_type) {
|
|
7038
7049
|
u32 => value,
|
|
7039
7050
|
Alignment,
|
|
7040
7051
|
AtomicOrdering,
|
|
@@ -7048,11 +7059,11 @@ pub const WipFunction = struct {
|
|
|
7048
7059
|
Instruction.Alloca.Info,
|
|
7049
7060
|
Instruction.Call.Info,
|
|
7050
7061
|
=> @bitCast(value),
|
|
7051
|
-
else => @compileError("bad field type: " ++
|
|
7062
|
+
else => @compileError("bad field type: " ++ field_name ++ ": " ++ @typeName(field_type)),
|
|
7052
7063
|
};
|
|
7053
7064
|
return .{
|
|
7054
7065
|
.data = result,
|
|
7055
|
-
.trail = .{ .index = index + @as(Type.Item.ExtraIndex, @intCast(
|
|
7066
|
+
.trail = .{ .index = index + @as(Type.Item.ExtraIndex, @intCast(info.field_names.len)) },
|
|
7056
7067
|
};
|
|
7057
7068
|
}
|
|
7058
7069
|
|
|
@@ -8202,19 +8213,20 @@ pub const Metadata = packed struct(u32) {
|
|
|
8202
8213
|
|
|
8203
8214
|
pub fn format(self: DIFlags, w: *Writer) Writer.Error!void {
|
|
8204
8215
|
var need_pipe = false;
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8216
|
+
const info = @typeInfo(DIFlags).@"struct";
|
|
8217
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
8218
|
+
switch (@typeInfo(field_type)) {
|
|
8219
|
+
.bool => if (@field(self, field_name)) {
|
|
8208
8220
|
if (need_pipe) try w.writeAll(" | ") else need_pipe = true;
|
|
8209
|
-
try w.print("DIFlag{s}", .{
|
|
8221
|
+
try w.print("DIFlag{s}", .{field_name});
|
|
8210
8222
|
},
|
|
8211
|
-
.@"enum" => if (@field(self,
|
|
8223
|
+
.@"enum" => if (@field(self, field_name) != .Zero) {
|
|
8212
8224
|
if (need_pipe) try w.writeAll(" | ") else need_pipe = true;
|
|
8213
|
-
try w.print("DIFlag{s}", .{@tagName(@field(self,
|
|
8225
|
+
try w.print("DIFlag{s}", .{@tagName(@field(self, field_name))});
|
|
8214
8226
|
},
|
|
8215
|
-
.int => assert(@field(self,
|
|
8216
|
-
else => @compileError("bad field type: " ++
|
|
8217
|
-
@typeName(
|
|
8227
|
+
.int => assert(@field(self, field_name) == 0),
|
|
8228
|
+
else => @compileError("bad field type: " ++ field_name ++ ": " ++
|
|
8229
|
+
@typeName(field_type)),
|
|
8218
8230
|
}
|
|
8219
8231
|
}
|
|
8220
8232
|
if (!need_pipe) try w.writeByte('0');
|
|
@@ -8259,19 +8271,20 @@ pub const Metadata = packed struct(u32) {
|
|
|
8259
8271
|
|
|
8260
8272
|
pub fn format(self: DISPFlags, w: *Writer) Writer.Error!void {
|
|
8261
8273
|
var need_pipe = false;
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8274
|
+
const info = @typeInfo(DISPFlags).@"struct";
|
|
8275
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
8276
|
+
switch (@typeInfo(field_type)) {
|
|
8277
|
+
.bool => if (@field(self, field_name)) {
|
|
8265
8278
|
if (need_pipe) try w.writeAll(" | ") else need_pipe = true;
|
|
8266
|
-
try w.print("DISPFlag{s}", .{
|
|
8279
|
+
try w.print("DISPFlag{s}", .{field_name});
|
|
8267
8280
|
},
|
|
8268
|
-
.@"enum" => if (@field(self,
|
|
8281
|
+
.@"enum" => if (@field(self, field_name) != .Zero) {
|
|
8269
8282
|
if (need_pipe) try w.writeAll(" | ") else need_pipe = true;
|
|
8270
|
-
try w.print("DISPFlag{s}", .{@tagName(@field(self,
|
|
8283
|
+
try w.print("DISPFlag{s}", .{@tagName(@field(self, field_name))});
|
|
8271
8284
|
},
|
|
8272
|
-
.int => assert(@field(self,
|
|
8273
|
-
else => @compileError("bad field type: " ++
|
|
8274
|
-
@typeName(
|
|
8285
|
+
.int => assert(@field(self, field_name) == 0),
|
|
8286
|
+
else => @compileError("bad field type: " ++ field_name ++ ": " ++
|
|
8287
|
+
@typeName(field_type)),
|
|
8275
8288
|
}
|
|
8276
8289
|
}
|
|
8277
8290
|
if (!need_pipe) try w.writeByte('0');
|
|
@@ -8567,7 +8580,7 @@ pub const Metadata = packed struct(u32) {
|
|
|
8567
8580
|
})) |some| switch (@typeInfo(Some)) {
|
|
8568
8581
|
.@"enum" => |enum_info| switch (Some) {
|
|
8569
8582
|
Metadata.String => .{ .string = some },
|
|
8570
|
-
else => if (enum_info.
|
|
8583
|
+
else => if (enum_info.mode == .exhaustive)
|
|
8571
8584
|
.{ .raw = @tagName(some) }
|
|
8572
8585
|
else
|
|
8573
8586
|
@compileError("unknown type to format: " ++ @typeName(Node)),
|
|
@@ -8763,14 +8776,15 @@ pub fn init(options: Options) Allocator.Error!Builder {
|
|
|
8763
8776
|
}
|
|
8764
8777
|
|
|
8765
8778
|
{
|
|
8766
|
-
const static_len = @typeInfo(Type).@"enum".
|
|
8779
|
+
const static_len = @typeInfo(Type).@"enum".field_names.len - 1;
|
|
8767
8780
|
try self.type_map.ensureTotalCapacity(self.gpa, static_len);
|
|
8768
8781
|
try self.type_items.ensureTotalCapacity(self.gpa, static_len);
|
|
8769
|
-
|
|
8782
|
+
const info = @typeInfo(Type.Simple).@"enum";
|
|
8783
|
+
inline for (info.field_names, info.field_values) |simple_field_name, simple_field_value| {
|
|
8770
8784
|
const result = self.getOrPutTypeNoExtraAssumeCapacity(
|
|
8771
|
-
.{ .tag = .simple, .data =
|
|
8785
|
+
.{ .tag = .simple, .data = simple_field_value },
|
|
8772
8786
|
);
|
|
8773
|
-
assert(result.new and result.type == @field(Type,
|
|
8787
|
+
assert(result.new and result.type == @field(Type, simple_field_name));
|
|
8774
8788
|
}
|
|
8775
8789
|
inline for (.{ 1, 8, 16, 29, 32, 64, 80, 128 }) |bits|
|
|
8776
8790
|
assert(self.intTypeAssumeCapacity(bits) ==
|
|
@@ -11016,7 +11030,7 @@ fn ensureUnusedTypeCapacity(
|
|
|
11016
11030
|
try self.type_items.ensureUnusedCapacity(self.gpa, count);
|
|
11017
11031
|
try self.type_extra.ensureUnusedCapacity(
|
|
11018
11032
|
self.gpa,
|
|
11019
|
-
count * (@typeInfo(Extra).@"struct".
|
|
11033
|
+
count * (@typeInfo(Extra).@"struct".field_names.len + trail_len),
|
|
11020
11034
|
);
|
|
11021
11035
|
}
|
|
11022
11036
|
|
|
@@ -11046,12 +11060,13 @@ fn getOrPutTypeNoExtraAssumeCapacity(self: *Builder, item: Type.Item) struct { n
|
|
|
11046
11060
|
|
|
11047
11061
|
fn addTypeExtraAssumeCapacity(self: *Builder, extra: anytype) Type.Item.ExtraIndex {
|
|
11048
11062
|
const result: Type.Item.ExtraIndex = @intCast(self.type_extra.items.len);
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11063
|
+
const info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
11064
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
11065
|
+
const value = @field(extra, field_name);
|
|
11066
|
+
self.type_extra.appendAssumeCapacity(switch (field_type) {
|
|
11052
11067
|
u32 => value,
|
|
11053
11068
|
String, Type => @intFromEnum(value),
|
|
11054
|
-
else => @compileError("bad field type: " ++
|
|
11069
|
+
else => @compileError("bad field type: " ++ field_name ++ ": " ++ @typeName(field_type)),
|
|
11055
11070
|
});
|
|
11056
11071
|
}
|
|
11057
11072
|
return result;
|
|
@@ -11084,16 +11099,20 @@ fn typeExtraDataTrail(
|
|
|
11084
11099
|
index: Type.Item.ExtraIndex,
|
|
11085
11100
|
) struct { data: T, trail: TypeExtraDataTrail } {
|
|
11086
11101
|
var result: T = undefined;
|
|
11087
|
-
const
|
|
11088
|
-
inline for (
|
|
11089
|
-
|
|
11102
|
+
const info = @typeInfo(T).@"struct";
|
|
11103
|
+
inline for (
|
|
11104
|
+
info.field_names,
|
|
11105
|
+
info.field_types,
|
|
11106
|
+
self.type_extra.items[index..][0..info.field_names.len],
|
|
11107
|
+
) |field_name, field_type, value|
|
|
11108
|
+
@field(result, field_name) = switch (field_type) {
|
|
11090
11109
|
u32 => value,
|
|
11091
11110
|
String, Type => @enumFromInt(value),
|
|
11092
|
-
else => @compileError("bad field type: " ++ @typeName(
|
|
11111
|
+
else => @compileError("bad field type: " ++ @typeName(field_type)),
|
|
11093
11112
|
};
|
|
11094
11113
|
return .{
|
|
11095
11114
|
.data = result,
|
|
11096
|
-
.trail = .{ .index = index + @as(Type.Item.ExtraIndex, @intCast(
|
|
11115
|
+
.trail = .{ .index = index + @as(Type.Item.ExtraIndex, @intCast(info.field_names.len)) },
|
|
11097
11116
|
};
|
|
11098
11117
|
}
|
|
11099
11118
|
|
|
@@ -11899,7 +11918,7 @@ fn ensureUnusedConstantCapacity(
|
|
|
11899
11918
|
try self.constant_items.ensureUnusedCapacity(self.gpa, count);
|
|
11900
11919
|
try self.constant_extra.ensureUnusedCapacity(
|
|
11901
11920
|
self.gpa,
|
|
11902
|
-
count * (@typeInfo(Extra).@"struct".
|
|
11921
|
+
count * (@typeInfo(Extra).@"struct".field_names.len + trail_len),
|
|
11903
11922
|
);
|
|
11904
11923
|
}
|
|
11905
11924
|
|
|
@@ -11974,13 +11993,14 @@ fn getOrPutConstantAggregateAssumeCapacity(
|
|
|
11974
11993
|
|
|
11975
11994
|
fn addConstantExtraAssumeCapacity(self: *Builder, extra: anytype) Constant.Item.ExtraIndex {
|
|
11976
11995
|
const result: Constant.Item.ExtraIndex = @intCast(self.constant_extra.items.len);
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
|
|
11996
|
+
const info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
11997
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
11998
|
+
const value = @field(extra, field_name);
|
|
11999
|
+
self.constant_extra.appendAssumeCapacity(switch (field_type) {
|
|
11980
12000
|
u32 => value,
|
|
11981
12001
|
String, Type, Constant, Function.Index, Function.Block.Index => @intFromEnum(value),
|
|
11982
12002
|
Constant.GetElementPtr.Info => @bitCast(value),
|
|
11983
|
-
else => @compileError("bad field type: " ++ @typeName(
|
|
12003
|
+
else => @compileError("bad field type: " ++ @typeName(field_type)),
|
|
11984
12004
|
});
|
|
11985
12005
|
}
|
|
11986
12006
|
return result;
|
|
@@ -12013,17 +12033,21 @@ fn constantExtraDataTrail(
|
|
|
12013
12033
|
index: Constant.Item.ExtraIndex,
|
|
12014
12034
|
) struct { data: T, trail: ConstantExtraDataTrail } {
|
|
12015
12035
|
var result: T = undefined;
|
|
12016
|
-
const
|
|
12017
|
-
inline for (
|
|
12018
|
-
|
|
12036
|
+
const info = @typeInfo(T).@"struct";
|
|
12037
|
+
inline for (
|
|
12038
|
+
info.field_names,
|
|
12039
|
+
info.field_types,
|
|
12040
|
+
self.constant_extra.items[index..][0..info.field_names.len],
|
|
12041
|
+
) |field_name, field_type, value|
|
|
12042
|
+
@field(result, field_name) = switch (field_type) {
|
|
12019
12043
|
u32 => value,
|
|
12020
12044
|
String, Type, Constant, Function.Index, Function.Block.Index => @enumFromInt(value),
|
|
12021
12045
|
Constant.GetElementPtr.Info => @bitCast(value),
|
|
12022
|
-
else => @compileError("bad field type: " ++ @typeName(
|
|
12046
|
+
else => @compileError("bad field type: " ++ @typeName(field_type)),
|
|
12023
12047
|
};
|
|
12024
12048
|
return .{
|
|
12025
12049
|
.data = result,
|
|
12026
|
-
.trail = .{ .index = index + @as(Constant.Item.ExtraIndex, @intCast(
|
|
12050
|
+
.trail = .{ .index = index + @as(Constant.Item.ExtraIndex, @intCast(info.field_names.len)) },
|
|
12027
12051
|
};
|
|
12028
12052
|
}
|
|
12029
12053
|
|
|
@@ -12041,19 +12065,20 @@ fn ensureUnusedMetadataCapacity(
|
|
|
12041
12065
|
try self.metadata_items.ensureUnusedCapacity(self.gpa, count);
|
|
12042
12066
|
try self.metadata_extra.ensureUnusedCapacity(
|
|
12043
12067
|
self.gpa,
|
|
12044
|
-
count * (@typeInfo(Extra).@"struct".
|
|
12068
|
+
count * (@typeInfo(Extra).@"struct".field_names.len + trail_len),
|
|
12045
12069
|
);
|
|
12046
12070
|
}
|
|
12047
12071
|
|
|
12048
12072
|
fn addMetadataExtraAssumeCapacity(self: *Builder, extra: anytype) Metadata.Item.ExtraIndex {
|
|
12049
12073
|
const result: Metadata.Item.ExtraIndex = @intCast(self.metadata_extra.items.len);
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12074
|
+
const info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
12075
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
12076
|
+
const value = @field(extra, field_name);
|
|
12077
|
+
self.metadata_extra.appendAssumeCapacity(switch (field_type) {
|
|
12053
12078
|
u32 => value,
|
|
12054
12079
|
Metadata.String, Metadata.String.Optional, Variable.Index, Value => @intFromEnum(value),
|
|
12055
12080
|
Metadata, Metadata.Optional, Metadata.DIFlags => @bitCast(value),
|
|
12056
|
-
else => @compileError("bad field type: " ++ @typeName(
|
|
12081
|
+
else => @compileError("bad field type: " ++ @typeName(field_type)),
|
|
12057
12082
|
});
|
|
12058
12083
|
}
|
|
12059
12084
|
return result;
|
|
@@ -12086,17 +12111,21 @@ fn metadataExtraDataTrail(
|
|
|
12086
12111
|
index: Metadata.Item.ExtraIndex,
|
|
12087
12112
|
) struct { data: T, trail: MetadataExtraDataTrail } {
|
|
12088
12113
|
var result: T = undefined;
|
|
12089
|
-
const
|
|
12090
|
-
inline for (
|
|
12091
|
-
|
|
12114
|
+
const info = @typeInfo(T).@"struct";
|
|
12115
|
+
inline for (
|
|
12116
|
+
info.field_names,
|
|
12117
|
+
info.field_types,
|
|
12118
|
+
self.metadata_extra.items[index..][0..info.field_names.len],
|
|
12119
|
+
) |field_name, field_type, value|
|
|
12120
|
+
@field(result, field_name) = switch (field_type) {
|
|
12092
12121
|
u32 => value,
|
|
12093
12122
|
Metadata.String, Metadata.String.Optional, Variable.Index, Value => @enumFromInt(value),
|
|
12094
12123
|
Metadata, Metadata.Optional, Metadata.DIFlags => @bitCast(value),
|
|
12095
|
-
else => @compileError("bad field type: " ++ @typeName(
|
|
12124
|
+
else => @compileError("bad field type: " ++ @typeName(field_type)),
|
|
12096
12125
|
};
|
|
12097
12126
|
return .{
|
|
12098
12127
|
.data = result,
|
|
12099
|
-
.trail = .{ .index = index + @as(Metadata.Item.ExtraIndex, @intCast(
|
|
12128
|
+
.trail = .{ .index = index + @as(Metadata.Item.ExtraIndex, @intCast(info.field_names.len)) },
|
|
12100
12129
|
};
|
|
12101
12130
|
}
|
|
12102
12131
|
|
|
@@ -12602,8 +12631,8 @@ fn metadataSimpleAssumeCapacity(self: *Builder, tag: Metadata.Tag, value: anytyp
|
|
|
12602
12631
|
builder: *const Builder,
|
|
12603
12632
|
pub fn hash(_: @This(), key: Key) u32 {
|
|
12604
12633
|
var hasher = std.hash.Wyhash.init(std.hash.int(@intFromEnum(key.tag)));
|
|
12605
|
-
inline for (std.meta.
|
|
12606
|
-
hasher.update(std.mem.asBytes(&@field(key.value,
|
|
12634
|
+
inline for (comptime std.meta.fieldNames(@TypeOf(value))) |field_name| {
|
|
12635
|
+
hasher.update(std.mem.asBytes(&@field(key.value, field_name)));
|
|
12607
12636
|
}
|
|
12608
12637
|
return @truncate(hasher.final());
|
|
12609
12638
|
}
|
|
@@ -14184,12 +14213,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
|
|
|
14184
14213
|
const MetadataKindBlock = ir.ModuleBlock.MetadataKindBlock;
|
|
14185
14214
|
var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);
|
|
14186
14215
|
|
|
14187
|
-
|
|
14216
|
+
const info = @typeInfo(ir.FixedMetadataKind).@"enum";
|
|
14217
|
+
|
|
14218
|
+
inline for (info.field_names, info.field_values) |field_name, field_value| {
|
|
14188
14219
|
// don't include `dbg` in stripped functions
|
|
14189
|
-
if (!(self.strip and std.mem.eql(u8,
|
|
14220
|
+
if (!(self.strip and std.mem.eql(u8, field_name, "dbg"))) {
|
|
14190
14221
|
try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{
|
|
14191
|
-
.id =
|
|
14192
|
-
.name =
|
|
14222
|
+
.id = field_value,
|
|
14223
|
+
.name = field_name,
|
|
14193
14224
|
});
|
|
14194
14225
|
}
|
|
14195
14226
|
}
|
|
@@ -246,14 +246,14 @@ pub fn BitcodeWriter(comptime types: []const type) type {
|
|
|
246
246
|
|
|
247
247
|
try self.bitcode.writeBits(comptime abbrevId(Abbrev), abbrev_len);
|
|
248
248
|
|
|
249
|
-
const
|
|
249
|
+
const field_names = comptime std.meta.fieldNames(Abbrev);
|
|
250
250
|
|
|
251
251
|
// This abbreviation might only contain literals
|
|
252
|
-
if (
|
|
252
|
+
if (field_names.len == 0) return;
|
|
253
253
|
|
|
254
254
|
comptime var field_index: usize = 0;
|
|
255
255
|
inline for (Abbrev.ops) |ty| {
|
|
256
|
-
const param = @field(params,
|
|
256
|
+
const param = @field(params, field_names[field_index]);
|
|
257
257
|
switch (ty) {
|
|
258
258
|
.literal => continue,
|
|
259
259
|
.fixed => |len| try self.bitcode.writeBits(adapter.get(param), len),
|
|
@@ -296,7 +296,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
|
|
|
296
296
|
},
|
|
297
297
|
}
|
|
298
298
|
field_index += 1;
|
|
299
|
-
if (field_index ==
|
|
299
|
+
if (field_index == field_names.len) break;
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
|
|
@@ -60,14 +60,14 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
|
|
|
60
60
|
@compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const fields_info = args_type_info.@"struct"
|
|
63
|
+
const fields_info = args_type_info.@"struct";
|
|
64
64
|
|
|
65
65
|
// Originally, I wanted to issue a single call with a more complex table structure such that we
|
|
66
66
|
// would sequentially visit each CPU#d subkey in the registry and pull the value of interest into
|
|
67
67
|
// a buffer, however, NT seems to be expecting a single buffer per each table meaning we would
|
|
68
68
|
// end up pulling only the last CPU core info, overwriting everything else.
|
|
69
69
|
// If anyone can come up with a solution to this, please do!
|
|
70
|
-
const table_size = 1 + fields_info.len;
|
|
70
|
+
const table_size = 1 + fields_info.field_names.len;
|
|
71
71
|
var table: [table_size + 1]std.os.windows.RTL_QUERY_REGISTRY_TABLE = undefined;
|
|
72
72
|
|
|
73
73
|
const topkey = std.unicode.utf8ToUtf16LeStringLiteral("\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor");
|
|
@@ -90,11 +90,11 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
|
|
|
90
90
|
.DefaultLength = 0,
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
var tmp_bufs: [fields_info.len][max_value_len]u8 align(@alignOf(std.os.windows.UNICODE_STRING)) = undefined;
|
|
93
|
+
var tmp_bufs: [fields_info.field_names.len][max_value_len]u8 align(@alignOf(std.os.windows.UNICODE_STRING)) = undefined;
|
|
94
94
|
|
|
95
|
-
inline for (fields_info, 0..) |
|
|
95
|
+
inline for (fields_info.field_names, 0..) |field_name, i| {
|
|
96
96
|
const ctx: *anyopaque = blk: {
|
|
97
|
-
switch (@field(args,
|
|
97
|
+
switch (@field(args, field_name).value_type) {
|
|
98
98
|
.SZ,
|
|
99
99
|
.EXPAND_SZ,
|
|
100
100
|
.MULTI_SZ,
|
|
@@ -119,7 +119,7 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
var key_buf: [max_value_len / 2 + 1]u16 = undefined;
|
|
122
|
-
const key_len = try std.unicode.utf8ToUtf16Le(&key_buf, @field(args,
|
|
122
|
+
const key_len = try std.unicode.utf8ToUtf16Le(&key_buf, @field(args, field_name).key);
|
|
123
123
|
key_buf[key_len] = 0;
|
|
124
124
|
|
|
125
125
|
table[i + 1] = .{
|
|
@@ -153,12 +153,12 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
|
|
|
153
153
|
);
|
|
154
154
|
switch (res) {
|
|
155
155
|
.SUCCESS => {
|
|
156
|
-
inline for (fields_info, 0..) |
|
|
156
|
+
inline for (fields_info.field_names, 0..) |field_name, i| switch (@field(args, field_name).value_type) {
|
|
157
157
|
.SZ,
|
|
158
158
|
.EXPAND_SZ,
|
|
159
159
|
.MULTI_SZ,
|
|
160
160
|
=> {
|
|
161
|
-
var buf = @field(args,
|
|
161
|
+
var buf = @field(args, field_name).value_buf;
|
|
162
162
|
const entry: *const std.os.windows.UNICODE_STRING = @ptrCast(table[i + 1].EntryContext);
|
|
163
163
|
const len = try std.unicode.utf16LeToUtf8(buf, entry.slice());
|
|
164
164
|
buf[len] = 0;
|
|
@@ -169,12 +169,12 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
|
|
|
169
169
|
.QWORD,
|
|
170
170
|
=> {
|
|
171
171
|
const entry: [*]const u8 = @ptrCast(table[i + 1].EntryContext);
|
|
172
|
-
switch (@field(args,
|
|
172
|
+
switch (@field(args, field_name).value_type) {
|
|
173
173
|
.DWORD, .DWORD_BIG_ENDIAN => {
|
|
174
|
-
@memcpy(@field(args,
|
|
174
|
+
@memcpy(@field(args, field_name).value_buf[0..4], entry[0..4]);
|
|
175
175
|
},
|
|
176
176
|
.QWORD => {
|
|
177
|
-
@memcpy(@field(args,
|
|
177
|
+
@memcpy(@field(args, field_name).value_buf[0..8], entry[0..8]);
|
|
178
178
|
},
|
|
179
179
|
else => unreachable,
|
|
180
180
|
}
|
package/std/zig/system.zig
CHANGED
|
@@ -973,10 +973,10 @@ fn detectAbiAndDynamicLinker(io: Io, cpu: Target.Cpu, os: Target.Os, query: Targ
|
|
|
973
973
|
// relying on `builtin.target`.
|
|
974
974
|
const all_abis = comptime blk: {
|
|
975
975
|
assert(@intFromEnum(Target.Abi.none) == 0);
|
|
976
|
-
const
|
|
977
|
-
var array: [
|
|
978
|
-
for (
|
|
979
|
-
array[i] = @field(Target.Abi,
|
|
976
|
+
const field_names = std.meta.fieldNames(Target.Abi)[1..];
|
|
977
|
+
var array: [field_names.len]Target.Abi = undefined;
|
|
978
|
+
for (field_names, 0..) |field_name, i| {
|
|
979
|
+
array[i] = @field(Target.Abi, field_name);
|
|
980
980
|
}
|
|
981
981
|
break :blk array;
|
|
982
982
|
};
|
package/std/zig.zig
CHANGED
|
@@ -736,8 +736,8 @@ pub fn parseTargetQueryOrReportFatalError(
|
|
|
736
736
|
help: {
|
|
737
737
|
var help_text = std.array_list.Managed(u8).init(allocator);
|
|
738
738
|
defer help_text.deinit();
|
|
739
|
-
inline for (@typeInfo(std.Target.ObjectFormat).@"enum".
|
|
740
|
-
help_text.print(" {s}\n", .{
|
|
739
|
+
inline for (@typeInfo(std.Target.ObjectFormat).@"enum".field_names) |field_name| {
|
|
740
|
+
help_text.print(" {s}\n", .{field_name}) catch break :help;
|
|
741
741
|
}
|
|
742
742
|
std.log.info("available object formats:\n{s}", .{help_text.items});
|
|
743
743
|
}
|
|
@@ -747,8 +747,8 @@ pub fn parseTargetQueryOrReportFatalError(
|
|
|
747
747
|
help: {
|
|
748
748
|
var help_text = std.array_list.Managed(u8).init(allocator);
|
|
749
749
|
defer help_text.deinit();
|
|
750
|
-
inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".
|
|
751
|
-
help_text.print(" {s}\n", .{
|
|
750
|
+
inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".field_names) |field_name| {
|
|
751
|
+
help_text.print(" {s}\n", .{field_name}) catch break :help;
|
|
752
752
|
}
|
|
753
753
|
std.log.info("available architectures:\n{s} native\n", .{help_text.items});
|
|
754
754
|
}
|