| author | |
| committer | |
| log | 0b786059b5c2549acc8824857a5bdc3b13956272 |
| tree | b24f5733d98e93c286980748594f7e5d3d675a6c |
| parent | 2319d62f21e4cdcf4575d1512cb8058dd03fd6b4 |
| signature |
Using `@FieldType` (#21702).3 files changed, 11 insertions(+), 16 deletions(-)
src/InternPool.zig+3-4| ... | @@ -12243,7 +12243,7 @@ const PackedCallingConvention = packed struct(u18) { | ... | @@ -12243,7 +12243,7 @@ const PackedCallingConvention = packed struct(u18) { |
| 12243 | std.builtin.CallingConvention.RiscvInterruptOptions => .{ | 12243 | std.builtin.CallingConvention.RiscvInterruptOptions => .{ |
| 12244 | .tag = tag, | 12244 | .tag = tag, |
| 12245 | .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0), | 12245 | .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0), |
| 12246 | .extra = @intFromEnum(pl.level), | 12246 | .extra = @intFromEnum(pl.mode), |
| 12247 | }, | 12247 | }, |
| 12248 | else => comptime unreachable, | 12248 | else => comptime unreachable, |
| 12249 | }, | 12249 | }, |
| ... | @@ -12251,12 +12251,11 @@ const PackedCallingConvention = packed struct(u18) { | ... | @@ -12251,12 +12251,11 @@ const PackedCallingConvention = packed struct(u18) { |
| 12251 | } | 12251 | } |
| 12252 | 12252 | ||
| 12253 | fn unpack(cc: PackedCallingConvention) std.builtin.CallingConvention { | 12253 | fn unpack(cc: PackedCallingConvention) std.builtin.CallingConvention { |
| 12254 | @setEvalBranchQuota(400_000); | ||
| 12255 | return switch (cc.tag) { | 12254 | return switch (cc.tag) { |
| 12256 | inline else => |tag| @unionInit( | 12255 | inline else => |tag| @unionInit( |
| 12257 | std.builtin.CallingConvention, | 12256 | std.builtin.CallingConvention, |
| 12258 | @tagName(tag), | 12257 | @tagName(tag), |
| 12259 | switch (std.meta.FieldType(std.builtin.CallingConvention, tag)) { | 12258 | switch (@FieldType(std.builtin.CallingConvention, @tagName(tag))) { |
| 12260 | void => {}, | 12259 | void => {}, |
| 12261 | std.builtin.CallingConvention.CommonOptions => .{ | 12260 | std.builtin.CallingConvention.CommonOptions => .{ |
| 12262 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), | 12261 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), |
| ... | @@ -12275,7 +12274,7 @@ const PackedCallingConvention = packed struct(u18) { | ... | @@ -12275,7 +12274,7 @@ const PackedCallingConvention = packed struct(u18) { |
| 12275 | }, | 12274 | }, |
| 12276 | std.builtin.CallingConvention.RiscvInterruptOptions => .{ | 12275 | std.builtin.CallingConvention.RiscvInterruptOptions => .{ |
| 12277 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), | 12276 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), |
| 12278 | .level = @enumFromInt(cc.extra), | 12277 | .mode = @enumFromInt(cc.extra), |
| 12279 | }, | 12278 | }, |
| 12280 | else => comptime unreachable, | 12279 | else => comptime unreachable, |
| 12281 | }, | 12280 | }, |
src/Sema.zig+1-1| ... | @@ -31348,7 +31348,7 @@ fn callconvCoerceAllowed( | ... | @@ -31348,7 +31348,7 @@ fn callconvCoerceAllowed( |
| 31348 | if (src_data.mode != dest_data.mode) return false; | 31348 | if (src_data.mode != dest_data.mode) return false; |
| 31349 | }, | 31349 | }, |
| 31350 | std.builtin.CallingConvention.RiscvInterruptOptions => { | 31350 | std.builtin.CallingConvention.RiscvInterruptOptions => { |
| 31351 | if (src_data.level != dest_data.level) return false; | 31351 | if (src_data.mode != dest_data.mode) return false; |
| 31352 | }, | 31352 | }, |
| 31353 | else => comptime unreachable, | 31353 | else => comptime unreachable, |
| 31354 | } | 31354 | } |
src/Value.zig+7-11| ... | @@ -4495,8 +4495,6 @@ pub fn resolveLazy( | ... | @@ -4495,8 +4495,6 @@ pub fn resolveLazy( |
| 4495 | /// This is useful for accessing `std.builtin` structures received from comptime logic. | 4495 | /// This is useful for accessing `std.builtin` structures received from comptime logic. |
| 4496 | /// `val` must be fully resolved. | 4496 | /// `val` must be fully resolved. |
| 4497 | pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMemory, UndefinedValue, TypeMismatch }!T { | 4497 | pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMemory, UndefinedValue, TypeMismatch }!T { |
| 4498 | @setEvalBranchQuota(400_000); | ||
| 4499 | |||
| 4500 | const zcu = pt.zcu; | 4498 | const zcu = pt.zcu; |
| 4501 | const ip = &zcu.intern_pool; | 4499 | const ip = &zcu.intern_pool; |
| 4502 | const ty = val.typeOf(zcu); | 4500 | const ty = val.typeOf(zcu); |
| ... | @@ -4552,13 +4550,13 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe | ... | @@ -4552,13 +4550,13 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe |
| 4552 | if (union_obj.field_types.len != @"union".fields.len) return error.TypeMismatch; | 4550 | if (union_obj.field_types.len != @"union".fields.len) return error.TypeMismatch; |
| 4553 | const tag_val = val.unionTag(zcu) orelse return error.TypeMismatch; | 4551 | const tag_val = val.unionTag(zcu) orelse return error.TypeMismatch; |
| 4554 | const tag = try tag_val.interpret(@"union".tag_type.?, pt); | 4552 | const tag = try tag_val.interpret(@"union".tag_type.?, pt); |
| 4555 | switch (tag) { | 4553 | return switch (tag) { |
| 4556 | inline else => |tag_comptime| { | 4554 | inline else => |tag_comptime| @unionInit( |
| 4557 | const Payload = std.meta.FieldType(T, tag_comptime); | 4555 | T, |
| 4558 | const payload = try val.unionValue(zcu).interpret(Payload, pt); | 4556 | @tagName(tag_comptime), |
| 4559 | return @unionInit(T, @tagName(tag_comptime), payload); | 4557 | try val.unionValue(zcu).interpret(@FieldType(T, @tagName(tag_comptime)), pt), |
| 4560 | }, | 4558 | ), |
| 4561 | } | 4559 | }; |
| 4562 | }, | 4560 | }, |
| 4563 | 4561 | ||
| 4564 | .@"struct" => |@"struct"| { | 4562 | .@"struct" => |@"struct"| { |
| ... | @@ -4577,8 +4575,6 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe | ... | @@ -4577,8 +4575,6 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe |
| 4577 | /// within the compilation. This is useful for passing `std.builtin` structures in the compiler back to the compilation. | 4575 | /// within the compilation. This is useful for passing `std.builtin` structures in the compiler back to the compilation. |
| 4578 | /// This is the inverse of `interpret`. | 4576 | /// This is the inverse of `interpret`. |
| 4579 | pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory, TypeMismatch }!Value { | 4577 | pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory, TypeMismatch }!Value { |
| 4580 | @setEvalBranchQuota(400_000); | ||
| 4581 | |||
| 4582 | const T = @TypeOf(val); | 4578 | const T = @TypeOf(val); |
| 4583 | 4579 | ||
| 4584 | const zcu = pt.zcu; | 4580 | const zcu = pt.zcu; |