@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
package/std/testing.zig
CHANGED
|
@@ -141,16 +141,16 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
|
|
|
141
141
|
},
|
|
142
142
|
|
|
143
143
|
.@"struct" => |structType| {
|
|
144
|
-
inline for (structType.
|
|
145
|
-
try expectEqual(@field(expected,
|
|
144
|
+
inline for (structType.field_names) |field_name| {
|
|
145
|
+
try expectEqual(@field(expected, field_name), @field(actual, field_name));
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
148
|
|
|
149
149
|
.@"union" => |union_info| {
|
|
150
150
|
if (union_info.tag_type == null) {
|
|
151
|
-
const first_size = @bitSizeOf(union_info.
|
|
152
|
-
inline for (union_info.
|
|
153
|
-
if (@bitSizeOf(
|
|
151
|
+
const first_size = @bitSizeOf(union_info.field_types[0]);
|
|
152
|
+
inline for (union_info.field_types) |field_type| {
|
|
153
|
+
if (@bitSizeOf(field_type) != first_size) {
|
|
154
154
|
@compileError("Unable to compare untagged unions with varying field sizes for type " ++ @typeName(@TypeOf(actual)));
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -840,9 +840,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
|
|
|
840
840
|
},
|
|
841
841
|
|
|
842
842
|
.@"struct" => |structType| {
|
|
843
|
-
inline for (structType.
|
|
844
|
-
expectEqualDeep(@field(expected,
|
|
845
|
-
print("Field {s} incorrect. expected {any}, found {any}\n", .{
|
|
843
|
+
inline for (structType.field_names) |field_name| {
|
|
844
|
+
expectEqualDeep(@field(expected, field_name), @field(actual, field_name)) catch |e| {
|
|
845
|
+
print("Field {s} incorrect. expected {any}, found {any}\n", .{ field_name, @field(expected, field_name), @field(actual, field_name) });
|
|
846
846
|
return e;
|
|
847
847
|
};
|
|
848
848
|
}
|
|
@@ -1165,14 +1165,14 @@ fn CheckAllAllocationFailuresExtraArgs(comptime TestFn: type) type {
|
|
|
1165
1165
|
|
|
1166
1166
|
const ArgsTuple = std.meta.ArgsTuple(TestFn);
|
|
1167
1167
|
|
|
1168
|
-
const
|
|
1169
|
-
if (
|
|
1168
|
+
const field_types = @typeInfo(ArgsTuple).@"struct".field_types;
|
|
1169
|
+
if (field_types.len == 0 or field_types[0] != std.mem.Allocator) {
|
|
1170
1170
|
@compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");
|
|
1171
1171
|
}
|
|
1172
1172
|
|
|
1173
|
-
var extra_args: [
|
|
1174
|
-
for (&extra_args,
|
|
1175
|
-
arg.* =
|
|
1173
|
+
var extra_args: [field_types.len - 1]type = undefined;
|
|
1174
|
+
for (&extra_args, field_types[1..]) |*arg, field_type| {
|
|
1175
|
+
arg.* = field_type;
|
|
1176
1176
|
}
|
|
1177
1177
|
|
|
1178
1178
|
return @Tuple(&extra_args);
|
|
@@ -1204,8 +1204,8 @@ test "checkAllAllocationFailures provide result type to 'extra_args' argument" {
|
|
|
1204
1204
|
/// Given a type, references all the declarations inside, so that the semantic analyzer sees them.
|
|
1205
1205
|
pub fn refAllDecls(comptime T: type) void {
|
|
1206
1206
|
if (!builtin.is_test) return;
|
|
1207
|
-
inline for (comptime std.meta.declarations(T)) |
|
|
1208
|
-
_ = &@field(T,
|
|
1207
|
+
inline for (comptime std.meta.declarations(T)) |decl_name| {
|
|
1208
|
+
_ = &@field(T, decl_name);
|
|
1209
1209
|
}
|
|
1210
1210
|
}
|
|
1211
1211
|
|
package/std/zig/Ast.zig
CHANGED
|
@@ -298,17 +298,17 @@ pub fn extraDataSliceWithLen(tree: Ast, start: ExtraIndex, len: u32, comptime T:
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
pub fn extraData(tree: Ast, index: ExtraIndex, comptime T: type) T {
|
|
301
|
-
const
|
|
301
|
+
const info = @typeInfo(T).@"struct";
|
|
302
302
|
var result: T = undefined;
|
|
303
|
-
inline for (
|
|
304
|
-
@field(result,
|
|
303
|
+
inline for (info.field_names, info.field_types, 0..) |field_name, field_type, i| {
|
|
304
|
+
@field(result, field_name) = switch (field_type) {
|
|
305
305
|
Node.Index,
|
|
306
306
|
Node.OptionalIndex,
|
|
307
307
|
OptionalTokenIndex,
|
|
308
308
|
ExtraIndex,
|
|
309
309
|
=> @enumFromInt(tree.extra_data[@intFromEnum(index) + i]),
|
|
310
310
|
TokenIndex => tree.extra_data[@intFromEnum(index) + i],
|
|
311
|
-
else => @compileError("unexpected field type: " ++ @typeName(
|
|
311
|
+
else => @compileError("unexpected field type: " ++ @typeName(field_type)),
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
314
|
return result;
|
package/std/zig/AstGen.zig
CHANGED
|
@@ -74,25 +74,25 @@ src_hasher: std.zig.SrcHasher,
|
|
|
74
74
|
const InnerError = error{ OutOfMemory, AnalysisFail };
|
|
75
75
|
|
|
76
76
|
fn addExtra(astgen: *AstGen, extra: anytype) Allocator.Error!u32 {
|
|
77
|
-
const
|
|
78
|
-
try astgen.extra.ensureUnusedCapacity(astgen.gpa,
|
|
77
|
+
const field_count = std.meta.fieldNames(@TypeOf(extra)).len;
|
|
78
|
+
try astgen.extra.ensureUnusedCapacity(astgen.gpa, field_count);
|
|
79
79
|
return addExtraAssumeCapacity(astgen, extra);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
fn addExtraAssumeCapacity(astgen: *AstGen, extra: anytype) u32 {
|
|
83
|
-
const
|
|
83
|
+
const field_count = std.meta.fieldNames(@TypeOf(extra)).len;
|
|
84
84
|
const extra_index: u32 = @intCast(astgen.extra.items.len);
|
|
85
|
-
astgen.extra.items.len +=
|
|
85
|
+
astgen.extra.items.len += field_count;
|
|
86
86
|
setExtra(astgen, extra_index, extra);
|
|
87
87
|
return extra_index;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
|
|
91
|
-
const
|
|
91
|
+
const info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
92
92
|
var i = index;
|
|
93
|
-
inline for (
|
|
94
|
-
astgen.extra.items[i] = switch (
|
|
95
|
-
u32 => @field(extra,
|
|
93
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
94
|
+
astgen.extra.items[i] = switch (field_type) {
|
|
95
|
+
u32 => @field(extra, field_name),
|
|
96
96
|
|
|
97
97
|
Zir.Inst.Ref,
|
|
98
98
|
Zir.Inst.Index,
|
|
@@ -103,13 +103,13 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
|
|
|
103
103
|
Ast.OptionalTokenIndex,
|
|
104
104
|
Ast.Node.Index,
|
|
105
105
|
Ast.Node.OptionalIndex,
|
|
106
|
-
=> @intFromEnum(@field(extra,
|
|
106
|
+
=> @intFromEnum(@field(extra, field_name)),
|
|
107
107
|
|
|
108
108
|
Ast.TokenOffset,
|
|
109
109
|
Ast.OptionalTokenOffset,
|
|
110
110
|
Ast.Node.Offset,
|
|
111
111
|
Ast.Node.OptionalOffset,
|
|
112
|
-
=> @bitCast(@intFromEnum(@field(extra,
|
|
112
|
+
=> @bitCast(@intFromEnum(@field(extra, field_name))),
|
|
113
113
|
|
|
114
114
|
i32,
|
|
115
115
|
Zir.Inst.Call.Flags,
|
|
@@ -118,7 +118,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
|
|
|
118
118
|
Zir.Inst.FuncFancy.Bits,
|
|
119
119
|
Zir.Inst.Param.Type,
|
|
120
120
|
Zir.Inst.Func.RetTy,
|
|
121
|
-
=> @bitCast(@field(extra,
|
|
121
|
+
=> @bitCast(@field(extra, field_name)),
|
|
122
122
|
|
|
123
123
|
else => @compileError("bad field type"),
|
|
124
124
|
};
|
|
@@ -166,7 +166,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
|
|
|
166
166
|
try astgen.instructions.ensureTotalCapacity(gpa, tree.nodes.len);
|
|
167
167
|
|
|
168
168
|
// First few indexes of extra are reserved and set at the end.
|
|
169
|
-
const reserved_count = @typeInfo(Zir.ExtraIndex).@"enum".
|
|
169
|
+
const reserved_count = @typeInfo(Zir.ExtraIndex).@"enum".field_names.len;
|
|
170
170
|
try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count);
|
|
171
171
|
astgen.extra.items.len += reserved_count;
|
|
172
172
|
|
|
@@ -212,7 +212,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
|
|
|
212
212
|
astgen.extra.items[err_index] = 0;
|
|
213
213
|
} else {
|
|
214
214
|
try astgen.extra.ensureUnusedCapacity(gpa, 1 + astgen.compile_errors.items.len *
|
|
215
|
-
@typeInfo(Zir.Inst.CompileErrors.Item).@"struct".
|
|
215
|
+
@typeInfo(Zir.Inst.CompileErrors.Item).@"struct".field_names.len);
|
|
216
216
|
|
|
217
217
|
astgen.extra.items[err_index] = astgen.addExtraAssumeCapacity(Zir.Inst.CompileErrors{
|
|
218
218
|
.items_len = @intCast(astgen.compile_errors.items.len),
|
|
@@ -227,8 +227,8 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
|
|
|
227
227
|
if (astgen.imports.count() == 0) {
|
|
228
228
|
astgen.extra.items[imports_index] = 0;
|
|
229
229
|
} else {
|
|
230
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).@"struct".
|
|
231
|
-
astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).@"struct".
|
|
230
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).@"struct".field_names.len +
|
|
231
|
+
astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).@"struct".field_names.len);
|
|
232
232
|
|
|
233
233
|
astgen.extra.items[imports_index] = astgen.addExtraAssumeCapacity(Zir.Inst.Imports{
|
|
234
234
|
.imports_len = @intCast(astgen.imports.count()),
|
|
@@ -1888,7 +1888,7 @@ fn structInitExprAnon(
|
|
|
1888
1888
|
.abs_line = astgen.source_line,
|
|
1889
1889
|
.fields_len = @intCast(struct_init.ast.fields.len),
|
|
1890
1890
|
});
|
|
1891
|
-
const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).@"struct".
|
|
1891
|
+
const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).@"struct".field_names.len;
|
|
1892
1892
|
var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
|
|
1893
1893
|
|
|
1894
1894
|
for (struct_init.ast.fields) |field_init| {
|
|
@@ -1921,7 +1921,7 @@ fn structInitExprTyped(
|
|
|
1921
1921
|
.abs_line = astgen.source_line,
|
|
1922
1922
|
.fields_len = @intCast(struct_init.ast.fields.len),
|
|
1923
1923
|
});
|
|
1924
|
-
const field_size = @typeInfo(Zir.Inst.StructInit.Item).@"struct".
|
|
1924
|
+
const field_size = @typeInfo(Zir.Inst.StructInit.Item).@"struct".field_names.len;
|
|
1925
1925
|
var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
|
|
1926
1926
|
|
|
1927
1927
|
for (struct_init.ast.fields) |field_init| {
|
|
@@ -3804,7 +3804,7 @@ fn ptrType(
|
|
|
3804
3804
|
const gpa = gz.astgen.gpa;
|
|
3805
3805
|
try gz.instructions.ensureUnusedCapacity(gpa, 1);
|
|
3806
3806
|
try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
|
|
3807
|
-
try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).@"struct".
|
|
3807
|
+
try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).@"struct".field_names.len +
|
|
3808
3808
|
trailing_count);
|
|
3809
3809
|
|
|
3810
3810
|
const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.PtrType{
|
|
@@ -5096,7 +5096,7 @@ fn tupleDecl(
|
|
|
5096
5096
|
|
|
5097
5097
|
const extra_trail = astgen.scratch.items[fields_start..];
|
|
5098
5098
|
assert(extra_trail.len == fields_len * 2);
|
|
5099
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.TupleDecl).@"struct".
|
|
5099
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.TupleDecl).@"struct".field_names.len + extra_trail.len);
|
|
5100
5100
|
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.TupleDecl{
|
|
5101
5101
|
.src_node = gz.nodeIndexToRelative(node),
|
|
5102
5102
|
});
|
|
@@ -5670,7 +5670,7 @@ fn errorSetDecl(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index) InnerError!Zi
|
|
|
5670
5670
|
const gpa = astgen.gpa;
|
|
5671
5671
|
const tree = astgen.tree;
|
|
5672
5672
|
|
|
5673
|
-
const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).@"struct".
|
|
5673
|
+
const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).@"struct".field_names.len);
|
|
5674
5674
|
var fields_len: usize = 0;
|
|
5675
5675
|
{
|
|
5676
5676
|
var idents: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.TokenIndex) = .empty;
|
|
@@ -6332,7 +6332,7 @@ fn setCondBrPayload(
|
|
|
6332
6332
|
const else_body_len = astgen.countBodyLenAfterFixups(else_body);
|
|
6333
6333
|
try astgen.extra.ensureUnusedCapacity(
|
|
6334
6334
|
astgen.gpa,
|
|
6335
|
-
@typeInfo(Zir.Inst.CondBr).@"struct".
|
|
6335
|
+
@typeInfo(Zir.Inst.CondBr).@"struct".field_names.len + then_body_len + else_body_len,
|
|
6336
6336
|
);
|
|
6337
6337
|
|
|
6338
6338
|
const zir_datas = astgen.instructions.items(.data);
|
|
@@ -6761,7 +6761,7 @@ fn forExpr(
|
|
|
6761
6761
|
const len: Zir.Inst.Ref = len: {
|
|
6762
6762
|
const all_lens = @as([*]Zir.Inst.Ref, @ptrCast(lens))[0 .. lens.len * 2];
|
|
6763
6763
|
const lens_len: u32 = @intCast(all_lens.len);
|
|
6764
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).@"struct".
|
|
6764
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).@"struct".field_names.len + lens_len);
|
|
6765
6765
|
const len = try parent_gz.addPlNode(.for_len, node, Zir.Inst.MultiOp{
|
|
6766
6766
|
.operands_len = lens_len,
|
|
6767
6767
|
});
|
|
@@ -7791,7 +7791,7 @@ fn switchExpr(
|
|
|
7791
7791
|
// by copying our bodies from `payloads` to `extra`, this time in the order
|
|
7792
7792
|
// expected by ZIR consumers.
|
|
7793
7793
|
|
|
7794
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).@"struct".
|
|
7794
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).@"struct".field_names.len +
|
|
7795
7795
|
@intFromBool(multi_cases_len > 0) + // multi_cases_len
|
|
7796
7796
|
@intFromBool(payload_capture_inst_is_placeholder) + // payload_capture_placeholder
|
|
7797
7797
|
@intFromBool(tag_capture_inst_is_placeholder) + // tag_capture_placeholder
|
|
@@ -8878,7 +8878,7 @@ fn typeOf(
|
|
|
8878
8878
|
try gz.instructions.append(gpa, typeof_inst);
|
|
8879
8879
|
return rvalue(gz, ri, typeof_inst.toRef(), node);
|
|
8880
8880
|
}
|
|
8881
|
-
const payload_size: u32 =
|
|
8881
|
+
const payload_size: u32 = @typeInfo(Zir.Inst.TypeOfPeer).@"struct".field_names.len;
|
|
8882
8882
|
const payload_index = try reserveExtra(astgen, payload_size + args.len);
|
|
8883
8883
|
const args_index = payload_index + payload_size;
|
|
8884
8884
|
|
|
@@ -11348,7 +11348,7 @@ const GenZir = struct {
|
|
|
11348
11348
|
const body_len = astgen.countBodyLenAfterFixups(body);
|
|
11349
11349
|
try astgen.extra.ensureUnusedCapacity(
|
|
11350
11350
|
gpa,
|
|
11351
|
-
@typeInfo(Zir.Inst.BoolBr).@"struct".
|
|
11351
|
+
@typeInfo(Zir.Inst.BoolBr).@"struct".field_names.len + body_len,
|
|
11352
11352
|
);
|
|
11353
11353
|
const zir_datas = astgen.instructions.items(.data);
|
|
11354
11354
|
zir_datas[@intFromEnum(bool_br)].pl_node.payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.BoolBr{
|
|
@@ -11372,7 +11372,7 @@ const GenZir = struct {
|
|
|
11372
11372
|
|
|
11373
11373
|
try astgen.extra.ensureUnusedCapacity(
|
|
11374
11374
|
gpa,
|
|
11375
|
-
@typeInfo(Zir.Inst.Block).@"struct".
|
|
11375
|
+
@typeInfo(Zir.Inst.Block).@"struct".field_names.len + body_len,
|
|
11376
11376
|
);
|
|
11377
11377
|
const zir_datas = astgen.instructions.items(.data);
|
|
11378
11378
|
zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(
|
|
@@ -11395,7 +11395,7 @@ const GenZir = struct {
|
|
|
11395
11395
|
|
|
11396
11396
|
try astgen.extra.ensureUnusedCapacity(
|
|
11397
11397
|
gpa,
|
|
11398
|
-
@typeInfo(Zir.Inst.BlockComptime).@"struct".
|
|
11398
|
+
@typeInfo(Zir.Inst.BlockComptime).@"struct".field_names.len + body_len,
|
|
11399
11399
|
);
|
|
11400
11400
|
const zir_datas = astgen.instructions.items(.data);
|
|
11401
11401
|
zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(
|
|
@@ -11416,7 +11416,7 @@ const GenZir = struct {
|
|
|
11416
11416
|
const body_len = astgen.countBodyLenAfterFixups(body);
|
|
11417
11417
|
try astgen.extra.ensureUnusedCapacity(
|
|
11418
11418
|
gpa,
|
|
11419
|
-
@typeInfo(Zir.Inst.Try).@"struct".
|
|
11419
|
+
@typeInfo(Zir.Inst.Try).@"struct".field_names.len + body_len,
|
|
11420
11420
|
);
|
|
11421
11421
|
const zir_datas = astgen.instructions.items(.data);
|
|
11422
11422
|
zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(
|
|
@@ -11529,7 +11529,7 @@ const GenZir = struct {
|
|
|
11529
11529
|
inst_info: {
|
|
11530
11530
|
try astgen.extra.ensureUnusedCapacity(
|
|
11531
11531
|
gpa,
|
|
11532
|
-
@typeInfo(Zir.Inst.FuncFancy).@"struct".
|
|
11532
|
+
@typeInfo(Zir.Inst.FuncFancy).@"struct".field_names.len +
|
|
11533
11533
|
fancyFnExprExtraLen(astgen, &.{}, cc_body, args.cc_ref) +
|
|
11534
11534
|
fancyFnExprExtraLen(astgen, args.ret_param_refs, ret_body, ret_ref) +
|
|
11535
11535
|
body_len + src_locs_and_hash.len +
|
|
@@ -11589,7 +11589,7 @@ const GenZir = struct {
|
|
|
11589
11589
|
} else inst_info: {
|
|
11590
11590
|
try astgen.extra.ensureUnusedCapacity(
|
|
11591
11591
|
gpa,
|
|
11592
|
-
@typeInfo(Zir.Inst.Func).@"struct".
|
|
11592
|
+
@typeInfo(Zir.Inst.Func).@"struct".field_names.len + 1 +
|
|
11593
11593
|
fancyFnExprExtraLen(astgen, args.ret_param_refs, ret_body, ret_ref) +
|
|
11594
11594
|
body_len + src_locs_and_hash.len,
|
|
11595
11595
|
);
|
|
@@ -11777,7 +11777,7 @@ const GenZir = struct {
|
|
|
11777
11777
|
const param_body = param_gz.instructionsSlice();
|
|
11778
11778
|
const body_len = gz.astgen.countBodyLenAfterFixupsExtraRefs(param_body, prev_param_insts);
|
|
11779
11779
|
try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
|
|
11780
|
-
try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).@"struct".
|
|
11780
|
+
try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).@"struct".field_names.len + body_len);
|
|
11781
11781
|
|
|
11782
11782
|
const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Param{
|
|
11783
11783
|
.name = name,
|
|
@@ -11847,7 +11847,7 @@ const GenZir = struct {
|
|
|
11847
11847
|
try astgen.instructions.ensureUnusedCapacity(gpa, 1);
|
|
11848
11848
|
try astgen.extra.ensureUnusedCapacity(
|
|
11849
11849
|
gpa,
|
|
11850
|
-
@typeInfo(Zir.Inst.NodeMultiOp).@"struct".
|
|
11850
|
+
@typeInfo(Zir.Inst.NodeMultiOp).@"struct".field_names.len + operands.len,
|
|
11851
11851
|
);
|
|
11852
11852
|
|
|
11853
11853
|
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.NodeMultiOp{
|
|
@@ -12088,7 +12088,7 @@ const GenZir = struct {
|
|
|
12088
12088
|
) !Zir.Inst.Index {
|
|
12089
12089
|
const gpa = gz.astgen.gpa;
|
|
12090
12090
|
try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
|
|
12091
|
-
try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).@"struct".
|
|
12091
|
+
try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).@"struct".field_names.len);
|
|
12092
12092
|
|
|
12093
12093
|
const new_index: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len);
|
|
12094
12094
|
gz.astgen.instructions.appendAssumeCapacity(.{
|
|
@@ -12211,7 +12211,7 @@ const GenZir = struct {
|
|
|
12211
12211
|
try astgen.instructions.ensureUnusedCapacity(gpa, 1);
|
|
12212
12212
|
try astgen.extra.ensureUnusedCapacity(
|
|
12213
12213
|
gpa,
|
|
12214
|
-
@typeInfo(Zir.Inst.AllocExtended).@"struct".
|
|
12214
|
+
@typeInfo(Zir.Inst.AllocExtended).@"struct".field_names.len +
|
|
12215
12215
|
@intFromBool(args.type_inst != .none) +
|
|
12216
12216
|
@intFromBool(args.align_inst != .none),
|
|
12217
12217
|
);
|
|
@@ -12263,9 +12263,9 @@ const GenZir = struct {
|
|
|
12263
12263
|
|
|
12264
12264
|
try gz.instructions.ensureUnusedCapacity(gpa, 1);
|
|
12265
12265
|
try astgen.instructions.ensureUnusedCapacity(gpa, 1);
|
|
12266
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".
|
|
12267
|
-
args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".
|
|
12268
|
-
args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".
|
|
12266
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".field_names.len +
|
|
12267
|
+
args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".field_names.len +
|
|
12268
|
+
args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".field_names.len);
|
|
12269
12269
|
|
|
12270
12270
|
const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{
|
|
12271
12271
|
.src_node = gz.nodeIndexToRelative(args.node),
|
|
@@ -12374,7 +12374,7 @@ const GenZir = struct {
|
|
|
12374
12374
|
|
|
12375
12375
|
const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
|
|
12376
12376
|
|
|
12377
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).@"struct".
|
|
12377
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).@"struct".field_names.len +
|
|
12378
12378
|
4 + // `captures_len`, `decls_len`, `fields_len`, `backing_int_type_body_len`
|
|
12379
12379
|
captures_len * 2 + // `capture`, `capture_name`
|
|
12380
12380
|
args.remaining.len);
|
|
@@ -12441,7 +12441,7 @@ const GenZir = struct {
|
|
|
12441
12441
|
|
|
12442
12442
|
const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
|
|
12443
12443
|
|
|
12444
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).@"struct".
|
|
12444
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).@"struct".field_names.len +
|
|
12445
12445
|
4 + // `captures_len`, `decls_len`, `fields_len`, `arg_type_body_len`
|
|
12446
12446
|
captures_len * 2 + // `capture`, `capture_name`
|
|
12447
12447
|
args.remaining.len);
|
|
@@ -12509,7 +12509,7 @@ const GenZir = struct {
|
|
|
12509
12509
|
|
|
12510
12510
|
const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
|
|
12511
12511
|
|
|
12512
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).@"struct".
|
|
12512
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).@"struct".field_names.len +
|
|
12513
12513
|
4 + // `captures_len`, `decls_len`, `fields_len`, `tag_type_body_len`
|
|
12514
12514
|
captures_len * 2 + // `capture`, `capture_name`
|
|
12515
12515
|
args.remaining.len);
|
|
@@ -12565,7 +12565,7 @@ const GenZir = struct {
|
|
|
12565
12565
|
const captures_len: u32 = @intCast(args.captures.len);
|
|
12566
12566
|
assert(args.capture_names.len == captures_len);
|
|
12567
12567
|
|
|
12568
|
-
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).@"struct".
|
|
12568
|
+
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).@"struct".field_names.len +
|
|
12569
12569
|
2 + // `captures_len`, `decls_len`
|
|
12570
12570
|
captures_len * 2 + // `capture`, `capture_name`
|
|
12571
12571
|
args.decls.len);
|
|
@@ -13465,7 +13465,7 @@ fn setDeclaration(
|
|
|
13465
13465
|
const flags_arr: [2]u32 = @bitCast(flags);
|
|
13466
13466
|
|
|
13467
13467
|
const need_extra: usize =
|
|
13468
|
-
@typeInfo(Zir.Inst.Declaration).@"struct".
|
|
13468
|
+
@typeInfo(Zir.Inst.Declaration).@"struct".field_names.len +
|
|
13469
13469
|
@as(usize, @intFromBool(id.hasName())) +
|
|
13470
13470
|
@as(usize, @intFromBool(id.hasLibName())) +
|
|
13471
13471
|
@as(usize, @intFromBool(id.hasTypeBody())) +
|
package/std/zig/ErrorBundle.zig
CHANGED
|
@@ -117,7 +117,7 @@ pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLoca
|
|
|
117
117
|
|
|
118
118
|
pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex {
|
|
119
119
|
const notes_len = eb.getErrorMessage(index).notes_len;
|
|
120
|
-
const start = @intFromEnum(index) + @typeInfo(ErrorMessage).@"struct".
|
|
120
|
+
const start = @intFromEnum(index) + @typeInfo(ErrorMessage).@"struct".field_names.len;
|
|
121
121
|
return @as([]const MessageIndex, @ptrCast(eb.extra[start..][0..notes_len]));
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -128,11 +128,12 @@ pub fn getCompileLogOutput(eb: ErrorBundle) [:0]const u8 {
|
|
|
128
128
|
/// Returns the requested data, as well as the new index which is at the start of the
|
|
129
129
|
/// trailers for the object.
|
|
130
130
|
fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, end: usize } {
|
|
131
|
-
const
|
|
131
|
+
const field_names = @typeInfo(T).@"struct".field_names;
|
|
132
|
+
const field_types = @typeInfo(T).@"struct".field_types;
|
|
132
133
|
var i: usize = index;
|
|
133
134
|
var result: T = undefined;
|
|
134
|
-
inline for (
|
|
135
|
-
@field(result,
|
|
135
|
+
inline for (field_names, field_types) |field_name, field_type| {
|
|
136
|
+
@field(result, field_name) = switch (field_type) {
|
|
136
137
|
u32 => eb.extra[i],
|
|
137
138
|
MessageIndex => @as(MessageIndex, @enumFromInt(eb.extra[i])),
|
|
138
139
|
SourceLocationIndex => @as(SourceLocationIndex, @enumFromInt(eb.extra[i])),
|
|
@@ -498,7 +499,7 @@ pub const Wip = struct {
|
|
|
498
499
|
|
|
499
500
|
pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 {
|
|
500
501
|
try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len +
|
|
501
|
-
notes_len * @typeInfo(ErrorBundle.ErrorMessage).@"struct".
|
|
502
|
+
notes_len * @typeInfo(ErrorBundle.ErrorMessage).@"struct".field_names.len);
|
|
502
503
|
wip.extra.items.len += notes_len;
|
|
503
504
|
return @intCast(wip.extra.items.len - notes_len);
|
|
504
505
|
}
|
|
@@ -731,13 +732,13 @@ pub const Wip = struct {
|
|
|
731
732
|
|
|
732
733
|
fn addExtra(wip: *Wip, extra: anytype) Allocator.Error!u32 {
|
|
733
734
|
const gpa = wip.gpa;
|
|
734
|
-
const fields = @typeInfo(@TypeOf(extra)).@"struct".
|
|
735
|
+
const fields = @typeInfo(@TypeOf(extra)).@"struct".field_names;
|
|
735
736
|
try wip.extra.ensureUnusedCapacity(gpa, fields.len);
|
|
736
737
|
return addExtraAssumeCapacity(wip, extra);
|
|
737
738
|
}
|
|
738
739
|
|
|
739
740
|
fn addExtraAssumeCapacity(wip: *Wip, extra: anytype) u32 {
|
|
740
|
-
const fields = @typeInfo(@TypeOf(extra)).@"struct".
|
|
741
|
+
const fields = @typeInfo(@TypeOf(extra)).@"struct".field_names;
|
|
741
742
|
const result: u32 = @intCast(wip.extra.items.len);
|
|
742
743
|
wip.extra.items.len += fields.len;
|
|
743
744
|
setExtra(wip, result, extra);
|
|
@@ -745,13 +746,15 @@ pub const Wip = struct {
|
|
|
745
746
|
}
|
|
746
747
|
|
|
747
748
|
fn setExtra(wip: *Wip, index: usize, extra: anytype) void {
|
|
748
|
-
const
|
|
749
|
+
const extra_info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
750
|
+
const field_names = extra_info.field_names;
|
|
751
|
+
const field_types = extra_info.field_types;
|
|
749
752
|
var i = index;
|
|
750
|
-
inline for (
|
|
751
|
-
wip.extra.items[i] = switch (
|
|
752
|
-
u32 => @field(extra,
|
|
753
|
-
MessageIndex => @intFromEnum(@field(extra,
|
|
754
|
-
SourceLocationIndex => @intFromEnum(@field(extra,
|
|
753
|
+
inline for (field_names, field_types) |field_name, field_type| {
|
|
754
|
+
wip.extra.items[i] = switch (field_type) {
|
|
755
|
+
u32 => @field(extra, field_name),
|
|
756
|
+
MessageIndex => @intFromEnum(@field(extra, field_name)),
|
|
757
|
+
SourceLocationIndex => @intFromEnum(@field(extra, field_name)),
|
|
755
758
|
else => @compileError("bad field type"),
|
|
756
759
|
};
|
|
757
760
|
i += 1;
|
|
@@ -43,12 +43,13 @@ pub const FindError = error{
|
|
|
43
43
|
pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const std.Target) !LibCInstallation {
|
|
44
44
|
var self: LibCInstallation = .{};
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const field_names = comptime std.meta.fieldNames(LibCInstallation);
|
|
47
47
|
const FoundKey = struct {
|
|
48
48
|
found: bool,
|
|
49
49
|
allocated: ?[:0]u8,
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
var found_keys: [field_names.len]FoundKey = @splat(.{ .found = false, .allocated = null });
|
|
52
53
|
errdefer {
|
|
53
54
|
self = .{};
|
|
54
55
|
for (found_keys) |found_key| {
|
|
@@ -65,22 +66,22 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
|
|
|
65
66
|
var line_it = std.mem.splitScalar(u8, line, '=');
|
|
66
67
|
const name = line_it.first();
|
|
67
68
|
const value = line_it.rest();
|
|
68
|
-
inline for (
|
|
69
|
-
if (std.mem.eql(u8, name,
|
|
69
|
+
inline for (field_names, 0..) |field_name, i| {
|
|
70
|
+
if (std.mem.eql(u8, name, field_name)) {
|
|
70
71
|
found_keys[i].found = true;
|
|
71
72
|
if (value.len == 0) {
|
|
72
|
-
@field(self,
|
|
73
|
+
@field(self, field_name) = null;
|
|
73
74
|
} else {
|
|
74
75
|
found_keys[i].allocated = try allocator.dupeSentinel(u8, value, 0);
|
|
75
|
-
@field(self,
|
|
76
|
+
@field(self, field_name) = found_keys[i].allocated;
|
|
76
77
|
}
|
|
77
78
|
break;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
inline for (
|
|
82
|
+
inline for (field_names, 0..) |field_name, i| {
|
|
82
83
|
if (!found_keys[i].found) {
|
|
83
|
-
log.err("missing field: {s}", .{
|
|
84
|
+
log.err("missing field: {s}", .{field_name});
|
|
84
85
|
return error.ParseError;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
@@ -235,9 +236,8 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
|
|
|
235
236
|
|
|
236
237
|
/// Must be the same allocator passed to `parse` or `findNative`.
|
|
237
238
|
pub fn deinit(self: *LibCInstallation, allocator: Allocator) void {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (@field(self, field.name)) |payload| {
|
|
239
|
+
inline for (@typeInfo(LibCInstallation).@"struct".field_names) |field_name| {
|
|
240
|
+
if (@field(self, field_name)) |payload| {
|
|
241
241
|
allocator.free(payload);
|
|
242
242
|
}
|
|
243
243
|
}
|
package/std/zig/Parse.zig
CHANGED
|
@@ -89,18 +89,18 @@ fn unreserveNode(p: *Parse, node_index: usize) void {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
fn addExtra(p: *Parse, extra: anytype) Allocator.Error!ExtraIndex {
|
|
92
|
-
const
|
|
93
|
-
try p.extra_data.ensureUnusedCapacity(p.gpa,
|
|
92
|
+
const info = @typeInfo(@TypeOf(extra)).@"struct";
|
|
93
|
+
try p.extra_data.ensureUnusedCapacity(p.gpa, info.field_names.len);
|
|
94
94
|
const result: ExtraIndex = @enumFromInt(p.extra_data.items.len);
|
|
95
|
-
inline for (
|
|
96
|
-
const data: u32 = switch (
|
|
95
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
96
|
+
const data: u32 = switch (field_type) {
|
|
97
97
|
Node.Index,
|
|
98
98
|
Node.OptionalIndex,
|
|
99
99
|
OptionalTokenIndex,
|
|
100
100
|
ExtraIndex,
|
|
101
|
-
=> @intFromEnum(@field(extra,
|
|
101
|
+
=> @intFromEnum(@field(extra, field_name)),
|
|
102
102
|
TokenIndex,
|
|
103
|
-
=> @field(extra,
|
|
103
|
+
=> @field(extra, field_name),
|
|
104
104
|
else => @compileError("unexpected field type"),
|
|
105
105
|
};
|
|
106
106
|
p.extra_data.appendAssumeCapacity(data);
|
package/std/zig/Zir.zig
CHANGED
|
@@ -68,11 +68,11 @@ fn ExtraData(comptime T: type) type {
|
|
|
68
68
|
/// Returns the requested data, as well as the new index which is at the start of the
|
|
69
69
|
/// trailers for the object.
|
|
70
70
|
pub fn extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) {
|
|
71
|
-
const
|
|
71
|
+
const info = @typeInfo(T).@"struct";
|
|
72
72
|
var i: usize = index;
|
|
73
73
|
var result: T = undefined;
|
|
74
|
-
inline for (
|
|
75
|
-
@field(result,
|
|
74
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
75
|
+
@field(result, field_name) = switch (field_type) {
|
|
76
76
|
u32 => code.extra[i],
|
|
77
77
|
|
|
78
78
|
Inst.Ref,
|
|
@@ -1877,7 +1877,7 @@ pub const Inst = struct {
|
|
|
1877
1877
|
|
|
1878
1878
|
// Uncomment to view how many tag slots are available.
|
|
1879
1879
|
//comptime {
|
|
1880
|
-
// @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).@"enum".
|
|
1880
|
+
// @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).@"enum".field_names.len);
|
|
1881
1881
|
//}
|
|
1882
1882
|
};
|
|
1883
1883
|
|
|
@@ -2325,7 +2325,7 @@ pub const Inst = struct {
|
|
|
2325
2325
|
|
|
2326
2326
|
_,
|
|
2327
2327
|
|
|
2328
|
-
pub const static_len = @typeInfo(@This()).@"enum".
|
|
2328
|
+
pub const static_len = @typeInfo(@This()).@"enum".field_names.len - 1;
|
|
2329
2329
|
|
|
2330
2330
|
pub fn toIndex(inst: Ref) ?Index {
|
|
2331
2331
|
assert(inst != .none);
|
|
@@ -3186,7 +3186,7 @@ pub const Inst = struct {
|
|
|
3186
3186
|
|
|
3187
3187
|
pub const ReifySliceArgInfo = enum(u16) {
|
|
3188
3188
|
/// Input element type is `type`.
|
|
3189
|
-
/// Output element type is `std.lang.Type.Fn.
|
|
3189
|
+
/// Output element type is `std.lang.Type.Fn.ParamAttributes`.
|
|
3190
3190
|
type_to_fn_param_attrs,
|
|
3191
3191
|
/// Input element type is `[]const u8`.
|
|
3192
3192
|
/// Output element type is `type`.
|
|
@@ -3194,10 +3194,10 @@ pub const Inst = struct {
|
|
|
3194
3194
|
/// Identical to `string_to_struct_field_type` aside from emitting slightly different error messages.
|
|
3195
3195
|
string_to_union_field_type,
|
|
3196
3196
|
/// Input element type is `[]const u8`.
|
|
3197
|
-
/// Output element type is `std.lang.Type.
|
|
3197
|
+
/// Output element type is `std.lang.Type.Struct.FieldAttributes`.
|
|
3198
3198
|
string_to_struct_field_attrs,
|
|
3199
3199
|
/// Input element type is `[]const u8`.
|
|
3200
|
-
/// Output element type is `std.lang.Type.
|
|
3200
|
+
/// Output element type is `std.lang.Type.Union.FieldAttributes`.
|
|
3201
3201
|
string_to_union_field_attrs,
|
|
3202
3202
|
};
|
|
3203
3203
|
|
|
@@ -4842,7 +4842,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {
|
|
|
4842
4842
|
const extra_index = extra.end +
|
|
4843
4843
|
extra.data.ret_ty.body_len +
|
|
4844
4844
|
extra.data.body_len +
|
|
4845
|
-
@typeInfo(Inst.Func.SrcLocs).@"struct".
|
|
4845
|
+
@typeInfo(Inst.Func.SrcLocs).@"struct".field_names.len;
|
|
4846
4846
|
return @bitCast([4]u32{
|
|
4847
4847
|
zir.extra[extra_index + 0],
|
|
4848
4848
|
zir.extra[extra_index + 1],
|
|
@@ -4869,7 +4869,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {
|
|
|
4869
4869
|
} else extra_index += @intFromBool(bits.has_ret_ty_ref);
|
|
4870
4870
|
extra_index += @intFromBool(bits.has_any_noalias);
|
|
4871
4871
|
extra_index += extra.data.body_len;
|
|
4872
|
-
extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).@"struct".
|
|
4872
|
+
extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).@"struct".field_names.len;
|
|
4873
4873
|
return @bitCast([4]u32{
|
|
4874
4874
|
zir.extra[extra_index + 0],
|
|
4875
4875
|
zir.extra[extra_index + 1],
|
|
@@ -199,8 +199,8 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {
|
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
201
|
.@"union" => |info| {
|
|
202
|
-
inline for (info.
|
|
203
|
-
if (
|
|
202
|
+
inline for (info.field_names, info.field_types) |field_name, field_type| {
|
|
203
|
+
if (field_type == SourceType) return @unionInit(DestType, field_name, target);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
@compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union");
|