| author | |
| committer | |
| log | 31fef6f1103ea64a899729adea13b0ab9b66cb46 |
| tree | 31c13b06483af84cd0977be8de00d3539e3e3c4d |
| parent | 9a12905a2da045b0948f612583b526bca3a1b2f0 |
| parent | aaa7e739831f39151a37c7beb08660f0fb6ae0ed |
| signature |
std: update `std.builtin.Type` fields to follow naming conventions336 files changed, 4119 insertions(+), 4118 deletions(-)
doc/langref.html.in+12-12| ... | ... | @@ -4299,7 +4299,7 @@ comptime { |
| 4299 | 4299 | Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}. |
| 4300 | 4300 | </p> |
| 4301 | 4301 | <p> |
| 4302 | Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this. | |
| 4302 | Asserts that {#syntax#}@typeInfo(DestType) != .pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this. | |
| 4303 | 4303 | </p> |
| 4304 | 4304 | <p> |
| 4305 | 4305 | Can be used for these things for example: |
| ... | ... | @@ -4517,7 +4517,7 @@ comptime { |
| 4517 | 4517 | {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, |
| 4518 | 4518 | an integer or an enum. |
| 4519 | 4519 | </p> |
| 4520 | <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> | |
| 4520 | <p>{#syntax#}@typeInfo(@TypeOf(ptr)).pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> | |
| 4521 | 4521 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 4522 | 4522 | {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak#} |
| 4523 | 4523 | {#header_close#} |
| ... | ... | @@ -4549,7 +4549,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 4549 | 4549 | {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, |
| 4550 | 4550 | an integer or an enum. |
| 4551 | 4551 | </p> |
| 4552 | <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> | |
| 4552 | <p>{#syntax#}@typeInfo(@TypeOf(ptr)).pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> | |
| 4553 | 4553 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 4554 | 4554 | {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgStrong#} |
| 4555 | 4555 | {#header_close#} |
| ... | ... | @@ -4672,7 +4672,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 4672 | 4672 | <p> |
| 4673 | 4673 | Floored division. Rounds toward negative infinity. For unsigned integers it is |
| 4674 | 4674 | the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and |
| 4675 | {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}. | |
| 4675 | {#syntax#}!(@typeInfo(T) == .int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}. | |
| 4676 | 4676 | </p> |
| 4677 | 4677 | <ul> |
| 4678 | 4678 | <li>{#syntax#}@divFloor(-5, 3) == -2{#endsyntax#}</li> |
| ... | ... | @@ -4686,7 +4686,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 4686 | 4686 | <p> |
| 4687 | 4687 | Truncated division. Rounds toward zero. For unsigned integers it is |
| 4688 | 4688 | the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and |
| 4689 | {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}. | |
| 4689 | {#syntax#}!(@typeInfo(T) == .int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}. | |
| 4690 | 4690 | </p> |
| 4691 | 4691 | <ul> |
| 4692 | 4692 | <li>{#syntax#}@divTrunc(-5, 3) == -1{#endsyntax#}</li> |
| ... | ... | @@ -5320,8 +5320,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5320 | 5320 | any bits that disagree with the resultant sign bit are shifted out. |
| 5321 | 5321 | </p> |
| 5322 | 5322 | <p> |
| 5323 | The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits. | |
| 5324 | This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior. | |
| 5323 | The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).int.bits){#endsyntax#} bits. | |
| 5324 | This is because {#syntax#}shift_amt >= @typeInfo(T).int.bits{#endsyntax#} is undefined behavior. | |
| 5325 | 5325 | </p> |
| 5326 | 5326 | <p> |
| 5327 | 5327 | {#syntax#}comptime_int{#endsyntax#} is modeled as an integer with an infinite number of bits, |
| ... | ... | @@ -5337,8 +5337,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5337 | 5337 | Performs {#syntax#}a << b{#endsyntax#} and returns a tuple with the result and a possible overflow bit. |
| 5338 | 5338 | </p> |
| 5339 | 5339 | <p> |
| 5340 | The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(@TypeOf(a)).Int.bits){#endsyntax#} bits. | |
| 5341 | This is because {#syntax#}shift_amt >= @typeInfo(@TypeOf(a)).Int.bits{#endsyntax#} is undefined behavior. | |
| 5340 | The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(@TypeOf(a)).int.bits){#endsyntax#} bits. | |
| 5341 | This is because {#syntax#}shift_amt >= @typeInfo(@TypeOf(a)).int.bits{#endsyntax#} is undefined behavior. | |
| 5342 | 5342 | </p> |
| 5343 | 5343 | {#see_also|@shlExact|@shrExact#} |
| 5344 | 5344 | {#header_close#} |
| ... | ... | @@ -5350,8 +5350,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5350 | 5350 | that the shift will not shift any 1 bits out. |
| 5351 | 5351 | </p> |
| 5352 | 5352 | <p> |
| 5353 | The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits. | |
| 5354 | This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior. | |
| 5353 | The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).int.bits){#endsyntax#} bits. | |
| 5354 | This is because {#syntax#}shift_amt >= @typeInfo(T).int.bits{#endsyntax#} is undefined behavior. | |
| 5355 | 5355 | </p> |
| 5356 | 5356 | {#see_also|@shlExact|@shlWithOverflow#} |
| 5357 | 5357 | {#header_close#} |
| ... | ... | @@ -5405,7 +5405,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5405 | 5405 | This size may contain padding bytes. If there were two consecutive T in memory, the padding would be the offset |
| 5406 | 5406 | in bytes between element at index 0 and the element at index 1. For {#link|integer|Integers#}, |
| 5407 | 5407 | consider whether you want to use {#syntax#}@sizeOf(T){#endsyntax#} or |
| 5408 | {#syntax#}@typeInfo(T).Int.bits{#endsyntax#}. | |
| 5408 | {#syntax#}@typeInfo(T).int.bits{#endsyntax#}. | |
| 5409 | 5409 | </p> |
| 5410 | 5410 | <p> |
| 5411 | 5411 | This function measures the size at runtime. For types that are disallowed at runtime, such as |
doc/langref/inline_prong_range.zig+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | fn isFieldOptional(comptime T: type, field_index: usize) !bool { |
| 2 | const fields = @typeInfo(T).Struct.fields; | |
| 2 | const fields = @typeInfo(T).@"struct".fields; | |
| 3 | 3 | return switch (field_index) { |
| 4 | inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .Optional, | |
| 4 | inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .optional, | |
| 5 | 5 | else => return error.IndexOutOfBounds, |
| 6 | 6 | }; |
| 7 | 7 | } |
doc/langref/poc_printValue_fn.zig+3-3| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | 1 | const Writer = struct { |
| 2 | 2 | pub fn printValue(self: *Writer, value: anytype) !void { |
| 3 | 3 | switch (@typeInfo(@TypeOf(value))) { |
| 4 | .Int => { | |
| 4 | .int => { | |
| 5 | 5 | return self.writeInt(value); |
| 6 | 6 | }, |
| 7 | .Float => { | |
| 7 | .float => { | |
| 8 | 8 | return self.writeFloat(value); |
| 9 | 9 | }, |
| 10 | .Pointer => { | |
| 10 | .pointer => { | |
| 11 | 11 | return self.write(value); |
| 12 | 12 | }, |
| 13 | 13 | else => { |
doc/langref/test_enums.zig+3-3| ... | ... | @@ -95,13 +95,13 @@ const Small = enum { |
| 95 | 95 | four, |
| 96 | 96 | }; |
| 97 | 97 | test "std.meta.Tag" { |
| 98 | try expect(@typeInfo(Small).Enum.tag_type == u2); | |
| 98 | try expect(@typeInfo(Small).@"enum".tag_type == u2); | |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // @typeInfo tells us the field count and the fields names: |
| 102 | 102 | test "@typeInfo" { |
| 103 | try expect(@typeInfo(Small).Enum.fields.len == 4); | |
| 104 | try expect(mem.eql(u8, @typeInfo(Small).Enum.fields[1].name, "two")); | |
| 103 | try expect(@typeInfo(Small).@"enum".fields.len == 4); | |
| 104 | try expect(mem.eql(u8, @typeInfo(Small).@"enum".fields[1].name, "two")); | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // @tagName gives a [:0]const u8 representation of an enum value: |
doc/langref/test_error_union.zig+2-2| ... | ... | @@ -10,10 +10,10 @@ test "error union" { |
| 10 | 10 | foo = error.SomeError; |
| 11 | 11 | |
| 12 | 12 | // Use compile-time reflection to access the payload type of an error union: |
| 13 | try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.payload == i32); | |
| 13 | try comptime expect(@typeInfo(@TypeOf(foo)).error_union.payload == i32); | |
| 14 | 14 | |
| 15 | 15 | // Use compile-time reflection to access the error set type of an error union: |
| 16 | try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.error_set == anyerror); | |
| 16 | try comptime expect(@typeInfo(@TypeOf(foo)).error_union.error_set == anyerror); | |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | // test |
doc/langref/test_fn_reflection.zig+3-3| ... | ... | @@ -3,10 +3,10 @@ const math = std.math; |
| 3 | 3 | const testing = std.testing; |
| 4 | 4 | |
| 5 | 5 | test "fn reflection" { |
| 6 | try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.params[0].type.? == bool); | |
| 7 | try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir); | |
| 6 | try testing.expect(@typeInfo(@TypeOf(testing.expect)).@"fn".params[0].type.? == bool); | |
| 7 | try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).@"fn".return_type.? == testing.TmpDir); | |
| 8 | 8 | |
| 9 | try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic); | |
| 9 | try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).@"fn".is_generic); | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | // test |
doc/langref/test_inline_else.zig+2-2| ... | ... | @@ -17,8 +17,8 @@ const AnySlice = union(enum) { |
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | 19 | fn withFor(any: AnySlice) usize { |
| 20 | const Tag = @typeInfo(AnySlice).Union.tag_type.?; | |
| 21 | inline for (@typeInfo(Tag).Enum.fields) |field| { | |
| 20 | const Tag = @typeInfo(AnySlice).@"union".tag_type.?; | |
| 21 | inline for (@typeInfo(Tag).@"enum".fields) |field| { | |
| 22 | 22 | // With `inline for` the function gets generated as |
| 23 | 23 | // a series of `if` statements relying on the optimizer |
| 24 | 24 | // to convert it to a switch. |
doc/langref/test_inline_switch.zig+2-2| ... | ... | @@ -3,11 +3,11 @@ const expect = std.testing.expect; |
| 3 | 3 | const expectError = std.testing.expectError; |
| 4 | 4 | |
| 5 | 5 | fn isFieldOptional(comptime T: type, field_index: usize) !bool { |
| 6 | const fields = @typeInfo(T).Struct.fields; | |
| 6 | const fields = @typeInfo(T).@"struct".fields; | |
| 7 | 7 | return switch (field_index) { |
| 8 | 8 | // This prong is analyzed twice with `idx` being a |
| 9 | 9 | // comptime-known value each time. |
| 10 | inline 0, 1 => |idx| @typeInfo(fields[idx].type) == .Optional, | |
| 10 | inline 0, 1 => |idx| @typeInfo(fields[idx].type) == .optional, | |
| 11 | 11 | else => return error.IndexOutOfBounds, |
| 12 | 12 | }; |
| 13 | 13 | } |
doc/langref/test_optional_type.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ test "optional type" { |
| 8 | 8 | foo = 1234; |
| 9 | 9 | |
| 10 | 10 | // Use compile-time reflection to access the child type of the optional: |
| 11 | try comptime expect(@typeInfo(@TypeOf(foo)).Optional.child == i32); | |
| 11 | try comptime expect(@typeInfo(@TypeOf(foo)).optional.child == i32); | |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // test |
doc/langref/test_pointer_casting.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ test "pointer casting" { |
| 17 | 17 | |
| 18 | 18 | test "pointer child type" { |
| 19 | 19 | // pointer types have a `child` field which tells you the type they point to. |
| 20 | try expect(@typeInfo(*u32).Pointer.child == u32); | |
| 20 | try expect(@typeInfo(*u32).pointer.child == u32); | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // test |
doc/langref/test_variable_alignment.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ test "variable alignment" { |
| 8 | 8 | try expect(@TypeOf(&x) == *i32); |
| 9 | 9 | try expect(*i32 == *align(align_of_i32) i32); |
| 10 | 10 | if (builtin.target.cpu.arch == .x86_64) { |
| 11 | try expect(@typeInfo(*i32).Pointer.alignment == 4); | |
| 11 | try expect(@typeInfo(*i32).pointer.alignment == 4); | |
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 |
doc/langref/test_variable_func_alignment.zig+1-1| ... | ... | @@ -3,7 +3,7 @@ const expect = @import("std").testing.expect; |
| 3 | 3 | var foo: u8 align(4) = 100; |
| 4 | 4 | |
| 5 | 5 | test "global variable alignment" { |
| 6 | try expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4); | |
| 6 | try expect(@typeInfo(@TypeOf(&foo)).pointer.alignment == 4); | |
| 7 | 7 | try expect(@TypeOf(&foo) == *align(4) u8); |
| 8 | 8 | const as_pointer_to_array: *align(4) [1]u8 = &foo; |
| 9 | 9 | const as_slice: []align(4) u8 = as_pointer_to_array; |
doc/langref/test_variadic_function.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; |
| 5 | 5 | |
| 6 | 6 | test "variadic function" { |
| 7 | 7 | try testing.expect(printf("Hello, world!\n") == 14); |
| 8 | try testing.expect(@typeInfo(@TypeOf(printf)).Fn.is_var_args); | |
| 8 | try testing.expect(@typeInfo(@TypeOf(printf)).@"fn".is_var_args); | |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | // test |
lib/compiler/aro/aro/Attribute.zig+14-14| ... | ... | @@ -67,7 +67,7 @@ pub fn requiredArgCount(attr: Tag) u32 { |
| 67 | 67 | comptime { |
| 68 | 68 | const fields = std.meta.fields(@field(attributes, @tagName(tag))); |
| 69 | 69 | for (fields) |arg_field| { |
| 70 | if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .Optional) needed += 1; | |
| 70 | if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .optional) needed += 1; | |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | return needed; |
| ... | ... | @@ -93,7 +93,7 @@ pub fn maxArgCount(attr: Tag) u32 { |
| 93 | 93 | |
| 94 | 94 | fn UnwrapOptional(comptime T: type) type { |
| 95 | 95 | return switch (@typeInfo(T)) { |
| 96 | .Optional => |optional| optional.child, | |
| 96 | .optional => |optional| optional.child, | |
| 97 | 97 | else => T, |
| 98 | 98 | }; |
| 99 | 99 | } |
| ... | ... | @@ -110,7 +110,7 @@ pub const Formatting = struct { |
| 110 | 110 | |
| 111 | 111 | if (fields.len == 0) unreachable; |
| 112 | 112 | const Unwrapped = UnwrapOptional(fields[0].type); |
| 113 | if (@typeInfo(Unwrapped) != .Enum) unreachable; | |
| 113 | if (@typeInfo(Unwrapped) != .@"enum") unreachable; | |
| 114 | 114 | |
| 115 | 115 | return if (Unwrapped.opts.enum_kind == .identifier) "'" else "\""; |
| 116 | 116 | }, |
| ... | ... | @@ -127,9 +127,9 @@ pub const Formatting = struct { |
| 127 | 127 | |
| 128 | 128 | if (fields.len == 0) unreachable; |
| 129 | 129 | const Unwrapped = UnwrapOptional(fields[0].type); |
| 130 | if (@typeInfo(Unwrapped) != .Enum) unreachable; | |
| 130 | if (@typeInfo(Unwrapped) != .@"enum") unreachable; | |
| 131 | 131 | |
| 132 | const enum_fields = @typeInfo(Unwrapped).Enum.fields; | |
| 132 | const enum_fields = @typeInfo(Unwrapped).@"enum".fields; | |
| 133 | 133 | @setEvalBranchQuota(3000); |
| 134 | 134 | const quote = comptime quoteChar(@enumFromInt(@intFromEnum(tag))); |
| 135 | 135 | comptime var values: []const u8 = quote ++ enum_fields[0].name ++ quote; |
| ... | ... | @@ -152,7 +152,7 @@ pub fn wantsIdentEnum(attr: Tag) bool { |
| 152 | 152 | |
| 153 | 153 | if (fields.len == 0) return false; |
| 154 | 154 | const Unwrapped = UnwrapOptional(fields[0].type); |
| 155 | if (@typeInfo(Unwrapped) != .Enum) return false; | |
| 155 | if (@typeInfo(Unwrapped) != .@"enum") return false; | |
| 156 | 156 | |
| 157 | 157 | return Unwrapped.opts.enum_kind == .identifier; |
| 158 | 158 | }, |
| ... | ... | @@ -165,7 +165,7 @@ pub fn diagnoseIdent(attr: Tag, arguments: *Arguments, ident: []const u8) ?Diagn |
| 165 | 165 | const fields = std.meta.fields(@field(attributes, @tagName(tag))); |
| 166 | 166 | if (fields.len == 0) unreachable; |
| 167 | 167 | const Unwrapped = UnwrapOptional(fields[0].type); |
| 168 | if (@typeInfo(Unwrapped) != .Enum) unreachable; | |
| 168 | if (@typeInfo(Unwrapped) != .@"enum") unreachable; | |
| 169 | 169 | if (std.meta.stringToEnum(Unwrapped, normalize(ident))) |enum_val| { |
| 170 | 170 | @field(@field(arguments, @tagName(tag)), fields[0].name) = enum_val; |
| 171 | 171 | return null; |
| ... | ... | @@ -239,7 +239,7 @@ fn diagnoseField( |
| 239 | 239 | const key = p.comp.interner.get(res.val.ref()); |
| 240 | 240 | switch (key) { |
| 241 | 241 | .int => { |
| 242 | if (@typeInfo(Wanted) == .Int) { | |
| 242 | if (@typeInfo(Wanted) == .int) { | |
| 243 | 243 | @field(@field(arguments, decl.name), field.name) = res.val.toInt(Wanted, p.comp) orelse return .{ |
| 244 | 244 | .tag = .attribute_int_out_of_range, |
| 245 | 245 | .extra = .{ .str = try res.str(p) }, |
| ... | ... | @@ -258,7 +258,7 @@ fn diagnoseField( |
| 258 | 258 | } |
| 259 | 259 | @field(@field(arguments, decl.name), field.name) = try p.removeNull(res.val); |
| 260 | 260 | return null; |
| 261 | } else if (@typeInfo(Wanted) == .Enum and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) { | |
| 261 | } else if (@typeInfo(Wanted) == .@"enum" and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) { | |
| 262 | 262 | const str = bytes[0 .. bytes.len - 1]; |
| 263 | 263 | if (std.meta.stringToEnum(Wanted, str)) |enum_val| { |
| 264 | 264 | @field(@field(arguments, decl.name), field.name) = enum_val; |
| ... | ... | @@ -293,7 +293,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess |
| 293 | 293 | Alignment => .alignment, |
| 294 | 294 | CallingConvention => .identifier, |
| 295 | 295 | else => switch (@typeInfo(Expected)) { |
| 296 | .Enum => if (Expected.opts.enum_kind == .string) .string else .identifier, | |
| 296 | .@"enum" => if (Expected.opts.enum_kind == .string) .string else .identifier, | |
| 297 | 297 | else => unreachable, |
| 298 | 298 | }, |
| 299 | 299 | }, .actual = actual } }, |
| ... | ... | @@ -303,7 +303,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess |
| 303 | 303 | pub fn diagnose(attr: Tag, arguments: *Arguments, arg_idx: u32, res: Parser.Result, node: Tree.Node, p: *Parser) !?Diagnostics.Message { |
| 304 | 304 | switch (attr) { |
| 305 | 305 | inline else => |tag| { |
| 306 | const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)]; | |
| 306 | const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)]; | |
| 307 | 307 | const max_arg_count = comptime maxArgCount(tag); |
| 308 | 308 | if (arg_idx >= max_arg_count) return Diagnostics.Message{ |
| 309 | 309 | .tag = .attribute_too_many_args, |
| ... | ... | @@ -641,7 +641,7 @@ const attributes = struct { |
| 641 | 641 | pub const Tag = std.meta.DeclEnum(attributes); |
| 642 | 642 | |
| 643 | 643 | pub const Arguments = blk: { |
| 644 | const decls = @typeInfo(attributes).Struct.decls; | |
| 644 | const decls = @typeInfo(attributes).@"struct".decls; | |
| 645 | 645 | var union_fields: [decls.len]ZigType.UnionField = undefined; |
| 646 | 646 | for (decls, &union_fields) |decl, *field| { |
| 647 | 647 | field.* = .{ |
| ... | ... | @@ -652,7 +652,7 @@ pub const Arguments = blk: { |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | break :blk @Type(.{ |
| 655 | .Union = .{ | |
| 655 | .@"union" = .{ | |
| 656 | 656 | .layout = .auto, |
| 657 | 657 | .tag_type = null, |
| 658 | 658 | .fields = &union_fields, |
| ... | ... | @@ -662,7 +662,7 @@ pub const Arguments = blk: { |
| 662 | 662 | }; |
| 663 | 663 | |
| 664 | 664 | pub fn ArgumentsForTag(comptime tag: Tag) type { |
| 665 | const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)]; | |
| 665 | const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)]; | |
| 666 | 666 | return @field(attributes, decl.name); |
| 667 | 667 | } |
| 668 | 668 |
lib/compiler/aro/aro/Compilation.zig+2-2| ... | ... | @@ -61,7 +61,7 @@ pub const Environment = struct { |
| 61 | 61 | var env: Environment = .{}; |
| 62 | 62 | errdefer env.deinit(allocator); |
| 63 | 63 | |
| 64 | inline for (@typeInfo(@TypeOf(env)).Struct.fields) |field| { | |
| 64 | inline for (@typeInfo(@TypeOf(env)).@"struct".fields) |field| { | |
| 65 | 65 | std.debug.assert(@field(env, field.name) == null); |
| 66 | 66 | |
| 67 | 67 | var env_var_buf: [field.name.len]u8 = undefined; |
| ... | ... | @@ -78,7 +78,7 @@ pub const Environment = struct { |
| 78 | 78 | |
| 79 | 79 | /// Use this only if environment slices were allocated with `allocator` (such as via `loadAll`) |
| 80 | 80 | pub fn deinit(self: *Environment, allocator: std.mem.Allocator) void { |
| 81 | inline for (@typeInfo(@TypeOf(self.*)).Struct.fields) |field| { | |
| 81 | inline for (@typeInfo(@TypeOf(self.*)).@"struct".fields) |field| { | |
| 82 | 82 | if (@field(self, field.name)) |slice| { |
| 83 | 83 | allocator.free(slice); |
| 84 | 84 | } |
lib/compiler/aro/aro/Tree.zig+2-2| ... | ... | @@ -707,7 +707,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void { |
| 707 | 707 | switch (attr.tag) { |
| 708 | 708 | inline else => |tag| { |
| 709 | 709 | const args = @field(attr.args, @tagName(tag)); |
| 710 | const fields = @typeInfo(@TypeOf(args)).Struct.fields; | |
| 710 | const fields = @typeInfo(@TypeOf(args)).@"struct".fields; | |
| 711 | 711 | if (fields.len == 0) { |
| 712 | 712 | try writer.writeByte('\n'); |
| 713 | 713 | return; |
| ... | ... | @@ -724,7 +724,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void { |
| 724 | 724 | Interner.Ref => try writer.print("\"{s}\"", .{tree.interner.get(@field(args, f.name)).bytes}), |
| 725 | 725 | ?Interner.Ref => try writer.print("\"{?s}\"", .{if (@field(args, f.name)) |str| tree.interner.get(str).bytes else null}), |
| 726 | 726 | else => switch (@typeInfo(f.type)) { |
| 727 | .Enum => try writer.writeAll(@tagName(@field(args, f.name))), | |
| 727 | .@"enum" => try writer.writeAll(@tagName(@field(args, f.name))), | |
| 728 | 728 | else => try writer.print("{any}", .{@field(args, f.name)}), |
| 729 | 729 | }, |
| 730 | 730 | } |
lib/compiler/aro/aro/Value.zig+1-1| ... | ... | @@ -24,7 +24,7 @@ pub fn intern(comp: *Compilation, k: Interner.Key) !Value { |
| 24 | 24 | |
| 25 | 25 | pub fn int(i: anytype, comp: *Compilation) !Value { |
| 26 | 26 | const info = @typeInfo(@TypeOf(i)); |
| 27 | if (info == .ComptimeInt or info.Int.signedness == .unsigned) { | |
| 27 | if (info == .comptime_int or info.int.signedness == .unsigned) { | |
| 28 | 28 | return intern(comp, .{ .int = .{ .u64 = i } }); |
| 29 | 29 | } else { |
| 30 | 30 | return intern(comp, .{ .int = .{ .i64 = i } }); |
lib/compiler/aro/backend/Interner.zig+4-4| ... | ... | @@ -505,7 +505,7 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref { |
| 505 | 505 | }); |
| 506 | 506 | }, |
| 507 | 507 | .record_ty => |elems| { |
| 508 | try i.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.Record).Struct.fields.len + | |
| 508 | try i.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.Record).@"struct".fields.len + | |
| 509 | 509 | elems.len); |
| 510 | 510 | i.items.appendAssumeCapacity(.{ |
| 511 | 511 | .tag = .record_ty, |
| ... | ... | @@ -527,14 +527,14 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref { |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | fn addExtra(i: *Interner, gpa: Allocator, extra: anytype) Allocator.Error!u32 { |
| 530 | const fields = @typeInfo(@TypeOf(extra)).Struct.fields; | |
| 530 | const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; | |
| 531 | 531 | try i.extra.ensureUnusedCapacity(gpa, fields.len); |
| 532 | 532 | return i.addExtraAssumeCapacity(extra); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | fn addExtraAssumeCapacity(i: *Interner, extra: anytype) u32 { |
| 536 | 536 | const result = @as(u32, @intCast(i.extra.items.len)); |
| 537 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { | |
| 537 | inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| { | |
| 538 | 538 | i.extra.appendAssumeCapacity(switch (field.type) { |
| 539 | 539 | Ref => @intFromEnum(@field(extra, field.name)), |
| 540 | 540 | u32 => @field(extra, field.name), |
| ... | ... | @@ -631,7 +631,7 @@ fn extraData(i: *const Interner, comptime T: type, index: usize) T { |
| 631 | 631 | |
| 632 | 632 | fn extraDataTrail(i: *const Interner, comptime T: type, index: usize) struct { data: T, end: u32 } { |
| 633 | 633 | var result: T = undefined; |
| 634 | const fields = @typeInfo(T).Struct.fields; | |
| 634 | const fields = @typeInfo(T).@"struct".fields; | |
| 635 | 635 | inline for (fields, 0..) |field, field_i| { |
| 636 | 636 | const int32 = i.extra.items[field_i + index]; |
| 637 | 637 | @field(result, field.name) = switch (field.type) { |
lib/compiler/aro_translate_c.zig+1-1| ... | ... | @@ -168,7 +168,7 @@ pub fn translate( |
| 168 | 168 | context.pattern_list.deinit(gpa); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | inline for (@typeInfo(std.zig.c_builtins).Struct.decls) |decl| { | |
| 171 | inline for (@typeInfo(std.zig.c_builtins).@"struct".decls) |decl| { | |
| 172 | 172 | const builtin_fn = try ZigTag.pub_var_simple.create(arena, .{ |
| 173 | 173 | .name = decl.name, |
| 174 | 174 | .init = try ZigTag.import_c_builtin.create(arena, decl.name), |
lib/compiler/resinator/bmp.zig+1-1| ... | ... | @@ -224,7 +224,7 @@ pub const Compression = enum(u32) { |
| 224 | 224 | }; |
| 225 | 225 | |
| 226 | 226 | fn structFieldsLittleToNative(comptime T: type, x: *T) void { |
| 227 | inline for (@typeInfo(T).Struct.fields) |field| { | |
| 227 | inline for (@typeInfo(T).@"struct".fields) |field| { | |
| 228 | 228 | @field(x, field.name) = std.mem.littleToNative(field.type, @field(x, field.name)); |
| 229 | 229 | } |
| 230 | 230 | } |
lib/compiler/resinator/code_pages.zig+1-1| ... | ... | @@ -259,7 +259,7 @@ pub const CodePage = enum(u16) { |
| 259 | 259 | pub fn getByIdentifier(identifier: u16) !CodePage { |
| 260 | 260 | // There's probably a more efficient way to do this (e.g. ComptimeHashMap?) but |
| 261 | 261 | // this should be fine, especially since this function likely won't be called much. |
| 262 | inline for (@typeInfo(CodePage).Enum.fields) |enumField| { | |
| 262 | inline for (@typeInfo(CodePage).@"enum".fields) |enumField| { | |
| 263 | 263 | if (identifier == enumField.value) { |
| 264 | 264 | return @field(CodePage, enumField.name); |
| 265 | 265 | } |
lib/compiler/resinator/errors.zig+1-1| ... | ... | @@ -250,7 +250,7 @@ pub const ErrorDetails = struct { |
| 250 | 250 | }); |
| 251 | 251 | |
| 252 | 252 | pub fn writeCommaSeparated(self: ExpectedTypes, writer: anytype) !void { |
| 253 | const struct_info = @typeInfo(ExpectedTypes).Struct; | |
| 253 | const struct_info = @typeInfo(ExpectedTypes).@"struct"; | |
| 254 | 254 | const num_real_fields = struct_info.fields.len - 1; |
| 255 | 255 | const num_padding_bits = @bitSizeOf(ExpectedTypes) - num_real_fields; |
| 256 | 256 | const mask = std.math.maxInt(struct_info.backing_integer.?) >> num_padding_bits; |
lib/compiler/resinator/ico.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ pub fn read(allocator: std.mem.Allocator, reader: anytype, max_size: u64) ReadEr |
| 14 | 14 | // Some Reader implementations have an empty ReadError error set which would |
| 15 | 15 | // cause 'unreachable else' if we tried to use an else in the switch, so we |
| 16 | 16 | // need to detect this case and not try to translate to ReadError |
| 17 | const empty_reader_errorset = @typeInfo(@TypeOf(reader).Error).ErrorSet == null or @typeInfo(@TypeOf(reader).Error).ErrorSet.?.len == 0; | |
| 17 | const empty_reader_errorset = @typeInfo(@TypeOf(reader).Error).error_set == null or @typeInfo(@TypeOf(reader).Error).error_set.?.len == 0; | |
| 18 | 18 | if (empty_reader_errorset) { |
| 19 | 19 | return readAnyError(allocator, reader, max_size) catch |err| switch (err) { |
| 20 | 20 | error.EndOfStream => error.UnexpectedEOF, |
lib/compiler/resinator/lang.zig+1-1| ... | ... | @@ -87,7 +87,7 @@ pub fn tagToId(tag: []const u8) error{InvalidLanguageTag}!?LanguageId { |
| 87 | 87 | if (parsed.multiple_suffixes) return null; |
| 88 | 88 | const longest_known_tag = comptime blk: { |
| 89 | 89 | var len = 0; |
| 90 | for (@typeInfo(LanguageId).Enum.fields) |field| { | |
| 90 | for (@typeInfo(LanguageId).@"enum".fields) |field| { | |
| 91 | 91 | if (field.name.len > len) len = field.name.len; |
| 92 | 92 | } |
| 93 | 93 | break :blk len; |
lib/compiler/test_runner.zig+1-1| ... | ... | @@ -265,7 +265,7 @@ fn mainTerminal() void { |
| 265 | 265 | |
| 266 | 266 | pub fn log( |
| 267 | 267 | comptime message_level: std.log.Level, |
| 268 | comptime scope: @Type(.EnumLiteral), | |
| 268 | comptime scope: @Type(.enum_literal), | |
| 269 | 269 | comptime format: []const u8, |
| 270 | 270 | args: anytype, |
| 271 | 271 | ) void { |
lib/compiler_rt/addf3.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ const normalize = common.normalize; |
| 7 | 7 | /// |
| 8 | 8 | /// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc |
| 9 | 9 | pub inline fn addf3(comptime T: type, a: T, b: T) T { |
| 10 | const bits = @typeInfo(T).Float.bits; | |
| 10 | const bits = @typeInfo(T).float.bits; | |
| 11 | 11 | const Z = std.meta.Int(.unsigned, bits); |
| 12 | 12 | |
| 13 | 13 | const typeWidth = bits; |
lib/compiler_rt/ceil.zig+1-1| ... | ... | @@ -130,7 +130,7 @@ pub fn ceilq(x: f128) callconv(.C) f128 { |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble { |
| 133 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 133 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 134 | 134 | 16 => return __ceilh(x), |
| 135 | 135 | 32 => return ceilf(x), |
| 136 | 136 | 64 => return ceil(x), |
lib/compiler_rt/common.zig+5-5| ... | ... | @@ -219,8 +219,8 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | |
| 223 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 222 | pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 { | |
| 223 | const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 224 | 224 | const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T); |
| 225 | 225 | |
| 226 | 226 | const shift = @clz(significand.*) - @clz(integerBit); |
| ... | ... | @@ -230,8 +230,8 @@ pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeIn |
| 230 | 230 | |
| 231 | 231 | pub inline fn fneg(a: anytype) @TypeOf(a) { |
| 232 | 232 | const F = @TypeOf(a); |
| 233 | const bits = @typeInfo(F).Float.bits; | |
| 234 | const U = @Type(.{ .Int = .{ | |
| 233 | const bits = @typeInfo(F).float.bits; | |
| 234 | const U = @Type(.{ .int = .{ | |
| 235 | 235 | .signedness = .unsigned, |
| 236 | 236 | .bits = bits, |
| 237 | 237 | } }); |
| ... | ... | @@ -244,7 +244,7 @@ pub inline fn fneg(a: anytype) @TypeOf(a) { |
| 244 | 244 | /// signed or unsigned integers. |
| 245 | 245 | pub fn HalveInt(comptime T: type, comptime signed_half: bool) type { |
| 246 | 246 | return extern union { |
| 247 | pub const bits = @divExact(@typeInfo(T).Int.bits, 2); | |
| 247 | pub const bits = @divExact(@typeInfo(T).int.bits, 2); | |
| 248 | 248 | pub const HalfTU = std.meta.Int(.unsigned, bits); |
| 249 | 249 | pub const HalfTS = std.meta.Int(.signed, bits); |
| 250 | 250 | pub const HalfT = if (signed_half) HalfTS else HalfTU; |
lib/compiler_rt/comparef.zig+2-2| ... | ... | @@ -17,7 +17,7 @@ pub const GE = enum(i32) { |
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | 19 | pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT { |
| 20 | const bits = @typeInfo(T).Float.bits; | |
| 20 | const bits = @typeInfo(T).float.bits; | |
| 21 | 21 | const srep_t = std.meta.Int(.signed, bits); |
| 22 | 22 | const rep_t = std.meta.Int(.unsigned, bits); |
| 23 | 23 | |
| ... | ... | @@ -109,7 +109,7 @@ test "cmp_f80" { |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 { |
| 112 | const rep_t = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 112 | const rep_t = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 113 | 113 | |
| 114 | 114 | const significandBits = std.math.floatMantissaBits(T); |
| 115 | 115 | const exponentBits = std.math.floatExponentBits(T); |
lib/compiler_rt/cos.zig+1-1| ... | ... | @@ -124,7 +124,7 @@ pub fn cosq(a: f128) callconv(.C) f128 { |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble { |
| 127 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 127 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 128 | 128 | 16 => return __cosh(x), |
| 129 | 129 | 32 => return cosf(x), |
| 130 | 130 | 64 => return cos(x), |
lib/compiler_rt/count0bits.zig+1-1| ... | ... | @@ -203,7 +203,7 @@ pub fn __ctzti2(a: i128) callconv(.C) i32 { |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | inline fn ffsXi2(comptime T: type, a: T) i32 { |
| 206 | var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a); | |
| 206 | var x: std.meta.Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a); | |
| 207 | 207 | var n: T = 1; |
| 208 | 208 | // adapted from Number of trailing zeroes (see ctzXi2) |
| 209 | 209 | var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x)); |
lib/compiler_rt/exp.zig+1-1| ... | ... | @@ -201,7 +201,7 @@ pub fn expq(a: f128) callconv(.C) f128 { |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | pub fn expl(x: c_longdouble) callconv(.C) c_longdouble { |
| 204 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 204 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 205 | 205 | 16 => return __exph(x), |
| 206 | 206 | 32 => return expf(x), |
| 207 | 207 | 64 => return exp(x), |
lib/compiler_rt/exp2.zig+1-1| ... | ... | @@ -168,7 +168,7 @@ pub fn exp2q(x: f128) callconv(.C) f128 { |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble { |
| 171 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 171 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 172 | 172 | 16 => return __exp2h(x), |
| 173 | 173 | 32 => return exp2f(x), |
| 174 | 174 | 64 => return exp2(x), |
lib/compiler_rt/extendf.zig+5-5| ... | ... | @@ -3,10 +3,10 @@ const std = @import("std"); |
| 3 | 3 | pub inline fn extendf( |
| 4 | 4 | comptime dst_t: type, |
| 5 | 5 | comptime src_t: type, |
| 6 | a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits), | |
| 6 | a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits), | |
| 7 | 7 | ) dst_t { |
| 8 | const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits); | |
| 9 | const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); | |
| 8 | const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); | |
| 9 | const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); | |
| 10 | 10 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 11 | 11 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 12 | 12 | |
| ... | ... | @@ -70,8 +70,8 @@ pub inline fn extendf( |
| 70 | 70 | return @bitCast(result); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits)) f80 { | |
| 74 | const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits); | |
| 73 | pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits)) f80 { | |
| 74 | const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); | |
| 75 | 75 | const src_sig_bits = std.math.floatMantissaBits(src_t); |
| 76 | 76 | const dst_int_bit = 0x8000000000000000; |
| 77 | 77 | const dst_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit |
lib/compiler_rt/fabs.zig+2-2| ... | ... | @@ -38,7 +38,7 @@ pub fn fabsq(a: f128) callconv(.C) f128 { |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { |
| 41 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 41 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 42 | 42 | 16 => return __fabsh(x), |
| 43 | 43 | 32 => return fabsf(x), |
| 44 | 44 | 64 => return fabs(x), |
| ... | ... | @@ -50,7 +50,7 @@ pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { |
| 50 | 50 | |
| 51 | 51 | inline fn generic_fabs(x: anytype) @TypeOf(x) { |
| 52 | 52 | const T = @TypeOf(x); |
| 53 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 53 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 54 | 54 | const float_bits: TBits = @bitCast(x); |
| 55 | 55 | const remove_sign = ~@as(TBits, 0) >> 1; |
| 56 | 56 | return @bitCast(float_bits & remove_sign); |
lib/compiler_rt/float_from_int.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ pub fn floatFromInt(comptime T: type, x: anytype) T { |
| 18 | 18 | const max_exp = exp_bias; |
| 19 | 19 | |
| 20 | 20 | // Sign |
| 21 | const abs_val = if (@TypeOf(x) == comptime_int or @typeInfo(@TypeOf(x)).Int.signedness == .signed) @abs(x) else x; | |
| 21 | const abs_val = if (@TypeOf(x) == comptime_int or @typeInfo(@TypeOf(x)).int.signedness == .signed) @abs(x) else x; | |
| 22 | 22 | const sign_bit = if (x < 0) @as(uT, 1) << (float_bits - 1) else 0; |
| 23 | 23 | var result: uT = sign_bit; |
| 24 | 24 |
lib/compiler_rt/floor.zig+1-1| ... | ... | @@ -160,7 +160,7 @@ pub fn floorq(x: f128) callconv(.C) f128 { |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble { |
| 163 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 163 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 164 | 164 | 16 => return __floorh(x), |
| 165 | 165 | 32 => return floorf(x), |
| 166 | 166 | 64 => return floor(x), |
lib/compiler_rt/fma.zig+1-1| ... | ... | @@ -151,7 +151,7 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 { |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble { |
| 154 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 154 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 155 | 155 | 16 => return __fmah(x, y, z), |
| 156 | 156 | 32 => return fmaf(x, y, z), |
| 157 | 157 | 64 => return fma(x, y, z), |
lib/compiler_rt/fmax.zig+1-1| ... | ... | @@ -39,7 +39,7 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 { |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { |
| 42 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 42 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 43 | 43 | 16 => return __fmaxh(x, y), |
| 44 | 44 | 32 => return fmaxf(x, y), |
| 45 | 45 | 64 => return fmax(x, y), |
lib/compiler_rt/fmin.zig+1-1| ... | ... | @@ -39,7 +39,7 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 { |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { |
| 42 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 42 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 43 | 43 | 16 => return __fminh(x, y), |
| 44 | 44 | 32 => return fminf(x, y), |
| 45 | 45 | 64 => return fmin(x, y), |
lib/compiler_rt/fmod.zig+2-2| ... | ... | @@ -251,7 +251,7 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { |
| 254 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 254 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 255 | 255 | 16 => return __fmodh(a, b), |
| 256 | 256 | 32 => return fmodf(a, b), |
| 257 | 257 | 64 => return fmod(a, b), |
| ... | ... | @@ -262,7 +262,7 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | inline fn generic_fmod(comptime T: type, x: T, y: T) T { |
| 265 | const bits = @typeInfo(T).Float.bits; | |
| 265 | const bits = @typeInfo(T).float.bits; | |
| 266 | 266 | const uint = std.meta.Int(.unsigned, bits); |
| 267 | 267 | comptime assert(T == f32 or T == f64); |
| 268 | 268 | const digits = if (T == f32) 23 else 52; |
lib/compiler_rt/int_from_float.zig+4-4| ... | ... | @@ -4,8 +4,8 @@ const Log2Int = math.Log2Int; |
| 4 | 4 | |
| 5 | 5 | pub inline fn intFromFloat(comptime I: type, a: anytype) I { |
| 6 | 6 | const F = @TypeOf(a); |
| 7 | const float_bits = @typeInfo(F).Float.bits; | |
| 8 | const int_bits = @typeInfo(I).Int.bits; | |
| 7 | const float_bits = @typeInfo(F).float.bits; | |
| 8 | const int_bits = @typeInfo(I).int.bits; | |
| 9 | 9 | const rep_t = Int(.unsigned, float_bits); |
| 10 | 10 | const sig_bits = math.floatMantissaBits(F); |
| 11 | 11 | const exp_bits = math.floatExponentBits(F); |
| ... | ... | @@ -26,7 +26,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I { |
| 26 | 26 | if (exponent < 0) return 0; |
| 27 | 27 | |
| 28 | 28 | // If the value is too large for the integer type, saturate. |
| 29 | switch (@typeInfo(I).Int.signedness) { | |
| 29 | switch (@typeInfo(I).int.signedness) { | |
| 30 | 30 | .unsigned => { |
| 31 | 31 | if (negative) return 0; |
| 32 | 32 | if (@as(c_uint, @intCast(exponent)) >= @min(int_bits, max_exp)) return math.maxInt(I); |
| ... | ... | @@ -45,7 +45,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I { |
| 45 | 45 | result = @as(I, @intCast(significand)) << @intCast(exponent - fractional_bits); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | if ((@typeInfo(I).Int.signedness == .signed) and negative) | |
| 48 | if ((@typeInfo(I).int.signedness == .signed) and negative) | |
| 49 | 49 | return ~result +% 1; |
| 50 | 50 | return result; |
| 51 | 51 | } |
lib/compiler_rt/log.zig+1-1| ... | ... | @@ -149,7 +149,7 @@ pub fn logq(a: f128) callconv(.C) f128 { |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | pub fn logl(x: c_longdouble) callconv(.C) c_longdouble { |
| 152 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 152 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 153 | 153 | 16 => return __logh(x), |
| 154 | 154 | 32 => return logf(x), |
| 155 | 155 | 64 => return log(x), |
lib/compiler_rt/log10.zig+1-1| ... | ... | @@ -177,7 +177,7 @@ pub fn log10q(a: f128) callconv(.C) f128 { |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble { |
| 180 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 180 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 181 | 181 | 16 => return __log10h(x), |
| 182 | 182 | 32 => return log10f(x), |
| 183 | 183 | 64 => return log10(x), |
lib/compiler_rt/log2.zig+1-1| ... | ... | @@ -169,7 +169,7 @@ pub fn log2q(a: f128) callconv(.C) f128 { |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble { |
| 172 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 172 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 173 | 173 | 16 => return __log2h(x), |
| 174 | 174 | 32 => return log2f(x), |
| 175 | 175 | 64 => return log2(x), |
lib/compiler_rt/mulf3.zig+3-3| ... | ... | @@ -7,7 +7,7 @@ const common = @import("./common.zig"); |
| 7 | 7 | /// https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/fp_mul_impl.inc |
| 8 | 8 | pub inline fn mulf3(comptime T: type, a: T, b: T) T { |
| 9 | 9 | @setRuntimeSafety(builtin.is_test); |
| 10 | const typeWidth = @typeInfo(T).Float.bits; | |
| 10 | const typeWidth = @typeInfo(T).float.bits; | |
| 11 | 11 | const significandBits = math.floatMantissaBits(T); |
| 12 | 12 | const fractionalBits = math.floatFractionalBits(T); |
| 13 | 13 | const exponentBits = math.floatExponentBits(T); |
| ... | ... | @@ -16,7 +16,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { |
| 16 | 16 | |
| 17 | 17 | // ZSignificand is large enough to contain the significand, including an explicit integer bit |
| 18 | 18 | const ZSignificand = PowerOfTwoSignificandZ(T); |
| 19 | const ZSignificandBits = @typeInfo(ZSignificand).Int.bits; | |
| 19 | const ZSignificandBits = @typeInfo(ZSignificand).int.bits; | |
| 20 | 20 | |
| 21 | 21 | const roundBit = (1 << (ZSignificandBits - 1)); |
| 22 | 22 | const signBit = (@as(Z, 1) << (significandBits + exponentBits)); |
| ... | ... | @@ -164,7 +164,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { |
| 164 | 164 | /// This is analogous to an shr version of `@shlWithOverflow` |
| 165 | 165 | fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool { |
| 166 | 166 | @setRuntimeSafety(builtin.is_test); |
| 167 | const typeWidth = @typeInfo(Z).Int.bits; | |
| 167 | const typeWidth = @typeInfo(Z).int.bits; | |
| 168 | 168 | var inexact = false; |
| 169 | 169 | if (count < typeWidth) { |
| 170 | 170 | inexact = (lo.* << @intCast(typeWidth -% count)) != 0; |
lib/compiler_rt/parity.zig+1-1| ... | ... | @@ -26,7 +26,7 @@ pub fn __parityti2(a: i128) callconv(.C) i32 { |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | inline fn parityXi2(comptime T: type, a: T) i32 { |
| 29 | var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a); | |
| 29 | var x: std.meta.Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a); | |
| 30 | 30 | // Bit Twiddling Hacks: Compute parity in parallel |
| 31 | 31 | comptime var shift: u8 = @bitSizeOf(T) / 2; |
| 32 | 32 | inline while (shift > 2) { |
lib/compiler_rt/round.zig+1-1| ... | ... | @@ -142,7 +142,7 @@ pub fn roundq(x_: f128) callconv(.C) f128 { |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble { |
| 145 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 145 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 146 | 146 | 16 => return __roundh(x), |
| 147 | 147 | 32 => return roundf(x), |
| 148 | 148 | 64 => return round(x), |
lib/compiler_rt/sin.zig+1-1| ... | ... | @@ -130,7 +130,7 @@ pub fn sinq(x: f128) callconv(.C) f128 { |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble { |
| 133 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 133 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 134 | 134 | 16 => return __sinh(x), |
| 135 | 135 | 32 => return sinf(x), |
| 136 | 136 | 64 => return sin(x), |
lib/compiler_rt/sincos.zig+2-2| ... | ... | @@ -198,7 +198,7 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void { |
| 201 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 201 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 202 | 202 | 16 => return __sincosh(x, r_sin, r_cos), |
| 203 | 203 | 32 => return sincosf(x, r_sin, r_cos), |
| 204 | 204 | 64 => return sincos(x, r_sin, r_cos), |
| ... | ... | @@ -216,7 +216,7 @@ pub const rem_pio2_generic = @compileError("TODO"); |
| 216 | 216 | /// * trig.cos_generic ported from __cosl.c |
| 217 | 217 | inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void { |
| 218 | 218 | const sc1pio4: F = 1.0 * math.pi / 4.0; |
| 219 | const bits = @typeInfo(F).Float.bits; | |
| 219 | const bits = @typeInfo(F).float.bits; | |
| 220 | 220 | const I = std.meta.Int(.unsigned, bits); |
| 221 | 221 | const ix = @as(I, @bitCast(x)) & (math.maxInt(I) >> 1); |
| 222 | 222 | const se: u16 = @truncate(ix >> (bits - 16)); |
lib/compiler_rt/sqrt.zig+1-1| ... | ... | @@ -243,7 +243,7 @@ pub fn sqrtq(x: f128) callconv(.C) f128 { |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble { |
| 246 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 246 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 247 | 247 | 16 => return __sqrth(x), |
| 248 | 248 | 32 => return sqrtf(x), |
| 249 | 249 | 64 => return sqrt(x), |
lib/compiler_rt/tan.zig+1-1| ... | ... | @@ -116,7 +116,7 @@ pub fn tanq(x: f128) callconv(.C) f128 { |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble { |
| 119 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 119 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 120 | 120 | 16 => return __tanh(x), |
| 121 | 121 | 32 => return tanf(x), |
| 122 | 122 | 64 => return tan(x), |
lib/compiler_rt/trunc.zig+1-1| ... | ... | @@ -100,7 +100,7 @@ pub fn truncq(x: f128) callconv(.C) f128 { |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble { |
| 103 | switch (@typeInfo(c_longdouble).Float.bits) { | |
| 103 | switch (@typeInfo(c_longdouble).float.bits) { | |
| 104 | 104 | 16 => return __trunch(x), |
| 105 | 105 | 32 => return truncf(x), |
| 106 | 106 | 64 => return trunc(x), |
lib/compiler_rt/truncf.zig+6-6| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t { |
| 4 | const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits); | |
| 5 | const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); | |
| 4 | const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); | |
| 5 | const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); | |
| 6 | 6 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 7 | 7 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 8 | 8 | |
| 9 | 9 | // Various constants whose values follow from the type parameters. |
| 10 | 10 | // Any reasonable optimizer will fold and propagate all of these. |
| 11 | const srcBits = @typeInfo(src_t).Float.bits; | |
| 11 | const srcBits = @typeInfo(src_t).float.bits; | |
| 12 | 12 | const srcExpBits = srcBits - srcSigBits - 1; |
| 13 | 13 | const srcInfExp = (1 << srcExpBits) - 1; |
| 14 | 14 | const srcExpBias = srcInfExp >> 1; |
| ... | ... | @@ -23,7 +23,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t |
| 23 | 23 | const srcQNaN = 1 << (srcSigBits - 1); |
| 24 | 24 | const srcNaNCode = srcQNaN - 1; |
| 25 | 25 | |
| 26 | const dstBits = @typeInfo(dst_t).Float.bits; | |
| 26 | const dstBits = @typeInfo(dst_t).float.bits; | |
| 27 | 27 | const dstExpBits = dstBits - dstSigBits - 1; |
| 28 | 28 | const dstInfExp = (1 << dstExpBits) - 1; |
| 29 | 29 | const dstExpBias = dstInfExp >> 1; |
| ... | ... | @@ -100,7 +100,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { |
| 103 | const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); | |
| 103 | const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); | |
| 104 | 104 | const src_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit |
| 105 | 105 | const dst_sig_bits = std.math.floatMantissaBits(dst_t); |
| 106 | 106 | |
| ... | ... | @@ -109,7 +109,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { |
| 109 | 109 | const round_mask = (1 << (src_sig_bits - dst_sig_bits)) - 1; |
| 110 | 110 | const halfway = 1 << (src_sig_bits - dst_sig_bits - 1); |
| 111 | 111 | |
| 112 | const dst_bits = @typeInfo(dst_t).Float.bits; | |
| 112 | const dst_bits = @typeInfo(dst_t).float.bits; | |
| 113 | 113 | const dst_exp_bits = dst_bits - dst_sig_bits - 1; |
| 114 | 114 | const dst_inf_exp = (1 << dst_exp_bits) - 1; |
| 115 | 115 | const dst_exp_bias = dst_inf_exp >> 1; |
lib/compiler_rt/trunctfxf2.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ pub fn __trunctfxf2(a: f128) callconv(.C) f80 { |
| 14 | 14 | |
| 15 | 15 | // Various constants whose values follow from the type parameters. |
| 16 | 16 | // Any reasonable optimizer will fold and propagate all of these. |
| 17 | const src_bits = @typeInfo(f128).Float.bits; | |
| 17 | const src_bits = @typeInfo(f128).float.bits; | |
| 18 | 18 | const src_exp_bits = src_bits - src_sig_bits - 1; |
| 19 | 19 | const src_inf_exp = 0x7FFF; |
| 20 | 20 |
lib/docs/wasm/Walk.zig+1-1| ... | ... | @@ -36,7 +36,7 @@ pub const Category = union(enum(u8)) { |
| 36 | 36 | /// A function that returns a type. |
| 37 | 37 | type_function: Ast.Node.Index, |
| 38 | 38 | |
| 39 | pub const Tag = @typeInfo(Category).Union.tag_type.?; | |
| 39 | pub const Tag = @typeInfo(Category).@"union".tag_type.?; | |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | 42 | pub const File = struct { |
lib/docs/wasm/markdown/Document.zig+1-1| ... | ... | @@ -170,7 +170,7 @@ pub fn ExtraData(comptime T: type) type { |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | pub fn extraData(doc: Document, comptime T: type, index: ExtraIndex) ExtraData(T) { |
| 173 | const fields = @typeInfo(T).Struct.fields; | |
| 173 | const fields = @typeInfo(T).@"struct".fields; | |
| 174 | 174 | var i: usize = @intFromEnum(index); |
| 175 | 175 | var result: T = undefined; |
| 176 | 176 | inline for (fields) |field| { |
lib/docs/wasm/markdown/Parser.zig+1-1| ... | ... | @@ -1564,7 +1564,7 @@ fn parseInlines(p: *Parser, content: []const u8) !ExtraIndex { |
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | pub fn extraData(p: Parser, comptime T: type, index: ExtraIndex) ExtraData(T) { |
| 1567 | const fields = @typeInfo(T).Struct.fields; | |
| 1567 | const fields = @typeInfo(T).@"struct".fields; | |
| 1568 | 1568 | var i: usize = @intFromEnum(index); |
| 1569 | 1569 | var result: T = undefined; |
| 1570 | 1570 | inline for (fields) |field| { |
lib/fuzzer.zig+2-2| ... | ... | @@ -13,7 +13,7 @@ var log_file: ?std.fs.File = null; |
| 13 | 13 | |
| 14 | 14 | fn logOverride( |
| 15 | 15 | comptime level: std.log.Level, |
| 16 | comptime scope: @TypeOf(.EnumLiteral), | |
| 16 | comptime scope: @Type(.enum_literal), | |
| 17 | 17 | comptime format: []const u8, |
| 18 | 18 | args: anytype, |
| 19 | 19 | ) void { |
| ... | ... | @@ -178,7 +178,7 @@ const Fuzzer = struct { |
| 178 | 178 | addr: usize, |
| 179 | 179 | flags: packed struct(usize) { |
| 180 | 180 | entry: bool, |
| 181 | _: @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(usize) - 1 } }), | |
| 181 | _: @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(usize) - 1 } }), | |
| 182 | 182 | }, |
| 183 | 183 | }; |
| 184 | 184 |
lib/std/Build.zig+23-23| ... | ... | @@ -408,7 +408,7 @@ fn createChildOnly( |
| 408 | 408 | |
| 409 | 409 | fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOptionsMap { |
| 410 | 410 | var user_input_options = UserInputOptionsMap.init(allocator); |
| 411 | inline for (@typeInfo(@TypeOf(args)).Struct.fields) |field| { | |
| 411 | inline for (@typeInfo(@TypeOf(args)).@"struct".fields) |field| { | |
| 412 | 412 | const v = @field(args, field.name); |
| 413 | 413 | const T = @TypeOf(v); |
| 414 | 414 | switch (T) { |
| ... | ... | @@ -454,28 +454,28 @@ fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOption |
| 454 | 454 | }) catch @panic("OOM"); |
| 455 | 455 | }, |
| 456 | 456 | else => switch (@typeInfo(T)) { |
| 457 | .Bool => { | |
| 457 | .bool => { | |
| 458 | 458 | user_input_options.put(field.name, .{ |
| 459 | 459 | .name = field.name, |
| 460 | 460 | .value = .{ .scalar = if (v) "true" else "false" }, |
| 461 | 461 | .used = false, |
| 462 | 462 | }) catch @panic("OOM"); |
| 463 | 463 | }, |
| 464 | .Enum, .EnumLiteral => { | |
| 464 | .@"enum", .enum_literal => { | |
| 465 | 465 | user_input_options.put(field.name, .{ |
| 466 | 466 | .name = field.name, |
| 467 | 467 | .value = .{ .scalar = @tagName(v) }, |
| 468 | 468 | .used = false, |
| 469 | 469 | }) catch @panic("OOM"); |
| 470 | 470 | }, |
| 471 | .ComptimeInt, .Int => { | |
| 471 | .comptime_int, .int => { | |
| 472 | 472 | user_input_options.put(field.name, .{ |
| 473 | 473 | .name = field.name, |
| 474 | 474 | .value = .{ .scalar = std.fmt.allocPrint(allocator, "{d}", .{v}) catch @panic("OOM") }, |
| 475 | 475 | .used = false, |
| 476 | 476 | }) catch @panic("OOM"); |
| 477 | 477 | }, |
| 478 | .ComptimeFloat, .Float => { | |
| 478 | .comptime_float, .float => { | |
| 479 | 479 | user_input_options.put(field.name, .{ |
| 480 | 480 | .name = field.name, |
| 481 | 481 | .value = .{ .scalar = std.fmt.allocPrint(allocator, "{e}", .{v}) catch @panic("OOM") }, |
| ... | ... | @@ -1111,7 +1111,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw |
| 1111 | 1111 | const description = b.dupe(description_raw); |
| 1112 | 1112 | const type_id = comptime typeToEnum(T); |
| 1113 | 1113 | const enum_options = if (type_id == .@"enum" or type_id == .enum_list) blk: { |
| 1114 | const EnumType = if (type_id == .enum_list) @typeInfo(T).Pointer.child else T; | |
| 1114 | const EnumType = if (type_id == .enum_list) @typeInfo(T).pointer.child else T; | |
| 1115 | 1115 | const fields = comptime std.meta.fields(EnumType); |
| 1116 | 1116 | var options = ArrayList([]const u8).initCapacity(b.allocator, fields.len) catch @panic("OOM"); |
| 1117 | 1117 | |
| ... | ... | @@ -1265,7 +1265,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw |
| 1265 | 1265 | return null; |
| 1266 | 1266 | }, |
| 1267 | 1267 | .scalar => |s| { |
| 1268 | const Child = @typeInfo(T).Pointer.child; | |
| 1268 | const Child = @typeInfo(T).pointer.child; | |
| 1269 | 1269 | const value = std.meta.stringToEnum(Child, s) orelse { |
| 1270 | 1270 | log.err("Expected -D{s} to be of type {s}.", .{ name, @typeName(Child) }); |
| 1271 | 1271 | b.markInvalidUserInput(); |
| ... | ... | @@ -1274,7 +1274,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw |
| 1274 | 1274 | return b.allocator.dupe(Child, &[_]Child{value}) catch @panic("OOM"); |
| 1275 | 1275 | }, |
| 1276 | 1276 | .list => |lst| { |
| 1277 | const Child = @typeInfo(T).Pointer.child; | |
| 1277 | const Child = @typeInfo(T).pointer.child; | |
| 1278 | 1278 | var new_list = b.allocator.alloc(Child, lst.items.len) catch @panic("OOM"); |
| 1279 | 1279 | for (lst.items, 0..) |str, i| { |
| 1280 | 1280 | const value = std.meta.stringToEnum(Child, str) orelse { |
| ... | ... | @@ -1542,15 +1542,15 @@ fn typeToEnum(comptime T: type) TypeId { |
| 1542 | 1542 | return switch (T) { |
| 1543 | 1543 | std.zig.BuildId => .build_id, |
| 1544 | 1544 | else => return switch (@typeInfo(T)) { |
| 1545 | .Int => .int, | |
| 1546 | .Float => .float, | |
| 1547 | .Bool => .bool, | |
| 1548 | .Enum => .@"enum", | |
| 1549 | .Pointer => |pointer| switch (pointer.child) { | |
| 1545 | .int => .int, | |
| 1546 | .float => .float, | |
| 1547 | .bool => .bool, | |
| 1548 | .@"enum" => .@"enum", | |
| 1549 | .pointer => |pointer| switch (pointer.child) { | |
| 1550 | 1550 | u8 => .string, |
| 1551 | 1551 | []const u8 => .list, |
| 1552 | 1552 | else => switch (@typeInfo(pointer.child)) { |
| 1553 | .Enum => .enum_list, | |
| 1553 | .@"enum" => .enum_list, | |
| 1554 | 1554 | else => @compileError("Unsupported type: " ++ @typeName(T)), |
| 1555 | 1555 | }, |
| 1556 | 1556 | }, |
| ... | ... | @@ -1726,7 +1726,7 @@ pub fn fmt(b: *Build, comptime format: []const u8, args: anytype) []u8 { |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | fn supportedWindowsProgramExtension(ext: []const u8) bool { |
| 1729 | inline for (@typeInfo(std.process.Child.WindowsExtension).Enum.fields) |field| { | |
| 1729 | inline for (@typeInfo(std.process.Child.WindowsExtension).@"enum".fields) |field| { | |
| 1730 | 1730 | if (std.ascii.eqlIgnoreCase(ext, "." ++ field.name)) return true; |
| 1731 | 1731 | } |
| 1732 | 1732 | return false; |
| ... | ... | @@ -1925,7 +1925,7 @@ inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, c |
| 1925 | 1925 | const build_runner = @import("root"); |
| 1926 | 1926 | const deps = build_runner.dependencies; |
| 1927 | 1927 | |
| 1928 | const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).Struct.decls) |decl| { | |
| 1928 | const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).@"struct".decls) |decl| { | |
| 1929 | 1929 | const pkg_hash = decl.name; |
| 1930 | 1930 | const pkg = @field(deps.packages, pkg_hash); |
| 1931 | 1931 | if (@hasDecl(pkg, "build_zig") and pkg.build_zig == asking_build_zig) break .{ pkg_hash, pkg.deps }; |
| ... | ... | @@ -1963,7 +1963,7 @@ pub fn lazyDependency(b: *Build, name: []const u8, args: anytype) ?*Dependency { |
| 1963 | 1963 | const deps = build_runner.dependencies; |
| 1964 | 1964 | const pkg_hash = findPkgHashOrFatal(b, name); |
| 1965 | 1965 | |
| 1966 | inline for (@typeInfo(deps.packages).Struct.decls) |decl| { | |
| 1966 | inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { | |
| 1967 | 1967 | if (mem.eql(u8, decl.name, pkg_hash)) { |
| 1968 | 1968 | const pkg = @field(deps.packages, decl.name); |
| 1969 | 1969 | const available = !@hasDecl(pkg, "available") or pkg.available; |
| ... | ... | @@ -1983,7 +1983,7 @@ pub fn dependency(b: *Build, name: []const u8, args: anytype) *Dependency { |
| 1983 | 1983 | const deps = build_runner.dependencies; |
| 1984 | 1984 | const pkg_hash = findPkgHashOrFatal(b, name); |
| 1985 | 1985 | |
| 1986 | inline for (@typeInfo(deps.packages).Struct.decls) |decl| { | |
| 1986 | inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { | |
| 1987 | 1987 | if (mem.eql(u8, decl.name, pkg_hash)) { |
| 1988 | 1988 | const pkg = @field(deps.packages, decl.name); |
| 1989 | 1989 | if (@hasDecl(pkg, "available")) { |
| ... | ... | @@ -2013,7 +2013,7 @@ pub inline fn lazyImport( |
| 2013 | 2013 | const deps = build_runner.dependencies; |
| 2014 | 2014 | const pkg_hash = findImportPkgHashOrFatal(b, asking_build_zig, dep_name); |
| 2015 | 2015 | |
| 2016 | inline for (@typeInfo(deps.packages).Struct.decls) |decl| { | |
| 2016 | inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { | |
| 2017 | 2017 | if (comptime mem.eql(u8, decl.name, pkg_hash)) { |
| 2018 | 2018 | const pkg = @field(deps.packages, decl.name); |
| 2019 | 2019 | const available = !@hasDecl(pkg, "available") or pkg.available; |
| ... | ... | @@ -2042,7 +2042,7 @@ pub fn dependencyFromBuildZig( |
| 2042 | 2042 | const deps = build_runner.dependencies; |
| 2043 | 2043 | |
| 2044 | 2044 | find_dep: { |
| 2045 | const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).Struct.decls) |decl| { | |
| 2045 | const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { | |
| 2046 | 2046 | const pkg_hash = decl.name; |
| 2047 | 2047 | const pkg = @field(deps.packages, pkg_hash); |
| 2048 | 2048 | if (@hasDecl(pkg, "build_zig") and pkg.build_zig == build_zig) break .{ pkg, pkg_hash }; |
| ... | ... | @@ -2150,9 +2150,9 @@ fn dependencyInner( |
| 2150 | 2150 | } |
| 2151 | 2151 | |
| 2152 | 2152 | pub fn runBuild(b: *Build, build_zig: anytype) anyerror!void { |
| 2153 | switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).Fn.return_type.?)) { | |
| 2154 | .Void => build_zig.build(b), | |
| 2155 | .ErrorUnion => try build_zig.build(b), | |
| 2153 | switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).@"fn".return_type.?)) { | |
| 2154 | .void => build_zig.build(b), | |
| 2155 | .error_union => try build_zig.build(b), | |
| 2156 | 2156 | else => @compileError("expected return type of build to be 'void' or '!void'"), |
| 2157 | 2157 | } |
| 2158 | 2158 | } |
lib/std/Build/Cache.zig+3-3| ... | ... | @@ -222,7 +222,7 @@ pub const HashHelper = struct { |
| 222 | 222 | .hexstring => |hex_string| hh.addBytes(hex_string.toSlice()), |
| 223 | 223 | }, |
| 224 | 224 | else => switch (@typeInfo(@TypeOf(x))) { |
| 225 | .Bool, .Int, .Enum, .Array => hh.addBytes(mem.asBytes(&x)), | |
| 225 | .bool, .int, .@"enum", .array => hh.addBytes(mem.asBytes(&x)), | |
| 226 | 226 | else => @compileError("unable to hash type " ++ @typeName(@TypeOf(x))), |
| 227 | 227 | }, |
| 228 | 228 | } |
| ... | ... | @@ -1014,7 +1014,7 @@ pub const Manifest = struct { |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | pub fn populateFileSystemInputs(man: *Manifest, buf: *std.ArrayListUnmanaged(u8)) Allocator.Error!void { |
| 1017 | assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len); | |
| 1017 | assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len); | |
| 1018 | 1018 | buf.clearRetainingCapacity(); |
| 1019 | 1019 | const gpa = man.cache.gpa; |
| 1020 | 1020 | const files = man.files.keys(); |
| ... | ... | @@ -1032,7 +1032,7 @@ pub const Manifest = struct { |
| 1032 | 1032 | |
| 1033 | 1033 | pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [4]u8) Allocator.Error!void { |
| 1034 | 1034 | const gpa = other.cache.gpa; |
| 1035 | assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len); | |
| 1035 | assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len); | |
| 1036 | 1036 | assert(man.cache.prefixes_len == 4); |
| 1037 | 1037 | for (man.files.keys()) |file| { |
| 1038 | 1038 | const prefixed_path: PrefixedPath = .{ |
lib/std/Build/Cache/Path.zig+2-2| ... | ... | @@ -189,8 +189,8 @@ pub const TableAdapter = struct { |
| 189 | 189 | pub fn hash(self: TableAdapter, a: Cache.Path) u32 { |
| 190 | 190 | _ = self; |
| 191 | 191 | const seed = switch (@typeInfo(@TypeOf(a.root_dir.handle.fd))) { |
| 192 | .Pointer => @intFromPtr(a.root_dir.handle.fd), | |
| 193 | .Int => @as(u32, @bitCast(a.root_dir.handle.fd)), | |
| 192 | .pointer => @intFromPtr(a.root_dir.handle.fd), | |
| 193 | .int => @as(u32, @bitCast(a.root_dir.handle.fd)), | |
| 194 | 194 | else => @compileError("unimplemented hash function"), |
| 195 | 195 | }; |
| 196 | 196 | return @truncate(Hash.hash(seed, a.sub_path)); |
lib/std/Build/Step/ConfigHeader.zig+11-11| ... | ... | @@ -109,47 +109,47 @@ pub fn getOutput(config_header: *ConfigHeader) std.Build.LazyPath { |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | fn addValuesInner(config_header: *ConfigHeader, values: anytype) !void { |
| 112 | inline for (@typeInfo(@TypeOf(values)).Struct.fields) |field| { | |
| 112 | inline for (@typeInfo(@TypeOf(values)).@"struct".fields) |field| { | |
| 113 | 113 | try putValue(config_header, field.name, field.type, @field(values, field.name)); |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: type, v: T) !void { |
| 118 | 118 | switch (@typeInfo(T)) { |
| 119 | .Null => { | |
| 119 | .null => { | |
| 120 | 120 | try config_header.values.put(field_name, .undef); |
| 121 | 121 | }, |
| 122 | .Void => { | |
| 122 | .void => { | |
| 123 | 123 | try config_header.values.put(field_name, .defined); |
| 124 | 124 | }, |
| 125 | .Bool => { | |
| 125 | .bool => { | |
| 126 | 126 | try config_header.values.put(field_name, .{ .boolean = v }); |
| 127 | 127 | }, |
| 128 | .Int => { | |
| 128 | .int => { | |
| 129 | 129 | try config_header.values.put(field_name, .{ .int = v }); |
| 130 | 130 | }, |
| 131 | .ComptimeInt => { | |
| 131 | .comptime_int => { | |
| 132 | 132 | try config_header.values.put(field_name, .{ .int = v }); |
| 133 | 133 | }, |
| 134 | .EnumLiteral => { | |
| 134 | .enum_literal => { | |
| 135 | 135 | try config_header.values.put(field_name, .{ .ident = @tagName(v) }); |
| 136 | 136 | }, |
| 137 | .Optional => { | |
| 137 | .optional => { | |
| 138 | 138 | if (v) |x| { |
| 139 | 139 | return putValue(config_header, field_name, @TypeOf(x), x); |
| 140 | 140 | } else { |
| 141 | 141 | try config_header.values.put(field_name, .undef); |
| 142 | 142 | } |
| 143 | 143 | }, |
| 144 | .Pointer => |ptr| { | |
| 144 | .pointer => |ptr| { | |
| 145 | 145 | switch (@typeInfo(ptr.child)) { |
| 146 | .Array => |array| { | |
| 146 | .array => |array| { | |
| 147 | 147 | if (ptr.size == .One and array.child == u8) { |
| 148 | 148 | try config_header.values.put(field_name, .{ .string = v }); |
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | 151 | }, |
| 152 | .Int => { | |
| 152 | .int => { | |
| 153 | 153 | if (ptr.size == .Slice and ptr.child == u8) { |
| 154 | 154 | try config_header.values.put(field_name, .{ .string = v }); |
| 155 | 155 | return; |
lib/std/Build/Step/Options.zig+17-17| ... | ... | @@ -151,7 +151,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | switch (@typeInfo(T)) { |
| 154 | .Array => { | |
| 154 | .array => { | |
| 155 | 155 | if (name) |some| { |
| 156 | 156 | try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) }); |
| 157 | 157 | } |
| ... | ... | @@ -171,7 +171,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 171 | 171 | } |
| 172 | 172 | return; |
| 173 | 173 | }, |
| 174 | .Pointer => |p| { | |
| 174 | .pointer => |p| { | |
| 175 | 175 | if (p.size != .Slice) { |
| 176 | 176 | @compileError("Non-slice pointers are not yet supported in build options"); |
| 177 | 177 | } |
| ... | ... | @@ -195,7 +195,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 195 | 195 | } |
| 196 | 196 | return; |
| 197 | 197 | }, |
| 198 | .Optional => { | |
| 198 | .optional => { | |
| 199 | 199 | if (name) |some| { |
| 200 | 200 | try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) }); |
| 201 | 201 | } |
| ... | ... | @@ -216,12 +216,12 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 216 | 216 | } |
| 217 | 217 | return; |
| 218 | 218 | }, |
| 219 | .Void, | |
| 220 | .Bool, | |
| 221 | .Int, | |
| 222 | .ComptimeInt, | |
| 223 | .Float, | |
| 224 | .Null, | |
| 219 | .void, | |
| 220 | .bool, | |
| 221 | .int, | |
| 222 | .comptime_int, | |
| 223 | .float, | |
| 224 | .null, | |
| 225 | 225 | => { |
| 226 | 226 | if (name) |some| { |
| 227 | 227 | try out.print("pub const {}: {s} = {any};\n", .{ std.zig.fmtId(some), @typeName(T), value }); |
| ... | ... | @@ -230,7 +230,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 230 | 230 | } |
| 231 | 231 | return; |
| 232 | 232 | }, |
| 233 | .Enum => |info| { | |
| 233 | .@"enum" => |info| { | |
| 234 | 234 | try printEnum(options, out, T, info, indent); |
| 235 | 235 | |
| 236 | 236 | if (name) |some| { |
| ... | ... | @@ -242,7 +242,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 242 | 242 | } |
| 243 | 243 | return; |
| 244 | 244 | }, |
| 245 | .Struct => |info| { | |
| 245 | .@"struct" => |info| { | |
| 246 | 246 | try printStruct(options, out, T, info, indent); |
| 247 | 247 | |
| 248 | 248 | if (name) |some| { |
| ... | ... | @@ -260,10 +260,10 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 260 | 260 | |
| 261 | 261 | fn printUserDefinedType(options: *Options, out: anytype, comptime T: type, indent: u8) !void { |
| 262 | 262 | switch (@typeInfo(T)) { |
| 263 | .Enum => |info| { | |
| 263 | .@"enum" => |info| { | |
| 264 | 264 | return try printEnum(options, out, T, info, indent); |
| 265 | 265 | }, |
| 266 | .Struct => |info| { | |
| 266 | .@"struct" => |info| { | |
| 267 | 267 | return try printStruct(options, out, T, info, indent); |
| 268 | 268 | }, |
| 269 | 269 | else => {}, |
| ... | ... | @@ -323,8 +323,8 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val: |
| 323 | 323 | |
| 324 | 324 | try out.writeAll(" = "); |
| 325 | 325 | switch (@typeInfo(@TypeOf(default_value))) { |
| 326 | .Enum => try out.print(".{s},\n", .{@tagName(default_value)}), | |
| 327 | .Struct => |info| { | |
| 326 | .@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}), | |
| 327 | .@"struct" => |info| { | |
| 328 | 328 | try printStructValue(options, out, info, default_value, indent + 4); |
| 329 | 329 | }, |
| 330 | 330 | else => try printType(options, out, @TypeOf(default_value), default_value, indent, null), |
| ... | ... | @@ -359,8 +359,8 @@ fn printStructValue(options: *Options, out: anytype, comptime struct_val: std.bu |
| 359 | 359 | |
| 360 | 360 | const field_name = @field(val, field.name); |
| 361 | 361 | switch (@typeInfo(@TypeOf(field_name))) { |
| 362 | .Enum => try out.print(".{s},\n", .{@tagName(field_name)}), | |
| 363 | .Struct => |struct_info| { | |
| 362 | .@"enum" => try out.print(".{s},\n", .{@tagName(field_name)}), | |
| 363 | .@"struct" => |struct_info| { | |
| 364 | 364 | try printStructValue(options, out, struct_info, field_name, indent + 4); |
| 365 | 365 | }, |
| 366 | 366 | else => try printType(options, out, @TypeOf(field_name), field_name, indent, null), |
lib/std/Build/Step/Run.zig+1-1| ... | ... | @@ -614,7 +614,7 @@ fn checksContainStderr(checks: []const StdIo.Check) bool { |
| 614 | 614 | |
| 615 | 615 | const IndexedOutput = struct { |
| 616 | 616 | index: usize, |
| 617 | tag: @typeInfo(Arg).Union.tag_type.?, | |
| 617 | tag: @typeInfo(Arg).@"union".tag_type.?, | |
| 618 | 618 | output: *Output, |
| 619 | 619 | }; |
| 620 | 620 | fn make(step: *Step, options: Step.MakeOptions) !void { |
lib/std/Progress.zig+9-9| ... | ... | @@ -95,8 +95,8 @@ pub const Node = struct { |
| 95 | 95 | /// Not thread-safe. |
| 96 | 96 | fn getIpcFd(s: Storage) ?posix.fd_t { |
| 97 | 97 | return if (s.estimated_total_count == std.math.maxInt(u32)) switch (@typeInfo(posix.fd_t)) { |
| 98 | .Int => @bitCast(s.completed_count), | |
| 99 | .Pointer => @ptrFromInt(s.completed_count), | |
| 98 | .int => @bitCast(s.completed_count), | |
| 99 | .pointer => @ptrFromInt(s.completed_count), | |
| 100 | 100 | else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), |
| 101 | 101 | } else null; |
| 102 | 102 | } |
| ... | ... | @@ -104,8 +104,8 @@ pub const Node = struct { |
| 104 | 104 | /// Thread-safe. |
| 105 | 105 | fn setIpcFd(s: *Storage, fd: posix.fd_t) void { |
| 106 | 106 | const integer: u32 = switch (@typeInfo(posix.fd_t)) { |
| 107 | .Int => @bitCast(fd), | |
| 108 | .Pointer => @intFromPtr(fd), | |
| 107 | .int => @bitCast(fd), | |
| 108 | .pointer => @intFromPtr(fd), | |
| 109 | 109 | else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), |
| 110 | 110 | }; |
| 111 | 111 | // `estimated_total_count` max int indicates the special state that |
| ... | ... | @@ -276,8 +276,8 @@ pub const Node = struct { |
| 276 | 276 | const storage = storageByIndex(index); |
| 277 | 277 | const int = @atomicLoad(u32, &storage.completed_count, .monotonic); |
| 278 | 278 | return switch (@typeInfo(posix.fd_t)) { |
| 279 | .Int => @bitCast(int), | |
| 280 | .Pointer => @ptrFromInt(int), | |
| 279 | .int => @bitCast(int), | |
| 280 | .pointer => @ptrFromInt(int), | |
| 281 | 281 | else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), |
| 282 | 282 | }; |
| 283 | 283 | } |
| ... | ... | @@ -381,8 +381,8 @@ pub fn start(options: Options) Node { |
| 381 | 381 | if (std.process.parseEnvVarInt("ZIG_PROGRESS", u31, 10)) |ipc_fd| { |
| 382 | 382 | global_progress.update_thread = std.Thread.spawn(.{}, ipcThreadRun, .{ |
| 383 | 383 | @as(posix.fd_t, switch (@typeInfo(posix.fd_t)) { |
| 384 | .Int => ipc_fd, | |
| 385 | .Pointer => @ptrFromInt(ipc_fd), | |
| 384 | .int => ipc_fd, | |
| 385 | .pointer => @ptrFromInt(ipc_fd), | |
| 386 | 386 | else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), |
| 387 | 387 | }), |
| 388 | 388 | }) catch |err| { |
| ... | ... | @@ -633,7 +633,7 @@ const TreeSymbol = enum { |
| 633 | 633 | |
| 634 | 634 | fn maxByteLen(symbol: TreeSymbol) usize { |
| 635 | 635 | var max: usize = 0; |
| 636 | inline for (@typeInfo(Encoding).Enum.fields) |field| { | |
| 636 | inline for (@typeInfo(Encoding).@"enum".fields) |field| { | |
| 637 | 637 | const len = symbol.bytes(@field(Encoding, field.name)).len; |
| 638 | 638 | max = @max(max, len); |
| 639 | 639 | } |
lib/std/Random.zig+20-20| ... | ... | @@ -34,9 +34,9 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void, |
| 34 | 34 | |
| 35 | 35 | pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random { |
| 36 | 36 | const Ptr = @TypeOf(pointer); |
| 37 | assert(@typeInfo(Ptr) == .Pointer); // Must be a pointer | |
| 38 | assert(@typeInfo(Ptr).Pointer.size == .One); // Must be a single-item pointer | |
| 39 | assert(@typeInfo(@typeInfo(Ptr).Pointer.child) == .Struct); // Must point to a struct | |
| 37 | assert(@typeInfo(Ptr) == .pointer); // Must be a pointer | |
| 38 | assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer | |
| 39 | assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct | |
| 40 | 40 | const gen = struct { |
| 41 | 41 | fn fill(ptr: *anyopaque, buf: []u8) void { |
| 42 | 42 | const self: Ptr = @ptrCast(@alignCast(ptr)); |
| ... | ... | @@ -79,7 +79,7 @@ pub inline fn enumValue(r: Random, comptime EnumType: type) EnumType { |
| 79 | 79 | /// See `uintLessThan`, which this function uses in most cases, |
| 80 | 80 | /// for commentary on the runtime of this function. |
| 81 | 81 | pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: type) EnumType { |
| 82 | comptime assert(@typeInfo(EnumType) == .Enum); | |
| 82 | comptime assert(@typeInfo(EnumType) == .@"enum"); | |
| 83 | 83 | |
| 84 | 84 | // We won't use int -> enum casting because enum elements can have |
| 85 | 85 | // arbitrary values. Instead we'll randomly pick one of the type's values. |
| ... | ... | @@ -100,7 +100,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty |
| 100 | 100 | /// Returns a random int `i` such that `minInt(T) <= i <= maxInt(T)`. |
| 101 | 101 | /// `i` is evenly distributed. |
| 102 | 102 | pub fn int(r: Random, comptime T: type) T { |
| 103 | const bits = @typeInfo(T).Int.bits; | |
| 103 | const bits = @typeInfo(T).int.bits; | |
| 104 | 104 | const UnsignedT = std.meta.Int(.unsigned, bits); |
| 105 | 105 | const ceil_bytes = comptime std.math.divCeil(u16, bits, 8) catch unreachable; |
| 106 | 106 | const ByteAlignedT = std.meta.Int(.unsigned, ceil_bytes * 8); |
| ... | ... | @@ -119,7 +119,7 @@ pub fn int(r: Random, comptime T: type) T { |
| 119 | 119 | /// Constant-time implementation off `uintLessThan`. |
| 120 | 120 | /// The results of this function may be biased. |
| 121 | 121 | pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T { |
| 122 | comptime assert(@typeInfo(T).Int.signedness == .unsigned); | |
| 122 | comptime assert(@typeInfo(T).int.signedness == .unsigned); | |
| 123 | 123 | assert(0 < less_than); |
| 124 | 124 | return limitRangeBiased(T, r.int(T), less_than); |
| 125 | 125 | } |
| ... | ... | @@ -133,8 +133,8 @@ pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T { |
| 133 | 133 | /// this function is guaranteed to return. |
| 134 | 134 | /// If you need deterministic runtime bounds, use `uintLessThanBiased`. |
| 135 | 135 | pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T { |
| 136 | comptime assert(@typeInfo(T).Int.signedness == .unsigned); | |
| 137 | const bits = @typeInfo(T).Int.bits; | |
| 136 | comptime assert(@typeInfo(T).int.signedness == .unsigned); | |
| 137 | const bits = @typeInfo(T).int.bits; | |
| 138 | 138 | assert(0 < less_than); |
| 139 | 139 | |
| 140 | 140 | // adapted from: |
| ... | ... | @@ -164,7 +164,7 @@ pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T { |
| 164 | 164 | /// Constant-time implementation off `uintAtMost`. |
| 165 | 165 | /// The results of this function may be biased. |
| 166 | 166 | pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T { |
| 167 | assert(@typeInfo(T).Int.signedness == .unsigned); | |
| 167 | assert(@typeInfo(T).int.signedness == .unsigned); | |
| 168 | 168 | if (at_most == maxInt(T)) { |
| 169 | 169 | // have the full range |
| 170 | 170 | return r.int(T); |
| ... | ... | @@ -176,7 +176,7 @@ pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T { |
| 176 | 176 | /// See `uintLessThan`, which this function uses in most cases, |
| 177 | 177 | /// for commentary on the runtime of this function. |
| 178 | 178 | pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T { |
| 179 | assert(@typeInfo(T).Int.signedness == .unsigned); | |
| 179 | assert(@typeInfo(T).int.signedness == .unsigned); | |
| 180 | 180 | if (at_most == maxInt(T)) { |
| 181 | 181 | // have the full range |
| 182 | 182 | return r.int(T); |
| ... | ... | @@ -188,7 +188,7 @@ pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T { |
| 188 | 188 | /// The results of this function may be biased. |
| 189 | 189 | pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_than: T) T { |
| 190 | 190 | assert(at_least < less_than); |
| 191 | const info = @typeInfo(T).Int; | |
| 191 | const info = @typeInfo(T).int; | |
| 192 | 192 | if (info.signedness == .signed) { |
| 193 | 193 | // Two's complement makes this math pretty easy. |
| 194 | 194 | const UnsignedT = std.meta.Int(.unsigned, info.bits); |
| ... | ... | @@ -207,7 +207,7 @@ pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_tha |
| 207 | 207 | /// for commentary on the runtime of this function. |
| 208 | 208 | pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) T { |
| 209 | 209 | assert(at_least < less_than); |
| 210 | const info = @typeInfo(T).Int; | |
| 210 | const info = @typeInfo(T).int; | |
| 211 | 211 | if (info.signedness == .signed) { |
| 212 | 212 | // Two's complement makes this math pretty easy. |
| 213 | 213 | const UnsignedT = std.meta.Int(.unsigned, info.bits); |
| ... | ... | @@ -225,7 +225,7 @@ pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) |
| 225 | 225 | /// The results of this function may be biased. |
| 226 | 226 | pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T) T { |
| 227 | 227 | assert(at_least <= at_most); |
| 228 | const info = @typeInfo(T).Int; | |
| 228 | const info = @typeInfo(T).int; | |
| 229 | 229 | if (info.signedness == .signed) { |
| 230 | 230 | // Two's complement makes this math pretty easy. |
| 231 | 231 | const UnsignedT = std.meta.Int(.unsigned, info.bits); |
| ... | ... | @@ -244,7 +244,7 @@ pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T |
| 244 | 244 | /// for commentary on the runtime of this function. |
| 245 | 245 | pub fn intRangeAtMost(r: Random, comptime T: type, at_least: T, at_most: T) T { |
| 246 | 246 | assert(at_least <= at_most); |
| 247 | const info = @typeInfo(T).Int; | |
| 247 | const info = @typeInfo(T).int; | |
| 248 | 248 | if (info.signedness == .signed) { |
| 249 | 249 | // Two's complement makes this math pretty easy. |
| 250 | 250 | const UnsignedT = std.meta.Int(.unsigned, info.bits); |
| ... | ... | @@ -392,12 +392,12 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize |
| 392 | 392 | }; |
| 393 | 393 | |
| 394 | 394 | const point = switch (@typeInfo(T)) { |
| 395 | .Int => |int_info| switch (int_info.signedness) { | |
| 395 | .int => |int_info| switch (int_info.signedness) { | |
| 396 | 396 | .signed => r.intRangeLessThan(T, 0, sum), |
| 397 | 397 | .unsigned => r.uintLessThan(T, sum), |
| 398 | 398 | }, |
| 399 | 399 | // take care that imprecision doesn't lead to a value slightly greater than sum |
| 400 | .Float => @min(r.float(T) * sum, sum - std.math.floatEps(T)), | |
| 400 | .float => @min(r.float(T) * sum, sum - std.math.floatEps(T)), | |
| 401 | 401 | else => @compileError("weightedIndex does not support proportions of type " ++ |
| 402 | 402 | @typeName(T)), |
| 403 | 403 | }; |
| ... | ... | @@ -415,8 +415,8 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize |
| 415 | 415 | /// into an integer 0 <= result < less_than. |
| 416 | 416 | /// This function introduces a minor bias. |
| 417 | 417 | pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { |
| 418 | comptime assert(@typeInfo(T).Int.signedness == .unsigned); | |
| 419 | const bits = @typeInfo(T).Int.bits; | |
| 418 | comptime assert(@typeInfo(T).int.signedness == .unsigned); | |
| 419 | const bits = @typeInfo(T).int.bits; | |
| 420 | 420 | |
| 421 | 421 | // adapted from: |
| 422 | 422 | // http://www.pcg-random.org/posts/bounded-rands.html |
| ... | ... | @@ -427,9 +427,9 @@ pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { |
| 427 | 427 | |
| 428 | 428 | /// Returns the smallest of `Index` and `usize`. |
| 429 | 429 | fn MinArrayIndex(comptime Index: type) type { |
| 430 | const index_info = @typeInfo(Index).Int; | |
| 430 | const index_info = @typeInfo(Index).int; | |
| 431 | 431 | assert(index_info.signedness == .unsigned); |
| 432 | return if (index_info.bits >= @typeInfo(usize).Int.bits) usize else Index; | |
| 432 | return if (index_info.bits >= @typeInfo(usize).int.bits) usize else Index; | |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | test { |
lib/std/Target.zig+2-2| ... | ... | @@ -154,7 +154,7 @@ pub const Os = struct { |
| 154 | 154 | }; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).Union.tag_type.? { | |
| 157 | pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? { | |
| 158 | 158 | return switch (tag) { |
| 159 | 159 | .freestanding, |
| 160 | 160 | .fuchsia, |
| ... | ... | @@ -1458,7 +1458,7 @@ pub const Cpu = struct { |
| 1458 | 1458 | |
| 1459 | 1459 | fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model { |
| 1460 | 1460 | @setEvalBranchQuota(2000); |
| 1461 | const decls = @typeInfo(cpus).Struct.decls; | |
| 1461 | const decls = @typeInfo(cpus).@"struct".decls; | |
| 1462 | 1462 | var array: [decls.len]*const Cpu.Model = undefined; |
| 1463 | 1463 | for (decls, 0..) |decl, i| { |
| 1464 | 1464 | array[i] = &@field(cpus, decl.name); |
lib/std/Target/Query.zig+2-2| ... | ... | @@ -53,7 +53,7 @@ pub const CpuModel = union(enum) { |
| 53 | 53 | explicit: *const Target.Cpu.Model, |
| 54 | 54 | |
| 55 | 55 | pub fn eql(a: CpuModel, b: CpuModel) bool { |
| 56 | const Tag = @typeInfo(CpuModel).Union.tag_type.?; | |
| 56 | const Tag = @typeInfo(CpuModel).@"union".tag_type.?; | |
| 57 | 57 | const a_tag: Tag = a; |
| 58 | 58 | const b_tag: Tag = b; |
| 59 | 59 | if (a_tag != b_tag) return false; |
| ... | ... | @@ -70,7 +70,7 @@ pub const OsVersion = union(enum) { |
| 70 | 70 | windows: Target.Os.WindowsVersion, |
| 71 | 71 | |
| 72 | 72 | pub fn eql(a: OsVersion, b: OsVersion) bool { |
| 73 | const Tag = @typeInfo(OsVersion).Union.tag_type.?; | |
| 73 | const Tag = @typeInfo(OsVersion).@"union".tag_type.?; | |
| 74 | 74 | const a_tag: Tag = a; |
| 75 | 75 | const b_tag: Tag = b; |
| 76 | 76 | if (a_tag != b_tag) return false; |
lib/std/Target/aarch64.zig+2-2| ... | ... | @@ -242,7 +242,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 242 | 242 | |
| 243 | 243 | pub const all_features = blk: { |
| 244 | 244 | @setEvalBranchQuota(2000); |
| 245 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 245 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 246 | 246 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 247 | 247 | var result: [len]CpuFeature = undefined; |
| 248 | 248 | result[@intFromEnum(Feature.a510)] = .{ |
| ... | ... | @@ -1660,7 +1660,7 @@ pub const all_features = blk: { |
| 1660 | 1660 | const ti = @typeInfo(Feature); |
| 1661 | 1661 | for (&result, 0..) |*elem, i| { |
| 1662 | 1662 | elem.index = i; |
| 1663 | elem.name = ti.Enum.fields[i].name; | |
| 1663 | elem.name = ti.@"enum".fields[i].name; | |
| 1664 | 1664 | } |
| 1665 | 1665 | break :blk result; |
| 1666 | 1666 | }; |
lib/std/Target/amdgpu.zig+2-2| ... | ... | @@ -183,7 +183,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 183 | 183 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 184 | 184 | |
| 185 | 185 | pub const all_features = blk: { |
| 186 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 186 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 187 | 187 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 188 | 188 | var result: [len]CpuFeature = undefined; |
| 189 | 189 | result[@intFromEnum(Feature.@"16_bit_insts")] = .{ |
| ... | ... | @@ -1284,7 +1284,7 @@ pub const all_features = blk: { |
| 1284 | 1284 | const ti = @typeInfo(Feature); |
| 1285 | 1285 | for (&result, 0..) |*elem, i| { |
| 1286 | 1286 | elem.index = i; |
| 1287 | elem.name = ti.Enum.fields[i].name; | |
| 1287 | elem.name = ti.@"enum".fields[i].name; | |
| 1288 | 1288 | } |
| 1289 | 1289 | break :blk result; |
| 1290 | 1290 | }; |
lib/std/Target/arc.zig+2-2| ... | ... | @@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 14 | 14 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 15 | 15 | |
| 16 | 16 | pub const all_features = blk: { |
| 17 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 17 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 18 | 18 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 19 | 19 | var result: [len]CpuFeature = undefined; |
| 20 | 20 | result[@intFromEnum(Feature.norm)] = .{ |
| ... | ... | @@ -25,7 +25,7 @@ pub const all_features = blk: { |
| 25 | 25 | const ti = @typeInfo(Feature); |
| 26 | 26 | for (&result, 0..) |*elem, i| { |
| 27 | 27 | elem.index = i; |
| 28 | elem.name = ti.Enum.fields[i].name; | |
| 28 | elem.name = ti.@"enum".fields[i].name; | |
| 29 | 29 | } |
| 30 | 30 | break :blk result; |
| 31 | 31 | }; |
lib/std/Target/arm.zig+2-2| ... | ... | @@ -215,7 +215,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 215 | 215 | |
| 216 | 216 | pub const all_features = blk: { |
| 217 | 217 | @setEvalBranchQuota(10000); |
| 218 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 218 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 219 | 219 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 220 | 220 | var result: [len]CpuFeature = undefined; |
| 221 | 221 | result[@intFromEnum(Feature.@"32bit")] = .{ |
| ... | ... | @@ -1735,7 +1735,7 @@ pub const all_features = blk: { |
| 1735 | 1735 | const ti = @typeInfo(Feature); |
| 1736 | 1736 | for (&result, 0..) |*elem, i| { |
| 1737 | 1737 | elem.index = i; |
| 1738 | elem.name = ti.Enum.fields[i].name; | |
| 1738 | elem.name = ti.@"enum".fields[i].name; | |
| 1739 | 1739 | } |
| 1740 | 1740 | break :blk result; |
| 1741 | 1741 | }; |
lib/std/Target/avr.zig+2-2| ... | ... | @@ -49,7 +49,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 49 | 49 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 50 | 50 | |
| 51 | 51 | pub const all_features = blk: { |
| 52 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 52 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 53 | 53 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 54 | 54 | var result: [len]CpuFeature = undefined; |
| 55 | 55 | result[@intFromEnum(Feature.addsubiw)] = .{ |
| ... | ... | @@ -340,7 +340,7 @@ pub const all_features = blk: { |
| 340 | 340 | const ti = @typeInfo(Feature); |
| 341 | 341 | for (&result, 0..) |*elem, i| { |
| 342 | 342 | elem.index = i; |
| 343 | elem.name = ti.Enum.fields[i].name; | |
| 343 | elem.name = ti.@"enum".fields[i].name; | |
| 344 | 344 | } |
| 345 | 345 | break :blk result; |
| 346 | 346 | }; |
lib/std/Target/bpf.zig+2-2| ... | ... | @@ -16,7 +16,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 16 | 16 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 17 | 17 | |
| 18 | 18 | pub const all_features = blk: { |
| 19 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 19 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 20 | 20 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 21 | 21 | var result: [len]CpuFeature = undefined; |
| 22 | 22 | result[@intFromEnum(Feature.alu32)] = .{ |
| ... | ... | @@ -37,7 +37,7 @@ pub const all_features = blk: { |
| 37 | 37 | const ti = @typeInfo(Feature); |
| 38 | 38 | for (&result, 0..) |*elem, i| { |
| 39 | 39 | elem.index = i; |
| 40 | elem.name = ti.Enum.fields[i].name; | |
| 40 | elem.name = ti.@"enum".fields[i].name; | |
| 41 | 41 | } |
| 42 | 42 | break :blk result; |
| 43 | 43 | }; |
lib/std/Target/csky.zig+2-2| ... | ... | @@ -76,7 +76,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 76 | 76 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 77 | 77 | |
| 78 | 78 | pub const all_features = blk: { |
| 79 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 79 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 80 | 80 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 81 | 81 | var result: [len]CpuFeature = undefined; |
| 82 | 82 | result[@intFromEnum(Feature.@"10e60")] = .{ |
| ... | ... | @@ -418,7 +418,7 @@ pub const all_features = blk: { |
| 418 | 418 | const ti = @typeInfo(Feature); |
| 419 | 419 | for (&result, 0..) |*elem, i| { |
| 420 | 420 | elem.index = i; |
| 421 | elem.name = ti.Enum.fields[i].name; | |
| 421 | elem.name = ti.@"enum".fields[i].name; | |
| 422 | 422 | } |
| 423 | 423 | break :blk result; |
| 424 | 424 | }; |
lib/std/Target/hexagon.zig+2-2| ... | ... | @@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 55 | 55 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 56 | 56 | |
| 57 | 57 | pub const all_features = blk: { |
| 58 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 58 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 59 | 59 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 60 | 60 | var result: [len]CpuFeature = undefined; |
| 61 | 61 | result[@intFromEnum(Feature.audio)] = .{ |
| ... | ... | @@ -298,7 +298,7 @@ pub const all_features = blk: { |
| 298 | 298 | const ti = @typeInfo(Feature); |
| 299 | 299 | for (&result, 0..) |*elem, i| { |
| 300 | 300 | elem.index = i; |
| 301 | elem.name = ti.Enum.fields[i].name; | |
| 301 | elem.name = ti.@"enum".fields[i].name; | |
| 302 | 302 | } |
| 303 | 303 | break :blk result; |
| 304 | 304 | }; |
lib/std/Target/loongarch.zig+2-2| ... | ... | @@ -28,7 +28,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 28 | 28 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 29 | 29 | |
| 30 | 30 | pub const all_features = blk: { |
| 31 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 31 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 32 | 32 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 33 | 33 | var result: [len]CpuFeature = undefined; |
| 34 | 34 | result[@intFromEnum(Feature.@"32bit")] = .{ |
| ... | ... | @@ -115,7 +115,7 @@ pub const all_features = blk: { |
| 115 | 115 | const ti = @typeInfo(Feature); |
| 116 | 116 | for (&result, 0..) |*elem, i| { |
| 117 | 117 | elem.index = i; |
| 118 | elem.name = ti.Enum.fields[i].name; | |
| 118 | elem.name = ti.@"enum".fields[i].name; | |
| 119 | 119 | } |
| 120 | 120 | break :blk result; |
| 121 | 121 | }; |
lib/std/Target/m68k.zig+2-2| ... | ... | @@ -36,7 +36,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 36 | 36 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 37 | 37 | |
| 38 | 38 | pub const all_features = blk: { |
| 39 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 39 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 40 | 40 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 41 | 41 | var result: [len]CpuFeature = undefined; |
| 42 | 42 | result[@intFromEnum(Feature.isa_68000)] = .{ |
| ... | ... | @@ -170,7 +170,7 @@ pub const all_features = blk: { |
| 170 | 170 | const ti = @typeInfo(Feature); |
| 171 | 171 | for (&result, 0..) |*elem, i| { |
| 172 | 172 | elem.index = i; |
| 173 | elem.name = ti.Enum.fields[i].name; | |
| 173 | elem.name = ti.@"enum".fields[i].name; | |
| 174 | 174 | } |
| 175 | 175 | break :blk result; |
| 176 | 176 | }; |
lib/std/Target/mips.zig+2-2| ... | ... | @@ -65,7 +65,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 65 | 65 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 66 | 66 | |
| 67 | 67 | pub const all_features = blk: { |
| 68 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 68 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 69 | 69 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 70 | 70 | var result: [len]CpuFeature = undefined; |
| 71 | 71 | result[@intFromEnum(Feature.abs2008)] = .{ |
| ... | ... | @@ -389,7 +389,7 @@ pub const all_features = blk: { |
| 389 | 389 | const ti = @typeInfo(Feature); |
| 390 | 390 | for (&result, 0..) |*elem, i| { |
| 391 | 391 | elem.index = i; |
| 392 | elem.name = ti.Enum.fields[i].name; | |
| 392 | elem.name = ti.@"enum".fields[i].name; | |
| 393 | 393 | } |
| 394 | 394 | break :blk result; |
| 395 | 395 | }; |
lib/std/Target/msp430.zig+2-2| ... | ... | @@ -17,7 +17,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 17 | 17 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 18 | 18 | |
| 19 | 19 | pub const all_features = blk: { |
| 20 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 20 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 21 | 21 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 22 | 22 | var result: [len]CpuFeature = undefined; |
| 23 | 23 | result[@intFromEnum(Feature.ext)] = .{ |
| ... | ... | @@ -43,7 +43,7 @@ pub const all_features = blk: { |
| 43 | 43 | const ti = @typeInfo(Feature); |
| 44 | 44 | for (&result, 0..) |*elem, i| { |
| 45 | 45 | elem.index = i; |
| 46 | elem.name = ti.Enum.fields[i].name; | |
| 46 | elem.name = ti.@"enum".fields[i].name; | |
| 47 | 47 | } |
| 48 | 48 | break :blk result; |
| 49 | 49 | }; |
lib/std/Target/nvptx.zig+2-2| ... | ... | @@ -58,7 +58,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 58 | 58 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 59 | 59 | |
| 60 | 60 | pub const all_features = blk: { |
| 61 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 61 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 62 | 62 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 63 | 63 | var result: [len]CpuFeature = undefined; |
| 64 | 64 | result[@intFromEnum(Feature.ptx32)] = .{ |
| ... | ... | @@ -289,7 +289,7 @@ pub const all_features = blk: { |
| 289 | 289 | const ti = @typeInfo(Feature); |
| 290 | 290 | for (&result, 0..) |*elem, i| { |
| 291 | 291 | elem.index = i; |
| 292 | elem.name = ti.Enum.fields[i].name; | |
| 292 | elem.name = ti.@"enum".fields[i].name; | |
| 293 | 293 | } |
| 294 | 294 | break :blk result; |
| 295 | 295 | }; |
lib/std/Target/powerpc.zig+2-2| ... | ... | @@ -95,7 +95,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 95 | 95 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 96 | 96 | |
| 97 | 97 | pub const all_features = blk: { |
| 98 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 98 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 99 | 99 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 100 | 100 | var result: [len]CpuFeature = undefined; |
| 101 | 101 | result[@intFromEnum(Feature.@"64bit")] = .{ |
| ... | ... | @@ -606,7 +606,7 @@ pub const all_features = blk: { |
| 606 | 606 | const ti = @typeInfo(Feature); |
| 607 | 607 | for (&result, 0..) |*elem, i| { |
| 608 | 608 | elem.index = i; |
| 609 | elem.name = ti.Enum.fields[i].name; | |
| 609 | elem.name = ti.@"enum".fields[i].name; | |
| 610 | 610 | } |
| 611 | 611 | break :blk result; |
| 612 | 612 | }; |
lib/std/Target/riscv.zig+2-2| ... | ... | @@ -201,7 +201,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 201 | 201 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 202 | 202 | |
| 203 | 203 | pub const all_features = blk: { |
| 204 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 204 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 205 | 205 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 206 | 206 | var result: [len]CpuFeature = undefined; |
| 207 | 207 | result[@intFromEnum(Feature.@"32bit")] = .{ |
| ... | ... | @@ -1298,7 +1298,7 @@ pub const all_features = blk: { |
| 1298 | 1298 | const ti = @typeInfo(Feature); |
| 1299 | 1299 | for (&result, 0..) |*elem, i| { |
| 1300 | 1300 | elem.index = i; |
| 1301 | elem.name = ti.Enum.fields[i].name; | |
| 1301 | elem.name = ti.@"enum".fields[i].name; | |
| 1302 | 1302 | } |
| 1303 | 1303 | break :blk result; |
| 1304 | 1304 | }; |
lib/std/Target/s390x.zig+2-2| ... | ... | @@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 55 | 55 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 56 | 56 | |
| 57 | 57 | pub const all_features = blk: { |
| 58 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 58 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 59 | 59 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 60 | 60 | var result: [len]CpuFeature = undefined; |
| 61 | 61 | result[@intFromEnum(Feature.backchain)] = .{ |
| ... | ... | @@ -271,7 +271,7 @@ pub const all_features = blk: { |
| 271 | 271 | const ti = @typeInfo(Feature); |
| 272 | 272 | for (&result, 0..) |*elem, i| { |
| 273 | 273 | elem.index = i; |
| 274 | elem.name = ti.Enum.fields[i].name; | |
| 274 | elem.name = ti.@"enum".fields[i].name; | |
| 275 | 275 | } |
| 276 | 276 | break :blk result; |
| 277 | 277 | }; |
lib/std/Target/sparc.zig+2-2| ... | ... | @@ -60,7 +60,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 60 | 60 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 61 | 61 | |
| 62 | 62 | pub const all_features = blk: { |
| 63 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 63 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 64 | 64 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 65 | 65 | var result: [len]CpuFeature = undefined; |
| 66 | 66 | result[@intFromEnum(Feature.deprecated_v8)] = .{ |
| ... | ... | @@ -303,7 +303,7 @@ pub const all_features = blk: { |
| 303 | 303 | const ti = @typeInfo(Feature); |
| 304 | 304 | for (&result, 0..) |*elem, i| { |
| 305 | 305 | elem.index = i; |
| 306 | elem.name = ti.Enum.fields[i].name; | |
| 306 | elem.name = ti.@"enum".fields[i].name; | |
| 307 | 307 | } |
| 308 | 308 | break :blk result; |
| 309 | 309 | }; |
lib/std/Target/spirv.zig+2-2| ... | ... | @@ -301,7 +301,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 301 | 301 | |
| 302 | 302 | pub const all_features = blk: { |
| 303 | 303 | @setEvalBranchQuota(2000); |
| 304 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 304 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 305 | 305 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 306 | 306 | var result: [len]CpuFeature = undefined; |
| 307 | 307 | result[@intFromEnum(Feature.v1_1)] = .{ |
| ... | ... | @@ -2077,7 +2077,7 @@ pub const all_features = blk: { |
| 2077 | 2077 | const ti = @typeInfo(Feature); |
| 2078 | 2078 | for (&result, 0..) |*elem, i| { |
| 2079 | 2079 | elem.index = i; |
| 2080 | elem.name = ti.Enum.fields[i].name; | |
| 2080 | elem.name = ti.@"enum".fields[i].name; | |
| 2081 | 2081 | } |
| 2082 | 2082 | break :blk result; |
| 2083 | 2083 | }; |
lib/std/Target/ve.zig+2-2| ... | ... | @@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 14 | 14 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 15 | 15 | |
| 16 | 16 | pub const all_features = blk: { |
| 17 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 17 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 18 | 18 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 19 | 19 | var result: [len]CpuFeature = undefined; |
| 20 | 20 | result[@intFromEnum(Feature.vpu)] = .{ |
| ... | ... | @@ -25,7 +25,7 @@ pub const all_features = blk: { |
| 25 | 25 | const ti = @typeInfo(Feature); |
| 26 | 26 | for (&result, 0..) |*elem, i| { |
| 27 | 27 | elem.index = i; |
| 28 | elem.name = ti.Enum.fields[i].name; | |
| 28 | elem.name = ti.@"enum".fields[i].name; | |
| 29 | 29 | } |
| 30 | 30 | break :blk result; |
| 31 | 31 | }; |
lib/std/Target/wasm.zig+2-2| ... | ... | @@ -26,7 +26,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 26 | 26 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 27 | 27 | |
| 28 | 28 | pub const all_features = blk: { |
| 29 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 29 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 30 | 30 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 31 | 31 | var result: [len]CpuFeature = undefined; |
| 32 | 32 | result[@intFromEnum(Feature.atomics)] = .{ |
| ... | ... | @@ -97,7 +97,7 @@ pub const all_features = blk: { |
| 97 | 97 | const ti = @typeInfo(Feature); |
| 98 | 98 | for (&result, 0..) |*elem, i| { |
| 99 | 99 | elem.index = i; |
| 100 | elem.name = ti.Enum.fields[i].name; | |
| 100 | elem.name = ti.@"enum".fields[i].name; | |
| 101 | 101 | } |
| 102 | 102 | break :blk result; |
| 103 | 103 | }; |
lib/std/Target/x86.zig+2-2| ... | ... | @@ -199,7 +199,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 199 | 199 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 200 | 200 | |
| 201 | 201 | pub const all_features = blk: { |
| 202 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 202 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 203 | 203 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 204 | 204 | var result: [len]CpuFeature = undefined; |
| 205 | 205 | result[@intFromEnum(Feature.@"16bit_mode")] = .{ |
| ... | ... | @@ -1272,7 +1272,7 @@ pub const all_features = blk: { |
| 1272 | 1272 | const ti = @typeInfo(Feature); |
| 1273 | 1273 | for (&result, 0..) |*elem, i| { |
| 1274 | 1274 | elem.index = i; |
| 1275 | elem.name = ti.Enum.fields[i].name; | |
| 1275 | elem.name = ti.@"enum".fields[i].name; | |
| 1276 | 1276 | } |
| 1277 | 1277 | break :blk result; |
| 1278 | 1278 | }; |
lib/std/Target/xtensa.zig+2-2| ... | ... | @@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; |
| 14 | 14 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; |
| 15 | 15 | |
| 16 | 16 | pub const all_features = blk: { |
| 17 | const len = @typeInfo(Feature).Enum.fields.len; | |
| 17 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 18 | 18 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 19 | 19 | var result: [len]CpuFeature = undefined; |
| 20 | 20 | result[@intFromEnum(Feature.density)] = .{ |
| ... | ... | @@ -25,7 +25,7 @@ pub const all_features = blk: { |
| 25 | 25 | const ti = @typeInfo(Feature); |
| 26 | 26 | for (&result, 0..) |*elem, i| { |
| 27 | 27 | elem.index = i; |
| 28 | elem.name = ti.Enum.fields[i].name; | |
| 28 | elem.name = ti.@"enum".fields[i].name; | |
| 29 | 29 | } |
| 30 | 30 | break :blk result; |
| 31 | 31 | }; |
lib/std/Thread.zig+9-9| ... | ... | @@ -401,15 +401,15 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) { |
| 401 | 401 | const default_value = if (Impl == PosixThreadImpl) null else 0; |
| 402 | 402 | const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', '!noreturn', 'void', or '!void'"; |
| 403 | 403 | |
| 404 | switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) { | |
| 405 | .NoReturn => { | |
| 404 | switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) { | |
| 405 | .noreturn => { | |
| 406 | 406 | @call(.auto, f, args); |
| 407 | 407 | }, |
| 408 | .Void => { | |
| 408 | .void => { | |
| 409 | 409 | @call(.auto, f, args); |
| 410 | 410 | return default_value; |
| 411 | 411 | }, |
| 412 | .Int => |info| { | |
| 412 | .int => |info| { | |
| 413 | 413 | if (info.bits != 8) { |
| 414 | 414 | @compileError(bad_fn_ret); |
| 415 | 415 | } |
| ... | ... | @@ -422,7 +422,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) { |
| 422 | 422 | // pthreads don't support exit status, ignore value |
| 423 | 423 | return default_value; |
| 424 | 424 | }, |
| 425 | .ErrorUnion => |info| { | |
| 425 | .error_union => |info| { | |
| 426 | 426 | switch (info.payload) { |
| 427 | 427 | void, noreturn => { |
| 428 | 428 | @call(.auto, f, args) catch |err| { |
| ... | ... | @@ -850,17 +850,17 @@ const WasiThreadImpl = struct { |
| 850 | 850 | fn entry(ptr: usize) void { |
| 851 | 851 | const w: *@This() = @ptrFromInt(ptr); |
| 852 | 852 | const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'"; |
| 853 | switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) { | |
| 854 | .NoReturn, .Void => { | |
| 853 | switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) { | |
| 854 | .noreturn, .void => { | |
| 855 | 855 | @call(.auto, f, w.args); |
| 856 | 856 | }, |
| 857 | .Int => |info| { | |
| 857 | .int => |info| { | |
| 858 | 858 | if (info.bits != 8) { |
| 859 | 859 | @compileError(bad_fn_ret); |
| 860 | 860 | } |
| 861 | 861 | _ = @call(.auto, f, w.args); // WASI threads don't support exit status, ignore value |
| 862 | 862 | }, |
| 863 | .ErrorUnion => |info| { | |
| 863 | .error_union => |info| { | |
| 864 | 864 | if (info.payload != void) { |
| 865 | 865 | @compileError(bad_fn_ret); |
| 866 | 866 | } |
lib/std/array_hash_map.zig+11-11| ... | ... | @@ -2584,17 +2584,17 @@ pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K |
| 2584 | 2584 | |
| 2585 | 2585 | pub fn autoEqlIsCheap(comptime K: type) bool { |
| 2586 | 2586 | return switch (@typeInfo(K)) { |
| 2587 | .Bool, | |
| 2588 | .Int, | |
| 2589 | .Float, | |
| 2590 | .Pointer, | |
| 2591 | .ComptimeFloat, | |
| 2592 | .ComptimeInt, | |
| 2593 | .Enum, | |
| 2594 | .Fn, | |
| 2595 | .ErrorSet, | |
| 2596 | .AnyFrame, | |
| 2597 | .EnumLiteral, | |
| 2587 | .bool, | |
| 2588 | .int, | |
| 2589 | .float, | |
| 2590 | .pointer, | |
| 2591 | .comptime_float, | |
| 2592 | .comptime_int, | |
| 2593 | .@"enum", | |
| 2594 | .@"fn", | |
| 2595 | .error_set, | |
| 2596 | .@"anyframe", | |
| 2597 | .enum_literal, | |
| 2598 | 2598 | => true, |
| 2599 | 2599 | else => false, |
| 2600 | 2600 | }; |
lib/std/bit_set.zig+2-2| ... | ... | @@ -319,10 +319,10 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { |
| 319 | 319 | const mask_info: std.builtin.Type = @typeInfo(MaskIntType); |
| 320 | 320 | |
| 321 | 321 | // Make sure the mask int is indeed an int |
| 322 | if (mask_info != .Int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType)); | |
| 322 | if (mask_info != .int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType)); | |
| 323 | 323 | |
| 324 | 324 | // It must also be unsigned. |
| 325 | if (mask_info.Int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType)); | |
| 325 | if (mask_info.int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType)); | |
| 326 | 326 | |
| 327 | 327 | // And it must not be empty. |
| 328 | 328 | if (MaskIntType == u0) |
lib/std/builtin.zig+24-24| ... | ... | @@ -257,30 +257,30 @@ pub const TypeId = std.meta.Tag(Type); |
| 257 | 257 | /// This data structure is used by the Zig language code generation and |
| 258 | 258 | /// therefore must be kept in sync with the compiler implementation. |
| 259 | 259 | pub const Type = union(enum) { |
| 260 | Type: void, | |
| 261 | Void: void, | |
| 262 | Bool: void, | |
| 263 | NoReturn: void, | |
| 264 | Int: Int, | |
| 265 | Float: Float, | |
| 266 | Pointer: Pointer, | |
| 267 | Array: Array, | |
| 268 | Struct: Struct, | |
| 269 | ComptimeFloat: void, | |
| 270 | ComptimeInt: void, | |
| 271 | Undefined: void, | |
| 272 | Null: void, | |
| 273 | Optional: Optional, | |
| 274 | ErrorUnion: ErrorUnion, | |
| 275 | ErrorSet: ErrorSet, | |
| 276 | Enum: Enum, | |
| 277 | Union: Union, | |
| 278 | Fn: Fn, | |
| 279 | Opaque: Opaque, | |
| 280 | Frame: Frame, | |
| 281 | AnyFrame: AnyFrame, | |
| 282 | Vector: Vector, | |
| 283 | EnumLiteral: void, | |
| 260 | type: void, | |
| 261 | void: void, | |
| 262 | bool: void, | |
| 263 | noreturn: void, | |
| 264 | int: Int, | |
| 265 | float: Float, | |
| 266 | pointer: Pointer, | |
| 267 | array: Array, | |
| 268 | @"struct": Struct, | |
| 269 | comptime_float: void, | |
| 270 | comptime_int: void, | |
| 271 | undefined: void, | |
| 272 | null: void, | |
| 273 | optional: Optional, | |
| 274 | error_union: ErrorUnion, | |
| 275 | error_set: ErrorSet, | |
| 276 | @"enum": Enum, | |
| 277 | @"union": Union, | |
| 278 | @"fn": Fn, | |
| 279 | @"opaque": Opaque, | |
| 280 | frame: Frame, | |
| 281 | @"anyframe": AnyFrame, | |
| 282 | vector: Vector, | |
| 283 | enum_literal: void, | |
| 284 | 284 | |
| 285 | 285 | /// This data structure is used by the Zig language code generation and |
| 286 | 286 | /// therefore must be kept in sync with the compiler implementation. |
lib/std/c/darwin.zig+1-1| ... | ... | @@ -54,7 +54,7 @@ pub const EXC = enum(exception_type_t) { |
| 54 | 54 | /// Abnormal process exited to corpse state |
| 55 | 55 | CORPSE_NOTIFY = 13, |
| 56 | 56 | |
| 57 | pub const TYPES_COUNT = @typeInfo(EXC).Enum.fields.len; | |
| 57 | pub const TYPES_COUNT = @typeInfo(EXC).@"enum".fields.len; | |
| 58 | 58 | pub const SOFT_SIGNAL = 0x10003; |
| 59 | 59 | |
| 60 | 60 | pub const MASK = packed struct(u32) { |
lib/std/compress/flate/huffman_encoder.zig+1-1| ... | ... | @@ -455,7 +455,7 @@ test "generate a Huffman code for the 30 possible relative distances (LZ77 dista |
| 455 | 455 | // Reverse bit-by-bit a N-bit code. |
| 456 | 456 | fn bitReverse(comptime T: type, value: T, n: usize) T { |
| 457 | 457 | const r = @bitReverse(value); |
| 458 | return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).Int.bits - n)); | |
| 458 | return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).int.bits - n)); | |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | test bitReverse { |
lib/std/crypto/cmac.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ pub const CmacAes128 = Cmac(crypto.core.aes.Aes128); |
| 8 | 8 | /// NIST Special Publication 800-38B - The CMAC Mode for Authentication |
| 9 | 9 | /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38b.pdf |
| 10 | 10 | pub fn Cmac(comptime BlockCipher: type) type { |
| 11 | const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).Fn.return_type.?; | |
| 11 | const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).@"fn".return_type.?; | |
| 12 | 12 | const Block = [BlockCipher.block.block_length]u8; |
| 13 | 13 | |
| 14 | 14 | return struct { |
lib/std/crypto/ff.zig+2-2| ... | ... | @@ -848,7 +848,7 @@ const ct_protected = struct { |
| 848 | 848 | |
| 849 | 849 | // Multiplies two limbs and returns the result as a wide limb. |
| 850 | 850 | fn mulWide(x: Limb, y: Limb) WideLimb { |
| 851 | const half_bits = @typeInfo(Limb).Int.bits / 2; | |
| 851 | const half_bits = @typeInfo(Limb).int.bits / 2; | |
| 852 | 852 | const Half = meta.Int(.unsigned, half_bits); |
| 853 | 853 | const x0 = @as(Half, @truncate(x)); |
| 854 | 854 | const x1 = @as(Half, @truncate(x >> half_bits)); |
| ... | ... | @@ -901,7 +901,7 @@ const ct_unprotected = struct { |
| 901 | 901 | fn mulWide(x: Limb, y: Limb) WideLimb { |
| 902 | 902 | const wide = math.mulWide(Limb, x, y); |
| 903 | 903 | return .{ |
| 904 | .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).Int.bits)), | |
| 904 | .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).int.bits)), | |
| 905 | 905 | .lo = @as(Limb, @truncate(wide)), |
| 906 | 906 | }; |
| 907 | 907 | } |
lib/std/crypto/phc_encoding.zig+8-8| ... | ... | @@ -91,7 +91,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 91 | 91 | if (mem.eql(u8, opt_version.key, version_param_name)) { |
| 92 | 92 | if (@hasField(HashResult, "alg_version")) { |
| 93 | 93 | const value_type_info = switch (@typeInfo(@TypeOf(out.alg_version))) { |
| 94 | .Optional => |opt| comptime @typeInfo(opt.child), | |
| 94 | .optional => |opt| @typeInfo(opt.child), | |
| 95 | 95 | else => |t| t, |
| 96 | 96 | }; |
| 97 | 97 | out.alg_version = fmt.parseUnsigned( |
| ... | ... | @@ -114,16 +114,16 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 114 | 114 | inline for (comptime meta.fields(HashResult)) |p| { |
| 115 | 115 | if (mem.eql(u8, p.name, param.key)) { |
| 116 | 116 | switch (@typeInfo(p.type)) { |
| 117 | .Int => @field(out, p.name) = fmt.parseUnsigned( | |
| 117 | .int => @field(out, p.name) = fmt.parseUnsigned( | |
| 118 | 118 | p.type, |
| 119 | 119 | param.value, |
| 120 | 120 | 10, |
| 121 | 121 | ) catch return Error.InvalidEncoding, |
| 122 | .Pointer => |ptr| { | |
| 122 | .pointer => |ptr| { | |
| 123 | 123 | if (!ptr.is_const) @compileError("Value slice must be constant"); |
| 124 | 124 | @field(out, p.name) = param.value; |
| 125 | 125 | }, |
| 126 | .Struct => try @field(out, p.name).fromB64(param.value), | |
| 126 | .@"struct" => try @field(out, p.name).fromB64(param.value), | |
| 127 | 127 | else => std.debug.panic( |
| 128 | 128 | "Value for [{s}] must be an integer, a constant slice or a BinValue", |
| 129 | 129 | .{p.name}, |
| ... | ... | @@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 164 | 164 | // with default values |
| 165 | 165 | var expected_fields: usize = 0; |
| 166 | 166 | inline for (comptime meta.fields(HashResult)) |p| { |
| 167 | if (@typeInfo(p.type) != .Optional and p.default_value == null) { | |
| 167 | if (@typeInfo(p.type) != .optional and p.default_value == null) { | |
| 168 | 168 | expected_fields += 1; |
| 169 | 169 | } |
| 170 | 170 | } |
| ... | ... | @@ -202,7 +202,7 @@ fn serializeTo(params: anytype, out: anytype) !void { |
| 202 | 202 | try out.writeAll(params.alg_id); |
| 203 | 203 | |
| 204 | 204 | if (@hasField(HashResult, "alg_version")) { |
| 205 | if (@typeInfo(@TypeOf(params.alg_version)) == .Optional) { | |
| 205 | if (@typeInfo(@TypeOf(params.alg_version)) == .optional) { | |
| 206 | 206 | if (params.alg_version) |alg_version| { |
| 207 | 207 | try out.print( |
| 208 | 208 | "{s}{s}{s}{}", |
| ... | ... | @@ -226,12 +226,12 @@ fn serializeTo(params: anytype, out: anytype) !void { |
| 226 | 226 | { |
| 227 | 227 | const value = @field(params, p.name); |
| 228 | 228 | try out.writeAll(if (has_params) params_delimiter else fields_delimiter); |
| 229 | if (@typeInfo(p.type) == .Struct) { | |
| 229 | if (@typeInfo(p.type) == .@"struct") { | |
| 230 | 230 | var buf: [@TypeOf(value).max_encoded_length]u8 = undefined; |
| 231 | 231 | try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) }); |
| 232 | 232 | } else { |
| 233 | 233 | try out.print( |
| 234 | if (@typeInfo(@TypeOf(value)) == .Pointer) "{s}{s}{s}" else "{s}{s}{}", | |
| 234 | if (@typeInfo(@TypeOf(value)) == .pointer) "{s}{s}{s}" else "{s}{s}{}", | |
| 235 | 235 | .{ p.name, kv_delimiter, value }, |
| 236 | 236 | ); |
| 237 | 237 | } |
lib/std/crypto/timing_safe.zig+7-7| ... | ... | @@ -11,27 +11,27 @@ const Order = std.math.Order; |
| 11 | 11 | /// For all other applications, use mem.eql() instead. |
| 12 | 12 | pub fn eql(comptime T: type, a: T, b: T) bool { |
| 13 | 13 | switch (@typeInfo(T)) { |
| 14 | .Array => |info| { | |
| 14 | .array => |info| { | |
| 15 | 15 | const C = info.child; |
| 16 | if (@typeInfo(C) != .Int) { | |
| 16 | if (@typeInfo(C) != .int) { | |
| 17 | 17 | @compileError("Elements to be compared must be integers"); |
| 18 | 18 | } |
| 19 | 19 | var acc = @as(C, 0); |
| 20 | 20 | for (a, 0..) |x, i| { |
| 21 | 21 | acc |= x ^ b[i]; |
| 22 | 22 | } |
| 23 | const s = @typeInfo(C).Int.bits; | |
| 23 | const s = @typeInfo(C).int.bits; | |
| 24 | 24 | const Cu = std.meta.Int(.unsigned, s); |
| 25 | 25 | const Cext = std.meta.Int(.unsigned, s + 1); |
| 26 | 26 | return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s)))); |
| 27 | 27 | }, |
| 28 | .Vector => |info| { | |
| 28 | .vector => |info| { | |
| 29 | 29 | const C = info.child; |
| 30 | if (@typeInfo(C) != .Int) { | |
| 30 | if (@typeInfo(C) != .int) { | |
| 31 | 31 | @compileError("Elements to be compared must be integers"); |
| 32 | 32 | } |
| 33 | 33 | const acc = @reduce(.Or, a ^ b); |
| 34 | const s = @typeInfo(C).Int.bits; | |
| 34 | const s = @typeInfo(C).int.bits; | |
| 35 | 35 | const Cu = std.meta.Int(.unsigned, s); |
| 36 | 36 | const Cext = std.meta.Int(.unsigned, s + 1); |
| 37 | 37 | return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s)))); |
| ... | ... | @@ -47,7 +47,7 @@ pub fn eql(comptime T: type, a: T, b: T) bool { |
| 47 | 47 | pub fn compare(comptime T: type, a: []const T, b: []const T, endian: Endian) Order { |
| 48 | 48 | assert(a.len == b.len); |
| 49 | 49 | const bits = switch (@typeInfo(T)) { |
| 50 | .Int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits, | |
| 50 | .int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits, | |
| 51 | 51 | else => @compileError("Elements to be compared must be integers"), |
| 52 | 52 | }; |
| 53 | 53 | const Cext = std.meta.Int(.unsigned, bits + 1); |
lib/std/crypto/tls.zig+2-2| ... | ... | @@ -491,7 +491,7 @@ pub const Decoder = struct { |
| 491 | 491 | /// Use this function to increase `idx`. |
| 492 | 492 | pub fn decode(d: *Decoder, comptime T: type) T { |
| 493 | 493 | switch (@typeInfo(T)) { |
| 494 | .Int => |info| switch (info.bits) { | |
| 494 | .int => |info| switch (info.bits) { | |
| 495 | 495 | 8 => { |
| 496 | 496 | skip(d, 1); |
| 497 | 497 | return d.buf[d.idx - 1]; |
| ... | ... | @@ -511,7 +511,7 @@ pub const Decoder = struct { |
| 511 | 511 | }, |
| 512 | 512 | else => @compileError("unsupported int type: " ++ @typeName(T)), |
| 513 | 513 | }, |
| 514 | .Enum => |info| { | |
| 514 | .@"enum" => |info| { | |
| 515 | 515 | const int = d.decode(info.tag_type); |
| 516 | 516 | if (info.is_exhaustive) @compileError("exhaustive enum cannot be used"); |
| 517 | 517 | return @as(T, @enumFromInt(int)); |
lib/std/debug.zig+1-1| ... | ... | @@ -547,7 +547,7 @@ pub fn writeStackTrace( |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | pub const UnwindError = if (have_ucontext) |
| 550 | @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).Fn.return_type.?).ErrorUnion.error_set | |
| 550 | @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).@"fn".return_type.?).error_union.error_set | |
| 551 | 551 | else |
| 552 | 552 | void; |
| 553 | 553 |
lib/std/debug/Dwarf.zig+1-1| ... | ... | @@ -2216,7 +2216,7 @@ pub const ElfModule = struct { |
| 2216 | 2216 | } |
| 2217 | 2217 | |
| 2218 | 2218 | var section_index: ?usize = null; |
| 2219 | inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |sect, i| { | |
| 2219 | inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |sect, i| { | |
| 2220 | 2220 | if (mem.eql(u8, "." ++ sect.name, name)) section_index = i; |
| 2221 | 2221 | } |
| 2222 | 2222 | if (section_index == null) continue; |
lib/std/debug/Dwarf/expression.zig+3-3| ... | ... | @@ -164,7 +164,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | fn generic(value: anytype) Operand { |
| 167 | const int_info = @typeInfo(@TypeOf(value)).Int; | |
| 167 | const int_info = @typeInfo(@TypeOf(value)).int; | |
| 168 | 168 | if (@sizeOf(@TypeOf(value)) > options.addr_size) { |
| 169 | 169 | return .{ .generic = switch (int_info.signedness) { |
| 170 | 170 | .signed => @bitCast(@as(addr_type_signed, @truncate(value))), |
| ... | ... | @@ -843,7 +843,7 @@ pub fn Builder(comptime options: Options) type { |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | pub fn writeConst(writer: anytype, comptime T: type, value: T) !void { |
| 846 | if (@typeInfo(T) != .Int) @compileError("Constants must be integers"); | |
| 846 | if (@typeInfo(T) != .int) @compileError("Constants must be integers"); | |
| 847 | 847 | |
| 848 | 848 | switch (T) { |
| 849 | 849 | u8, i8, u16, i16, u32, i32, u64, i64 => { |
| ... | ... | @@ -861,7 +861,7 @@ pub fn Builder(comptime options: Options) type { |
| 861 | 861 | |
| 862 | 862 | try writer.writeInt(T, value, options.endian); |
| 863 | 863 | }, |
| 864 | else => switch (@typeInfo(T).Int.signedness) { | |
| 864 | else => switch (@typeInfo(T).int.signedness) { | |
| 865 | 865 | .unsigned => { |
| 866 | 866 | try writer.writeByte(OP.constu); |
| 867 | 867 | try leb.writeUleb128(writer, value); |
lib/std/debug/FixedBufferReader.zig+1-1| ... | ... | @@ -32,7 +32,7 @@ pub fn readByteSigned(fbr: *FixedBufferReader) Error!i8 { |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | pub fn readInt(fbr: *FixedBufferReader, comptime T: type) Error!T { |
| 35 | const size = @divExact(@typeInfo(T).Int.bits, 8); | |
| 35 | const size = @divExact(@typeInfo(T).int.bits, 8); | |
| 36 | 36 | if (fbr.buf.len - fbr.pos < size) return error.EndOfBuffer; |
| 37 | 37 | defer fbr.pos += size; |
| 38 | 38 | return std.mem.readInt(T, fbr.buf[fbr.pos..][0..size], fbr.endian); |
lib/std/debug/Pdb.zig+1-1| ... | ... | @@ -495,7 +495,7 @@ const MsfStream = struct { |
| 495 | 495 | blocks: []u32 = undefined, |
| 496 | 496 | block_size: u32 = undefined, |
| 497 | 497 | |
| 498 | pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).Fn.return_type.?).ErrorUnion.error_set; | |
| 498 | pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).@"fn".return_type.?).error_union.error_set; | |
| 499 | 499 | |
| 500 | 500 | fn init(block_size: u32, file: File, blocks: []u32) MsfStream { |
| 501 | 501 | const stream = MsfStream{ |
lib/std/debug/SelfInfo.zig+5-5| ... | ... | @@ -37,7 +37,7 @@ modules: if (native_os == .windows) std.ArrayListUnmanaged(WindowsModule) else v |
| 37 | 37 | pub const OpenError = error{ |
| 38 | 38 | MissingDebugInfo, |
| 39 | 39 | UnsupportedOperatingSystem, |
| 40 | } || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).Fn.return_type.?).ErrorUnion.error_set; | |
| 40 | } || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).@"fn".return_type.?).error_union.error_set; | |
| 41 | 41 | |
| 42 | 42 | pub fn open(allocator: Allocator) OpenError!SelfInfo { |
| 43 | 43 | nosuspend { |
| ... | ... | @@ -582,7 +582,7 @@ pub const Module = switch (native_os) { |
| 582 | 582 | if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue; |
| 583 | 583 | |
| 584 | 584 | var section_index: ?usize = null; |
| 585 | inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| { | |
| 585 | inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| { | |
| 586 | 586 | if (mem.eql(u8, "__" ++ section.name, sect.sectName())) section_index = i; |
| 587 | 587 | } |
| 588 | 588 | if (section_index == null) continue; |
| ... | ... | @@ -981,7 +981,7 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module { |
| 981 | 981 | var sections: Dwarf.SectionArray = Dwarf.null_section_array; |
| 982 | 982 | errdefer for (sections) |section| if (section) |s| if (s.owned) allocator.free(s.data); |
| 983 | 983 | |
| 984 | inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| { | |
| 984 | inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| { | |
| 985 | 985 | sections[i] = if (coff_obj.getSectionByName("." ++ section.name)) |section_header| blk: { |
| 986 | 986 | break :blk .{ |
| 987 | 987 | .data = try coff_obj.getSectionDataAlloc(section_header, allocator), |
| ... | ... | @@ -1443,7 +1443,7 @@ pub fn unwindFrameMachO( |
| 1443 | 1443 | if (ma.load(usize, new_sp) == null or ma.load(usize, min_reg_addr) == null) return error.InvalidUnwindInfo; |
| 1444 | 1444 | |
| 1445 | 1445 | var reg_addr = fp - @sizeOf(usize); |
| 1446 | inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).Struct.fields, 0..) |field, i| { | |
| 1446 | inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).@"struct".fields, 0..) |field, i| { | |
| 1447 | 1447 | if (@field(encoding.value.arm64.frame.x_reg_pairs, field.name) != 0) { |
| 1448 | 1448 | (try regValueNative(context.thread_context, 19 + i, reg_context)).* = @as(*const usize, @ptrFromInt(reg_addr)).*; |
| 1449 | 1449 | reg_addr += @sizeOf(usize); |
| ... | ... | @@ -1452,7 +1452,7 @@ pub fn unwindFrameMachO( |
| 1452 | 1452 | } |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).Struct.fields, 0..) |field, i| { | |
| 1455 | inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).@"struct".fields, 0..) |field, i| { | |
| 1456 | 1456 | if (@field(encoding.value.arm64.frame.d_reg_pairs, field.name) != 0) { |
| 1457 | 1457 | // Only the lower half of the 128-bit V registers are restored during unwinding |
| 1458 | 1458 | @memcpy( |
lib/std/enums.zig+31-31| ... | ... | @@ -13,9 +13,9 @@ const eval_branch_quota_cushion = 10; |
| 13 | 13 | /// the first name is used. Each field is of type Data and has the provided |
| 14 | 14 | /// default, which may be undefined. |
| 15 | 15 | pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type { |
| 16 | @setEvalBranchQuota(@typeInfo(E).Enum.fields.len + eval_branch_quota_cushion); | |
| 17 | var struct_fields: [@typeInfo(E).Enum.fields.len]std.builtin.Type.StructField = undefined; | |
| 18 | for (&struct_fields, @typeInfo(E).Enum.fields) |*struct_field, enum_field| { | |
| 16 | @setEvalBranchQuota(@typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion); | |
| 17 | var struct_fields: [@typeInfo(E).@"enum".fields.len]std.builtin.Type.StructField = undefined; | |
| 18 | for (&struct_fields, @typeInfo(E).@"enum".fields) |*struct_field, enum_field| { | |
| 19 | 19 | struct_field.* = .{ |
| 20 | 20 | .name = enum_field.name ++ "", |
| 21 | 21 | .type = Data, |
| ... | ... | @@ -24,7 +24,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def |
| 24 | 24 | .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0, |
| 25 | 25 | }; |
| 26 | 26 | } |
| 27 | return @Type(.{ .Struct = .{ | |
| 27 | return @Type(.{ .@"struct" = .{ | |
| 28 | 28 | .layout = .auto, |
| 29 | 29 | .fields = &struct_fields, |
| 30 | 30 | .decls = &.{}, |
| ... | ... | @@ -49,14 +49,14 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi |
| 49 | 49 | /// Returns the set of all named values in the given enum, in |
| 50 | 50 | /// declaration order. |
| 51 | 51 | pub fn values(comptime E: type) []const E { |
| 52 | return comptime valuesFromFields(E, @typeInfo(E).Enum.fields); | |
| 52 | return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields); | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /// A safe alternative to @tagName() for non-exhaustive enums that doesn't |
| 56 | 56 | /// panic when `e` has no tagged value. |
| 57 | 57 | /// Returns the tag name for `e` or null if no tag exists. |
| 58 | 58 | pub fn tagName(comptime E: type, e: E) ?[]const u8 { |
| 59 | return inline for (@typeInfo(E).Enum.fields) |f| { | |
| 59 | return inline for (@typeInfo(E).@"enum".fields) |f| { | |
| 60 | 60 | if (@intFromEnum(e) == f.value) break f.name; |
| 61 | 61 | } else null; |
| 62 | 62 | } |
| ... | ... | @@ -80,7 +80,7 @@ test tagName { |
| 80 | 80 | pub fn directEnumArrayLen(comptime E: type, comptime max_unused_slots: comptime_int) comptime_int { |
| 81 | 81 | var max_value: comptime_int = -1; |
| 82 | 82 | const max_usize: comptime_int = ~@as(usize, 0); |
| 83 | const fields = @typeInfo(E).Enum.fields; | |
| 83 | const fields = @typeInfo(E).@"enum".fields; | |
| 84 | 84 | for (fields) |f| { |
| 85 | 85 | if (f.value < 0) { |
| 86 | 86 | @compileError("Cannot create a direct enum array for " ++ @typeName(E) ++ ", field ." ++ f.name ++ " has a negative value."); |
| ... | ... | @@ -159,7 +159,7 @@ pub fn directEnumArrayDefault( |
| 159 | 159 | ) [directEnumArrayLen(E, max_unused_slots)]Data { |
| 160 | 160 | const len = comptime directEnumArrayLen(E, max_unused_slots); |
| 161 | 161 | var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined; |
| 162 | inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| { | |
| 162 | inline for (@typeInfo(@TypeOf(init_values)).@"struct".fields) |f| { | |
| 163 | 163 | const enum_value = @field(E, f.name); |
| 164 | 164 | const index = @as(usize, @intCast(@intFromEnum(enum_value))); |
| 165 | 165 | result[index] = @field(init_values, f.name); |
| ... | ... | @@ -204,8 +204,8 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E { |
| 204 | 204 | const V = @TypeOf(value); |
| 205 | 205 | if (V == E) break :blk value; |
| 206 | 206 | const name: ?[]const u8 = switch (@typeInfo(V)) { |
| 207 | .EnumLiteral, .Enum => @tagName(value), | |
| 208 | .Pointer => value, | |
| 207 | .enum_literal, .@"enum" => @tagName(value), | |
| 208 | .pointer => value, | |
| 209 | 209 | else => null, |
| 210 | 210 | }; |
| 211 | 211 | if (name) |n| { |
| ... | ... | @@ -262,9 +262,9 @@ pub fn EnumSet(comptime E: type) type { |
| 262 | 262 | |
| 263 | 263 | /// Initializes the set using a struct of bools |
| 264 | 264 | pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self { |
| 265 | @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); | |
| 265 | @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); | |
| 266 | 266 | var result: Self = .{}; |
| 267 | if (@typeInfo(E).Enum.is_exhaustive) { | |
| 267 | if (@typeInfo(E).@"enum".is_exhaustive) { | |
| 268 | 268 | inline for (0..Self.len) |i| { |
| 269 | 269 | const key = comptime Indexer.keyForIndex(i); |
| 270 | 270 | const tag = @tagName(key); |
| ... | ... | @@ -453,9 +453,9 @@ pub fn EnumMap(comptime E: type, comptime V: type) type { |
| 453 | 453 | |
| 454 | 454 | /// Initializes the map using a sparse struct of optionals |
| 455 | 455 | pub fn init(init_values: EnumFieldStruct(E, ?Value, @as(?Value, null))) Self { |
| 456 | @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); | |
| 456 | @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); | |
| 457 | 457 | var result: Self = .{}; |
| 458 | if (@typeInfo(E).Enum.is_exhaustive) { | |
| 458 | if (@typeInfo(E).@"enum".is_exhaustive) { | |
| 459 | 459 | inline for (0..Self.len) |i| { |
| 460 | 460 | const key = comptime Indexer.keyForIndex(i); |
| 461 | 461 | const tag = @tagName(key); |
| ... | ... | @@ -497,7 +497,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type { |
| 497 | 497 | /// Initializes a full mapping with a provided default. |
| 498 | 498 | /// Consider using EnumArray instead if the map will remain full. |
| 499 | 499 | pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self { |
| 500 | @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); | |
| 500 | @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); | |
| 501 | 501 | var result: Self = .{ |
| 502 | 502 | .bits = Self.BitSet.initFull(), |
| 503 | 503 | .values = undefined, |
| ... | ... | @@ -683,9 +683,9 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 683 | 683 | |
| 684 | 684 | /// Initializes the multiset using a struct of counts. |
| 685 | 685 | pub fn init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self { |
| 686 | @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); | |
| 686 | @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); | |
| 687 | 687 | var self = initWithCount(0); |
| 688 | inline for (@typeInfo(E).Enum.fields) |field| { | |
| 688 | inline for (@typeInfo(E).@"enum".fields) |field| { | |
| 689 | 689 | const c = @field(init_counts, field.name); |
| 690 | 690 | const key = @as(E, @enumFromInt(field.value)); |
| 691 | 691 | self.counts.set(key, c); |
| ... | ... | @@ -757,7 +757,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 757 | 757 | /// Increases the all key counts by given multiset. Caller |
| 758 | 758 | /// asserts operation will not overflow any key. |
| 759 | 759 | pub fn addSetAssertSafe(self: *Self, other: Self) void { |
| 760 | inline for (@typeInfo(E).Enum.fields) |field| { | |
| 760 | inline for (@typeInfo(E).@"enum".fields) |field| { | |
| 761 | 761 | const key = @as(E, @enumFromInt(field.value)); |
| 762 | 762 | self.addAssertSafe(key, other.getCount(key)); |
| 763 | 763 | } |
| ... | ... | @@ -765,7 +765,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 765 | 765 | |
| 766 | 766 | /// Increases the all key counts by given multiset. |
| 767 | 767 | pub fn addSet(self: *Self, other: Self) error{Overflow}!void { |
| 768 | inline for (@typeInfo(E).Enum.fields) |field| { | |
| 768 | inline for (@typeInfo(E).@"enum".fields) |field| { | |
| 769 | 769 | const key = @as(E, @enumFromInt(field.value)); |
| 770 | 770 | try self.add(key, other.getCount(key)); |
| 771 | 771 | } |
| ... | ... | @@ -775,7 +775,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 775 | 775 | /// the given multiset has more key counts than this, |
| 776 | 776 | /// then that key will have a key count of zero. |
| 777 | 777 | pub fn removeSet(self: *Self, other: Self) void { |
| 778 | inline for (@typeInfo(E).Enum.fields) |field| { | |
| 778 | inline for (@typeInfo(E).@"enum".fields) |field| { | |
| 779 | 779 | const key = @as(E, @enumFromInt(field.value)); |
| 780 | 780 | self.remove(key, other.getCount(key)); |
| 781 | 781 | } |
| ... | ... | @@ -784,7 +784,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 784 | 784 | /// Returns true iff all key counts are the same as |
| 785 | 785 | /// given multiset. |
| 786 | 786 | pub fn eql(self: Self, other: Self) bool { |
| 787 | inline for (@typeInfo(E).Enum.fields) |field| { | |
| 787 | inline for (@typeInfo(E).@"enum".fields) |field| { | |
| 788 | 788 | const key = @as(E, @enumFromInt(field.value)); |
| 789 | 789 | if (self.getCount(key) != other.getCount(key)) { |
| 790 | 790 | return false; |
| ... | ... | @@ -796,7 +796,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 796 | 796 | /// Returns true iff all key counts less than or |
| 797 | 797 | /// equal to the given multiset. |
| 798 | 798 | pub fn subsetOf(self: Self, other: Self) bool { |
| 799 | inline for (@typeInfo(E).Enum.fields) |field| { | |
| 799 | inline for (@typeInfo(E).@"enum".fields) |field| { | |
| 800 | 800 | const key = @as(E, @enumFromInt(field.value)); |
| 801 | 801 | if (self.getCount(key) > other.getCount(key)) { |
| 802 | 802 | return false; |
| ... | ... | @@ -808,7 +808,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 808 | 808 | /// Returns true iff all key counts greater than or |
| 809 | 809 | /// equal to the given multiset. |
| 810 | 810 | pub fn supersetOf(self: Self, other: Self) bool { |
| 811 | inline for (@typeInfo(E).Enum.fields) |field| { | |
| 811 | inline for (@typeInfo(E).@"enum".fields) |field| { | |
| 812 | 812 | const key = @as(E, @enumFromInt(field.value)); |
| 813 | 813 | if (self.getCount(key) < other.getCount(key)) { |
| 814 | 814 | return false; |
| ... | ... | @@ -1087,7 +1087,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type { |
| 1087 | 1087 | |
| 1088 | 1088 | /// Initializes values in the enum array, with the specified default. |
| 1089 | 1089 | pub fn initDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self { |
| 1090 | @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); | |
| 1090 | @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); | |
| 1091 | 1091 | var result: Self = .{ .values = undefined }; |
| 1092 | 1092 | inline for (0..Self.len) |i| { |
| 1093 | 1093 | const key = comptime Indexer.keyForIndex(i); |
| ... | ... | @@ -1277,17 +1277,17 @@ test "EnumSet non-exhaustive" { |
| 1277 | 1277 | pub fn EnumIndexer(comptime E: type) type { |
| 1278 | 1278 | // Assumes that the enum fields are sorted in ascending order (optimistic). |
| 1279 | 1279 | // Unsorted enums may require the user to manually increase the quota. |
| 1280 | @setEvalBranchQuota(3 * @typeInfo(E).Enum.fields.len + eval_branch_quota_cushion); | |
| 1280 | @setEvalBranchQuota(3 * @typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion); | |
| 1281 | 1281 | |
| 1282 | if (!@typeInfo(E).Enum.is_exhaustive) { | |
| 1283 | const BackingInt = @typeInfo(E).Enum.tag_type; | |
| 1282 | if (!@typeInfo(E).@"enum".is_exhaustive) { | |
| 1283 | const BackingInt = @typeInfo(E).@"enum".tag_type; | |
| 1284 | 1284 | if (@bitSizeOf(BackingInt) > @bitSizeOf(usize)) |
| 1285 | 1285 | @compileError("Cannot create an enum indexer for a given non-exhaustive enum, tag_type is larger than usize."); |
| 1286 | 1286 | |
| 1287 | 1287 | return struct { |
| 1288 | 1288 | pub const Key: type = E; |
| 1289 | 1289 | |
| 1290 | const backing_int_sign = @typeInfo(BackingInt).Int.signedness; | |
| 1290 | const backing_int_sign = @typeInfo(BackingInt).int.signedness; | |
| 1291 | 1291 | const min_value = std.math.minInt(BackingInt); |
| 1292 | 1292 | const max_value = std.math.maxInt(BackingInt); |
| 1293 | 1293 | |
| ... | ... | @@ -1312,7 +1312,7 @@ pub fn EnumIndexer(comptime E: type) type { |
| 1312 | 1312 | }; |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | const const_fields = @typeInfo(E).Enum.fields; | |
| 1315 | const const_fields = @typeInfo(E).@"enum".fields; | |
| 1316 | 1316 | var fields = const_fields[0..const_fields.len].*; |
| 1317 | 1317 | const fields_len = fields.len; |
| 1318 | 1318 | |
| ... | ... | @@ -1359,7 +1359,7 @@ pub fn EnumIndexer(comptime E: type) type { |
| 1359 | 1359 | // gives up some safety to avoid artificially limiting |
| 1360 | 1360 | // the range of signed enum values to max_isize. |
| 1361 | 1361 | const enum_value = if (min < 0) @as(isize, @bitCast(i)) +% min else i + min; |
| 1362 | return @as(E, @enumFromInt(@as(@typeInfo(E).Enum.tag_type, @intCast(enum_value)))); | |
| 1362 | return @as(E, @enumFromInt(@as(@typeInfo(E).@"enum".tag_type, @intCast(enum_value)))); | |
| 1363 | 1363 | } |
| 1364 | 1364 | }; |
| 1365 | 1365 | } |
| ... | ... | @@ -1411,7 +1411,7 @@ test "EnumIndexer non-exhaustive" { |
| 1411 | 1411 | |
| 1412 | 1412 | const RangedType = std.meta.Int(.unsigned, @bitSizeOf(BackingInt)); |
| 1413 | 1413 | const max_index: comptime_int = std.math.maxInt(RangedType); |
| 1414 | const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).Int.signedness) { | |
| 1414 | const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).int.signedness) { | |
| 1415 | 1415 | .unsigned => 0, |
| 1416 | 1416 | .signed => std.math.divCeil(comptime_int, max_index, 2) catch unreachable, |
| 1417 | 1417 | }; |
lib/std/fmt.zig+38-38| ... | ... | @@ -87,11 +87,11 @@ pub fn format( |
| 87 | 87 | ) !void { |
| 88 | 88 | const ArgsType = @TypeOf(args); |
| 89 | 89 | const args_type_info = @typeInfo(ArgsType); |
| 90 | if (args_type_info != .Struct) { | |
| 90 | if (args_type_info != .@"struct") { | |
| 91 | 91 | @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType)); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | const fields_info = args_type_info.Struct.fields; | |
| 94 | const fields_info = args_type_info.@"struct".fields; | |
| 95 | 95 | if (fields_info.len > max_format_args) { |
| 96 | 96 | @compileError("32 arguments max are supported per format call"); |
| 97 | 97 | } |
| ... | ... | @@ -397,7 +397,7 @@ pub const Parser = struct { |
| 397 | 397 | }; |
| 398 | 398 | |
| 399 | 399 | pub const ArgSetType = u32; |
| 400 | const max_format_args = @typeInfo(ArgSetType).Int.bits; | |
| 400 | const max_format_args = @typeInfo(ArgSetType).int.bits; | |
| 401 | 401 | |
| 402 | 402 | pub const ArgState = struct { |
| 403 | 403 | next_arg: usize = 0, |
| ... | ... | @@ -430,7 +430,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T |
| 430 | 430 | const T = @TypeOf(value); |
| 431 | 431 | |
| 432 | 432 | switch (@typeInfo(T)) { |
| 433 | .Pointer => |info| { | |
| 433 | .pointer => |info| { | |
| 434 | 434 | try writer.writeAll(@typeName(info.child) ++ "@"); |
| 435 | 435 | if (info.size == .Slice) |
| 436 | 436 | try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer) |
| ... | ... | @@ -438,8 +438,8 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T |
| 438 | 438 | try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); |
| 439 | 439 | return; |
| 440 | 440 | }, |
| 441 | .Optional => |info| { | |
| 442 | if (@typeInfo(info.child) == .Pointer) { | |
| 441 | .optional => |info| { | |
| 442 | if (@typeInfo(info.child) == .pointer) { | |
| 443 | 443 | try writer.writeAll(@typeName(info.child) ++ "@"); |
| 444 | 444 | try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); |
| 445 | 445 | return; |
| ... | ... | @@ -456,17 +456,17 @@ const ANY = "any"; |
| 456 | 456 | |
| 457 | 457 | pub fn defaultSpec(comptime T: type) [:0]const u8 { |
| 458 | 458 | switch (@typeInfo(T)) { |
| 459 | .Array => |_| return ANY, | |
| 460 | .Pointer => |ptr_info| switch (ptr_info.size) { | |
| 459 | .array => |_| return ANY, | |
| 460 | .pointer => |ptr_info| switch (ptr_info.size) { | |
| 461 | 461 | .One => switch (@typeInfo(ptr_info.child)) { |
| 462 | .Array => |_| return ANY, | |
| 462 | .array => |_| return ANY, | |
| 463 | 463 | else => {}, |
| 464 | 464 | }, |
| 465 | 465 | .Many, .C => return "*", |
| 466 | 466 | .Slice => return ANY, |
| 467 | 467 | }, |
| 468 | .Optional => |info| return "?" ++ defaultSpec(info.child), | |
| 469 | .ErrorUnion => |info| return "!" ++ defaultSpec(info.payload), | |
| 468 | .optional => |info| return "?" ++ defaultSpec(info.child), | |
| 469 | .error_union => |info| return "!" ++ defaultSpec(info.payload), | |
| 470 | 470 | else => {}, |
| 471 | 471 | } |
| 472 | 472 | return ""; |
| ... | ... | @@ -494,7 +494,7 @@ pub fn formatType( |
| 494 | 494 | const actual_fmt = comptime if (std.mem.eql(u8, fmt, ANY)) |
| 495 | 495 | defaultSpec(T) |
| 496 | 496 | else if (fmt.len != 0 and (fmt[0] == '?' or fmt[0] == '!')) switch (@typeInfo(T)) { |
| 497 | .Optional, .ErrorUnion => fmt, | |
| 497 | .optional, .error_union => fmt, | |
| 498 | 498 | else => stripOptionalOrErrorUnionSpec(fmt), |
| 499 | 499 | } else fmt; |
| 500 | 500 | |
| ... | ... | @@ -507,18 +507,18 @@ pub fn formatType( |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | switch (@typeInfo(T)) { |
| 510 | .ComptimeInt, .Int, .ComptimeFloat, .Float => { | |
| 510 | .comptime_int, .int, .comptime_float, .float => { | |
| 511 | 511 | return formatValue(value, actual_fmt, options, writer); |
| 512 | 512 | }, |
| 513 | .Void => { | |
| 513 | .void => { | |
| 514 | 514 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 515 | 515 | return formatBuf("void", options, writer); |
| 516 | 516 | }, |
| 517 | .Bool => { | |
| 517 | .bool => { | |
| 518 | 518 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 519 | 519 | return formatBuf(if (value) "true" else "false", options, writer); |
| 520 | 520 | }, |
| 521 | .Optional => { | |
| 521 | .optional => { | |
| 522 | 522 | if (actual_fmt.len == 0 or actual_fmt[0] != '?') |
| 523 | 523 | @compileError("cannot format optional without a specifier (i.e. {?} or {any})"); |
| 524 | 524 | const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt); |
| ... | ... | @@ -528,7 +528,7 @@ pub fn formatType( |
| 528 | 528 | return formatBuf("null", options, writer); |
| 529 | 529 | } |
| 530 | 530 | }, |
| 531 | .ErrorUnion => { | |
| 531 | .error_union => { | |
| 532 | 532 | if (actual_fmt.len == 0 or actual_fmt[0] != '!') |
| 533 | 533 | @compileError("cannot format error union without a specifier (i.e. {!} or {any})"); |
| 534 | 534 | const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt); |
| ... | ... | @@ -538,12 +538,12 @@ pub fn formatType( |
| 538 | 538 | return formatType(err, "", options, writer, max_depth); |
| 539 | 539 | } |
| 540 | 540 | }, |
| 541 | .ErrorSet => { | |
| 541 | .error_set => { | |
| 542 | 542 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 543 | 543 | try writer.writeAll("error."); |
| 544 | 544 | return writer.writeAll(@errorName(value)); |
| 545 | 545 | }, |
| 546 | .Enum => |enumInfo| { | |
| 546 | .@"enum" => |enumInfo| { | |
| 547 | 547 | try writer.writeAll(@typeName(T)); |
| 548 | 548 | if (enumInfo.is_exhaustive) { |
| 549 | 549 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| ... | ... | @@ -566,7 +566,7 @@ pub fn formatType( |
| 566 | 566 | try formatType(@intFromEnum(value), actual_fmt, options, writer, max_depth); |
| 567 | 567 | try writer.writeAll(")"); |
| 568 | 568 | }, |
| 569 | .Union => |info| { | |
| 569 | .@"union" => |info| { | |
| 570 | 570 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 571 | 571 | try writer.writeAll(@typeName(T)); |
| 572 | 572 | if (max_depth == 0) { |
| ... | ... | @@ -586,7 +586,7 @@ pub fn formatType( |
| 586 | 586 | try format(writer, "@{x}", .{@intFromPtr(&value)}); |
| 587 | 587 | } |
| 588 | 588 | }, |
| 589 | .Struct => |info| { | |
| 589 | .@"struct" => |info| { | |
| 590 | 590 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 591 | 591 | if (info.is_tuple) { |
| 592 | 592 | // Skip the type and field names when formatting tuples. |
| ... | ... | @@ -621,9 +621,9 @@ pub fn formatType( |
| 621 | 621 | } |
| 622 | 622 | try writer.writeAll(" }"); |
| 623 | 623 | }, |
| 624 | .Pointer => |ptr_info| switch (ptr_info.size) { | |
| 624 | .pointer => |ptr_info| switch (ptr_info.size) { | |
| 625 | 625 | .One => switch (@typeInfo(ptr_info.child)) { |
| 626 | .Array, .Enum, .Union, .Struct => { | |
| 626 | .array, .@"enum", .@"union", .@"struct" => { | |
| 627 | 627 | return formatType(value.*, actual_fmt, options, writer, max_depth); |
| 628 | 628 | }, |
| 629 | 629 | else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }), |
| ... | ... | @@ -658,7 +658,7 @@ pub fn formatType( |
| 658 | 658 | try writer.writeAll(" }"); |
| 659 | 659 | }, |
| 660 | 660 | }, |
| 661 | .Array => |info| { | |
| 661 | .array => |info| { | |
| 662 | 662 | if (actual_fmt.len == 0) |
| 663 | 663 | @compileError("cannot format array without a specifier (i.e. {s} or {any})"); |
| 664 | 664 | if (max_depth == 0) { |
| ... | ... | @@ -676,7 +676,7 @@ pub fn formatType( |
| 676 | 676 | } |
| 677 | 677 | try writer.writeAll(" }"); |
| 678 | 678 | }, |
| 679 | .Vector => |info| { | |
| 679 | .vector => |info| { | |
| 680 | 680 | try writer.writeAll("{ "); |
| 681 | 681 | var i: usize = 0; |
| 682 | 682 | while (i < info.len) : (i += 1) { |
| ... | ... | @@ -687,17 +687,17 @@ pub fn formatType( |
| 687 | 687 | } |
| 688 | 688 | try writer.writeAll(" }"); |
| 689 | 689 | }, |
| 690 | .Fn => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"), | |
| 691 | .Type => { | |
| 690 | .@"fn" => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"), | |
| 691 | .type => { | |
| 692 | 692 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 693 | 693 | return formatBuf(@typeName(value), options, writer); |
| 694 | 694 | }, |
| 695 | .EnumLiteral => { | |
| 695 | .enum_literal => { | |
| 696 | 696 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 697 | 697 | const buffer = [_]u8{'.'} ++ @tagName(value); |
| 698 | 698 | return formatBuf(buffer, options, writer); |
| 699 | 699 | }, |
| 700 | .Null => { | |
| 700 | .null => { | |
| 701 | 701 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); |
| 702 | 702 | return formatBuf("null", options, writer); |
| 703 | 703 | }, |
| ... | ... | @@ -713,9 +713,9 @@ fn formatValue( |
| 713 | 713 | ) !void { |
| 714 | 714 | const T = @TypeOf(value); |
| 715 | 715 | switch (@typeInfo(T)) { |
| 716 | .Float, .ComptimeFloat => return formatFloatValue(value, fmt, options, writer), | |
| 717 | .Int, .ComptimeInt => return formatIntValue(value, fmt, options, writer), | |
| 718 | .Bool => return formatBuf(if (value) "true" else "false", options, writer), | |
| 716 | .float, .comptime_float => return formatFloatValue(value, fmt, options, writer), | |
| 717 | .int, .comptime_int => return formatIntValue(value, fmt, options, writer), | |
| 718 | .bool => return formatBuf(if (value) "true" else "false", options, writer), | |
| 719 | 719 | else => comptime unreachable, |
| 720 | 720 | } |
| 721 | 721 | } |
| ... | ... | @@ -738,13 +738,13 @@ pub fn formatIntValue( |
| 738 | 738 | base = 10; |
| 739 | 739 | case = .lower; |
| 740 | 740 | } else if (comptime std.mem.eql(u8, fmt, "c")) { |
| 741 | if (@typeInfo(@TypeOf(int_value)).Int.bits <= 8) { | |
| 741 | if (@typeInfo(@TypeOf(int_value)).int.bits <= 8) { | |
| 742 | 742 | return formatAsciiChar(@as(u8, int_value), options, writer); |
| 743 | 743 | } else { |
| 744 | 744 | @compileError("cannot print integer that is larger than 8 bits as an ASCII character"); |
| 745 | 745 | } |
| 746 | 746 | } else if (comptime std.mem.eql(u8, fmt, "u")) { |
| 747 | if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) { | |
| 747 | if (@typeInfo(@TypeOf(int_value)).int.bits <= 21) { | |
| 748 | 748 | return formatUnicodeCodepoint(@as(u21, int_value), options, writer); |
| 749 | 749 | } else { |
| 750 | 750 | @compileError("cannot print integer that is larger than 21 bits as an UTF-8 sequence"); |
| ... | ... | @@ -1179,7 +1179,7 @@ pub fn formatInt( |
| 1179 | 1179 | break :blk @as(Int, value); |
| 1180 | 1180 | } else value; |
| 1181 | 1181 | |
| 1182 | const value_info = @typeInfo(@TypeOf(int_value)).Int; | |
| 1182 | const value_info = @typeInfo(@TypeOf(int_value)).int; | |
| 1183 | 1183 | |
| 1184 | 1184 | // The type must have the same size as `base` or be wider in order for the |
| 1185 | 1185 | // division to work |
| ... | ... | @@ -1480,7 +1480,7 @@ pub const ParseIntError = error{ |
| 1480 | 1480 | /// ) !void; |
| 1481 | 1481 | /// |
| 1482 | 1482 | pub fn Formatter(comptime format_fn: anytype) type { |
| 1483 | const Data = @typeInfo(@TypeOf(format_fn)).Fn.params[0].type.?; | |
| 1483 | const Data = @typeInfo(@TypeOf(format_fn)).@"fn".params[0].type.?; | |
| 1484 | 1484 | return struct { |
| 1485 | 1485 | data: Data, |
| 1486 | 1486 | pub fn format( |
| ... | ... | @@ -1624,7 +1624,7 @@ fn parseIntWithSign( |
| 1624 | 1624 | // accumulate into Accumulate which is always 8 bits or larger. this prevents |
| 1625 | 1625 | // `buf_base` from overflowing Result. |
| 1626 | 1626 | const info = @typeInfo(Result); |
| 1627 | const Accumulate = std.meta.Int(info.Int.signedness, @max(8, info.Int.bits)); | |
| 1627 | const Accumulate = std.meta.Int(info.int.signedness, @max(8, info.int.bits)); | |
| 1628 | 1628 | var accumulate: Accumulate = 0; |
| 1629 | 1629 | |
| 1630 | 1630 | if (buf_start[0] == '_' or buf_start[buf_start.len - 1] == '_') return error.InvalidCharacter; |
| ... | ... | @@ -2724,7 +2724,7 @@ pub const hex_charset = "0123456789abcdef"; |
| 2724 | 2724 | /// Converts an unsigned integer of any multiple of u8 to an array of lowercase |
| 2725 | 2725 | /// hex bytes, little endian. |
| 2726 | 2726 | pub fn hex(x: anytype) [@sizeOf(@TypeOf(x)) * 2]u8 { |
| 2727 | comptime assert(@typeInfo(@TypeOf(x)).Int.signedness == .unsigned); | |
| 2727 | comptime assert(@typeInfo(@TypeOf(x)).int.signedness == .unsigned); | |
| 2728 | 2728 | var result: [@sizeOf(@TypeOf(x)) * 2]u8 = undefined; |
| 2729 | 2729 | var i: usize = 0; |
| 2730 | 2730 | while (i < result.len / 2) : (i += 1) { |
lib/std/fmt/format_float.zig+6-6| ... | ... | @@ -12,7 +12,7 @@ pub const min_buffer_size = 53; |
| 12 | 12 | |
| 13 | 13 | /// Returns the minimum buffer size needed to print every float of a specific type and format. |
| 14 | 14 | pub fn bufferSize(comptime mode: Format, comptime T: type) comptime_int { |
| 15 | comptime std.debug.assert(@typeInfo(T) == .Float); | |
| 15 | comptime std.debug.assert(@typeInfo(T) == .float); | |
| 16 | 16 | return switch (mode) { |
| 17 | 17 | .scientific => 53, |
| 18 | 18 | // Based on minimum subnormal values. |
| ... | ... | @@ -60,8 +60,8 @@ pub fn formatFloat(buf: []u8, v_: anytype, options: FormatOptions) FormatError![ |
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | 62 | const T = @TypeOf(v); |
| 63 | comptime std.debug.assert(@typeInfo(T) == .Float); | |
| 64 | const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); | |
| 63 | comptime std.debug.assert(@typeInfo(T) == .float); | |
| 64 | const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); | |
| 65 | 65 | |
| 66 | 66 | const DT = if (@bitSizeOf(T) <= 64) u64 else u128; |
| 67 | 67 | const tables = switch (DT) { |
| ... | ... | @@ -563,13 +563,13 @@ fn pow5Factor(value_: anytype) u32 { |
| 563 | 563 | |
| 564 | 564 | fn multipleOfPowerOf5(value: anytype, p: u32) bool { |
| 565 | 565 | const T = @TypeOf(value); |
| 566 | std.debug.assert(@typeInfo(T) == .Int); | |
| 566 | std.debug.assert(@typeInfo(T) == .int); | |
| 567 | 567 | return pow5Factor(value) >= p; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | fn multipleOfPowerOf2(value: anytype, p: u32) bool { |
| 571 | 571 | const T = @TypeOf(value); |
| 572 | std.debug.assert(@typeInfo(T) == .Int); | |
| 572 | std.debug.assert(@typeInfo(T) == .int); | |
| 573 | 573 | return (value & ((@as(T, 1) << @as(std.math.Log2Int(T), @intCast(p))) - 1)) == 0; |
| 574 | 574 | } |
| 575 | 575 | |
| ... | ... | @@ -1516,7 +1516,7 @@ const FLOAT128_POW5_INV_ERRORS: [154]u64 = .{ |
| 1516 | 1516 | const builtin = @import("builtin"); |
| 1517 | 1517 | |
| 1518 | 1518 | fn check(comptime T: type, value: T, comptime expected: []const u8) !void { |
| 1519 | const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); | |
| 1519 | const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); | |
| 1520 | 1520 | |
| 1521 | 1521 | var buf: [6000]u8 = undefined; |
| 1522 | 1522 | const value_bits: I = @bitCast(value); |
lib/std/fmt/parse_float.zig+2-2| ... | ... | @@ -17,7 +17,7 @@ pub const ParseFloatError = error{ |
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | 19 | pub fn parseFloat(comptime T: type, s: []const u8) ParseFloatError!T { |
| 20 | if (@typeInfo(T) != .Float) { | |
| 20 | if (@typeInfo(T) != .float) { | |
| 21 | 21 | @compileError("Cannot parse a float into a non-floating point type."); |
| 22 | 22 | } |
| 23 | 23 | |
| ... | ... | @@ -128,7 +128,7 @@ test parseFloat { |
| 128 | 128 | |
| 129 | 129 | test "nan and inf" { |
| 130 | 130 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 131 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 131 | const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 132 | 132 | |
| 133 | 133 | try expectEqual(@as(Z, @bitCast(try parseFloat(T, "nAn"))), @as(Z, @bitCast(std.math.nan(T)))); |
| 134 | 134 | try expectEqual(try parseFloat(T, "inF"), std.math.inf(T)); |
lib/std/hash/auto_hash.zig+28-28| ... | ... | @@ -22,7 +22,7 @@ pub const HashStrategy = enum { |
| 22 | 22 | pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 23 | 23 | const info = @typeInfo(@TypeOf(key)); |
| 24 | 24 | |
| 25 | switch (info.Pointer.size) { | |
| 25 | switch (info.pointer.size) { | |
| 26 | 26 | .One => switch (strat) { |
| 27 | 27 | .Shallow => hash(hasher, @intFromPtr(key), .Shallow), |
| 28 | 28 | .Deep => hash(hasher, key.*, .Shallow), |
| ... | ... | @@ -64,7 +64,7 @@ pub fn hashArray(hasher: anytype, key: anytype, comptime strat: HashStrategy) vo |
| 64 | 64 | pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 65 | 65 | const Key = @TypeOf(key); |
| 66 | 66 | const Hasher = switch (@typeInfo(@TypeOf(hasher))) { |
| 67 | .Pointer => |ptr| ptr.child, | |
| 67 | .pointer => |ptr| ptr.child, | |
| 68 | 68 | else => @TypeOf(hasher), |
| 69 | 69 | }; |
| 70 | 70 | |
| ... | ... | @@ -74,24 +74,24 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | switch (@typeInfo(Key)) { |
| 77 | .NoReturn, | |
| 78 | .Opaque, | |
| 79 | .Undefined, | |
| 80 | .Null, | |
| 81 | .ComptimeFloat, | |
| 82 | .ComptimeInt, | |
| 83 | .Type, | |
| 84 | .EnumLiteral, | |
| 85 | .Frame, | |
| 86 | .Float, | |
| 77 | .noreturn, | |
| 78 | .@"opaque", | |
| 79 | .undefined, | |
| 80 | .null, | |
| 81 | .comptime_float, | |
| 82 | .comptime_int, | |
| 83 | .type, | |
| 84 | .enum_literal, | |
| 85 | .frame, | |
| 86 | .float, | |
| 87 | 87 | => @compileError("unable to hash type " ++ @typeName(Key)), |
| 88 | 88 | |
| 89 | .Void => return, | |
| 89 | .void => return, | |
| 90 | 90 | |
| 91 | 91 | // Help the optimizer see that hashing an int is easy by inlining! |
| 92 | 92 | // TODO Check if the situation is better after #561 is resolved. |
| 93 | .Int => |int| switch (int.signedness) { | |
| 94 | .signed => hash(hasher, @as(@Type(.{ .Int = .{ | |
| 93 | .int => |int| switch (int.signedness) { | |
| 94 | .signed => hash(hasher, @as(@Type(.{ .int = .{ | |
| 95 | 95 | .bits = int.bits, |
| 96 | 96 | .signedness = .unsigned, |
| 97 | 97 | } }), @bitCast(key)), strat), |
| ... | ... | @@ -107,18 +107,18 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 107 | 107 | }, |
| 108 | 108 | }, |
| 109 | 109 | |
| 110 | .Bool => hash(hasher, @intFromBool(key), strat), | |
| 111 | .Enum => hash(hasher, @intFromEnum(key), strat), | |
| 112 | .ErrorSet => hash(hasher, @intFromError(key), strat), | |
| 113 | .AnyFrame, .Fn => hash(hasher, @intFromPtr(key), strat), | |
| 110 | .bool => hash(hasher, @intFromBool(key), strat), | |
| 111 | .@"enum" => hash(hasher, @intFromEnum(key), strat), | |
| 112 | .error_set => hash(hasher, @intFromError(key), strat), | |
| 113 | .@"anyframe", .@"fn" => hash(hasher, @intFromPtr(key), strat), | |
| 114 | 114 | |
| 115 | .Pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }), | |
| 115 | .pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }), | |
| 116 | 116 | |
| 117 | .Optional => if (key) |k| hash(hasher, k, strat), | |
| 117 | .optional => if (key) |k| hash(hasher, k, strat), | |
| 118 | 118 | |
| 119 | .Array => hashArray(hasher, key, strat), | |
| 119 | .array => hashArray(hasher, key, strat), | |
| 120 | 120 | |
| 121 | .Vector => |info| { | |
| 121 | .vector => |info| { | |
| 122 | 122 | if (std.meta.hasUniqueRepresentation(Key)) { |
| 123 | 123 | hasher.update(mem.asBytes(&key)); |
| 124 | 124 | } else { |
| ... | ... | @@ -129,7 +129,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 129 | 129 | } |
| 130 | 130 | }, |
| 131 | 131 | |
| 132 | .Struct => |info| { | |
| 132 | .@"struct" => |info| { | |
| 133 | 133 | inline for (info.fields) |field| { |
| 134 | 134 | // We reuse the hash of the previous field as the seed for the |
| 135 | 135 | // next one so that they're dependant. |
| ... | ... | @@ -137,7 +137,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 137 | 137 | } |
| 138 | 138 | }, |
| 139 | 139 | |
| 140 | .Union => |info| { | |
| 140 | .@"union" => |info| { | |
| 141 | 141 | if (info.tag_type) |tag_type| { |
| 142 | 142 | const tag = std.meta.activeTag(key); |
| 143 | 143 | hash(hasher, tag, strat); |
| ... | ... | @@ -155,7 +155,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 155 | 155 | } else @compileError("cannot hash untagged union type: " ++ @typeName(Key) ++ ", provide your own hash function"); |
| 156 | 156 | }, |
| 157 | 157 | |
| 158 | .ErrorUnion => blk: { | |
| 158 | .error_union => blk: { | |
| 159 | 159 | const payload = key catch |err| { |
| 160 | 160 | hash(hasher, err, strat); |
| 161 | 161 | break :blk; |
| ... | ... | @@ -167,9 +167,9 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 167 | 167 | |
| 168 | 168 | inline fn typeContainsSlice(comptime K: type) bool { |
| 169 | 169 | return switch (@typeInfo(K)) { |
| 170 | .Pointer => |info| info.size == .Slice, | |
| 170 | .pointer => |info| info.size == .Slice, | |
| 171 | 171 | |
| 172 | inline .Struct, .Union => |info| { | |
| 172 | inline .@"struct", .@"union" => |info| { | |
| 173 | 173 | inline for (info.fields) |field| { |
| 174 | 174 | if (typeContainsSlice(field.type)) { |
| 175 | 175 | return true; |
lib/std/hash/verify.zig+5-5| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).Fn.return_type.? { | |
| 4 | const HashFn = @typeInfo(@TypeOf(hash_fn)).Fn; | |
| 3 | fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).@"fn".return_type.? { | |
| 4 | const HashFn = @typeInfo(@TypeOf(hash_fn)).@"fn"; | |
| 5 | 5 | if (HashFn.params.len > 1) { |
| 6 | if (@typeInfo(HashFn.params[0].type.?) == .Int) { | |
| 6 | if (@typeInfo(HashFn.params[0].type.?) == .int) { | |
| 7 | 7 | return hash_fn(@intCast(seed), buf); |
| 8 | 8 | } else { |
| 9 | 9 | return hash_fn(buf, @intCast(seed)); |
| ... | ... | @@ -14,7 +14,7 @@ fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typ |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash { |
| 17 | const HashFn = @typeInfo(@TypeOf(Hash.init)).Fn; | |
| 17 | const HashFn = @typeInfo(@TypeOf(Hash.init)).@"fn"; | |
| 18 | 18 | if (HashFn.params.len == 1) { |
| 19 | 19 | return Hash.init(@intCast(seed)); |
| 20 | 20 | } else { |
| ... | ... | @@ -27,7 +27,7 @@ fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash { |
| 27 | 27 | // Hash keys of the form {0}, {0,1}, {0,1,2}... up to N=255, using 256-N as seed. |
| 28 | 28 | // First four-bytes of the hash, interpreted as little-endian is the verification code. |
| 29 | 29 | pub fn smhasher(comptime hash_fn: anytype) u32 { |
| 30 | const HashFnTy = @typeInfo(@TypeOf(hash_fn)).Fn; | |
| 30 | const HashFnTy = @typeInfo(@TypeOf(hash_fn)).@"fn"; | |
| 31 | 31 | const HashResult = HashFnTy.return_type.?; |
| 32 | 32 | const hash_size = @sizeOf(HashResult); |
| 33 | 33 |
lib/std/hash_map.zig+11-11| ... | ... | @@ -139,10 +139,10 @@ pub fn verifyContext( |
| 139 | 139 | var Context = RawContext; |
| 140 | 140 | // Make sure the context is a namespace type which may have member functions |
| 141 | 141 | switch (@typeInfo(Context)) { |
| 142 | .Struct, .Union, .Enum => {}, | |
| 143 | // Special-case .Opaque for a better error message | |
| 144 | .Opaque => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."), | |
| 145 | .Pointer => |ptr| { | |
| 142 | .@"struct", .@"union", .@"enum" => {}, | |
| 143 | // Special-case .@"opaque" for a better error message | |
| 144 | .@"opaque" => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."), | |
| 145 | .pointer => |ptr| { | |
| 146 | 146 | if (ptr.size != .One) { |
| 147 | 147 | @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is not a single pointer."); |
| 148 | 148 | } |
| ... | ... | @@ -150,7 +150,7 @@ pub fn verifyContext( |
| 150 | 150 | allow_const_ptr = true; |
| 151 | 151 | allow_mutable_ptr = !ptr.is_const; |
| 152 | 152 | switch (@typeInfo(Context)) { |
| 153 | .Struct, .Union, .Enum, .Opaque => {}, | |
| 153 | .@"struct", .@"union", .@"enum", .@"opaque" => {}, | |
| 154 | 154 | else => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context)), |
| 155 | 155 | } |
| 156 | 156 | }, |
| ... | ... | @@ -179,8 +179,8 @@ pub fn verifyContext( |
| 179 | 179 | if (@hasDecl(Context, "hash")) { |
| 180 | 180 | const hash = Context.hash; |
| 181 | 181 | const info = @typeInfo(@TypeOf(hash)); |
| 182 | if (info == .Fn) { | |
| 183 | const func = info.Fn; | |
| 182 | if (info == .@"fn") { | |
| 183 | const func = info.@"fn"; | |
| 184 | 184 | if (func.params.len != 2) { |
| 185 | 185 | errors = errors ++ lazy.err_invalid_hash_signature; |
| 186 | 186 | } else { |
| ... | ... | @@ -255,8 +255,8 @@ pub fn verifyContext( |
| 255 | 255 | if (@hasDecl(Context, "eql")) { |
| 256 | 256 | const eql = Context.eql; |
| 257 | 257 | const info = @typeInfo(@TypeOf(eql)); |
| 258 | if (info == .Fn) { | |
| 259 | const func = info.Fn; | |
| 258 | if (info == .@"fn") { | |
| 259 | const func = info.@"fn"; | |
| 260 | 260 | const args_len = if (is_array) 4 else 3; |
| 261 | 261 | if (func.params.len != args_len) { |
| 262 | 262 | errors = errors ++ lazy.err_invalid_eql_signature; |
| ... | ... | @@ -824,8 +824,8 @@ pub fn HashMapUnmanaged( |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | pub fn takeFingerprint(hash: Hash) FingerPrint { |
| 827 | const hash_bits = @typeInfo(Hash).Int.bits; | |
| 828 | const fp_bits = @typeInfo(FingerPrint).Int.bits; | |
| 827 | const hash_bits = @typeInfo(Hash).int.bits; | |
| 828 | const fp_bits = @typeInfo(FingerPrint).int.bits; | |
| 829 | 829 | return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits))); |
| 830 | 830 | } |
| 831 | 831 |
lib/std/heap/logging_allocator.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ pub fn LoggingAllocator( |
| 15 | 15 | /// with the given scope on every call to the allocator. |
| 16 | 16 | /// For logging to a `std.io.Writer` see `std.heap.LogToWriterAllocator` |
| 17 | 17 | pub fn ScopedLoggingAllocator( |
| 18 | comptime scope: @Type(.EnumLiteral), | |
| 18 | comptime scope: @Type(.enum_literal), | |
| 19 | 19 | comptime success_log_level: std.log.Level, |
| 20 | 20 | comptime failure_log_level: std.log.Level, |
| 21 | 21 | ) type { |
lib/std/io.zig+4-4| ... | ... | @@ -434,7 +434,7 @@ pub fn poll( |
| 434 | 434 | comptime StreamEnum: type, |
| 435 | 435 | files: PollFiles(StreamEnum), |
| 436 | 436 | ) Poller(StreamEnum) { |
| 437 | const enum_fields = @typeInfo(StreamEnum).Enum.fields; | |
| 437 | const enum_fields = @typeInfo(StreamEnum).@"enum".fields; | |
| 438 | 438 | var result: Poller(StreamEnum) = undefined; |
| 439 | 439 | |
| 440 | 440 | if (is_windows) result.windows = .{ |
| ... | ... | @@ -473,7 +473,7 @@ pub const PollFifo = std.fifo.LinearFifo(u8, .Dynamic); |
| 473 | 473 | |
| 474 | 474 | pub fn Poller(comptime StreamEnum: type) type { |
| 475 | 475 | return struct { |
| 476 | const enum_fields = @typeInfo(StreamEnum).Enum.fields; | |
| 476 | const enum_fields = @typeInfo(StreamEnum).@"enum".fields; | |
| 477 | 477 | const PollFd = if (is_windows) void else posix.pollfd; |
| 478 | 478 | |
| 479 | 479 | fifos: [enum_fields.len]PollFifo, |
| ... | ... | @@ -676,7 +676,7 @@ fn windowsAsyncRead( |
| 676 | 676 | /// Given an enum, returns a struct with fields of that enum, each field |
| 677 | 677 | /// representing an I/O stream for polling. |
| 678 | 678 | pub fn PollFiles(comptime StreamEnum: type) type { |
| 679 | const enum_fields = @typeInfo(StreamEnum).Enum.fields; | |
| 679 | const enum_fields = @typeInfo(StreamEnum).@"enum".fields; | |
| 680 | 680 | var struct_fields: [enum_fields.len]std.builtin.Type.StructField = undefined; |
| 681 | 681 | for (&struct_fields, enum_fields) |*struct_field, enum_field| { |
| 682 | 682 | struct_field.* = .{ |
| ... | ... | @@ -687,7 +687,7 @@ pub fn PollFiles(comptime StreamEnum: type) type { |
| 687 | 687 | .alignment = @alignOf(fs.File), |
| 688 | 688 | }; |
| 689 | 689 | } |
| 690 | return @Type(.{ .Struct = .{ | |
| 690 | return @Type(.{ .@"struct" = .{ | |
| 691 | 691 | .layout = .auto, |
| 692 | 692 | .fields = &struct_fields, |
| 693 | 693 | .decls = &.{}, |
lib/std/io/Reader.zig+3-3| ... | ... | @@ -277,7 +277,7 @@ pub fn readBoundedBytes(self: Self, comptime num_bytes: usize) anyerror!std.Boun |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | pub inline fn readInt(self: Self, comptime T: type, endian: std.builtin.Endian) anyerror!T { |
| 280 | const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).Int.bits, 8)); | |
| 280 | const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).int.bits, 8)); | |
| 281 | 281 | return mem.readInt(T, &bytes, endian); |
| 282 | 282 | } |
| 283 | 283 | |
| ... | ... | @@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool { |
| 326 | 326 | |
| 327 | 327 | pub fn readStruct(self: Self, comptime T: type) anyerror!T { |
| 328 | 328 | // Only extern and packed structs have defined in-memory layout. |
| 329 | comptime assert(@typeInfo(T).Struct.layout != .auto); | |
| 329 | comptime assert(@typeInfo(T).@"struct".layout != .auto); | |
| 330 | 330 | var res: [1]T = undefined; |
| 331 | 331 | try self.readNoEof(mem.sliceAsBytes(res[0..])); |
| 332 | 332 | return res[0]; |
| ... | ... | @@ -348,7 +348,7 @@ pub fn readEnum(self: Self, comptime Enum: type, endian: std.builtin.Endian) any |
| 348 | 348 | /// An integer was read, but it did not match any of the tags in the supplied enum. |
| 349 | 349 | InvalidValue, |
| 350 | 350 | }; |
| 351 | const type_info = @typeInfo(Enum).Enum; | |
| 351 | const type_info = @typeInfo(Enum).@"enum"; | |
| 352 | 352 | const tag = try self.readInt(type_info.tag_type, endian); |
| 353 | 353 | |
| 354 | 354 | inline for (std.meta.fields(Enum)) |field| { |
lib/std/io/Writer.zig+2-2| ... | ... | @@ -49,14 +49,14 @@ pub fn writeBytesNTimes(self: Self, bytes: []const u8, n: usize) anyerror!void { |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.builtin.Endian) anyerror!void { |
| 52 | var bytes: [@divExact(@typeInfo(T).Int.bits, 8)]u8 = undefined; | |
| 52 | var bytes: [@divExact(@typeInfo(T).int.bits, 8)]u8 = undefined; | |
| 53 | 53 | mem.writeInt(std.math.ByteAlignedInt(@TypeOf(value)), &bytes, value, endian); |
| 54 | 54 | return self.writeAll(&bytes); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | pub fn writeStruct(self: Self, value: anytype) anyerror!void { |
| 58 | 58 | // Only extern and packed structs have defined in-memory layout. |
| 59 | comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto); | |
| 59 | comptime assert(@typeInfo(@TypeOf(value)).@"struct".layout != .auto); | |
| 60 | 60 | return self.writeAll(mem.asBytes(&value)); |
| 61 | 61 | } |
| 62 | 62 |
lib/std/io/bit_writer.zig+1-1| ... | ... | @@ -33,7 +33,7 @@ pub fn BitWriter(comptime endian: std.builtin.Endian, comptime WriterType: type) |
| 33 | 33 | if (bits == 0) return; |
| 34 | 34 | |
| 35 | 35 | const U = @TypeOf(value); |
| 36 | comptime assert(@typeInfo(U).Int.signedness == .unsigned); | |
| 36 | comptime assert(@typeInfo(U).int.signedness == .unsigned); | |
| 37 | 37 | |
| 38 | 38 | //by extending the buffer to a minimum of u8 we can cover a number of edge cases |
| 39 | 39 | // related to shifting and casting. |
lib/std/io/fixed_buffer_stream.zig+3-3| ... | ... | @@ -115,18 +115,18 @@ pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(Slice(@TypeOf(buffer |
| 115 | 115 | |
| 116 | 116 | fn Slice(comptime T: type) type { |
| 117 | 117 | switch (@typeInfo(T)) { |
| 118 | .Pointer => |ptr_info| { | |
| 118 | .pointer => |ptr_info| { | |
| 119 | 119 | var new_ptr_info = ptr_info; |
| 120 | 120 | switch (ptr_info.size) { |
| 121 | 121 | .Slice => {}, |
| 122 | 122 | .One => switch (@typeInfo(ptr_info.child)) { |
| 123 | .Array => |info| new_ptr_info.child = info.child, | |
| 123 | .array => |info| new_ptr_info.child = info.child, | |
| 124 | 124 | else => @compileError("invalid type given to fixedBufferStream"), |
| 125 | 125 | }, |
| 126 | 126 | else => @compileError("invalid type given to fixedBufferStream"), |
| 127 | 127 | } |
| 128 | 128 | new_ptr_info.size = .Slice; |
| 129 | return @Type(.{ .Pointer = new_ptr_info }); | |
| 129 | return @Type(.{ .pointer = new_ptr_info }); | |
| 130 | 130 | }, |
| 131 | 131 | else => @compileError("invalid type given to fixedBufferStream"), |
| 132 | 132 | } |
lib/std/io/multi_writer.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const io = std.io; |
| 4 | 4 | /// Takes a tuple of streams, and constructs a new stream that writes to all of them |
| 5 | 5 | pub fn MultiWriter(comptime Writers: type) type { |
| 6 | 6 | comptime var ErrSet = error{}; |
| 7 | inline for (@typeInfo(Writers).Struct.fields) |field| { | |
| 7 | inline for (@typeInfo(Writers).@"struct".fields) |field| { | |
| 8 | 8 | const StreamType = field.type; |
| 9 | 9 | ErrSet = ErrSet || StreamType.Error; |
| 10 | 10 | } |
lib/std/io/tty.zig+1-1| ... | ... | @@ -75,7 +75,7 @@ pub const Config = union(enum) { |
| 75 | 75 | conf: Config, |
| 76 | 76 | writer: anytype, |
| 77 | 77 | color: Color, |
| 78 | ) (@typeInfo(@TypeOf(writer.writeAll(""))).ErrorUnion.error_set || | |
| 78 | ) (@typeInfo(@TypeOf(writer.writeAll(""))).error_union.error_set || | |
| 79 | 79 | windows.SetConsoleTextAttributeError)!void { |
| 80 | 80 | nosuspend switch (conf) { |
| 81 | 81 | .no_color => return, |
lib/std/json/static.zig+23-23| ... | ... | @@ -219,14 +219,14 @@ pub fn innerParse( |
| 219 | 219 | options: ParseOptions, |
| 220 | 220 | ) ParseError(@TypeOf(source.*))!T { |
| 221 | 221 | switch (@typeInfo(T)) { |
| 222 | .Bool => { | |
| 222 | .bool => { | |
| 223 | 223 | return switch (try source.next()) { |
| 224 | 224 | .true => true, |
| 225 | 225 | .false => false, |
| 226 | 226 | else => error.UnexpectedToken, |
| 227 | 227 | }; |
| 228 | 228 | }, |
| 229 | .Float, .ComptimeFloat => { | |
| 229 | .float, .comptime_float => { | |
| 230 | 230 | const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?); |
| 231 | 231 | defer freeAllocated(allocator, token); |
| 232 | 232 | const slice = switch (token) { |
| ... | ... | @@ -235,7 +235,7 @@ pub fn innerParse( |
| 235 | 235 | }; |
| 236 | 236 | return try std.fmt.parseFloat(T, slice); |
| 237 | 237 | }, |
| 238 | .Int, .ComptimeInt => { | |
| 238 | .int, .comptime_int => { | |
| 239 | 239 | const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?); |
| 240 | 240 | defer freeAllocated(allocator, token); |
| 241 | 241 | const slice = switch (token) { |
| ... | ... | @@ -244,7 +244,7 @@ pub fn innerParse( |
| 244 | 244 | }; |
| 245 | 245 | return sliceToInt(T, slice); |
| 246 | 246 | }, |
| 247 | .Optional => |optionalInfo| { | |
| 247 | .optional => |optionalInfo| { | |
| 248 | 248 | switch (try source.peekNextTokenType()) { |
| 249 | 249 | .null => { |
| 250 | 250 | _ = try source.next(); |
| ... | ... | @@ -255,7 +255,7 @@ pub fn innerParse( |
| 255 | 255 | }, |
| 256 | 256 | } |
| 257 | 257 | }, |
| 258 | .Enum => { | |
| 258 | .@"enum" => { | |
| 259 | 259 | if (std.meta.hasFn(T, "jsonParse")) { |
| 260 | 260 | return T.jsonParse(allocator, source, options); |
| 261 | 261 | } |
| ... | ... | @@ -268,7 +268,7 @@ pub fn innerParse( |
| 268 | 268 | }; |
| 269 | 269 | return sliceToEnum(T, slice); |
| 270 | 270 | }, |
| 271 | .Union => |unionInfo| { | |
| 271 | .@"union" => |unionInfo| { | |
| 272 | 272 | if (std.meta.hasFn(T, "jsonParse")) { |
| 273 | 273 | return T.jsonParse(allocator, source, options); |
| 274 | 274 | } |
| ... | ... | @@ -313,7 +313,7 @@ pub fn innerParse( |
| 313 | 313 | return result.?; |
| 314 | 314 | }, |
| 315 | 315 | |
| 316 | .Struct => |structInfo| { | |
| 316 | .@"struct" => |structInfo| { | |
| 317 | 317 | if (structInfo.is_tuple) { |
| 318 | 318 | if (.array_begin != try source.next()) return error.UnexpectedToken; |
| 319 | 319 | |
| ... | ... | @@ -385,7 +385,7 @@ pub fn innerParse( |
| 385 | 385 | return r; |
| 386 | 386 | }, |
| 387 | 387 | |
| 388 | .Array => |arrayInfo| { | |
| 388 | .array => |arrayInfo| { | |
| 389 | 389 | switch (try source.peekNextTokenType()) { |
| 390 | 390 | .array_begin => { |
| 391 | 391 | // Typical array. |
| ... | ... | @@ -440,7 +440,7 @@ pub fn innerParse( |
| 440 | 440 | } |
| 441 | 441 | }, |
| 442 | 442 | |
| 443 | .Vector => |vecInfo| { | |
| 443 | .vector => |vecInfo| { | |
| 444 | 444 | switch (try source.peekNextTokenType()) { |
| 445 | 445 | .array_begin => { |
| 446 | 446 | return internalParseArray(T, vecInfo.child, vecInfo.len, allocator, source, options); |
| ... | ... | @@ -449,7 +449,7 @@ pub fn innerParse( |
| 449 | 449 | } |
| 450 | 450 | }, |
| 451 | 451 | |
| 452 | .Pointer => |ptrInfo| { | |
| 452 | .pointer => |ptrInfo| { | |
| 453 | 453 | switch (ptrInfo.size) { |
| 454 | 454 | .One => { |
| 455 | 455 | const r: *ptrInfo.child = try allocator.create(ptrInfo.child); |
| ... | ... | @@ -550,13 +550,13 @@ pub fn innerParseFromValue( |
| 550 | 550 | options: ParseOptions, |
| 551 | 551 | ) ParseFromValueError!T { |
| 552 | 552 | switch (@typeInfo(T)) { |
| 553 | .Bool => { | |
| 553 | .bool => { | |
| 554 | 554 | switch (source) { |
| 555 | 555 | .bool => |b| return b, |
| 556 | 556 | else => return error.UnexpectedToken, |
| 557 | 557 | } |
| 558 | 558 | }, |
| 559 | .Float, .ComptimeFloat => { | |
| 559 | .float, .comptime_float => { | |
| 560 | 560 | switch (source) { |
| 561 | 561 | .float => |f| return @as(T, @floatCast(f)), |
| 562 | 562 | .integer => |i| return @as(T, @floatFromInt(i)), |
| ... | ... | @@ -564,7 +564,7 @@ pub fn innerParseFromValue( |
| 564 | 564 | else => return error.UnexpectedToken, |
| 565 | 565 | } |
| 566 | 566 | }, |
| 567 | .Int, .ComptimeInt => { | |
| 567 | .int, .comptime_int => { | |
| 568 | 568 | switch (source) { |
| 569 | 569 | .float => |f| { |
| 570 | 570 | if (@round(f) != f) return error.InvalidNumber; |
| ... | ... | @@ -583,13 +583,13 @@ pub fn innerParseFromValue( |
| 583 | 583 | else => return error.UnexpectedToken, |
| 584 | 584 | } |
| 585 | 585 | }, |
| 586 | .Optional => |optionalInfo| { | |
| 586 | .optional => |optionalInfo| { | |
| 587 | 587 | switch (source) { |
| 588 | 588 | .null => return null, |
| 589 | 589 | else => return try innerParseFromValue(optionalInfo.child, allocator, source, options), |
| 590 | 590 | } |
| 591 | 591 | }, |
| 592 | .Enum => { | |
| 592 | .@"enum" => { | |
| 593 | 593 | if (std.meta.hasFn(T, "jsonParseFromValue")) { |
| 594 | 594 | return T.jsonParseFromValue(allocator, source, options); |
| 595 | 595 | } |
| ... | ... | @@ -601,7 +601,7 @@ pub fn innerParseFromValue( |
| 601 | 601 | else => return error.UnexpectedToken, |
| 602 | 602 | } |
| 603 | 603 | }, |
| 604 | .Union => |unionInfo| { | |
| 604 | .@"union" => |unionInfo| { | |
| 605 | 605 | if (std.meta.hasFn(T, "jsonParseFromValue")) { |
| 606 | 606 | return T.jsonParseFromValue(allocator, source, options); |
| 607 | 607 | } |
| ... | ... | @@ -631,7 +631,7 @@ pub fn innerParseFromValue( |
| 631 | 631 | return error.UnknownField; |
| 632 | 632 | }, |
| 633 | 633 | |
| 634 | .Struct => |structInfo| { | |
| 634 | .@"struct" => |structInfo| { | |
| 635 | 635 | if (structInfo.is_tuple) { |
| 636 | 636 | if (source != .array) return error.UnexpectedToken; |
| 637 | 637 | if (source.array.items.len != structInfo.fields.len) return error.UnexpectedToken; |
| ... | ... | @@ -674,7 +674,7 @@ pub fn innerParseFromValue( |
| 674 | 674 | return r; |
| 675 | 675 | }, |
| 676 | 676 | |
| 677 | .Array => |arrayInfo| { | |
| 677 | .array => |arrayInfo| { | |
| 678 | 678 | switch (source) { |
| 679 | 679 | .array => |array| { |
| 680 | 680 | // Typical array. |
| ... | ... | @@ -695,7 +695,7 @@ pub fn innerParseFromValue( |
| 695 | 695 | } |
| 696 | 696 | }, |
| 697 | 697 | |
| 698 | .Vector => |vecInfo| { | |
| 698 | .vector => |vecInfo| { | |
| 699 | 699 | switch (source) { |
| 700 | 700 | .array => |array| { |
| 701 | 701 | return innerParseArrayFromArrayValue(T, vecInfo.child, vecInfo.len, allocator, array, options); |
| ... | ... | @@ -704,7 +704,7 @@ pub fn innerParseFromValue( |
| 704 | 704 | } |
| 705 | 705 | }, |
| 706 | 706 | |
| 707 | .Pointer => |ptrInfo| { | |
| 707 | .pointer => |ptrInfo| { | |
| 708 | 708 | switch (ptrInfo.size) { |
| 709 | 709 | .One => { |
| 710 | 710 | const r: *ptrInfo.child = try allocator.create(ptrInfo.child); |
| ... | ... | @@ -780,12 +780,12 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T { |
| 780 | 780 | if (std.meta.stringToEnum(T, slice)) |value| return value; |
| 781 | 781 | // Check for a numeric value. |
| 782 | 782 | if (!isNumberFormattedLikeAnInteger(slice)) return error.InvalidEnumTag; |
| 783 | const n = std.fmt.parseInt(@typeInfo(T).Enum.tag_type, slice, 10) catch return error.InvalidEnumTag; | |
| 783 | const n = std.fmt.parseInt(@typeInfo(T).@"enum".tag_type, slice, 10) catch return error.InvalidEnumTag; | |
| 784 | 784 | return std.meta.intToEnum(T, n); |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).Struct.fields.len]bool) !void { | |
| 788 | inline for (@typeInfo(T).Struct.fields, 0..) |field, i| { | |
| 787 | fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).@"struct".fields.len]bool) !void { | |
| 788 | inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| { | |
| 789 | 789 | if (!fields_seen[i]) { |
| 790 | 790 | if (field.default_value) |default_ptr| { |
| 791 | 791 | const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*; |
lib/std/json/stringify.zig+16-16| ... | ... | @@ -493,7 +493,7 @@ pub fn WriteStream( |
| 493 | 493 | if (build_mode_has_safety) assert(self.raw_streaming_mode == .none); |
| 494 | 494 | const T = @TypeOf(value); |
| 495 | 495 | switch (@typeInfo(T)) { |
| 496 | .Int => { | |
| 496 | .int => { | |
| 497 | 497 | try self.valueStart(); |
| 498 | 498 | if (self.options.emit_nonportable_numbers_as_strings and |
| 499 | 499 | (value <= -(1 << 53) or value >= (1 << 53))) |
| ... | ... | @@ -505,10 +505,10 @@ pub fn WriteStream( |
| 505 | 505 | self.valueDone(); |
| 506 | 506 | return; |
| 507 | 507 | }, |
| 508 | .ComptimeInt => { | |
| 508 | .comptime_int => { | |
| 509 | 509 | return self.write(@as(std.math.IntFittingRange(value, value), value)); |
| 510 | 510 | }, |
| 511 | .Float, .ComptimeFloat => { | |
| 511 | .float, .comptime_float => { | |
| 512 | 512 | if (@as(f64, @floatCast(value)) == value) { |
| 513 | 513 | try self.valueStart(); |
| 514 | 514 | try self.stream.print("{}", .{@as(f64, @floatCast(value))}); |
| ... | ... | @@ -521,38 +521,38 @@ pub fn WriteStream( |
| 521 | 521 | return; |
| 522 | 522 | }, |
| 523 | 523 | |
| 524 | .Bool => { | |
| 524 | .bool => { | |
| 525 | 525 | try self.valueStart(); |
| 526 | 526 | try self.stream.writeAll(if (value) "true" else "false"); |
| 527 | 527 | self.valueDone(); |
| 528 | 528 | return; |
| 529 | 529 | }, |
| 530 | .Null => { | |
| 530 | .null => { | |
| 531 | 531 | try self.valueStart(); |
| 532 | 532 | try self.stream.writeAll("null"); |
| 533 | 533 | self.valueDone(); |
| 534 | 534 | return; |
| 535 | 535 | }, |
| 536 | .Optional => { | |
| 536 | .optional => { | |
| 537 | 537 | if (value) |payload| { |
| 538 | 538 | return try self.write(payload); |
| 539 | 539 | } else { |
| 540 | 540 | return try self.write(null); |
| 541 | 541 | } |
| 542 | 542 | }, |
| 543 | .Enum, .EnumLiteral => { | |
| 543 | .@"enum", .enum_literal => { | |
| 544 | 544 | if (std.meta.hasFn(T, "jsonStringify")) { |
| 545 | 545 | return value.jsonStringify(self); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | return self.stringValue(@tagName(value)); |
| 549 | 549 | }, |
| 550 | .Union => { | |
| 550 | .@"union" => { | |
| 551 | 551 | if (std.meta.hasFn(T, "jsonStringify")) { |
| 552 | 552 | return value.jsonStringify(self); |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | const info = @typeInfo(T).Union; | |
| 555 | const info = @typeInfo(T).@"union"; | |
| 556 | 556 | if (info.tag_type) |UnionTagType| { |
| 557 | 557 | try self.beginObject(); |
| 558 | 558 | inline for (info.fields) |u_field| { |
| ... | ... | @@ -576,7 +576,7 @@ pub fn WriteStream( |
| 576 | 576 | @compileError("Unable to stringify untagged union '" ++ @typeName(T) ++ "'"); |
| 577 | 577 | } |
| 578 | 578 | }, |
| 579 | .Struct => |S| { | |
| 579 | .@"struct" => |S| { | |
| 580 | 580 | if (std.meta.hasFn(T, "jsonStringify")) { |
| 581 | 581 | return value.jsonStringify(self); |
| 582 | 582 | } |
| ... | ... | @@ -593,7 +593,7 @@ pub fn WriteStream( |
| 593 | 593 | var emit_field = true; |
| 594 | 594 | |
| 595 | 595 | // don't include optional fields that are null when emit_null_optional_fields is set to false |
| 596 | if (@typeInfo(Field.type) == .Optional) { | |
| 596 | if (@typeInfo(Field.type) == .optional) { | |
| 597 | 597 | if (self.options.emit_null_optional_fields == false) { |
| 598 | 598 | if (@field(value, Field.name) == null) { |
| 599 | 599 | emit_field = false; |
| ... | ... | @@ -615,10 +615,10 @@ pub fn WriteStream( |
| 615 | 615 | } |
| 616 | 616 | return; |
| 617 | 617 | }, |
| 618 | .ErrorSet => return self.stringValue(@errorName(value)), | |
| 619 | .Pointer => |ptr_info| switch (ptr_info.size) { | |
| 618 | .error_set => return self.stringValue(@errorName(value)), | |
| 619 | .pointer => |ptr_info| switch (ptr_info.size) { | |
| 620 | 620 | .One => switch (@typeInfo(ptr_info.child)) { |
| 621 | .Array => { | |
| 621 | .array => { | |
| 622 | 622 | // Coerce `*[N]T` to `[]const T`. |
| 623 | 623 | const Slice = []const std.meta.Elem(ptr_info.child); |
| 624 | 624 | return self.write(@as(Slice, value)); |
| ... | ... | @@ -648,11 +648,11 @@ pub fn WriteStream( |
| 648 | 648 | }, |
| 649 | 649 | else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"), |
| 650 | 650 | }, |
| 651 | .Array => { | |
| 651 | .array => { | |
| 652 | 652 | // Coerce `[N]T` to `*const [N]T` (and then to `[]const T`). |
| 653 | 653 | return self.write(&value); |
| 654 | 654 | }, |
| 655 | .Vector => |info| { | |
| 655 | .vector => |info| { | |
| 656 | 656 | const array: [info.len]info.child = value; |
| 657 | 657 | return self.write(&array); |
| 658 | 658 | }, |
lib/std/leb128.zig+19-19| ... | ... | @@ -4,10 +4,10 @@ const testing = std.testing; |
| 4 | 4 | /// Read a single unsigned LEB128 value from the given reader as type T, |
| 5 | 5 | /// or error.Overflow if the value cannot fit. |
| 6 | 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 | 8 | const ShiftT = std.math.Log2Int(U); |
| 9 | 9 | |
| 10 | const max_group = (@typeInfo(U).Int.bits + 6) / 7; | |
| 10 | const max_group = (@typeInfo(U).int.bits + 6) / 7; | |
| 11 | 11 | |
| 12 | 12 | var value: U = 0; |
| 13 | 13 | var group: ShiftT = 0; |
| ... | ... | @@ -42,7 +42,7 @@ pub fn writeUleb128(writer: anytype, arg: anytype) !void { |
| 42 | 42 | comptime_int => std.math.IntFittingRange(arg, arg), |
| 43 | 43 | else => Arg, |
| 44 | 44 | }; |
| 45 | const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int; | |
| 45 | const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int; | |
| 46 | 46 | var value: Value = arg; |
| 47 | 47 | |
| 48 | 48 | while (true) { |
| ... | ... | @@ -63,11 +63,11 @@ pub const writeULEB128 = writeUleb128; |
| 63 | 63 | /// Read a single signed LEB128 value from the given reader as type T, |
| 64 | 64 | /// or error.Overflow if the value cannot fit. |
| 65 | 65 | pub fn readIleb128(comptime T: type, reader: anytype) !T { |
| 66 | const S = if (@typeInfo(T).Int.bits < 8) i8 else T; | |
| 67 | const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits); | |
| 66 | const S = if (@typeInfo(T).int.bits < 8) i8 else T; | |
| 67 | const U = std.meta.Int(.unsigned, @typeInfo(S).int.bits); | |
| 68 | 68 | const ShiftU = std.math.Log2Int(U); |
| 69 | 69 | |
| 70 | const max_group = (@typeInfo(U).Int.bits + 6) / 7; | |
| 70 | const max_group = (@typeInfo(U).int.bits + 6) / 7; | |
| 71 | 71 | |
| 72 | 72 | var value = @as(U, 0); |
| 73 | 73 | var group = @as(ShiftU, 0); |
| ... | ... | @@ -83,14 +83,14 @@ pub fn readIleb128(comptime T: type, reader: anytype) !T { |
| 83 | 83 | if (@as(S, @bitCast(ov[0])) >= 0) return error.Overflow; |
| 84 | 84 | |
| 85 | 85 | // and all the overflowed bits are 1 |
| 86 | const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift))); | |
| 86 | const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift))); | |
| 87 | 87 | const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift; |
| 88 | 88 | if (remaining_bits != -1) return error.Overflow; |
| 89 | 89 | } else { |
| 90 | 90 | // If we don't overflow and this is the last byte and the number being decoded |
| 91 | 91 | // is negative, check that the remaining bits are 1 |
| 92 | 92 | if ((byte & 0x80 == 0) and (@as(S, @bitCast(ov[0])) < 0)) { |
| 93 | const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift))); | |
| 93 | const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift))); | |
| 94 | 94 | const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift; |
| 95 | 95 | if (remaining_bits != -1) return error.Overflow; |
| 96 | 96 | } |
| ... | ... | @@ -128,8 +128,8 @@ pub fn writeIleb128(writer: anytype, arg: anytype) !void { |
| 128 | 128 | comptime_int => std.math.IntFittingRange(-@abs(arg), @abs(arg)), |
| 129 | 129 | else => Arg, |
| 130 | 130 | }; |
| 131 | const Signed = if (@typeInfo(Int).Int.bits < 8) i8 else Int; | |
| 132 | const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).Int.bits); | |
| 131 | const Signed = if (@typeInfo(Int).int.bits < 8) i8 else Int; | |
| 132 | const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).int.bits); | |
| 133 | 133 | var value: Signed = arg; |
| 134 | 134 | |
| 135 | 135 | while (true) { |
| ... | ... | @@ -165,7 +165,7 @@ pub fn writeUnsignedExtended(slice: []u8, arg: anytype) void { |
| 165 | 165 | comptime_int => std.math.IntFittingRange(arg, arg), |
| 166 | 166 | else => Arg, |
| 167 | 167 | }; |
| 168 | const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int; | |
| 168 | const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int; | |
| 169 | 169 | var value: Value = arg; |
| 170 | 170 | |
| 171 | 171 | for (slice[0 .. slice.len - 1]) |*byte| { |
| ... | ... | @@ -210,7 +210,7 @@ test writeUnsignedFixed { |
| 210 | 210 | /// different value without shifting all the following code. |
| 211 | 211 | pub fn writeSignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.signed, l * 7)) void { |
| 212 | 212 | const T = @TypeOf(int); |
| 213 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; | |
| 213 | const U = if (@typeInfo(T).int.bits < 8) u8 else T; | |
| 214 | 214 | var value: U = @intCast(int); |
| 215 | 215 | |
| 216 | 216 | comptime var i = 0; |
| ... | ... | @@ -388,7 +388,7 @@ test "deserialize unsigned LEB128" { |
| 388 | 388 | |
| 389 | 389 | fn test_write_leb128(value: anytype) !void { |
| 390 | 390 | const T = @TypeOf(value); |
| 391 | const signedness = @typeInfo(T).Int.signedness; | |
| 391 | const signedness = @typeInfo(T).int.signedness; | |
| 392 | 392 | const t_signed = signedness == .signed; |
| 393 | 393 | |
| 394 | 394 | const writeStream = if (t_signed) writeIleb128 else writeUleb128; |
| ... | ... | @@ -396,19 +396,19 @@ fn test_write_leb128(value: anytype) !void { |
| 396 | 396 | |
| 397 | 397 | // decode to a larger bit size too, to ensure sign extension |
| 398 | 398 | // is working as expected |
| 399 | const larger_type_bits = ((@typeInfo(T).Int.bits + 8) / 8) * 8; | |
| 399 | const larger_type_bits = ((@typeInfo(T).int.bits + 8) / 8) * 8; | |
| 400 | 400 | const B = std.meta.Int(signedness, larger_type_bits); |
| 401 | 401 | |
| 402 | 402 | const bytes_needed = bn: { |
| 403 | if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1); | |
| 403 | if (@typeInfo(T).int.bits <= 7) break :bn @as(u16, 1); | |
| 404 | 404 | |
| 405 | 405 | const unused_bits = if (value < 0) @clz(~value) else @clz(value); |
| 406 | const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @intFromBool(t_signed); | |
| 406 | const used_bits: u16 = (@typeInfo(T).int.bits - unused_bits) + @intFromBool(t_signed); | |
| 407 | 407 | if (used_bits <= 7) break :bn @as(u16, 1); |
| 408 | 408 | break :bn ((used_bits + 6) / 7); |
| 409 | 409 | }; |
| 410 | 410 | |
| 411 | const max_groups = if (@typeInfo(T).Int.bits == 0) 1 else (@typeInfo(T).Int.bits + 6) / 7; | |
| 411 | const max_groups = if (@typeInfo(T).int.bits == 0) 1 else (@typeInfo(T).int.bits + 6) / 7; | |
| 412 | 412 | |
| 413 | 413 | var buf: [max_groups]u8 = undefined; |
| 414 | 414 | var fbs = std.io.fixedBufferStream(&buf); |
| ... | ... | @@ -439,7 +439,7 @@ test "serialize unsigned LEB128" { |
| 439 | 439 | const T = std.meta.Int(.unsigned, t); |
| 440 | 440 | const min = std.math.minInt(T); |
| 441 | 441 | const max = std.math.maxInt(T); |
| 442 | var i = @as(std.meta.Int(.unsigned, @typeInfo(T).Int.bits + 1), min); | |
| 442 | var i = @as(std.meta.Int(.unsigned, @typeInfo(T).int.bits + 1), min); | |
| 443 | 443 | |
| 444 | 444 | while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i))); |
| 445 | 445 | } |
| ... | ... | @@ -457,7 +457,7 @@ test "serialize signed LEB128" { |
| 457 | 457 | const T = std.meta.Int(.signed, t); |
| 458 | 458 | const min = std.math.minInt(T); |
| 459 | 459 | const max = std.math.maxInt(T); |
| 460 | var i = @as(std.meta.Int(.signed, @typeInfo(T).Int.bits + 1), min); | |
| 460 | var i = @as(std.meta.Int(.signed, @typeInfo(T).int.bits + 1), min); | |
| 461 | 461 | |
| 462 | 462 | while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i))); |
| 463 | 463 | } |
lib/std/log.zig+6-6| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | //! |
| 29 | 29 | //! pub fn myLogFn( |
| 30 | 30 | //! comptime level: std.log.Level, |
| 31 | //! comptime scope: @TypeOf(.EnumLiteral), | |
| 31 | //! comptime scope: @Type(.enum_literal), | |
| 32 | 32 | //! comptime format: []const u8, |
| 33 | 33 | //! args: anytype, |
| 34 | 34 | //! ) void { |
| ... | ... | @@ -108,7 +108,7 @@ pub const default_level: Level = switch (builtin.mode) { |
| 108 | 108 | const level = std.options.log_level; |
| 109 | 109 | |
| 110 | 110 | pub const ScopeLevel = struct { |
| 111 | scope: @Type(.EnumLiteral), | |
| 111 | scope: @Type(.enum_literal), | |
| 112 | 112 | level: Level, |
| 113 | 113 | }; |
| 114 | 114 | |
| ... | ... | @@ -116,7 +116,7 @@ const scope_levels = std.options.log_scope_levels; |
| 116 | 116 | |
| 117 | 117 | fn log( |
| 118 | 118 | comptime message_level: Level, |
| 119 | comptime scope: @Type(.EnumLiteral), | |
| 119 | comptime scope: @Type(.enum_literal), | |
| 120 | 120 | comptime format: []const u8, |
| 121 | 121 | args: anytype, |
| 122 | 122 | ) void { |
| ... | ... | @@ -126,7 +126,7 @@ fn log( |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /// Determine if a specific log message level and scope combination are enabled for logging. |
| 129 | pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.EnumLiteral)) bool { | |
| 129 | pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.enum_literal)) bool { | |
| 130 | 130 | inline for (scope_levels) |scope_level| { |
| 131 | 131 | if (scope_level.scope == scope) return @intFromEnum(message_level) <= @intFromEnum(scope_level.level); |
| 132 | 132 | } |
| ... | ... | @@ -142,7 +142,7 @@ pub fn defaultLogEnabled(comptime message_level: Level) bool { |
| 142 | 142 | /// forward log messages to this function. |
| 143 | 143 | pub fn defaultLog( |
| 144 | 144 | comptime message_level: Level, |
| 145 | comptime scope: @Type(.EnumLiteral), | |
| 145 | comptime scope: @Type(.enum_literal), | |
| 146 | 146 | comptime format: []const u8, |
| 147 | 147 | args: anytype, |
| 148 | 148 | ) void { |
| ... | ... | @@ -162,7 +162,7 @@ pub fn defaultLog( |
| 162 | 162 | |
| 163 | 163 | /// Returns a scoped logging namespace that logs all messages using the scope |
| 164 | 164 | /// provided here. |
| 165 | pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { | |
| 165 | pub fn scoped(comptime scope: @Type(.enum_literal)) type { | |
| 166 | 166 | return struct { |
| 167 | 167 | /// Log an error message. This log level is intended to be used |
| 168 | 168 | /// when something has gone wrong. This might be recoverable or might |
lib/std/math.zig+98-98| ... | ... | @@ -71,7 +71,7 @@ pub const snan = float.snan; |
| 71 | 71 | /// |
| 72 | 72 | /// NaN values are never considered equal to any value. |
| 73 | 73 | pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool { |
| 74 | assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat); | |
| 74 | assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float); | |
| 75 | 75 | assert(tolerance >= 0); |
| 76 | 76 | |
| 77 | 77 | // Fast path for equal values (and signed zeros and infinites). |
| ... | ... | @@ -99,7 +99,7 @@ pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool { |
| 99 | 99 | /// |
| 100 | 100 | /// NaN values are never considered equal to any value. |
| 101 | 101 | pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool { |
| 102 | assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat); | |
| 102 | assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float); | |
| 103 | 103 | assert(tolerance > 0); |
| 104 | 104 | |
| 105 | 105 | // Fast path for equal values (and signed zeros and infinites). |
| ... | ... | @@ -263,8 +263,8 @@ pub inline fn tan(value: anytype) @TypeOf(value) { |
| 263 | 263 | pub fn radiansToDegrees(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) { |
| 264 | 264 | const T = @TypeOf(ang); |
| 265 | 265 | switch (@typeInfo(T)) { |
| 266 | .Float, .ComptimeFloat, .ComptimeInt => return ang * deg_per_rad, | |
| 267 | .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(deg_per_rad)), | |
| 266 | .float, .comptime_float, .comptime_int => return ang * deg_per_rad, | |
| 267 | .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(deg_per_rad)), | |
| 268 | 268 | else => {}, |
| 269 | 269 | } |
| 270 | 270 | @compileError("Input must be float or a comptime number, or a vector of floats."); |
| ... | ... | @@ -298,8 +298,8 @@ test radiansToDegrees { |
| 298 | 298 | pub fn degreesToRadians(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) { |
| 299 | 299 | const T = @TypeOf(ang); |
| 300 | 300 | switch (@typeInfo(T)) { |
| 301 | .Float, .ComptimeFloat, .ComptimeInt => return ang * rad_per_deg, | |
| 302 | .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(rad_per_deg)), | |
| 301 | .float, .comptime_float, .comptime_int => return ang * rad_per_deg, | |
| 302 | .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(rad_per_deg)), | |
| 303 | 303 | else => {}, |
| 304 | 304 | } |
| 305 | 305 | @compileError("Input must be float or a comptime number, or a vector of floats."); |
| ... | ... | @@ -408,8 +408,8 @@ test { |
| 408 | 408 | /// full range of the minimum value. |
| 409 | 409 | pub fn Min(comptime A: type, comptime B: type) type { |
| 410 | 410 | switch (@typeInfo(A)) { |
| 411 | .Int => |a_info| switch (@typeInfo(B)) { | |
| 412 | .Int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) { | |
| 411 | .int => |a_info| switch (@typeInfo(B)) { | |
| 412 | .int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) { | |
| 413 | 413 | if (a_info.bits < b_info.bits) { |
| 414 | 414 | return A; |
| 415 | 415 | } else { |
| ... | ... | @@ -437,21 +437,21 @@ pub fn Min(comptime A: type, comptime B: type) type { |
| 437 | 437 | pub fn wrap(x: anytype, r: anytype) @TypeOf(x) { |
| 438 | 438 | const info_x = @typeInfo(@TypeOf(x)); |
| 439 | 439 | const info_r = @typeInfo(@TypeOf(r)); |
| 440 | if (info_x == .Int and info_x.Int.signedness != .signed) { | |
| 440 | if (info_x == .int and info_x.int.signedness != .signed) { | |
| 441 | 441 | @compileError("x must be floating point, comptime integer, or signed integer."); |
| 442 | 442 | } |
| 443 | 443 | switch (info_r) { |
| 444 | .Int => { | |
| 444 | .int => { | |
| 445 | 445 | // in the rare usecase of r not being comptime_int or float, |
| 446 | 446 | // take the penalty of having an intermediary type conversion, |
| 447 | 447 | // otherwise the alternative is to unwind iteratively to avoid overflow |
| 448 | 448 | const R = comptime do: { |
| 449 | 449 | var info = info_r; |
| 450 | info.Int.bits += 1; | |
| 451 | info.Int.signedness = .signed; | |
| 450 | info.int.bits += 1; | |
| 451 | info.int.signedness = .signed; | |
| 452 | 452 | break :do @Type(info); |
| 453 | 453 | }; |
| 454 | const radius: if (info_r.Int.signedness == .signed) @TypeOf(r) else R = r; | |
| 454 | const radius: if (info_r.int.signedness == .signed) @TypeOf(r) else R = r; | |
| 455 | 455 | return @intCast(@mod(x - radius, 2 * @as(R, r)) - r); // provably impossible to overflow |
| 456 | 456 | }, |
| 457 | 457 | else => { |
| ... | ... | @@ -520,9 +520,9 @@ test wrap { |
| 520 | 520 | pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) { |
| 521 | 521 | const T = @TypeOf(val, lower, upper); |
| 522 | 522 | switch (@typeInfo(T)) { |
| 523 | .Int, .Float, .ComptimeInt, .ComptimeFloat => assert(lower <= upper), | |
| 524 | .Vector => |vinfo| switch (@typeInfo(vinfo.child)) { | |
| 525 | .Int, .Float => assert(@reduce(.And, lower <= upper)), | |
| 523 | .int, .float, .comptime_int, .comptime_float => assert(lower <= upper), | |
| 524 | .vector => |vinfo| switch (@typeInfo(vinfo.child)) { | |
| 525 | .int, .float => assert(@reduce(.And, lower <= upper)), | |
| 526 | 526 | else => @compileError("Expected vector of ints or floats, found " ++ @typeName(T)), |
| 527 | 527 | }, |
| 528 | 528 | else => @compileError("Expected an int, float or vector of one, found " ++ @typeName(T)), |
| ... | ... | @@ -593,18 +593,18 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T { |
| 593 | 593 | const abs_shift_amt = @abs(shift_amt); |
| 594 | 594 | |
| 595 | 595 | const casted_shift_amt = blk: { |
| 596 | if (@typeInfo(T) == .Vector) { | |
| 597 | const C = @typeInfo(T).Vector.child; | |
| 598 | const len = @typeInfo(T).Vector.len; | |
| 599 | if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0); | |
| 596 | if (@typeInfo(T) == .vector) { | |
| 597 | const C = @typeInfo(T).vector.child; | |
| 598 | const len = @typeInfo(T).vector.len; | |
| 599 | if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0); | |
| 600 | 600 | break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt)))); |
| 601 | 601 | } else { |
| 602 | if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0; | |
| 602 | if (abs_shift_amt >= @typeInfo(T).int.bits) return 0; | |
| 603 | 603 | break :blk @as(Log2Int(T), @intCast(abs_shift_amt)); |
| 604 | 604 | } |
| 605 | 605 | }; |
| 606 | 606 | |
| 607 | if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) { | |
| 607 | if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) { | |
| 608 | 608 | if (shift_amt < 0) { |
| 609 | 609 | return a >> casted_shift_amt; |
| 610 | 610 | } |
| ... | ... | @@ -633,18 +633,18 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T { |
| 633 | 633 | const abs_shift_amt = @abs(shift_amt); |
| 634 | 634 | |
| 635 | 635 | const casted_shift_amt = blk: { |
| 636 | if (@typeInfo(T) == .Vector) { | |
| 637 | const C = @typeInfo(T).Vector.child; | |
| 638 | const len = @typeInfo(T).Vector.len; | |
| 639 | if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0); | |
| 636 | if (@typeInfo(T) == .vector) { | |
| 637 | const C = @typeInfo(T).vector.child; | |
| 638 | const len = @typeInfo(T).vector.len; | |
| 639 | if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0); | |
| 640 | 640 | break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt)))); |
| 641 | 641 | } else { |
| 642 | if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0; | |
| 642 | if (abs_shift_amt >= @typeInfo(T).int.bits) return 0; | |
| 643 | 643 | break :blk @as(Log2Int(T), @intCast(abs_shift_amt)); |
| 644 | 644 | } |
| 645 | 645 | }; |
| 646 | 646 | |
| 647 | if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) { | |
| 647 | if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) { | |
| 648 | 648 | if (shift_amt < 0) { |
| 649 | 649 | return a << casted_shift_amt; |
| 650 | 650 | } |
| ... | ... | @@ -670,26 +670,26 @@ test shr { |
| 670 | 670 | /// Rotates right. Only unsigned values can be rotated. Negative shift |
| 671 | 671 | /// values result in shift modulo the bit count. |
| 672 | 672 | pub fn rotr(comptime T: type, x: T, r: anytype) T { |
| 673 | if (@typeInfo(T) == .Vector) { | |
| 674 | const C = @typeInfo(T).Vector.child; | |
| 673 | if (@typeInfo(T) == .vector) { | |
| 674 | const C = @typeInfo(T).vector.child; | |
| 675 | 675 | if (C == u0) return 0; |
| 676 | 676 | |
| 677 | if (@typeInfo(C).Int.signedness == .signed) { | |
| 677 | if (@typeInfo(C).int.signedness == .signed) { | |
| 678 | 678 | @compileError("cannot rotate signed integers"); |
| 679 | 679 | } |
| 680 | const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits)); | |
| 680 | const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits)); | |
| 681 | 681 | return (x >> @splat(ar)) | (x << @splat(1 + ~ar)); |
| 682 | } else if (@typeInfo(T).Int.signedness == .signed) { | |
| 682 | } else if (@typeInfo(T).int.signedness == .signed) { | |
| 683 | 683 | @compileError("cannot rotate signed integer"); |
| 684 | 684 | } else { |
| 685 | 685 | if (T == u0) return 0; |
| 686 | 686 | |
| 687 | if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) { | |
| 688 | const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits)); | |
| 687 | if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) { | |
| 688 | const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits)); | |
| 689 | 689 | return x >> ar | x << (1 +% ~ar); |
| 690 | 690 | } else { |
| 691 | const ar = @mod(r, @typeInfo(T).Int.bits); | |
| 692 | return shr(T, x, ar) | shl(T, x, @typeInfo(T).Int.bits - ar); | |
| 691 | const ar = @mod(r, @typeInfo(T).int.bits); | |
| 692 | return shr(T, x, ar) | shl(T, x, @typeInfo(T).int.bits - ar); | |
| 693 | 693 | } |
| 694 | 694 | } |
| 695 | 695 | } |
| ... | ... | @@ -711,26 +711,26 @@ test rotr { |
| 711 | 711 | /// Rotates left. Only unsigned values can be rotated. Negative shift |
| 712 | 712 | /// values result in shift modulo the bit count. |
| 713 | 713 | pub fn rotl(comptime T: type, x: T, r: anytype) T { |
| 714 | if (@typeInfo(T) == .Vector) { | |
| 715 | const C = @typeInfo(T).Vector.child; | |
| 714 | if (@typeInfo(T) == .vector) { | |
| 715 | const C = @typeInfo(T).vector.child; | |
| 716 | 716 | if (C == u0) return 0; |
| 717 | 717 | |
| 718 | if (@typeInfo(C).Int.signedness == .signed) { | |
| 718 | if (@typeInfo(C).int.signedness == .signed) { | |
| 719 | 719 | @compileError("cannot rotate signed integers"); |
| 720 | 720 | } |
| 721 | const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits)); | |
| 721 | const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits)); | |
| 722 | 722 | return (x << @splat(ar)) | (x >> @splat(1 +% ~ar)); |
| 723 | } else if (@typeInfo(T).Int.signedness == .signed) { | |
| 723 | } else if (@typeInfo(T).int.signedness == .signed) { | |
| 724 | 724 | @compileError("cannot rotate signed integer"); |
| 725 | 725 | } else { |
| 726 | 726 | if (T == u0) return 0; |
| 727 | 727 | |
| 728 | if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) { | |
| 729 | const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits)); | |
| 728 | if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) { | |
| 729 | const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits)); | |
| 730 | 730 | return x << ar | x >> 1 +% ~ar; |
| 731 | 731 | } else { |
| 732 | const ar = @mod(r, @typeInfo(T).Int.bits); | |
| 733 | return shl(T, x, ar) | shr(T, x, @typeInfo(T).Int.bits - ar); | |
| 732 | const ar = @mod(r, @typeInfo(T).int.bits); | |
| 733 | return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar); | |
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | } |
| ... | ... | @@ -754,7 +754,7 @@ test rotl { |
| 754 | 754 | pub fn Log2Int(comptime T: type) type { |
| 755 | 755 | // comptime ceil log2 |
| 756 | 756 | if (T == comptime_int) return comptime_int; |
| 757 | const bits: u16 = @typeInfo(T).Int.bits; | |
| 757 | const bits: u16 = @typeInfo(T).int.bits; | |
| 758 | 758 | const log2_bits = 16 - @clz(bits - 1); |
| 759 | 759 | return std.meta.Int(.unsigned, log2_bits); |
| 760 | 760 | } |
| ... | ... | @@ -763,7 +763,7 @@ pub fn Log2Int(comptime T: type) type { |
| 763 | 763 | pub fn Log2IntCeil(comptime T: type) type { |
| 764 | 764 | // comptime ceil log2 |
| 765 | 765 | if (T == comptime_int) return comptime_int; |
| 766 | const bits: u16 = @typeInfo(T).Int.bits; | |
| 766 | const bits: u16 = @typeInfo(T).int.bits; | |
| 767 | 767 | const log2_bits = 16 - @clz(bits); |
| 768 | 768 | return std.meta.Int(.unsigned, log2_bits); |
| 769 | 769 | } |
| ... | ... | @@ -849,7 +849,7 @@ fn testOverflow() !void { |
| 849 | 849 | pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T { |
| 850 | 850 | @setRuntimeSafety(false); |
| 851 | 851 | if (denominator == 0) return error.DivisionByZero; |
| 852 | if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; | |
| 852 | if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; | |
| 853 | 853 | return @divTrunc(numerator, denominator); |
| 854 | 854 | } |
| 855 | 855 | |
| ... | ... | @@ -873,7 +873,7 @@ fn testDivTrunc() !void { |
| 873 | 873 | pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T { |
| 874 | 874 | @setRuntimeSafety(false); |
| 875 | 875 | if (denominator == 0) return error.DivisionByZero; |
| 876 | if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; | |
| 876 | if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; | |
| 877 | 877 | return @divFloor(numerator, denominator); |
| 878 | 878 | } |
| 879 | 879 | |
| ... | ... | @@ -899,10 +899,10 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T { |
| 899 | 899 | if (denominator == 0) return error.DivisionByZero; |
| 900 | 900 | const info = @typeInfo(T); |
| 901 | 901 | switch (info) { |
| 902 | .ComptimeFloat, .Float => return @ceil(numerator / denominator), | |
| 903 | .ComptimeInt, .Int => { | |
| 902 | .comptime_float, .float => return @ceil(numerator / denominator), | |
| 903 | .comptime_int, .int => { | |
| 904 | 904 | if (numerator < 0 and denominator < 0) { |
| 905 | if (info == .Int and numerator == minInt(T) and denominator == -1) | |
| 905 | if (info == .int and numerator == minInt(T) and denominator == -1) | |
| 906 | 906 | return error.Overflow; |
| 907 | 907 | return @divFloor(numerator + 1, denominator) + 1; |
| 908 | 908 | } |
| ... | ... | @@ -952,7 +952,7 @@ fn testDivCeil() !void { |
| 952 | 952 | pub fn divExact(comptime T: type, numerator: T, denominator: T) !T { |
| 953 | 953 | @setRuntimeSafety(false); |
| 954 | 954 | if (denominator == 0) return error.DivisionByZero; |
| 955 | if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; | |
| 955 | if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; | |
| 956 | 956 | const result = @divTrunc(numerator, denominator); |
| 957 | 957 | if (result * denominator != numerator) return error.UnexpectedRemainder; |
| 958 | 958 | return result; |
| ... | ... | @@ -1029,7 +1029,7 @@ fn testRem() !void { |
| 1029 | 1029 | /// Returns the negation of the integer parameter. |
| 1030 | 1030 | /// Result is a signed integer. |
| 1031 | 1031 | pub fn negateCast(x: anytype) !std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))) { |
| 1032 | if (@typeInfo(@TypeOf(x)).Int.signedness == .signed) return negate(x); | |
| 1032 | if (@typeInfo(@TypeOf(x)).int.signedness == .signed) return negate(x); | |
| 1033 | 1033 | |
| 1034 | 1034 | const int = std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))); |
| 1035 | 1035 | if (x > -minInt(int)) return error.Overflow; |
| ... | ... | @@ -1052,9 +1052,9 @@ test negateCast { |
| 1052 | 1052 | /// Cast an integer to a different integer type. If the value doesn't fit, |
| 1053 | 1053 | /// return null. |
| 1054 | 1054 | pub fn cast(comptime T: type, x: anytype) ?T { |
| 1055 | comptime assert(@typeInfo(T) == .Int); // must pass an integer | |
| 1055 | comptime assert(@typeInfo(T) == .int); // must pass an integer | |
| 1056 | 1056 | const is_comptime = @TypeOf(x) == comptime_int; |
| 1057 | comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .Int); // must pass an integer | |
| 1057 | comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .int); // must pass an integer | |
| 1058 | 1058 | if ((is_comptime or maxInt(@TypeOf(x)) > maxInt(T)) and x > maxInt(T)) { |
| 1059 | 1059 | return null; |
| 1060 | 1060 | } else if ((is_comptime or minInt(@TypeOf(x)) < minInt(T)) and x < minInt(T)) { |
| ... | ... | @@ -1084,7 +1084,7 @@ pub const AlignCastError = error{UnalignedMemory}; |
| 1084 | 1084 | |
| 1085 | 1085 | fn AlignCastResult(comptime alignment: u29, comptime Ptr: type) type { |
| 1086 | 1086 | var ptr_info = @typeInfo(Ptr); |
| 1087 | ptr_info.Pointer.alignment = alignment; | |
| 1087 | ptr_info.pointer.alignment = alignment; | |
| 1088 | 1088 | return @Type(ptr_info); |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| ... | ... | @@ -1117,7 +1117,7 @@ test isPowerOfTwo { |
| 1117 | 1117 | |
| 1118 | 1118 | /// Aligns the given integer type bit width to a width divisible by 8. |
| 1119 | 1119 | pub fn ByteAlignedInt(comptime T: type) type { |
| 1120 | const info = @typeInfo(T).Int; | |
| 1120 | const info = @typeInfo(T).int; | |
| 1121 | 1121 | const bits = (info.bits + 7) / 8 * 8; |
| 1122 | 1122 | const extended_type = std.meta.Int(info.signedness, bits); |
| 1123 | 1123 | return extended_type; |
| ... | ... | @@ -1157,7 +1157,7 @@ pub inline fn floor(value: anytype) @TypeOf(value) { |
| 1157 | 1157 | /// Returns the nearest power of two less than or equal to value, or |
| 1158 | 1158 | /// zero if value is less than or equal to zero. |
| 1159 | 1159 | pub fn floorPowerOfTwo(comptime T: type, value: T) T { |
| 1160 | const uT = std.meta.Int(.unsigned, @typeInfo(T).Int.bits); | |
| 1160 | const uT = std.meta.Int(.unsigned, @typeInfo(T).int.bits); | |
| 1161 | 1161 | if (value <= 0) return 0; |
| 1162 | 1162 | return @as(T, 1) << log2_int(uT, @as(uT, @intCast(value))); |
| 1163 | 1163 | } |
| ... | ... | @@ -1192,21 +1192,21 @@ pub inline fn ceil(value: anytype) @TypeOf(value) { |
| 1192 | 1192 | /// Returns the next power of two (if the value is not already a power of two). |
| 1193 | 1193 | /// Only unsigned integers can be used. Zero is not an allowed input. |
| 1194 | 1194 | /// Result is a type with 1 more bit than the input type. |
| 1195 | pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1) { | |
| 1196 | comptime assert(@typeInfo(T) == .Int); | |
| 1197 | comptime assert(@typeInfo(T).Int.signedness == .unsigned); | |
| 1195 | pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1) { | |
| 1196 | comptime assert(@typeInfo(T) == .int); | |
| 1197 | comptime assert(@typeInfo(T).int.signedness == .unsigned); | |
| 1198 | 1198 | assert(value != 0); |
| 1199 | const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1); | |
| 1199 | const PromotedType = std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1); | |
| 1200 | 1200 | const ShiftType = std.math.Log2Int(PromotedType); |
| 1201 | return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).Int.bits - @clz(value - 1))); | |
| 1201 | return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1))); | |
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /// Returns the next power of two (if the value is not already a power of two). |
| 1205 | 1205 | /// Only unsigned integers can be used. Zero is not an allowed input. |
| 1206 | 1206 | /// If the value doesn't fit, returns an error. |
| 1207 | 1207 | pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) { |
| 1208 | comptime assert(@typeInfo(T) == .Int); | |
| 1209 | const info = @typeInfo(T).Int; | |
| 1208 | comptime assert(@typeInfo(T) == .int); | |
| 1209 | const info = @typeInfo(T).int; | |
| 1210 | 1210 | comptime assert(info.signedness == .unsigned); |
| 1211 | 1211 | const PromotedType = std.meta.Int(info.signedness, info.bits + 1); |
| 1212 | 1212 | const overflowBit = @as(PromotedType, 1) << info.bits; |
| ... | ... | @@ -1261,16 +1261,16 @@ fn testCeilPowerOfTwo() !void { |
| 1261 | 1261 | /// Return the log base 2 of integer value x, rounding down to the |
| 1262 | 1262 | /// nearest integer. |
| 1263 | 1263 | pub fn log2_int(comptime T: type, x: T) Log2Int(T) { |
| 1264 | if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned) | |
| 1264 | if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned) | |
| 1265 | 1265 | @compileError("log2_int requires an unsigned integer, found " ++ @typeName(T)); |
| 1266 | 1266 | assert(x != 0); |
| 1267 | return @as(Log2Int(T), @intCast(@typeInfo(T).Int.bits - 1 - @clz(x))); | |
| 1267 | return @as(Log2Int(T), @intCast(@typeInfo(T).int.bits - 1 - @clz(x))); | |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | /// Return the log base 2 of integer value x, rounding up to the |
| 1271 | 1271 | /// nearest integer. |
| 1272 | 1272 | pub fn log2_int_ceil(comptime T: type, x: T) Log2IntCeil(T) { |
| 1273 | if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned) | |
| 1273 | if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned) | |
| 1274 | 1274 | @compileError("log2_int_ceil requires an unsigned integer, found " ++ @typeName(T)); |
| 1275 | 1275 | assert(x != 0); |
| 1276 | 1276 | if (x == 1) return 0; |
| ... | ... | @@ -1296,35 +1296,35 @@ test log2_int_ceil { |
| 1296 | 1296 | /// converted to the closest possible representation. |
| 1297 | 1297 | pub fn lossyCast(comptime T: type, value: anytype) T { |
| 1298 | 1298 | switch (@typeInfo(T)) { |
| 1299 | .Float => { | |
| 1299 | .float => { | |
| 1300 | 1300 | switch (@typeInfo(@TypeOf(value))) { |
| 1301 | .Int => return @as(T, @floatFromInt(value)), | |
| 1302 | .Float => return @as(T, @floatCast(value)), | |
| 1303 | .ComptimeInt => return @as(T, value), | |
| 1304 | .ComptimeFloat => return @as(T, value), | |
| 1301 | .int => return @floatFromInt(value), | |
| 1302 | .float => return @floatCast(value), | |
| 1303 | .comptime_int => return value, | |
| 1304 | .comptime_float => return value, | |
| 1305 | 1305 | else => @compileError("bad type"), |
| 1306 | 1306 | } |
| 1307 | 1307 | }, |
| 1308 | .Int => { | |
| 1308 | .int => { | |
| 1309 | 1309 | switch (@typeInfo(@TypeOf(value))) { |
| 1310 | .Int, .ComptimeInt => { | |
| 1310 | .int, .comptime_int => { | |
| 1311 | 1311 | if (value >= maxInt(T)) { |
| 1312 | return @as(T, maxInt(T)); | |
| 1312 | return maxInt(T); | |
| 1313 | 1313 | } else if (value <= minInt(T)) { |
| 1314 | return @as(T, minInt(T)); | |
| 1314 | return minInt(T); | |
| 1315 | 1315 | } else { |
| 1316 | return @as(T, @intCast(value)); | |
| 1316 | return @intCast(value); | |
| 1317 | 1317 | } |
| 1318 | 1318 | }, |
| 1319 | .Float, .ComptimeFloat => { | |
| 1319 | .float, .comptime_float => { | |
| 1320 | 1320 | if (isNan(value)) { |
| 1321 | 1321 | return 0; |
| 1322 | 1322 | } else if (value >= maxInt(T)) { |
| 1323 | return @as(T, maxInt(T)); | |
| 1323 | return maxInt(T); | |
| 1324 | 1324 | } else if (value <= minInt(T)) { |
| 1325 | return @as(T, minInt(T)); | |
| 1325 | return minInt(T); | |
| 1326 | 1326 | } else { |
| 1327 | return @as(T, @intFromFloat(value)); | |
| 1327 | return @intFromFloat(value); | |
| 1328 | 1328 | } |
| 1329 | 1329 | }, |
| 1330 | 1330 | else => @compileError("bad type"), |
| ... | ... | @@ -1405,16 +1405,16 @@ test lerp { |
| 1405 | 1405 | /// Returns the maximum value of integer type T. |
| 1406 | 1406 | pub fn maxInt(comptime T: type) comptime_int { |
| 1407 | 1407 | const info = @typeInfo(T); |
| 1408 | const bit_count = info.Int.bits; | |
| 1408 | const bit_count = info.int.bits; | |
| 1409 | 1409 | if (bit_count == 0) return 0; |
| 1410 | return (1 << (bit_count - @intFromBool(info.Int.signedness == .signed))) - 1; | |
| 1410 | return (1 << (bit_count - @intFromBool(info.int.signedness == .signed))) - 1; | |
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | /// Returns the minimum value of integer type T. |
| 1414 | 1414 | pub fn minInt(comptime T: type) comptime_int { |
| 1415 | 1415 | const info = @typeInfo(T); |
| 1416 | const bit_count = info.Int.bits; | |
| 1417 | if (info.Int.signedness == .unsigned) return 0; | |
| 1416 | const bit_count = info.int.bits; | |
| 1417 | if (info.int.signedness == .unsigned) return 0; | |
| 1418 | 1418 | if (bit_count == 0) return 0; |
| 1419 | 1419 | return -(1 << (bit_count - 1)); |
| 1420 | 1420 | } |
| ... | ... | @@ -1466,12 +1466,12 @@ test "max value type" { |
| 1466 | 1466 | /// Multiply a and b. Return type is wide enough to guarantee no |
| 1467 | 1467 | /// overflow. |
| 1468 | 1468 | pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int( |
| 1469 | @typeInfo(T).Int.signedness, | |
| 1470 | @typeInfo(T).Int.bits * 2, | |
| 1469 | @typeInfo(T).int.signedness, | |
| 1470 | @typeInfo(T).int.bits * 2, | |
| 1471 | 1471 | ) { |
| 1472 | 1472 | const ResultInt = std.meta.Int( |
| 1473 | @typeInfo(T).Int.signedness, | |
| 1474 | @typeInfo(T).Int.bits * 2, | |
| 1473 | @typeInfo(T).int.signedness, | |
| 1474 | @typeInfo(T).int.bits * 2, | |
| 1475 | 1475 | ); |
| 1476 | 1476 | return @as(ResultInt, a) * @as(ResultInt, b); |
| 1477 | 1477 | } |
| ... | ... | @@ -1616,7 +1616,7 @@ pub const CompareOperator = enum { |
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | test reverse { |
| 1619 | inline for (@typeInfo(CompareOperator).Enum.fields) |op_field| { | |
| 1619 | inline for (@typeInfo(CompareOperator).@"enum".fields) |op_field| { | |
| 1620 | 1620 | const op = @as(CompareOperator, @enumFromInt(op_field.value)); |
| 1621 | 1621 | try testing.expect(compare(2, op, 3) == compare(3, op.reverse(), 2)); |
| 1622 | 1622 | try testing.expect(compare(3, op, 3) == compare(3, op.reverse(), 3)); |
| ... | ... | @@ -1669,7 +1669,7 @@ test order { |
| 1669 | 1669 | /// and a mask of all zeroes if value is false. |
| 1670 | 1670 | /// Compiles to one instruction for register sized integers. |
| 1671 | 1671 | pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt { |
| 1672 | if (@typeInfo(MaskInt) != .Int) | |
| 1672 | if (@typeInfo(MaskInt) != .int) | |
| 1673 | 1673 | @compileError("boolMask requires an integer mask type."); |
| 1674 | 1674 | |
| 1675 | 1675 | if (MaskInt == u0 or MaskInt == i0) |
| ... | ... | @@ -1742,11 +1742,11 @@ pub fn break_f80(x: f80) F80 { |
| 1742 | 1742 | pub inline fn sign(i: anytype) @TypeOf(i) { |
| 1743 | 1743 | const T = @TypeOf(i); |
| 1744 | 1744 | return switch (@typeInfo(T)) { |
| 1745 | .Int, .ComptimeInt => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)), | |
| 1746 | .Float, .ComptimeFloat => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))), | |
| 1747 | .Vector => |vinfo| blk: { | |
| 1745 | .int, .comptime_int => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)), | |
| 1746 | .float, .comptime_float => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))), | |
| 1747 | .vector => |vinfo| blk: { | |
| 1748 | 1748 | switch (@typeInfo(vinfo.child)) { |
| 1749 | .Int, .Float => { | |
| 1749 | .int, .float => { | |
| 1750 | 1750 | const zero: T = @splat(0); |
| 1751 | 1751 | const one: T = @splat(1); |
| 1752 | 1752 | break :blk @select(vinfo.child, i > zero, one, zero) - @select(vinfo.child, i < zero, one, zero); |
lib/std/math/big.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const assert = std.debug.assert; |
| 4 | 4 | pub const Rational = @import("big/rational.zig").Rational; |
| 5 | 5 | pub const int = @import("big/int.zig"); |
| 6 | 6 | pub const Limb = usize; |
| 7 | const limb_info = @typeInfo(Limb).Int; | |
| 7 | const limb_info = @typeInfo(Limb).int; | |
| 8 | 8 | pub const SignedLimb = std.meta.Int(.signed, limb_info.bits); |
| 9 | 9 | pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits); |
| 10 | 10 | pub const HalfLimb = std.meta.Int(.unsigned, limb_info.bits / 2); |
lib/std/math/big/int.zig+12-12| ... | ... | @@ -2,9 +2,9 @@ const std = @import("../../std.zig"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const math = std.math; |
| 4 | 4 | const Limb = std.math.big.Limb; |
| 5 | const limb_bits = @typeInfo(Limb).Int.bits; | |
| 5 | const limb_bits = @typeInfo(Limb).int.bits; | |
| 6 | 6 | const HalfLimb = std.math.big.HalfLimb; |
| 7 | const half_limb_bits = @typeInfo(HalfLimb).Int.bits; | |
| 7 | const half_limb_bits = @typeInfo(HalfLimb).int.bits; | |
| 8 | 8 | const DoubleLimb = std.math.big.DoubleLimb; |
| 9 | 9 | const SignedDoubleLimb = std.math.big.SignedDoubleLimb; |
| 10 | 10 | const Log2Limb = std.math.big.Log2Limb; |
| ... | ... | @@ -23,7 +23,7 @@ const debug_safety = false; |
| 23 | 23 | /// primitive integer value. |
| 24 | 24 | /// Note: A comptime-known upper bound of this value that may be used |
| 25 | 25 | /// instead if `scalar` is not already comptime-known is |
| 26 | /// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).Int.bits)` | |
| 26 | /// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).int.bits)` | |
| 27 | 27 | pub fn calcLimbLen(scalar: anytype) usize { |
| 28 | 28 | if (scalar == 0) { |
| 29 | 29 | return 1; |
| ... | ... | @@ -236,7 +236,7 @@ pub const Mutable = struct { |
| 236 | 236 | self.positive = value >= 0; |
| 237 | 237 | |
| 238 | 238 | switch (@typeInfo(T)) { |
| 239 | .Int => |info| { | |
| 239 | .int => |info| { | |
| 240 | 240 | var w_value = @abs(value); |
| 241 | 241 | |
| 242 | 242 | if (info.bits <= limb_bits) { |
| ... | ... | @@ -251,7 +251,7 @@ pub const Mutable = struct { |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | }, |
| 254 | .ComptimeInt => { | |
| 254 | .comptime_int => { | |
| 255 | 255 | comptime var w_value = @abs(value); |
| 256 | 256 | |
| 257 | 257 | if (w_value <= maxInt(Limb)) { |
| ... | ... | @@ -405,8 +405,8 @@ pub const Mutable = struct { |
| 405 | 405 | // is well worth being able to use the stack and not needing an allocator passed in. |
| 406 | 406 | // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case. |
| 407 | 407 | const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) { |
| 408 | .ComptimeInt => calcLimbLen(scalar), | |
| 409 | .Int => |info| calcTwosCompLimbCount(info.bits), | |
| 408 | .comptime_int => calcLimbLen(scalar), | |
| 409 | .int => |info| calcTwosCompLimbCount(info.bits), | |
| 410 | 410 | else => @compileError("expected scalar to be an int"), |
| 411 | 411 | }; |
| 412 | 412 | var limbs: [limb_len]Limb = undefined; |
| ... | ... | @@ -2158,7 +2158,7 @@ pub const Const = struct { |
| 2158 | 2158 | |
| 2159 | 2159 | /// Returns whether self can fit into an integer of the requested type. |
| 2160 | 2160 | pub fn fits(self: Const, comptime T: type) bool { |
| 2161 | const info = @typeInfo(T).Int; | |
| 2161 | const info = @typeInfo(T).int; | |
| 2162 | 2162 | return self.fitsInTwosComp(info.signedness, info.bits); |
| 2163 | 2163 | } |
| 2164 | 2164 | |
| ... | ... | @@ -2181,7 +2181,7 @@ pub const Const = struct { |
| 2181 | 2181 | /// Returns an error if self cannot be narrowed into the requested type without truncation. |
| 2182 | 2182 | pub fn to(self: Const, comptime T: type) ConvertError!T { |
| 2183 | 2183 | switch (@typeInfo(T)) { |
| 2184 | .Int => |info| { | |
| 2184 | .int => |info| { | |
| 2185 | 2185 | // Make sure -0 is handled correctly. |
| 2186 | 2186 | if (self.eqlZero()) return 0; |
| 2187 | 2187 | |
| ... | ... | @@ -2495,8 +2495,8 @@ pub const Const = struct { |
| 2495 | 2495 | // is well worth being able to use the stack and not needing an allocator passed in. |
| 2496 | 2496 | // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case. |
| 2497 | 2497 | const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) { |
| 2498 | .ComptimeInt => calcLimbLen(scalar), | |
| 2499 | .Int => |info| calcTwosCompLimbCount(info.bits), | |
| 2498 | .comptime_int => calcLimbLen(scalar), | |
| 2499 | .int => |info| calcTwosCompLimbCount(info.bits), | |
| 2500 | 2500 | else => @compileError("expected scalar to be an int"), |
| 2501 | 2501 | }; |
| 2502 | 2502 | var limbs: [limb_len]Limb = undefined; |
| ... | ... | @@ -2555,7 +2555,7 @@ pub const Const = struct { |
| 2555 | 2555 | /// Memory is allocated as needed to ensure operations never overflow. The range |
| 2556 | 2556 | /// is bounded only by available memory. |
| 2557 | 2557 | pub const Managed = struct { |
| 2558 | pub const sign_bit: usize = 1 << (@typeInfo(usize).Int.bits - 1); | |
| 2558 | pub const sign_bit: usize = 1 << (@typeInfo(usize).int.bits - 1); | |
| 2559 | 2559 | |
| 2560 | 2560 | /// Default number of limbs to allocate on creation of a `Managed`. |
| 2561 | 2561 | pub const default_capacity = 4; |
lib/std/math/big/int_test.zig+13-13| ... | ... | @@ -22,13 +22,13 @@ test "comptime_int set" { |
| 22 | 22 | var a = try Managed.initSet(testing.allocator, s); |
| 23 | 23 | defer a.deinit(); |
| 24 | 24 | |
| 25 | const s_limb_count = 128 / @typeInfo(Limb).Int.bits; | |
| 25 | const s_limb_count = 128 / @typeInfo(Limb).int.bits; | |
| 26 | 26 | |
| 27 | 27 | comptime var i: usize = 0; |
| 28 | 28 | inline while (i < s_limb_count) : (i += 1) { |
| 29 | 29 | const result = @as(Limb, s & maxInt(Limb)); |
| 30 | s >>= @typeInfo(Limb).Int.bits / 2; | |
| 31 | s >>= @typeInfo(Limb).Int.bits / 2; | |
| 30 | s >>= @typeInfo(Limb).int.bits / 2; | |
| 31 | s >>= @typeInfo(Limb).int.bits / 2; | |
| 32 | 32 | try testing.expect(a.limbs[i] == result); |
| 33 | 33 | } |
| 34 | 34 | } |
| ... | ... | @@ -299,7 +299,7 @@ test "twos complement limit set" { |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | fn testTwosComplementLimit(comptime T: type) !void { |
| 302 | const int_info = @typeInfo(T).Int; | |
| 302 | const int_info = @typeInfo(T).int; | |
| 303 | 303 | |
| 304 | 304 | var a = try Managed.init(testing.allocator); |
| 305 | 305 | defer a.deinit(); |
| ... | ... | @@ -1893,7 +1893,7 @@ test "truncate multi to single signed" { |
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | 1895 | test "truncate multi to multi unsigned" { |
| 1896 | const bits = @typeInfo(SignedDoubleLimb).Int.bits; | |
| 1896 | const bits = @typeInfo(SignedDoubleLimb).int.bits; | |
| 1897 | 1897 | const Int = std.meta.Int(.unsigned, bits - 1); |
| 1898 | 1898 | |
| 1899 | 1899 | var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); |
| ... | ... | @@ -2239,11 +2239,11 @@ test "bitNotWrap more than two limbs" { |
| 2239 | 2239 | const bits = @bitSizeOf(Limb) * 4 + 2; |
| 2240 | 2240 | |
| 2241 | 2241 | try res.bitNotWrap(&a, .unsigned, bits); |
| 2242 | const Unsigned = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = bits } }); | |
| 2242 | const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = bits } }); | |
| 2243 | 2243 | try testing.expectEqual((try res.to(Unsigned)), ~@as(Unsigned, maxInt(Limb))); |
| 2244 | 2244 | |
| 2245 | 2245 | try res.bitNotWrap(&a, .signed, bits); |
| 2246 | const Signed = @Type(.{ .Int = .{ .signedness = .signed, .bits = bits } }); | |
| 2246 | const Signed = @Type(.{ .int = .{ .signedness = .signed, .bits = bits } }); | |
| 2247 | 2247 | try testing.expectEqual((try res.to(Signed)), ~@as(Signed, maxInt(Limb))); |
| 2248 | 2248 | } |
| 2249 | 2249 | |
| ... | ... | @@ -3037,8 +3037,8 @@ test "big int conversion write twos complement zero" { |
| 3037 | 3037 | } |
| 3038 | 3038 | |
| 3039 | 3039 | fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void { |
| 3040 | const bit_count = @typeInfo(T).Int.bits; | |
| 3041 | const signedness = @typeInfo(T).Int.signedness; | |
| 3040 | const bit_count = @typeInfo(T).int.bits; | |
| 3041 | const signedness = @typeInfo(T).int.signedness; | |
| 3042 | 3042 | |
| 3043 | 3043 | var a = try Managed.initSet(testing.allocator, input); |
| 3044 | 3044 | defer a.deinit(); |
| ... | ... | @@ -3084,8 +3084,8 @@ test "big int bit reverse" { |
| 3084 | 3084 | } |
| 3085 | 3085 | |
| 3086 | 3086 | fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void { |
| 3087 | const byte_count = @typeInfo(T).Int.bits / 8; | |
| 3088 | const signedness = @typeInfo(T).Int.signedness; | |
| 3087 | const byte_count = @typeInfo(T).int.bits / 8; | |
| 3088 | const signedness = @typeInfo(T).int.signedness; | |
| 3089 | 3089 | |
| 3090 | 3090 | var a = try Managed.initSet(testing.allocator, input); |
| 3091 | 3091 | defer a.deinit(); |
| ... | ... | @@ -3151,7 +3151,7 @@ test "mul multi-multi alias r with a and b" { |
| 3151 | 3151 | |
| 3152 | 3152 | try testing.expect(a.eql(want)); |
| 3153 | 3153 | |
| 3154 | if (@typeInfo(Limb).Int.bits == 64) { | |
| 3154 | if (@typeInfo(Limb).int.bits == 64) { | |
| 3155 | 3155 | try testing.expectEqual(@as(usize, 5), a.limbs.len); |
| 3156 | 3156 | } |
| 3157 | 3157 | } |
| ... | ... | @@ -3167,7 +3167,7 @@ test "sqr multi alias r with a" { |
| 3167 | 3167 | |
| 3168 | 3168 | try testing.expect(a.eql(want)); |
| 3169 | 3169 | |
| 3170 | if (@typeInfo(Limb).Int.bits == 64) { | |
| 3170 | if (@typeInfo(Limb).int.bits == 64) { | |
| 3171 | 3171 | try testing.expectEqual(@as(usize, 5), a.limbs.len); |
| 3172 | 3172 | } |
| 3173 | 3173 | } |
lib/std/math/big/rational.zig+7-7| ... | ... | @@ -135,9 +135,9 @@ pub const Rational = struct { |
| 135 | 135 | /// completely represent the provided float. |
| 136 | 136 | pub fn setFloat(self: *Rational, comptime T: type, f: T) !void { |
| 137 | 137 | // Translated from golang.go/src/math/big/rat.go. |
| 138 | debug.assert(@typeInfo(T) == .Float); | |
| 138 | debug.assert(@typeInfo(T) == .float); | |
| 139 | 139 | |
| 140 | const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 140 | const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 141 | 141 | const f_bits = @as(UnsignedInt, @bitCast(f)); |
| 142 | 142 | |
| 143 | 143 | const exponent_bits = math.floatExponentBits(T); |
| ... | ... | @@ -193,9 +193,9 @@ pub const Rational = struct { |
| 193 | 193 | pub fn toFloat(self: Rational, comptime T: type) !T { |
| 194 | 194 | // Translated from golang.go/src/math/big/rat.go. |
| 195 | 195 | // TODO: Indicate whether the result is not exact. |
| 196 | debug.assert(@typeInfo(T) == .Float); | |
| 196 | debug.assert(@typeInfo(T) == .float); | |
| 197 | 197 | |
| 198 | const fsize = @typeInfo(T).Float.bits; | |
| 198 | const fsize = @typeInfo(T).float.bits; | |
| 199 | 199 | const BitReprType = std.meta.Int(.unsigned, fsize); |
| 200 | 200 | |
| 201 | 201 | const msize = math.floatMantissaBits(T); |
| ... | ... | @@ -473,10 +473,10 @@ pub const Rational = struct { |
| 473 | 473 | }; |
| 474 | 474 | |
| 475 | 475 | fn extractLowBits(a: Int, comptime T: type) T { |
| 476 | debug.assert(@typeInfo(T) == .Int); | |
| 476 | debug.assert(@typeInfo(T) == .int); | |
| 477 | 477 | |
| 478 | const t_bits = @typeInfo(T).Int.bits; | |
| 479 | const limb_bits = @typeInfo(Limb).Int.bits; | |
| 478 | const t_bits = @typeInfo(T).int.bits; | |
| 479 | const limb_bits = @typeInfo(Limb).int.bits; | |
| 480 | 480 | if (t_bits <= limb_bits) { |
| 481 | 481 | return @as(T, @truncate(a.limbs[0])); |
| 482 | 482 | } else { |
lib/std/math/copysign.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns a value with the magnitude of `magnitude` and the sign of `sign`. |
| 6 | 6 | pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude) { |
| 7 | 7 | const T = @TypeOf(magnitude); |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 9 | 9 | const sign_bit_mask = @as(TBits, 1) << (@bitSizeOf(T) - 1); |
| 10 | 10 | const mag = @as(TBits, @bitCast(magnitude)) & ~sign_bit_mask; |
| 11 | 11 | const sgn = @as(TBits, @bitCast(sign)) & sign_bit_mask; |
lib/std/math/float.zig+10-10| ... | ... | @@ -6,21 +6,21 @@ const expectEqual = std.testing.expectEqual; |
| 6 | 6 | |
| 7 | 7 | /// Creates a raw "1.0" mantissa for floating point type T. Used to dedupe f80 logic. |
| 8 | 8 | inline fn mantissaOne(comptime T: type) comptime_int { |
| 9 | return if (@typeInfo(T).Float.bits == 80) 1 << floatFractionalBits(T) else 0; | |
| 9 | return if (@typeInfo(T).float.bits == 80) 1 << floatFractionalBits(T) else 0; | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /// Creates floating point type T from an unbiased exponent and raw mantissa. |
| 13 | 13 | inline fn reconstructFloat(comptime T: type, comptime exponent: comptime_int, comptime mantissa: comptime_int) T { |
| 14 | const TBits = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); | |
| 14 | const TBits = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); | |
| 15 | 15 | const biased_exponent = @as(TBits, exponent + floatExponentMax(T)); |
| 16 | 16 | return @as(T, @bitCast((biased_exponent << floatMantissaBits(T)) | @as(TBits, mantissa))); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /// Returns the number of bits in the exponent of floating point type T. |
| 20 | 20 | pub inline fn floatExponentBits(comptime T: type) comptime_int { |
| 21 | comptime assert(@typeInfo(T) == .Float); | |
| 21 | comptime assert(@typeInfo(T) == .float); | |
| 22 | 22 | |
| 23 | return switch (@typeInfo(T).Float.bits) { | |
| 23 | return switch (@typeInfo(T).float.bits) { | |
| 24 | 24 | 16 => 5, |
| 25 | 25 | 32 => 8, |
| 26 | 26 | 64 => 11, |
| ... | ... | @@ -32,9 +32,9 @@ pub inline fn floatExponentBits(comptime T: type) comptime_int { |
| 32 | 32 | |
| 33 | 33 | /// Returns the number of bits in the mantissa of floating point type T. |
| 34 | 34 | pub inline fn floatMantissaBits(comptime T: type) comptime_int { |
| 35 | comptime assert(@typeInfo(T) == .Float); | |
| 35 | comptime assert(@typeInfo(T) == .float); | |
| 36 | 36 | |
| 37 | return switch (@typeInfo(T).Float.bits) { | |
| 37 | return switch (@typeInfo(T).float.bits) { | |
| 38 | 38 | 16 => 10, |
| 39 | 39 | 32 => 23, |
| 40 | 40 | 64 => 52, |
| ... | ... | @@ -46,12 +46,12 @@ pub inline fn floatMantissaBits(comptime T: type) comptime_int { |
| 46 | 46 | |
| 47 | 47 | /// Returns the number of fractional bits in the mantissa of floating point type T. |
| 48 | 48 | pub inline fn floatFractionalBits(comptime T: type) comptime_int { |
| 49 | comptime assert(@typeInfo(T) == .Float); | |
| 49 | comptime assert(@typeInfo(T) == .float); | |
| 50 | 50 | |
| 51 | 51 | // standard IEEE floats have an implicit 0.m or 1.m integer part |
| 52 | 52 | // f80 is special and has an explicitly stored bit in the MSB |
| 53 | 53 | // this function corresponds to `MANT_DIG - 1' from C |
| 54 | return switch (@typeInfo(T).Float.bits) { | |
| 54 | return switch (@typeInfo(T).float.bits) { | |
| 55 | 55 | 16 => 10, |
| 56 | 56 | 32 => 23, |
| 57 | 57 | 64 => 52, |
| ... | ... | @@ -97,8 +97,8 @@ pub inline fn floatEps(comptime T: type) T { |
| 97 | 97 | /// Returns the local epsilon of floating point type T. |
| 98 | 98 | pub inline fn floatEpsAt(comptime T: type, x: T) T { |
| 99 | 99 | switch (@typeInfo(T)) { |
| 100 | .Float => |F| { | |
| 101 | const U: type = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = F.bits } }); | |
| 100 | .float => |F| { | |
| 101 | const U: type = @Type(.{ .int = .{ .signedness = .unsigned, .bits = F.bits } }); | |
| 102 | 102 | const u: U = @bitCast(x); |
| 103 | 103 | const y: T = @bitCast(u ^ 1); |
| 104 | 104 | return @abs(x - y); |
lib/std/math/frexp.zig+1-1| ... | ... | @@ -21,7 +21,7 @@ pub fn Frexp(comptime T: type) type { |
| 21 | 21 | pub fn frexp(x: anytype) Frexp(@TypeOf(x)) { |
| 22 | 22 | const T: type = @TypeOf(x); |
| 23 | 23 | |
| 24 | const bits: comptime_int = @typeInfo(T).Float.bits; | |
| 24 | const bits: comptime_int = @typeInfo(T).float.bits; | |
| 25 | 25 | const Int: type = std.meta.Int(.unsigned, bits); |
| 26 | 26 | |
| 27 | 27 | const exp_bits: comptime_int = math.floatExponentBits(T); |
lib/std/math/gcd.zig+2-2| ... | ... | @@ -8,8 +8,8 @@ pub fn gcd(a: anytype, b: anytype) @TypeOf(a, b) { |
| 8 | 8 | |
| 9 | 9 | // only unsigned integers are allowed and not both must be zero |
| 10 | 10 | comptime switch (@typeInfo(@TypeOf(a, b))) { |
| 11 | .Int => |int| std.debug.assert(int.signedness == .unsigned), | |
| 12 | .ComptimeInt => { | |
| 11 | .int => |int| std.debug.assert(int.signedness == .unsigned), | |
| 12 | .comptime_int => { | |
| 13 | 13 | std.debug.assert(a >= 0); |
| 14 | 14 | std.debug.assert(b >= 0); |
| 15 | 15 | }, |
lib/std/math/hypot.zig+2-2| ... | ... | @@ -23,8 +23,8 @@ const floatMax = math.floatMax; |
| 23 | 23 | pub fn hypot(x: anytype, y: anytype) @TypeOf(x, y) { |
| 24 | 24 | const T = @TypeOf(x, y); |
| 25 | 25 | switch (@typeInfo(T)) { |
| 26 | .Float => {}, | |
| 27 | .ComptimeFloat => return @sqrt(x * x + y * y), | |
| 26 | .float => {}, | |
| 27 | .comptime_float => return @sqrt(x * x + y * y), | |
| 28 | 28 | else => @compileError("hypot not implemented for " ++ @typeName(T)), |
| 29 | 29 | } |
| 30 | 30 | const lower = @sqrt(floatMin(T)); |
lib/std/math/ilogb.zig+1-1| ... | ... | @@ -26,7 +26,7 @@ pub const fp_ilogbnan = minInt(i32); |
| 26 | 26 | pub const fp_ilogb0 = minInt(i32); |
| 27 | 27 | |
| 28 | 28 | fn ilogbX(comptime T: type, x: T) i32 { |
| 29 | const typeWidth = @typeInfo(T).Float.bits; | |
| 29 | const typeWidth = @typeInfo(T).float.bits; | |
| 30 | 30 | const significandBits = math.floatMantissaBits(T); |
| 31 | 31 | const exponentBits = math.floatExponentBits(T); |
| 32 | 32 |
lib/std/math/isfinite.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is a finite value. |
| 6 | 6 | pub fn isFinite(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 9 | 9 | const remove_sign = ~@as(TBits, 0) >> 1; |
| 10 | 10 | return @as(TBits, @bitCast(x)) & remove_sign < @as(TBits, @bitCast(math.inf(T))); |
| 11 | 11 | } |
lib/std/math/isinf.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is an infinity, ignoring sign. |
| 6 | 6 | pub inline fn isInf(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 9 | 9 | const remove_sign = ~@as(TBits, 0) >> 1; |
| 10 | 10 | return @as(TBits, @bitCast(x)) & remove_sign == @as(TBits, @bitCast(math.inf(T))); |
| 11 | 11 | } |
lib/std/math/isnormal.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is neither zero, subnormal, infinity, or NaN. |
| 6 | 6 | pub fn isNormal(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 9 | 9 | |
| 10 | 10 | const increment_exp = 1 << math.floatMantissaBits(T); |
| 11 | 11 | const remove_sign = ~@as(TBits, 0) >> 1; |
lib/std/math/iszero.zig+2-2| ... | ... | @@ -5,7 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is positive zero. |
| 6 | 6 | pub inline fn isPositiveZero(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const bit_count = @typeInfo(T).Float.bits; | |
| 8 | const bit_count = @typeInfo(T).float.bits; | |
| 9 | 9 | const TBits = std.meta.Int(.unsigned, bit_count); |
| 10 | 10 | return @as(TBits, @bitCast(x)) == @as(TBits, 0); |
| 11 | 11 | } |
| ... | ... | @@ -13,7 +13,7 @@ pub inline fn isPositiveZero(x: anytype) bool { |
| 13 | 13 | /// Returns whether x is negative zero. |
| 14 | 14 | pub inline fn isNegativeZero(x: anytype) bool { |
| 15 | 15 | const T = @TypeOf(x); |
| 16 | const bit_count = @typeInfo(T).Float.bits; | |
| 16 | const bit_count = @typeInfo(T).float.bits; | |
| 17 | 17 | const TBits = std.meta.Int(.unsigned, bit_count); |
| 18 | 18 | return @as(TBits, @bitCast(x)) == @as(TBits, 1) << (bit_count - 1); |
| 19 | 19 | } |
lib/std/math/ldexp.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ const expect = std.testing.expect; |
| 7 | 7 | /// Returns x * 2^n. |
| 8 | 8 | pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { |
| 9 | 9 | const T = @TypeOf(x); |
| 10 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 10 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 11 | 11 | |
| 12 | 12 | const exponent_bits = math.floatExponentBits(T); |
| 13 | 13 | const mantissa_bits = math.floatMantissaBits(T); |
lib/std/math/log.zig+5-5| ... | ... | @@ -14,26 +14,26 @@ pub fn log(comptime T: type, base: T, x: T) T { |
| 14 | 14 | return math.log2(x); |
| 15 | 15 | } else if (base == 10) { |
| 16 | 16 | return math.log10(x); |
| 17 | } else if ((@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat) and base == math.e) { | |
| 17 | } else if ((@typeInfo(T) == .float or @typeInfo(T) == .comptime_float) and base == math.e) { | |
| 18 | 18 | return @log(x); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | const float_base = math.lossyCast(f64, base); |
| 22 | 22 | switch (@typeInfo(T)) { |
| 23 | .ComptimeFloat => { | |
| 23 | .comptime_float => { | |
| 24 | 24 | return @as(comptime_float, @log(@as(f64, x)) / @log(float_base)); |
| 25 | 25 | }, |
| 26 | 26 | |
| 27 | .ComptimeInt => { | |
| 27 | .comptime_int => { | |
| 28 | 28 | return @as(comptime_int, math.log_int(comptime_int, base, x)); |
| 29 | 29 | }, |
| 30 | 30 | |
| 31 | .Int => |IntType| switch (IntType.signedness) { | |
| 31 | .int => |IntType| switch (IntType.signedness) { | |
| 32 | 32 | .signed => @compileError("log not implemented for signed integers"), |
| 33 | 33 | .unsigned => return @as(T, math.log_int(T, base, x)), |
| 34 | 34 | }, |
| 35 | 35 | |
| 36 | .Float => { | |
| 36 | .float => { | |
| 37 | 37 | switch (T) { |
| 38 | 38 | f32 => return @as(f32, @floatCast(@log(@as(f64, x)) / @log(float_base))), |
| 39 | 39 | f64 => return @log(x) / @log(float_base), |
lib/std/math/log10.zig+6-6| ... | ... | @@ -12,14 +12,14 @@ const testing = std.testing; |
| 12 | 12 | pub fn log10(x: anytype) @TypeOf(x) { |
| 13 | 13 | const T = @TypeOf(x); |
| 14 | 14 | switch (@typeInfo(T)) { |
| 15 | .ComptimeFloat => { | |
| 15 | .comptime_float => { | |
| 16 | 16 | return @as(comptime_float, @log10(x)); |
| 17 | 17 | }, |
| 18 | .Float => return @log10(x), | |
| 19 | .ComptimeInt => { | |
| 18 | .float => return @log10(x), | |
| 19 | .comptime_int => { | |
| 20 | 20 | return @as(comptime_int, @floor(@log10(@as(f64, x)))); |
| 21 | 21 | }, |
| 22 | .Int => |IntType| switch (IntType.signedness) { | |
| 22 | .int => |IntType| switch (IntType.signedness) { | |
| 23 | 23 | .signed => @compileError("log10 not implemented for signed integers"), |
| 24 | 24 | .unsigned => return log10_int(x), |
| 25 | 25 | }, |
| ... | ... | @@ -37,12 +37,12 @@ pub fn log10(x: anytype) @TypeOf(x) { |
| 37 | 37 | pub fn log10_int(x: anytype) std.math.Log2Int(@TypeOf(x)) { |
| 38 | 38 | const T = @TypeOf(x); |
| 39 | 39 | const OutT = std.math.Log2Int(T); |
| 40 | if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned) | |
| 40 | if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned) | |
| 41 | 41 | @compileError("log10_int requires an unsigned integer, found " ++ @typeName(T)); |
| 42 | 42 | |
| 43 | 43 | std.debug.assert(x != 0); |
| 44 | 44 | |
| 45 | const bit_size = @typeInfo(T).Int.bits; | |
| 45 | const bit_size = @typeInfo(T).int.bits; | |
| 46 | 46 | |
| 47 | 47 | if (bit_size <= 8) { |
| 48 | 48 | return @as(OutT, @intCast(log10_int_u8(x))); |
lib/std/math/log2.zig+4-4| ... | ... | @@ -13,11 +13,11 @@ const expect = std.testing.expect; |
| 13 | 13 | pub fn log2(x: anytype) @TypeOf(x) { |
| 14 | 14 | const T = @TypeOf(x); |
| 15 | 15 | switch (@typeInfo(T)) { |
| 16 | .ComptimeFloat => { | |
| 16 | .comptime_float => { | |
| 17 | 17 | return @as(comptime_float, @log2(x)); |
| 18 | 18 | }, |
| 19 | .Float => return @log2(x), | |
| 20 | .ComptimeInt => comptime { | |
| 19 | .float => return @log2(x), | |
| 20 | .comptime_int => comptime { | |
| 21 | 21 | var x_shifted = x; |
| 22 | 22 | // First, calculate floorPowerOfTwo(x) |
| 23 | 23 | var shift_amt = 1; |
| ... | ... | @@ -34,7 +34,7 @@ pub fn log2(x: anytype) @TypeOf(x) { |
| 34 | 34 | } |
| 35 | 35 | return result; |
| 36 | 36 | }, |
| 37 | .Int => |IntType| switch (IntType.signedness) { | |
| 37 | .int => |IntType| switch (IntType.signedness) { | |
| 38 | 38 | .signed => @compileError("log2 not implemented for signed integers"), |
| 39 | 39 | .unsigned => return math.log2_int(T, x), |
| 40 | 40 | }, |
lib/std/math/log_int.zig+3-5| ... | ... | @@ -8,8 +8,8 @@ const Log2Int = math.Log2Int; |
| 8 | 8 | /// Asserts that `base > 1` and `x > 0`. |
| 9 | 9 | pub fn log_int(comptime T: type, base: T, x: T) Log2Int(T) { |
| 10 | 10 | const valid = switch (@typeInfo(T)) { |
| 11 | .ComptimeInt => true, | |
| 12 | .Int => |IntType| IntType.signedness == .unsigned, | |
| 11 | .comptime_int => true, | |
| 12 | .int => |IntType| IntType.signedness == .unsigned, | |
| 13 | 13 | else => false, |
| 14 | 14 | }; |
| 15 | 15 | if (!valid) @compileError("log_int requires an unsigned integer, found " ++ @typeName(T)); |
| ... | ... | @@ -64,9 +64,7 @@ test "log_int" { |
| 64 | 64 | // Test all unsigned integers with 2, 3, ..., 64 bits. |
| 65 | 65 | // We cannot test 0 or 1 bits since base must be > 1. |
| 66 | 66 | inline for (2..64 + 1) |bits| { |
| 67 | const T = @Type(std.builtin.Type{ | |
| 68 | .Int = std.builtin.Type.Int{ .signedness = .unsigned, .bits = @intCast(bits) }, | |
| 69 | }); | |
| 67 | const T = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @intCast(bits) } }); | |
| 70 | 68 | |
| 71 | 69 | // for base = 2, 3, ..., min(maxInt(T),1024) |
| 72 | 70 | var base: T = 1; |
lib/std/math/nextafter.zig+6-6| ... | ... | @@ -14,15 +14,15 @@ const expect = std.testing.expect; |
| 14 | 14 | /// |
| 15 | 15 | pub fn nextAfter(comptime T: type, x: T, y: T) T { |
| 16 | 16 | return switch (@typeInfo(T)) { |
| 17 | .Int, .ComptimeInt => nextAfterInt(T, x, y), | |
| 18 | .Float => nextAfterFloat(T, x, y), | |
| 17 | .int, .comptime_int => nextAfterInt(T, x, y), | |
| 18 | .float => nextAfterFloat(T, x, y), | |
| 19 | 19 | else => @compileError("expected int or non-comptime float, found '" ++ @typeName(T) ++ "'"), |
| 20 | 20 | }; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | fn nextAfterInt(comptime T: type, x: T, y: T) T { |
| 24 | comptime assert(@typeInfo(T) == .Int or @typeInfo(T) == .ComptimeInt); | |
| 25 | return if (@typeInfo(T) == .Int and @bitSizeOf(T) < 2) | |
| 24 | comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int); | |
| 25 | return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2) | |
| 26 | 26 | // Special case for `i0`, `u0`, `i1`, and `u1`. |
| 27 | 27 | y |
| 28 | 28 | else if (y > x) |
| ... | ... | @@ -38,7 +38,7 @@ fn nextAfterInt(comptime T: type, x: T, y: T) T { |
| 38 | 38 | // <https://github.com/mingw-w64/mingw-w64/blob/e89de847dd3e05bb8e46344378ce3e124f4e7d1c/mingw-w64-crt/math/nextafterl.c> |
| 39 | 39 | |
| 40 | 40 | fn nextAfterFloat(comptime T: type, x: T, y: T) T { |
| 41 | comptime assert(@typeInfo(T) == .Float); | |
| 41 | comptime assert(@typeInfo(T) == .float); | |
| 42 | 42 | if (x == y) { |
| 43 | 43 | // Returning `y` ensures that (0.0, -0.0) returns -0.0 and that (-0.0, 0.0) returns 0.0. |
| 44 | 44 | return y; |
| ... | ... | @@ -320,7 +320,7 @@ test "float" { |
| 320 | 320 | |
| 321 | 321 | /// Helps ensure that 0.0 doesn't compare equal to -0.0. |
| 322 | 322 | fn bitwiseEqual(comptime T: type, x: T, y: T) bool { |
| 323 | comptime assert(@typeInfo(T) == .Float); | |
| 323 | comptime assert(@typeInfo(T) == .float); | |
| 324 | 324 | const Bits = std.meta.Int(.unsigned, @bitSizeOf(T)); |
| 325 | 325 | return @as(Bits, @bitCast(x)) == @as(Bits, @bitCast(y)); |
| 326 | 326 | } |
lib/std/math/pow.zig+3-3| ... | ... | @@ -31,7 +31,7 @@ const expect = std.testing.expect; |
| 31 | 31 | /// - pow(-inf, y) = pow(-0, -y) |
| 32 | 32 | /// - pow(x, y) = nan for finite x < 0 and finite non-integer y |
| 33 | 33 | pub fn pow(comptime T: type, x: T, y: T) T { |
| 34 | if (@typeInfo(T) == .Int) { | |
| 34 | if (@typeInfo(T) == .int) { | |
| 35 | 35 | return math.powi(T, x, y) catch unreachable; |
| 36 | 36 | } |
| 37 | 37 | |
| ... | ... | @@ -122,7 +122,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { |
| 122 | 122 | if (yf != 0 and x < 0) { |
| 123 | 123 | return math.nan(T); |
| 124 | 124 | } |
| 125 | if (yi >= 1 << (@typeInfo(T).Float.bits - 1)) { | |
| 125 | if (yi >= 1 << (@typeInfo(T).float.bits - 1)) { | |
| 126 | 126 | return @exp(y * @log(x)); |
| 127 | 127 | } |
| 128 | 128 | |
| ... | ... | @@ -144,7 +144,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { |
| 144 | 144 | var xe = r2.exponent; |
| 145 | 145 | var x1 = r2.significand; |
| 146 | 146 | |
| 147 | var i = @as(std.meta.Int(.signed, @typeInfo(T).Float.bits), @intFromFloat(yi)); | |
| 147 | var i = @as(std.meta.Int(.signed, @typeInfo(T).float.bits), @intFromFloat(yi)); | |
| 148 | 148 | while (i != 0) : (i >>= 1) { |
| 149 | 149 | const overflow_shift = math.floatExponentBits(T) + 1; |
| 150 | 150 | if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) { |
lib/std/math/powi.zig+1-1| ... | ... | @@ -27,7 +27,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{ |
| 27 | 27 | Overflow, |
| 28 | 28 | Underflow, |
| 29 | 29 | }!T) { |
| 30 | const bit_size = @typeInfo(T).Int.bits; | |
| 30 | const bit_size = @typeInfo(T).int.bits; | |
| 31 | 31 | |
| 32 | 32 | // `y & 1 == 0` won't compile when `does_one_overflow`. |
| 33 | 33 | const does_one_overflow = math.maxInt(T) < 1; |
lib/std/math/signbit.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is negative or negative 0. |
| 6 | 6 | pub fn signbit(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 9 | 9 | return @as(TBits, @bitCast(x)) >> (@bitSizeOf(T) - 1) != 0; |
| 10 | 10 | } |
| 11 | 11 |
lib/std/math/sqrt.zig+6-6| ... | ... | @@ -15,8 +15,8 @@ const maxInt = std.math.maxInt; |
| 15 | 15 | pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { |
| 16 | 16 | const T = @TypeOf(x); |
| 17 | 17 | switch (@typeInfo(T)) { |
| 18 | .Float, .ComptimeFloat => return @sqrt(x), | |
| 19 | .ComptimeInt => comptime { | |
| 18 | .float, .comptime_float => return @sqrt(x), | |
| 19 | .comptime_int => comptime { | |
| 20 | 20 | if (x > maxInt(u128)) { |
| 21 | 21 | @compileError("sqrt not implemented for comptime_int greater than 128 bits"); |
| 22 | 22 | } |
| ... | ... | @@ -25,7 +25,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { |
| 25 | 25 | } |
| 26 | 26 | return @as(T, sqrt_int(u128, x)); |
| 27 | 27 | }, |
| 28 | .Int => |IntType| switch (IntType.signedness) { | |
| 28 | .int => |IntType| switch (IntType.signedness) { | |
| 29 | 29 | .signed => @compileError("sqrt not implemented for signed integers"), |
| 30 | 30 | .unsigned => return sqrt_int(T, x), |
| 31 | 31 | }, |
| ... | ... | @@ -34,10 +34,10 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | fn sqrt_int(comptime T: type, value: T) Sqrt(T) { |
| 37 | if (@typeInfo(T).Int.bits <= 2) { | |
| 37 | if (@typeInfo(T).int.bits <= 2) { | |
| 38 | 38 | return if (value == 0) 0 else 1; // shortcut for small number of bits to simplify general case |
| 39 | 39 | } else { |
| 40 | const bits = @typeInfo(T).Int.bits; | |
| 40 | const bits = @typeInfo(T).int.bits; | |
| 41 | 41 | const max = math.maxInt(T); |
| 42 | 42 | const minustwo = (@as(T, 2) ^ max) + 1; // unsigned int cannot represent -2 |
| 43 | 43 | var op = value; |
| ... | ... | @@ -80,7 +80,7 @@ test sqrt_int { |
| 80 | 80 | /// Returns the return type `sqrt` will return given an operand of type `T`. |
| 81 | 81 | pub fn Sqrt(comptime T: type) type { |
| 82 | 82 | return switch (@typeInfo(T)) { |
| 83 | .Int => |int| std.meta.Int(.unsigned, (int.bits + 1) / 2), | |
| 83 | .int => |int| @Type(.{ .int = .{ .signedness = .unsigned, .bits = (int.bits + 1) / 2 } }), | |
| 84 | 84 | else => T, |
| 85 | 85 | }; |
| 86 | 86 | } |
lib/std/mem.zig+89-89| ... | ... | @@ -229,22 +229,22 @@ pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void { |
| 229 | 229 | /// This can be used to zero-initialize any type for which it makes sense. Structs will be initialized recursively. |
| 230 | 230 | pub fn zeroes(comptime T: type) T { |
| 231 | 231 | switch (@typeInfo(T)) { |
| 232 | .ComptimeInt, .Int, .ComptimeFloat, .Float => { | |
| 232 | .comptime_int, .int, .comptime_float, .float => { | |
| 233 | 233 | return @as(T, 0); |
| 234 | 234 | }, |
| 235 | .Enum => { | |
| 235 | .@"enum" => { | |
| 236 | 236 | return @as(T, @enumFromInt(0)); |
| 237 | 237 | }, |
| 238 | .Void => { | |
| 238 | .void => { | |
| 239 | 239 | return {}; |
| 240 | 240 | }, |
| 241 | .Bool => { | |
| 241 | .bool => { | |
| 242 | 242 | return false; |
| 243 | 243 | }, |
| 244 | .Optional, .Null => { | |
| 244 | .optional, .null => { | |
| 245 | 245 | return null; |
| 246 | 246 | }, |
| 247 | .Struct => |struct_info| { | |
| 247 | .@"struct" => |struct_info| { | |
| 248 | 248 | if (@sizeOf(T) == 0) return undefined; |
| 249 | 249 | if (struct_info.layout == .@"extern") { |
| 250 | 250 | var item: T = undefined; |
| ... | ... | @@ -260,7 +260,7 @@ pub fn zeroes(comptime T: type) T { |
| 260 | 260 | return structure; |
| 261 | 261 | } |
| 262 | 262 | }, |
| 263 | .Pointer => |ptr_info| { | |
| 263 | .pointer => |ptr_info| { | |
| 264 | 264 | switch (ptr_info.size) { |
| 265 | 265 | .Slice => { |
| 266 | 266 | if (ptr_info.sentinel) |sentinel| { |
| ... | ... | @@ -281,17 +281,17 @@ pub fn zeroes(comptime T: type) T { |
| 281 | 281 | }, |
| 282 | 282 | } |
| 283 | 283 | }, |
| 284 | .Array => |info| { | |
| 284 | .array => |info| { | |
| 285 | 285 | if (info.sentinel) |sentinel_ptr| { |
| 286 | 286 | const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; |
| 287 | 287 | return [_:sentinel]info.child{zeroes(info.child)} ** info.len; |
| 288 | 288 | } |
| 289 | 289 | return [_]info.child{zeroes(info.child)} ** info.len; |
| 290 | 290 | }, |
| 291 | .Vector => |info| { | |
| 291 | .vector => |info| { | |
| 292 | 292 | return @splat(zeroes(info.child)); |
| 293 | 293 | }, |
| 294 | .Union => |info| { | |
| 294 | .@"union" => |info| { | |
| 295 | 295 | if (info.layout == .@"extern") { |
| 296 | 296 | var item: T = undefined; |
| 297 | 297 | @memset(asBytes(&item), 0); |
| ... | ... | @@ -299,16 +299,16 @@ pub fn zeroes(comptime T: type) T { |
| 299 | 299 | } |
| 300 | 300 | @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); |
| 301 | 301 | }, |
| 302 | .EnumLiteral, | |
| 303 | .ErrorUnion, | |
| 304 | .ErrorSet, | |
| 305 | .Fn, | |
| 306 | .Type, | |
| 307 | .NoReturn, | |
| 308 | .Undefined, | |
| 309 | .Opaque, | |
| 310 | .Frame, | |
| 311 | .AnyFrame, | |
| 302 | .enum_literal, | |
| 303 | .error_union, | |
| 304 | .error_set, | |
| 305 | .@"fn", | |
| 306 | .type, | |
| 307 | .noreturn, | |
| 308 | .undefined, | |
| 309 | .@"opaque", | |
| 310 | .frame, | |
| 311 | .@"anyframe", | |
| 312 | 312 | => { |
| 313 | 313 | @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); |
| 314 | 314 | }, |
| ... | ... | @@ -423,9 +423,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 423 | 423 | const Init = @TypeOf(init); |
| 424 | 424 | |
| 425 | 425 | switch (@typeInfo(T)) { |
| 426 | .Struct => |struct_info| { | |
| 426 | .@"struct" => |struct_info| { | |
| 427 | 427 | switch (@typeInfo(Init)) { |
| 428 | .Struct => |init_info| { | |
| 428 | .@"struct" => |init_info| { | |
| 429 | 429 | if (init_info.is_tuple) { |
| 430 | 430 | if (init_info.fields.len > struct_info.fields.len) { |
| 431 | 431 | @compileError("Tuple initializer has more elements than there are fields in `" ++ @typeName(T) ++ "`"); |
| ... | ... | @@ -449,7 +449,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 449 | 449 | @field(value, field.name) = @field(init, init_info.fields[i].name); |
| 450 | 450 | } else if (@hasField(@TypeOf(init), field.name)) { |
| 451 | 451 | switch (@typeInfo(field.type)) { |
| 452 | .Struct => { | |
| 452 | .@"struct" => { | |
| 453 | 453 | @field(value, field.name) = zeroInit(field.type, @field(init, field.name)); |
| 454 | 454 | }, |
| 455 | 455 | else => { |
| ... | ... | @@ -461,7 +461,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 461 | 461 | @field(value, field.name) = default_value; |
| 462 | 462 | } else { |
| 463 | 463 | switch (@typeInfo(field.type)) { |
| 464 | .Struct => { | |
| 464 | .@"struct" => { | |
| 465 | 465 | @field(value, field.name) = std.mem.zeroInit(field.type, .{}); |
| 466 | 466 | }, |
| 467 | 467 | else => { |
| ... | ... | @@ -752,10 +752,10 @@ test indexOfDiff { |
| 752 | 752 | /// `[*c]` pointers are assumed to be 0-terminated and assumed to not be allowzero. |
| 753 | 753 | fn Span(comptime T: type) type { |
| 754 | 754 | switch (@typeInfo(T)) { |
| 755 | .Optional => |optional_info| { | |
| 755 | .optional => |optional_info| { | |
| 756 | 756 | return ?Span(optional_info.child); |
| 757 | 757 | }, |
| 758 | .Pointer => |ptr_info| { | |
| 758 | .pointer => |ptr_info| { | |
| 759 | 759 | var new_ptr_info = ptr_info; |
| 760 | 760 | switch (ptr_info.size) { |
| 761 | 761 | .C => { |
| ... | ... | @@ -766,7 +766,7 @@ fn Span(comptime T: type) type { |
| 766 | 766 | .One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)), |
| 767 | 767 | } |
| 768 | 768 | new_ptr_info.size = .Slice; |
| 769 | return @Type(.{ .Pointer = new_ptr_info }); | |
| 769 | return @Type(.{ .pointer = new_ptr_info }); | |
| 770 | 770 | }, |
| 771 | 771 | else => {}, |
| 772 | 772 | } |
| ... | ... | @@ -789,7 +789,7 @@ test Span { |
| 789 | 789 | /// Pointer attributes such as const are preserved. |
| 790 | 790 | /// `[*c]` pointers are assumed to be non-null and 0-terminated. |
| 791 | 791 | pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { |
| 792 | if (@typeInfo(@TypeOf(ptr)) == .Optional) { | |
| 792 | if (@typeInfo(@TypeOf(ptr)) == .optional) { | |
| 793 | 793 | if (ptr) |non_null| { |
| 794 | 794 | return span(non_null); |
| 795 | 795 | } else { |
| ... | ... | @@ -798,7 +798,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { |
| 798 | 798 | } |
| 799 | 799 | const Result = Span(@TypeOf(ptr)); |
| 800 | 800 | const l = len(ptr); |
| 801 | const ptr_info = @typeInfo(Result).Pointer; | |
| 801 | const ptr_info = @typeInfo(Result).pointer; | |
| 802 | 802 | if (ptr_info.sentinel) |s_ptr| { |
| 803 | 803 | const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; |
| 804 | 804 | return ptr[0..l :s]; |
| ... | ... | @@ -817,15 +817,15 @@ test span { |
| 817 | 817 | /// Helper for the return type of sliceTo() |
| 818 | 818 | fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { |
| 819 | 819 | switch (@typeInfo(T)) { |
| 820 | .Optional => |optional_info| { | |
| 820 | .optional => |optional_info| { | |
| 821 | 821 | return ?SliceTo(optional_info.child, end); |
| 822 | 822 | }, |
| 823 | .Pointer => |ptr_info| { | |
| 823 | .pointer => |ptr_info| { | |
| 824 | 824 | var new_ptr_info = ptr_info; |
| 825 | 825 | new_ptr_info.size = .Slice; |
| 826 | 826 | switch (ptr_info.size) { |
| 827 | 827 | .One => switch (@typeInfo(ptr_info.child)) { |
| 828 | .Array => |array_info| { | |
| 828 | .array => |array_info| { | |
| 829 | 829 | new_ptr_info.child = array_info.child; |
| 830 | 830 | // The return type must only be sentinel terminated if we are guaranteed |
| 831 | 831 | // to find the value searched for, which is only the case if it matches |
| ... | ... | @@ -861,7 +861,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { |
| 861 | 861 | new_ptr_info.is_allowzero = false; |
| 862 | 862 | }, |
| 863 | 863 | } |
| 864 | return @Type(.{ .Pointer = new_ptr_info }); | |
| 864 | return @Type(.{ .pointer = new_ptr_info }); | |
| 865 | 865 | }, |
| 866 | 866 | else => {}, |
| 867 | 867 | } |
| ... | ... | @@ -876,13 +876,13 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { |
| 876 | 876 | /// Pointer properties such as mutability and alignment are preserved. |
| 877 | 877 | /// C pointers are assumed to be non-null. |
| 878 | 878 | pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end) { |
| 879 | if (@typeInfo(@TypeOf(ptr)) == .Optional) { | |
| 879 | if (@typeInfo(@TypeOf(ptr)) == .optional) { | |
| 880 | 880 | const non_null = ptr orelse return null; |
| 881 | 881 | return sliceTo(non_null, end); |
| 882 | 882 | } |
| 883 | 883 | const Result = SliceTo(@TypeOf(ptr), end); |
| 884 | 884 | const length = lenSliceTo(ptr, end); |
| 885 | const ptr_info = @typeInfo(Result).Pointer; | |
| 885 | const ptr_info = @typeInfo(Result).pointer; | |
| 886 | 886 | if (ptr_info.sentinel) |s_ptr| { |
| 887 | 887 | const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; |
| 888 | 888 | return ptr[0..length :s]; |
| ... | ... | @@ -933,9 +933,9 @@ test sliceTo { |
| 933 | 933 | /// Private helper for sliceTo(). If you want the length, use sliceTo(foo, x).len |
| 934 | 934 | fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize { |
| 935 | 935 | switch (@typeInfo(@TypeOf(ptr))) { |
| 936 | .Pointer => |ptr_info| switch (ptr_info.size) { | |
| 936 | .pointer => |ptr_info| switch (ptr_info.size) { | |
| 937 | 937 | .One => switch (@typeInfo(ptr_info.child)) { |
| 938 | .Array => |array_info| { | |
| 938 | .array => |array_info| { | |
| 939 | 939 | if (array_info.sentinel) |sentinel_ptr| { |
| 940 | 940 | const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; |
| 941 | 941 | if (sentinel == end) { |
| ... | ... | @@ -1015,7 +1015,7 @@ test lenSliceTo { |
| 1015 | 1015 | /// `[*c]` pointers are assumed to be non-null and 0-terminated. |
| 1016 | 1016 | pub fn len(value: anytype) usize { |
| 1017 | 1017 | switch (@typeInfo(@TypeOf(value))) { |
| 1018 | .Pointer => |info| switch (info.size) { | |
| 1018 | .pointer => |info| switch (info.size) { | |
| 1019 | 1019 | .Many => { |
| 1020 | 1020 | const sentinel_ptr = info.sentinel orelse |
| 1021 | 1021 | @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value))); |
| ... | ... | @@ -1051,7 +1051,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co |
| 1051 | 1051 | if (backend_supports_vectors and |
| 1052 | 1052 | !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717 |
| 1053 | 1053 | !@inComptime() and |
| 1054 | (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T))) | |
| 1054 | (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T))) | |
| 1055 | 1055 | { |
| 1056 | 1056 | switch (@import("builtin").cpu.arch) { |
| 1057 | 1057 | // The below branch assumes that reading past the end of the buffer is valid, as long |
| ... | ... | @@ -1202,7 +1202,7 @@ pub fn indexOfScalarPos(comptime T: type, slice: []const T, start_index: usize, |
| 1202 | 1202 | if (backend_supports_vectors and |
| 1203 | 1203 | !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717 |
| 1204 | 1204 | !@inComptime() and |
| 1205 | (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T))) | |
| 1205 | (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T))) | |
| 1206 | 1206 | { |
| 1207 | 1207 | if (std.simd.suggestVectorLength(T)) |block_len| { |
| 1208 | 1208 | // For Intel Nehalem (2009) and AMD Bulldozer (2012) or later, unaligned loads on aligned data result |
| ... | ... | @@ -1602,8 +1602,8 @@ test containsAtLeast { |
| 1602 | 1602 | /// T specifies the return type, which must be large enough to store |
| 1603 | 1603 | /// the result. |
| 1604 | 1604 | pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType { |
| 1605 | const bits = @typeInfo(ReturnType).Int.bits; | |
| 1606 | const signedness = @typeInfo(ReturnType).Int.signedness; | |
| 1605 | const bits = @typeInfo(ReturnType).int.bits; | |
| 1606 | const signedness = @typeInfo(ReturnType).int.signedness; | |
| 1607 | 1607 | const WorkType = std.meta.Int(signedness, @max(16, bits)); |
| 1608 | 1608 | var result: WorkType = 0; |
| 1609 | 1609 | switch (endian) { |
| ... | ... | @@ -1635,7 +1635,7 @@ test readVarInt { |
| 1635 | 1635 | try testing.expect(readVarInt(i16, &[_]u8{ 0xff, 0xfd }, .big) == -3); |
| 1636 | 1636 | try testing.expect(readVarInt(i16, &[_]u8{ 0xfc, 0xff }, .little) == -4); |
| 1637 | 1637 | |
| 1638 | // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).Int.bits) | |
| 1638 | // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).int.bits) | |
| 1639 | 1639 | try testing.expect(readVarInt(u9, &[_]u8{0x12}, .little) == 0x12); |
| 1640 | 1640 | try testing.expect(readVarInt(u9, &[_]u8{0xde}, .big) == 0xde); |
| 1641 | 1641 | try testing.expect(readVarInt(u80, &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }, .big) == 0x123456789abcdef024); |
| ... | ... | @@ -1719,7 +1719,7 @@ test readVarPackedInt { |
| 1719 | 1719 | /// Reads an integer from memory with bit count specified by T. |
| 1720 | 1720 | /// The bit count of T must be evenly divisible by 8. |
| 1721 | 1721 | /// This function cannot fail and cannot cause undefined behavior. |
| 1722 | pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).Int.bits, 8)]u8, endian: Endian) T { | |
| 1722 | pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).int.bits, 8)]u8, endian: Endian) T { | |
| 1723 | 1723 | const value: T = @bitCast(buffer.*); |
| 1724 | 1724 | return if (endian == native_endian) value else @byteSwap(value); |
| 1725 | 1725 | } |
| ... | ... | @@ -1844,7 +1844,7 @@ test "comptime read/write int" { |
| 1844 | 1844 | /// Writes an integer to memory, storing it in twos-complement. |
| 1845 | 1845 | /// This function always succeeds, has defined behavior for all inputs, but |
| 1846 | 1846 | /// the integer bit width must be divisible by 8. |
| 1847 | pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).Int.bits, 8)]u8, value: T, endian: Endian) void { | |
| 1847 | pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).int.bits, 8)]u8, value: T, endian: Endian) void { | |
| 1848 | 1848 | buffer.* = @bitCast(if (endian == native_endian) value else @byteSwap(value)); |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| ... | ... | @@ -2047,20 +2047,20 @@ test writeVarPackedInt { |
| 2047 | 2047 | /// (Changing their endianness) |
| 2048 | 2048 | pub fn byteSwapAllFields(comptime S: type, ptr: *S) void { |
| 2049 | 2049 | switch (@typeInfo(S)) { |
| 2050 | .Struct => { | |
| 2050 | .@"struct" => { | |
| 2051 | 2051 | inline for (std.meta.fields(S)) |f| { |
| 2052 | 2052 | switch (@typeInfo(f.type)) { |
| 2053 | .Struct => |struct_info| if (struct_info.backing_integer) |Int| { | |
| 2053 | .@"struct" => |struct_info| if (struct_info.backing_integer) |Int| { | |
| 2054 | 2054 | @field(ptr, f.name) = @bitCast(@byteSwap(@as(Int, @bitCast(@field(ptr, f.name))))); |
| 2055 | 2055 | } else { |
| 2056 | 2056 | byteSwapAllFields(f.type, &@field(ptr, f.name)); |
| 2057 | 2057 | }, |
| 2058 | .Array => byteSwapAllFields(f.type, &@field(ptr, f.name)), | |
| 2059 | .Enum => { | |
| 2058 | .array => byteSwapAllFields(f.type, &@field(ptr, f.name)), | |
| 2059 | .@"enum" => { | |
| 2060 | 2060 | @field(ptr, f.name) = @enumFromInt(@byteSwap(@intFromEnum(@field(ptr, f.name)))); |
| 2061 | 2061 | }, |
| 2062 | .Bool => {}, | |
| 2063 | .Float => |float_info| { | |
| 2062 | .bool => {}, | |
| 2063 | .float => |float_info| { | |
| 2064 | 2064 | @field(ptr, f.name) = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name))))); |
| 2065 | 2065 | }, |
| 2066 | 2066 | else => { |
| ... | ... | @@ -2069,15 +2069,15 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void { |
| 2069 | 2069 | } |
| 2070 | 2070 | } |
| 2071 | 2071 | }, |
| 2072 | .Array => { | |
| 2072 | .array => { | |
| 2073 | 2073 | for (ptr) |*item| { |
| 2074 | 2074 | switch (@typeInfo(@TypeOf(item.*))) { |
| 2075 | .Struct, .Array => byteSwapAllFields(@TypeOf(item.*), item), | |
| 2076 | .Enum => { | |
| 2075 | .@"struct", .array => byteSwapAllFields(@TypeOf(item.*), item), | |
| 2076 | .@"enum" => { | |
| 2077 | 2077 | item.* = @enumFromInt(@byteSwap(@intFromEnum(item.*))); |
| 2078 | 2078 | }, |
| 2079 | .Bool => {}, | |
| 2080 | .Float => |float_info| { | |
| 2079 | .bool => {}, | |
| 2080 | .float => |float_info| { | |
| 2081 | 2081 | item.* = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(item.*)))); |
| 2082 | 2082 | }, |
| 2083 | 2083 | else => { |
| ... | ... | @@ -3560,21 +3560,21 @@ test reverse { |
| 3560 | 3560 | fn ReverseIterator(comptime T: type) type { |
| 3561 | 3561 | const Pointer = blk: { |
| 3562 | 3562 | switch (@typeInfo(T)) { |
| 3563 | .Pointer => |ptr_info| switch (ptr_info.size) { | |
| 3563 | .pointer => |ptr_info| switch (ptr_info.size) { | |
| 3564 | 3564 | .One => switch (@typeInfo(ptr_info.child)) { |
| 3565 | .Array => |array_info| { | |
| 3565 | .array => |array_info| { | |
| 3566 | 3566 | var new_ptr_info = ptr_info; |
| 3567 | 3567 | new_ptr_info.size = .Many; |
| 3568 | 3568 | new_ptr_info.child = array_info.child; |
| 3569 | 3569 | new_ptr_info.sentinel = array_info.sentinel; |
| 3570 | break :blk @Type(.{ .Pointer = new_ptr_info }); | |
| 3570 | break :blk @Type(.{ .pointer = new_ptr_info }); | |
| 3571 | 3571 | }, |
| 3572 | 3572 | else => {}, |
| 3573 | 3573 | }, |
| 3574 | 3574 | .Slice => { |
| 3575 | 3575 | var new_ptr_info = ptr_info; |
| 3576 | 3576 | new_ptr_info.size = .Many; |
| 3577 | break :blk @Type(.{ .Pointer = new_ptr_info }); | |
| 3577 | break :blk @Type(.{ .pointer = new_ptr_info }); | |
| 3578 | 3578 | }, |
| 3579 | 3579 | else => {}, |
| 3580 | 3580 | }, |
| ... | ... | @@ -3583,8 +3583,8 @@ fn ReverseIterator(comptime T: type) type { |
| 3583 | 3583 | @compileError("expected slice or pointer to array, found '" ++ @typeName(T) ++ "'"); |
| 3584 | 3584 | }; |
| 3585 | 3585 | const Element = std.meta.Elem(Pointer); |
| 3586 | const ElementPointer = @Type(.{ .Pointer = ptr: { | |
| 3587 | var ptr = @typeInfo(Pointer).Pointer; | |
| 3586 | const ElementPointer = @Type(.{ .pointer = ptr: { | |
| 3587 | var ptr = @typeInfo(Pointer).pointer; | |
| 3588 | 3588 | ptr.size = .One; |
| 3589 | 3589 | ptr.child = Element; |
| 3590 | 3590 | ptr.sentinel = null; |
| ... | ... | @@ -3891,11 +3891,11 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { |
| 3891 | 3891 | |
| 3892 | 3892 | const T = @TypeOf(ptr); |
| 3893 | 3893 | const info = @typeInfo(T); |
| 3894 | if (info != .Pointer or info.Pointer.size != .Many) | |
| 3894 | if (info != .pointer or info.pointer.size != .Many) | |
| 3895 | 3895 | @compileError("expected many item pointer, got " ++ @typeName(T)); |
| 3896 | 3896 | |
| 3897 | 3897 | // Do nothing if the pointer is already well-aligned. |
| 3898 | if (align_to <= info.Pointer.alignment) | |
| 3898 | if (align_to <= info.pointer.alignment) | |
| 3899 | 3899 | return 0; |
| 3900 | 3900 | |
| 3901 | 3901 | // Calculate the aligned base address with an eye out for overflow. |
| ... | ... | @@ -3907,7 +3907,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { |
| 3907 | 3907 | // The delta is expressed in terms of bytes, turn it into a number of child |
| 3908 | 3908 | // type elements. |
| 3909 | 3909 | const delta = ov[0] - addr; |
| 3910 | const pointee_size = @sizeOf(info.Pointer.child); | |
| 3910 | const pointee_size = @sizeOf(info.pointer.child); | |
| 3911 | 3911 | if (delta % pointee_size != 0) return null; |
| 3912 | 3912 | return delta / pointee_size; |
| 3913 | 3913 | } |
| ... | ... | @@ -3948,9 +3948,9 @@ fn CopyPtrAttrs( |
| 3948 | 3948 | comptime size: std.builtin.Type.Pointer.Size, |
| 3949 | 3949 | comptime child: type, |
| 3950 | 3950 | ) type { |
| 3951 | const info = @typeInfo(source).Pointer; | |
| 3951 | const info = @typeInfo(source).pointer; | |
| 3952 | 3952 | return @Type(.{ |
| 3953 | .Pointer = .{ | |
| 3953 | .pointer = .{ | |
| 3954 | 3954 | .size = size, |
| 3955 | 3955 | .is_const = info.is_const, |
| 3956 | 3956 | .is_volatile = info.is_volatile, |
| ... | ... | @@ -4019,8 +4019,8 @@ test "asBytes preserves pointer attributes" { |
| 4019 | 4019 | const inPtr = @as(*align(16) const volatile u32, @ptrCast(&inArr)); |
| 4020 | 4020 | const outSlice = asBytes(inPtr); |
| 4021 | 4021 | |
| 4022 | const in = @typeInfo(@TypeOf(inPtr)).Pointer; | |
| 4023 | const out = @typeInfo(@TypeOf(outSlice)).Pointer; | |
| 4022 | const in = @typeInfo(@TypeOf(inPtr)).pointer; | |
| 4023 | const out = @typeInfo(@TypeOf(outSlice)).pointer; | |
| 4024 | 4024 | |
| 4025 | 4025 | try testing.expectEqual(in.is_const, out.is_const); |
| 4026 | 4026 | try testing.expectEqual(in.is_volatile, out.is_volatile); |
| ... | ... | @@ -4102,8 +4102,8 @@ test "bytesAsValue preserves pointer attributes" { |
| 4102 | 4102 | const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..]; |
| 4103 | 4103 | const outPtr = bytesAsValue(u32, inSlice); |
| 4104 | 4104 | |
| 4105 | const in = @typeInfo(@TypeOf(inSlice)).Pointer; | |
| 4106 | const out = @typeInfo(@TypeOf(outPtr)).Pointer; | |
| 4105 | const in = @typeInfo(@TypeOf(inSlice)).pointer; | |
| 4106 | const out = @typeInfo(@TypeOf(outPtr)).pointer; | |
| 4107 | 4107 | |
| 4108 | 4108 | try testing.expectEqual(in.is_const, out.is_const); |
| 4109 | 4109 | try testing.expectEqual(in.is_volatile, out.is_volatile); |
| ... | ... | @@ -4204,8 +4204,8 @@ test "bytesAsSlice preserves pointer attributes" { |
| 4204 | 4204 | const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..]; |
| 4205 | 4205 | const outSlice = bytesAsSlice(u16, inSlice); |
| 4206 | 4206 | |
| 4207 | const in = @typeInfo(@TypeOf(inSlice)).Pointer; | |
| 4208 | const out = @typeInfo(@TypeOf(outSlice)).Pointer; | |
| 4207 | const in = @typeInfo(@TypeOf(inSlice)).pointer; | |
| 4208 | const out = @typeInfo(@TypeOf(outSlice)).pointer; | |
| 4209 | 4209 | |
| 4210 | 4210 | try testing.expectEqual(in.is_const, out.is_const); |
| 4211 | 4211 | try testing.expectEqual(in.is_volatile, out.is_volatile); |
| ... | ... | @@ -4303,8 +4303,8 @@ test "sliceAsBytes preserves pointer attributes" { |
| 4303 | 4303 | const inSlice = @as(*align(16) const volatile [2]u16, @ptrCast(&inArr))[0..]; |
| 4304 | 4304 | const outSlice = sliceAsBytes(inSlice); |
| 4305 | 4305 | |
| 4306 | const in = @typeInfo(@TypeOf(inSlice)).Pointer; | |
| 4307 | const out = @typeInfo(@TypeOf(outSlice)).Pointer; | |
| 4306 | const in = @typeInfo(@TypeOf(inSlice)).pointer; | |
| 4307 | const out = @typeInfo(@TypeOf(outSlice)).pointer; | |
| 4308 | 4308 | |
| 4309 | 4309 | try testing.expectEqual(in.is_const, out.is_const); |
| 4310 | 4310 | try testing.expectEqual(in.is_volatile, out.is_volatile); |
| ... | ... | @@ -4346,14 +4346,14 @@ pub fn doNotOptimizeAway(val: anytype) void { |
| 4346 | 4346 | const max_gp_register_bits = @bitSizeOf(c_long); |
| 4347 | 4347 | const t = @typeInfo(@TypeOf(val)); |
| 4348 | 4348 | switch (t) { |
| 4349 | .Void, .Null, .ComptimeInt, .ComptimeFloat => return, | |
| 4350 | .Enum => doNotOptimizeAway(@intFromEnum(val)), | |
| 4351 | .Bool => doNotOptimizeAway(@intFromBool(val)), | |
| 4352 | .Int => { | |
| 4353 | const bits = t.Int.bits; | |
| 4349 | .void, .null, .comptime_int, .comptime_float => return, | |
| 4350 | .@"enum" => doNotOptimizeAway(@intFromEnum(val)), | |
| 4351 | .bool => doNotOptimizeAway(@intFromBool(val)), | |
| 4352 | .int => { | |
| 4353 | const bits = t.int.bits; | |
| 4354 | 4354 | if (bits <= max_gp_register_bits and builtin.zig_backend != .stage2_c) { |
| 4355 | 4355 | const val2 = @as( |
| 4356 | std.meta.Int(t.Int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))), | |
| 4356 | std.meta.Int(t.int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))), | |
| 4357 | 4357 | val, |
| 4358 | 4358 | ); |
| 4359 | 4359 | asm volatile ("" |
| ... | ... | @@ -4362,15 +4362,15 @@ pub fn doNotOptimizeAway(val: anytype) void { |
| 4362 | 4362 | ); |
| 4363 | 4363 | } else doNotOptimizeAway(&val); |
| 4364 | 4364 | }, |
| 4365 | .Float => { | |
| 4366 | if ((t.Float.bits == 32 or t.Float.bits == 64) and builtin.zig_backend != .stage2_c) { | |
| 4365 | .float => { | |
| 4366 | if ((t.float.bits == 32 or t.float.bits == 64) and builtin.zig_backend != .stage2_c) { | |
| 4367 | 4367 | asm volatile ("" |
| 4368 | 4368 | : |
| 4369 | 4369 | : [val] "rm" (val), |
| 4370 | 4370 | ); |
| 4371 | 4371 | } else doNotOptimizeAway(&val); |
| 4372 | 4372 | }, |
| 4373 | .Pointer => { | |
| 4373 | .pointer => { | |
| 4374 | 4374 | if (builtin.zig_backend == .stage2_c) { |
| 4375 | 4375 | doNotOptimizeAwayC(val); |
| 4376 | 4376 | } else { |
| ... | ... | @@ -4381,8 +4381,8 @@ pub fn doNotOptimizeAway(val: anytype) void { |
| 4381 | 4381 | ); |
| 4382 | 4382 | } |
| 4383 | 4383 | }, |
| 4384 | .Array => { | |
| 4385 | if (t.Array.len * @sizeOf(t.Array.child) <= 64) { | |
| 4384 | .array => { | |
| 4385 | if (t.array.len * @sizeOf(t.array.child) <= 64) { | |
| 4386 | 4386 | for (val) |v| doNotOptimizeAway(v); |
| 4387 | 4387 | } else doNotOptimizeAway(&val); |
| 4388 | 4388 | }, |
| ... | ... | @@ -4518,9 +4518,9 @@ test "freeing empty string with null-terminated sentinel" { |
| 4518 | 4518 | /// Returns a slice with the given new alignment, |
| 4519 | 4519 | /// all other pointer attributes copied from `AttributeSource`. |
| 4520 | 4520 | fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) type { |
| 4521 | const info = @typeInfo(AttributeSource).Pointer; | |
| 4521 | const info = @typeInfo(AttributeSource).pointer; | |
| 4522 | 4522 | return @Type(.{ |
| 4523 | .Pointer = .{ | |
| 4523 | .pointer = .{ | |
| 4524 | 4524 | .size = .Slice, |
| 4525 | 4525 | .is_const = info.is_const, |
| 4526 | 4526 | .is_volatile = info.is_volatile, |
| ... | ... | @@ -4659,7 +4659,7 @@ test "read/write(Var)PackedInt" { |
| 4659 | 4659 | try expect(diff_bits << @as(Log2T, @intCast(@bitSizeOf(BackingType) - offset)) == 0); |
| 4660 | 4660 | } |
| 4661 | 4661 | |
| 4662 | const signedness = @typeInfo(PackedType).Int.signedness; | |
| 4662 | const signedness = @typeInfo(PackedType).int.signedness; | |
| 4663 | 4663 | const NextPowerOfTwoInt = std.meta.Int(signedness, try comptime std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType))); |
| 4664 | 4664 | const ui64 = std.meta.Int(signedness, 64); |
| 4665 | 4665 | inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| { |
lib/std/mem/Allocator.zig+10-10| ... | ... | @@ -109,7 +109,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T { |
| 109 | 109 | /// `ptr` should be the return value of `create`, or otherwise |
| 110 | 110 | /// have the same address and alignment property. |
| 111 | 111 | pub fn destroy(self: Allocator, ptr: anytype) void { |
| 112 | const info = @typeInfo(@TypeOf(ptr)).Pointer; | |
| 112 | const info = @typeInfo(@TypeOf(ptr)).pointer; | |
| 113 | 113 | if (info.size != .One) @compileError("ptr must be a single item pointer"); |
| 114 | 114 | const T = info.child; |
| 115 | 115 | if (@sizeOf(T) == 0) return; |
| ... | ... | @@ -232,7 +232,7 @@ fn allocBytesWithAlignment(self: Allocator, comptime alignment: u29, byte_count: |
| 232 | 232 | /// the pointer, however the allocator implementation may refuse the resize |
| 233 | 233 | /// request by returning `false`. |
| 234 | 234 | pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool { |
| 235 | const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; | |
| 235 | const Slice = @typeInfo(@TypeOf(old_mem)).pointer; | |
| 236 | 236 | const T = Slice.child; |
| 237 | 237 | if (new_n == 0) { |
| 238 | 238 | self.free(old_mem); |
| ... | ... | @@ -253,7 +253,7 @@ pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool { |
| 253 | 253 | /// can be larger, smaller, or the same size as the old memory allocation. |
| 254 | 254 | /// If `new_n` is 0, this is the same as `free` and it always succeeds. |
| 255 | 255 | pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) t: { |
| 256 | const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; | |
| 256 | const Slice = @typeInfo(@TypeOf(old_mem)).pointer; | |
| 257 | 257 | break :t Error![]align(Slice.alignment) Slice.child; |
| 258 | 258 | } { |
| 259 | 259 | return self.reallocAdvanced(old_mem, new_n, @returnAddress()); |
| ... | ... | @@ -265,10 +265,10 @@ pub fn reallocAdvanced( |
| 265 | 265 | new_n: usize, |
| 266 | 266 | return_address: usize, |
| 267 | 267 | ) t: { |
| 268 | const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; | |
| 268 | const Slice = @typeInfo(@TypeOf(old_mem)).pointer; | |
| 269 | 269 | break :t Error![]align(Slice.alignment) Slice.child; |
| 270 | 270 | } { |
| 271 | const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; | |
| 271 | const Slice = @typeInfo(@TypeOf(old_mem)).pointer; | |
| 272 | 272 | const T = Slice.child; |
| 273 | 273 | if (old_mem.len == 0) { |
| 274 | 274 | return self.allocAdvancedWithRetAddr(T, Slice.alignment, new_n, return_address); |
| ... | ... | @@ -304,7 +304,7 @@ pub fn reallocAdvanced( |
| 304 | 304 | /// Free an array allocated with `alloc`. To free a single item, |
| 305 | 305 | /// see `destroy`. |
| 306 | 306 | pub fn free(self: Allocator, memory: anytype) void { |
| 307 | const Slice = @typeInfo(@TypeOf(memory)).Pointer; | |
| 307 | const Slice = @typeInfo(@TypeOf(memory)).pointer; | |
| 308 | 308 | const bytes = mem.sliceAsBytes(memory); |
| 309 | 309 | const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; |
| 310 | 310 | if (bytes_len == 0) return; |
| ... | ... | @@ -332,13 +332,13 @@ pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T { |
| 332 | 332 | /// TODO replace callsites with `@log2` after this proposal is implemented: |
| 333 | 333 | /// https://github.com/ziglang/zig/issues/13642 |
| 334 | 334 | inline fn log2a(x: anytype) switch (@typeInfo(@TypeOf(x))) { |
| 335 | .Int => math.Log2Int(@TypeOf(x)), | |
| 336 | .ComptimeInt => comptime_int, | |
| 335 | .int => math.Log2Int(@TypeOf(x)), | |
| 336 | .comptime_int => comptime_int, | |
| 337 | 337 | else => @compileError("int please"), |
| 338 | 338 | } { |
| 339 | 339 | switch (@typeInfo(@TypeOf(x))) { |
| 340 | .Int => return math.log2_int(@TypeOf(x), x), | |
| 341 | .ComptimeInt => return math.log2(x), | |
| 340 | .int => return math.log2_int(@TypeOf(x), x), | |
| 341 | .comptime_int => return math.log2(x), | |
| 342 | 342 | else => @compileError("bad"), |
| 343 | 343 | } |
| 344 | 344 | } |
lib/std/meta.zig+95-95| ... | ... | @@ -21,11 +21,11 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T { |
| 21 | 21 | // TODO The '100' here is arbitrary and should be increased when possible: |
| 22 | 22 | // - https://github.com/ziglang/zig/issues/4055 |
| 23 | 23 | // - https://github.com/ziglang/zig/issues/3863 |
| 24 | if (@typeInfo(T).Enum.fields.len <= 100) { | |
| 24 | if (@typeInfo(T).@"enum".fields.len <= 100) { | |
| 25 | 25 | const kvs = comptime build_kvs: { |
| 26 | 26 | const EnumKV = struct { []const u8, T }; |
| 27 | var kvs_array: [@typeInfo(T).Enum.fields.len]EnumKV = undefined; | |
| 28 | for (@typeInfo(T).Enum.fields, 0..) |enumField, i| { | |
| 27 | var kvs_array: [@typeInfo(T).@"enum".fields.len]EnumKV = undefined; | |
| 28 | for (@typeInfo(T).@"enum".fields, 0..) |enumField, i| { | |
| 29 | 29 | kvs_array[i] = .{ enumField.name, @field(T, enumField.name) }; |
| 30 | 30 | } |
| 31 | 31 | break :build_kvs kvs_array[0..]; |
| ... | ... | @@ -33,7 +33,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T { |
| 33 | 33 | const map = std.StaticStringMap(T).initComptime(kvs); |
| 34 | 34 | return map.get(str); |
| 35 | 35 | } else { |
| 36 | inline for (@typeInfo(T).Enum.fields) |enumField| { | |
| 36 | inline for (@typeInfo(T).@"enum".fields) |enumField| { | |
| 37 | 37 | if (mem.eql(u8, str, enumField.name)) { |
| 38 | 38 | return @field(T, enumField.name); |
| 39 | 39 | } |
| ... | ... | @@ -58,11 +58,11 @@ test stringToEnum { |
| 58 | 58 | /// If T is a pointer type the alignment of the type it points to is returned. |
| 59 | 59 | pub fn alignment(comptime T: type) comptime_int { |
| 60 | 60 | return switch (@typeInfo(T)) { |
| 61 | .Optional => |info| switch (@typeInfo(info.child)) { | |
| 62 | .Pointer, .Fn => alignment(info.child), | |
| 61 | .optional => |info| switch (@typeInfo(info.child)) { | |
| 62 | .pointer, .@"fn" => alignment(info.child), | |
| 63 | 63 | else => @alignOf(T), |
| 64 | 64 | }, |
| 65 | .Pointer => |info| info.alignment, | |
| 65 | .pointer => |info| info.alignment, | |
| 66 | 66 | else => @alignOf(T), |
| 67 | 67 | }; |
| 68 | 68 | } |
| ... | ... | @@ -81,10 +81,10 @@ test alignment { |
| 81 | 81 | /// Given a parameterized type (array, vector, pointer, optional), returns the "child type". |
| 82 | 82 | pub fn Child(comptime T: type) type { |
| 83 | 83 | return switch (@typeInfo(T)) { |
| 84 | .Array => |info| info.child, | |
| 85 | .Vector => |info| info.child, | |
| 86 | .Pointer => |info| info.child, | |
| 87 | .Optional => |info| info.child, | |
| 84 | .array => |info| info.child, | |
| 85 | .vector => |info| info.child, | |
| 86 | .pointer => |info| info.child, | |
| 87 | .optional => |info| info.child, | |
| 88 | 88 | else => @compileError("Expected pointer, optional, array or vector type, found '" ++ @typeName(T) ++ "'"), |
| 89 | 89 | }; |
| 90 | 90 | } |
| ... | ... | @@ -100,17 +100,17 @@ test Child { |
| 100 | 100 | /// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type". |
| 101 | 101 | pub fn Elem(comptime T: type) type { |
| 102 | 102 | switch (@typeInfo(T)) { |
| 103 | .Array => |info| return info.child, | |
| 104 | .Vector => |info| return info.child, | |
| 105 | .Pointer => |info| switch (info.size) { | |
| 103 | .array => |info| return info.child, | |
| 104 | .vector => |info| return info.child, | |
| 105 | .pointer => |info| switch (info.size) { | |
| 106 | 106 | .One => switch (@typeInfo(info.child)) { |
| 107 | .Array => |array_info| return array_info.child, | |
| 108 | .Vector => |vector_info| return vector_info.child, | |
| 107 | .array => |array_info| return array_info.child, | |
| 108 | .vector => |vector_info| return vector_info.child, | |
| 109 | 109 | else => {}, |
| 110 | 110 | }, |
| 111 | 111 | .Many, .C, .Slice => return info.child, |
| 112 | 112 | }, |
| 113 | .Optional => |info| return Elem(info.child), | |
| 113 | .optional => |info| return Elem(info.child), | |
| 114 | 114 | else => {}, |
| 115 | 115 | } |
| 116 | 116 | @compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'"); |
| ... | ... | @@ -132,18 +132,18 @@ test Elem { |
| 132 | 132 | /// Result is always comptime-known. |
| 133 | 133 | pub inline fn sentinel(comptime T: type) ?Elem(T) { |
| 134 | 134 | switch (@typeInfo(T)) { |
| 135 | .Array => |info| { | |
| 135 | .array => |info| { | |
| 136 | 136 | const sentinel_ptr = info.sentinel orelse return null; |
| 137 | 137 | return @as(*const info.child, @ptrCast(sentinel_ptr)).*; |
| 138 | 138 | }, |
| 139 | .Pointer => |info| { | |
| 139 | .pointer => |info| { | |
| 140 | 140 | switch (info.size) { |
| 141 | 141 | .Many, .Slice => { |
| 142 | 142 | const sentinel_ptr = info.sentinel orelse return null; |
| 143 | 143 | return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; |
| 144 | 144 | }, |
| 145 | 145 | .One => switch (@typeInfo(info.child)) { |
| 146 | .Array => |array_info| { | |
| 146 | .array => |array_info| { | |
| 147 | 147 | const sentinel_ptr = array_info.sentinel orelse return null; |
| 148 | 148 | return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; |
| 149 | 149 | }, |
| ... | ... | @@ -177,17 +177,17 @@ fn testSentinel() !void { |
| 177 | 177 | /// Given a "memory span" type, returns the same type except with the given sentinel value. |
| 178 | 178 | pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { |
| 179 | 179 | switch (@typeInfo(T)) { |
| 180 | .Pointer => |info| switch (info.size) { | |
| 180 | .pointer => |info| switch (info.size) { | |
| 181 | 181 | .One => switch (@typeInfo(info.child)) { |
| 182 | .Array => |array_info| return @Type(.{ | |
| 183 | .Pointer = .{ | |
| 182 | .array => |array_info| return @Type(.{ | |
| 183 | .pointer = .{ | |
| 184 | 184 | .size = info.size, |
| 185 | 185 | .is_const = info.is_const, |
| 186 | 186 | .is_volatile = info.is_volatile, |
| 187 | 187 | .alignment = info.alignment, |
| 188 | 188 | .address_space = info.address_space, |
| 189 | 189 | .child = @Type(.{ |
| 190 | .Array = .{ | |
| 190 | .array = .{ | |
| 191 | 191 | .len = array_info.len, |
| 192 | 192 | .child = array_info.child, |
| 193 | 193 | .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)), |
| ... | ... | @@ -200,7 +200,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { |
| 200 | 200 | else => {}, |
| 201 | 201 | }, |
| 202 | 202 | .Many, .Slice => return @Type(.{ |
| 203 | .Pointer = .{ | |
| 203 | .pointer = .{ | |
| 204 | 204 | .size = info.size, |
| 205 | 205 | .is_const = info.is_const, |
| 206 | 206 | .is_volatile = info.is_volatile, |
| ... | ... | @@ -213,12 +213,12 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { |
| 213 | 213 | }), |
| 214 | 214 | else => {}, |
| 215 | 215 | }, |
| 216 | .Optional => |info| switch (@typeInfo(info.child)) { | |
| 217 | .Pointer => |ptr_info| switch (ptr_info.size) { | |
| 216 | .optional => |info| switch (@typeInfo(info.child)) { | |
| 217 | .pointer => |ptr_info| switch (ptr_info.size) { | |
| 218 | 218 | .Many => return @Type(.{ |
| 219 | .Optional = .{ | |
| 219 | .optional = .{ | |
| 220 | 220 | .child = @Type(.{ |
| 221 | .Pointer = .{ | |
| 221 | .pointer = .{ | |
| 222 | 222 | .size = ptr_info.size, |
| 223 | 223 | .is_const = ptr_info.is_const, |
| 224 | 224 | .is_volatile = ptr_info.is_volatile, |
| ... | ... | @@ -244,8 +244,8 @@ pub const assumeSentinel = @compileError("This function has been removed, consid |
| 244 | 244 | |
| 245 | 245 | pub fn containerLayout(comptime T: type) Type.ContainerLayout { |
| 246 | 246 | return switch (@typeInfo(T)) { |
| 247 | .Struct => |info| info.layout, | |
| 248 | .Union => |info| info.layout, | |
| 247 | .@"struct" => |info| info.layout, | |
| 248 | .@"union" => |info| info.layout, | |
| 249 | 249 | else => @compileError("expected struct or union type, found '" ++ @typeName(T) ++ "'"), |
| 250 | 250 | }; |
| 251 | 251 | } |
| ... | ... | @@ -276,10 +276,10 @@ test containerLayout { |
| 276 | 276 | /// directly when you know what kind of type it is. |
| 277 | 277 | pub fn declarations(comptime T: type) []const Type.Declaration { |
| 278 | 278 | return switch (@typeInfo(T)) { |
| 279 | .Struct => |info| info.decls, | |
| 280 | .Enum => |info| info.decls, | |
| 281 | .Union => |info| info.decls, | |
| 282 | .Opaque => |info| info.decls, | |
| 279 | .@"struct" => |info| info.decls, | |
| 280 | .@"enum" => |info| info.decls, | |
| 281 | .@"union" => |info| info.decls, | |
| 282 | .@"opaque" => |info| info.decls, | |
| 283 | 283 | else => @compileError("Expected struct, enum, union, or opaque type, found '" ++ @typeName(T) ++ "'"), |
| 284 | 284 | }; |
| 285 | 285 | } |
| ... | ... | @@ -350,17 +350,17 @@ test declarationInfo { |
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | pub fn fields(comptime T: type) switch (@typeInfo(T)) { |
| 353 | .Struct => []const Type.StructField, | |
| 354 | .Union => []const Type.UnionField, | |
| 355 | .ErrorSet => []const Type.Error, | |
| 356 | .Enum => []const Type.EnumField, | |
| 353 | .@"struct" => []const Type.StructField, | |
| 354 | .@"union" => []const Type.UnionField, | |
| 355 | .@"enum" => []const Type.EnumField, | |
| 356 | .error_set => []const Type.Error, | |
| 357 | 357 | else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), |
| 358 | 358 | } { |
| 359 | 359 | return switch (@typeInfo(T)) { |
| 360 | .Struct => |info| info.fields, | |
| 361 | .Union => |info| info.fields, | |
| 362 | .Enum => |info| info.fields, | |
| 363 | .ErrorSet => |errors| errors.?, // must be non global error set | |
| 360 | .@"struct" => |info| info.fields, | |
| 361 | .@"union" => |info| info.fields, | |
| 362 | .@"enum" => |info| info.fields, | |
| 363 | .error_set => |errors| errors.?, // must be non global error set | |
| 364 | 364 | else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), |
| 365 | 365 | }; |
| 366 | 366 | } |
| ... | ... | @@ -395,10 +395,10 @@ test fields { |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { |
| 398 | .Struct => Type.StructField, | |
| 399 | .Union => Type.UnionField, | |
| 400 | .ErrorSet => Type.Error, | |
| 401 | .Enum => Type.EnumField, | |
| 398 | .@"struct" => Type.StructField, | |
| 399 | .@"union" => Type.UnionField, | |
| 400 | .@"enum" => Type.EnumField, | |
| 401 | .error_set => Type.Error, | |
| 402 | 402 | else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), |
| 403 | 403 | } { |
| 404 | 404 | return fields(T)[@intFromEnum(field)]; |
| ... | ... | @@ -430,7 +430,7 @@ test fieldInfo { |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type { |
| 433 | if (@typeInfo(T) != .Struct and @typeInfo(T) != .Union) { | |
| 433 | if (@typeInfo(T) != .@"struct" and @typeInfo(T) != .@"union") { | |
| 434 | 434 | @compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'"); |
| 435 | 435 | } |
| 436 | 436 | |
| ... | ... | @@ -528,7 +528,7 @@ pub fn FieldEnum(comptime T: type) type { |
| 528 | 528 | |
| 529 | 529 | if (field_infos.len == 0) { |
| 530 | 530 | return @Type(.{ |
| 531 | .Enum = .{ | |
| 531 | .@"enum" = .{ | |
| 532 | 532 | .tag_type = u0, |
| 533 | 533 | .fields = &.{}, |
| 534 | 534 | .decls = &.{}, |
| ... | ... | @@ -537,8 +537,8 @@ pub fn FieldEnum(comptime T: type) type { |
| 537 | 537 | }); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | if (@typeInfo(T) == .Union) { | |
| 541 | if (@typeInfo(T).Union.tag_type) |tag_type| { | |
| 540 | if (@typeInfo(T) == .@"union") { | |
| 541 | if (@typeInfo(T).@"union".tag_type) |tag_type| { | |
| 542 | 542 | for (std.enums.values(tag_type), 0..) |v, i| { |
| 543 | 543 | if (@intFromEnum(v) != i) break; // enum values not consecutive |
| 544 | 544 | if (!std.mem.eql(u8, @tagName(v), field_infos[i].name)) break; // fields out of order |
| ... | ... | @@ -557,7 +557,7 @@ pub fn FieldEnum(comptime T: type) type { |
| 557 | 557 | }; |
| 558 | 558 | } |
| 559 | 559 | return @Type(.{ |
| 560 | .Enum = .{ | |
| 560 | .@"enum" = .{ | |
| 561 | 561 | .tag_type = std.math.IntFittingRange(0, field_infos.len - 1), |
| 562 | 562 | .fields = &enumFields, |
| 563 | 563 | .decls = &decls, |
| ... | ... | @@ -568,17 +568,17 @@ pub fn FieldEnum(comptime T: type) type { |
| 568 | 568 | |
| 569 | 569 | fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { |
| 570 | 570 | // TODO: https://github.com/ziglang/zig/issues/7419 |
| 571 | // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum); | |
| 571 | // testing.expectEqual(@typeInfo(expected).@"enum", @typeInfo(actual).@"enum"); | |
| 572 | 572 | try testing.expectEqual( |
| 573 | @typeInfo(expected).Enum.tag_type, | |
| 574 | @typeInfo(actual).Enum.tag_type, | |
| 573 | @typeInfo(expected).@"enum".tag_type, | |
| 574 | @typeInfo(actual).@"enum".tag_type, | |
| 575 | 575 | ); |
| 576 | 576 | // For comparing decls and fields, we cannot use the meta eql function here |
| 577 | 577 | // because the language does not guarantee that the slice pointers for field names |
| 578 | 578 | // and decl names will be the same. |
| 579 | 579 | comptime { |
| 580 | const expected_fields = @typeInfo(expected).Enum.fields; | |
| 581 | const actual_fields = @typeInfo(actual).Enum.fields; | |
| 580 | const expected_fields = @typeInfo(expected).@"enum".fields; | |
| 581 | const actual_fields = @typeInfo(actual).@"enum".fields; | |
| 582 | 582 | if (expected_fields.len != actual_fields.len) return error.FailedTest; |
| 583 | 583 | for (expected_fields, 0..) |expected_field, i| { |
| 584 | 584 | const actual_field = actual_fields[i]; |
| ... | ... | @@ -587,8 +587,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | comptime { |
| 590 | const expected_decls = @typeInfo(expected).Enum.decls; | |
| 591 | const actual_decls = @typeInfo(actual).Enum.decls; | |
| 590 | const expected_decls = @typeInfo(expected).@"enum".decls; | |
| 591 | const actual_decls = @typeInfo(actual).@"enum".decls; | |
| 592 | 592 | if (expected_decls.len != actual_decls.len) return error.FailedTest; |
| 593 | 593 | for (expected_decls, 0..) |expected_decl, i| { |
| 594 | 594 | const actual_decl = actual_decls[i]; |
| ... | ... | @@ -596,8 +596,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { |
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | try testing.expectEqual( |
| 599 | @typeInfo(expected).Enum.is_exhaustive, | |
| 600 | @typeInfo(actual).Enum.is_exhaustive, | |
| 599 | @typeInfo(expected).@"enum".is_exhaustive, | |
| 600 | @typeInfo(actual).@"enum".is_exhaustive, | |
| 601 | 601 | ); |
| 602 | 602 | } |
| 603 | 603 | |
| ... | ... | @@ -627,7 +627,7 @@ pub fn DeclEnum(comptime T: type) type { |
| 627 | 627 | enumDecls[i] = .{ .name = field.name ++ "", .value = i }; |
| 628 | 628 | } |
| 629 | 629 | return @Type(.{ |
| 630 | .Enum = .{ | |
| 630 | .@"enum" = .{ | |
| 631 | 631 | .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1), |
| 632 | 632 | .fields = &enumDecls, |
| 633 | 633 | .decls = &decls, |
| ... | ... | @@ -661,8 +661,8 @@ test DeclEnum { |
| 661 | 661 | |
| 662 | 662 | pub fn Tag(comptime T: type) type { |
| 663 | 663 | return switch (@typeInfo(T)) { |
| 664 | .Enum => |info| info.tag_type, | |
| 665 | .Union => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"), | |
| 664 | .@"enum" => |info| info.tag_type, | |
| 665 | .@"union" => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"), | |
| 666 | 666 | else => @compileError("expected enum or union type, found '" ++ @typeName(T) ++ "'"), |
| 667 | 667 | }; |
| 668 | 668 | } |
| ... | ... | @@ -708,7 +708,7 @@ test activeTag { |
| 708 | 708 | const TagPayloadType = TagPayload; |
| 709 | 709 | |
| 710 | 710 | pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type { |
| 711 | const info = @typeInfo(U).Union; | |
| 711 | const info = @typeInfo(U).@"union"; | |
| 712 | 712 | |
| 713 | 713 | inline for (info.fields) |field_info| { |
| 714 | 714 | if (comptime mem.eql(u8, field_info.name, tag_name)) |
| ... | ... | @@ -742,20 +742,20 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { |
| 742 | 742 | const T = @TypeOf(a); |
| 743 | 743 | |
| 744 | 744 | switch (@typeInfo(T)) { |
| 745 | .Struct => |info| { | |
| 745 | .@"struct" => |info| { | |
| 746 | 746 | inline for (info.fields) |field_info| { |
| 747 | 747 | if (!eql(@field(a, field_info.name), @field(b, field_info.name))) return false; |
| 748 | 748 | } |
| 749 | 749 | return true; |
| 750 | 750 | }, |
| 751 | .ErrorUnion => { | |
| 751 | .error_union => { | |
| 752 | 752 | if (a) |a_p| { |
| 753 | 753 | if (b) |b_p| return eql(a_p, b_p) else |_| return false; |
| 754 | 754 | } else |a_e| { |
| 755 | 755 | if (b) |_| return false else |b_e| return a_e == b_e; |
| 756 | 756 | } |
| 757 | 757 | }, |
| 758 | .Union => |info| { | |
| 758 | .@"union" => |info| { | |
| 759 | 759 | if (info.tag_type) |UnionTag| { |
| 760 | 760 | const tag_a: UnionTag = a; |
| 761 | 761 | const tag_b: UnionTag = b; |
| ... | ... | @@ -768,26 +768,26 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { |
| 768 | 768 | |
| 769 | 769 | @compileError("cannot compare untagged union type " ++ @typeName(T)); |
| 770 | 770 | }, |
| 771 | .Array => { | |
| 771 | .array => { | |
| 772 | 772 | if (a.len != b.len) return false; |
| 773 | 773 | for (a, 0..) |e, i| |
| 774 | 774 | if (!eql(e, b[i])) return false; |
| 775 | 775 | return true; |
| 776 | 776 | }, |
| 777 | .Vector => |info| { | |
| 777 | .vector => |info| { | |
| 778 | 778 | var i: usize = 0; |
| 779 | 779 | while (i < info.len) : (i += 1) { |
| 780 | 780 | if (!eql(a[i], b[i])) return false; |
| 781 | 781 | } |
| 782 | 782 | return true; |
| 783 | 783 | }, |
| 784 | .Pointer => |info| { | |
| 784 | .pointer => |info| { | |
| 785 | 785 | return switch (info.size) { |
| 786 | 786 | .One, .Many, .C => a == b, |
| 787 | 787 | .Slice => a.ptr == b.ptr and a.len == b.len, |
| 788 | 788 | }; |
| 789 | 789 | }, |
| 790 | .Optional => { | |
| 790 | .optional => { | |
| 791 | 791 | if (a == null and b == null) return true; |
| 792 | 792 | if (a == null or b == null) return false; |
| 793 | 793 | return eql(a.?, b.?); |
| ... | ... | @@ -893,7 +893,7 @@ test intToEnum { |
| 893 | 893 | pub const IntToEnumError = error{InvalidEnumTag}; |
| 894 | 894 | |
| 895 | 895 | pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag { |
| 896 | const enum_info = @typeInfo(EnumTag).Enum; | |
| 896 | const enum_info = @typeInfo(EnumTag).@"enum"; | |
| 897 | 897 | |
| 898 | 898 | if (!enum_info.is_exhaustive) { |
| 899 | 899 | if (std.math.cast(enum_info.tag_type, tag_int)) |tag| { |
| ... | ... | @@ -955,7 +955,7 @@ pub const IntType = @compileError("replaced by std.meta.Int"); |
| 955 | 955 | |
| 956 | 956 | pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type { |
| 957 | 957 | return @Type(.{ |
| 958 | .Int = .{ | |
| 958 | .int = .{ | |
| 959 | 959 | .signedness = signedness, |
| 960 | 960 | .bits = bit_count, |
| 961 | 961 | }, |
| ... | ... | @@ -964,7 +964,7 @@ pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) |
| 964 | 964 | |
| 965 | 965 | pub fn Float(comptime bit_count: u8) type { |
| 966 | 966 | return @Type(.{ |
| 967 | .Float = .{ .bits = bit_count }, | |
| 967 | .float = .{ .bits = bit_count }, | |
| 968 | 968 | }); |
| 969 | 969 | } |
| 970 | 970 | |
| ... | ... | @@ -984,10 +984,10 @@ test Float { |
| 984 | 984 | /// - `ArgsTuple(fn (a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }` |
| 985 | 985 | pub fn ArgsTuple(comptime Function: type) type { |
| 986 | 986 | const info = @typeInfo(Function); |
| 987 | if (info != .Fn) | |
| 987 | if (info != .@"fn") | |
| 988 | 988 | @compileError("ArgsTuple expects a function type"); |
| 989 | 989 | |
| 990 | const function_info = info.Fn; | |
| 990 | const function_info = info.@"fn"; | |
| 991 | 991 | if (function_info.is_var_args) |
| 992 | 992 | @compileError("Cannot create ArgsTuple for variadic function"); |
| 993 | 993 | |
| ... | ... | @@ -1026,7 +1026,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | return @Type(.{ |
| 1029 | .Struct = .{ | |
| 1029 | .@"struct" = .{ | |
| 1030 | 1030 | .is_tuple = true, |
| 1031 | 1031 | .layout = .auto, |
| 1032 | 1032 | .decls = &.{}, |
| ... | ... | @@ -1043,9 +1043,9 @@ const TupleTester = struct { |
| 1043 | 1043 | |
| 1044 | 1044 | fn assertTuple(comptime expected: anytype, comptime Actual: type) void { |
| 1045 | 1045 | const info = @typeInfo(Actual); |
| 1046 | if (info != .Struct) | |
| 1046 | if (info != .@"struct") | |
| 1047 | 1047 | @compileError("Expected struct type"); |
| 1048 | if (!info.Struct.is_tuple) | |
| 1048 | if (!info.@"struct".is_tuple) | |
| 1049 | 1049 | @compileError("Struct type must be a tuple type"); |
| 1050 | 1050 | |
| 1051 | 1051 | const fields_list = std.meta.fields(Actual); |
| ... | ... | @@ -1115,13 +1115,13 @@ test isError { |
| 1115 | 1115 | /// `false` otherwise. Result is always comptime-known. |
| 1116 | 1116 | pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool { |
| 1117 | 1117 | switch (@typeInfo(T)) { |
| 1118 | .Struct, .Union, .Enum, .Opaque => {}, | |
| 1118 | .@"struct", .@"union", .@"enum", .@"opaque" => {}, | |
| 1119 | 1119 | else => return false, |
| 1120 | 1120 | } |
| 1121 | 1121 | if (!@hasDecl(T, name)) |
| 1122 | 1122 | return false; |
| 1123 | 1123 | |
| 1124 | return @typeInfo(@TypeOf(@field(T, name))) == .Fn; | |
| 1124 | return @typeInfo(@TypeOf(@field(T, name))) == .@"fn"; | |
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | test hasFn { |
| ... | ... | @@ -1144,7 +1144,7 @@ test hasFn { |
| 1144 | 1144 | /// Result is always comptime-known. |
| 1145 | 1145 | pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { |
| 1146 | 1146 | return switch (@typeInfo(T)) { |
| 1147 | .Pointer => |P| switch (P.size) { | |
| 1147 | .pointer => |P| switch (P.size) { | |
| 1148 | 1148 | .One => hasFn(P.child, name), |
| 1149 | 1149 | .Many, .Slice, .C => false, |
| 1150 | 1150 | }, |
| ... | ... | @@ -1191,29 +1191,29 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { |
| 1191 | 1191 | return switch (@typeInfo(T)) { |
| 1192 | 1192 | else => false, // TODO can we know if it's true for some of these types ? |
| 1193 | 1193 | |
| 1194 | .AnyFrame, | |
| 1195 | .Enum, | |
| 1196 | .ErrorSet, | |
| 1197 | .Fn, | |
| 1194 | .@"anyframe", | |
| 1195 | .@"enum", | |
| 1196 | .error_set, | |
| 1197 | .@"fn", | |
| 1198 | 1198 | => true, |
| 1199 | 1199 | |
| 1200 | .Bool => false, | |
| 1200 | .bool => false, | |
| 1201 | 1201 | |
| 1202 | .Int => |info| @sizeOf(T) * 8 == info.bits, | |
| 1202 | .int => |info| @sizeOf(T) * 8 == info.bits, | |
| 1203 | 1203 | |
| 1204 | .Pointer => |info| info.size != .Slice, | |
| 1204 | .pointer => |info| info.size != .Slice, | |
| 1205 | 1205 | |
| 1206 | .Optional => |info| switch (@typeInfo(info.child)) { | |
| 1207 | .Pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) { | |
| 1206 | .optional => |info| switch (@typeInfo(info.child)) { | |
| 1207 | .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) { | |
| 1208 | 1208 | .Slice, .C => false, |
| 1209 | 1209 | .One, .Many => true, |
| 1210 | 1210 | }, |
| 1211 | 1211 | else => false, |
| 1212 | 1212 | }, |
| 1213 | 1213 | |
| 1214 | .Array => |info| hasUniqueRepresentation(info.child), | |
| 1214 | .array => |info| hasUniqueRepresentation(info.child), | |
| 1215 | 1215 | |
| 1216 | .Struct => |info| { | |
| 1216 | .@"struct" => |info| { | |
| 1217 | 1217 | if (info.layout == .@"packed") return @sizeOf(T) * 8 == @bitSizeOf(T); |
| 1218 | 1218 | |
| 1219 | 1219 | var sum_size = @as(usize, 0); |
| ... | ... | @@ -1226,7 +1226,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { |
| 1226 | 1226 | return @sizeOf(T) == sum_size; |
| 1227 | 1227 | }, |
| 1228 | 1228 | |
| 1229 | .Vector => |info| hasUniqueRepresentation(info.child) and | |
| 1229 | .vector => |info| hasUniqueRepresentation(info.child) and | |
| 1230 | 1230 | @sizeOf(T) == @sizeOf(info.child) * info.len, |
| 1231 | 1231 | }; |
| 1232 | 1232 | } |
lib/std/meta/trailer_flags.zig+8-8| ... | ... | @@ -14,14 +14,14 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 14 | 14 | bits: Int, |
| 15 | 15 | |
| 16 | 16 | pub const Int = meta.Int(.unsigned, bit_count); |
| 17 | pub const bit_count = @typeInfo(Fields).Struct.fields.len; | |
| 17 | pub const bit_count = @typeInfo(Fields).@"struct".fields.len; | |
| 18 | 18 | |
| 19 | 19 | pub const FieldEnum = std.meta.FieldEnum(Fields); |
| 20 | 20 | |
| 21 | 21 | pub const ActiveFields = std.enums.EnumFieldStruct(FieldEnum, bool, false); |
| 22 | 22 | pub const FieldValues = blk: { |
| 23 | 23 | var fields: [bit_count]Type.StructField = undefined; |
| 24 | for (@typeInfo(Fields).Struct.fields, 0..) |struct_field, i| { | |
| 24 | for (@typeInfo(Fields).@"struct".fields, 0..) |struct_field, i| { | |
| 25 | 25 | fields[i] = Type.StructField{ |
| 26 | 26 | .name = struct_field.name, |
| 27 | 27 | .type = ?struct_field.type, |
| ... | ... | @@ -31,7 +31,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 31 | 31 | }; |
| 32 | 32 | } |
| 33 | 33 | break :blk @Type(.{ |
| 34 | .Struct = .{ | |
| 34 | .@"struct" = .{ | |
| 35 | 35 | .layout = .auto, |
| 36 | 36 | .fields = &fields, |
| 37 | 37 | .decls = &.{}, |
| ... | ... | @@ -61,7 +61,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 61 | 61 | /// `fields` is a boolean struct where each active field is set to `true` |
| 62 | 62 | pub fn init(fields: ActiveFields) Self { |
| 63 | 63 | var self: Self = .{ .bits = 0 }; |
| 64 | inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { | |
| 64 | inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| { | |
| 65 | 65 | if (@field(fields, field.name)) |
| 66 | 66 | self.bits |= 1 << i; |
| 67 | 67 | } |
| ... | ... | @@ -70,7 +70,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 70 | 70 | |
| 71 | 71 | /// `fields` is a struct with each field set to an optional value |
| 72 | 72 | pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void { |
| 73 | inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { | |
| 73 | inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| { | |
| 74 | 74 | if (@field(fields, field.name)) |value| |
| 75 | 75 | self.set(p, @as(FieldEnum, @enumFromInt(i)), value); |
| 76 | 76 | } |
| ... | ... | @@ -101,7 +101,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 101 | 101 | |
| 102 | 102 | pub fn offset(self: Self, comptime field: FieldEnum) usize { |
| 103 | 103 | var off: usize = 0; |
| 104 | inline for (@typeInfo(Fields).Struct.fields, 0..) |field_info, i| { | |
| 104 | inline for (@typeInfo(Fields).@"struct".fields, 0..) |field_info, i| { | |
| 105 | 105 | const active = (self.bits & (1 << i)) != 0; |
| 106 | 106 | if (i == @intFromEnum(field)) { |
| 107 | 107 | assert(active); |
| ... | ... | @@ -114,12 +114,12 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | pub fn Field(comptime field: FieldEnum) type { |
| 117 | return @typeInfo(Fields).Struct.fields[@intFromEnum(field)].type; | |
| 117 | return @typeInfo(Fields).@"struct".fields[@intFromEnum(field)].type; | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | pub fn sizeInBytes(self: Self) usize { |
| 121 | 121 | var off: usize = 0; |
| 122 | inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { | |
| 122 | inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| { | |
| 123 | 123 | if (@sizeOf(field.type) == 0) |
| 124 | 124 | continue; |
| 125 | 125 | if ((self.bits & (1 << i)) != 0) { |
lib/std/multi_array_list.zig+10-11| ... | ... | @@ -24,10 +24,9 @@ pub fn MultiArrayList(comptime T: type) type { |
| 24 | 24 | capacity: usize = 0, |
| 25 | 25 | |
| 26 | 26 | const Elem = switch (@typeInfo(T)) { |
| 27 | .Struct => T, | |
| 28 | .Union => |u| struct { | |
| 29 | pub const Bare = | |
| 30 | @Type(.{ .Union = .{ | |
| 27 | .@"struct" => T, | |
| 28 | .@"union" => |u| struct { | |
| 29 | pub const Bare = @Type(.{ .@"union" = .{ | |
| 31 | 30 | .layout = u.layout, |
| 32 | 31 | .tag_type = null, |
| 33 | 32 | .fields = u.fields, |
| ... | ... | @@ -84,8 +83,8 @@ pub fn MultiArrayList(comptime T: type) type { |
| 84 | 83 | |
| 85 | 84 | pub fn set(self: *Slice, index: usize, elem: T) void { |
| 86 | 85 | const e = switch (@typeInfo(T)) { |
| 87 | .Struct => elem, | |
| 88 | .Union => Elem.fromT(elem), | |
| 86 | .@"struct" => elem, | |
| 87 | .@"union" => Elem.fromT(elem), | |
| 89 | 88 | else => unreachable, |
| 90 | 89 | }; |
| 91 | 90 | inline for (fields, 0..) |field_info, i| { |
| ... | ... | @@ -99,8 +98,8 @@ pub fn MultiArrayList(comptime T: type) type { |
| 99 | 98 | @field(result, field_info.name) = self.items(@as(Field, @enumFromInt(i)))[index]; |
| 100 | 99 | } |
| 101 | 100 | return switch (@typeInfo(T)) { |
| 102 | .Struct => result, | |
| 103 | .Union => Elem.toT(result.tags, result.data), | |
| 101 | .@"struct" => result, | |
| 102 | .@"union" => Elem.toT(result.tags, result.data), | |
| 104 | 103 | else => unreachable, |
| 105 | 104 | }; |
| 106 | 105 | } |
| ... | ... | @@ -287,8 +286,8 @@ pub fn MultiArrayList(comptime T: type) type { |
| 287 | 286 | assert(index <= self.len); |
| 288 | 287 | self.len += 1; |
| 289 | 288 | const entry = switch (@typeInfo(T)) { |
| 290 | .Struct => elem, | |
| 291 | .Union => Elem.fromT(elem), | |
| 289 | .@"struct" => elem, | |
| 290 | .@"union" => Elem.fromT(elem), | |
| 292 | 291 | else => unreachable, |
| 293 | 292 | }; |
| 294 | 293 | const slices = self.slice(); |
| ... | ... | @@ -557,7 +556,7 @@ pub fn MultiArrayList(comptime T: type) type { |
| 557 | 556 | .is_comptime = fields[i].is_comptime, |
| 558 | 557 | .alignment = fields[i].alignment, |
| 559 | 558 | }; |
| 560 | break :entry @Type(.{ .Struct = .{ | |
| 559 | break :entry @Type(.{ .@"struct" = .{ | |
| 561 | 560 | .layout = .@"extern", |
| 562 | 561 | .fields = &entry_fields, |
| 563 | 562 | .decls = &.{}, |
lib/std/os/emscripten.zig+1-1| ... | ... | @@ -560,7 +560,7 @@ pub const Sigaction = extern struct { |
| 560 | 560 | }; |
| 561 | 561 | |
| 562 | 562 | pub const sigset_t = [1024 / 32]u32; |
| 563 | pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len; | |
| 563 | pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).array.len; | |
| 564 | 564 | pub const siginfo_t = extern struct { |
| 565 | 565 | signo: i32, |
| 566 | 566 | errno: i32, |
lib/std/os/linux.zig+7-7| ... | ... | @@ -1547,7 +1547,7 @@ pub fn seteuid(euid: uid_t) usize { |
| 1547 | 1547 | // The setresuid(2) man page says that if -1 is passed the corresponding |
| 1548 | 1548 | // id will not be changed. Since uid_t is unsigned, this wraps around to the |
| 1549 | 1549 | // max value in C. |
| 1550 | comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned); | |
| 1550 | comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned); | |
| 1551 | 1551 | return setresuid(std.math.maxInt(uid_t), euid, std.math.maxInt(uid_t)); |
| 1552 | 1552 | } |
| 1553 | 1553 | |
| ... | ... | @@ -1558,7 +1558,7 @@ pub fn setegid(egid: gid_t) usize { |
| 1558 | 1558 | // The setresgid(2) man page says that if -1 is passed the corresponding |
| 1559 | 1559 | // id will not be changed. Since gid_t is unsigned, this wraps around to the |
| 1560 | 1560 | // max value in C. |
| 1561 | comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned); | |
| 1561 | comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned); | |
| 1562 | 1562 | return setresgid(std.math.maxInt(gid_t), egid, std.math.maxInt(gid_t)); |
| 1563 | 1563 | } |
| 1564 | 1564 | |
| ... | ... | @@ -1673,7 +1673,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact |
| 1673 | 1673 | return 0; |
| 1674 | 1674 | } |
| 1675 | 1675 | |
| 1676 | const usize_bits = @typeInfo(usize).Int.bits; | |
| 1676 | const usize_bits = @typeInfo(usize).int.bits; | |
| 1677 | 1677 | |
| 1678 | 1678 | pub fn sigaddset(set: *sigset_t, sig: u6) void { |
| 1679 | 1679 | const s = sig - 1; |
| ... | ... | @@ -1734,7 +1734,7 @@ pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize { |
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | 1736 | pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize { |
| 1737 | if (@typeInfo(usize).Int.bits > @typeInfo(@typeInfo(mmsghdr).Struct.fields[1].type).Int.bits) { | |
| 1737 | if (@typeInfo(usize).int.bits > @typeInfo(@typeInfo(mmsghdr).@"struct".fields[1].type).int.bits) { | |
| 1738 | 1738 | // workaround kernel brokenness: |
| 1739 | 1739 | // if adding up all iov_len overflows a i32 then split into multiple calls |
| 1740 | 1740 | // see https://www.openwall.com/lists/musl/2014/06/07/5 |
| ... | ... | @@ -4904,7 +4904,7 @@ pub const NSIG = if (is_mips) 128 else 65; |
| 4904 | 4904 | |
| 4905 | 4905 | pub const sigset_t = [1024 / 32]u32; |
| 4906 | 4906 | |
| 4907 | pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).Array.len; | |
| 4907 | pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.len; | |
| 4908 | 4908 | pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30; |
| 4909 | 4909 | |
| 4910 | 4910 | const k_sigaction_funcs = struct { |
| ... | ... | @@ -4947,7 +4947,7 @@ pub const Sigaction = extern struct { |
| 4947 | 4947 | restorer: ?*const fn () callconv(.C) void = null, |
| 4948 | 4948 | }; |
| 4949 | 4949 | |
| 4950 | const sigset_len = @typeInfo(sigset_t).Array.len; | |
| 4950 | const sigset_len = @typeInfo(sigset_t).array.len; | |
| 4951 | 4951 | pub const empty_sigset = [_]u32{0} ** sigset_len; |
| 4952 | 4952 | pub const filled_sigset = [_]u32{(1 << (31 & (usize_bits - 1))) - 1} ++ [_]u32{0} ** (sigset_len - 1); |
| 4953 | 4953 | |
| ... | ... | @@ -7420,7 +7420,7 @@ pub const MADV = struct { |
| 7420 | 7420 | }; |
| 7421 | 7421 | |
| 7422 | 7422 | pub const POSIX_FADV = switch (native_arch) { |
| 7423 | .s390x => if (@typeInfo(usize).Int.bits == 64) struct { | |
| 7423 | .s390x => if (@typeInfo(usize).int.bits == 64) struct { | |
| 7424 | 7424 | pub const NORMAL = 0; |
| 7425 | 7425 | pub const RANDOM = 1; |
| 7426 | 7426 | pub const SEQUENTIAL = 2; |
lib/std/os/linux/bpf.zig+1-1| ... | ... | @@ -459,7 +459,7 @@ pub const Insn = packed struct { |
| 459 | 459 | }; |
| 460 | 460 | |
| 461 | 461 | fn imm_reg(code: u8, dst: Reg, src: anytype, off: i16) Insn { |
| 462 | const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .EnumLiteral) | |
| 462 | const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .enum_literal) | |
| 463 | 463 | ImmOrReg{ .reg = @as(Reg, src) } |
| 464 | 464 | else |
| 465 | 465 | ImmOrReg{ .imm = src }; |
lib/std/os/uefi/protocol/device_path.zig+2-2| ... | ... | @@ -76,7 +76,7 @@ pub const DevicePath = extern struct { |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath { |
| 79 | inline for (@typeInfo(uefi.DevicePath).Union.fields) |ufield| { | |
| 79 | inline for (@typeInfo(uefi.DevicePath).@"union".fields) |ufield| { | |
| 80 | 80 | const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name); |
| 81 | 81 | |
| 82 | 82 | // Got the associated union type for self.type, now |
| ... | ... | @@ -94,7 +94,7 @@ pub const DevicePath = extern struct { |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | pub fn initSubtype(self: *const DevicePath, comptime TUnion: type) ?TUnion { |
| 97 | const type_info = @typeInfo(TUnion).Union; | |
| 97 | const type_info = @typeInfo(TUnion).@"union"; | |
| 98 | 98 | const TTag = type_info.tag_type.?; |
| 99 | 99 | |
| 100 | 100 | inline for (type_info.fields) |subtype| { |
lib/std/os/uefi/status.zig+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const testing = @import("std").testing; |
| 2 | 2 | |
| 3 | const high_bit = 1 << @typeInfo(usize).Int.bits - 1; | |
| 3 | const high_bit = 1 << @typeInfo(usize).int.bits - 1; | |
| 4 | 4 | |
| 5 | 5 | pub const Status = enum(usize) { |
| 6 | 6 | /// The operation completed successfully. |
| ... | ... | @@ -186,7 +186,7 @@ pub const Status = enum(usize) { |
| 186 | 186 | }; |
| 187 | 187 | |
| 188 | 188 | pub fn err(self: Status) EfiError!void { |
| 189 | inline for (@typeInfo(EfiError).ErrorSet.?) |efi_err| { | |
| 189 | inline for (@typeInfo(EfiError).error_set.?) |efi_err| { | |
| 190 | 190 | if (self == @field(Status, efi_err.name)) { |
| 191 | 191 | return @field(EfiError, efi_err.name); |
| 192 | 192 | } |
lib/std/posix.zig+2-2| ... | ... | @@ -6181,7 +6181,7 @@ pub fn sendfile( |
| 6181 | 6181 | var total_written: usize = 0; |
| 6182 | 6182 | |
| 6183 | 6183 | // Prevents EOVERFLOW. |
| 6184 | const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1); | |
| 6184 | const size_t = std.meta.Int(.unsigned, @typeInfo(usize).int.bits - 1); | |
| 6185 | 6185 | const max_count = switch (native_os) { |
| 6186 | 6186 | .linux => 0x7ffff000, |
| 6187 | 6187 | .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32), |
| ... | ... | @@ -6988,7 +6988,7 @@ pub const PrctlError = error{ |
| 6988 | 6988 | } || UnexpectedError; |
| 6989 | 6989 | |
| 6990 | 6990 | pub fn prctl(option: PR, args: anytype) PrctlError!u31 { |
| 6991 | if (@typeInfo(@TypeOf(args)) != .Struct) | |
| 6991 | if (@typeInfo(@TypeOf(args)) != .@"struct") | |
| 6992 | 6992 | @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args))); |
| 6993 | 6993 | if (args.len > 4) |
| 6994 | 6994 | @compileError("prctl takes a maximum of 4 optional arguments"); |
lib/std/posix/test.zig+1-1| ... | ... | @@ -782,7 +782,7 @@ test "fsync" { |
| 782 | 782 | test "getrlimit and setrlimit" { |
| 783 | 783 | if (posix.system.rlimit_resource == void) return error.SkipZigTest; |
| 784 | 784 | |
| 785 | inline for (@typeInfo(posix.rlimit_resource).Enum.fields) |field| { | |
| 785 | inline for (@typeInfo(posix.rlimit_resource).@"enum".fields) |field| { | |
| 786 | 786 | const resource: posix.rlimit_resource = @enumFromInt(field.value); |
| 787 | 787 | const limit = try posix.getrlimit(resource); |
| 788 | 788 |
lib/std/process/Child.zig+1-1| ... | ... | @@ -1112,7 +1112,7 @@ fn windowsCreateProcessPathExt( |
| 1112 | 1112 | } |
| 1113 | 1113 | var io_status: windows.IO_STATUS_BLOCK = undefined; |
| 1114 | 1114 | |
| 1115 | const num_supported_pathext = @typeInfo(WindowsExtension).Enum.fields.len; | |
| 1115 | const num_supported_pathext = @typeInfo(WindowsExtension).@"enum".fields.len; | |
| 1116 | 1116 | var pathext_seen = [_]bool{false} ** num_supported_pathext; |
| 1117 | 1117 | var any_pathext_seen = false; |
| 1118 | 1118 | var unappended_exists = false; |
lib/std/segmented_list.zig+1-1| ... | ... | @@ -99,7 +99,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type |
| 99 | 99 | pub const prealloc_count = prealloc_item_count; |
| 100 | 100 | |
| 101 | 101 | fn AtType(comptime SelfType: type) type { |
| 102 | if (@typeInfo(SelfType).Pointer.is_const) { | |
| 102 | if (@typeInfo(SelfType).pointer.is_const) { | |
| 103 | 103 | return *const T; |
| 104 | 104 | } else { |
| 105 | 105 | return *T; |
lib/std/simd.zig+7-7| ... | ... | @@ -105,8 +105,8 @@ test "suggestVectorLengthForCpu works with signed and unsigned values" { |
| 105 | 105 | |
| 106 | 106 | fn vectorLength(comptime VectorType: type) comptime_int { |
| 107 | 107 | return switch (@typeInfo(VectorType)) { |
| 108 | .Vector => |info| info.len, | |
| 109 | .Array => |info| info.len, | |
| 108 | .vector => |info| info.len, | |
| 109 | .array => |info| info.len, | |
| 110 | 110 | else => @compileError("Invalid type " ++ @typeName(VectorType)), |
| 111 | 111 | }; |
| 112 | 112 | } |
| ... | ... | @@ -128,8 +128,8 @@ pub inline fn iota(comptime T: type, comptime len: usize) @Vector(len, T) { |
| 128 | 128 | var out: [len]T = undefined; |
| 129 | 129 | for (&out, 0..) |*element, i| { |
| 130 | 130 | element.* = switch (@typeInfo(T)) { |
| 131 | .Int => @as(T, @intCast(i)), | |
| 132 | .Float => @as(T, @floatFromInt(i)), | |
| 131 | .int => @as(T, @intCast(i)), | |
| 132 | .float => @as(T, @floatFromInt(i)), | |
| 133 | 133 | else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."), |
| 134 | 134 | }; |
| 135 | 135 | } |
| ... | ... | @@ -417,18 +417,18 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a |
| 417 | 417 | const Child = std.meta.Child(VecType); |
| 418 | 418 | |
| 419 | 419 | const identity = comptime switch (@typeInfo(Child)) { |
| 420 | .Bool => switch (op) { | |
| 420 | .bool => switch (op) { | |
| 421 | 421 | .Or, .Xor => false, |
| 422 | 422 | .And => true, |
| 423 | 423 | else => @compileError("Invalid prefixScan operation " ++ @tagName(op) ++ " for vector of booleans."), |
| 424 | 424 | }, |
| 425 | .Int => switch (op) { | |
| 425 | .int => switch (op) { | |
| 426 | 426 | .Max => std.math.minInt(Child), |
| 427 | 427 | .Add, .Or, .Xor => 0, |
| 428 | 428 | .Mul => 1, |
| 429 | 429 | .And, .Min => std.math.maxInt(Child), |
| 430 | 430 | }, |
| 431 | .Float => switch (op) { | |
| 431 | .float => switch (op) { | |
| 432 | 432 | .Max => -std.math.inf(Child), |
| 433 | 433 | .Add => 0, |
| 434 | 434 | .Mul => 1, |
lib/std/start.zig+6-6| ... | ... | @@ -30,7 +30,7 @@ comptime { |
| 30 | 30 | if (simplified_logic) { |
| 31 | 31 | if (builtin.output_mode == .Exe) { |
| 32 | 32 | if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { |
| 33 | if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { | |
| 33 | if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) { | |
| 34 | 34 | @export(&main2, .{ .name = "main" }); |
| 35 | 35 | } |
| 36 | 36 | } else if (builtin.os.tag == .windows) { |
| ... | ... | @@ -55,7 +55,7 @@ comptime { |
| 55 | 55 | if (builtin.link_libc and @hasDecl(root, "main")) { |
| 56 | 56 | if (native_arch.isWasm()) { |
| 57 | 57 | @export(&mainWithoutEnv, .{ .name = "main" }); |
| 58 | } else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { | |
| 58 | } else if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) { | |
| 59 | 59 | @export(&main, .{ .name = "main" }); |
| 60 | 60 | } |
| 61 | 61 | } else if (native_os == .windows) { |
| ... | ... | @@ -205,7 +205,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv |
| 205 | 205 | uefi.handle = handle; |
| 206 | 206 | uefi.system_table = system_table; |
| 207 | 207 | |
| 208 | switch (@typeInfo(@TypeOf(root.main)).Fn.return_type.?) { | |
| 208 | switch (@typeInfo(@TypeOf(root.main)).@"fn".return_type.?) { | |
| 209 | 209 | noreturn => { |
| 210 | 210 | root.main(); |
| 211 | 211 | }, |
| ... | ... | @@ -599,7 +599,7 @@ fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int { |
| 599 | 599 | const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'"; |
| 600 | 600 | |
| 601 | 601 | pub inline fn callMain() u8 { |
| 602 | const ReturnType = @typeInfo(@TypeOf(root.main)).Fn.return_type.?; | |
| 602 | const ReturnType = @typeInfo(@TypeOf(root.main)).@"fn".return_type.?; | |
| 603 | 603 | |
| 604 | 604 | switch (ReturnType) { |
| 605 | 605 | void => { |
| ... | ... | @@ -610,7 +610,7 @@ pub inline fn callMain() u8 { |
| 610 | 610 | return root.main(); |
| 611 | 611 | }, |
| 612 | 612 | else => { |
| 613 | if (@typeInfo(ReturnType) != .ErrorUnion) @compileError(bad_main_ret); | |
| 613 | if (@typeInfo(ReturnType) != .error_union) @compileError(bad_main_ret); | |
| 614 | 614 | |
| 615 | 615 | const result = root.main() catch |err| { |
| 616 | 616 | if (builtin.zig_backend == .stage2_riscv64) { |
| ... | ... | @@ -635,7 +635,7 @@ pub inline fn callMain() u8 { |
| 635 | 635 | |
| 636 | 636 | pub fn call_wWinMain() std.os.windows.INT { |
| 637 | 637 | const peb = std.os.windows.peb(); |
| 638 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; | |
| 638 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).@"fn".params[0].type.?; | |
| 639 | 639 | const hInstance = @as(MAIN_HINSTANCE, @ptrCast(peb.ImageBaseAddress)); |
| 640 | 640 | const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer); |
| 641 | 641 |
lib/std/testing.zig+66-66| ... | ... | @@ -64,33 +64,33 @@ pub inline fn expectEqual(expected: anytype, actual: anytype) !void { |
| 64 | 64 | |
| 65 | 65 | fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { |
| 66 | 66 | switch (@typeInfo(@TypeOf(actual))) { |
| 67 | .NoReturn, | |
| 68 | .Opaque, | |
| 69 | .Frame, | |
| 70 | .AnyFrame, | |
| 67 | .noreturn, | |
| 68 | .@"opaque", | |
| 69 | .frame, | |
| 70 | .@"anyframe", | |
| 71 | 71 | => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"), |
| 72 | 72 | |
| 73 | .Undefined, | |
| 74 | .Null, | |
| 75 | .Void, | |
| 73 | .undefined, | |
| 74 | .null, | |
| 75 | .void, | |
| 76 | 76 | => return, |
| 77 | 77 | |
| 78 | .Type => { | |
| 78 | .type => { | |
| 79 | 79 | if (actual != expected) { |
| 80 | 80 | print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) }); |
| 81 | 81 | return error.TestExpectedEqual; |
| 82 | 82 | } |
| 83 | 83 | }, |
| 84 | 84 | |
| 85 | .Bool, | |
| 86 | .Int, | |
| 87 | .Float, | |
| 88 | .ComptimeFloat, | |
| 89 | .ComptimeInt, | |
| 90 | .EnumLiteral, | |
| 91 | .Enum, | |
| 92 | .Fn, | |
| 93 | .ErrorSet, | |
| 85 | .bool, | |
| 86 | .int, | |
| 87 | .float, | |
| 88 | .comptime_float, | |
| 89 | .comptime_int, | |
| 90 | .enum_literal, | |
| 91 | .@"enum", | |
| 92 | .@"fn", | |
| 93 | .error_set, | |
| 94 | 94 | => { |
| 95 | 95 | if (actual != expected) { |
| 96 | 96 | print("expected {}, found {}\n", .{ expected, actual }); |
| ... | ... | @@ -98,7 +98,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { |
| 98 | 98 | } |
| 99 | 99 | }, |
| 100 | 100 | |
| 101 | .Pointer => |pointer| { | |
| 101 | .pointer => |pointer| { | |
| 102 | 102 | switch (pointer.size) { |
| 103 | 103 | .One, .Many, .C => { |
| 104 | 104 | if (actual != expected) { |
| ... | ... | @@ -119,9 +119,9 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { |
| 119 | 119 | } |
| 120 | 120 | }, |
| 121 | 121 | |
| 122 | .Array => |array| try expectEqualSlices(array.child, &expected, &actual), | |
| 122 | .array => |array| try expectEqualSlices(array.child, &expected, &actual), | |
| 123 | 123 | |
| 124 | .Vector => |info| { | |
| 124 | .vector => |info| { | |
| 125 | 125 | var i: usize = 0; |
| 126 | 126 | while (i < info.len) : (i += 1) { |
| 127 | 127 | if (!std.meta.eql(expected[i], actual[i])) { |
| ... | ... | @@ -133,13 +133,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { |
| 133 | 133 | } |
| 134 | 134 | }, |
| 135 | 135 | |
| 136 | .Struct => |structType| { | |
| 136 | .@"struct" => |structType| { | |
| 137 | 137 | inline for (structType.fields) |field| { |
| 138 | 138 | try expectEqual(@field(expected, field.name), @field(actual, field.name)); |
| 139 | 139 | } |
| 140 | 140 | }, |
| 141 | 141 | |
| 142 | .Union => |union_info| { | |
| 142 | .@"union" => |union_info| { | |
| 143 | 143 | if (union_info.tag_type == null) { |
| 144 | 144 | @compileError("Unable to compare untagged union values"); |
| 145 | 145 | } |
| ... | ... | @@ -157,7 +157,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { |
| 157 | 157 | } |
| 158 | 158 | }, |
| 159 | 159 | |
| 160 | .Optional => { | |
| 160 | .optional => { | |
| 161 | 161 | if (expected) |expected_payload| { |
| 162 | 162 | if (actual) |actual_payload| { |
| 163 | 163 | try expectEqual(expected_payload, actual_payload); |
| ... | ... | @@ -173,7 +173,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { |
| 173 | 173 | } |
| 174 | 174 | }, |
| 175 | 175 | |
| 176 | .ErrorUnion => { | |
| 176 | .error_union => { | |
| 177 | 177 | if (expected) |expected_payload| { |
| 178 | 178 | if (actual) |actual_payload| { |
| 179 | 179 | try expectEqual(expected_payload, actual_payload); |
| ... | ... | @@ -237,12 +237,12 @@ pub inline fn expectApproxEqAbs(expected: anytype, actual: anytype, tolerance: a |
| 237 | 237 | |
| 238 | 238 | fn expectApproxEqAbsInner(comptime T: type, expected: T, actual: T, tolerance: T) !void { |
| 239 | 239 | switch (@typeInfo(T)) { |
| 240 | .Float => if (!math.approxEqAbs(T, expected, actual, tolerance)) { | |
| 240 | .float => if (!math.approxEqAbs(T, expected, actual, tolerance)) { | |
| 241 | 241 | print("actual {}, not within absolute tolerance {} of expected {}\n", .{ actual, tolerance, expected }); |
| 242 | 242 | return error.TestExpectedApproxEqAbs; |
| 243 | 243 | }, |
| 244 | 244 | |
| 245 | .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"), | |
| 245 | .comptime_float => @compileError("Cannot approximately compare two comptime_float values"), | |
| 246 | 246 | |
| 247 | 247 | else => @compileError("Unable to compare non floating point values"), |
| 248 | 248 | } |
| ... | ... | @@ -273,12 +273,12 @@ pub inline fn expectApproxEqRel(expected: anytype, actual: anytype, tolerance: a |
| 273 | 273 | |
| 274 | 274 | fn expectApproxEqRelInner(comptime T: type, expected: T, actual: T, tolerance: T) !void { |
| 275 | 275 | switch (@typeInfo(T)) { |
| 276 | .Float => if (!math.approxEqRel(T, expected, actual, tolerance)) { | |
| 276 | .float => if (!math.approxEqRel(T, expected, actual, tolerance)) { | |
| 277 | 277 | print("actual {}, not within relative tolerance {} of expected {}\n", .{ actual, tolerance, expected }); |
| 278 | 278 | return error.TestExpectedApproxEqRel; |
| 279 | 279 | }, |
| 280 | 280 | |
| 281 | .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"), | |
| 281 | .comptime_float => @compileError("Cannot approximately compare two comptime_float values"), | |
| 282 | 282 | |
| 283 | 283 | else => @compileError("Unable to compare non floating point values"), |
| 284 | 284 | } |
| ... | ... | @@ -415,7 +415,7 @@ fn SliceDiffer(comptime T: type) type { |
| 415 | 415 | const full_index = self.start_index + i; |
| 416 | 416 | const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true; |
| 417 | 417 | if (diff) try self.ttyconf.setColor(writer, .red); |
| 418 | if (@typeInfo(T) == .Pointer) { | |
| 418 | if (@typeInfo(T) == .pointer) { | |
| 419 | 419 | try writer.print("[{}]{*}: {any}\n", .{ full_index, value, value }); |
| 420 | 420 | } else { |
| 421 | 421 | try writer.print("[{}]: {any}\n", .{ full_index, value }); |
| ... | ... | @@ -505,10 +505,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s |
| 505 | 505 | |
| 506 | 506 | const expected_value_sentinel = blk: { |
| 507 | 507 | switch (@typeInfo(@TypeOf(expected))) { |
| 508 | .Pointer => { | |
| 508 | .pointer => { | |
| 509 | 509 | break :blk expected[expected.len]; |
| 510 | 510 | }, |
| 511 | .Array => |array_info| { | |
| 511 | .array => |array_info| { | |
| 512 | 512 | const indexable_outside_of_bounds = @as([]const array_info.child, &expected); |
| 513 | 513 | break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len]; |
| 514 | 514 | }, |
| ... | ... | @@ -518,10 +518,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s |
| 518 | 518 | |
| 519 | 519 | const actual_value_sentinel = blk: { |
| 520 | 520 | switch (@typeInfo(@TypeOf(actual))) { |
| 521 | .Pointer => { | |
| 521 | .pointer => { | |
| 522 | 522 | break :blk actual[actual.len]; |
| 523 | 523 | }, |
| 524 | .Array => |array_info| { | |
| 524 | .array => |array_info| { | |
| 525 | 525 | const indexable_outside_of_bounds = @as([]const array_info.child, &actual); |
| 526 | 526 | break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len]; |
| 527 | 527 | }, |
| ... | ... | @@ -689,33 +689,33 @@ pub inline fn expectEqualDeep(expected: anytype, actual: anytype) error{TestExpe |
| 689 | 689 | |
| 690 | 690 | fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpectedEqual}!void { |
| 691 | 691 | switch (@typeInfo(@TypeOf(actual))) { |
| 692 | .NoReturn, | |
| 693 | .Opaque, | |
| 694 | .Frame, | |
| 695 | .AnyFrame, | |
| 692 | .noreturn, | |
| 693 | .@"opaque", | |
| 694 | .frame, | |
| 695 | .@"anyframe", | |
| 696 | 696 | => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"), |
| 697 | 697 | |
| 698 | .Undefined, | |
| 699 | .Null, | |
| 700 | .Void, | |
| 698 | .undefined, | |
| 699 | .null, | |
| 700 | .void, | |
| 701 | 701 | => return, |
| 702 | 702 | |
| 703 | .Type => { | |
| 703 | .type => { | |
| 704 | 704 | if (actual != expected) { |
| 705 | 705 | print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) }); |
| 706 | 706 | return error.TestExpectedEqual; |
| 707 | 707 | } |
| 708 | 708 | }, |
| 709 | 709 | |
| 710 | .Bool, | |
| 711 | .Int, | |
| 712 | .Float, | |
| 713 | .ComptimeFloat, | |
| 714 | .ComptimeInt, | |
| 715 | .EnumLiteral, | |
| 716 | .Enum, | |
| 717 | .Fn, | |
| 718 | .ErrorSet, | |
| 710 | .bool, | |
| 711 | .int, | |
| 712 | .float, | |
| 713 | .comptime_float, | |
| 714 | .comptime_int, | |
| 715 | .enum_literal, | |
| 716 | .@"enum", | |
| 717 | .@"fn", | |
| 718 | .error_set, | |
| 719 | 719 | => { |
| 720 | 720 | if (actual != expected) { |
| 721 | 721 | print("expected {}, found {}\n", .{ expected, actual }); |
| ... | ... | @@ -723,7 +723,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 723 | 723 | } |
| 724 | 724 | }, |
| 725 | 725 | |
| 726 | .Pointer => |pointer| { | |
| 726 | .pointer => |pointer| { | |
| 727 | 727 | switch (pointer.size) { |
| 728 | 728 | // We have no idea what is behind those pointers, so the best we can do is `==` check. |
| 729 | 729 | .C, .Many => { |
| ... | ... | @@ -735,7 +735,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 735 | 735 | .One => { |
| 736 | 736 | // Length of those pointers are runtime value, so the best we can do is `==` check. |
| 737 | 737 | switch (@typeInfo(pointer.child)) { |
| 738 | .Fn, .Opaque => { | |
| 738 | .@"fn", .@"opaque" => { | |
| 739 | 739 | if (actual != expected) { |
| 740 | 740 | print("expected {*}, found {*}\n", .{ expected, actual }); |
| 741 | 741 | return error.TestExpectedEqual; |
| ... | ... | @@ -762,7 +762,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 762 | 762 | } |
| 763 | 763 | }, |
| 764 | 764 | |
| 765 | .Array => |_| { | |
| 765 | .array => |_| { | |
| 766 | 766 | if (expected.len != actual.len) { |
| 767 | 767 | print("Array len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len }); |
| 768 | 768 | return error.TestExpectedEqual; |
| ... | ... | @@ -778,9 +778,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 778 | 778 | } |
| 779 | 779 | }, |
| 780 | 780 | |
| 781 | .Vector => |info| { | |
| 782 | if (info.len != @typeInfo(@TypeOf(actual)).Vector.len) { | |
| 783 | print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).Vector.len }); | |
| 781 | .vector => |info| { | |
| 782 | if (info.len != @typeInfo(@TypeOf(actual)).vector.len) { | |
| 783 | print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).vector.len }); | |
| 784 | 784 | return error.TestExpectedEqual; |
| 785 | 785 | } |
| 786 | 786 | var i: usize = 0; |
| ... | ... | @@ -794,7 +794,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 794 | 794 | } |
| 795 | 795 | }, |
| 796 | 796 | |
| 797 | .Struct => |structType| { | |
| 797 | .@"struct" => |structType| { | |
| 798 | 798 | inline for (structType.fields) |field| { |
| 799 | 799 | expectEqualDeep(@field(expected, field.name), @field(actual, field.name)) catch |e| { |
| 800 | 800 | print("Field {s} incorrect. expected {any}, found {any}\n", .{ field.name, @field(expected, field.name), @field(actual, field.name) }); |
| ... | ... | @@ -803,7 +803,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 803 | 803 | } |
| 804 | 804 | }, |
| 805 | 805 | |
| 806 | .Union => |union_info| { | |
| 806 | .@"union" => |union_info| { | |
| 807 | 807 | if (union_info.tag_type == null) { |
| 808 | 808 | @compileError("Unable to compare untagged union values"); |
| 809 | 809 | } |
| ... | ... | @@ -823,7 +823,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 823 | 823 | } |
| 824 | 824 | }, |
| 825 | 825 | |
| 826 | .Optional => { | |
| 826 | .optional => { | |
| 827 | 827 | if (expected) |expected_payload| { |
| 828 | 828 | if (actual) |actual_payload| { |
| 829 | 829 | try expectEqualDeep(expected_payload, actual_payload); |
| ... | ... | @@ -839,7 +839,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 839 | 839 | } |
| 840 | 840 | }, |
| 841 | 841 | |
| 842 | .ErrorUnion => { | |
| 842 | .error_union => { | |
| 843 | 843 | if (expected) |expected_payload| { |
| 844 | 844 | if (actual) |actual_payload| { |
| 845 | 845 | try expectEqualDeep(expected_payload, actual_payload); |
| ... | ... | @@ -1036,20 +1036,20 @@ test { |
| 1036 | 1036 | /// } |
| 1037 | 1037 | /// ``` |
| 1038 | 1038 | pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime test_fn: anytype, extra_args: anytype) !void { |
| 1039 | switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).Fn.return_type.?)) { | |
| 1040 | .ErrorUnion => |info| { | |
| 1039 | switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).@"fn".return_type.?)) { | |
| 1040 | .error_union => |info| { | |
| 1041 | 1041 | if (info.payload != void) { |
| 1042 | 1042 | @compileError("Return type must be !void"); |
| 1043 | 1043 | } |
| 1044 | 1044 | }, |
| 1045 | 1045 | else => @compileError("Return type must be !void"), |
| 1046 | 1046 | } |
| 1047 | if (@typeInfo(@TypeOf(extra_args)) != .Struct) { | |
| 1047 | if (@typeInfo(@TypeOf(extra_args)) != .@"struct") { | |
| 1048 | 1048 | @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(extra_args))); |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn)); |
| 1052 | const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields; | |
| 1052 | const fn_args_fields = @typeInfo(ArgsTuple).@"struct".fields; | |
| 1053 | 1053 | if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) { |
| 1054 | 1054 | @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument"); |
| 1055 | 1055 | } |
| ... | ... | @@ -1061,7 +1061,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime |
| 1061 | 1061 | // Setup the tuple that will actually be used with @call (we'll need to insert |
| 1062 | 1062 | // the failing allocator in field @"0" before each @call) |
| 1063 | 1063 | var args: ArgsTuple = undefined; |
| 1064 | inline for (@typeInfo(@TypeOf(extra_args)).Struct.fields, 0..) |field, i| { | |
| 1064 | inline for (@typeInfo(@TypeOf(extra_args)).@"struct".fields, 0..) |field, i| { | |
| 1065 | 1065 | const arg_i_str = comptime str: { |
| 1066 | 1066 | var str_buf: [100]u8 = undefined; |
| 1067 | 1067 | const args_i = i + 1; |
| ... | ... | @@ -1129,7 +1129,7 @@ pub fn refAllDeclsRecursive(comptime T: type) void { |
| 1129 | 1129 | inline for (comptime std.meta.declarations(T)) |decl| { |
| 1130 | 1130 | if (@TypeOf(@field(T, decl.name)) == type) { |
| 1131 | 1131 | switch (@typeInfo(@field(T, decl.name))) { |
| 1132 | .Struct, .Enum, .Union, .Opaque => refAllDeclsRecursive(@field(T, decl.name)), | |
| 1132 | .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)), | |
| 1133 | 1133 | else => {}, |
| 1134 | 1134 | } |
| 1135 | 1135 | } |
lib/std/zig.zig+2-2| ... | ... | @@ -246,7 +246,7 @@ pub const BuildId = union(enum) { |
| 246 | 246 | hexstring: HexString, |
| 247 | 247 | |
| 248 | 248 | pub fn eql(a: BuildId, b: BuildId) bool { |
| 249 | const Tag = @typeInfo(BuildId).Union.tag_type.?; | |
| 249 | const Tag = @typeInfo(BuildId).@"union".tag_type.?; | |
| 250 | 250 | const a_tag: Tag = a; |
| 251 | 251 | const b_tag: Tag = b; |
| 252 | 252 | if (a_tag != b_tag) return false; |
| ... | ... | @@ -654,7 +654,7 @@ pub fn parseTargetQueryOrReportFatalError( |
| 654 | 654 | help: { |
| 655 | 655 | var help_text = std.ArrayList(u8).init(allocator); |
| 656 | 656 | defer help_text.deinit(); |
| 657 | inline for (@typeInfo(std.Target.ObjectFormat).Enum.fields) |field| { | |
| 657 | inline for (@typeInfo(std.Target.ObjectFormat).@"enum".fields) |field| { | |
| 658 | 658 | help_text.writer().print(" {s}\n", .{field.name}) catch break :help; |
| 659 | 659 | } |
| 660 | 660 | std.log.info("available object formats:\n{s}", .{help_text.items}); |
lib/std/zig/AstGen.zig+39-39| ... | ... | @@ -153,7 +153,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 153 | 153 | try astgen.instructions.ensureTotalCapacity(gpa, tree.nodes.len); |
| 154 | 154 | |
| 155 | 155 | // First few indexes of extra are reserved and set at the end. |
| 156 | const reserved_count = @typeInfo(Zir.ExtraIndex).Enum.fields.len; | |
| 156 | const reserved_count = @typeInfo(Zir.ExtraIndex).@"enum".fields.len; | |
| 157 | 157 | try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count); |
| 158 | 158 | astgen.extra.items.len += reserved_count; |
| 159 | 159 | |
| ... | ... | @@ -197,7 +197,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 197 | 197 | astgen.extra.items[err_index] = 0; |
| 198 | 198 | } else { |
| 199 | 199 | try astgen.extra.ensureUnusedCapacity(gpa, 1 + astgen.compile_errors.items.len * |
| 200 | @typeInfo(Zir.Inst.CompileErrors.Item).Struct.fields.len); | |
| 200 | @typeInfo(Zir.Inst.CompileErrors.Item).@"struct".fields.len); | |
| 201 | 201 | |
| 202 | 202 | astgen.extra.items[err_index] = astgen.addExtraAssumeCapacity(Zir.Inst.CompileErrors{ |
| 203 | 203 | .items_len = @intCast(astgen.compile_errors.items.len), |
| ... | ... | @@ -212,8 +212,8 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 212 | 212 | if (astgen.imports.count() == 0) { |
| 213 | 213 | astgen.extra.items[imports_index] = 0; |
| 214 | 214 | } else { |
| 215 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).Struct.fields.len + | |
| 216 | astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).Struct.fields.len); | |
| 215 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).@"struct".fields.len + | |
| 216 | astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).@"struct".fields.len); | |
| 217 | 217 | |
| 218 | 218 | astgen.extra.items[imports_index] = astgen.addExtraAssumeCapacity(Zir.Inst.Imports{ |
| 219 | 219 | .imports_len = @intCast(astgen.imports.count()), |
| ... | ... | @@ -1885,7 +1885,7 @@ fn structInitExprAnon( |
| 1885 | 1885 | const payload_index = try addExtra(astgen, Zir.Inst.StructInitAnon{ |
| 1886 | 1886 | .fields_len = @intCast(struct_init.ast.fields.len), |
| 1887 | 1887 | }); |
| 1888 | const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).Struct.fields.len; | |
| 1888 | const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).@"struct".fields.len; | |
| 1889 | 1889 | var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size); |
| 1890 | 1890 | |
| 1891 | 1891 | for (struct_init.ast.fields) |field_init| { |
| ... | ... | @@ -1916,7 +1916,7 @@ fn structInitExprTyped( |
| 1916 | 1916 | const payload_index = try addExtra(astgen, Zir.Inst.StructInit{ |
| 1917 | 1917 | .fields_len = @intCast(struct_init.ast.fields.len), |
| 1918 | 1918 | }); |
| 1919 | const field_size = @typeInfo(Zir.Inst.StructInit.Item).Struct.fields.len; | |
| 1919 | const field_size = @typeInfo(Zir.Inst.StructInit.Item).@"struct".fields.len; | |
| 1920 | 1920 | var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size); |
| 1921 | 1921 | |
| 1922 | 1922 | for (struct_init.ast.fields) |field_init| { |
| ... | ... | @@ -2464,7 +2464,7 @@ fn labeledBlockExpr( |
| 2464 | 2464 | }; |
| 2465 | 2465 | // We need to call `rvalue` to write through to the pointer only if we had a |
| 2466 | 2466 | // result pointer and aren't forwarding it. |
| 2467 | const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; | |
| 2467 | const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; | |
| 2468 | 2468 | const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); |
| 2469 | 2469 | |
| 2470 | 2470 | // Reserve the Block ZIR instruction index so that we can put it into the GenZir struct |
| ... | ... | @@ -3864,7 +3864,7 @@ fn ptrType( |
| 3864 | 3864 | const gpa = gz.astgen.gpa; |
| 3865 | 3865 | try gz.instructions.ensureUnusedCapacity(gpa, 1); |
| 3866 | 3866 | try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1); |
| 3867 | try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).Struct.fields.len + | |
| 3867 | try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).@"struct".fields.len + | |
| 3868 | 3868 | trailing_count); |
| 3869 | 3869 | |
| 3870 | 3870 | const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.PtrType{ |
| ... | ... | @@ -5939,7 +5939,7 @@ fn errorSetDecl(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index) InnerError!Zi |
| 5939 | 5939 | const main_tokens = tree.nodes.items(.main_token); |
| 5940 | 5940 | const token_tags = tree.tokens.items(.tag); |
| 5941 | 5941 | |
| 5942 | const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).Struct.fields.len); | |
| 5942 | const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).@"struct".fields.len); | |
| 5943 | 5943 | var fields_len: usize = 0; |
| 5944 | 5944 | { |
| 5945 | 5945 | var idents: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.TokenIndex) = .{}; |
| ... | ... | @@ -6078,7 +6078,7 @@ fn orelseCatchExpr( |
| 6078 | 6078 | }; |
| 6079 | 6079 | // We need to call `rvalue` to write through to the pointer only if we had a |
| 6080 | 6080 | // result pointer and aren't forwarding it. |
| 6081 | const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; | |
| 6081 | const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; | |
| 6082 | 6082 | const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); |
| 6083 | 6083 | |
| 6084 | 6084 | const do_err_trace = astgen.fn_block != null and (cond_op == .is_non_err or cond_op == .is_non_err_ptr); |
| ... | ... | @@ -6347,7 +6347,7 @@ fn ifExpr( |
| 6347 | 6347 | }; |
| 6348 | 6348 | // We need to call `rvalue` to write through to the pointer only if we had a |
| 6349 | 6349 | // result pointer and aren't forwarding it. |
| 6350 | const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; | |
| 6350 | const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; | |
| 6351 | 6351 | const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); |
| 6352 | 6352 | |
| 6353 | 6353 | var block_scope = parent_gz.makeSubBlock(scope); |
| ... | ... | @@ -6537,7 +6537,7 @@ fn setCondBrPayload( |
| 6537 | 6537 | const else_body_len = astgen.countBodyLenAfterFixups(else_body); |
| 6538 | 6538 | try astgen.extra.ensureUnusedCapacity( |
| 6539 | 6539 | astgen.gpa, |
| 6540 | @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len, | |
| 6540 | @typeInfo(Zir.Inst.CondBr).@"struct".fields.len + then_body_len + else_body_len, | |
| 6541 | 6541 | ); |
| 6542 | 6542 | |
| 6543 | 6543 | const zir_datas = astgen.instructions.items(.data); |
| ... | ... | @@ -6573,7 +6573,7 @@ fn whileExpr( |
| 6573 | 6573 | }; |
| 6574 | 6574 | // We need to call `rvalue` to write through to the pointer only if we had a |
| 6575 | 6575 | // result pointer and aren't forwarding it. |
| 6576 | const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; | |
| 6576 | const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; | |
| 6577 | 6577 | const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); |
| 6578 | 6578 | |
| 6579 | 6579 | if (while_full.label_token) |label_token| { |
| ... | ... | @@ -6853,7 +6853,7 @@ fn forExpr( |
| 6853 | 6853 | }; |
| 6854 | 6854 | // We need to call `rvalue` to write through to the pointer only if we had a |
| 6855 | 6855 | // result pointer and aren't forwarding it. |
| 6856 | const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; | |
| 6856 | const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; | |
| 6857 | 6857 | const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); |
| 6858 | 6858 | |
| 6859 | 6859 | const is_inline = for_full.inline_token != null; |
| ... | ... | @@ -6951,7 +6951,7 @@ fn forExpr( |
| 6951 | 6951 | // nicer error reporting as well as fewer ZIR bytes emitted. |
| 6952 | 6952 | const len: Zir.Inst.Ref = len: { |
| 6953 | 6953 | const lens_len: u32 = @intCast(lens.len); |
| 6954 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).Struct.fields.len + lens_len); | |
| 6954 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).@"struct".fields.len + lens_len); | |
| 6955 | 6955 | const len = try parent_gz.addPlNode(.for_len, node, Zir.Inst.MultiOp{ |
| 6956 | 6956 | .operands_len = lens_len, |
| 6957 | 6957 | }); |
| ... | ... | @@ -7188,7 +7188,7 @@ fn switchExprErrUnion( |
| 7188 | 7188 | |
| 7189 | 7189 | // We need to call `rvalue` to write through to the pointer only if we had a |
| 7190 | 7190 | // result pointer and aren't forwarding it. |
| 7191 | const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; | |
| 7191 | const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; | |
| 7192 | 7192 | const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); |
| 7193 | 7193 | var scalar_cases_len: u32 = 0; |
| 7194 | 7194 | var multi_cases_len: u32 = 0; |
| ... | ... | @@ -7622,10 +7622,10 @@ fn switchExprErrUnion( |
| 7622 | 7622 | // Now that the item expressions are generated we can add this. |
| 7623 | 7623 | try parent_gz.instructions.append(gpa, switch_block); |
| 7624 | 7624 | |
| 7625 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).Struct.fields.len + | |
| 7625 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).@"struct".fields.len + | |
| 7626 | 7626 | @intFromBool(multi_cases_len != 0) + |
| 7627 | 7627 | payloads.items.len - case_table_end + |
| 7628 | (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len); | |
| 7628 | (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len); | |
| 7629 | 7629 | |
| 7630 | 7630 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlockErrUnion{ |
| 7631 | 7631 | .operand = raw_operand, |
| ... | ... | @@ -7705,7 +7705,7 @@ fn switchExpr( |
| 7705 | 7705 | }; |
| 7706 | 7706 | // We need to call `rvalue` to write through to the pointer only if we had a |
| 7707 | 7707 | // result pointer and aren't forwarding it. |
| 7708 | const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; | |
| 7708 | const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; | |
| 7709 | 7709 | const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); |
| 7710 | 7710 | |
| 7711 | 7711 | // We perform two passes over the AST. This first pass is to collect information |
| ... | ... | @@ -8068,11 +8068,11 @@ fn switchExpr( |
| 8068 | 8068 | // Now that the item expressions are generated we can add this. |
| 8069 | 8069 | try parent_gz.instructions.append(gpa, switch_block); |
| 8070 | 8070 | |
| 8071 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).Struct.fields.len + | |
| 8071 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).@"struct".fields.len + | |
| 8072 | 8072 | @intFromBool(multi_cases_len != 0) + |
| 8073 | 8073 | @intFromBool(any_has_tag_capture) + |
| 8074 | 8074 | payloads.items.len - case_table_end + |
| 8075 | (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len); | |
| 8075 | (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len); | |
| 8076 | 8076 | |
| 8077 | 8077 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlock{ |
| 8078 | 8078 | .operand = raw_operand, |
| ... | ... | @@ -8971,7 +8971,7 @@ fn ptrCast( |
| 8971 | 8971 | const node_datas = tree.nodes.items(.data); |
| 8972 | 8972 | const node_tags = tree.nodes.items(.tag); |
| 8973 | 8973 | |
| 8974 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; | |
| 8974 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | |
| 8975 | 8975 | var flags: Zir.Inst.FullPtrCastFlags = .{}; |
| 8976 | 8976 | |
| 8977 | 8977 | // Note that all pointer cast builtins have one parameter, so we only need |
| ... | ... | @@ -12080,7 +12080,7 @@ const GenZir = struct { |
| 12080 | 12080 | const body_len = astgen.countBodyLenAfterFixups(body); |
| 12081 | 12081 | try astgen.extra.ensureUnusedCapacity( |
| 12082 | 12082 | gpa, |
| 12083 | @typeInfo(Zir.Inst.BoolBr).Struct.fields.len + body_len, | |
| 12083 | @typeInfo(Zir.Inst.BoolBr).@"struct".fields.len + body_len, | |
| 12084 | 12084 | ); |
| 12085 | 12085 | const zir_datas = astgen.instructions.items(.data); |
| 12086 | 12086 | zir_datas[@intFromEnum(bool_br)].pl_node.payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.BoolBr{ |
| ... | ... | @@ -12099,7 +12099,7 @@ const GenZir = struct { |
| 12099 | 12099 | const body_len = astgen.countBodyLenAfterFixups(body); |
| 12100 | 12100 | try astgen.extra.ensureUnusedCapacity( |
| 12101 | 12101 | gpa, |
| 12102 | @typeInfo(Zir.Inst.Block).Struct.fields.len + body_len, | |
| 12102 | @typeInfo(Zir.Inst.Block).@"struct".fields.len + body_len, | |
| 12103 | 12103 | ); |
| 12104 | 12104 | const zir_datas = astgen.instructions.items(.data); |
| 12105 | 12105 | zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity( |
| ... | ... | @@ -12117,7 +12117,7 @@ const GenZir = struct { |
| 12117 | 12117 | const body_len = astgen.countBodyLenAfterFixups(body); |
| 12118 | 12118 | try astgen.extra.ensureUnusedCapacity( |
| 12119 | 12119 | gpa, |
| 12120 | @typeInfo(Zir.Inst.Try).Struct.fields.len + body_len, | |
| 12120 | @typeInfo(Zir.Inst.Try).@"struct".fields.len + body_len, | |
| 12121 | 12121 | ); |
| 12122 | 12122 | const zir_datas = astgen.instructions.items(.data); |
| 12123 | 12123 | zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity( |
| ... | ... | @@ -12235,7 +12235,7 @@ const GenZir = struct { |
| 12235 | 12235 | |
| 12236 | 12236 | try astgen.extra.ensureUnusedCapacity( |
| 12237 | 12237 | gpa, |
| 12238 | @typeInfo(Zir.Inst.FuncFancy).Struct.fields.len + | |
| 12238 | @typeInfo(Zir.Inst.FuncFancy).@"struct".fields.len + | |
| 12239 | 12239 | fancyFnExprExtraLen(astgen, align_body, args.align_ref) + |
| 12240 | 12240 | fancyFnExprExtraLen(astgen, addrspace_body, args.addrspace_ref) + |
| 12241 | 12241 | fancyFnExprExtraLen(astgen, section_body, args.section_ref) + |
| ... | ... | @@ -12354,7 +12354,7 @@ const GenZir = struct { |
| 12354 | 12354 | } else { |
| 12355 | 12355 | try astgen.extra.ensureUnusedCapacity( |
| 12356 | 12356 | gpa, |
| 12357 | @typeInfo(Zir.Inst.Func).Struct.fields.len + 1 + | |
| 12357 | @typeInfo(Zir.Inst.Func).@"struct".fields.len + 1 + | |
| 12358 | 12358 | fancyFnExprExtraLen(astgen, ret_body, ret_ref) + |
| 12359 | 12359 | body_len + src_locs_and_hash.len, |
| 12360 | 12360 | ); |
| ... | ... | @@ -12428,7 +12428,7 @@ const GenZir = struct { |
| 12428 | 12428 | |
| 12429 | 12429 | try astgen.extra.ensureUnusedCapacity( |
| 12430 | 12430 | gpa, |
| 12431 | @typeInfo(Zir.Inst.ExtendedVar).Struct.fields.len + | |
| 12431 | @typeInfo(Zir.Inst.ExtendedVar).@"struct".fields.len + | |
| 12432 | 12432 | @intFromBool(args.lib_name != .empty) + |
| 12433 | 12433 | @intFromBool(args.align_inst != .none) + |
| 12434 | 12434 | @intFromBool(args.init != .none), |
| ... | ... | @@ -12590,7 +12590,7 @@ const GenZir = struct { |
| 12590 | 12590 | const param_body = param_gz.instructionsSlice(); |
| 12591 | 12591 | const body_len = gz.astgen.countBodyLenAfterFixups(param_body); |
| 12592 | 12592 | try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1); |
| 12593 | try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).Struct.fields.len + body_len); | |
| 12593 | try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).@"struct".fields.len + body_len); | |
| 12594 | 12594 | |
| 12595 | 12595 | const doc_comment_index = if (first_doc_comment) |first| |
| 12596 | 12596 | try gz.astgen.docCommentAsStringFromFirst(abs_tok_index, first) |
| ... | ... | @@ -12663,7 +12663,7 @@ const GenZir = struct { |
| 12663 | 12663 | try astgen.instructions.ensureUnusedCapacity(gpa, 1); |
| 12664 | 12664 | try astgen.extra.ensureUnusedCapacity( |
| 12665 | 12665 | gpa, |
| 12666 | @typeInfo(Zir.Inst.NodeMultiOp).Struct.fields.len + operands.len, | |
| 12666 | @typeInfo(Zir.Inst.NodeMultiOp).@"struct".fields.len + operands.len, | |
| 12667 | 12667 | ); |
| 12668 | 12668 | |
| 12669 | 12669 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.NodeMultiOp{ |
| ... | ... | @@ -12904,7 +12904,7 @@ const GenZir = struct { |
| 12904 | 12904 | ) !Zir.Inst.Index { |
| 12905 | 12905 | const gpa = gz.astgen.gpa; |
| 12906 | 12906 | try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1); |
| 12907 | try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).Struct.fields.len); | |
| 12907 | try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).@"struct".fields.len); | |
| 12908 | 12908 | |
| 12909 | 12909 | const new_index: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len); |
| 12910 | 12910 | gz.astgen.instructions.appendAssumeCapacity(.{ |
| ... | ... | @@ -13027,7 +13027,7 @@ const GenZir = struct { |
| 13027 | 13027 | try astgen.instructions.ensureUnusedCapacity(gpa, 1); |
| 13028 | 13028 | try astgen.extra.ensureUnusedCapacity( |
| 13029 | 13029 | gpa, |
| 13030 | @typeInfo(Zir.Inst.AllocExtended).Struct.fields.len + | |
| 13030 | @typeInfo(Zir.Inst.AllocExtended).@"struct".fields.len + | |
| 13031 | 13031 | @intFromBool(args.type_inst != .none) + |
| 13032 | 13032 | @intFromBool(args.align_inst != .none), |
| 13033 | 13033 | ); |
| ... | ... | @@ -13079,9 +13079,9 @@ const GenZir = struct { |
| 13079 | 13079 | |
| 13080 | 13080 | try gz.instructions.ensureUnusedCapacity(gpa, 1); |
| 13081 | 13081 | try astgen.instructions.ensureUnusedCapacity(gpa, 1); |
| 13082 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).Struct.fields.len + | |
| 13083 | args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).Struct.fields.len + | |
| 13084 | args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).Struct.fields.len + | |
| 13082 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".fields.len + | |
| 13083 | args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".fields.len + | |
| 13084 | args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".fields.len + | |
| 13085 | 13085 | args.clobbers.len); |
| 13086 | 13086 | |
| 13087 | 13087 | const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{ |
| ... | ... | @@ -13190,7 +13190,7 @@ const GenZir = struct { |
| 13190 | 13190 | |
| 13191 | 13191 | const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash); |
| 13192 | 13192 | |
| 13193 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).Struct.fields.len + 3); | |
| 13193 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len + 3); | |
| 13194 | 13194 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.StructDecl{ |
| 13195 | 13195 | .fields_hash_0 = fields_hash_arr[0], |
| 13196 | 13196 | .fields_hash_1 = fields_hash_arr[1], |
| ... | ... | @@ -13251,7 +13251,7 @@ const GenZir = struct { |
| 13251 | 13251 | |
| 13252 | 13252 | const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash); |
| 13253 | 13253 | |
| 13254 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).Struct.fields.len + 5); | |
| 13254 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).@"struct".fields.len + 5); | |
| 13255 | 13255 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.UnionDecl{ |
| 13256 | 13256 | .fields_hash_0 = fields_hash_arr[0], |
| 13257 | 13257 | .fields_hash_1 = fields_hash_arr[1], |
| ... | ... | @@ -13313,7 +13313,7 @@ const GenZir = struct { |
| 13313 | 13313 | |
| 13314 | 13314 | const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash); |
| 13315 | 13315 | |
| 13316 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).Struct.fields.len + 5); | |
| 13316 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).@"struct".fields.len + 5); | |
| 13317 | 13317 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.EnumDecl{ |
| 13318 | 13318 | .fields_hash_0 = fields_hash_arr[0], |
| 13319 | 13319 | .fields_hash_1 = fields_hash_arr[1], |
| ... | ... | @@ -13366,7 +13366,7 @@ const GenZir = struct { |
| 13366 | 13366 | |
| 13367 | 13367 | assert(args.src_node != 0); |
| 13368 | 13368 | |
| 13369 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).Struct.fields.len + 2); | |
| 13369 | try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).@"struct".fields.len + 2); | |
| 13370 | 13370 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.OpaqueDecl{ |
| 13371 | 13371 | .src_line = astgen.source_line, |
| 13372 | 13372 | .src_node = args.src_node, |
lib/std/zig/ErrorBundle.zig+6-6| ... | ... | @@ -108,7 +108,7 @@ pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLoca |
| 108 | 108 | |
| 109 | 109 | pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex { |
| 110 | 110 | const notes_len = eb.getErrorMessage(index).notes_len; |
| 111 | const start = @intFromEnum(index) + @typeInfo(ErrorMessage).Struct.fields.len; | |
| 111 | const start = @intFromEnum(index) + @typeInfo(ErrorMessage).@"struct".fields.len; | |
| 112 | 112 | return @as([]const MessageIndex, @ptrCast(eb.extra[start..][0..notes_len])); |
| 113 | 113 | } |
| 114 | 114 | |
| ... | ... | @@ -119,7 +119,7 @@ pub fn getCompileLogOutput(eb: ErrorBundle) [:0]const u8 { |
| 119 | 119 | /// Returns the requested data, as well as the new index which is at the start of the |
| 120 | 120 | /// trailers for the object. |
| 121 | 121 | fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, end: usize } { |
| 122 | const fields = @typeInfo(T).Struct.fields; | |
| 122 | const fields = @typeInfo(T).@"struct".fields; | |
| 123 | 123 | var i: usize = index; |
| 124 | 124 | var result: T = undefined; |
| 125 | 125 | inline for (fields) |field| { |
| ... | ... | @@ -456,7 +456,7 @@ pub const Wip = struct { |
| 456 | 456 | |
| 457 | 457 | pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 { |
| 458 | 458 | try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len + |
| 459 | notes_len * @typeInfo(ErrorBundle.ErrorMessage).Struct.fields.len); | |
| 459 | notes_len * @typeInfo(ErrorBundle.ErrorMessage).@"struct".fields.len); | |
| 460 | 460 | wip.extra.items.len += notes_len; |
| 461 | 461 | return @intCast(wip.extra.items.len - notes_len); |
| 462 | 462 | } |
| ... | ... | @@ -616,13 +616,13 @@ pub const Wip = struct { |
| 616 | 616 | |
| 617 | 617 | fn addExtra(wip: *Wip, extra: anytype) Allocator.Error!u32 { |
| 618 | 618 | const gpa = wip.gpa; |
| 619 | const fields = @typeInfo(@TypeOf(extra)).Struct.fields; | |
| 619 | const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; | |
| 620 | 620 | try wip.extra.ensureUnusedCapacity(gpa, fields.len); |
| 621 | 621 | return addExtraAssumeCapacity(wip, extra); |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | fn addExtraAssumeCapacity(wip: *Wip, extra: anytype) u32 { |
| 625 | const fields = @typeInfo(@TypeOf(extra)).Struct.fields; | |
| 625 | const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; | |
| 626 | 626 | const result: u32 = @intCast(wip.extra.items.len); |
| 627 | 627 | wip.extra.items.len += fields.len; |
| 628 | 628 | setExtra(wip, result, extra); |
| ... | ... | @@ -630,7 +630,7 @@ pub const Wip = struct { |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | fn setExtra(wip: *Wip, index: usize, extra: anytype) void { |
| 633 | const fields = @typeInfo(@TypeOf(extra)).Struct.fields; | |
| 633 | const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; | |
| 634 | 634 | var i = index; |
| 635 | 635 | inline for (fields) |field| { |
| 636 | 636 | wip.extra.items[i] = switch (field.type) { |
lib/std/zig/Server.zig+3-3| ... | ... | @@ -282,9 +282,9 @@ fn bswap(x: anytype) @TypeOf(x) { |
| 282 | 282 | |
| 283 | 283 | const T = @TypeOf(x); |
| 284 | 284 | switch (@typeInfo(T)) { |
| 285 | .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))), | |
| 286 | .Int => return @byteSwap(x), | |
| 287 | .Struct => |info| switch (info.layout) { | |
| 285 | .@"enum" => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))), | |
| 286 | .int => return @byteSwap(x), | |
| 287 | .@"struct" => |info| switch (info.layout) { | |
| 288 | 288 | .@"extern" => { |
| 289 | 289 | var result: T = undefined; |
| 290 | 290 | inline for (info.fields) |field| { |
lib/std/zig/Zir.zig+8-8| ... | ... | @@ -68,7 +68,7 @@ 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 fields = @typeInfo(T).Struct.fields; | |
| 71 | const fields = @typeInfo(T).@"struct".fields; | |
| 72 | 72 | var i: usize = index; |
| 73 | 73 | var result: T = undefined; |
| 74 | 74 | inline for (fields) |field| { |
| ... | ... | @@ -1823,7 +1823,7 @@ pub const Inst = struct { |
| 1823 | 1823 | |
| 1824 | 1824 | // Uncomment to view how many tag slots are available. |
| 1825 | 1825 | //comptime { |
| 1826 | // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).Enum.fields.len); | |
| 1826 | // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).@"enum".fields.len); | |
| 1827 | 1827 | //} |
| 1828 | 1828 | }; |
| 1829 | 1829 | |
| ... | ... | @@ -3551,7 +3551,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { |
| 3551 | 3551 | }, |
| 3552 | 3552 | .struct_decl => { |
| 3553 | 3553 | const small: Inst.StructDecl.Small = @bitCast(extended.small); |
| 3554 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).Struct.fields.len); | |
| 3554 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).@"struct".fields.len); | |
| 3555 | 3555 | const captures_len = if (small.has_captures_len) captures_len: { |
| 3556 | 3556 | const captures_len = zir.extra[extra_index]; |
| 3557 | 3557 | extra_index += 1; |
| ... | ... | @@ -3584,7 +3584,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { |
| 3584 | 3584 | }, |
| 3585 | 3585 | .enum_decl => { |
| 3586 | 3586 | const small: Inst.EnumDecl.Small = @bitCast(extended.small); |
| 3587 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).Struct.fields.len); | |
| 3587 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).@"struct".fields.len); | |
| 3588 | 3588 | extra_index += @intFromBool(small.has_tag_type); |
| 3589 | 3589 | const captures_len = if (small.has_captures_len) captures_len: { |
| 3590 | 3590 | const captures_len = zir.extra[extra_index]; |
| ... | ... | @@ -3609,7 +3609,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { |
| 3609 | 3609 | }, |
| 3610 | 3610 | .union_decl => { |
| 3611 | 3611 | const small: Inst.UnionDecl.Small = @bitCast(extended.small); |
| 3612 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).Struct.fields.len); | |
| 3612 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).@"struct".fields.len); | |
| 3613 | 3613 | extra_index += @intFromBool(small.has_tag_type); |
| 3614 | 3614 | const captures_len = if (small.has_captures_len) captures_len: { |
| 3615 | 3615 | const captures_len = zir.extra[extra_index]; |
| ... | ... | @@ -3634,7 +3634,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { |
| 3634 | 3634 | }, |
| 3635 | 3635 | .opaque_decl => { |
| 3636 | 3636 | const small: Inst.OpaqueDecl.Small = @bitCast(extended.small); |
| 3637 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).Struct.fields.len); | |
| 3637 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).@"struct".fields.len); | |
| 3638 | 3638 | const decls_len = if (small.has_decls_len) decls_len: { |
| 3639 | 3639 | const decls_len = zir.extra[extra_index]; |
| 3640 | 3640 | extra_index += 1; |
| ... | ... | @@ -4607,7 +4607,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash { |
| 4607 | 4607 | const extra_index = extra.end + |
| 4608 | 4608 | extra.data.ret_body_len + |
| 4609 | 4609 | extra.data.body_len + |
| 4610 | @typeInfo(Inst.Func.SrcLocs).Struct.fields.len; | |
| 4610 | @typeInfo(Inst.Func.SrcLocs).@"struct".fields.len; | |
| 4611 | 4611 | return @bitCast([4]u32{ |
| 4612 | 4612 | zir.extra[extra_index + 0], |
| 4613 | 4613 | zir.extra[extra_index + 1], |
| ... | ... | @@ -4647,7 +4647,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash { |
| 4647 | 4647 | } else extra_index += @intFromBool(bits.has_ret_ty_ref); |
| 4648 | 4648 | extra_index += @intFromBool(bits.has_any_noalias); |
| 4649 | 4649 | extra_index += extra.data.body_len; |
| 4650 | extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).Struct.fields.len; | |
| 4650 | extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).@"struct".fields.len; | |
| 4651 | 4651 | return @bitCast([4]u32{ |
| 4652 | 4652 | zir.extra[extra_index + 0], |
| 4653 | 4653 | zir.extra[extra_index + 1], |
lib/std/zig/c_translation.zig+59-59| ... | ... | @@ -9,60 +9,60 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { |
| 9 | 9 | // this function should behave like transCCast in translate-c, except it's for macros |
| 10 | 10 | const SourceType = @TypeOf(target); |
| 11 | 11 | switch (@typeInfo(DestType)) { |
| 12 | .Fn => return castToPtr(*const DestType, SourceType, target), | |
| 13 | .Pointer => return castToPtr(DestType, SourceType, target), | |
| 14 | .Optional => |dest_opt| { | |
| 15 | if (@typeInfo(dest_opt.child) == .Pointer) { | |
| 12 | .@"fn" => return castToPtr(*const DestType, SourceType, target), | |
| 13 | .pointer => return castToPtr(DestType, SourceType, target), | |
| 14 | .optional => |dest_opt| { | |
| 15 | if (@typeInfo(dest_opt.child) == .pointer) { | |
| 16 | 16 | return castToPtr(DestType, SourceType, target); |
| 17 | } else if (@typeInfo(dest_opt.child) == .Fn) { | |
| 17 | } else if (@typeInfo(dest_opt.child) == .@"fn") { | |
| 18 | 18 | return castToPtr(?*const dest_opt.child, SourceType, target); |
| 19 | 19 | } |
| 20 | 20 | }, |
| 21 | .Int => { | |
| 21 | .int => { | |
| 22 | 22 | switch (@typeInfo(SourceType)) { |
| 23 | .Pointer => { | |
| 23 | .pointer => { | |
| 24 | 24 | return castInt(DestType, @intFromPtr(target)); |
| 25 | 25 | }, |
| 26 | .Optional => |opt| { | |
| 27 | if (@typeInfo(opt.child) == .Pointer) { | |
| 26 | .optional => |opt| { | |
| 27 | if (@typeInfo(opt.child) == .pointer) { | |
| 28 | 28 | return castInt(DestType, @intFromPtr(target)); |
| 29 | 29 | } |
| 30 | 30 | }, |
| 31 | .Int => { | |
| 31 | .int => { | |
| 32 | 32 | return castInt(DestType, target); |
| 33 | 33 | }, |
| 34 | .Fn => { | |
| 34 | .@"fn" => { | |
| 35 | 35 | return castInt(DestType, @intFromPtr(&target)); |
| 36 | 36 | }, |
| 37 | .Bool => { | |
| 37 | .bool => { | |
| 38 | 38 | return @intFromBool(target); |
| 39 | 39 | }, |
| 40 | 40 | else => {}, |
| 41 | 41 | } |
| 42 | 42 | }, |
| 43 | .Float => { | |
| 43 | .float => { | |
| 44 | 44 | switch (@typeInfo(SourceType)) { |
| 45 | .Int => return @as(DestType, @floatFromInt(target)), | |
| 46 | .Float => return @as(DestType, @floatCast(target)), | |
| 47 | .Bool => return @as(DestType, @floatFromInt(@intFromBool(target))), | |
| 45 | .int => return @as(DestType, @floatFromInt(target)), | |
| 46 | .float => return @as(DestType, @floatCast(target)), | |
| 47 | .bool => return @as(DestType, @floatFromInt(@intFromBool(target))), | |
| 48 | 48 | else => {}, |
| 49 | 49 | } |
| 50 | 50 | }, |
| 51 | .Union => |info| { | |
| 51 | .@"union" => |info| { | |
| 52 | 52 | inline for (info.fields) |field| { |
| 53 | 53 | if (field.type == SourceType) return @unionInit(DestType, field.name, target); |
| 54 | 54 | } |
| 55 | 55 | @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union"); |
| 56 | 56 | }, |
| 57 | .Bool => return cast(usize, target) != 0, | |
| 57 | .bool => return cast(usize, target) != 0, | |
| 58 | 58 | else => {}, |
| 59 | 59 | } |
| 60 | 60 | return @as(DestType, target); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | fn castInt(comptime DestType: type, target: anytype) DestType { |
| 64 | const dest = @typeInfo(DestType).Int; | |
| 65 | const source = @typeInfo(@TypeOf(target)).Int; | |
| 64 | const dest = @typeInfo(DestType).int; | |
| 65 | const source = @typeInfo(@TypeOf(target)).int; | |
| 66 | 66 | |
| 67 | 67 | if (dest.bits < source.bits) |
| 68 | 68 | return @as(DestType, @bitCast(@as(std.meta.Int(source.signedness, dest.bits), @truncate(target)))) |
| ... | ... | @@ -76,20 +76,20 @@ fn castPtr(comptime DestType: type, target: anytype) DestType { |
| 76 | 76 | |
| 77 | 77 | fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType { |
| 78 | 78 | switch (@typeInfo(SourceType)) { |
| 79 | .Int => { | |
| 79 | .int => { | |
| 80 | 80 | return @as(DestType, @ptrFromInt(castInt(usize, target))); |
| 81 | 81 | }, |
| 82 | .ComptimeInt => { | |
| 82 | .comptime_int => { | |
| 83 | 83 | if (target < 0) |
| 84 | 84 | return @as(DestType, @ptrFromInt(@as(usize, @bitCast(@as(isize, @intCast(target)))))) |
| 85 | 85 | else |
| 86 | 86 | return @as(DestType, @ptrFromInt(@as(usize, @intCast(target)))); |
| 87 | 87 | }, |
| 88 | .Pointer => { | |
| 88 | .pointer => { | |
| 89 | 89 | return castPtr(DestType, target); |
| 90 | 90 | }, |
| 91 | .Optional => |target_opt| { | |
| 92 | if (@typeInfo(target_opt.child) == .Pointer) { | |
| 91 | .optional => |target_opt| { | |
| 92 | if (@typeInfo(target_opt.child) == .pointer) { | |
| 93 | 93 | return castPtr(DestType, target); |
| 94 | 94 | } |
| 95 | 95 | }, |
| ... | ... | @@ -100,8 +100,8 @@ fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype |
| 100 | 100 | |
| 101 | 101 | fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer { |
| 102 | 102 | return switch (@typeInfo(PtrType)) { |
| 103 | .Optional => |opt_info| @typeInfo(opt_info.child).Pointer, | |
| 104 | .Pointer => |ptr_info| ptr_info, | |
| 103 | .optional => |opt_info| @typeInfo(opt_info.child).pointer, | |
| 104 | .pointer => |ptr_info| ptr_info, | |
| 105 | 105 | else => unreachable, |
| 106 | 106 | }; |
| 107 | 107 | } |
| ... | ... | @@ -144,17 +144,17 @@ test "cast" { |
| 144 | 144 | pub fn sizeof(target: anytype) usize { |
| 145 | 145 | const T: type = if (@TypeOf(target) == type) target else @TypeOf(target); |
| 146 | 146 | switch (@typeInfo(T)) { |
| 147 | .Float, .Int, .Struct, .Union, .Array, .Bool, .Vector => return @sizeOf(T), | |
| 148 | .Fn => { | |
| 147 | .float, .int, .@"struct", .@"union", .array, .bool, .vector => return @sizeOf(T), | |
| 148 | .@"fn" => { | |
| 149 | 149 | // sizeof(main) in C returns 1 |
| 150 | 150 | return 1; |
| 151 | 151 | }, |
| 152 | .Null => return @sizeOf(*anyopaque), | |
| 153 | .Void => { | |
| 152 | .null => return @sizeOf(*anyopaque), | |
| 153 | .void => { | |
| 154 | 154 | // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. |
| 155 | 155 | return 1; |
| 156 | 156 | }, |
| 157 | .Opaque => { | |
| 157 | .@"opaque" => { | |
| 158 | 158 | if (T == anyopaque) { |
| 159 | 159 | // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. |
| 160 | 160 | return 1; |
| ... | ... | @@ -162,24 +162,24 @@ pub fn sizeof(target: anytype) usize { |
| 162 | 162 | @compileError("Cannot use C sizeof on opaque type " ++ @typeName(T)); |
| 163 | 163 | } |
| 164 | 164 | }, |
| 165 | .Optional => |opt| { | |
| 166 | if (@typeInfo(opt.child) == .Pointer) { | |
| 165 | .optional => |opt| { | |
| 166 | if (@typeInfo(opt.child) == .pointer) { | |
| 167 | 167 | return sizeof(opt.child); |
| 168 | 168 | } else { |
| 169 | 169 | @compileError("Cannot use C sizeof on non-pointer optional " ++ @typeName(T)); |
| 170 | 170 | } |
| 171 | 171 | }, |
| 172 | .Pointer => |ptr| { | |
| 172 | .pointer => |ptr| { | |
| 173 | 173 | if (ptr.size == .Slice) { |
| 174 | 174 | @compileError("Cannot use C sizeof on slice type " ++ @typeName(T)); |
| 175 | 175 | } |
| 176 | 176 | // for strings, sizeof("a") returns 2. |
| 177 | 177 | // normal pointer decay scenarios from C are handled |
| 178 | // in the .Array case above, but strings remain literals | |
| 178 | // in the .array case above, but strings remain literals | |
| 179 | 179 | // and are therefore always pointers, so they need to be |
| 180 | 180 | // specially handled here. |
| 181 | if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .Array) { | |
| 182 | const array_info = @typeInfo(ptr.child).Array; | |
| 181 | if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) { | |
| 182 | const array_info = @typeInfo(ptr.child).array; | |
| 183 | 183 | if ((array_info.child == u8 or array_info.child == u16) and |
| 184 | 184 | array_info.sentinel != null and |
| 185 | 185 | @as(*align(1) const array_info.child, @ptrCast(array_info.sentinel.?)).* == 0) |
| ... | ... | @@ -195,8 +195,8 @@ pub fn sizeof(target: anytype) usize { |
| 195 | 195 | } |
| 196 | 196 | return @sizeOf(T); |
| 197 | 197 | }, |
| 198 | .ComptimeFloat => return @sizeOf(f64), // TODO c_double #3999 | |
| 199 | .ComptimeInt => { | |
| 198 | .comptime_float => return @sizeOf(f64), // TODO c_double #3999 | |
| 199 | .comptime_int => { | |
| 200 | 200 | // TODO to get the correct result we have to translate |
| 201 | 201 | // `1073741824 * 4` as `int(1073741824) *% int(4)` since |
| 202 | 202 | // sizeof(1073741824 * 4) != sizeof(4294967296). |
| ... | ... | @@ -262,7 +262,7 @@ fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: compt |
| 262 | 262 | const signed_oct_hex = [_]type{ c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong }; |
| 263 | 263 | const unsigned = [_]type{ c_uint, c_ulong, c_ulonglong }; |
| 264 | 264 | |
| 265 | const list: []const type = if (@typeInfo(SuffixType).Int.signedness == .unsigned) | |
| 265 | const list: []const type = if (@typeInfo(SuffixType).int.signedness == .unsigned) | |
| 266 | 266 | &unsigned |
| 267 | 267 | else if (base == .decimal) |
| 268 | 268 | &signed_decimal |
| ... | ... | @@ -339,8 +339,8 @@ test "shuffleVectorIndex" { |
| 339 | 339 | /// from SelfType for pointing to a C flexible array of ElementType. |
| 340 | 340 | pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type { |
| 341 | 341 | switch (@typeInfo(SelfType)) { |
| 342 | .Pointer => |ptr| { | |
| 343 | return @Type(.{ .Pointer = .{ | |
| 342 | .pointer => |ptr| { | |
| 343 | return @Type(.{ .pointer = .{ | |
| 344 | 344 | .size = .C, |
| 345 | 345 | .is_const = ptr.is_const, |
| 346 | 346 | .is_volatile = ptr.is_volatile, |
| ... | ... | @@ -372,7 +372,7 @@ test "Flexible Array Type" { |
| 372 | 372 | /// the type and denominator is -1. C has undefined behavior for those two cases; this function has safety |
| 373 | 373 | /// checked undefined behavior |
| 374 | 374 | pub fn signedRemainder(numerator: anytype, denominator: anytype) @TypeOf(numerator, denominator) { |
| 375 | std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).Int.signedness == .signed); | |
| 375 | std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).int.signedness == .signed); | |
| 376 | 376 | if (denominator > 0) return @rem(numerator, denominator); |
| 377 | 377 | return numerator - @divTrunc(numerator, denominator) * denominator; |
| 378 | 378 | } |
| ... | ... | @@ -384,15 +384,15 @@ pub const Macros = struct { |
| 384 | 384 | |
| 385 | 385 | fn L_SUFFIX_ReturnType(comptime number: anytype) type { |
| 386 | 386 | switch (@typeInfo(@TypeOf(number))) { |
| 387 | .Int, .ComptimeInt => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)), | |
| 388 | .Float, .ComptimeFloat => return c_longdouble, | |
| 387 | .int, .comptime_int => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)), | |
| 388 | .float, .comptime_float => return c_longdouble, | |
| 389 | 389 | else => @compileError("Invalid value for L suffix"), |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | pub fn L_SUFFIX(comptime number: anytype) L_SUFFIX_ReturnType(number) { |
| 393 | 393 | switch (@typeInfo(@TypeOf(number))) { |
| 394 | .Int, .ComptimeInt => return promoteIntLiteral(c_long, number, .decimal), | |
| 395 | .Float, .ComptimeFloat => @compileError("TODO: c_longdouble initialization from comptime_float not supported"), | |
| 394 | .int, .comptime_int => return promoteIntLiteral(c_long, number, .decimal), | |
| 395 | .float, .comptime_float => @compileError("TODO: c_longdouble initialization from comptime_float not supported"), | |
| 396 | 396 | else => @compileError("Invalid value for L suffix"), |
| 397 | 397 | } |
| 398 | 398 | } |
| ... | ... | @@ -420,13 +420,13 @@ pub const Macros = struct { |
| 420 | 420 | /// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B) |
| 421 | 421 | /// could be either: cast B to A, or call A with the value B. |
| 422 | 422 | pub fn CAST_OR_CALL(a: anytype, b: anytype) switch (@typeInfo(@TypeOf(a))) { |
| 423 | .Type => a, | |
| 424 | .Fn => |fn_info| fn_info.return_type orelse void, | |
| 423 | .type => a, | |
| 424 | .@"fn" => |fn_info| fn_info.return_type orelse void, | |
| 425 | 425 | else => |info| @compileError("Unexpected argument type: " ++ @tagName(info)), |
| 426 | 426 | } { |
| 427 | 427 | switch (@typeInfo(@TypeOf(a))) { |
| 428 | .Type => return cast(a, b), | |
| 429 | .Fn => return a(b), | |
| 428 | .type => return cast(a, b), | |
| 429 | .@"fn" => return a(b), | |
| 430 | 430 | else => unreachable, // return type will be a compile error otherwise |
| 431 | 431 | } |
| 432 | 432 | } |
| ... | ... | @@ -444,7 +444,7 @@ fn PromotedIntType(comptime T: type) type { |
| 444 | 444 | c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong => T, |
| 445 | 445 | else => if (T == comptime_int) { |
| 446 | 446 | @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a fixed-size number type is required"); |
| 447 | } else if (@typeInfo(T) == .Int) { | |
| 447 | } else if (@typeInfo(T) == .int) { | |
| 448 | 448 | @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a C ABI type is required"); |
| 449 | 449 | } else { |
| 450 | 450 | @compileError("Attempted to promote invalid type `" ++ @typeName(T) ++ "`"); |
| ... | ... | @@ -490,8 +490,8 @@ fn ArithmeticConversion(comptime A: type, comptime B: type) type { |
| 490 | 490 | |
| 491 | 491 | if (A_Promoted == B_Promoted) return A_Promoted; |
| 492 | 492 | |
| 493 | const a_signed = @typeInfo(A_Promoted).Int.signedness == .signed; | |
| 494 | const b_signed = @typeInfo(B_Promoted).Int.signedness == .signed; | |
| 493 | const a_signed = @typeInfo(A_Promoted).int.signedness == .signed; | |
| 494 | const b_signed = @typeInfo(B_Promoted).int.signedness == .signed; | |
| 495 | 495 | |
| 496 | 496 | if (a_signed == b_signed) { |
| 497 | 497 | return if (integerRank(A_Promoted) > integerRank(B_Promoted)) A_Promoted else B_Promoted; |
| ... | ... | @@ -544,8 +544,8 @@ pub const MacroArithmetic = struct { |
| 544 | 544 | const a_casted = cast(ResType, a); |
| 545 | 545 | const b_casted = cast(ResType, b); |
| 546 | 546 | switch (@typeInfo(ResType)) { |
| 547 | .Float => return a_casted / b_casted, | |
| 548 | .Int => return @divTrunc(a_casted, b_casted), | |
| 547 | .float => return a_casted / b_casted, | |
| 548 | .int => return @divTrunc(a_casted, b_casted), | |
| 549 | 549 | else => unreachable, |
| 550 | 550 | } |
| 551 | 551 | } |
| ... | ... | @@ -555,8 +555,8 @@ pub const MacroArithmetic = struct { |
| 555 | 555 | const a_casted = cast(ResType, a); |
| 556 | 556 | const b_casted = cast(ResType, b); |
| 557 | 557 | switch (@typeInfo(ResType)) { |
| 558 | .Int => { | |
| 559 | if (@typeInfo(ResType).Int.signedness == .signed) { | |
| 558 | .int => { | |
| 559 | if (@typeInfo(ResType).int.signedness == .signed) { | |
| 560 | 560 | return signedRemainder(a_casted, b_casted); |
| 561 | 561 | } else { |
| 562 | 562 | return a_casted % b_casted; |
lib/std/zig/parser_test.zig+1-1| ... | ... | @@ -2548,7 +2548,7 @@ test "zig fmt: same-line comment after non-block if expression" { |
| 2548 | 2548 | test "zig fmt: same-line comment on comptime expression" { |
| 2549 | 2549 | try testCanonical( |
| 2550 | 2550 | \\test "" { |
| 2551 | \\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt | |
| 2551 | \\ comptime assert(@typeInfo(T) == .int); // must pass an integer to absInt | |
| 2552 | 2552 | \\} |
| 2553 | 2553 | \\ |
| 2554 | 2554 | ); |
lib/std/zig/system/windows.zig+2-2| ... | ... | @@ -56,11 +56,11 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void { |
| 56 | 56 | const ArgsType = @TypeOf(args); |
| 57 | 57 | const args_type_info = @typeInfo(ArgsType); |
| 58 | 58 | |
| 59 | if (args_type_info != .Struct) { | |
| 59 | if (args_type_info != .@"struct") { | |
| 60 | 60 | @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType)); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | const fields_info = args_type_info.Struct.fields; | |
| 63 | const fields_info = args_type_info.@"struct".fields; | |
| 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 |
src/Air/types_resolved.zig+25-25| ... | ... | @@ -272,7 +272,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool { |
| 272 | 272 | const elems_len: usize = @intCast(ty.arrayLen(zcu)); |
| 273 | 273 | const elems: []const Air.Inst.Ref = @ptrCast(air.extra[data.ty_pl.payload..][0..elems_len]); |
| 274 | 274 | if (!checkType(ty, zcu)) return false; |
| 275 | if (ty.zigTypeTag(zcu) == .Struct) { | |
| 275 | if (ty.zigTypeTag(zcu) == .@"struct") { | |
| 276 | 276 | for (elems, 0..) |elem, elem_idx| { |
| 277 | 277 | if (ty.structFieldIsComptime(elem_idx, zcu)) continue; |
| 278 | 278 | if (!checkRef(elem, zcu)) return false; |
| ... | ... | @@ -453,35 +453,35 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool { |
| 453 | 453 | return switch (ty.zigTypeTagOrPoison(zcu) catch |err| switch (err) { |
| 454 | 454 | error.GenericPoison => return true, |
| 455 | 455 | }) { |
| 456 | .Type, | |
| 457 | .Void, | |
| 458 | .Bool, | |
| 459 | .NoReturn, | |
| 460 | .Int, | |
| 461 | .Float, | |
| 462 | .ErrorSet, | |
| 463 | .Enum, | |
| 464 | .Opaque, | |
| 465 | .Vector, | |
| 456 | .type, | |
| 457 | .void, | |
| 458 | .bool, | |
| 459 | .noreturn, | |
| 460 | .int, | |
| 461 | .float, | |
| 462 | .error_set, | |
| 463 | .@"enum", | |
| 464 | .@"opaque", | |
| 465 | .vector, | |
| 466 | 466 | // These types can appear due to some dummy instructions Sema introduces and expects to be omitted by Liveness. |
| 467 | 467 | // It's a little silly -- but fine, we'll return `true`. |
| 468 | .ComptimeFloat, | |
| 469 | .ComptimeInt, | |
| 470 | .Undefined, | |
| 471 | .Null, | |
| 472 | .EnumLiteral, | |
| 468 | .comptime_float, | |
| 469 | .comptime_int, | |
| 470 | .undefined, | |
| 471 | .null, | |
| 472 | .enum_literal, | |
| 473 | 473 | => true, |
| 474 | 474 | |
| 475 | .Frame, | |
| 476 | .AnyFrame, | |
| 475 | .frame, | |
| 476 | .@"anyframe", | |
| 477 | 477 | => @panic("TODO Air.types_resolved.checkType async frames"), |
| 478 | 478 | |
| 479 | .Optional => checkType(ty.childType(zcu), zcu), | |
| 480 | .ErrorUnion => checkType(ty.errorUnionPayload(zcu), zcu), | |
| 481 | .Pointer => checkType(ty.childType(zcu), zcu), | |
| 482 | .Array => checkType(ty.childType(zcu), zcu), | |
| 479 | .optional => checkType(ty.childType(zcu), zcu), | |
| 480 | .error_union => checkType(ty.errorUnionPayload(zcu), zcu), | |
| 481 | .pointer => checkType(ty.childType(zcu), zcu), | |
| 482 | .array => checkType(ty.childType(zcu), zcu), | |
| 483 | 483 | |
| 484 | .Fn => { | |
| 484 | .@"fn" => { | |
| 485 | 485 | const info = zcu.typeToFunc(ty).?; |
| 486 | 486 | for (0..info.param_types.len) |i| { |
| 487 | 487 | const param_ty = info.param_types.get(ip)[i]; |
| ... | ... | @@ -489,7 +489,7 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool { |
| 489 | 489 | } |
| 490 | 490 | return checkType(Type.fromInterned(info.return_type), zcu); |
| 491 | 491 | }, |
| 492 | .Struct => switch (ip.indexToKey(ty.toIntern())) { | |
| 492 | .@"struct" => switch (ip.indexToKey(ty.toIntern())) { | |
| 493 | 493 | .struct_type => { |
| 494 | 494 | const struct_obj = zcu.typeToStruct(ty).?; |
| 495 | 495 | return switch (struct_obj.layout) { |
| ... | ... | @@ -508,6 +508,6 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool { |
| 508 | 508 | }, |
| 509 | 509 | else => unreachable, |
| 510 | 510 | }, |
| 511 | .Union => return zcu.typeToUnion(ty).?.flagsUnordered(ip).status == .fully_resolved, | |
| 511 | .@"union" => return zcu.typeToUnion(ty).?.flagsUnordered(ip).status == .fully_resolved, | |
| 512 | 512 | }; |
| 513 | 513 | } |
src/Compilation.zig+5-5| ... | ... | @@ -384,7 +384,7 @@ const Job = union(enum) { |
| 384 | 384 | /// The value is the index into `system_libs`. |
| 385 | 385 | windows_import_lib: usize, |
| 386 | 386 | |
| 387 | const Tag = @typeInfo(Job).Union.tag_type.?; | |
| 387 | const Tag = @typeInfo(Job).@"union".tag_type.?; | |
| 388 | 388 | fn stage(tag: Tag) usize { |
| 389 | 389 | return switch (tag) { |
| 390 | 390 | // Prioritize functions so that codegen can get to work on them on a |
| ... | ... | @@ -911,7 +911,7 @@ pub const cache_helpers = struct { |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | pub fn addDebugFormat(hh: *Cache.HashHelper, x: Config.DebugFormat) void { |
| 914 | const tag: @typeInfo(Config.DebugFormat).Union.tag_type.? = x; | |
| 914 | const tag: @typeInfo(Config.DebugFormat).@"union".tag_type.? = x; | |
| 915 | 915 | hh.add(tag); |
| 916 | 916 | switch (x) { |
| 917 | 917 | .strip, .code_view => {}, |
| ... | ... | @@ -1486,7 +1486,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1486 | 1486 | .emit_asm = options.emit_asm, |
| 1487 | 1487 | .emit_llvm_ir = options.emit_llvm_ir, |
| 1488 | 1488 | .emit_llvm_bc = options.emit_llvm_bc, |
| 1489 | .work_queues = .{std.fifo.LinearFifo(Job, .Dynamic).init(gpa)} ** @typeInfo(std.meta.FieldType(Compilation, .work_queues)).Array.len, | |
| 1489 | .work_queues = .{std.fifo.LinearFifo(Job, .Dynamic).init(gpa)} ** @typeInfo(std.meta.FieldType(Compilation, .work_queues)).array.len, | |
| 1490 | 1490 | .codegen_work = if (InternPool.single_threaded) {} else .{ |
| 1491 | 1491 | .mutex = .{}, |
| 1492 | 1492 | .cond = .{}, |
| ... | ... | @@ -3113,8 +3113,8 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3113 | 3113 | err: *?Error, |
| 3114 | 3114 | |
| 3115 | 3115 | const Error = @typeInfo( |
| 3116 | @typeInfo(@TypeOf(Zcu.SrcLoc.span)).Fn.return_type.?, | |
| 3117 | ).ErrorUnion.error_set; | |
| 3116 | @typeInfo(@TypeOf(Zcu.SrcLoc.span)).@"fn".return_type.?, | |
| 3117 | ).error_union.error_set; | |
| 3118 | 3118 | |
| 3119 | 3119 | pub fn lessThan(ctx: @This(), lhs_index: usize, rhs_index: usize) bool { |
| 3120 | 3120 | if (ctx.err.*) |_| return lhs_index < rhs_index; |
src/InternPool.zig+93-93| ... | ... | @@ -893,7 +893,7 @@ const Local = struct { |
| 893 | 893 | }; |
| 894 | 894 | |
| 895 | 895 | fn List(comptime Elem: type) type { |
| 896 | assert(@typeInfo(Elem) == .Struct); | |
| 896 | assert(@typeInfo(Elem) == .@"struct"); | |
| 897 | 897 | return struct { |
| 898 | 898 | bytes: [*]align(@alignOf(Elem)) u8, |
| 899 | 899 | |
| ... | ... | @@ -907,7 +907,7 @@ const Local = struct { |
| 907 | 907 | const fields = std.enums.values(std.meta.FieldEnum(Elem)); |
| 908 | 908 | |
| 909 | 909 | fn PtrArrayElem(comptime len: usize) type { |
| 910 | const elem_info = @typeInfo(Elem).Struct; | |
| 910 | const elem_info = @typeInfo(Elem).@"struct"; | |
| 911 | 911 | const elem_fields = elem_info.fields; |
| 912 | 912 | var new_fields: [elem_fields.len]std.builtin.Type.StructField = undefined; |
| 913 | 913 | for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{ |
| ... | ... | @@ -917,7 +917,7 @@ const Local = struct { |
| 917 | 917 | .is_comptime = false, |
| 918 | 918 | .alignment = 0, |
| 919 | 919 | }; |
| 920 | return @Type(.{ .Struct = .{ | |
| 920 | return @Type(.{ .@"struct" = .{ | |
| 921 | 921 | .layout = .auto, |
| 922 | 922 | .fields = &new_fields, |
| 923 | 923 | .decls = &.{}, |
| ... | ... | @@ -928,12 +928,12 @@ const Local = struct { |
| 928 | 928 | size: std.builtin.Type.Pointer.Size, |
| 929 | 929 | is_const: bool = false, |
| 930 | 930 | }) type { |
| 931 | const elem_info = @typeInfo(Elem).Struct; | |
| 931 | const elem_info = @typeInfo(Elem).@"struct"; | |
| 932 | 932 | const elem_fields = elem_info.fields; |
| 933 | 933 | var new_fields: [elem_fields.len]std.builtin.Type.StructField = undefined; |
| 934 | 934 | for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{ |
| 935 | 935 | .name = elem_field.name, |
| 936 | .type = @Type(.{ .Pointer = .{ | |
| 936 | .type = @Type(.{ .pointer = .{ | |
| 937 | 937 | .size = opts.size, |
| 938 | 938 | .is_const = opts.is_const, |
| 939 | 939 | .is_volatile = false, |
| ... | ... | @@ -947,7 +947,7 @@ const Local = struct { |
| 947 | 947 | .is_comptime = false, |
| 948 | 948 | .alignment = 0, |
| 949 | 949 | }; |
| 950 | return @Type(.{ .Struct = .{ | |
| 950 | return @Type(.{ .@"struct" = .{ | |
| 951 | 951 | .layout = .auto, |
| 952 | 952 | .fields = &new_fields, |
| 953 | 953 | .decls = &.{}, |
| ... | ... | @@ -1306,7 +1306,7 @@ const Shard = struct { |
| 1306 | 1306 | }; |
| 1307 | 1307 | |
| 1308 | 1308 | fn Map(comptime Value: type) type { |
| 1309 | comptime assert(@typeInfo(Value).Enum.tag_type == u32); | |
| 1309 | comptime assert(@typeInfo(Value).@"enum".tag_type == u32); | |
| 1310 | 1310 | _ = @as(Value, .none); // expected .none key |
| 1311 | 1311 | return struct { |
| 1312 | 1312 | /// header: Header, |
| ... | ... | @@ -2254,7 +2254,7 @@ pub const Key = union(enum) { |
| 2254 | 2254 | byte_offset: u64, |
| 2255 | 2255 | |
| 2256 | 2256 | pub const BaseAddr = union(enum) { |
| 2257 | const Tag = @typeInfo(BaseAddr).Union.tag_type.?; | |
| 2257 | const Tag = @typeInfo(BaseAddr).@"union".tag_type.?; | |
| 2258 | 2258 | |
| 2259 | 2259 | /// Points to the value of a single `Nav`, which may be constant or a `variable`. |
| 2260 | 2260 | nav: Nav.Index, |
| ... | ... | @@ -2411,7 +2411,7 @@ pub const Key = union(enum) { |
| 2411 | 2411 | |
| 2412 | 2412 | pub fn hash64(key: Key, ip: *const InternPool) u64 { |
| 2413 | 2413 | const asBytes = std.mem.asBytes; |
| 2414 | const KeyTag = @typeInfo(Key).Union.tag_type.?; | |
| 2414 | const KeyTag = @typeInfo(Key).@"union".tag_type.?; | |
| 2415 | 2415 | const seed = @intFromEnum(@as(KeyTag, key)); |
| 2416 | 2416 | return switch (key) { |
| 2417 | 2417 | // TODO: assert no padding in these types |
| ... | ... | @@ -2487,7 +2487,7 @@ pub const Key = union(enum) { |
| 2487 | 2487 | .lazy_align, .lazy_size => |lazy_ty| { |
| 2488 | 2488 | std.hash.autoHash( |
| 2489 | 2489 | &hasher, |
| 2490 | @as(@typeInfo(Key.Int.Storage).Union.tag_type.?, int.storage), | |
| 2490 | @as(@typeInfo(Key.Int.Storage).@"union".tag_type.?, int.storage), | |
| 2491 | 2491 | ); |
| 2492 | 2492 | std.hash.autoHash(&hasher, lazy_ty); |
| 2493 | 2493 | }, |
| ... | ... | @@ -2651,7 +2651,7 @@ pub const Key = union(enum) { |
| 2651 | 2651 | } |
| 2652 | 2652 | |
| 2653 | 2653 | pub fn eql(a: Key, b: Key, ip: *const InternPool) bool { |
| 2654 | const KeyTag = @typeInfo(Key).Union.tag_type.?; | |
| 2654 | const KeyTag = @typeInfo(Key).@"union".tag_type.?; | |
| 2655 | 2655 | const a_tag: KeyTag = a; |
| 2656 | 2656 | const b_tag: KeyTag = b; |
| 2657 | 2657 | if (a_tag != b_tag) return false; |
| ... | ... | @@ -2861,7 +2861,7 @@ pub const Key = union(enum) { |
| 2861 | 2861 | return a_val == b_val; |
| 2862 | 2862 | } |
| 2863 | 2863 | |
| 2864 | const StorageTag = @typeInfo(Key.Float.Storage).Union.tag_type.?; | |
| 2864 | const StorageTag = @typeInfo(Key.Float.Storage).@"union".tag_type.?; | |
| 2865 | 2865 | assert(@as(StorageTag, a_info.storage) == @as(StorageTag, b_info.storage)); |
| 2866 | 2866 | |
| 2867 | 2867 | switch (a_info.storage) { |
| ... | ... | @@ -2905,7 +2905,7 @@ pub const Key = union(enum) { |
| 2905 | 2905 | if (a_info.ty != b_info.ty) return false; |
| 2906 | 2906 | |
| 2907 | 2907 | const len = ip.aggregateTypeLen(a_info.ty); |
| 2908 | const StorageTag = @typeInfo(Key.Aggregate.Storage).Union.tag_type.?; | |
| 2908 | const StorageTag = @typeInfo(Key.Aggregate.Storage).@"union".tag_type.?; | |
| 2909 | 2909 | if (@as(StorageTag, a_info.storage) != @as(StorageTag, b_info.storage)) { |
| 2910 | 2910 | for (0..@intCast(len)) |elem_index| { |
| 2911 | 2911 | const a_elem = switch (a_info.storage) { |
| ... | ... | @@ -4000,7 +4000,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 4000 | 4000 | const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]); |
| 4001 | 4001 | const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "fields_len").?]; |
| 4002 | 4002 | const flags: Tag.TypeStruct.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "flags").?], .unordered)); |
| 4003 | var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStruct).Struct.fields.len); | |
| 4003 | var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStruct).@"struct".fields.len); | |
| 4004 | 4004 | const captures_len = if (flags.any_captures) c: { |
| 4005 | 4005 | const len = extra_list.view().items(.@"0")[extra_index]; |
| 4006 | 4006 | extra_index += 1; |
| ... | ... | @@ -4105,7 +4105,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 4105 | 4105 | const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?]); |
| 4106 | 4106 | const names_map: MapIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "names_map").?]); |
| 4107 | 4107 | const flags: Tag.TypeStructPacked.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?], .unordered)); |
| 4108 | var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStructPacked).Struct.fields.len); | |
| 4108 | var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStructPacked).@"struct".fields.len); | |
| 4109 | 4109 | const has_inits = item.tag == .type_struct_packed_inits; |
| 4110 | 4110 | const captures_len = if (flags.any_captures) c: { |
| 4111 | 4111 | const len = extra_list.view().items(.@"0")[extra_index]; |
| ... | ... | @@ -4711,9 +4711,9 @@ pub const Index = enum(u32) { |
| 4711 | 4711 | }, |
| 4712 | 4712 | }) void { |
| 4713 | 4713 | _ = self; |
| 4714 | const map_fields = @typeInfo(@typeInfo(@TypeOf(tag_to_encoding_map)).Pointer.child).Struct.fields; | |
| 4714 | const map_fields = @typeInfo(@typeInfo(@TypeOf(tag_to_encoding_map)).pointer.child).@"struct".fields; | |
| 4715 | 4715 | @setEvalBranchQuota(2_000); |
| 4716 | inline for (@typeInfo(Tag).Enum.fields, 0..) |tag, start| { | |
| 4716 | inline for (@typeInfo(Tag).@"enum".fields, 0..) |tag, start| { | |
| 4717 | 4717 | inline for (0..map_fields.len) |offset| { |
| 4718 | 4718 | if (comptime std.mem.eql(u8, tag.name, map_fields[(start + offset) % map_fields.len].name)) break; |
| 4719 | 4719 | } else { |
| ... | ... | @@ -6384,7 +6384,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { |
| 6384 | 6384 | const extra_items = extra_list.view().items(.@"0"); |
| 6385 | 6385 | const zir_index: TrackedInst.Index = @enumFromInt(extra_items[data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]); |
| 6386 | 6386 | const flags: Tag.TypeStruct.Flags = @bitCast(@atomicLoad(u32, &extra_items[data + std.meta.fieldIndex(Tag.TypeStruct, "flags").?], .unordered)); |
| 6387 | const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStruct).Struct.fields.len); | |
| 6387 | const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStruct).@"struct".fields.len); | |
| 6388 | 6388 | if (flags.is_reified) { |
| 6389 | 6389 | assert(!flags.any_captures); |
| 6390 | 6390 | break :ns .{ .reified = .{ |
| ... | ... | @@ -6407,7 +6407,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { |
| 6407 | 6407 | const extra_items = extra_list.view().items(.@"0"); |
| 6408 | 6408 | const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "zir_index").?]); |
| 6409 | 6409 | const flags: Tag.TypeStructPacked.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?], .unordered)); |
| 6410 | const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStructPacked).Struct.fields.len); | |
| 6410 | const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStructPacked).@"struct".fields.len); | |
| 6411 | 6411 | if (flags.is_reified) { |
| 6412 | 6412 | assert(!flags.any_captures); |
| 6413 | 6413 | break :ns .{ .reified = .{ |
| ... | ... | @@ -6922,7 +6922,7 @@ fn extraFuncInstance(ip: *const InternPool, tid: Zcu.PerThread.Id, extra: Local. |
| 6922 | 6922 | const ty: Index = @enumFromInt(extra_items[extra_index + std.meta.fieldIndex(Tag.FuncInstance, "ty").?]); |
| 6923 | 6923 | const generic_owner: Index = @enumFromInt(extra_items[extra_index + std.meta.fieldIndex(Tag.FuncInstance, "generic_owner").?]); |
| 6924 | 6924 | const func_decl = ip.funcDeclInfo(generic_owner); |
| 6925 | const end_extra_index = extra_index + @as(u32, @typeInfo(Tag.FuncInstance).Struct.fields.len); | |
| 6925 | const end_extra_index = extra_index + @as(u32, @typeInfo(Tag.FuncInstance).@"struct".fields.len); | |
| 6926 | 6926 | return .{ |
| 6927 | 6927 | .tid = tid, |
| 6928 | 6928 | .ty = ty, |
| ... | ... | @@ -7288,7 +7288,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7288 | 7288 | const names_map = try ip.addMap(gpa, tid, names.len); |
| 7289 | 7289 | ip.addStringsToMap(names_map, names); |
| 7290 | 7290 | const names_len = error_set_type.names.len; |
| 7291 | try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).Struct.fields.len + names_len); | |
| 7291 | try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).@"struct".fields.len + names_len); | |
| 7292 | 7292 | items.appendAssumeCapacity(.{ |
| 7293 | 7293 | .tag = .type_error_set, |
| 7294 | 7294 | .data = addExtraAssumeCapacity(extra, Tag.ErrorSet{ |
| ... | ... | @@ -7883,7 +7883,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7883 | 7883 | .repeated_elem => |elem| elem, |
| 7884 | 7884 | }; |
| 7885 | 7885 | |
| 7886 | try extra.ensureUnusedCapacity(@typeInfo(Repeated).Struct.fields.len); | |
| 7886 | try extra.ensureUnusedCapacity(@typeInfo(Repeated).@"struct".fields.len); | |
| 7887 | 7887 | items.appendAssumeCapacity(.{ |
| 7888 | 7888 | .tag = .repeated, |
| 7889 | 7889 | .data = addExtraAssumeCapacity(extra, Repeated{ |
| ... | ... | @@ -7898,7 +7898,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7898 | 7898 | const strings = ip.getLocal(tid).getMutableStrings(gpa); |
| 7899 | 7899 | const start = strings.mutate.len; |
| 7900 | 7900 | try strings.ensureUnusedCapacity(@intCast(len_including_sentinel + 1)); |
| 7901 | try extra.ensureUnusedCapacity(@typeInfo(Bytes).Struct.fields.len); | |
| 7901 | try extra.ensureUnusedCapacity(@typeInfo(Bytes).@"struct".fields.len); | |
| 7902 | 7902 | switch (aggregate.storage) { |
| 7903 | 7903 | .bytes => |bytes| strings.appendSliceAssumeCapacity(.{bytes.toSlice(len, ip)}), |
| 7904 | 7904 | .elems => |elems| for (elems[0..@intCast(len)]) |elem| switch (ip.indexToKey(elem)) { |
| ... | ... | @@ -7938,7 +7938,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7938 | 7938 | } |
| 7939 | 7939 | |
| 7940 | 7940 | try extra.ensureUnusedCapacity( |
| 7941 | @typeInfo(Tag.Aggregate).Struct.fields.len + @as(usize, @intCast(len_including_sentinel + 1)), | |
| 7941 | @typeInfo(Tag.Aggregate).@"struct".fields.len + @as(usize, @intCast(len_including_sentinel + 1)), | |
| 7942 | 7942 | ); |
| 7943 | 7943 | items.appendAssumeCapacity(.{ |
| 7944 | 7944 | .tag = .aggregate, |
| ... | ... | @@ -7961,7 +7961,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7961 | 7961 | |
| 7962 | 7962 | .memoized_call => |memoized_call| { |
| 7963 | 7963 | for (memoized_call.arg_values) |arg| assert(arg != .none); |
| 7964 | try extra.ensureUnusedCapacity(@typeInfo(MemoizedCall).Struct.fields.len + | |
| 7964 | try extra.ensureUnusedCapacity(@typeInfo(MemoizedCall).@"struct".fields.len + | |
| 7965 | 7965 | memoized_call.arg_values.len); |
| 7966 | 7966 | items.appendAssumeCapacity(.{ |
| 7967 | 7967 | .tag = .memoized_call, |
| ... | ... | @@ -8050,7 +8050,7 @@ pub fn getUnionType( |
| 8050 | 8050 | |
| 8051 | 8051 | const align_elements_len = if (ini.flags.any_aligned_fields) (ini.fields_len + 3) / 4 else 0; |
| 8052 | 8052 | const align_element: u32 = @bitCast([1]u8{@intFromEnum(Alignment.none)} ** 4); |
| 8053 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeUnion).Struct.fields.len + | |
| 8053 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeUnion).@"struct".fields.len + | |
| 8054 | 8054 | // TODO: fmt bug |
| 8055 | 8055 | // zig fmt: off |
| 8056 | 8056 | switch (ini.key) { |
| ... | ... | @@ -8259,7 +8259,7 @@ pub fn getStructType( |
| 8259 | 8259 | .auto => false, |
| 8260 | 8260 | .@"extern" => true, |
| 8261 | 8261 | .@"packed" => { |
| 8262 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStructPacked).Struct.fields.len + | |
| 8262 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStructPacked).@"struct".fields.len + | |
| 8263 | 8263 | // TODO: fmt bug |
| 8264 | 8264 | // zig fmt: off |
| 8265 | 8265 | switch (ini.key) { |
| ... | ... | @@ -8327,7 +8327,7 @@ pub fn getStructType( |
| 8327 | 8327 | const align_element: u32 = @bitCast([1]u8{@intFromEnum(Alignment.none)} ** 4); |
| 8328 | 8328 | const comptime_elements_len = if (ini.any_comptime_fields) (ini.fields_len + 31) / 32 else 0; |
| 8329 | 8329 | |
| 8330 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStruct).Struct.fields.len + | |
| 8330 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStruct).@"struct".fields.len + | |
| 8331 | 8331 | // TODO: fmt bug |
| 8332 | 8332 | // zig fmt: off |
| 8333 | 8333 | switch (ini.key) { |
| ... | ... | @@ -8443,7 +8443,7 @@ pub fn getAnonStructType( |
| 8443 | 8443 | |
| 8444 | 8444 | try items.ensureUnusedCapacity(1); |
| 8445 | 8445 | try extra.ensureUnusedCapacity( |
| 8446 | @typeInfo(TypeStructAnon).Struct.fields.len + (fields_len * 3), | |
| 8446 | @typeInfo(TypeStructAnon).@"struct".fields.len + (fields_len * 3), | |
| 8447 | 8447 | ); |
| 8448 | 8448 | |
| 8449 | 8449 | const extra_index = addExtraAssumeCapacity(extra, TypeStructAnon{ |
| ... | ... | @@ -8509,7 +8509,7 @@ pub fn getFuncType( |
| 8509 | 8509 | const prev_extra_len = extra.mutate.len; |
| 8510 | 8510 | const params_len: u32 = @intCast(key.param_types.len); |
| 8511 | 8511 | |
| 8512 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeFunction).Struct.fields.len + | |
| 8512 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeFunction).@"struct".fields.len + | |
| 8513 | 8513 | @intFromBool(key.comptime_bits != 0) + |
| 8514 | 8514 | @intFromBool(key.noalias_bits != 0) + |
| 8515 | 8515 | params_len); |
| ... | ... | @@ -8575,7 +8575,7 @@ pub fn getExtern( |
| 8575 | 8575 | const items = local.getMutableItems(gpa); |
| 8576 | 8576 | const extra = local.getMutableExtra(gpa); |
| 8577 | 8577 | try items.ensureUnusedCapacity(1); |
| 8578 | try extra.ensureUnusedCapacity(@typeInfo(Tag.Extern).Struct.fields.len); | |
| 8578 | try extra.ensureUnusedCapacity(@typeInfo(Tag.Extern).@"struct".fields.len); | |
| 8579 | 8579 | try local.getMutableNavs(gpa).ensureUnusedCapacity(1); |
| 8580 | 8580 | |
| 8581 | 8581 | // Predict the index the `@"extern" will live at, so we can construct the owner `Nav` before releasing the shard's mutex. |
| ... | ... | @@ -8642,7 +8642,7 @@ pub fn getFuncDecl( |
| 8642 | 8642 | // arrays. This is similar to what `getOrPutTrailingString` does. |
| 8643 | 8643 | const prev_extra_len = extra.mutate.len; |
| 8644 | 8644 | |
| 8645 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).Struct.fields.len); | |
| 8645 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).@"struct".fields.len); | |
| 8646 | 8646 | |
| 8647 | 8647 | const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{ |
| 8648 | 8648 | .analysis = .{ |
| ... | ... | @@ -8723,10 +8723,10 @@ pub fn getFuncDeclIes( |
| 8723 | 8723 | const prev_extra_len = extra.mutate.len; |
| 8724 | 8724 | const params_len: u32 = @intCast(key.param_types.len); |
| 8725 | 8725 | |
| 8726 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).Struct.fields.len + | |
| 8726 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).@"struct".fields.len + | |
| 8727 | 8727 | 1 + // inferred_error_set |
| 8728 | @typeInfo(Tag.ErrorUnionType).Struct.fields.len + | |
| 8729 | @typeInfo(Tag.TypeFunction).Struct.fields.len + | |
| 8728 | @typeInfo(Tag.ErrorUnionType).@"struct".fields.len + | |
| 8729 | @typeInfo(Tag.TypeFunction).@"struct".fields.len + | |
| 8730 | 8730 | @intFromBool(key.comptime_bits != 0) + |
| 8731 | 8731 | @intFromBool(key.noalias_bits != 0) + |
| 8732 | 8732 | params_len); |
| ... | ... | @@ -8855,7 +8855,7 @@ pub fn getErrorSetType( |
| 8855 | 8855 | const local = ip.getLocal(tid); |
| 8856 | 8856 | const items = local.getMutableItems(gpa); |
| 8857 | 8857 | const extra = local.getMutableExtra(gpa); |
| 8858 | try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).Struct.fields.len + names.len); | |
| 8858 | try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).@"struct".fields.len + names.len); | |
| 8859 | 8859 | |
| 8860 | 8860 | const names_map = try ip.addMap(gpa, tid, names.len); |
| 8861 | 8861 | errdefer local.mutate.maps.len -= 1; |
| ... | ... | @@ -8930,7 +8930,7 @@ pub fn getFuncInstance( |
| 8930 | 8930 | const local = ip.getLocal(tid); |
| 8931 | 8931 | const items = local.getMutableItems(gpa); |
| 8932 | 8932 | const extra = local.getMutableExtra(gpa); |
| 8933 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).Struct.fields.len + | |
| 8933 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).@"struct".fields.len + | |
| 8934 | 8934 | arg.comptime_args.len); |
| 8935 | 8935 | |
| 8936 | 8936 | const generic_owner = unwrapCoercedFunc(ip, arg.generic_owner); |
| ... | ... | @@ -9015,11 +9015,11 @@ pub fn getFuncInstanceIes( |
| 9015 | 9015 | const prev_extra_len = extra.mutate.len; |
| 9016 | 9016 | const params_len: u32 = @intCast(arg.param_types.len); |
| 9017 | 9017 | |
| 9018 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).Struct.fields.len + | |
| 9018 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).@"struct".fields.len + | |
| 9019 | 9019 | 1 + // inferred_error_set |
| 9020 | 9020 | arg.comptime_args.len + |
| 9021 | @typeInfo(Tag.ErrorUnionType).Struct.fields.len + | |
| 9022 | @typeInfo(Tag.TypeFunction).Struct.fields.len + | |
| 9021 | @typeInfo(Tag.ErrorUnionType).@"struct".fields.len + | |
| 9022 | @typeInfo(Tag.TypeFunction).@"struct".fields.len + | |
| 9023 | 9023 | @intFromBool(arg.noalias_bits != 0) + |
| 9024 | 9024 | params_len); |
| 9025 | 9025 | |
| ... | ... | @@ -9324,7 +9324,7 @@ pub fn getEnumType( |
| 9324 | 9324 | switch (ini.tag_mode) { |
| 9325 | 9325 | .auto => { |
| 9326 | 9326 | assert(!ini.has_values); |
| 9327 | try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).Struct.fields.len + | |
| 9327 | try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).@"struct".fields.len + | |
| 9328 | 9328 | // TODO: fmt bug |
| 9329 | 9329 | // zig fmt: off |
| 9330 | 9330 | switch (ini.key) { |
| ... | ... | @@ -9384,7 +9384,7 @@ pub fn getEnumType( |
| 9384 | 9384 | local.mutate.maps.len -= 1; |
| 9385 | 9385 | }; |
| 9386 | 9386 | |
| 9387 | try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).Struct.fields.len + | |
| 9387 | try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).@"struct".fields.len + | |
| 9388 | 9388 | // TODO: fmt bug |
| 9389 | 9389 | // zig fmt: off |
| 9390 | 9390 | switch (ini.key) { |
| ... | ... | @@ -9499,7 +9499,7 @@ pub fn getGeneratedTagEnumType( |
| 9499 | 9499 | const prev_extra_len = extra.mutate.len; |
| 9500 | 9500 | switch (ini.tag_mode) { |
| 9501 | 9501 | .auto => { |
| 9502 | try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).Struct.fields.len + | |
| 9502 | try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).@"struct".fields.len + | |
| 9503 | 9503 | 1 + // owner_union |
| 9504 | 9504 | fields_len); // field names |
| 9505 | 9505 | items.appendAssumeCapacity(.{ |
| ... | ... | @@ -9518,7 +9518,7 @@ pub fn getGeneratedTagEnumType( |
| 9518 | 9518 | extra.appendSliceAssumeCapacity(.{@ptrCast(ini.names)}); |
| 9519 | 9519 | }, |
| 9520 | 9520 | .explicit, .nonexhaustive => { |
| 9521 | try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).Struct.fields.len + | |
| 9521 | try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).@"struct".fields.len + | |
| 9522 | 9522 | 1 + // owner_union |
| 9523 | 9523 | fields_len + // field names |
| 9524 | 9524 | ini.values.len); // field values |
| ... | ... | @@ -9606,7 +9606,7 @@ pub fn getOpaqueType( |
| 9606 | 9606 | const extra = local.getMutableExtra(gpa); |
| 9607 | 9607 | try items.ensureUnusedCapacity(1); |
| 9608 | 9608 | |
| 9609 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeOpaque).Struct.fields.len + switch (ini.key) { | |
| 9609 | try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeOpaque).@"struct".fields.len + switch (ini.key) { | |
| 9610 | 9610 | .declared => |d| d.captures.len, |
| 9611 | 9611 | .reified => 0, |
| 9612 | 9612 | }); |
| ... | ... | @@ -9740,14 +9740,14 @@ fn addInt( |
| 9740 | 9740 | } |
| 9741 | 9741 | |
| 9742 | 9742 | fn addExtra(extra: Local.Extra.Mutable, item: anytype) Allocator.Error!u32 { |
| 9743 | const fields = @typeInfo(@TypeOf(item)).Struct.fields; | |
| 9743 | const fields = @typeInfo(@TypeOf(item)).@"struct".fields; | |
| 9744 | 9744 | try extra.ensureUnusedCapacity(fields.len); |
| 9745 | 9745 | return addExtraAssumeCapacity(extra, item); |
| 9746 | 9746 | } |
| 9747 | 9747 | |
| 9748 | 9748 | fn addExtraAssumeCapacity(extra: Local.Extra.Mutable, item: anytype) u32 { |
| 9749 | 9749 | const result: u32 = extra.mutate.len; |
| 9750 | inline for (@typeInfo(@TypeOf(item)).Struct.fields) |field| { | |
| 9750 | inline for (@typeInfo(@TypeOf(item)).@"struct".fields) |field| { | |
| 9751 | 9751 | extra.appendAssumeCapacity(.{switch (field.type) { |
| 9752 | 9752 | Index, |
| 9753 | 9753 | Cau.Index, |
| ... | ... | @@ -9791,7 +9791,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { |
| 9791 | 9791 | else => @compileError("unsupported host"), |
| 9792 | 9792 | } |
| 9793 | 9793 | const result: u32 = @intCast(ip.limbs.items.len); |
| 9794 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields, 0..) |field, i| { | |
| 9794 | inline for (@typeInfo(@TypeOf(extra)).@"struct".fields, 0..) |field, i| { | |
| 9795 | 9795 | const new: u32 = switch (field.type) { |
| 9796 | 9796 | u32 => @field(extra, field.name), |
| 9797 | 9797 | Index => @intFromEnum(@field(extra, field.name)), |
| ... | ... | @@ -9809,7 +9809,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { |
| 9809 | 9809 | fn extraDataTrail(extra: Local.Extra, comptime T: type, index: u32) struct { data: T, end: u32 } { |
| 9810 | 9810 | const extra_items = extra.view().items(.@"0"); |
| 9811 | 9811 | var result: T = undefined; |
| 9812 | const fields = @typeInfo(T).Struct.fields; | |
| 9812 | const fields = @typeInfo(T).@"struct".fields; | |
| 9813 | 9813 | inline for (fields, index..) |field, extra_index| { |
| 9814 | 9814 | const extra_item = extra_items[extra_index]; |
| 9815 | 9815 | @field(result, field.name) = switch (field.type) { |
| ... | ... | @@ -10268,7 +10268,7 @@ fn getCoercedFunc( |
| 10268 | 10268 | const extra = local.getMutableExtra(gpa); |
| 10269 | 10269 | |
| 10270 | 10270 | const prev_extra_len = extra.mutate.len; |
| 10271 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncCoerced).Struct.fields.len); | |
| 10271 | try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncCoerced).@"struct".fields.len); | |
| 10272 | 10272 | |
| 10273 | 10273 | const extra_index = addExtraAssumeCapacity(extra, Tag.FuncCoerced{ |
| 10274 | 10274 | .ty = ty, |
| ... | ... | @@ -10480,31 +10480,31 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { |
| 10480 | 10480 | .type_inferred_error_set => 0, |
| 10481 | 10481 | .type_enum_explicit, .type_enum_nonexhaustive => b: { |
| 10482 | 10482 | const info = extraData(extra_list, EnumExplicit, data); |
| 10483 | var ints = @typeInfo(EnumExplicit).Struct.fields.len; | |
| 10483 | var ints = @typeInfo(EnumExplicit).@"struct".fields.len; | |
| 10484 | 10484 | if (info.zir_index == .none) ints += 1; |
| 10485 | 10485 | ints += if (info.captures_len != std.math.maxInt(u32)) |
| 10486 | 10486 | info.captures_len |
| 10487 | 10487 | else |
| 10488 | @typeInfo(PackedU64).Struct.fields.len; | |
| 10488 | @typeInfo(PackedU64).@"struct".fields.len; | |
| 10489 | 10489 | ints += info.fields_len; |
| 10490 | 10490 | if (info.values_map != .none) ints += info.fields_len; |
| 10491 | 10491 | break :b @sizeOf(u32) * ints; |
| 10492 | 10492 | }, |
| 10493 | 10493 | .type_enum_auto => b: { |
| 10494 | 10494 | const info = extraData(extra_list, EnumAuto, data); |
| 10495 | const ints = @typeInfo(EnumAuto).Struct.fields.len + info.captures_len + info.fields_len; | |
| 10495 | const ints = @typeInfo(EnumAuto).@"struct".fields.len + info.captures_len + info.fields_len; | |
| 10496 | 10496 | break :b @sizeOf(u32) * ints; |
| 10497 | 10497 | }, |
| 10498 | 10498 | .type_opaque => b: { |
| 10499 | 10499 | const info = extraData(extra_list, Tag.TypeOpaque, data); |
| 10500 | const ints = @typeInfo(Tag.TypeOpaque).Struct.fields.len + info.captures_len; | |
| 10500 | const ints = @typeInfo(Tag.TypeOpaque).@"struct".fields.len + info.captures_len; | |
| 10501 | 10501 | break :b @sizeOf(u32) * ints; |
| 10502 | 10502 | }, |
| 10503 | 10503 | .type_struct => b: { |
| 10504 | 10504 | if (data == 0) break :b 0; |
| 10505 | 10505 | const extra = extraDataTrail(extra_list, Tag.TypeStruct, data); |
| 10506 | 10506 | const info = extra.data; |
| 10507 | var ints: usize = @typeInfo(Tag.TypeStruct).Struct.fields.len; | |
| 10507 | var ints: usize = @typeInfo(Tag.TypeStruct).@"struct".fields.len; | |
| 10508 | 10508 | if (info.flags.any_captures) { |
| 10509 | 10509 | const captures_len = extra_items[extra.end]; |
| 10510 | 10510 | ints += 1 + captures_len; |
| ... | ... | @@ -10535,7 +10535,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { |
| 10535 | 10535 | extra_items[extra.end] |
| 10536 | 10536 | else |
| 10537 | 10537 | 0; |
| 10538 | break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).Struct.fields.len + | |
| 10538 | break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).@"struct".fields.len + | |
| 10539 | 10539 | @intFromBool(extra.data.flags.any_captures) + captures_len + |
| 10540 | 10540 | extra.data.fields_len * 2); |
| 10541 | 10541 | }, |
| ... | ... | @@ -10545,7 +10545,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { |
| 10545 | 10545 | extra_items[extra.end] |
| 10546 | 10546 | else |
| 10547 | 10547 | 0; |
| 10548 | break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).Struct.fields.len + | |
| 10548 | break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).@"struct".fields.len + | |
| 10549 | 10549 | @intFromBool(extra.data.flags.any_captures) + captures_len + |
| 10550 | 10550 | extra.data.fields_len * 3); |
| 10551 | 10551 | }, |
| ... | ... | @@ -11627,7 +11627,7 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois |
| 11627 | 11627 | .c_ulong_type, |
| 11628 | 11628 | .c_longlong_type, |
| 11629 | 11629 | .c_ulonglong_type, |
| 11630 | => .Int, | |
| 11630 | => .int, | |
| 11631 | 11631 | |
| 11632 | 11632 | .c_longdouble_type, |
| 11633 | 11633 | .f16_type, |
| ... | ... | @@ -11635,20 +11635,20 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois |
| 11635 | 11635 | .f64_type, |
| 11636 | 11636 | .f80_type, |
| 11637 | 11637 | .f128_type, |
| 11638 | => .Float, | |
| 11639 | ||
| 11640 | .anyopaque_type => .Opaque, | |
| 11641 | .bool_type => .Bool, | |
| 11642 | .void_type => .Void, | |
| 11643 | .type_type => .Type, | |
| 11644 | .anyerror_type, .adhoc_inferred_error_set_type => .ErrorSet, | |
| 11645 | .comptime_int_type => .ComptimeInt, | |
| 11646 | .comptime_float_type => .ComptimeFloat, | |
| 11647 | .noreturn_type => .NoReturn, | |
| 11648 | .anyframe_type => .AnyFrame, | |
| 11649 | .null_type => .Null, | |
| 11650 | .undefined_type => .Undefined, | |
| 11651 | .enum_literal_type => .EnumLiteral, | |
| 11638 | => .float, | |
| 11639 | ||
| 11640 | .anyopaque_type => .@"opaque", | |
| 11641 | .bool_type => .bool, | |
| 11642 | .void_type => .void, | |
| 11643 | .type_type => .type, | |
| 11644 | .anyerror_type, .adhoc_inferred_error_set_type => .error_set, | |
| 11645 | .comptime_int_type => .comptime_int, | |
| 11646 | .comptime_float_type => .comptime_float, | |
| 11647 | .noreturn_type => .noreturn, | |
| 11648 | .anyframe_type => .@"anyframe", | |
| 11649 | .null_type => .null, | |
| 11650 | .undefined_type => .undefined, | |
| 11651 | .enum_literal_type => .enum_literal, | |
| 11652 | 11652 | |
| 11653 | 11653 | .manyptr_u8_type, |
| 11654 | 11654 | .manyptr_const_u8_type, |
| ... | ... | @@ -11656,11 +11656,11 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois |
| 11656 | 11656 | .single_const_pointer_to_comptime_int_type, |
| 11657 | 11657 | .slice_const_u8_type, |
| 11658 | 11658 | .slice_const_u8_sentinel_0_type, |
| 11659 | => .Pointer, | |
| 11659 | => .pointer, | |
| 11660 | 11660 | |
| 11661 | .optional_noreturn_type => .Optional, | |
| 11662 | .anyerror_void_error_union_type => .ErrorUnion, | |
| 11663 | .empty_struct_type => .Struct, | |
| 11661 | .optional_noreturn_type => .optional, | |
| 11662 | .anyerror_void_error_union_type => .error_union, | |
| 11663 | .empty_struct_type => .@"struct", | |
| 11664 | 11664 | |
| 11665 | 11665 | .generic_poison_type => return error.GenericPoison, |
| 11666 | 11666 | |
| ... | ... | @@ -11687,48 +11687,48 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois |
| 11687 | 11687 | |
| 11688 | 11688 | .type_int_signed, |
| 11689 | 11689 | .type_int_unsigned, |
| 11690 | => .Int, | |
| 11690 | => .int, | |
| 11691 | 11691 | |
| 11692 | 11692 | .type_array_big, |
| 11693 | 11693 | .type_array_small, |
| 11694 | => .Array, | |
| 11694 | => .array, | |
| 11695 | 11695 | |
| 11696 | .type_vector => .Vector, | |
| 11696 | .type_vector => .vector, | |
| 11697 | 11697 | |
| 11698 | 11698 | .type_pointer, |
| 11699 | 11699 | .type_slice, |
| 11700 | => .Pointer, | |
| 11700 | => .pointer, | |
| 11701 | 11701 | |
| 11702 | .type_optional => .Optional, | |
| 11703 | .type_anyframe => .AnyFrame, | |
| 11702 | .type_optional => .optional, | |
| 11703 | .type_anyframe => .@"anyframe", | |
| 11704 | 11704 | |
| 11705 | 11705 | .type_error_union, |
| 11706 | 11706 | .type_anyerror_union, |
| 11707 | => .ErrorUnion, | |
| 11707 | => .error_union, | |
| 11708 | 11708 | |
| 11709 | 11709 | .type_error_set, |
| 11710 | 11710 | .type_inferred_error_set, |
| 11711 | => .ErrorSet, | |
| 11711 | => .error_set, | |
| 11712 | 11712 | |
| 11713 | 11713 | .type_enum_auto, |
| 11714 | 11714 | .type_enum_explicit, |
| 11715 | 11715 | .type_enum_nonexhaustive, |
| 11716 | => .Enum, | |
| 11716 | => .@"enum", | |
| 11717 | 11717 | |
| 11718 | 11718 | .simple_type => unreachable, // handled via Index tag above |
| 11719 | 11719 | |
| 11720 | .type_opaque => .Opaque, | |
| 11720 | .type_opaque => .@"opaque", | |
| 11721 | 11721 | |
| 11722 | 11722 | .type_struct, |
| 11723 | 11723 | .type_struct_anon, |
| 11724 | 11724 | .type_struct_packed, |
| 11725 | 11725 | .type_struct_packed_inits, |
| 11726 | 11726 | .type_tuple_anon, |
| 11727 | => .Struct, | |
| 11727 | => .@"struct", | |
| 11728 | 11728 | |
| 11729 | .type_union => .Union, | |
| 11729 | .type_union => .@"union", | |
| 11730 | 11730 | |
| 11731 | .type_function => .Fn, | |
| 11731 | .type_function => .@"fn", | |
| 11732 | 11732 | |
| 11733 | 11733 | // values, not types |
| 11734 | 11734 | .undef, |
| ... | ... | @@ -11919,8 +11919,8 @@ fn funcIesResolvedPtr(ip: *InternPool, func_index: Index) *Index { |
| 11919 | 11919 | const func_extra = unwrapped_func.getExtra(ip); |
| 11920 | 11920 | const func_item = unwrapped_func.getItem(ip); |
| 11921 | 11921 | const extra_index = switch (func_item.tag) { |
| 11922 | .func_decl => func_item.data + @typeInfo(Tag.FuncDecl).Struct.fields.len, | |
| 11923 | .func_instance => func_item.data + @typeInfo(Tag.FuncInstance).Struct.fields.len, | |
| 11922 | .func_decl => func_item.data + @typeInfo(Tag.FuncDecl).@"struct".fields.len, | |
| 11923 | .func_instance => func_item.data + @typeInfo(Tag.FuncInstance).@"struct".fields.len, | |
| 11924 | 11924 | .func_coerced => { |
| 11925 | 11925 | const uncoerced_func_index: Index = @enumFromInt(func_extra.view().items(.@"0")[ |
| 11926 | 11926 | func_item.data + std.meta.fieldIndex(Tag.FuncCoerced, "func").? |
| ... | ... | @@ -11929,8 +11929,8 @@ fn funcIesResolvedPtr(ip: *InternPool, func_index: Index) *Index { |
| 11929 | 11929 | const uncoerced_func_item = unwrapped_uncoerced_func.getItem(ip); |
| 11930 | 11930 | return @ptrCast(&unwrapped_uncoerced_func.getExtra(ip).view().items(.@"0")[ |
| 11931 | 11931 | switch (uncoerced_func_item.tag) { |
| 11932 | .func_decl => uncoerced_func_item.data + @typeInfo(Tag.FuncDecl).Struct.fields.len, | |
| 11933 | .func_instance => uncoerced_func_item.data + @typeInfo(Tag.FuncInstance).Struct.fields.len, | |
| 11932 | .func_decl => uncoerced_func_item.data + @typeInfo(Tag.FuncDecl).@"struct".fields.len, | |
| 11933 | .func_instance => uncoerced_func_item.data + @typeInfo(Tag.FuncInstance).@"struct".fields.len, | |
| 11934 | 11934 | else => unreachable, |
| 11935 | 11935 | } |
| 11936 | 11936 | ]); |
src/Package/Fetch.zig+2-2| ... | ... | @@ -325,7 +325,7 @@ pub fn run(f: *Fetch) RunError!void { |
| 325 | 325 | // "p/$hash/foo", with possibly more directories after "foo". |
| 326 | 326 | // We want to fail unless the resolved relative path has a |
| 327 | 327 | // prefix of "p/$hash/". |
| 328 | const digest_len = @typeInfo(Manifest.MultiHashHexDigest).Array.len; | |
| 328 | const digest_len = @typeInfo(Manifest.MultiHashHexDigest).array.len; | |
| 329 | 329 | const prefix_len: usize = if (f.job_queue.read_only) 0 else "p/".len; |
| 330 | 330 | const expected_prefix = f.parent_package_root.sub_path[0 .. prefix_len + digest_len]; |
| 331 | 331 | if (!std.mem.startsWith(u8, pkg_root.sub_path, expected_prefix)) { |
| ... | ... | @@ -670,7 +670,7 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 670 | 670 | .url = url, |
| 671 | 671 | .hash = h: { |
| 672 | 672 | const h = dep.hash orelse break :h null; |
| 673 | const digest_len = @typeInfo(Manifest.MultiHashHexDigest).Array.len; | |
| 673 | const digest_len = @typeInfo(Manifest.MultiHashHexDigest).array.len; | |
| 674 | 674 | const multihash_digest = h[0..digest_len].*; |
| 675 | 675 | const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest); |
| 676 | 676 | if (gop.found_existing) continue; |
src/Sema.zig+971-971| ... | ... | @@ -1783,7 +1783,7 @@ fn analyzeBodyInner( |
| 1783 | 1783 | const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len); |
| 1784 | 1784 | const err_union = try sema.resolveInst(extra.data.operand); |
| 1785 | 1785 | const err_union_ty = sema.typeOf(err_union); |
| 1786 | if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) { | |
| 1786 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | |
| 1787 | 1787 | return sema.fail(block, operand_src, "expected error union type, found '{}'", .{ |
| 1788 | 1788 | err_union_ty.fmt(pt), |
| 1789 | 1789 | }); |
| ... | ... | @@ -1985,14 +1985,14 @@ fn resolveDestType( |
| 1985 | 1985 | else => |e| return e, |
| 1986 | 1986 | }; |
| 1987 | 1987 | |
| 1988 | if (remove_eu and raw_ty.zigTypeTag(zcu) == .ErrorUnion) { | |
| 1988 | if (remove_eu and raw_ty.zigTypeTag(zcu) == .error_union) { | |
| 1989 | 1989 | const eu_child = raw_ty.errorUnionPayload(zcu); |
| 1990 | if (remove_opt and eu_child.zigTypeTag(zcu) == .Optional) { | |
| 1990 | if (remove_opt and eu_child.zigTypeTag(zcu) == .optional) { | |
| 1991 | 1991 | return eu_child.childType(zcu); |
| 1992 | 1992 | } |
| 1993 | 1993 | return eu_child; |
| 1994 | 1994 | } |
| 1995 | if (remove_opt and raw_ty.zigTypeTag(zcu) == .Optional) { | |
| 1995 | if (remove_opt and raw_ty.zigTypeTag(zcu) == .optional) { | |
| 1996 | 1996 | return raw_ty.childType(zcu); |
| 1997 | 1997 | } |
| 1998 | 1998 | return raw_ty; |
| ... | ... | @@ -2280,7 +2280,7 @@ fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, non |
| 2280 | 2280 | non_optional_ty.fmt(pt), |
| 2281 | 2281 | }); |
| 2282 | 2282 | errdefer msg.destroy(sema.gpa); |
| 2283 | if (non_optional_ty.zigTypeTag(pt.zcu) == .ErrorUnion) { | |
| 2283 | if (non_optional_ty.zigTypeTag(pt.zcu) == .error_union) { | |
| 2284 | 2284 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| 2285 | 2285 | } |
| 2286 | 2286 | try addDeclaredHereNote(sema, msg, non_optional_ty); |
| ... | ... | @@ -2327,7 +2327,7 @@ fn failWithErrorSetCodeMissing( |
| 2327 | 2327 | fn failWithIntegerOverflow(sema: *Sema, block: *Block, src: LazySrcLoc, int_ty: Type, val: Value, vector_index: usize) CompileError { |
| 2328 | 2328 | const pt = sema.pt; |
| 2329 | 2329 | const zcu = pt.zcu; |
| 2330 | if (int_ty.zigTypeTag(zcu) == .Vector) { | |
| 2330 | if (int_ty.zigTypeTag(zcu) == .vector) { | |
| 2331 | 2331 | const msg = msg: { |
| 2332 | 2332 | const msg = try sema.errMsg(src, "overflow of vector type '{}' with value '{}'", .{ |
| 2333 | 2333 | int_ty.fmt(pt), val.fmtValueSema(pt, sema), |
| ... | ... | @@ -2380,7 +2380,7 @@ fn failWithInvalidFieldAccess( |
| 2380 | 2380 | const zcu = pt.zcu; |
| 2381 | 2381 | const inner_ty = if (object_ty.isSinglePointer(zcu)) object_ty.childType(zcu) else object_ty; |
| 2382 | 2382 | |
| 2383 | if (inner_ty.zigTypeTag(zcu) == .Optional) opt: { | |
| 2383 | if (inner_ty.zigTypeTag(zcu) == .optional) opt: { | |
| 2384 | 2384 | const child_ty = inner_ty.optionalChild(zcu); |
| 2385 | 2385 | if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :opt; |
| 2386 | 2386 | const msg = msg: { |
| ... | ... | @@ -2390,7 +2390,7 @@ fn failWithInvalidFieldAccess( |
| 2390 | 2390 | break :msg msg; |
| 2391 | 2391 | }; |
| 2392 | 2392 | return sema.failWithOwnedErrorMsg(block, msg); |
| 2393 | } else if (inner_ty.zigTypeTag(zcu) == .ErrorUnion) err: { | |
| 2393 | } else if (inner_ty.zigTypeTag(zcu) == .error_union) err: { | |
| 2394 | 2394 | const child_ty = inner_ty.errorUnionPayload(zcu); |
| 2395 | 2395 | if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :err; |
| 2396 | 2396 | const msg = msg: { |
| ... | ... | @@ -2407,16 +2407,16 @@ fn failWithInvalidFieldAccess( |
| 2407 | 2407 | fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.NullTerminatedString) bool { |
| 2408 | 2408 | const ip = &zcu.intern_pool; |
| 2409 | 2409 | switch (ty.zigTypeTag(zcu)) { |
| 2410 | .Array => return field_name.eqlSlice("len", ip), | |
| 2411 | .Pointer => { | |
| 2410 | .array => return field_name.eqlSlice("len", ip), | |
| 2411 | .pointer => { | |
| 2412 | 2412 | const ptr_info = ty.ptrInfo(zcu); |
| 2413 | 2413 | if (ptr_info.flags.size == .Slice) { |
| 2414 | 2414 | return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip); |
| 2415 | } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Array) { | |
| 2415 | } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { | |
| 2416 | 2416 | return field_name.eqlSlice("len", ip); |
| 2417 | 2417 | } else return false; |
| 2418 | 2418 | }, |
| 2419 | .Type, .Struct, .Union => return true, | |
| 2419 | .type, .@"struct", .@"union" => return true, | |
| 2420 | 2420 | else => return false, |
| 2421 | 2421 | } |
| 2422 | 2422 | } |
| ... | ... | @@ -3384,9 +3384,9 @@ fn ensureResultUsed( |
| 3384 | 3384 | const pt = sema.pt; |
| 3385 | 3385 | const zcu = pt.zcu; |
| 3386 | 3386 | switch (ty.zigTypeTag(zcu)) { |
| 3387 | .Void, .NoReturn => return, | |
| 3388 | .ErrorSet => return sema.fail(block, src, "error set is ignored", .{}), | |
| 3389 | .ErrorUnion => { | |
| 3387 | .void, .noreturn => return, | |
| 3388 | .error_set => return sema.fail(block, src, "error set is ignored", .{}), | |
| 3389 | .error_union => { | |
| 3390 | 3390 | const msg = msg: { |
| 3391 | 3391 | const msg = try sema.errMsg(src, "error union is ignored", .{}); |
| 3392 | 3392 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -3419,8 +3419,8 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3419 | 3419 | const src = block.nodeOffset(inst_data.src_node); |
| 3420 | 3420 | const operand_ty = sema.typeOf(operand); |
| 3421 | 3421 | switch (operand_ty.zigTypeTag(zcu)) { |
| 3422 | .ErrorSet => return sema.fail(block, src, "error set is discarded", .{}), | |
| 3423 | .ErrorUnion => { | |
| 3422 | .error_set => return sema.fail(block, src, "error set is discarded", .{}), | |
| 3423 | .error_union => { | |
| 3424 | 3424 | const msg = msg: { |
| 3425 | 3425 | const msg = try sema.errMsg(src, "error union is discarded", .{}); |
| 3426 | 3426 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -3443,13 +3443,13 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index |
| 3443 | 3443 | const src = block.nodeOffset(inst_data.src_node); |
| 3444 | 3444 | const operand = try sema.resolveInst(inst_data.operand); |
| 3445 | 3445 | const operand_ty = sema.typeOf(operand); |
| 3446 | const err_union_ty = if (operand_ty.zigTypeTag(zcu) == .Pointer) | |
| 3446 | const err_union_ty = if (operand_ty.zigTypeTag(zcu) == .pointer) | |
| 3447 | 3447 | operand_ty.childType(zcu) |
| 3448 | 3448 | else |
| 3449 | 3449 | operand_ty; |
| 3450 | if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) return; | |
| 3450 | if (err_union_ty.zigTypeTag(zcu) != .error_union) return; | |
| 3451 | 3451 | const payload_ty = err_union_ty.errorUnionPayload(zcu).zigTypeTag(zcu); |
| 3452 | if (payload_ty != .Void and payload_ty != .NoReturn) { | |
| 3452 | if (payload_ty != .void and payload_ty != .noreturn) { | |
| 3453 | 3453 | const msg = msg: { |
| 3454 | 3454 | const msg = try sema.errMsg(src, "error union payload is ignored", .{}); |
| 3455 | 3455 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -4198,7 +4198,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4198 | 4198 | _ = try replacement_block.addBr(placeholder_inst, .void_value); |
| 4199 | 4199 | try sema.air_extra.ensureUnusedCapacity( |
| 4200 | 4200 | gpa, |
| 4201 | @typeInfo(Air.Block).Struct.fields.len + replacement_block.instructions.items.len, | |
| 4201 | @typeInfo(Air.Block).@"struct".fields.len + replacement_block.instructions.items.len, | |
| 4202 | 4202 | ); |
| 4203 | 4203 | sema.air_instructions.set(@intFromEnum(placeholder_inst), .{ |
| 4204 | 4204 | .tag = .block, |
| ... | ... | @@ -4244,7 +4244,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4244 | 4244 | // Each arg could be an indexable, or a range, in which case the length |
| 4245 | 4245 | // is passed directly as an integer. |
| 4246 | 4246 | const is_int = switch (object_ty.zigTypeTag(zcu)) { |
| 4247 | .Int, .ComptimeInt => true, | |
| 4247 | .int, .comptime_int => true, | |
| 4248 | 4248 | else => false, |
| 4249 | 4249 | }; |
| 4250 | 4250 | const arg_src = block.src(.{ .for_input = .{ |
| ... | ... | @@ -4259,7 +4259,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4259 | 4259 | errdefer msg.destroy(sema.gpa); |
| 4260 | 4260 | try sema.errNote(arg_src, msg, "for loop operand must be a range, array, slice, tuple, or vector", .{}); |
| 4261 | 4261 | |
| 4262 | if (object_ty.zigTypeTag(zcu) == .ErrorUnion) { | |
| 4262 | if (object_ty.zigTypeTag(zcu) == .error_union) { | |
| 4263 | 4263 | try sema.errNote(arg_src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| 4264 | 4264 | } |
| 4265 | 4265 | |
| ... | ... | @@ -4319,7 +4319,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4319 | 4319 | // Each arg could be an indexable, or a range, in which case the length |
| 4320 | 4320 | // is passed directly as an integer. |
| 4321 | 4321 | switch (object_ty.zigTypeTag(zcu)) { |
| 4322 | .Int, .ComptimeInt => continue, | |
| 4322 | .int, .comptime_int => continue, | |
| 4323 | 4323 | else => {}, |
| 4324 | 4324 | } |
| 4325 | 4325 | const arg_src = block.src(.{ .for_input = .{ |
| ... | ... | @@ -4357,8 +4357,8 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL |
| 4357 | 4357 | const zcu = pt.zcu; |
| 4358 | 4358 | var base_ptr = ptr; |
| 4359 | 4359 | while (true) switch (sema.typeOf(base_ptr).childType(zcu).zigTypeTag(zcu)) { |
| 4360 | .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), | |
| 4361 | .Optional => base_ptr = try sema.analyzeOptionalPayloadPtr(block, src, base_ptr, false, true), | |
| 4360 | .error_union => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), | |
| 4361 | .optional => base_ptr = try sema.analyzeOptionalPayloadPtr(block, src, base_ptr, false, true), | |
| 4362 | 4362 | else => break, |
| 4363 | 4363 | }; |
| 4364 | 4364 | try sema.checkKnownAllocPtr(block, ptr, base_ptr); |
| ... | ... | @@ -4383,12 +4383,12 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 4383 | 4383 | else => |e| return e, |
| 4384 | 4384 | }; |
| 4385 | 4385 | const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu); |
| 4386 | assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction | |
| 4386 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction | |
| 4387 | 4387 | const elem_ty = ptr_ty.childType(zcu); |
| 4388 | 4388 | switch (ptr_ty.ptrSize(zcu)) { |
| 4389 | 4389 | .One => { |
| 4390 | 4390 | const uncoerced_ty = sema.typeOf(uncoerced_val); |
| 4391 | if (elem_ty.zigTypeTag(zcu) == .Array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) { | |
| 4391 | if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) { | |
| 4392 | 4392 | // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion. |
| 4393 | 4393 | return uncoerced_val; |
| 4394 | 4394 | } |
| ... | ... | @@ -4403,7 +4403,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 4403 | 4403 | // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`. |
| 4404 | 4404 | const val_ty = sema.typeOf(uncoerced_val); |
| 4405 | 4405 | switch (val_ty.zigTypeTag(zcu)) { |
| 4406 | .Array, .Vector => {}, | |
| 4406 | .array, .vector => {}, | |
| 4407 | 4407 | else => if (!val_ty.isTuple(zcu)) { |
| 4408 | 4408 | return sema.fail(block, src, "expected array of '{}', found '{}'", .{ elem_ty.fmt(pt), val_ty.fmt(pt) }); |
| 4409 | 4409 | }, |
| ... | ... | @@ -4439,7 +4439,7 @@ fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 4439 | 4439 | else => |e| return e, |
| 4440 | 4440 | }; |
| 4441 | 4441 | if (ty_operand.isGenericPoison()) return; |
| 4442 | if (ty_operand.optEuBaseType(zcu).zigTypeTag(zcu) != .Pointer) { | |
| 4442 | if (ty_operand.optEuBaseType(zcu).zigTypeTag(zcu) != .pointer) { | |
| 4443 | 4443 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 4444 | 4444 | const msg = try sema.errMsg(src, "expected type '{}', found pointer", .{ty_operand.fmt(pt)}); |
| 4445 | 4445 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -4464,7 +4464,7 @@ fn zirValidateArrayInitRefTy( |
| 4464 | 4464 | else => |e| return e, |
| 4465 | 4465 | }; |
| 4466 | 4466 | const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu); |
| 4467 | assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction | |
| 4467 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction | |
| 4468 | 4468 | switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) { |
| 4469 | 4469 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 4470 | 4470 | .Slice, .Many => { |
| ... | ... | @@ -4523,7 +4523,7 @@ fn validateArrayInitTy( |
| 4523 | 4523 | const pt = sema.pt; |
| 4524 | 4524 | const zcu = pt.zcu; |
| 4525 | 4525 | switch (ty.zigTypeTag(zcu)) { |
| 4526 | .Array => { | |
| 4526 | .array => { | |
| 4527 | 4527 | const array_len = ty.arrayLen(zcu); |
| 4528 | 4528 | if (init_count != array_len) { |
| 4529 | 4529 | return sema.fail(block, src, "expected {d} array elements; found {d}", .{ |
| ... | ... | @@ -4532,7 +4532,7 @@ fn validateArrayInitTy( |
| 4532 | 4532 | } |
| 4533 | 4533 | return; |
| 4534 | 4534 | }, |
| 4535 | .Vector => { | |
| 4535 | .vector => { | |
| 4536 | 4536 | const array_len = ty.arrayLen(zcu); |
| 4537 | 4537 | if (init_count != array_len) { |
| 4538 | 4538 | return sema.fail(block, src, "expected {d} vector elements; found {d}", .{ |
| ... | ... | @@ -4541,7 +4541,7 @@ fn validateArrayInitTy( |
| 4541 | 4541 | } |
| 4542 | 4542 | return; |
| 4543 | 4543 | }, |
| 4544 | .Struct => if (ty.isTuple(zcu)) { | |
| 4544 | .@"struct" => if (ty.isTuple(zcu)) { | |
| 4545 | 4545 | try ty.resolveFields(pt); |
| 4546 | 4546 | const array_len = ty.arrayLen(zcu); |
| 4547 | 4547 | if (init_count > array_len) { |
| ... | ... | @@ -4574,7 +4574,7 @@ fn zirValidateStructInitTy( |
| 4574 | 4574 | const struct_ty = if (is_result_ty) ty.optEuBaseType(zcu) else ty; |
| 4575 | 4575 | |
| 4576 | 4576 | switch (struct_ty.zigTypeTag(zcu)) { |
| 4577 | .Struct, .Union => return, | |
| 4577 | .@"struct", .@"union" => return, | |
| 4578 | 4578 | else => {}, |
| 4579 | 4579 | } |
| 4580 | 4580 | return sema.failWithStructInitNotSupported(block, src, struct_ty); |
| ... | ... | @@ -4599,13 +4599,13 @@ fn zirValidatePtrStructInit( |
| 4599 | 4599 | const object_ptr = try sema.resolveInst(field_ptr_extra.lhs); |
| 4600 | 4600 | const agg_ty = sema.typeOf(object_ptr).childType(zcu).optEuBaseType(zcu); |
| 4601 | 4601 | switch (agg_ty.zigTypeTag(zcu)) { |
| 4602 | .Struct => return sema.validateStructInit( | |
| 4602 | .@"struct" => return sema.validateStructInit( | |
| 4603 | 4603 | block, |
| 4604 | 4604 | agg_ty, |
| 4605 | 4605 | init_src, |
| 4606 | 4606 | instrs, |
| 4607 | 4607 | ), |
| 4608 | .Union => return sema.validateUnionInit( | |
| 4608 | .@"union" => return sema.validateUnionInit( | |
| 4609 | 4609 | block, |
| 4610 | 4610 | agg_ty, |
| 4611 | 4611 | init_src, |
| ... | ... | @@ -5084,7 +5084,7 @@ fn zirValidatePtrArrayInit( |
| 5084 | 5084 | ); |
| 5085 | 5085 | |
| 5086 | 5086 | if (instrs.len != array_len) switch (array_ty.zigTypeTag(zcu)) { |
| 5087 | .Struct => { | |
| 5087 | .@"struct" => { | |
| 5088 | 5088 | var root_msg: ?*Zcu.ErrorMsg = null; |
| 5089 | 5089 | errdefer if (root_msg) |msg| msg.destroy(sema.gpa); |
| 5090 | 5090 | |
| ... | ... | @@ -5110,12 +5110,12 @@ fn zirValidatePtrArrayInit( |
| 5110 | 5110 | return sema.failWithOwnedErrorMsg(block, msg); |
| 5111 | 5111 | } |
| 5112 | 5112 | }, |
| 5113 | .Array => { | |
| 5113 | .array => { | |
| 5114 | 5114 | return sema.fail(block, init_src, "expected {d} array elements; found {d}", .{ |
| 5115 | 5115 | array_len, instrs.len, |
| 5116 | 5116 | }); |
| 5117 | 5117 | }, |
| 5118 | .Vector => { | |
| 5118 | .vector => { | |
| 5119 | 5119 | return sema.fail(block, init_src, "expected {d} vector elements; found {d}", .{ |
| 5120 | 5120 | array_len, instrs.len, |
| 5121 | 5121 | }); |
| ... | ... | @@ -5277,7 +5277,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 5277 | 5277 | const operand = try sema.resolveInst(inst_data.operand); |
| 5278 | 5278 | const operand_ty = sema.typeOf(operand); |
| 5279 | 5279 | |
| 5280 | if (operand_ty.zigTypeTag(zcu) != .Pointer) { | |
| 5280 | if (operand_ty.zigTypeTag(zcu) != .pointer) { | |
| 5281 | 5281 | return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)}); |
| 5282 | 5282 | } else switch (operand_ty.ptrSize(zcu)) { |
| 5283 | 5283 | .One, .C => {}, |
| ... | ... | @@ -5322,8 +5322,8 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 5322 | 5322 | const operand_ty = sema.typeOf(operand); |
| 5323 | 5323 | |
| 5324 | 5324 | const can_destructure = switch (operand_ty.zigTypeTag(zcu)) { |
| 5325 | .Array, .Vector => true, | |
| 5326 | .Struct => operand_ty.isTuple(zcu), | |
| 5325 | .array, .vector => true, | |
| 5326 | .@"struct" => operand_ty.isTuple(zcu), | |
| 5327 | 5327 | else => false, |
| 5328 | 5328 | }; |
| 5329 | 5329 | |
| ... | ... | @@ -5360,10 +5360,10 @@ fn failWithBadMemberAccess( |
| 5360 | 5360 | const zcu = pt.zcu; |
| 5361 | 5361 | const ip = &zcu.intern_pool; |
| 5362 | 5362 | const kw_name = switch (agg_ty.zigTypeTag(zcu)) { |
| 5363 | .Union => "union", | |
| 5364 | .Struct => "struct", | |
| 5365 | .Opaque => "opaque", | |
| 5366 | .Enum => "enum", | |
| 5363 | .@"union" => "union", | |
| 5364 | .@"struct" => "struct", | |
| 5365 | .@"opaque" => "opaque", | |
| 5366 | .@"enum" => "enum", | |
| 5367 | 5367 | else => unreachable, |
| 5368 | 5368 | }; |
| 5369 | 5369 | if (agg_ty.typeDeclInst(zcu)) |inst| if ((inst.resolve(ip) orelse return error.AnalysisFail) == .main_struct_inst) { |
| ... | ... | @@ -5432,10 +5432,10 @@ fn addDeclaredHereNote(sema: *Sema, parent: *Zcu.ErrorMsg, decl_ty: Type) !void |
| 5432 | 5432 | const zcu = sema.pt.zcu; |
| 5433 | 5433 | const src_loc = decl_ty.srcLocOrNull(zcu) orelse return; |
| 5434 | 5434 | const category = switch (decl_ty.zigTypeTag(zcu)) { |
| 5435 | .Union => "union", | |
| 5436 | .Struct => "struct", | |
| 5437 | .Enum => "enum", | |
| 5438 | .Opaque => "opaque", | |
| 5435 | .@"union" => "union", | |
| 5436 | .@"struct" => "struct", | |
| 5437 | .@"enum" => "enum", | |
| 5438 | .@"opaque" => "opaque", | |
| 5439 | 5439 | else => unreachable, |
| 5440 | 5440 | }; |
| 5441 | 5441 | try sema.errNote(src_loc, parent, "{s} declared here", .{category}); |
| ... | ... | @@ -5562,7 +5562,7 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v |
| 5562 | 5562 | // Where %c is an error union or error set. In such case we need to add |
| 5563 | 5563 | // to the current function's inferred error set, if any. |
| 5564 | 5564 | if (is_ret and sema.fn_ret_ty_ies != null) switch (sema.typeOf(operand).zigTypeTag(zcu)) { |
| 5565 | .ErrorUnion, .ErrorSet => try sema.addToInferredErrorSet(operand), | |
| 5565 | .error_union, .error_set => try sema.addToInferredErrorSet(operand), | |
| 5566 | 5566 | else => {}, |
| 5567 | 5567 | }; |
| 5568 | 5568 | |
| ... | ... | @@ -5819,7 +5819,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError |
| 5819 | 5819 | } else { |
| 5820 | 5820 | try child_block.instructions.append(gpa, loop_inst); |
| 5821 | 5821 | |
| 5822 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + loop_block_len); | |
| 5822 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len + loop_block_len); | |
| 5823 | 5823 | sema.air_instructions.items(.data)[@intFromEnum(loop_inst)].ty_pl.payload = sema.addExtraAssumeCapacity( |
| 5824 | 5824 | Air.Block{ .body_len = @intCast(loop_block_len) }, |
| 5825 | 5825 | ); |
| ... | ... | @@ -6035,7 +6035,7 @@ fn resolveBlockBody( |
| 6035 | 6035 | // We need a runtime block for scoping reasons. |
| 6036 | 6036 | _ = try child_block.addBr(merges.block_inst, .void_value); |
| 6037 | 6037 | try parent_block.instructions.append(sema.gpa, merges.block_inst); |
| 6038 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Block).Struct.fields.len + | |
| 6038 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Block).@"struct".fields.len + | |
| 6039 | 6039 | child_block.instructions.items.len); |
| 6040 | 6040 | sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{ |
| 6041 | 6041 | .ty = .void_type, |
| ... | ... | @@ -6111,7 +6111,7 @@ fn resolveAnalyzedBlock( |
| 6111 | 6111 | .dbg_inline_block => { |
| 6112 | 6112 | // Create a block containing all instruction from the body. |
| 6113 | 6113 | try parent_block.instructions.append(gpa, merges.block_inst); |
| 6114 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).Struct.fields.len + | |
| 6114 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".fields.len + | |
| 6115 | 6115 | child_block.instructions.items.len); |
| 6116 | 6116 | sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{ |
| 6117 | 6117 | .ty = .noreturn_type, |
| ... | ... | @@ -6149,7 +6149,7 @@ fn resolveAnalyzedBlock( |
| 6149 | 6149 | try parent_block.instructions.append(gpa, merges.block_inst); |
| 6150 | 6150 | switch (block_tag) { |
| 6151 | 6151 | .block => { |
| 6152 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + | |
| 6152 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len + | |
| 6153 | 6153 | child_block.instructions.items.len); |
| 6154 | 6154 | sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{ |
| 6155 | 6155 | .ty = .void_type, |
| ... | ... | @@ -6159,7 +6159,7 @@ fn resolveAnalyzedBlock( |
| 6159 | 6159 | } }; |
| 6160 | 6160 | }, |
| 6161 | 6161 | .dbg_inline_block => { |
| 6162 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).Struct.fields.len + | |
| 6162 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".fields.len + | |
| 6163 | 6163 | child_block.instructions.items.len); |
| 6164 | 6164 | sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{ |
| 6165 | 6165 | .ty = .void_type, |
| ... | ... | @@ -6210,7 +6210,7 @@ fn resolveAnalyzedBlock( |
| 6210 | 6210 | const ty_inst = Air.internedToRef(resolved_ty.toIntern()); |
| 6211 | 6211 | switch (block_tag) { |
| 6212 | 6212 | .block => { |
| 6213 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + | |
| 6213 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len + | |
| 6214 | 6214 | child_block.instructions.items.len); |
| 6215 | 6215 | sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{ |
| 6216 | 6216 | .ty = ty_inst, |
| ... | ... | @@ -6220,7 +6220,7 @@ fn resolveAnalyzedBlock( |
| 6220 | 6220 | } }; |
| 6221 | 6221 | }, |
| 6222 | 6222 | .dbg_inline_block => { |
| 6223 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).Struct.fields.len + | |
| 6223 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".fields.len + | |
| 6224 | 6224 | child_block.instructions.items.len); |
| 6225 | 6225 | sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{ |
| 6226 | 6226 | .ty = ty_inst, |
| ... | ... | @@ -6257,7 +6257,7 @@ fn resolveAnalyzedBlock( |
| 6257 | 6257 | // Convert the br instruction to a block instruction that has the coercion |
| 6258 | 6258 | // and then a new br inside that returns the coerced instruction. |
| 6259 | 6259 | const sub_block_len: u32 = @intCast(coerce_block.instructions.items.len + 1); |
| 6260 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + | |
| 6260 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len + | |
| 6261 | 6261 | sub_block_len); |
| 6262 | 6262 | try sema.air_instructions.ensureUnusedCapacity(gpa, 1); |
| 6263 | 6263 | const sub_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); |
| ... | ... | @@ -6306,7 +6306,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 6306 | 6306 | const options = try sema.resolveExportOptions(block, options_src, extra.options); |
| 6307 | 6307 | |
| 6308 | 6308 | { |
| 6309 | if (ptr_ty.zigTypeTag(zcu) != .Pointer) { | |
| 6309 | if (ptr_ty.zigTypeTag(zcu) != .pointer) { | |
| 6310 | 6310 | return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)}); |
| 6311 | 6311 | } |
| 6312 | 6312 | const ptr_ty_info = ptr_ty.ptrInfo(zcu); |
| ... | ... | @@ -6856,7 +6856,7 @@ fn popErrorReturnTrace( |
| 6856 | 6856 | // The result might be an error. If it is, we leave the error trace alone. If it isn't, we need |
| 6857 | 6857 | // to pop any error trace that may have been propagated from our arguments. |
| 6858 | 6858 | |
| 6859 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len); | |
| 6859 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len); | |
| 6860 | 6860 | const cond_block_inst = try block.addInstAsIndex(.{ |
| 6861 | 6861 | .tag = .block, |
| 6862 | 6862 | .data = .{ |
| ... | ... | @@ -6885,9 +6885,9 @@ fn popErrorReturnTrace( |
| 6885 | 6885 | defer else_block.instructions.deinit(gpa); |
| 6886 | 6886 | _ = try else_block.addBr(cond_block_inst, .void_value); |
| 6887 | 6887 | |
| 6888 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + | |
| 6888 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len + | |
| 6889 | 6889 | then_block.instructions.items.len + else_block.instructions.items.len + |
| 6890 | @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block | |
| 6890 | @typeInfo(Air.Block).@"struct".fields.len + 1); // +1 for the sole .cond_br instruction in the .block | |
| 6891 | 6891 | |
| 6892 | 6892 | const cond_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); |
| 6893 | 6893 | try sema.air_instructions.append(gpa, .{ |
| ... | ... | @@ -7046,17 +7046,17 @@ fn checkCallArgumentCount( |
| 7046 | 7046 | const zcu = pt.zcu; |
| 7047 | 7047 | const func_ty = func_ty: { |
| 7048 | 7048 | switch (callee_ty.zigTypeTag(zcu)) { |
| 7049 | .Fn => break :func_ty callee_ty, | |
| 7050 | .Pointer => { | |
| 7049 | .@"fn" => break :func_ty callee_ty, | |
| 7050 | .pointer => { | |
| 7051 | 7051 | const ptr_info = callee_ty.ptrInfo(zcu); |
| 7052 | if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Fn) { | |
| 7052 | if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { | |
| 7053 | 7053 | break :func_ty Type.fromInterned(ptr_info.child); |
| 7054 | 7054 | } |
| 7055 | 7055 | }, |
| 7056 | .Optional => { | |
| 7056 | .optional => { | |
| 7057 | 7057 | const opt_child = callee_ty.optionalChild(zcu); |
| 7058 | if (opt_child.zigTypeTag(zcu) == .Fn or (opt_child.isSinglePointer(zcu) and | |
| 7059 | opt_child.childType(zcu).zigTypeTag(zcu) == .Fn)) | |
| 7058 | if (opt_child.zigTypeTag(zcu) == .@"fn" or (opt_child.isSinglePointer(zcu) and | |
| 7059 | opt_child.childType(zcu).zigTypeTag(zcu) == .@"fn")) | |
| 7060 | 7060 | { |
| 7061 | 7061 | const msg = msg: { |
| 7062 | 7062 | const msg = try sema.errMsg(func_src, "cannot call optional type '{}'", .{ |
| ... | ... | @@ -7125,10 +7125,10 @@ fn callBuiltin( |
| 7125 | 7125 | const callee_ty = sema.typeOf(builtin_fn); |
| 7126 | 7126 | const func_ty = func_ty: { |
| 7127 | 7127 | switch (callee_ty.zigTypeTag(zcu)) { |
| 7128 | .Fn => break :func_ty callee_ty, | |
| 7129 | .Pointer => { | |
| 7128 | .@"fn" => break :func_ty callee_ty, | |
| 7129 | .pointer => { | |
| 7130 | 7130 | const ptr_info = callee_ty.ptrInfo(zcu); |
| 7131 | if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Fn) { | |
| 7131 | if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { | |
| 7132 | 7132 | break :func_ty Type.fromInterned(ptr_info.child); |
| 7133 | 7133 | } |
| 7134 | 7134 | }, |
| ... | ... | @@ -7276,7 +7276,7 @@ const CallArgsInfo = union(enum) { |
| 7276 | 7276 | // Resolve the arg! |
| 7277 | 7277 | const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst); |
| 7278 | 7278 | |
| 7279 | if (sema.typeOf(uncoerced_arg).zigTypeTag(zcu) == .NoReturn) { | |
| 7279 | if (sema.typeOf(uncoerced_arg).zigTypeTag(zcu) == .noreturn) { | |
| 7280 | 7280 | // This terminates resolution of arguments. The caller should |
| 7281 | 7281 | // propagate this. |
| 7282 | 7282 | return uncoerced_arg; |
| ... | ... | @@ -7863,7 +7863,7 @@ fn analyzeCall( |
| 7863 | 7863 | if (param_ty) |t| assert(!t.isGenericPoison()); |
| 7864 | 7864 | arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func); |
| 7865 | 7865 | try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_idx), arg_out.*); |
| 7866 | if (sema.typeOf(arg_out.*).zigTypeTag(zcu) == .NoReturn) { | |
| 7866 | if (sema.typeOf(arg_out.*).zigTypeTag(zcu) == .noreturn) { | |
| 7867 | 7867 | return arg_out.*; |
| 7868 | 7868 | } |
| 7869 | 7869 | } |
| ... | ... | @@ -7884,7 +7884,7 @@ fn analyzeCall( |
| 7884 | 7884 | } |
| 7885 | 7885 | } |
| 7886 | 7886 | |
| 7887 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Call).Struct.fields.len + | |
| 7887 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Call).@"struct".fields.len + | |
| 7888 | 7888 | args.len); |
| 7889 | 7889 | const func_inst = try block.addInst(.{ |
| 7890 | 7890 | .tag = call_tag, |
| ... | ... | @@ -7991,7 +7991,7 @@ fn analyzeInlineCallArg( |
| 7991 | 7991 | }; |
| 7992 | 7992 | new_param_types[arg_i.*] = param_ty; |
| 7993 | 7993 | const casted_arg = try args_info.analyzeArg(ics.caller(), arg_block, arg_i.*, Type.fromInterned(param_ty), func_ty_info, func_inst); |
| 7994 | if (ics.caller().typeOf(casted_arg).zigTypeTag(zcu) == .NoReturn) { | |
| 7994 | if (ics.caller().typeOf(casted_arg).zigTypeTag(zcu) == .noreturn) { | |
| 7995 | 7995 | return casted_arg; |
| 7996 | 7996 | } |
| 7997 | 7997 | const arg_src = args_info.argSrc(arg_block, arg_i.*); |
| ... | ... | @@ -8039,7 +8039,7 @@ fn analyzeInlineCallArg( |
| 8039 | 8039 | .param_anytype, .param_anytype_comptime => { |
| 8040 | 8040 | // No coercion needed. |
| 8041 | 8041 | const uncasted_arg = try args_info.analyzeArg(ics.caller(), arg_block, arg_i.*, Type.generic_poison, func_ty_info, func_inst); |
| 8042 | if (ics.caller().typeOf(uncasted_arg).zigTypeTag(zcu) == .NoReturn) { | |
| 8042 | if (ics.caller().typeOf(uncasted_arg).zigTypeTag(zcu) == .noreturn) { | |
| 8043 | 8043 | return uncasted_arg; |
| 8044 | 8044 | } |
| 8045 | 8045 | const arg_src = args_info.argSrc(arg_block, arg_i.*); |
| ... | ... | @@ -8228,7 +8228,7 @@ fn instantiateGenericCall( |
| 8228 | 8228 | const arg_ref = try args_info.analyzeArg(sema, block, arg_index, param_ty, generic_owner_ty_info, func); |
| 8229 | 8229 | try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_index), arg_ref); |
| 8230 | 8230 | const arg_ty = sema.typeOf(arg_ref); |
| 8231 | if (arg_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 8231 | if (arg_ty.zigTypeTag(zcu) == .noreturn) { | |
| 8232 | 8232 | // This terminates argument analysis. |
| 8233 | 8233 | return arg_ref; |
| 8234 | 8234 | } |
| ... | ... | @@ -8345,7 +8345,7 @@ fn instantiateGenericCall( |
| 8345 | 8345 | try sema.addReferenceEntry(call_src, AnalUnit.wrap(.{ .func = callee_index })); |
| 8346 | 8346 | try zcu.ensureFuncBodyAnalysisQueued(callee_index); |
| 8347 | 8347 | |
| 8348 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Call).Struct.fields.len + runtime_args.items.len); | |
| 8348 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Call).@"struct".fields.len + runtime_args.items.len); | |
| 8349 | 8349 | const result = try block.addInst(.{ |
| 8350 | 8350 | .tag = call_tag, |
| 8351 | 8351 | .data = .{ .pl_op = .{ |
| ... | ... | @@ -8404,9 +8404,9 @@ fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 8404 | 8404 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 8405 | 8405 | const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node }); |
| 8406 | 8406 | const child_type = try sema.resolveType(block, operand_src, inst_data.operand); |
| 8407 | if (child_type.zigTypeTag(zcu) == .Opaque) { | |
| 8407 | if (child_type.zigTypeTag(zcu) == .@"opaque") { | |
| 8408 | 8408 | return sema.fail(block, operand_src, "opaque type '{}' cannot be optional", .{child_type.fmt(pt)}); |
| 8409 | } else if (child_type.zigTypeTag(zcu) == .Null) { | |
| 8409 | } else if (child_type.zigTypeTag(zcu) == .null) { | |
| 8410 | 8410 | return sema.fail(block, operand_src, "type '{}' cannot be optional", .{child_type.fmt(pt)}); |
| 8411 | 8411 | } |
| 8412 | 8412 | const opt_type = try pt.optionalType(child_type.toIntern()); |
| ... | ... | @@ -8429,7 +8429,7 @@ fn zirArrayInitElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 8429 | 8429 | const indexable_ty = maybe_wrapped_indexable_ty.optEuBaseType(zcu); |
| 8430 | 8430 | try indexable_ty.resolveFields(pt); |
| 8431 | 8431 | assert(indexable_ty.isIndexable(zcu)); // validated by a previous instruction |
| 8432 | if (indexable_ty.zigTypeTag(zcu) == .Struct) { | |
| 8432 | if (indexable_ty.zigTypeTag(zcu) == .@"struct") { | |
| 8433 | 8433 | const elem_type = indexable_ty.fieldType(@intFromEnum(bin.rhs), zcu); |
| 8434 | 8434 | return Air.internedToRef(elem_type.toIntern()); |
| 8435 | 8435 | } else { |
| ... | ... | @@ -8447,7 +8447,7 @@ fn zirElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 8447 | 8447 | else => |e| return e, |
| 8448 | 8448 | }; |
| 8449 | 8449 | const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu); |
| 8450 | assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction | |
| 8450 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction | |
| 8451 | 8451 | const elem_ty = ptr_ty.childType(zcu); |
| 8452 | 8452 | if (elem_ty.toIntern() == .anyopaque_type) { |
| 8453 | 8453 | // The pointer's actual child type is effectively unknown, so it makes |
| ... | ... | @@ -8561,9 +8561,9 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 8561 | 8561 | fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: LazySrcLoc) !void { |
| 8562 | 8562 | const pt = sema.pt; |
| 8563 | 8563 | const zcu = pt.zcu; |
| 8564 | if (elem_type.zigTypeTag(zcu) == .Opaque) { | |
| 8564 | if (elem_type.zigTypeTag(zcu) == .@"opaque") { | |
| 8565 | 8565 | return sema.fail(block, elem_src, "array of opaque type '{}' not allowed", .{elem_type.fmt(pt)}); |
| 8566 | } else if (elem_type.zigTypeTag(zcu) == .NoReturn) { | |
| 8566 | } else if (elem_type.zigTypeTag(zcu) == .noreturn) { | |
| 8567 | 8567 | return sema.fail(block, elem_src, "array of 'noreturn' not allowed", .{}); |
| 8568 | 8568 | } |
| 8569 | 8569 | } |
| ... | ... | @@ -8597,7 +8597,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 8597 | 8597 | const error_set = try sema.resolveType(block, lhs_src, extra.lhs); |
| 8598 | 8598 | const payload = try sema.resolveType(block, rhs_src, extra.rhs); |
| 8599 | 8599 | |
| 8600 | if (error_set.zigTypeTag(zcu) != .ErrorSet) { | |
| 8600 | if (error_set.zigTypeTag(zcu) != .error_set) { | |
| 8601 | 8601 | return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{ |
| 8602 | 8602 | error_set.fmt(pt), |
| 8603 | 8603 | }); |
| ... | ... | @@ -8610,11 +8610,11 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 8610 | 8610 | fn validateErrorUnionPayloadType(sema: *Sema, block: *Block, payload_ty: Type, payload_src: LazySrcLoc) !void { |
| 8611 | 8611 | const pt = sema.pt; |
| 8612 | 8612 | const zcu = pt.zcu; |
| 8613 | if (payload_ty.zigTypeTag(zcu) == .Opaque) { | |
| 8613 | if (payload_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 8614 | 8614 | return sema.fail(block, payload_src, "error union with payload of opaque type '{}' not allowed", .{ |
| 8615 | 8615 | payload_ty.fmt(pt), |
| 8616 | 8616 | }); |
| 8617 | } else if (payload_ty.zigTypeTag(zcu) == .ErrorSet) { | |
| 8617 | } else if (payload_ty.zigTypeTag(zcu) == .error_set) { | |
| 8618 | 8618 | return sema.fail(block, payload_src, "error union with payload of error set type '{}' not allowed", .{ |
| 8619 | 8619 | payload_ty.fmt(pt), |
| 8620 | 8620 | }); |
| ... | ... | @@ -8741,7 +8741,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 8741 | 8741 | const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node }); |
| 8742 | 8742 | const lhs = try sema.resolveInst(extra.lhs); |
| 8743 | 8743 | const rhs = try sema.resolveInst(extra.rhs); |
| 8744 | if (sema.typeOf(lhs).zigTypeTag(zcu) == .Bool and sema.typeOf(rhs).zigTypeTag(zcu) == .Bool) { | |
| 8744 | if (sema.typeOf(lhs).zigTypeTag(zcu) == .bool and sema.typeOf(rhs).zigTypeTag(zcu) == .bool) { | |
| 8745 | 8745 | const msg = msg: { |
| 8746 | 8746 | const msg = try sema.errMsg(lhs_src, "expected error set type, found 'bool'", .{}); |
| 8747 | 8747 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -8752,9 +8752,9 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 8752 | 8752 | } |
| 8753 | 8753 | const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs); |
| 8754 | 8754 | const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs); |
| 8755 | if (lhs_ty.zigTypeTag(zcu) != .ErrorSet) | |
| 8755 | if (lhs_ty.zigTypeTag(zcu) != .error_set) | |
| 8756 | 8756 | return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{lhs_ty.fmt(pt)}); |
| 8757 | if (rhs_ty.zigTypeTag(zcu) != .ErrorSet) | |
| 8757 | if (rhs_ty.zigTypeTag(zcu) != .error_set) | |
| 8758 | 8758 | return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(pt)}); |
| 8759 | 8759 | |
| 8760 | 8760 | // Anything merged with anyerror is anyerror. |
| ... | ... | @@ -8807,8 +8807,8 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8807 | 8807 | const operand_ty = sema.typeOf(operand); |
| 8808 | 8808 | |
| 8809 | 8809 | const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(zcu)) { |
| 8810 | .Enum => operand, | |
| 8811 | .Union => blk: { | |
| 8810 | .@"enum" => operand, | |
| 8811 | .@"union" => blk: { | |
| 8812 | 8812 | try operand_ty.resolveFields(pt); |
| 8813 | 8813 | const tag_ty = operand_ty.unionTagType(zcu) orelse { |
| 8814 | 8814 | return sema.fail( |
| ... | ... | @@ -8865,7 +8865,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8865 | 8865 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt"); |
| 8866 | 8866 | const operand = try sema.resolveInst(extra.rhs); |
| 8867 | 8867 | |
| 8868 | if (dest_ty.zigTypeTag(zcu) != .Enum) { | |
| 8868 | if (dest_ty.zigTypeTag(zcu) != .@"enum") { | |
| 8869 | 8869 | return sema.fail(block, src, "expected enum, found '{}'", .{dest_ty.fmt(pt)}); |
| 8870 | 8870 | } |
| 8871 | 8871 | _ = try sema.checkIntType(block, operand_src, sema.typeOf(operand)); |
| ... | ... | @@ -8891,7 +8891,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8891 | 8891 | return Air.internedToRef((try pt.getCoerced(int_val, dest_ty)).toIntern()); |
| 8892 | 8892 | } |
| 8893 | 8893 | |
| 8894 | if (dest_ty.intTagType(zcu).zigTypeTag(zcu) == .ComptimeInt) { | |
| 8894 | if (dest_ty.intTagType(zcu).zigTypeTag(zcu) == .comptime_int) { | |
| 8895 | 8895 | return sema.failWithNeededComptime(block, operand_src, .{ |
| 8896 | 8896 | .needed_comptime_reason = "value being casted to enum with 'comptime_int' tag type must be comptime-known", |
| 8897 | 8897 | }); |
| ... | ... | @@ -8945,10 +8945,10 @@ fn analyzeOptionalPayloadPtr( |
| 8945 | 8945 | const pt = sema.pt; |
| 8946 | 8946 | const zcu = pt.zcu; |
| 8947 | 8947 | const optional_ptr_ty = sema.typeOf(optional_ptr); |
| 8948 | assert(optional_ptr_ty.zigTypeTag(zcu) == .Pointer); | |
| 8948 | assert(optional_ptr_ty.zigTypeTag(zcu) == .pointer); | |
| 8949 | 8949 | |
| 8950 | 8950 | const opt_type = optional_ptr_ty.childType(zcu); |
| 8951 | if (opt_type.zigTypeTag(zcu) != .Optional) { | |
| 8951 | if (opt_type.zigTypeTag(zcu) != .optional) { | |
| 8952 | 8952 | return sema.failWithExpectedOptionalType(block, src, opt_type); |
| 8953 | 8953 | } |
| 8954 | 8954 | |
| ... | ... | @@ -9019,8 +9019,8 @@ fn zirOptionalPayload( |
| 9019 | 9019 | const operand = try sema.resolveInst(inst_data.operand); |
| 9020 | 9020 | const operand_ty = sema.typeOf(operand); |
| 9021 | 9021 | const result_ty = switch (operand_ty.zigTypeTag(zcu)) { |
| 9022 | .Optional => operand_ty.optionalChild(zcu), | |
| 9023 | .Pointer => t: { | |
| 9022 | .optional => operand_ty.optionalChild(zcu), | |
| 9023 | .pointer => t: { | |
| 9024 | 9024 | if (operand_ty.ptrSize(zcu) != .C) { |
| 9025 | 9025 | return sema.failWithExpectedOptionalType(block, src, operand_ty); |
| 9026 | 9026 | } |
| ... | ... | @@ -9072,7 +9072,7 @@ fn zirErrUnionPayload( |
| 9072 | 9072 | const operand = try sema.resolveInst(inst_data.operand); |
| 9073 | 9073 | const operand_src = src; |
| 9074 | 9074 | const err_union_ty = sema.typeOf(operand); |
| 9075 | if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) { | |
| 9075 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | |
| 9076 | 9076 | return sema.fail(block, operand_src, "expected error union type, found '{}'", .{ |
| 9077 | 9077 | err_union_ty.fmt(pt), |
| 9078 | 9078 | }); |
| ... | ... | @@ -9138,9 +9138,9 @@ fn analyzeErrUnionPayloadPtr( |
| 9138 | 9138 | const pt = sema.pt; |
| 9139 | 9139 | const zcu = pt.zcu; |
| 9140 | 9140 | const operand_ty = sema.typeOf(operand); |
| 9141 | assert(operand_ty.zigTypeTag(zcu) == .Pointer); | |
| 9141 | assert(operand_ty.zigTypeTag(zcu) == .pointer); | |
| 9142 | 9142 | |
| 9143 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .ErrorUnion) { | |
| 9143 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) { | |
| 9144 | 9144 | return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| 9145 | 9145 | operand_ty.childType(zcu).fmt(pt), |
| 9146 | 9146 | }); |
| ... | ... | @@ -9216,7 +9216,7 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air |
| 9216 | 9216 | const pt = sema.pt; |
| 9217 | 9217 | const zcu = pt.zcu; |
| 9218 | 9218 | const operand_ty = sema.typeOf(operand); |
| 9219 | if (operand_ty.zigTypeTag(zcu) != .ErrorUnion) { | |
| 9219 | if (operand_ty.zigTypeTag(zcu) != .error_union) { | |
| 9220 | 9220 | return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| 9221 | 9221 | operand_ty.fmt(pt), |
| 9222 | 9222 | }); |
| ... | ... | @@ -9250,9 +9250,9 @@ fn analyzeErrUnionCodePtr(sema: *Sema, block: *Block, src: LazySrcLoc, operand: |
| 9250 | 9250 | const pt = sema.pt; |
| 9251 | 9251 | const zcu = pt.zcu; |
| 9252 | 9252 | const operand_ty = sema.typeOf(operand); |
| 9253 | assert(operand_ty.zigTypeTag(zcu) == .Pointer); | |
| 9253 | assert(operand_ty.zigTypeTag(zcu) == .pointer); | |
| 9254 | 9254 | |
| 9255 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .ErrorUnion) { | |
| 9255 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) { | |
| 9256 | 9256 | return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| 9257 | 9257 | operand_ty.childType(zcu).fmt(pt), |
| 9258 | 9258 | }); |
| ... | ... | @@ -9587,7 +9587,7 @@ fn funcCommon( |
| 9587 | 9587 | return sema.fail(block, param_src, "generic parameters not allowed in function with calling convention '{s}'", .{@tagName(cc_resolved)}); |
| 9588 | 9588 | } |
| 9589 | 9589 | if (!param_ty.isValidParamType(zcu)) { |
| 9590 | const opaque_str = if (param_ty.zigTypeTag(zcu) == .Opaque) "opaque " else ""; | |
| 9590 | const opaque_str = if (param_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; | |
| 9591 | 9591 | return sema.fail(block, param_src, "parameter of {s}type '{}' not allowed", .{ |
| 9592 | 9592 | opaque_str, param_ty.fmt(pt), |
| 9593 | 9593 | }); |
| ... | ... | @@ -9621,7 +9621,7 @@ fn funcCommon( |
| 9621 | 9621 | return sema.failWithOwnedErrorMsg(block, msg); |
| 9622 | 9622 | } |
| 9623 | 9623 | if (is_source_decl and !this_generic and is_noalias and |
| 9624 | !(param_ty.zigTypeTag(zcu) == .Pointer or param_ty.isPtrLikeOptional(zcu))) | |
| 9624 | !(param_ty.zigTypeTag(zcu) == .pointer or param_ty.isPtrLikeOptional(zcu))) | |
| 9625 | 9625 | { |
| 9626 | 9626 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); |
| 9627 | 9627 | } |
| ... | ... | @@ -9629,7 +9629,7 @@ fn funcCommon( |
| 9629 | 9629 | .Interrupt => if (target.cpu.arch.isX86()) { |
| 9630 | 9630 | const err_code_size = target.ptrBitWidth(); |
| 9631 | 9631 | switch (i) { |
| 9632 | 0 => if (param_ty.zigTypeTag(zcu) != .Pointer) return sema.fail(block, param_src, "first parameter of function with 'Interrupt' calling convention must be a pointer type", .{}), | |
| 9632 | 0 => if (param_ty.zigTypeTag(zcu) != .pointer) return sema.fail(block, param_src, "first parameter of function with 'Interrupt' calling convention must be a pointer type", .{}), | |
| 9633 | 9633 | 1 => if (param_ty.bitSize(zcu) != err_code_size) return sema.fail(block, param_src, "second parameter of function with 'Interrupt' calling convention must be a {d}-bit integer", .{err_code_size}), |
| 9634 | 9634 | else => return sema.fail(block, param_src, "'Interrupt' calling convention supports up to 2 parameters, found {d}", .{i + 1}), |
| 9635 | 9635 | } |
| ... | ... | @@ -9891,7 +9891,7 @@ fn finishFunc( |
| 9891 | 9891 | Type.fromInterned(ip.funcTypeReturnType(ip.typeOf(opt_func_index))); |
| 9892 | 9892 | |
| 9893 | 9893 | if (!return_type.isValidReturnType(zcu)) { |
| 9894 | const opaque_str = if (return_type.zigTypeTag(zcu) == .Opaque) "opaque " else ""; | |
| 9894 | const opaque_str = if (return_type.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; | |
| 9895 | 9895 | return sema.fail(block, ret_ty_src, "{s}return type '{}' not allowed", .{ |
| 9896 | 9896 | opaque_str, return_type.fmt(pt), |
| 9897 | 9897 | }); |
| ... | ... | @@ -9953,7 +9953,7 @@ fn finishFunc( |
| 9953 | 9953 | } |
| 9954 | 9954 | |
| 9955 | 9955 | switch (cc_resolved) { |
| 9956 | .Interrupt, .Signal => if (return_type.zigTypeTag(zcu) != .Void and return_type.zigTypeTag(zcu) != .NoReturn) { | |
| 9956 | .Interrupt, .Signal => if (return_type.zigTypeTag(zcu) != .void and return_type.zigTypeTag(zcu) != .noreturn) { | |
| 9957 | 9957 | return sema.fail(block, ret_ty_src, "function with calling convention '{s}' must return 'void' or 'noreturn'", .{@tagName(cc_resolved)}); |
| 9958 | 9958 | }, |
| 9959 | 9959 | .Inline => if (is_noinline) { |
| ... | ... | @@ -10154,11 +10154,11 @@ fn analyzeAs( |
| 10154 | 10154 | error.GenericPoison => return operand, |
| 10155 | 10155 | }; |
| 10156 | 10156 | |
| 10157 | if (dest_ty_tag == .Opaque) { | |
| 10157 | if (dest_ty_tag == .@"opaque") { | |
| 10158 | 10158 | return sema.fail(block, src, "cannot cast to opaque type '{}'", .{dest_ty.fmt(pt)}); |
| 10159 | 10159 | } |
| 10160 | 10160 | |
| 10161 | if (dest_ty_tag == .NoReturn) { | |
| 10161 | if (dest_ty_tag == .noreturn) { | |
| 10162 | 10162 | return sema.fail(block, src, "cannot cast to noreturn", .{}); |
| 10163 | 10163 | } |
| 10164 | 10164 | |
| ... | ... | @@ -10183,7 +10183,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10183 | 10183 | const operand = try sema.resolveInst(inst_data.operand); |
| 10184 | 10184 | const operand_ty = sema.typeOf(operand); |
| 10185 | 10185 | const ptr_ty = operand_ty.scalarType(zcu); |
| 10186 | const is_vector = operand_ty.zigTypeTag(zcu) == .Vector; | |
| 10186 | const is_vector = operand_ty.zigTypeTag(zcu) == .vector; | |
| 10187 | 10187 | if (!ptr_ty.isPtrAtRuntime(zcu)) { |
| 10188 | 10188 | return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(pt)}); |
| 10189 | 10189 | } |
| ... | ... | @@ -10305,7 +10305,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 10305 | 10305 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 10306 | 10306 | const struct_ty = sema.typeOf(object_ptr).childType(zcu); |
| 10307 | 10307 | switch (struct_ty.zigTypeTag(zcu)) { |
| 10308 | .Struct, .Union => { | |
| 10308 | .@"struct", .@"union" => { | |
| 10309 | 10309 | return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, true); |
| 10310 | 10310 | }, |
| 10311 | 10311 | else => { |
| ... | ... | @@ -10377,12 +10377,12 @@ fn intCast( |
| 10377 | 10377 | |
| 10378 | 10378 | if (try sema.isComptimeKnown(operand)) { |
| 10379 | 10379 | return sema.coerce(block, dest_ty, operand, operand_src); |
| 10380 | } else if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 10380 | } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) { | |
| 10381 | 10381 | return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_int'", .{}); |
| 10382 | 10382 | } |
| 10383 | 10383 | |
| 10384 | 10384 | try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, dest_ty_src, operand_src); |
| 10385 | const is_vector = dest_ty.zigTypeTag(zcu) == .Vector; | |
| 10385 | const is_vector = dest_ty.zigTypeTag(zcu) == .vector; | |
| 10386 | 10386 | |
| 10387 | 10387 | if ((try sema.typeHasOnePossibleValue(dest_ty))) |opv| { |
| 10388 | 10388 | // requirement: intCast(u0, input) iff input == 0 |
| ... | ... | @@ -10529,29 +10529,29 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10529 | 10529 | const operand = try sema.resolveInst(extra.rhs); |
| 10530 | 10530 | const operand_ty = sema.typeOf(operand); |
| 10531 | 10531 | switch (dest_ty.zigTypeTag(zcu)) { |
| 10532 | .AnyFrame, | |
| 10533 | .ComptimeFloat, | |
| 10534 | .ComptimeInt, | |
| 10535 | .EnumLiteral, | |
| 10536 | .ErrorSet, | |
| 10537 | .ErrorUnion, | |
| 10538 | .Fn, | |
| 10539 | .Frame, | |
| 10540 | .NoReturn, | |
| 10541 | .Null, | |
| 10542 | .Opaque, | |
| 10543 | .Optional, | |
| 10544 | .Type, | |
| 10545 | .Undefined, | |
| 10546 | .Void, | |
| 10532 | .@"anyframe", | |
| 10533 | .comptime_float, | |
| 10534 | .comptime_int, | |
| 10535 | .enum_literal, | |
| 10536 | .error_set, | |
| 10537 | .error_union, | |
| 10538 | .@"fn", | |
| 10539 | .frame, | |
| 10540 | .noreturn, | |
| 10541 | .null, | |
| 10542 | .@"opaque", | |
| 10543 | .optional, | |
| 10544 | .type, | |
| 10545 | .undefined, | |
| 10546 | .void, | |
| 10547 | 10547 | => return sema.fail(block, src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)}), |
| 10548 | 10548 | |
| 10549 | .Enum => { | |
| 10549 | .@"enum" => { | |
| 10550 | 10550 | const msg = msg: { |
| 10551 | 10551 | const msg = try sema.errMsg(src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)}); |
| 10552 | 10552 | errdefer msg.destroy(sema.gpa); |
| 10553 | 10553 | switch (operand_ty.zigTypeTag(zcu)) { |
| 10554 | .Int, .ComptimeInt => try sema.errNote(src, msg, "use @enumFromInt to cast from '{}'", .{operand_ty.fmt(pt)}), | |
| 10554 | .int, .comptime_int => try sema.errNote(src, msg, "use @enumFromInt to cast from '{}'", .{operand_ty.fmt(pt)}), | |
| 10555 | 10555 | else => {}, |
| 10556 | 10556 | } |
| 10557 | 10557 | |
| ... | ... | @@ -10560,13 +10560,13 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10560 | 10560 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10561 | 10561 | }, |
| 10562 | 10562 | |
| 10563 | .Pointer => { | |
| 10563 | .pointer => { | |
| 10564 | 10564 | const msg = msg: { |
| 10565 | 10565 | const msg = try sema.errMsg(src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)}); |
| 10566 | 10566 | errdefer msg.destroy(sema.gpa); |
| 10567 | 10567 | switch (operand_ty.zigTypeTag(zcu)) { |
| 10568 | .Int, .ComptimeInt => try sema.errNote(src, msg, "use @ptrFromInt to cast from '{}'", .{operand_ty.fmt(pt)}), | |
| 10569 | .Pointer => try sema.errNote(src, msg, "use @ptrCast to cast from '{}'", .{operand_ty.fmt(pt)}), | |
| 10568 | .int, .comptime_int => try sema.errNote(src, msg, "use @ptrFromInt to cast from '{}'", .{operand_ty.fmt(pt)}), | |
| 10569 | .pointer => try sema.errNote(src, msg, "use @ptrCast to cast from '{}'", .{operand_ty.fmt(pt)}), | |
| 10570 | 10570 | else => {}, |
| 10571 | 10571 | } |
| 10572 | 10572 | |
| ... | ... | @@ -10574,10 +10574,10 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10574 | 10574 | }; |
| 10575 | 10575 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10576 | 10576 | }, |
| 10577 | .Struct, .Union => if (dest_ty.containerLayout(zcu) == .auto) { | |
| 10577 | .@"struct", .@"union" => if (dest_ty.containerLayout(zcu) == .auto) { | |
| 10578 | 10578 | const container = switch (dest_ty.zigTypeTag(zcu)) { |
| 10579 | .Struct => "struct", | |
| 10580 | .Union => "union", | |
| 10579 | .@"struct" => "struct", | |
| 10580 | .@"union" => "union", | |
| 10581 | 10581 | else => unreachable, |
| 10582 | 10582 | }; |
| 10583 | 10583 | return sema.fail(block, src, "cannot @bitCast to '{}'; {s} does not have a guaranteed in-memory layout", .{ |
| ... | ... | @@ -10585,37 +10585,37 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10585 | 10585 | }); |
| 10586 | 10586 | }, |
| 10587 | 10587 | |
| 10588 | .Array, | |
| 10589 | .Bool, | |
| 10590 | .Float, | |
| 10591 | .Int, | |
| 10592 | .Vector, | |
| 10588 | .array, | |
| 10589 | .bool, | |
| 10590 | .float, | |
| 10591 | .int, | |
| 10592 | .vector, | |
| 10593 | 10593 | => {}, |
| 10594 | 10594 | } |
| 10595 | 10595 | switch (operand_ty.zigTypeTag(zcu)) { |
| 10596 | .AnyFrame, | |
| 10597 | .ComptimeFloat, | |
| 10598 | .ComptimeInt, | |
| 10599 | .EnumLiteral, | |
| 10600 | .ErrorSet, | |
| 10601 | .ErrorUnion, | |
| 10602 | .Fn, | |
| 10603 | .Frame, | |
| 10604 | .NoReturn, | |
| 10605 | .Null, | |
| 10606 | .Opaque, | |
| 10607 | .Optional, | |
| 10608 | .Type, | |
| 10609 | .Undefined, | |
| 10610 | .Void, | |
| 10596 | .@"anyframe", | |
| 10597 | .comptime_float, | |
| 10598 | .comptime_int, | |
| 10599 | .enum_literal, | |
| 10600 | .error_set, | |
| 10601 | .error_union, | |
| 10602 | .@"fn", | |
| 10603 | .frame, | |
| 10604 | .noreturn, | |
| 10605 | .null, | |
| 10606 | .@"opaque", | |
| 10607 | .optional, | |
| 10608 | .type, | |
| 10609 | .undefined, | |
| 10610 | .void, | |
| 10611 | 10611 | => return sema.fail(block, operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)}), |
| 10612 | 10612 | |
| 10613 | .Enum => { | |
| 10613 | .@"enum" => { | |
| 10614 | 10614 | const msg = msg: { |
| 10615 | 10615 | const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)}); |
| 10616 | 10616 | errdefer msg.destroy(sema.gpa); |
| 10617 | 10617 | switch (dest_ty.zigTypeTag(zcu)) { |
| 10618 | .Int, .ComptimeInt => try sema.errNote(operand_src, msg, "use @intFromEnum to cast to '{}'", .{dest_ty.fmt(pt)}), | |
| 10618 | .int, .comptime_int => try sema.errNote(operand_src, msg, "use @intFromEnum to cast to '{}'", .{dest_ty.fmt(pt)}), | |
| 10619 | 10619 | else => {}, |
| 10620 | 10620 | } |
| 10621 | 10621 | |
| ... | ... | @@ -10623,13 +10623,13 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10623 | 10623 | }; |
| 10624 | 10624 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10625 | 10625 | }, |
| 10626 | .Pointer => { | |
| 10626 | .pointer => { | |
| 10627 | 10627 | const msg = msg: { |
| 10628 | 10628 | const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)}); |
| 10629 | 10629 | errdefer msg.destroy(sema.gpa); |
| 10630 | 10630 | switch (dest_ty.zigTypeTag(zcu)) { |
| 10631 | .Int, .ComptimeInt => try sema.errNote(operand_src, msg, "use @intFromPtr to cast to '{}'", .{dest_ty.fmt(pt)}), | |
| 10632 | .Pointer => try sema.errNote(operand_src, msg, "use @ptrCast to cast to '{}'", .{dest_ty.fmt(pt)}), | |
| 10631 | .int, .comptime_int => try sema.errNote(operand_src, msg, "use @intFromPtr to cast to '{}'", .{dest_ty.fmt(pt)}), | |
| 10632 | .pointer => try sema.errNote(operand_src, msg, "use @ptrCast to cast to '{}'", .{dest_ty.fmt(pt)}), | |
| 10633 | 10633 | else => {}, |
| 10634 | 10634 | } |
| 10635 | 10635 | |
| ... | ... | @@ -10637,10 +10637,10 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10637 | 10637 | }; |
| 10638 | 10638 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10639 | 10639 | }, |
| 10640 | .Struct, .Union => if (operand_ty.containerLayout(zcu) == .auto) { | |
| 10640 | .@"struct", .@"union" => if (operand_ty.containerLayout(zcu) == .auto) { | |
| 10641 | 10641 | const container = switch (operand_ty.zigTypeTag(zcu)) { |
| 10642 | .Struct => "struct", | |
| 10643 | .Union => "union", | |
| 10642 | .@"struct" => "struct", | |
| 10643 | .@"union" => "union", | |
| 10644 | 10644 | else => unreachable, |
| 10645 | 10645 | }; |
| 10646 | 10646 | return sema.fail(block, operand_src, "cannot @bitCast from '{}'; {s} does not have a guaranteed in-memory layout", .{ |
| ... | ... | @@ -10648,11 +10648,11 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10648 | 10648 | }); |
| 10649 | 10649 | }, |
| 10650 | 10650 | |
| 10651 | .Array, | |
| 10652 | .Bool, | |
| 10653 | .Float, | |
| 10654 | .Int, | |
| 10655 | .Vector, | |
| 10651 | .array, | |
| 10652 | .bool, | |
| 10653 | .float, | |
| 10654 | .int, | |
| 10655 | .vector, | |
| 10656 | 10656 | => {}, |
| 10657 | 10657 | } |
| 10658 | 10658 | return sema.bitCast(block, dest_ty, operand, block.nodeOffset(inst_data.src_node), operand_src); |
| ... | ... | @@ -10677,12 +10677,12 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 10677 | 10677 | const operand_scalar_ty = operand_ty.scalarType(zcu); |
| 10678 | 10678 | |
| 10679 | 10679 | try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src); |
| 10680 | const is_vector = dest_ty.zigTypeTag(zcu) == .Vector; | |
| 10680 | const is_vector = dest_ty.zigTypeTag(zcu) == .vector; | |
| 10681 | 10681 | |
| 10682 | 10682 | const target = zcu.getTarget(); |
| 10683 | 10683 | const dest_is_comptime_float = switch (dest_scalar_ty.zigTypeTag(zcu)) { |
| 10684 | .ComptimeFloat => true, | |
| 10685 | .Float => false, | |
| 10684 | .comptime_float => true, | |
| 10685 | .float => false, | |
| 10686 | 10686 | else => return sema.fail( |
| 10687 | 10687 | block, |
| 10688 | 10688 | src, |
| ... | ... | @@ -10692,7 +10692,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 10692 | 10692 | }; |
| 10693 | 10693 | |
| 10694 | 10694 | switch (operand_scalar_ty.zigTypeTag(zcu)) { |
| 10695 | .ComptimeFloat, .Float, .ComptimeInt => {}, | |
| 10695 | .comptime_float, .float, .comptime_int => {}, | |
| 10696 | 10696 | else => return sema.fail( |
| 10697 | 10697 | block, |
| 10698 | 10698 | operand_src, |
| ... | ... | @@ -10787,7 +10787,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10787 | 10787 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 10788 | 10788 | const elem_index = try sema.resolveInst(extra.rhs); |
| 10789 | 10789 | const indexable_ty = sema.typeOf(array_ptr); |
| 10790 | if (indexable_ty.zigTypeTag(zcu) != .Pointer) { | |
| 10790 | if (indexable_ty.zigTypeTag(zcu) != .pointer) { | |
| 10791 | 10791 | const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node }); |
| 10792 | 10792 | const msg = msg: { |
| 10793 | 10793 | const msg = try sema.errMsg(capture_src, "pointer capture of non pointer type '{}'", .{ |
| ... | ... | @@ -10831,7 +10831,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile |
| 10831 | 10831 | const elem_index = try pt.intRef(Type.usize, extra.index); |
| 10832 | 10832 | const array_ty = sema.typeOf(array_ptr).childType(zcu); |
| 10833 | 10833 | switch (array_ty.zigTypeTag(zcu)) { |
| 10834 | .Array, .Vector => {}, | |
| 10834 | .array, .vector => {}, | |
| 10835 | 10835 | else => if (!array_ty.isTuple(zcu)) { |
| 10836 | 10836 | return sema.failWithArrayInitNotSupported(block, src, array_ty); |
| 10837 | 10837 | }, |
| ... | ... | @@ -11066,7 +11066,7 @@ const SwitchProngAnalysis = struct { |
| 11066 | 11066 | const pt = sema.pt; |
| 11067 | 11067 | const zcu = pt.zcu; |
| 11068 | 11068 | const operand_ty = sema.typeOf(spa.operand); |
| 11069 | if (operand_ty.zigTypeTag(zcu) != .Union) { | |
| 11069 | if (operand_ty.zigTypeTag(zcu) != .@"union") { | |
| 11070 | 11070 | const tag_capture_src: LazySrcLoc = .{ |
| 11071 | 11071 | .base_node_inst = capture_src.base_node_inst, |
| 11072 | 11072 | .offset = .{ .switch_tag_capture = capture_src.offset.switch_capture }, |
| ... | ... | @@ -11102,7 +11102,7 @@ const SwitchProngAnalysis = struct { |
| 11102 | 11102 | |
| 11103 | 11103 | if (inline_case_capture != .none) { |
| 11104 | 11104 | const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inline_case_capture, undefined) catch unreachable; |
| 11105 | if (operand_ty.zigTypeTag(zcu) == .Union) { | |
| 11105 | if (operand_ty.zigTypeTag(zcu) == .@"union") { | |
| 11106 | 11106 | const field_index: u32 = @intCast(operand_ty.unionTagFieldIndex(item_val, zcu).?); |
| 11107 | 11107 | const union_obj = zcu.typeToUnion(operand_ty).?; |
| 11108 | 11108 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| ... | ... | @@ -11139,7 +11139,7 @@ const SwitchProngAnalysis = struct { |
| 11139 | 11139 | } |
| 11140 | 11140 | |
| 11141 | 11141 | switch (operand_ty.zigTypeTag(zcu)) { |
| 11142 | .ErrorSet => if (spa.else_error_ty) |ty| { | |
| 11142 | .error_set => if (spa.else_error_ty) |ty| { | |
| 11143 | 11143 | return sema.bitCast(block, ty, spa.operand, operand_src, null); |
| 11144 | 11144 | } else { |
| 11145 | 11145 | try sema.analyzeUnreachable(block, operand_src, false); |
| ... | ... | @@ -11150,7 +11150,7 @@ const SwitchProngAnalysis = struct { |
| 11150 | 11150 | } |
| 11151 | 11151 | |
| 11152 | 11152 | switch (operand_ty.zigTypeTag(zcu)) { |
| 11153 | .Union => { | |
| 11153 | .@"union" => { | |
| 11154 | 11154 | const union_obj = zcu.typeToUnion(operand_ty).?; |
| 11155 | 11155 | const first_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, case_vals[0], undefined) catch unreachable; |
| 11156 | 11156 | |
| ... | ... | @@ -11370,9 +11370,9 @@ const SwitchProngAnalysis = struct { |
| 11370 | 11370 | break :len coerce_block.instructions.items.len; |
| 11371 | 11371 | }; |
| 11372 | 11372 | |
| 11373 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.SwitchBr).Struct.fields.len + | |
| 11373 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.SwitchBr).@"struct".fields.len + | |
| 11374 | 11374 | cases_extra.items.len + |
| 11375 | @typeInfo(Air.Block).Struct.fields.len + | |
| 11375 | @typeInfo(Air.Block).@"struct".fields.len + | |
| 11376 | 11376 | 1); |
| 11377 | 11377 | |
| 11378 | 11378 | const switch_br_inst: u32 = @intCast(sema.air_instructions.len); |
| ... | ... | @@ -11396,7 +11396,7 @@ const SwitchProngAnalysis = struct { |
| 11396 | 11396 | |
| 11397 | 11397 | return capture_block_inst.toRef(); |
| 11398 | 11398 | }, |
| 11399 | .ErrorSet => { | |
| 11399 | .error_set => { | |
| 11400 | 11400 | if (capture_byref) { |
| 11401 | 11401 | return sema.fail( |
| 11402 | 11402 | block, |
| ... | ... | @@ -11444,18 +11444,18 @@ fn switchCond( |
| 11444 | 11444 | const zcu = pt.zcu; |
| 11445 | 11445 | const operand_ty = sema.typeOf(operand); |
| 11446 | 11446 | switch (operand_ty.zigTypeTag(zcu)) { |
| 11447 | .Type, | |
| 11448 | .Void, | |
| 11449 | .Bool, | |
| 11450 | .Int, | |
| 11451 | .Float, | |
| 11452 | .ComptimeFloat, | |
| 11453 | .ComptimeInt, | |
| 11454 | .EnumLiteral, | |
| 11455 | .Pointer, | |
| 11456 | .Fn, | |
| 11457 | .ErrorSet, | |
| 11458 | .Enum, | |
| 11447 | .type, | |
| 11448 | .void, | |
| 11449 | .bool, | |
| 11450 | .int, | |
| 11451 | .float, | |
| 11452 | .comptime_float, | |
| 11453 | .comptime_int, | |
| 11454 | .enum_literal, | |
| 11455 | .pointer, | |
| 11456 | .@"fn", | |
| 11457 | .error_set, | |
| 11458 | .@"enum", | |
| 11459 | 11459 | => { |
| 11460 | 11460 | if (operand_ty.isSlice(zcu)) { |
| 11461 | 11461 | return sema.fail(block, src, "switch on type '{}'", .{operand_ty.fmt(pt)}); |
| ... | ... | @@ -11466,7 +11466,7 @@ fn switchCond( |
| 11466 | 11466 | return operand; |
| 11467 | 11467 | }, |
| 11468 | 11468 | |
| 11469 | .Union => { | |
| 11469 | .@"union" => { | |
| 11470 | 11470 | try operand_ty.resolveFields(pt); |
| 11471 | 11471 | const enum_ty = operand_ty.unionTagType(zcu) orelse { |
| 11472 | 11472 | const msg = msg: { |
| ... | ... | @@ -11482,17 +11482,17 @@ fn switchCond( |
| 11482 | 11482 | return sema.unionToTag(block, enum_ty, operand, src); |
| 11483 | 11483 | }, |
| 11484 | 11484 | |
| 11485 | .ErrorUnion, | |
| 11486 | .NoReturn, | |
| 11487 | .Array, | |
| 11488 | .Struct, | |
| 11489 | .Undefined, | |
| 11490 | .Null, | |
| 11491 | .Optional, | |
| 11492 | .Opaque, | |
| 11493 | .Vector, | |
| 11494 | .Frame, | |
| 11495 | .AnyFrame, | |
| 11485 | .error_union, | |
| 11486 | .noreturn, | |
| 11487 | .array, | |
| 11488 | .@"struct", | |
| 11489 | .undefined, | |
| 11490 | .null, | |
| 11491 | .optional, | |
| 11492 | .@"opaque", | |
| 11493 | .vector, | |
| 11494 | .frame, | |
| 11495 | .@"anyframe", | |
| 11496 | 11496 | => return sema.fail(block, src, "switch on type '{}'", .{operand_ty.fmt(pt)}), |
| 11497 | 11497 | } |
| 11498 | 11498 | } |
| ... | ... | @@ -11593,7 +11593,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 11593 | 11593 | else |
| 11594 | 11594 | operand_ty; |
| 11595 | 11595 | |
| 11596 | if (operand_err_set.zigTypeTag(zcu) != .ErrorUnion) { | |
| 11596 | if (operand_err_set.zigTypeTag(zcu) != .error_union) { | |
| 11597 | 11597 | return sema.fail(block, switch_src, "expected error union type, found '{}'", .{ |
| 11598 | 11598 | operand_ty.fmt(pt), |
| 11599 | 11599 | }); |
| ... | ... | @@ -11791,7 +11791,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 11791 | 11791 | true, |
| 11792 | 11792 | ); |
| 11793 | 11793 | |
| 11794 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + | |
| 11794 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len + | |
| 11795 | 11795 | true_instructions.len + sub_block.instructions.items.len); |
| 11796 | 11796 | |
| 11797 | 11797 | _ = try child_block.addInst(.{ |
| ... | ... | @@ -11886,7 +11886,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11886 | 11886 | }; |
| 11887 | 11887 | |
| 11888 | 11888 | const maybe_union_ty = sema.typeOf(raw_operand_val); |
| 11889 | const union_originally = maybe_union_ty.zigTypeTag(zcu) == .Union; | |
| 11889 | const union_originally = maybe_union_ty.zigTypeTag(zcu) == .@"union"; | |
| 11890 | 11890 | |
| 11891 | 11891 | // Duplicate checking variables later also used for `inline else`. |
| 11892 | 11892 | var seen_enum_fields: []?LazySrcLoc = &.{}; |
| ... | ... | @@ -11904,7 +11904,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11904 | 11904 | var empty_enum = false; |
| 11905 | 11905 | |
| 11906 | 11906 | const operand_ty = sema.typeOf(operand); |
| 11907 | const err_set = operand_ty.zigTypeTag(zcu) == .ErrorSet; | |
| 11907 | const err_set = operand_ty.zigTypeTag(zcu) == .error_set; | |
| 11908 | 11908 | |
| 11909 | 11909 | var else_error_ty: ?Type = null; |
| 11910 | 11910 | |
| ... | ... | @@ -11936,8 +11936,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11936 | 11936 | |
| 11937 | 11937 | // Validate for duplicate items, missing else prong, and invalid range. |
| 11938 | 11938 | switch (operand_ty.zigTypeTag(zcu)) { |
| 11939 | .Union => unreachable, // handled in `switchCond` | |
| 11940 | .Enum => { | |
| 11939 | .@"union" => unreachable, // handled in `switchCond` | |
| 11940 | .@"enum" => { | |
| 11941 | 11941 | seen_enum_fields = try gpa.alloc(?LazySrcLoc, operand_ty.enumFieldCount(zcu)); |
| 11942 | 11942 | empty_enum = seen_enum_fields.len == 0 and !operand_ty.isNonexhaustiveEnum(zcu); |
| 11943 | 11943 | @memset(seen_enum_fields, null); |
| ... | ... | @@ -12046,7 +12046,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12046 | 12046 | ); |
| 12047 | 12047 | } |
| 12048 | 12048 | }, |
| 12049 | .ErrorSet => else_error_ty = try validateErrSetSwitch( | |
| 12049 | .error_set => else_error_ty = try validateErrSetSwitch( | |
| 12050 | 12050 | sema, |
| 12051 | 12051 | block, |
| 12052 | 12052 | &seen_errors, |
| ... | ... | @@ -12058,7 +12058,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12058 | 12058 | .{ .body = special.body, .end = special.end, .src = special_prong_src }, |
| 12059 | 12059 | special_prong == .@"else", |
| 12060 | 12060 | ), |
| 12061 | .Int, .ComptimeInt => { | |
| 12061 | .int, .comptime_int => { | |
| 12062 | 12062 | var extra_index: usize = special.end; |
| 12063 | 12063 | { |
| 12064 | 12064 | var scalar_i: u32 = 0; |
| ... | ... | @@ -12137,7 +12137,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12137 | 12137 | } |
| 12138 | 12138 | |
| 12139 | 12139 | check_range: { |
| 12140 | if (operand_ty.zigTypeTag(zcu) == .Int) { | |
| 12140 | if (operand_ty.zigTypeTag(zcu) == .int) { | |
| 12141 | 12141 | const min_int = try operand_ty.minInt(pt, operand_ty); |
| 12142 | 12142 | const max_int = try operand_ty.maxInt(pt, operand_ty); |
| 12143 | 12143 | if (try range_set.spans(min_int.toIntern(), max_int.toIntern())) { |
| ... | ... | @@ -12162,7 +12162,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12162 | 12162 | } |
| 12163 | 12163 | } |
| 12164 | 12164 | }, |
| 12165 | .Bool => { | |
| 12165 | .bool => { | |
| 12166 | 12166 | var extra_index: usize = special.end; |
| 12167 | 12167 | { |
| 12168 | 12168 | var scalar_i: u32 = 0; |
| ... | ... | @@ -12238,7 +12238,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12238 | 12238 | }, |
| 12239 | 12239 | } |
| 12240 | 12240 | }, |
| 12241 | .EnumLiteral, .Void, .Fn, .Pointer, .Type => { | |
| 12241 | .enum_literal, .void, .@"fn", .pointer, .type => { | |
| 12242 | 12242 | if (special_prong != .@"else") { |
| 12243 | 12243 | return sema.fail( |
| 12244 | 12244 | block, |
| ... | ... | @@ -12306,19 +12306,19 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12306 | 12306 | } |
| 12307 | 12307 | }, |
| 12308 | 12308 | |
| 12309 | .ErrorUnion, | |
| 12310 | .NoReturn, | |
| 12311 | .Array, | |
| 12312 | .Struct, | |
| 12313 | .Undefined, | |
| 12314 | .Null, | |
| 12315 | .Optional, | |
| 12316 | .Opaque, | |
| 12317 | .Vector, | |
| 12318 | .Frame, | |
| 12319 | .AnyFrame, | |
| 12320 | .ComptimeFloat, | |
| 12321 | .Float, | |
| 12309 | .error_union, | |
| 12310 | .noreturn, | |
| 12311 | .array, | |
| 12312 | .@"struct", | |
| 12313 | .undefined, | |
| 12314 | .null, | |
| 12315 | .optional, | |
| 12316 | .@"opaque", | |
| 12317 | .vector, | |
| 12318 | .frame, | |
| 12319 | .@"anyframe", | |
| 12320 | .comptime_float, | |
| 12321 | .float, | |
| 12322 | 12322 | => return sema.fail(block, operand_src, "invalid switch operand type '{}'", .{ |
| 12323 | 12323 | operand_ty.fmt(pt), |
| 12324 | 12324 | }), |
| ... | ... | @@ -12401,7 +12401,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12401 | 12401 | if (err_set and try sema.maybeErrorUnwrap(block, special.body, operand, operand_src, false)) { |
| 12402 | 12402 | return .unreachable_value; |
| 12403 | 12403 | } |
| 12404 | if (zcu.backendSupportsFeature(.is_named_enum_value) and block.wantSafety() and operand_ty.zigTypeTag(zcu) == .Enum and | |
| 12404 | if (zcu.backendSupportsFeature(.is_named_enum_value) and block.wantSafety() and operand_ty.zigTypeTag(zcu) == .@"enum" and | |
| 12405 | 12405 | (!operand_ty.isNonexhaustiveEnum(zcu) or union_originally)) |
| 12406 | 12406 | { |
| 12407 | 12407 | try sema.zirDbgStmt(block, cond_dbg_node_index); |
| ... | ... | @@ -12502,7 +12502,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12502 | 12502 | const block = child_block.parent.?; |
| 12503 | 12503 | |
| 12504 | 12504 | const estimated_cases_extra = (scalar_cases_len + multi_cases_len) * |
| 12505 | @typeInfo(Air.SwitchBr.Case).Struct.fields.len + 2; | |
| 12505 | @typeInfo(Air.SwitchBr.Case).@"struct".fields.len + 2; | |
| 12506 | 12506 | var cases_extra = try std.ArrayListUnmanaged(u32).initCapacity(gpa, estimated_cases_extra); |
| 12507 | 12507 | defer cases_extra.deinit(gpa); |
| 12508 | 12508 | |
| ... | ... | @@ -12536,7 +12536,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12536 | 12536 | const unresolved_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable; |
| 12537 | 12537 | const item_val = sema.resolveLazyValue(unresolved_item_val) catch unreachable; |
| 12538 | 12538 | const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?; |
| 12539 | break :blk field_ty.zigTypeTag(zcu) != .NoReturn; | |
| 12539 | break :blk field_ty.zigTypeTag(zcu) != .noreturn; | |
| 12540 | 12540 | } else true; |
| 12541 | 12541 | |
| 12542 | 12542 | const prong_hint: std.builtin.BranchHint = if (err_set and |
| ... | ... | @@ -12669,7 +12669,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12669 | 12669 | const analyze_body = if (union_originally) blk: { |
| 12670 | 12670 | const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable; |
| 12671 | 12671 | const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?; |
| 12672 | break :blk field_ty.zigTypeTag(zcu) != .NoReturn; | |
| 12672 | break :blk field_ty.zigTypeTag(zcu) != .noreturn; | |
| 12673 | 12673 | } else true; |
| 12674 | 12674 | |
| 12675 | 12675 | if (emit_bb) try sema.emitBackwardBranch(block, block.src(.{ .switch_case_item = .{ |
| ... | ... | @@ -12722,7 +12722,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12722 | 12722 | for (items) |item| { |
| 12723 | 12723 | const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable; |
| 12724 | 12724 | const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?; |
| 12725 | if (field_ty.zigTypeTag(zcu) != .NoReturn) break true; | |
| 12725 | if (field_ty.zigTypeTag(zcu) != .noreturn) break true; | |
| 12726 | 12726 | } else false |
| 12727 | 12727 | else |
| 12728 | 12728 | true; |
| ... | ... | @@ -12847,7 +12847,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12847 | 12847 | } else { |
| 12848 | 12848 | try sema.air_extra.ensureUnusedCapacity( |
| 12849 | 12849 | gpa, |
| 12850 | @typeInfo(Air.CondBr).Struct.fields.len + prev_then_body.len + cond_body.len, | |
| 12850 | @typeInfo(Air.CondBr).@"struct".fields.len + prev_then_body.len + cond_body.len, | |
| 12851 | 12851 | ); |
| 12852 | 12852 | |
| 12853 | 12853 | sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| ... | ... | @@ -12869,7 +12869,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12869 | 12869 | if (special.body.len != 0 or !is_first or case_block.wantSafety()) { |
| 12870 | 12870 | var emit_bb = false; |
| 12871 | 12871 | if (special.is_inline) switch (operand_ty.zigTypeTag(zcu)) { |
| 12872 | .Enum => { | |
| 12872 | .@"enum" => { | |
| 12873 | 12873 | if (operand_ty.isNonexhaustiveEnum(zcu) and !union_originally) { |
| 12874 | 12874 | return sema.fail(block, special_prong_src, "cannot enumerate values of type '{}' for 'inline else'", .{ |
| 12875 | 12875 | operand_ty.fmt(pt), |
| ... | ... | @@ -12887,7 +12887,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12887 | 12887 | |
| 12888 | 12888 | const analyze_body = if (union_originally) blk: { |
| 12889 | 12889 | const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?; |
| 12890 | break :blk field_ty.zigTypeTag(zcu) != .NoReturn; | |
| 12890 | break :blk field_ty.zigTypeTag(zcu) != .noreturn; | |
| 12891 | 12891 | } else true; |
| 12892 | 12892 | |
| 12893 | 12893 | if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src); |
| ... | ... | @@ -12920,7 +12920,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12920 | 12920 | cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items)); |
| 12921 | 12921 | } |
| 12922 | 12922 | }, |
| 12923 | .ErrorSet => { | |
| 12923 | .error_set => { | |
| 12924 | 12924 | if (operand_ty.isAnyError(zcu)) { |
| 12925 | 12925 | return sema.fail(block, special_prong_src, "cannot enumerate values of type '{}' for 'inline else'", .{ |
| 12926 | 12926 | operand_ty.fmt(pt), |
| ... | ... | @@ -12966,7 +12966,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12966 | 12966 | cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items)); |
| 12967 | 12967 | } |
| 12968 | 12968 | }, |
| 12969 | .Int => { | |
| 12969 | .int => { | |
| 12970 | 12970 | var it = try RangeSetUnhandledIterator.init(sema, operand_ty, range_set); |
| 12971 | 12971 | while (try it.next()) |cur| { |
| 12972 | 12972 | cases_len += 1; |
| ... | ... | @@ -13001,7 +13001,7 @@ fn analyzeSwitchRuntimeBlock( |
| 13001 | 13001 | cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items)); |
| 13002 | 13002 | } |
| 13003 | 13003 | }, |
| 13004 | .Bool => { | |
| 13004 | .bool => { | |
| 13005 | 13005 | if (true_count == 0) { |
| 13006 | 13006 | cases_len += 1; |
| 13007 | 13007 | |
| ... | ... | @@ -13073,7 +13073,7 @@ fn analyzeSwitchRuntimeBlock( |
| 13073 | 13073 | |
| 13074 | 13074 | if (zcu.backendSupportsFeature(.is_named_enum_value) and |
| 13075 | 13075 | special.body.len != 0 and block.wantSafety() and |
| 13076 | operand_ty.zigTypeTag(zcu) == .Enum and | |
| 13076 | operand_ty.zigTypeTag(zcu) == .@"enum" and | |
| 13077 | 13077 | (!operand_ty.isNonexhaustiveEnum(zcu) or union_originally)) |
| 13078 | 13078 | { |
| 13079 | 13079 | try sema.zirDbgStmt(&case_block, cond_dbg_node_index); |
| ... | ... | @@ -13086,7 +13086,7 @@ fn analyzeSwitchRuntimeBlock( |
| 13086 | 13086 | if (seen_field != null) continue; |
| 13087 | 13087 | const union_obj = zcu.typeToUnion(maybe_union_ty).?; |
| 13088 | 13088 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[index]); |
| 13089 | if (field_ty.zigTypeTag(zcu) != .NoReturn) break true; | |
| 13089 | if (field_ty.zigTypeTag(zcu) != .noreturn) break true; | |
| 13090 | 13090 | } else false |
| 13091 | 13091 | else |
| 13092 | 13092 | true; |
| ... | ... | @@ -13128,7 +13128,7 @@ fn analyzeSwitchRuntimeBlock( |
| 13128 | 13128 | } else { |
| 13129 | 13129 | try branch_hints.append(gpa, .none); // we have the range conditionals first |
| 13130 | 13130 | try sema.air_extra.ensureUnusedCapacity(gpa, prev_then_body.len + |
| 13131 | @typeInfo(Air.CondBr).Struct.fields.len + case_block.instructions.items.len); | |
| 13131 | @typeInfo(Air.CondBr).@"struct".fields.len + case_block.instructions.items.len); | |
| 13132 | 13132 | |
| 13133 | 13133 | sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 13134 | 13134 | .then_body_len = @intCast(prev_then_body.len), |
| ... | ... | @@ -13145,7 +13145,7 @@ fn analyzeSwitchRuntimeBlock( |
| 13145 | 13145 | |
| 13146 | 13146 | assert(branch_hints.items.len == cases_len + 1); |
| 13147 | 13147 | |
| 13148 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.SwitchBr).Struct.fields.len + | |
| 13148 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.SwitchBr).@"struct".fields.len + | |
| 13149 | 13149 | cases_extra.items.len + final_else_body.len + |
| 13150 | 13150 | (std.math.divCeil(usize, branch_hints.items.len, 10) catch unreachable)); // branch hints |
| 13151 | 13151 | |
| ... | ... | @@ -13847,7 +13847,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind |
| 13847 | 13847 | const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node; |
| 13848 | 13848 | const err_operand = try sema.resolveInst(err_inst_data.operand); |
| 13849 | 13849 | const operand_ty = sema.typeOf(err_operand); |
| 13850 | if (operand_ty.zigTypeTag(zcu) == .ErrorSet) { | |
| 13850 | if (operand_ty.zigTypeTag(zcu) == .error_set) { | |
| 13851 | 13851 | try sema.maybeErrorUnwrapComptime(block, body, err_operand); |
| 13852 | 13852 | return; |
| 13853 | 13853 | } |
| ... | ... | @@ -14076,9 +14076,9 @@ fn zirShl( |
| 14076 | 14076 | if (try rhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 14077 | 14077 | return lhs; |
| 14078 | 14078 | } |
| 14079 | if (scalar_ty.zigTypeTag(zcu) != .ComptimeInt and air_tag != .shl_sat) { | |
| 14079 | if (scalar_ty.zigTypeTag(zcu) != .comptime_int and air_tag != .shl_sat) { | |
| 14080 | 14080 | const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits); |
| 14081 | if (rhs_ty.zigTypeTag(zcu) == .Vector) { | |
| 14081 | if (rhs_ty.zigTypeTag(zcu) == .vector) { | |
| 14082 | 14082 | var i: usize = 0; |
| 14083 | 14083 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { |
| 14084 | 14084 | const rhs_elem = try rhs_val.elemValue(pt, i); |
| ... | ... | @@ -14097,7 +14097,7 @@ fn zirShl( |
| 14097 | 14097 | }); |
| 14098 | 14098 | } |
| 14099 | 14099 | } |
| 14100 | if (rhs_ty.zigTypeTag(zcu) == .Vector) { | |
| 14100 | if (rhs_ty.zigTypeTag(zcu) == .vector) { | |
| 14101 | 14101 | var i: usize = 0; |
| 14102 | 14102 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { |
| 14103 | 14103 | const rhs_elem = try rhs_val.elemValue(pt, i); |
| ... | ... | @@ -14118,12 +14118,12 @@ fn zirShl( |
| 14118 | 14118 | const runtime_src = if (maybe_lhs_val) |lhs_val| rs: { |
| 14119 | 14119 | if (lhs_val.isUndef(zcu)) return pt.undefRef(lhs_ty); |
| 14120 | 14120 | const rhs_val = maybe_rhs_val orelse { |
| 14121 | if (scalar_ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 14121 | if (scalar_ty.zigTypeTag(zcu) == .comptime_int) { | |
| 14122 | 14122 | return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{}); |
| 14123 | 14123 | } |
| 14124 | 14124 | break :rs rhs_src; |
| 14125 | 14125 | }; |
| 14126 | const val = if (scalar_ty.zigTypeTag(zcu) == .ComptimeInt) | |
| 14126 | const val = if (scalar_ty.zigTypeTag(zcu) == .comptime_int) | |
| 14127 | 14127 | try lhs_val.shl(rhs_val, lhs_ty, sema.arena, pt) |
| 14128 | 14128 | else switch (air_tag) { |
| 14129 | 14129 | .shl_exact => val: { |
| ... | ... | @@ -14158,7 +14158,7 @@ fn zirShl( |
| 14158 | 14158 | const bit_count = scalar_ty.intInfo(zcu).bits; |
| 14159 | 14159 | if (!std.math.isPowerOfTwo(bit_count)) { |
| 14160 | 14160 | const bit_count_val = try pt.intValue(scalar_rhs_ty, bit_count); |
| 14161 | const ok = if (rhs_ty.zigTypeTag(zcu) == .Vector) ok: { | |
| 14161 | const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: { | |
| 14162 | 14162 | const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern()); |
| 14163 | 14163 | const lt = try block.addCmpVector(rhs, bit_count_inst, .lt); |
| 14164 | 14164 | break :ok try block.addInst(.{ |
| ... | ... | @@ -14188,7 +14188,7 @@ fn zirShl( |
| 14188 | 14188 | } }, |
| 14189 | 14189 | }); |
| 14190 | 14190 | const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty); |
| 14191 | const any_ov_bit = if (lhs_ty.zigTypeTag(zcu) == .Vector) | |
| 14191 | const any_ov_bit = if (lhs_ty.zigTypeTag(zcu) == .vector) | |
| 14192 | 14192 | try block.addInst(.{ |
| 14193 | 14193 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, |
| 14194 | 14194 | .data = .{ .reduce = .{ |
| ... | ... | @@ -14242,9 +14242,9 @@ fn zirShr( |
| 14242 | 14242 | if (try rhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 14243 | 14243 | return lhs; |
| 14244 | 14244 | } |
| 14245 | if (scalar_ty.zigTypeTag(zcu) != .ComptimeInt) { | |
| 14245 | if (scalar_ty.zigTypeTag(zcu) != .comptime_int) { | |
| 14246 | 14246 | const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits); |
| 14247 | if (rhs_ty.zigTypeTag(zcu) == .Vector) { | |
| 14247 | if (rhs_ty.zigTypeTag(zcu) == .vector) { | |
| 14248 | 14248 | var i: usize = 0; |
| 14249 | 14249 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { |
| 14250 | 14250 | const rhs_elem = try rhs_val.elemValue(pt, i); |
| ... | ... | @@ -14263,7 +14263,7 @@ fn zirShr( |
| 14263 | 14263 | }); |
| 14264 | 14264 | } |
| 14265 | 14265 | } |
| 14266 | if (rhs_ty.zigTypeTag(zcu) == .Vector) { | |
| 14266 | if (rhs_ty.zigTypeTag(zcu) == .vector) { | |
| 14267 | 14267 | var i: usize = 0; |
| 14268 | 14268 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { |
| 14269 | 14269 | const rhs_elem = try rhs_val.elemValue(pt, i); |
| ... | ... | @@ -14297,7 +14297,7 @@ fn zirShr( |
| 14297 | 14297 | } |
| 14298 | 14298 | } else rhs_src; |
| 14299 | 14299 | |
| 14300 | if (maybe_rhs_val == null and scalar_ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 14300 | if (maybe_rhs_val == null and scalar_ty.zigTypeTag(zcu) == .comptime_int) { | |
| 14301 | 14301 | return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{}); |
| 14302 | 14302 | } |
| 14303 | 14303 | |
| ... | ... | @@ -14308,7 +14308,7 @@ fn zirShr( |
| 14308 | 14308 | if (!std.math.isPowerOfTwo(bit_count)) { |
| 14309 | 14309 | const bit_count_val = try pt.intValue(rhs_ty.scalarType(zcu), bit_count); |
| 14310 | 14310 | |
| 14311 | const ok = if (rhs_ty.zigTypeTag(zcu) == .Vector) ok: { | |
| 14311 | const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: { | |
| 14312 | 14312 | const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern()); |
| 14313 | 14313 | const lt = try block.addCmpVector(rhs, bit_count_inst, .lt); |
| 14314 | 14314 | break :ok try block.addInst(.{ |
| ... | ... | @@ -14328,7 +14328,7 @@ fn zirShr( |
| 14328 | 14328 | if (air_tag == .shr_exact) { |
| 14329 | 14329 | const back = try block.addBinOp(.shl, result, rhs); |
| 14330 | 14330 | |
| 14331 | const ok = if (rhs_ty.zigTypeTag(zcu) == .Vector) ok: { | |
| 14331 | const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: { | |
| 14332 | 14332 | const eql = try block.addCmpVector(lhs, back, .eq); |
| 14333 | 14333 | break :ok try block.addInst(.{ |
| 14334 | 14334 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, |
| ... | ... | @@ -14374,7 +14374,7 @@ fn zirBitwise( |
| 14374 | 14374 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| 14375 | 14375 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); |
| 14376 | 14376 | |
| 14377 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 14377 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 14378 | 14378 | |
| 14379 | 14379 | if (!is_int) { |
| 14380 | 14380 | return sema.fail(block, src, "invalid operands to binary bitwise expression: '{s}' and '{s}'", .{ @tagName(lhs_ty.zigTypeTag(zcu)), @tagName(rhs_ty.zigTypeTag(zcu)) }); |
| ... | ... | @@ -14418,7 +14418,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 14418 | 14418 | const operand_type = sema.typeOf(operand); |
| 14419 | 14419 | const scalar_type = operand_type.scalarType(zcu); |
| 14420 | 14420 | |
| 14421 | if (scalar_type.zigTypeTag(zcu) != .Int) { | |
| 14421 | if (scalar_type.zigTypeTag(zcu) != .int) { | |
| 14422 | 14422 | return sema.fail(block, src, "unable to perform binary not operation on type '{}'", .{ |
| 14423 | 14423 | operand_type.fmt(pt), |
| 14424 | 14424 | }); |
| ... | ... | @@ -14427,7 +14427,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 14427 | 14427 | if (try sema.resolveValue(operand)) |val| { |
| 14428 | 14428 | if (val.isUndef(zcu)) { |
| 14429 | 14429 | return pt.undefRef(operand_type); |
| 14430 | } else if (operand_type.zigTypeTag(zcu) == .Vector) { | |
| 14430 | } else if (operand_type.zigTypeTag(zcu) == .vector) { | |
| 14431 | 14431 | const vec_len = try sema.usizeCast(block, operand_src, operand_type.vectorLen(zcu)); |
| 14432 | 14432 | const elems = try sema.arena.alloc(InternPool.Index, vec_len); |
| 14433 | 14433 | for (elems, 0..) |*elem, i| { |
| ... | ... | @@ -14647,19 +14647,19 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14647 | 14647 | .child = resolved_elem_ty.toIntern(), |
| 14648 | 14648 | }); |
| 14649 | 14649 | const ptr_addrspace = p: { |
| 14650 | if (lhs_ty.zigTypeTag(zcu) == .Pointer) break :p lhs_ty.ptrAddressSpace(zcu); | |
| 14651 | if (rhs_ty.zigTypeTag(zcu) == .Pointer) break :p rhs_ty.ptrAddressSpace(zcu); | |
| 14650 | if (lhs_ty.zigTypeTag(zcu) == .pointer) break :p lhs_ty.ptrAddressSpace(zcu); | |
| 14651 | if (rhs_ty.zigTypeTag(zcu) == .pointer) break :p rhs_ty.ptrAddressSpace(zcu); | |
| 14652 | 14652 | break :p null; |
| 14653 | 14653 | }; |
| 14654 | 14654 | |
| 14655 | 14655 | const runtime_src = if (switch (lhs_ty.zigTypeTag(zcu)) { |
| 14656 | .Array, .Struct => try sema.resolveValue(lhs), | |
| 14657 | .Pointer => try sema.resolveDefinedValue(block, lhs_src, lhs), | |
| 14656 | .array, .@"struct" => try sema.resolveValue(lhs), | |
| 14657 | .pointer => try sema.resolveDefinedValue(block, lhs_src, lhs), | |
| 14658 | 14658 | else => unreachable, |
| 14659 | 14659 | }) |lhs_val| rs: { |
| 14660 | 14660 | if (switch (rhs_ty.zigTypeTag(zcu)) { |
| 14661 | .Array, .Struct => try sema.resolveValue(rhs), | |
| 14662 | .Pointer => try sema.resolveDefinedValue(block, rhs_src, rhs), | |
| 14661 | .array, .@"struct" => try sema.resolveValue(rhs), | |
| 14662 | .pointer => try sema.resolveDefinedValue(block, rhs_src, rhs), | |
| 14663 | 14663 | else => unreachable, |
| 14664 | 14664 | }) |rhs_val| { |
| 14665 | 14665 | const lhs_sub_val = if (lhs_ty.isSinglePointer(zcu)) |
| ... | ... | @@ -14789,8 +14789,8 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins |
| 14789 | 14789 | const zcu = pt.zcu; |
| 14790 | 14790 | const operand_ty = sema.typeOf(operand); |
| 14791 | 14791 | switch (operand_ty.zigTypeTag(zcu)) { |
| 14792 | .Array => return operand_ty.arrayInfo(zcu), | |
| 14793 | .Pointer => { | |
| 14792 | .array => return operand_ty.arrayInfo(zcu), | |
| 14793 | .pointer => { | |
| 14794 | 14794 | const ptr_info = operand_ty.ptrInfo(zcu); |
| 14795 | 14795 | switch (ptr_info.flags.size) { |
| 14796 | 14796 | .Slice => { |
| ... | ... | @@ -14807,14 +14807,14 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins |
| 14807 | 14807 | }; |
| 14808 | 14808 | }, |
| 14809 | 14809 | .One => { |
| 14810 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Array) { | |
| 14810 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { | |
| 14811 | 14811 | return Type.fromInterned(ptr_info.child).arrayInfo(zcu); |
| 14812 | 14812 | } |
| 14813 | 14813 | }, |
| 14814 | 14814 | .C, .Many => {}, |
| 14815 | 14815 | } |
| 14816 | 14816 | }, |
| 14817 | .Struct => { | |
| 14817 | .@"struct" => { | |
| 14818 | 14818 | if (operand_ty.isTuple(zcu) and peer_ty.isIndexable(zcu)) { |
| 14819 | 14819 | assert(!peer_ty.isTuple(zcu)); |
| 14820 | 14820 | return .{ |
| ... | ... | @@ -14934,12 +14934,12 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14934 | 14934 | const lhs_len = uncoerced_lhs_ty.structFieldCount(zcu); |
| 14935 | 14935 | const lhs_dest_ty = switch (res_ty.zigTypeTag(zcu)) { |
| 14936 | 14936 | else => break :no_coerce, |
| 14937 | .Array => try pt.arrayType(.{ | |
| 14937 | .array => try pt.arrayType(.{ | |
| 14938 | 14938 | .child = res_ty.childType(zcu).toIntern(), |
| 14939 | 14939 | .len = lhs_len, |
| 14940 | 14940 | .sentinel = if (res_ty.sentinel(zcu)) |s| s.toIntern() else .none, |
| 14941 | 14941 | }), |
| 14942 | .Vector => try pt.vectorType(.{ | |
| 14942 | .vector => try pt.vectorType(.{ | |
| 14943 | 14943 | .child = res_ty.childType(zcu).toIntern(), |
| 14944 | 14944 | .len = lhs_len, |
| 14945 | 14945 | }), |
| ... | ... | @@ -14971,7 +14971,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14971 | 14971 | const msg = try sema.errMsg(lhs_src, "expected indexable; found '{}'", .{lhs_ty.fmt(pt)}); |
| 14972 | 14972 | errdefer msg.destroy(sema.gpa); |
| 14973 | 14973 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 14974 | .Int, .Float, .ComptimeFloat, .ComptimeInt, .Vector => { | |
| 14974 | .int, .float, .comptime_float, .comptime_int, .vector => { | |
| 14975 | 14975 | try sema.errNote(operator_src, msg, "this operator multiplies arrays; use std.math.pow for exponentiation", .{}); |
| 14976 | 14976 | }, |
| 14977 | 14977 | else => {}, |
| ... | ... | @@ -14996,7 +14996,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14996 | 14996 | .child = lhs_info.elem_type.toIntern(), |
| 14997 | 14997 | }); |
| 14998 | 14998 | |
| 14999 | const ptr_addrspace = if (lhs_ty.zigTypeTag(zcu) == .Pointer) lhs_ty.ptrAddressSpace(zcu) else null; | |
| 14999 | const ptr_addrspace = if (lhs_ty.zigTypeTag(zcu) == .pointer) lhs_ty.ptrAddressSpace(zcu) else null; | |
| 15000 | 15000 | const lhs_len = try sema.usizeCast(block, lhs_src, lhs_info.len); |
| 15001 | 15001 | |
| 15002 | 15002 | if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| ct: { |
| ... | ... | @@ -15096,7 +15096,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15096 | 15096 | const rhs_scalar_ty = rhs_ty.scalarType(zcu); |
| 15097 | 15097 | |
| 15098 | 15098 | if (rhs_scalar_ty.isUnsignedInt(zcu) or switch (rhs_scalar_ty.zigTypeTag(zcu)) { |
| 15099 | .Int, .ComptimeInt, .Float, .ComptimeFloat => false, | |
| 15099 | .int, .comptime_int, .float, .comptime_float => false, | |
| 15100 | 15100 | else => true, |
| 15101 | 15101 | }) { |
| 15102 | 15102 | return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(pt)}); |
| ... | ... | @@ -15129,7 +15129,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 15129 | 15129 | const rhs_scalar_ty = rhs_ty.scalarType(zcu); |
| 15130 | 15130 | |
| 15131 | 15131 | switch (rhs_scalar_ty.zigTypeTag(zcu)) { |
| 15132 | .Int, .ComptimeInt, .Float, .ComptimeFloat => {}, | |
| 15132 | .int, .comptime_int, .float, .comptime_float => {}, | |
| 15133 | 15133 | else => return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(pt)}), |
| 15134 | 15134 | } |
| 15135 | 15135 | |
| ... | ... | @@ -15187,15 +15187,15 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15187 | 15187 | const rhs_scalar_ty = rhs_ty.scalarType(zcu); |
| 15188 | 15188 | const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu); |
| 15189 | 15189 | |
| 15190 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 15190 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 15191 | 15191 | |
| 15192 | 15192 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div); |
| 15193 | 15193 | |
| 15194 | 15194 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 15195 | 15195 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 15196 | 15196 | |
| 15197 | if ((lhs_ty.zigTypeTag(zcu) == .ComptimeFloat and rhs_ty.zigTypeTag(zcu) == .ComptimeInt) or | |
| 15198 | (lhs_ty.zigTypeTag(zcu) == .ComptimeInt and rhs_ty.zigTypeTag(zcu) == .ComptimeFloat)) | |
| 15197 | if ((lhs_ty.zigTypeTag(zcu) == .comptime_float and rhs_ty.zigTypeTag(zcu) == .comptime_int) or | |
| 15198 | (lhs_ty.zigTypeTag(zcu) == .comptime_int and rhs_ty.zigTypeTag(zcu) == .comptime_float)) | |
| 15199 | 15199 | { |
| 15200 | 15200 | // If it makes a difference whether we coerce to ints or floats before doing the division, error. |
| 15201 | 15201 | // If lhs % rhs is 0, it doesn't matter. |
| ... | ... | @@ -15240,13 +15240,13 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15240 | 15240 | // * other float type: result is undefined |
| 15241 | 15241 | // If the lhs is undefined, result is undefined. |
| 15242 | 15242 | switch (scalar_tag) { |
| 15243 | .Int, .ComptimeInt, .ComptimeFloat => { | |
| 15243 | .int, .comptime_int, .comptime_float => { | |
| 15244 | 15244 | if (maybe_lhs_val) |lhs_val| { |
| 15245 | 15245 | if (!lhs_val.isUndef(zcu)) { |
| 15246 | 15246 | if (try lhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 15247 | 15247 | const scalar_zero = switch (scalar_tag) { |
| 15248 | .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15249 | .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15248 | .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15249 | .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15250 | 15250 | else => unreachable, |
| 15251 | 15251 | }; |
| 15252 | 15252 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| ... | ... | @@ -15352,7 +15352,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15352 | 15352 | const lhs_scalar_ty = lhs_ty.scalarType(zcu); |
| 15353 | 15353 | const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu); |
| 15354 | 15354 | |
| 15355 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 15355 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 15356 | 15356 | |
| 15357 | 15357 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact); |
| 15358 | 15358 | |
| ... | ... | @@ -15382,8 +15382,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15382 | 15382 | } else { |
| 15383 | 15383 | if (try lhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 15384 | 15384 | const scalar_zero = switch (scalar_tag) { |
| 15385 | .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15386 | .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15385 | .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15386 | .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15387 | 15387 | else => unreachable, |
| 15388 | 15388 | }; |
| 15389 | 15389 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| ... | ... | @@ -15439,7 +15439,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15439 | 15439 | const ok = if (!is_int) ok: { |
| 15440 | 15440 | const floored = try block.addUnOp(.floor, result); |
| 15441 | 15441 | |
| 15442 | if (resolved_type.zigTypeTag(zcu) == .Vector) { | |
| 15442 | if (resolved_type.zigTypeTag(zcu) == .vector) { | |
| 15443 | 15443 | const eql = try block.addCmpVector(result, floored, .eq); |
| 15444 | 15444 | break :ok try block.addInst(.{ |
| 15445 | 15445 | .tag = switch (block.float_mode) { |
| ... | ... | @@ -15462,11 +15462,11 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15462 | 15462 | const remainder = try block.addBinOp(.rem, casted_lhs, casted_rhs); |
| 15463 | 15463 | |
| 15464 | 15464 | const scalar_zero = switch (scalar_tag) { |
| 15465 | .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15466 | .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15465 | .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15466 | .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15467 | 15467 | else => unreachable, |
| 15468 | 15468 | }; |
| 15469 | if (resolved_type.zigTypeTag(zcu) == .Vector) { | |
| 15469 | if (resolved_type.zigTypeTag(zcu) == .vector) { | |
| 15470 | 15470 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| 15471 | 15471 | const zero = Air.internedToRef(zero_val.toIntern()); |
| 15472 | 15472 | const eql = try block.addCmpVector(remainder, zero, .eq); |
| ... | ... | @@ -15519,7 +15519,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15519 | 15519 | const rhs_scalar_ty = rhs_ty.scalarType(zcu); |
| 15520 | 15520 | const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu); |
| 15521 | 15521 | |
| 15522 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 15522 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 15523 | 15523 | |
| 15524 | 15524 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor); |
| 15525 | 15525 | |
| ... | ... | @@ -15550,8 +15550,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15550 | 15550 | if (!lhs_val.isUndef(zcu)) { |
| 15551 | 15551 | if (try lhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 15552 | 15552 | const scalar_zero = switch (scalar_tag) { |
| 15553 | .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15554 | .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15553 | .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15554 | .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15555 | 15555 | else => unreachable, |
| 15556 | 15556 | }; |
| 15557 | 15557 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| ... | ... | @@ -15630,7 +15630,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15630 | 15630 | const rhs_scalar_ty = rhs_ty.scalarType(zcu); |
| 15631 | 15631 | const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu); |
| 15632 | 15632 | |
| 15633 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 15633 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 15634 | 15634 | |
| 15635 | 15635 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc); |
| 15636 | 15636 | |
| ... | ... | @@ -15661,8 +15661,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15661 | 15661 | if (!lhs_val.isUndef(zcu)) { |
| 15662 | 15662 | if (try lhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 15663 | 15663 | const scalar_zero = switch (scalar_tag) { |
| 15664 | .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15665 | .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15664 | .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15665 | .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15666 | 15666 | else => unreachable, |
| 15667 | 15667 | }; |
| 15668 | 15668 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| ... | ... | @@ -15756,7 +15756,7 @@ fn addDivIntOverflowSafety( |
| 15756 | 15756 | } |
| 15757 | 15757 | |
| 15758 | 15758 | var ok: Air.Inst.Ref = .none; |
| 15759 | if (resolved_type.zigTypeTag(zcu) == .Vector) { | |
| 15759 | if (resolved_type.zigTypeTag(zcu) == .vector) { | |
| 15760 | 15760 | if (maybe_lhs_val == null) { |
| 15761 | 15761 | const min_int_ref = Air.internedToRef(min_int.toIntern()); |
| 15762 | 15762 | ok = try block.addCmpVector(casted_lhs, min_int_ref, .neq); |
| ... | ... | @@ -15819,7 +15819,7 @@ fn addDivByZeroSafety( |
| 15819 | 15819 | try pt.intValue(resolved_type.scalarType(zcu), 0) |
| 15820 | 15820 | else |
| 15821 | 15821 | try pt.floatValue(resolved_type.scalarType(zcu), 0.0); |
| 15822 | const ok = if (resolved_type.zigTypeTag(zcu) == .Vector) ok: { | |
| 15822 | const ok = if (resolved_type.zigTypeTag(zcu) == .vector) ok: { | |
| 15823 | 15823 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| 15824 | 15824 | const zero = Air.internedToRef(zero_val.toIntern()); |
| 15825 | 15825 | const ok = try block.addCmpVector(casted_rhs, zero, .neq); |
| ... | ... | @@ -15867,7 +15867,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15867 | 15867 | .override = &[_]?LazySrcLoc{ lhs_src, rhs_src }, |
| 15868 | 15868 | }); |
| 15869 | 15869 | |
| 15870 | const is_vector = resolved_type.zigTypeTag(zcu) == .Vector; | |
| 15870 | const is_vector = resolved_type.zigTypeTag(zcu) == .vector; | |
| 15871 | 15871 | |
| 15872 | 15872 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| 15873 | 15873 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); |
| ... | ... | @@ -15876,7 +15876,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15876 | 15876 | const rhs_scalar_ty = rhs_ty.scalarType(zcu); |
| 15877 | 15877 | const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu); |
| 15878 | 15878 | |
| 15879 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 15879 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 15880 | 15880 | |
| 15881 | 15881 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem); |
| 15882 | 15882 | |
| ... | ... | @@ -15904,8 +15904,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15904 | 15904 | } |
| 15905 | 15905 | if (try lhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 15906 | 15906 | const scalar_zero = switch (scalar_tag) { |
| 15907 | .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15908 | .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15907 | .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0), | |
| 15908 | .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0), | |
| 15909 | 15909 | else => unreachable, |
| 15910 | 15910 | }; |
| 15911 | 15911 | const zero_val = if (is_vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ |
| ... | ... | @@ -15987,7 +15987,7 @@ fn intRem( |
| 15987 | 15987 | ) CompileError!Value { |
| 15988 | 15988 | const pt = sema.pt; |
| 15989 | 15989 | const zcu = pt.zcu; |
| 15990 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 15990 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 15991 | 15991 | const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 15992 | 15992 | const scalar_ty = ty.scalarType(zcu); |
| 15993 | 15993 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -16058,7 +16058,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 16058 | 16058 | |
| 16059 | 16059 | const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu); |
| 16060 | 16060 | |
| 16061 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 16061 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 16062 | 16062 | |
| 16063 | 16063 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod); |
| 16064 | 16064 | |
| ... | ... | @@ -16154,7 +16154,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 16154 | 16154 | |
| 16155 | 16155 | const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu); |
| 16156 | 16156 | |
| 16157 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 16157 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 16158 | 16158 | |
| 16159 | 16159 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem); |
| 16160 | 16160 | |
| ... | ... | @@ -16265,7 +16265,7 @@ fn zirOverflowArithmetic( |
| 16265 | 16265 | const lhs = try sema.coerce(block, dest_ty, uncasted_lhs, lhs_src); |
| 16266 | 16266 | const rhs = try sema.coerce(block, rhs_dest_ty, uncasted_rhs, rhs_src); |
| 16267 | 16267 | |
| 16268 | if (dest_ty.scalarType(zcu).zigTypeTag(zcu) != .Int) { | |
| 16268 | if (dest_ty.scalarType(zcu).zigTypeTag(zcu) != .int) { | |
| 16269 | 16269 | return sema.fail(block, src, "expected vector of integers or integer tag type, found '{}'", .{dest_ty.fmt(pt)}); |
| 16270 | 16270 | } |
| 16271 | 16271 | |
| ... | ... | @@ -16438,7 +16438,7 @@ fn zirOverflowArithmetic( |
| 16438 | 16438 | fn splat(sema: *Sema, ty: Type, val: Value) !Value { |
| 16439 | 16439 | const pt = sema.pt; |
| 16440 | 16440 | const zcu = pt.zcu; |
| 16441 | if (ty.zigTypeTag(zcu) != .Vector) return val; | |
| 16441 | if (ty.zigTypeTag(zcu) != .vector) return val; | |
| 16442 | 16442 | const repeated = try pt.intern(.{ .aggregate = .{ |
| 16443 | 16443 | .ty = ty.toIntern(), |
| 16444 | 16444 | .storage = .{ .repeated_elem = val.toIntern() }, |
| ... | ... | @@ -16450,7 +16450,7 @@ fn overflowArithmeticTupleType(sema: *Sema, ty: Type) !Type { |
| 16450 | 16450 | const pt = sema.pt; |
| 16451 | 16451 | const zcu = pt.zcu; |
| 16452 | 16452 | const ip = &zcu.intern_pool; |
| 16453 | const ov_ty = if (ty.zigTypeTag(zcu) == .Vector) try pt.vectorType(.{ | |
| 16453 | const ov_ty = if (ty.zigTypeTag(zcu) == .vector) try pt.vectorType(.{ | |
| 16454 | 16454 | .len = ty.vectorLen(zcu), |
| 16455 | 16455 | .child = .u1_type, |
| 16456 | 16456 | }) else Type.u1; |
| ... | ... | @@ -16485,8 +16485,8 @@ fn analyzeArithmetic( |
| 16485 | 16485 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(zcu); |
| 16486 | 16486 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 16487 | 16487 | |
| 16488 | if (lhs_zig_ty_tag == .Pointer) { | |
| 16489 | if (rhs_zig_ty_tag == .Pointer) { | |
| 16488 | if (lhs_zig_ty_tag == .pointer) { | |
| 16489 | if (rhs_zig_ty_tag == .pointer) { | |
| 16490 | 16490 | if (lhs_ty.ptrSize(zcu) != .Slice and rhs_ty.ptrSize(zcu) != .Slice) { |
| 16491 | 16491 | if (zir_tag != .sub) { |
| 16492 | 16492 | return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction"); |
| ... | ... | @@ -16569,7 +16569,7 @@ fn analyzeArithmetic( |
| 16569 | 16569 | const scalar_type = resolved_type.scalarType(zcu); |
| 16570 | 16570 | const scalar_tag = scalar_type.zigTypeTag(zcu); |
| 16571 | 16571 | |
| 16572 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 16572 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 16573 | 16573 | |
| 16574 | 16574 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, zir_tag); |
| 16575 | 16575 | |
| ... | ... | @@ -16667,7 +16667,7 @@ fn analyzeArithmetic( |
| 16667 | 16667 | return pt.undefRef(resolved_type); |
| 16668 | 16668 | } |
| 16669 | 16669 | |
| 16670 | const val = if (scalar_tag == .ComptimeInt) | |
| 16670 | const val = if (scalar_tag == .comptime_int) | |
| 16671 | 16671 | try sema.intAdd(lhs_val, rhs_val, resolved_type, undefined) |
| 16672 | 16672 | else |
| 16673 | 16673 | try lhs_val.intAddSat(rhs_val, resolved_type, sema.arena, pt); |
| ... | ... | @@ -16765,7 +16765,7 @@ fn analyzeArithmetic( |
| 16765 | 16765 | return pt.undefRef(resolved_type); |
| 16766 | 16766 | } |
| 16767 | 16767 | if (maybe_rhs_val) |rhs_val| { |
| 16768 | const val = if (scalar_tag == .ComptimeInt) | |
| 16768 | const val = if (scalar_tag == .comptime_int) | |
| 16769 | 16769 | try sema.intSub(lhs_val, rhs_val, resolved_type, undefined) |
| 16770 | 16770 | else |
| 16771 | 16771 | try lhs_val.intSubSat(rhs_val, resolved_type, sema.arena, pt); |
| ... | ... | @@ -16789,13 +16789,13 @@ fn analyzeArithmetic( |
| 16789 | 16789 | // the result is nan. |
| 16790 | 16790 | // If either of the operands are nan, the result is nan. |
| 16791 | 16791 | const scalar_zero = switch (scalar_tag) { |
| 16792 | .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 0.0), | |
| 16793 | .ComptimeInt, .Int => try pt.intValue(scalar_type, 0), | |
| 16792 | .comptime_float, .float => try pt.floatValue(scalar_type, 0.0), | |
| 16793 | .comptime_int, .int => try pt.intValue(scalar_type, 0), | |
| 16794 | 16794 | else => unreachable, |
| 16795 | 16795 | }; |
| 16796 | 16796 | const scalar_one = switch (scalar_tag) { |
| 16797 | .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 1.0), | |
| 16798 | .ComptimeInt, .Int => try pt.intValue(scalar_type, 1), | |
| 16797 | .comptime_float, .float => try pt.floatValue(scalar_type, 1.0), | |
| 16798 | .comptime_int, .int => try pt.intValue(scalar_type, 1), | |
| 16799 | 16799 | else => unreachable, |
| 16800 | 16800 | }; |
| 16801 | 16801 | if (maybe_lhs_val) |lhs_val| { |
| ... | ... | @@ -16875,13 +16875,13 @@ fn analyzeArithmetic( |
| 16875 | 16875 | // If either of the operands are one, result is the other operand. |
| 16876 | 16876 | // If either of the operands are undefined, result is undefined. |
| 16877 | 16877 | const scalar_zero = switch (scalar_tag) { |
| 16878 | .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 0.0), | |
| 16879 | .ComptimeInt, .Int => try pt.intValue(scalar_type, 0), | |
| 16878 | .comptime_float, .float => try pt.floatValue(scalar_type, 0.0), | |
| 16879 | .comptime_int, .int => try pt.intValue(scalar_type, 0), | |
| 16880 | 16880 | else => unreachable, |
| 16881 | 16881 | }; |
| 16882 | 16882 | const scalar_one = switch (scalar_tag) { |
| 16883 | .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 1.0), | |
| 16884 | .ComptimeInt, .Int => try pt.intValue(scalar_type, 1), | |
| 16883 | .comptime_float, .float => try pt.floatValue(scalar_type, 1.0), | |
| 16884 | .comptime_int, .int => try pt.intValue(scalar_type, 1), | |
| 16885 | 16885 | else => unreachable, |
| 16886 | 16886 | }; |
| 16887 | 16887 | if (maybe_lhs_val) |lhs_val| { |
| ... | ... | @@ -16920,13 +16920,13 @@ fn analyzeArithmetic( |
| 16920 | 16920 | // If either of the operands are one, result is the other operand. |
| 16921 | 16921 | // If either of the operands are undefined, result is undefined. |
| 16922 | 16922 | const scalar_zero = switch (scalar_tag) { |
| 16923 | .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 0.0), | |
| 16924 | .ComptimeInt, .Int => try pt.intValue(scalar_type, 0), | |
| 16923 | .comptime_float, .float => try pt.floatValue(scalar_type, 0.0), | |
| 16924 | .comptime_int, .int => try pt.intValue(scalar_type, 0), | |
| 16925 | 16925 | else => unreachable, |
| 16926 | 16926 | }; |
| 16927 | 16927 | const scalar_one = switch (scalar_tag) { |
| 16928 | .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 1.0), | |
| 16929 | .ComptimeInt, .Int => try pt.intValue(scalar_type, 1), | |
| 16928 | .comptime_float, .float => try pt.floatValue(scalar_type, 1.0), | |
| 16929 | .comptime_int, .int => try pt.intValue(scalar_type, 1), | |
| 16930 | 16930 | else => unreachable, |
| 16931 | 16931 | }; |
| 16932 | 16932 | if (maybe_lhs_val) |lhs_val| { |
| ... | ... | @@ -16956,7 +16956,7 @@ fn analyzeArithmetic( |
| 16956 | 16956 | return pt.undefRef(resolved_type); |
| 16957 | 16957 | } |
| 16958 | 16958 | |
| 16959 | const val = if (scalar_tag == .ComptimeInt) | |
| 16959 | const val = if (scalar_tag == .comptime_int) | |
| 16960 | 16960 | try lhs_val.intMul(rhs_val, resolved_type, undefined, sema.arena, pt) |
| 16961 | 16961 | else |
| 16962 | 16962 | try lhs_val.intMulSat(rhs_val, resolved_type, sema.arena, pt); |
| ... | ... | @@ -16971,7 +16971,7 @@ fn analyzeArithmetic( |
| 16971 | 16971 | |
| 16972 | 16972 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 16973 | 16973 | |
| 16974 | if (block.wantSafety() and want_safety and scalar_tag == .Int) { | |
| 16974 | if (block.wantSafety() and want_safety and scalar_tag == .int) { | |
| 16975 | 16975 | if (zcu.backendSupportsFeature(.safety_checked_instructions)) { |
| 16976 | 16976 | if (air_tag != air_tag_safe) { |
| 16977 | 16977 | _ = try sema.preparePanicId(block, src, .integer_overflow); |
| ... | ... | @@ -16997,7 +16997,7 @@ fn analyzeArithmetic( |
| 16997 | 16997 | } }, |
| 16998 | 16998 | }); |
| 16999 | 16999 | const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty); |
| 17000 | const any_ov_bit = if (resolved_type.zigTypeTag(zcu) == .Vector) | |
| 17000 | const any_ov_bit = if (resolved_type.zigTypeTag(zcu) == .vector) | |
| 17001 | 17001 | try block.addInst(.{ |
| 17002 | 17002 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, |
| 17003 | 17003 | .data = .{ .reduce = .{ |
| ... | ... | @@ -17170,7 +17170,7 @@ fn zirAsm( |
| 17170 | 17170 | |
| 17171 | 17171 | var extra_i = extra.end; |
| 17172 | 17172 | var output_type_bits = extra.data.output_type_bits; |
| 17173 | var needed_capacity: usize = @typeInfo(Air.Asm).Struct.fields.len + outputs_len + inputs_len; | |
| 17173 | var needed_capacity: usize = @typeInfo(Air.Asm).@"struct".fields.len + outputs_len + inputs_len; | |
| 17174 | 17174 | |
| 17175 | 17175 | const ConstraintName = struct { c: []const u8, n: []const u8 }; |
| 17176 | 17176 | const out_args = try sema.arena.alloc(Air.Inst.Ref, outputs_len); |
| ... | ... | @@ -17217,8 +17217,8 @@ fn zirAsm( |
| 17217 | 17217 | const uncasted_arg = try sema.resolveInst(input.data.operand); |
| 17218 | 17218 | const uncasted_arg_ty = sema.typeOf(uncasted_arg); |
| 17219 | 17219 | switch (uncasted_arg_ty.zigTypeTag(zcu)) { |
| 17220 | .ComptimeInt => arg.* = try sema.coerce(block, Type.usize, uncasted_arg, src), | |
| 17221 | .ComptimeFloat => arg.* = try sema.coerce(block, Type.f64, uncasted_arg, src), | |
| 17220 | .comptime_int => arg.* = try sema.coerce(block, Type.usize, uncasted_arg, src), | |
| 17221 | .comptime_float => arg.* = try sema.coerce(block, Type.f64, uncasted_arg, src), | |
| 17222 | 17222 | else => { |
| 17223 | 17223 | arg.* = uncasted_arg; |
| 17224 | 17224 | }, |
| ... | ... | @@ -17312,32 +17312,32 @@ fn zirCmpEq( |
| 17312 | 17312 | const rhs_ty = sema.typeOf(rhs); |
| 17313 | 17313 | const lhs_ty_tag = lhs_ty.zigTypeTag(zcu); |
| 17314 | 17314 | const rhs_ty_tag = rhs_ty.zigTypeTag(zcu); |
| 17315 | if (lhs_ty_tag == .Null and rhs_ty_tag == .Null) { | |
| 17315 | if (lhs_ty_tag == .null and rhs_ty_tag == .null) { | |
| 17316 | 17316 | // null == null, null != null |
| 17317 | 17317 | return if (op == .eq) .bool_true else .bool_false; |
| 17318 | 17318 | } |
| 17319 | 17319 | |
| 17320 | 17320 | // comparing null with optionals |
| 17321 | if (lhs_ty_tag == .Null and (rhs_ty_tag == .Optional or rhs_ty.isCPtr(zcu))) { | |
| 17321 | if (lhs_ty_tag == .null and (rhs_ty_tag == .optional or rhs_ty.isCPtr(zcu))) { | |
| 17322 | 17322 | return sema.analyzeIsNull(block, src, rhs, op == .neq); |
| 17323 | 17323 | } |
| 17324 | if (rhs_ty_tag == .Null and (lhs_ty_tag == .Optional or lhs_ty.isCPtr(zcu))) { | |
| 17324 | if (rhs_ty_tag == .null and (lhs_ty_tag == .optional or lhs_ty.isCPtr(zcu))) { | |
| 17325 | 17325 | return sema.analyzeIsNull(block, src, lhs, op == .neq); |
| 17326 | 17326 | } |
| 17327 | 17327 | |
| 17328 | if (lhs_ty_tag == .Null or rhs_ty_tag == .Null) { | |
| 17329 | const non_null_type = if (lhs_ty_tag == .Null) rhs_ty else lhs_ty; | |
| 17328 | if (lhs_ty_tag == .null or rhs_ty_tag == .null) { | |
| 17329 | const non_null_type = if (lhs_ty_tag == .null) rhs_ty else lhs_ty; | |
| 17330 | 17330 | return sema.fail(block, src, "comparison of '{}' with null", .{non_null_type.fmt(pt)}); |
| 17331 | 17331 | } |
| 17332 | 17332 | |
| 17333 | if (lhs_ty_tag == .Union and (rhs_ty_tag == .EnumLiteral or rhs_ty_tag == .Enum)) { | |
| 17333 | if (lhs_ty_tag == .@"union" and (rhs_ty_tag == .enum_literal or rhs_ty_tag == .@"enum")) { | |
| 17334 | 17334 | return sema.analyzeCmpUnionTag(block, src, lhs, lhs_src, rhs, rhs_src, op); |
| 17335 | 17335 | } |
| 17336 | if (rhs_ty_tag == .Union and (lhs_ty_tag == .EnumLiteral or lhs_ty_tag == .Enum)) { | |
| 17336 | if (rhs_ty_tag == .@"union" and (lhs_ty_tag == .enum_literal or lhs_ty_tag == .@"enum")) { | |
| 17337 | 17337 | return sema.analyzeCmpUnionTag(block, src, rhs, rhs_src, lhs, lhs_src, op); |
| 17338 | 17338 | } |
| 17339 | 17339 | |
| 17340 | if (lhs_ty_tag == .ErrorSet and rhs_ty_tag == .ErrorSet) { | |
| 17340 | if (lhs_ty_tag == .error_set and rhs_ty_tag == .error_set) { | |
| 17341 | 17341 | const runtime_src: LazySrcLoc = src: { |
| 17342 | 17342 | if (try sema.resolveValue(lhs)) |lval| { |
| 17343 | 17343 | if (try sema.resolveValue(rhs)) |rval| { |
| ... | ... | @@ -17360,7 +17360,7 @@ fn zirCmpEq( |
| 17360 | 17360 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 17361 | 17361 | return block.addBinOp(air_tag, lhs, rhs); |
| 17362 | 17362 | } |
| 17363 | if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) { | |
| 17363 | if (lhs_ty_tag == .type and rhs_ty_tag == .type) { | |
| 17364 | 17364 | const lhs_as_type = try sema.analyzeAsType(block, lhs_src, lhs); |
| 17365 | 17365 | const rhs_as_type = try sema.analyzeAsType(block, rhs_src, rhs); |
| 17366 | 17366 | return if (lhs_as_type.eql(rhs_as_type, zcu) == (op == .eq)) .bool_true else .bool_false; |
| ... | ... | @@ -17399,7 +17399,7 @@ fn analyzeCmpUnionTag( |
| 17399 | 17399 | if (try sema.resolveValue(coerced_tag)) |enum_val| { |
| 17400 | 17400 | if (enum_val.isUndef(zcu)) return pt.undefRef(Type.bool); |
| 17401 | 17401 | const field_ty = union_ty.unionFieldType(enum_val, zcu).?; |
| 17402 | if (field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 17402 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 17403 | 17403 | return .bool_false; |
| 17404 | 17404 | } |
| 17405 | 17405 | } |
| ... | ... | @@ -17442,11 +17442,11 @@ fn analyzeCmp( |
| 17442 | 17442 | const zcu = pt.zcu; |
| 17443 | 17443 | const lhs_ty = sema.typeOf(lhs); |
| 17444 | 17444 | const rhs_ty = sema.typeOf(rhs); |
| 17445 | if (lhs_ty.zigTypeTag(zcu) != .Optional and rhs_ty.zigTypeTag(zcu) != .Optional) { | |
| 17445 | if (lhs_ty.zigTypeTag(zcu) != .optional and rhs_ty.zigTypeTag(zcu) != .optional) { | |
| 17446 | 17446 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 17447 | 17447 | } |
| 17448 | 17448 | |
| 17449 | if (lhs_ty.zigTypeTag(zcu) == .Vector and rhs_ty.zigTypeTag(zcu) == .Vector) { | |
| 17449 | if (lhs_ty.zigTypeTag(zcu) == .vector and rhs_ty.zigTypeTag(zcu) == .vector) { | |
| 17450 | 17450 | return sema.cmpVector(block, src, lhs, rhs, op, lhs_src, rhs_src); |
| 17451 | 17451 | } |
| 17452 | 17452 | if (lhs_ty.isNumeric(zcu) and rhs_ty.isNumeric(zcu)) { |
| ... | ... | @@ -17455,11 +17455,11 @@ fn analyzeCmp( |
| 17455 | 17455 | // numeric types. |
| 17456 | 17456 | return sema.cmpNumeric(block, src, lhs, rhs, op, lhs_src, rhs_src); |
| 17457 | 17457 | } |
| 17458 | if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .ErrorUnion and rhs_ty.zigTypeTag(zcu) == .ErrorSet) { | |
| 17458 | if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .error_union and rhs_ty.zigTypeTag(zcu) == .error_set) { | |
| 17459 | 17459 | const casted_lhs = try sema.analyzeErrUnionCode(block, lhs_src, lhs); |
| 17460 | 17460 | return sema.cmpSelf(block, src, casted_lhs, rhs, op, lhs_src, rhs_src); |
| 17461 | 17461 | } |
| 17462 | if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .ErrorSet and rhs_ty.zigTypeTag(zcu) == .ErrorUnion) { | |
| 17462 | if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .error_set and rhs_ty.zigTypeTag(zcu) == .error_union) { | |
| 17463 | 17463 | const casted_rhs = try sema.analyzeErrUnionCode(block, rhs_src, rhs); |
| 17464 | 17464 | return sema.cmpSelf(block, src, lhs, casted_rhs, op, lhs_src, rhs_src); |
| 17465 | 17465 | } |
| ... | ... | @@ -17505,7 +17505,7 @@ fn cmpSelf( |
| 17505 | 17505 | if (try sema.resolveValue(casted_rhs)) |rhs_val| { |
| 17506 | 17506 | if (rhs_val.isUndef(zcu)) return pt.undefRef(Type.bool); |
| 17507 | 17507 | |
| 17508 | if (resolved_type.zigTypeTag(zcu) == .Vector) { | |
| 17508 | if (resolved_type.zigTypeTag(zcu) == .vector) { | |
| 17509 | 17509 | const cmp_val = try sema.compareVector(lhs_val, op, rhs_val, resolved_type); |
| 17510 | 17510 | return Air.internedToRef(cmp_val.toIntern()); |
| 17511 | 17511 | } |
| ... | ... | @@ -17515,7 +17515,7 @@ fn cmpSelf( |
| 17515 | 17515 | else |
| 17516 | 17516 | .bool_false; |
| 17517 | 17517 | } else { |
| 17518 | if (resolved_type.zigTypeTag(zcu) == .Bool) { | |
| 17518 | if (resolved_type.zigTypeTag(zcu) == .bool) { | |
| 17519 | 17519 | // We can lower bool eq/neq more efficiently. |
| 17520 | 17520 | return sema.runtimeBoolCmp(block, src, op, casted_rhs, lhs_val.toBool(), rhs_src); |
| 17521 | 17521 | } |
| ... | ... | @@ -17524,7 +17524,7 @@ fn cmpSelf( |
| 17524 | 17524 | } else { |
| 17525 | 17525 | // For bools, we still check the other operand, because we can lower |
| 17526 | 17526 | // bool eq/neq more efficiently. |
| 17527 | if (resolved_type.zigTypeTag(zcu) == .Bool) { | |
| 17527 | if (resolved_type.zigTypeTag(zcu) == .bool) { | |
| 17528 | 17528 | if (try sema.resolveValue(casted_rhs)) |rhs_val| { |
| 17529 | 17529 | if (rhs_val.isUndef(zcu)) return pt.undefRef(Type.bool); |
| 17530 | 17530 | return sema.runtimeBoolCmp(block, src, op, casted_lhs, rhs_val.toBool(), lhs_src); |
| ... | ... | @@ -17534,7 +17534,7 @@ fn cmpSelf( |
| 17534 | 17534 | } |
| 17535 | 17535 | }; |
| 17536 | 17536 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 17537 | if (resolved_type.zigTypeTag(zcu) == .Vector) { | |
| 17537 | if (resolved_type.zigTypeTag(zcu) == .vector) { | |
| 17538 | 17538 | return block.addCmpVector(casted_lhs, casted_rhs, op); |
| 17539 | 17539 | } |
| 17540 | 17540 | const tag = Air.Inst.Tag.fromCmpOp(op, block.float_mode == .optimized); |
| ... | ... | @@ -17568,34 +17568,34 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 17568 | 17568 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| 17569 | 17569 | const ty = try sema.resolveType(block, operand_src, inst_data.operand); |
| 17570 | 17570 | switch (ty.zigTypeTag(pt.zcu)) { |
| 17571 | .Fn, | |
| 17572 | .NoReturn, | |
| 17573 | .Undefined, | |
| 17574 | .Null, | |
| 17575 | .Opaque, | |
| 17571 | .@"fn", | |
| 17572 | .noreturn, | |
| 17573 | .undefined, | |
| 17574 | .null, | |
| 17575 | .@"opaque", | |
| 17576 | 17576 | => return sema.fail(block, operand_src, "no size available for type '{}'", .{ty.fmt(pt)}), |
| 17577 | 17577 | |
| 17578 | .Type, | |
| 17579 | .EnumLiteral, | |
| 17580 | .ComptimeFloat, | |
| 17581 | .ComptimeInt, | |
| 17582 | .Void, | |
| 17578 | .type, | |
| 17579 | .enum_literal, | |
| 17580 | .comptime_float, | |
| 17581 | .comptime_int, | |
| 17582 | .void, | |
| 17583 | 17583 | => return pt.intRef(Type.comptime_int, 0), |
| 17584 | 17584 | |
| 17585 | .Bool, | |
| 17586 | .Int, | |
| 17587 | .Float, | |
| 17588 | .Pointer, | |
| 17589 | .Array, | |
| 17590 | .Struct, | |
| 17591 | .Optional, | |
| 17592 | .ErrorUnion, | |
| 17593 | .ErrorSet, | |
| 17594 | .Enum, | |
| 17595 | .Union, | |
| 17596 | .Vector, | |
| 17597 | .Frame, | |
| 17598 | .AnyFrame, | |
| 17585 | .bool, | |
| 17586 | .int, | |
| 17587 | .float, | |
| 17588 | .pointer, | |
| 17589 | .array, | |
| 17590 | .@"struct", | |
| 17591 | .optional, | |
| 17592 | .error_union, | |
| 17593 | .error_set, | |
| 17594 | .@"enum", | |
| 17595 | .@"union", | |
| 17596 | .vector, | |
| 17597 | .frame, | |
| 17598 | .@"anyframe", | |
| 17599 | 17599 | => {}, |
| 17600 | 17600 | } |
| 17601 | 17601 | const val = try ty.abiSizeLazy(pt); |
| ... | ... | @@ -17609,34 +17609,34 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 17609 | 17609 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| 17610 | 17610 | const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand); |
| 17611 | 17611 | switch (operand_ty.zigTypeTag(zcu)) { |
| 17612 | .Fn, | |
| 17613 | .NoReturn, | |
| 17614 | .Undefined, | |
| 17615 | .Null, | |
| 17616 | .Opaque, | |
| 17612 | .@"fn", | |
| 17613 | .noreturn, | |
| 17614 | .undefined, | |
| 17615 | .null, | |
| 17616 | .@"opaque", | |
| 17617 | 17617 | => return sema.fail(block, operand_src, "no size available for type '{}'", .{operand_ty.fmt(pt)}), |
| 17618 | 17618 | |
| 17619 | .Type, | |
| 17620 | .EnumLiteral, | |
| 17621 | .ComptimeFloat, | |
| 17622 | .ComptimeInt, | |
| 17623 | .Void, | |
| 17619 | .type, | |
| 17620 | .enum_literal, | |
| 17621 | .comptime_float, | |
| 17622 | .comptime_int, | |
| 17623 | .void, | |
| 17624 | 17624 | => return pt.intRef(Type.comptime_int, 0), |
| 17625 | 17625 | |
| 17626 | .Bool, | |
| 17627 | .Int, | |
| 17628 | .Float, | |
| 17629 | .Pointer, | |
| 17630 | .Array, | |
| 17631 | .Struct, | |
| 17632 | .Optional, | |
| 17633 | .ErrorUnion, | |
| 17634 | .ErrorSet, | |
| 17635 | .Enum, | |
| 17636 | .Union, | |
| 17637 | .Vector, | |
| 17638 | .Frame, | |
| 17639 | .AnyFrame, | |
| 17626 | .bool, | |
| 17627 | .int, | |
| 17628 | .float, | |
| 17629 | .pointer, | |
| 17630 | .array, | |
| 17631 | .@"struct", | |
| 17632 | .optional, | |
| 17633 | .error_union, | |
| 17634 | .error_set, | |
| 17635 | .@"enum", | |
| 17636 | .@"union", | |
| 17637 | .vector, | |
| 17638 | .frame, | |
| 17639 | .@"anyframe", | |
| 17640 | 17640 | => {}, |
| 17641 | 17641 | } |
| 17642 | 17642 | const bit_size = try operand_ty.bitSizeSema(pt); |
| ... | ... | @@ -17893,21 +17893,21 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17893 | 17893 | } |
| 17894 | 17894 | |
| 17895 | 17895 | switch (ty.zigTypeTag(zcu)) { |
| 17896 | .Type, | |
| 17897 | .Void, | |
| 17898 | .Bool, | |
| 17899 | .NoReturn, | |
| 17900 | .ComptimeFloat, | |
| 17901 | .ComptimeInt, | |
| 17902 | .Undefined, | |
| 17903 | .Null, | |
| 17904 | .EnumLiteral, | |
| 17896 | .type, | |
| 17897 | .void, | |
| 17898 | .bool, | |
| 17899 | .noreturn, | |
| 17900 | .comptime_float, | |
| 17901 | .comptime_int, | |
| 17902 | .undefined, | |
| 17903 | .null, | |
| 17904 | .enum_literal, | |
| 17905 | 17905 | => |type_info_tag| return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 17906 | 17906 | .ty = type_info_ty.toIntern(), |
| 17907 | 17907 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(type_info_tag))).toIntern(), |
| 17908 | 17908 | .val = .void_value, |
| 17909 | 17909 | } }))), |
| 17910 | .Fn => { | |
| 17910 | .@"fn" => { | |
| 17911 | 17911 | const fn_info_nav = try sema.namespaceLookup( |
| 17912 | 17912 | block, |
| 17913 | 17913 | src, |
| ... | ... | @@ -18010,14 +18010,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18010 | 18010 | }; |
| 18011 | 18011 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18012 | 18012 | .ty = type_info_ty.toIntern(), |
| 18013 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Fn))).toIntern(), | |
| 18013 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"fn"))).toIntern(), | |
| 18014 | 18014 | .val = try pt.intern(.{ .aggregate = .{ |
| 18015 | 18015 | .ty = fn_info_ty.toIntern(), |
| 18016 | 18016 | .storage = .{ .elems = &field_values }, |
| 18017 | 18017 | } }), |
| 18018 | 18018 | } }))); |
| 18019 | 18019 | }, |
| 18020 | .Int => { | |
| 18020 | .int => { | |
| 18021 | 18021 | const int_info_nav = try sema.namespaceLookup( |
| 18022 | 18022 | block, |
| 18023 | 18023 | src, |
| ... | ... | @@ -18037,14 +18037,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18037 | 18037 | }; |
| 18038 | 18038 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18039 | 18039 | .ty = type_info_ty.toIntern(), |
| 18040 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Int))).toIntern(), | |
| 18040 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.int))).toIntern(), | |
| 18041 | 18041 | .val = try pt.intern(.{ .aggregate = .{ |
| 18042 | 18042 | .ty = int_info_ty.toIntern(), |
| 18043 | 18043 | .storage = .{ .elems = &field_values }, |
| 18044 | 18044 | } }), |
| 18045 | 18045 | } }))); |
| 18046 | 18046 | }, |
| 18047 | .Float => { | |
| 18047 | .float => { | |
| 18048 | 18048 | const float_info_nav = try sema.namespaceLookup( |
| 18049 | 18049 | block, |
| 18050 | 18050 | src, |
| ... | ... | @@ -18060,14 +18060,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18060 | 18060 | }; |
| 18061 | 18061 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18062 | 18062 | .ty = type_info_ty.toIntern(), |
| 18063 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Float))).toIntern(), | |
| 18063 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.float))).toIntern(), | |
| 18064 | 18064 | .val = try pt.intern(.{ .aggregate = .{ |
| 18065 | 18065 | .ty = float_info_ty.toIntern(), |
| 18066 | 18066 | .storage = .{ .elems = &field_vals }, |
| 18067 | 18067 | } }), |
| 18068 | 18068 | } }))); |
| 18069 | 18069 | }, |
| 18070 | .Pointer => { | |
| 18070 | .pointer => { | |
| 18071 | 18071 | const info = ty.ptrInfo(zcu); |
| 18072 | 18072 | const alignment = if (info.flags.alignment.toByteUnits()) |alignment| |
| 18073 | 18073 | try pt.intValue(Type.comptime_int, alignment) |
| ... | ... | @@ -18119,14 +18119,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18119 | 18119 | }; |
| 18120 | 18120 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18121 | 18121 | .ty = type_info_ty.toIntern(), |
| 18122 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Pointer))).toIntern(), | |
| 18122 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.pointer))).toIntern(), | |
| 18123 | 18123 | .val = try pt.intern(.{ .aggregate = .{ |
| 18124 | 18124 | .ty = pointer_ty.toIntern(), |
| 18125 | 18125 | .storage = .{ .elems = &field_values }, |
| 18126 | 18126 | } }), |
| 18127 | 18127 | } }))); |
| 18128 | 18128 | }, |
| 18129 | .Array => { | |
| 18129 | .array => { | |
| 18130 | 18130 | const array_field_ty = t: { |
| 18131 | 18131 | const nav = try sema.namespaceLookup( |
| 18132 | 18132 | block, |
| ... | ... | @@ -18149,14 +18149,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18149 | 18149 | }; |
| 18150 | 18150 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18151 | 18151 | .ty = type_info_ty.toIntern(), |
| 18152 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Array))).toIntern(), | |
| 18152 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.array))).toIntern(), | |
| 18153 | 18153 | .val = try pt.intern(.{ .aggregate = .{ |
| 18154 | 18154 | .ty = array_field_ty.toIntern(), |
| 18155 | 18155 | .storage = .{ .elems = &field_values }, |
| 18156 | 18156 | } }), |
| 18157 | 18157 | } }))); |
| 18158 | 18158 | }, |
| 18159 | .Vector => { | |
| 18159 | .vector => { | |
| 18160 | 18160 | const vector_field_ty = t: { |
| 18161 | 18161 | const nav = try sema.namespaceLookup( |
| 18162 | 18162 | block, |
| ... | ... | @@ -18177,14 +18177,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18177 | 18177 | }; |
| 18178 | 18178 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18179 | 18179 | .ty = type_info_ty.toIntern(), |
| 18180 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Vector))).toIntern(), | |
| 18180 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.vector))).toIntern(), | |
| 18181 | 18181 | .val = try pt.intern(.{ .aggregate = .{ |
| 18182 | 18182 | .ty = vector_field_ty.toIntern(), |
| 18183 | 18183 | .storage = .{ .elems = &field_values }, |
| 18184 | 18184 | } }), |
| 18185 | 18185 | } }))); |
| 18186 | 18186 | }, |
| 18187 | .Optional => { | |
| 18187 | .optional => { | |
| 18188 | 18188 | const optional_field_ty = t: { |
| 18189 | 18189 | const nav = try sema.namespaceLookup( |
| 18190 | 18190 | block, |
| ... | ... | @@ -18202,14 +18202,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18202 | 18202 | }; |
| 18203 | 18203 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18204 | 18204 | .ty = type_info_ty.toIntern(), |
| 18205 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Optional))).toIntern(), | |
| 18205 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.optional))).toIntern(), | |
| 18206 | 18206 | .val = try pt.intern(.{ .aggregate = .{ |
| 18207 | 18207 | .ty = optional_field_ty.toIntern(), |
| 18208 | 18208 | .storage = .{ .elems = &field_values }, |
| 18209 | 18209 | } }), |
| 18210 | 18210 | } }))); |
| 18211 | 18211 | }, |
| 18212 | .ErrorSet => { | |
| 18212 | .error_set => { | |
| 18213 | 18213 | // Get the Error type |
| 18214 | 18214 | const error_field_ty = t: { |
| 18215 | 18215 | const nav = try sema.namespaceLookup( |
| ... | ... | @@ -18308,14 +18308,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18308 | 18308 | .val = errors_payload_val, |
| 18309 | 18309 | } }); |
| 18310 | 18310 | |
| 18311 | // Construct Type{ .ErrorSet = errors_val } | |
| 18311 | // Construct Type{ .error_set = errors_val } | |
| 18312 | 18312 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18313 | 18313 | .ty = type_info_ty.toIntern(), |
| 18314 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorSet))).toIntern(), | |
| 18314 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.error_set))).toIntern(), | |
| 18315 | 18315 | .val = errors_val, |
| 18316 | 18316 | } }))); |
| 18317 | 18317 | }, |
| 18318 | .ErrorUnion => { | |
| 18318 | .error_union => { | |
| 18319 | 18319 | const error_union_field_ty = t: { |
| 18320 | 18320 | const nav = try sema.namespaceLookup( |
| 18321 | 18321 | block, |
| ... | ... | @@ -18335,14 +18335,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18335 | 18335 | }; |
| 18336 | 18336 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18337 | 18337 | .ty = type_info_ty.toIntern(), |
| 18338 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorUnion))).toIntern(), | |
| 18338 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.error_union))).toIntern(), | |
| 18339 | 18339 | .val = try pt.intern(.{ .aggregate = .{ |
| 18340 | 18340 | .ty = error_union_field_ty.toIntern(), |
| 18341 | 18341 | .storage = .{ .elems = &field_values }, |
| 18342 | 18342 | } }), |
| 18343 | 18343 | } }))); |
| 18344 | 18344 | }, |
| 18345 | .Enum => { | |
| 18345 | .@"enum" => { | |
| 18346 | 18346 | const is_exhaustive = Value.makeBool(ip.loadEnumType(ty.toIntern()).tag_mode != .nonexhaustive); |
| 18347 | 18347 | |
| 18348 | 18348 | const enum_field_ty = t: { |
| ... | ... | @@ -18464,14 +18464,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18464 | 18464 | }; |
| 18465 | 18465 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18466 | 18466 | .ty = type_info_ty.toIntern(), |
| 18467 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Enum))).toIntern(), | |
| 18467 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"enum"))).toIntern(), | |
| 18468 | 18468 | .val = try pt.intern(.{ .aggregate = .{ |
| 18469 | 18469 | .ty = type_enum_ty.toIntern(), |
| 18470 | 18470 | .storage = .{ .elems = &field_values }, |
| 18471 | 18471 | } }), |
| 18472 | 18472 | } }))); |
| 18473 | 18473 | }, |
| 18474 | .Union => { | |
| 18474 | .@"union" => { | |
| 18475 | 18475 | const type_union_ty = t: { |
| 18476 | 18476 | const nav = try sema.namespaceLookup( |
| 18477 | 18477 | block, |
| ... | ... | @@ -18611,14 +18611,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18611 | 18611 | }; |
| 18612 | 18612 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18613 | 18613 | .ty = type_info_ty.toIntern(), |
| 18614 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Union))).toIntern(), | |
| 18614 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"union"))).toIntern(), | |
| 18615 | 18615 | .val = try pt.intern(.{ .aggregate = .{ |
| 18616 | 18616 | .ty = type_union_ty.toIntern(), |
| 18617 | 18617 | .storage = .{ .elems = &field_values }, |
| 18618 | 18618 | } }), |
| 18619 | 18619 | } }))); |
| 18620 | 18620 | }, |
| 18621 | .Struct => { | |
| 18621 | .@"struct" => { | |
| 18622 | 18622 | const type_struct_ty = t: { |
| 18623 | 18623 | const nav = try sema.namespaceLookup( |
| 18624 | 18624 | block, |
| ... | ... | @@ -18843,14 +18843,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18843 | 18843 | }; |
| 18844 | 18844 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18845 | 18845 | .ty = type_info_ty.toIntern(), |
| 18846 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Struct))).toIntern(), | |
| 18846 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"struct"))).toIntern(), | |
| 18847 | 18847 | .val = try pt.intern(.{ .aggregate = .{ |
| 18848 | 18848 | .ty = type_struct_ty.toIntern(), |
| 18849 | 18849 | .storage = .{ .elems = &field_values }, |
| 18850 | 18850 | } }), |
| 18851 | 18851 | } }))); |
| 18852 | 18852 | }, |
| 18853 | .Opaque => { | |
| 18853 | .@"opaque" => { | |
| 18854 | 18854 | const type_opaque_ty = t: { |
| 18855 | 18855 | const nav = try sema.namespaceLookup( |
| 18856 | 18856 | block, |
| ... | ... | @@ -18871,15 +18871,15 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18871 | 18871 | }; |
| 18872 | 18872 | return Air.internedToRef((try pt.intern(.{ .un = .{ |
| 18873 | 18873 | .ty = type_info_ty.toIntern(), |
| 18874 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Opaque))).toIntern(), | |
| 18874 | .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"opaque"))).toIntern(), | |
| 18875 | 18875 | .val = try pt.intern(.{ .aggregate = .{ |
| 18876 | 18876 | .ty = type_opaque_ty.toIntern(), |
| 18877 | 18877 | .storage = .{ .elems = &field_values }, |
| 18878 | 18878 | } }), |
| 18879 | 18879 | } }))); |
| 18880 | 18880 | }, |
| 18881 | .Frame => return sema.failWithUseOfAsync(block, src), | |
| 18882 | .AnyFrame => return sema.failWithUseOfAsync(block, src), | |
| 18881 | .frame => return sema.failWithUseOfAsync(block, src), | |
| 18882 | .@"anyframe" => return sema.failWithUseOfAsync(block, src), | |
| 18883 | 18883 | } |
| 18884 | 18884 | } |
| 18885 | 18885 | |
| ... | ... | @@ -19064,8 +19064,8 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi |
| 19064 | 19064 | const pt = sema.pt; |
| 19065 | 19065 | const zcu = pt.zcu; |
| 19066 | 19066 | switch (operand.zigTypeTag(zcu)) { |
| 19067 | .ComptimeInt => return Type.comptime_int, | |
| 19068 | .Int => { | |
| 19067 | .comptime_int => return Type.comptime_int, | |
| 19068 | .int => { | |
| 19069 | 19069 | const bits = operand.bitSize(zcu); |
| 19070 | 19070 | const count = if (bits == 0) |
| 19071 | 19071 | 0 |
| ... | ... | @@ -19079,7 +19079,7 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi |
| 19079 | 19079 | }; |
| 19080 | 19080 | return pt.intType(.unsigned, count); |
| 19081 | 19081 | }, |
| 19082 | .Vector => { | |
| 19082 | .vector => { | |
| 19083 | 19083 | const elem_ty = operand.elemType2(zcu); |
| 19084 | 19084 | const log2_elem_ty = try sema.log2IntType(block, elem_ty, src); |
| 19085 | 19085 | return pt.vectorType(.{ |
| ... | ... | @@ -19277,9 +19277,9 @@ fn finishCondBr( |
| 19277 | 19277 | ) !Air.Inst.Ref { |
| 19278 | 19278 | const gpa = sema.gpa; |
| 19279 | 19279 | |
| 19280 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + | |
| 19280 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len + | |
| 19281 | 19281 | then_block.instructions.items.len + else_block.instructions.items.len + |
| 19282 | @typeInfo(Air.Block).Struct.fields.len + child_block.instructions.items.len + 1); | |
| 19282 | @typeInfo(Air.Block).@"struct".fields.len + child_block.instructions.items.len + 1); | |
| 19283 | 19283 | |
| 19284 | 19284 | const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 19285 | 19285 | .then_body_len = @intCast(then_block.instructions.items.len), |
| ... | ... | @@ -19307,8 +19307,8 @@ fn checkNullableType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !voi |
| 19307 | 19307 | const pt = sema.pt; |
| 19308 | 19308 | const zcu = pt.zcu; |
| 19309 | 19309 | switch (ty.zigTypeTag(zcu)) { |
| 19310 | .Optional, .Null, .Undefined => return, | |
| 19311 | .Pointer => if (ty.isPtrLikeOptional(zcu)) return, | |
| 19310 | .optional, .null, .undefined => return, | |
| 19311 | .pointer => if (ty.isPtrLikeOptional(zcu)) return, | |
| 19312 | 19312 | else => {}, |
| 19313 | 19313 | } |
| 19314 | 19314 | return sema.failWithExpectedOptionalType(block, src, ty); |
| ... | ... | @@ -19354,7 +19354,7 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| 19354 | 19354 | const pt = sema.pt; |
| 19355 | 19355 | const zcu = pt.zcu; |
| 19356 | 19356 | switch (ty.zigTypeTag(zcu)) { |
| 19357 | .ErrorSet, .ErrorUnion, .Undefined => return, | |
| 19357 | .error_set, .error_union, .undefined => return, | |
| 19358 | 19358 | else => return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| 19359 | 19359 | ty.fmt(pt), |
| 19360 | 19360 | }), |
| ... | ... | @@ -19451,7 +19451,7 @@ fn zirCondbr( |
| 19451 | 19451 | const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node; |
| 19452 | 19452 | const err_operand = try sema.resolveInst(err_inst_data.operand); |
| 19453 | 19453 | const operand_ty = sema.typeOf(err_operand); |
| 19454 | assert(operand_ty.zigTypeTag(zcu) == .ErrorUnion); | |
| 19454 | assert(operand_ty.zigTypeTag(zcu) == .error_union); | |
| 19455 | 19455 | const result_ty = operand_ty.errorUnionSet(zcu); |
| 19456 | 19456 | break :blk try sub_block.addTyOp(.unwrap_errunion_err, result_ty, err_operand); |
| 19457 | 19457 | }; |
| ... | ... | @@ -19463,7 +19463,7 @@ fn zirCondbr( |
| 19463 | 19463 | break :h .unlikely; |
| 19464 | 19464 | } else try sema.analyzeBodyRuntimeBreak(&sub_block, else_body); |
| 19465 | 19465 | |
| 19466 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + | |
| 19466 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len + | |
| 19467 | 19467 | true_instructions.len + sub_block.instructions.items.len); |
| 19468 | 19468 | _ = try parent_block.addInst(.{ |
| 19469 | 19469 | .tag = .cond_br, |
| ... | ... | @@ -19490,7 +19490,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! |
| 19490 | 19490 | const err_union_ty = sema.typeOf(err_union); |
| 19491 | 19491 | const pt = sema.pt; |
| 19492 | 19492 | const zcu = pt.zcu; |
| 19493 | if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) { | |
| 19493 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | |
| 19494 | 19494 | return sema.fail(parent_block, operand_src, "expected error union type, found '{}'", .{ |
| 19495 | 19495 | err_union_ty.fmt(pt), |
| 19496 | 19496 | }); |
| ... | ... | @@ -19524,7 +19524,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! |
| 19524 | 19524 | // The only interesting hint here is `.cold`, which can come from e.g. `errdefer @panic`. |
| 19525 | 19525 | const is_cold = sema.branch_hint == .cold; |
| 19526 | 19526 | |
| 19527 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Try).Struct.fields.len + | |
| 19527 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Try).@"struct".fields.len + | |
| 19528 | 19528 | sub_block.instructions.items.len); |
| 19529 | 19529 | const try_inst = try parent_block.addInst(.{ |
| 19530 | 19530 | .tag = if (is_cold) .try_cold else .@"try", |
| ... | ... | @@ -19550,7 +19550,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 19550 | 19550 | const err_union_ty = sema.typeOf(err_union); |
| 19551 | 19551 | const pt = sema.pt; |
| 19552 | 19552 | const zcu = pt.zcu; |
| 19553 | if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) { | |
| 19553 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | |
| 19554 | 19554 | return sema.fail(parent_block, operand_src, "expected error union type, found '{}'", .{ |
| 19555 | 19555 | err_union_ty.fmt(pt), |
| 19556 | 19556 | }); |
| ... | ... | @@ -19596,7 +19596,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 19596 | 19596 | }, |
| 19597 | 19597 | }); |
| 19598 | 19598 | const res_ty_ref = Air.internedToRef(res_ty.toIntern()); |
| 19599 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).Struct.fields.len + | |
| 19599 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).@"struct".fields.len + | |
| 19600 | 19600 | sub_block.instructions.items.len); |
| 19601 | 19601 | const try_inst = try parent_block.addInst(.{ |
| 19602 | 19602 | .tag = if (is_cold) .try_ptr_cold else .try_ptr, |
| ... | ... | @@ -19747,7 +19747,7 @@ fn zirRetImplicit( |
| 19747 | 19747 | const operand = try sema.resolveInst(inst_data.operand); |
| 19748 | 19748 | const ret_ty_src = block.src(.{ .node_offset_fn_type_ret_ty = 0 }); |
| 19749 | 19749 | const base_tag = sema.fn_ret_ty.baseZigTypeTag(zcu); |
| 19750 | if (base_tag == .NoReturn) { | |
| 19750 | if (base_tag == .noreturn) { | |
| 19751 | 19751 | const msg = msg: { |
| 19752 | 19752 | const msg = try sema.errMsg(ret_ty_src, "function declared '{}' implicitly returns", .{ |
| 19753 | 19753 | sema.fn_ret_ty.fmt(pt), |
| ... | ... | @@ -19757,7 +19757,7 @@ fn zirRetImplicit( |
| 19757 | 19757 | break :msg msg; |
| 19758 | 19758 | }; |
| 19759 | 19759 | return sema.failWithOwnedErrorMsg(block, msg); |
| 19760 | } else if (base_tag != .Void) { | |
| 19760 | } else if (base_tag != .void) { | |
| 19761 | 19761 | const msg = msg: { |
| 19762 | 19762 | const msg = try sema.errMsg(ret_ty_src, "function with non-void return type '{}' implicitly returns", .{ |
| 19763 | 19763 | sema.fn_ret_ty.fmt(pt), |
| ... | ... | @@ -19844,9 +19844,9 @@ fn retWithErrTracing( |
| 19844 | 19844 | try sema.callBuiltin(&else_block, src, return_err_fn, .never_inline, &args, .@"error return"); |
| 19845 | 19845 | _ = try else_block.addUnOp(ret_tag, operand); |
| 19846 | 19846 | |
| 19847 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + | |
| 19847 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len + | |
| 19848 | 19848 | then_block.instructions.items.len + else_block.instructions.items.len + |
| 19849 | @typeInfo(Air.Block).Struct.fields.len + 1); | |
| 19849 | @typeInfo(Air.Block).@"struct".fields.len + 1); | |
| 19850 | 19850 | |
| 19851 | 19851 | const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 19852 | 19852 | .then_body_len = @intCast(then_block.instructions.items.len), |
| ... | ... | @@ -19958,7 +19958,7 @@ fn addToInferredErrorSet(sema: *Sema, uncasted_operand: Air.Inst.Ref) !void { |
| 19958 | 19958 | const pt = sema.pt; |
| 19959 | 19959 | const zcu = pt.zcu; |
| 19960 | 19960 | const ip = &zcu.intern_pool; |
| 19961 | assert(sema.fn_ret_ty.zigTypeTag(zcu) == .ErrorUnion); | |
| 19961 | assert(sema.fn_ret_ty.zigTypeTag(zcu) == .error_union); | |
| 19962 | 19962 | const err_set_ty = sema.fn_ret_ty.errorUnionSet(zcu).toIntern(); |
| 19963 | 19963 | switch (err_set_ty) { |
| 19964 | 19964 | .adhoc_inferred_error_set_type => { |
| ... | ... | @@ -19980,8 +19980,8 @@ fn addToInferredErrorSetPtr(sema: *Sema, ies: *InferredErrorSet, op_ty: Type) !v |
| 19980 | 19980 | const zcu = pt.zcu; |
| 19981 | 19981 | const ip = &zcu.intern_pool; |
| 19982 | 19982 | switch (op_ty.zigTypeTag(zcu)) { |
| 19983 | .ErrorSet => try ies.addErrorSet(op_ty, ip, arena), | |
| 19984 | .ErrorUnion => try ies.addErrorSet(op_ty.errorUnionSet(zcu), ip, arena), | |
| 19983 | .error_set => try ies.addErrorSet(op_ty, ip, arena), | |
| 19984 | .error_union => try ies.addErrorSet(op_ty.errorUnionSet(zcu), ip, arena), | |
| 19985 | 19985 | else => {}, |
| 19986 | 19986 | } |
| 19987 | 19987 | } |
| ... | ... | @@ -19998,7 +19998,7 @@ fn analyzeRet( |
| 19998 | 19998 | // that the coercion below works correctly. |
| 19999 | 19999 | const pt = sema.pt; |
| 20000 | 20000 | const zcu = pt.zcu; |
| 20001 | if (sema.fn_ret_ty_ies != null and sema.fn_ret_ty.zigTypeTag(zcu) == .ErrorUnion) { | |
| 20001 | if (sema.fn_ret_ty_ies != null and sema.fn_ret_ty.zigTypeTag(zcu) == .error_union) { | |
| 20002 | 20002 | try sema.addToInferredErrorSet(uncasted_operand); |
| 20003 | 20003 | } |
| 20004 | 20004 | const operand = sema.coerceExtra(block, sema.fn_ret_ty, uncasted_operand, operand_src, .{ .is_ret = true }) catch |err| switch (err) { |
| ... | ... | @@ -20087,7 +20087,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 20087 | 20087 | break :blk ty; |
| 20088 | 20088 | }; |
| 20089 | 20089 | |
| 20090 | if (elem_ty.zigTypeTag(zcu) == .NoReturn) | |
| 20090 | if (elem_ty.zigTypeTag(zcu) == .noreturn) | |
| 20091 | 20091 | return sema.fail(block, elem_ty_src, "pointer to noreturn not allowed", .{}); |
| 20092 | 20092 | |
| 20093 | 20093 | const target = zcu.getTarget(); |
| ... | ... | @@ -20128,7 +20128,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 20128 | 20128 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 20129 | 20129 | extra_i += 1; |
| 20130 | 20130 | break :blk try sema.resolveAddressSpace(block, addrspace_src, ref, .pointer); |
| 20131 | } else if (elem_ty.zigTypeTag(zcu) == .Fn and target.cpu.arch == .avr) .flash else .generic; | |
| 20131 | } else if (elem_ty.zigTypeTag(zcu) == .@"fn" and target.cpu.arch == .avr) .flash else .generic; | |
| 20132 | 20132 | |
| 20133 | 20133 | const bit_offset: u16 = if (inst_data.flags.has_bit_range) blk: { |
| 20134 | 20134 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| ... | ... | @@ -20162,11 +20162,11 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 20162 | 20162 | } |
| 20163 | 20163 | } |
| 20164 | 20164 | |
| 20165 | if (elem_ty.zigTypeTag(zcu) == .Fn) { | |
| 20165 | if (elem_ty.zigTypeTag(zcu) == .@"fn") { | |
| 20166 | 20166 | if (inst_data.size != .One) { |
| 20167 | 20167 | return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{}); |
| 20168 | 20168 | } |
| 20169 | } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .Opaque) { | |
| 20169 | } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 20170 | 20170 | return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{}); |
| 20171 | 20171 | } else if (inst_data.size == .C) { |
| 20172 | 20172 | if (!try sema.validateExternType(elem_ty, .other)) { |
| ... | ... | @@ -20181,7 +20181,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 20181 | 20181 | }; |
| 20182 | 20182 | return sema.failWithOwnedErrorMsg(block, msg); |
| 20183 | 20183 | } |
| 20184 | if (elem_ty.zigTypeTag(zcu) == .Opaque) { | |
| 20184 | if (elem_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 20185 | 20185 | return sema.fail(block, elem_ty_src, "C pointers cannot point to opaque types", .{}); |
| 20186 | 20186 | } |
| 20187 | 20187 | } |
| ... | ... | @@ -20226,10 +20226,10 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 20226 | 20226 | const zcu = pt.zcu; |
| 20227 | 20227 | |
| 20228 | 20228 | switch (obj_ty.zigTypeTag(zcu)) { |
| 20229 | .Struct => return sema.structInitEmpty(block, obj_ty, src, src), | |
| 20230 | .Array, .Vector => return sema.arrayInitEmpty(block, src, obj_ty), | |
| 20231 | .Void => return Air.internedToRef(Value.void.toIntern()), | |
| 20232 | .Union => return sema.fail(block, src, "union initializer must initialize one field", .{}), | |
| 20229 | .@"struct" => return sema.structInitEmpty(block, obj_ty, src, src), | |
| 20230 | .array, .vector => return sema.arrayInitEmpty(block, src, obj_ty), | |
| 20231 | .void => return Air.internedToRef(Value.void.toIntern()), | |
| 20232 | .@"union" => return sema.fail(block, src, "union initializer must initialize one field", .{}), | |
| 20233 | 20233 | else => return sema.failWithArrayInitNotSupported(block, src, obj_ty), |
| 20234 | 20234 | } |
| 20235 | 20235 | } |
| ... | ... | @@ -20249,7 +20249,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is |
| 20249 | 20249 | }; |
| 20250 | 20250 | const init_ty = if (is_byref) ty: { |
| 20251 | 20251 | const ptr_ty = ty_operand.optEuBaseType(zcu); |
| 20252 | assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction | |
| 20252 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction | |
| 20253 | 20253 | if (!ptr_ty.isSlice(zcu)) { |
| 20254 | 20254 | break :ty ptr_ty.childType(zcu); |
| 20255 | 20255 | } |
| ... | ... | @@ -20263,9 +20263,9 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is |
| 20263 | 20263 | const obj_ty = init_ty.optEuBaseType(zcu); |
| 20264 | 20264 | |
| 20265 | 20265 | const empty_ref = switch (obj_ty.zigTypeTag(zcu)) { |
| 20266 | .Struct => try sema.structInitEmpty(block, obj_ty, src, src), | |
| 20267 | .Array, .Vector => try sema.arrayInitEmpty(block, src, obj_ty), | |
| 20268 | .Union => return sema.fail(block, src, "union initializer must initialize one field", .{}), | |
| 20266 | .@"struct" => try sema.structInitEmpty(block, obj_ty, src, src), | |
| 20267 | .array, .vector => try sema.arrayInitEmpty(block, src, obj_ty), | |
| 20268 | .@"union" => return sema.fail(block, src, "union initializer must initialize one field", .{}), | |
| 20269 | 20269 | else => return sema.failWithArrayInitNotSupported(block, src, obj_ty), |
| 20270 | 20270 | }; |
| 20271 | 20271 | const init_ref = try sema.coerce(block, init_ty, empty_ref, src); |
| ... | ... | @@ -20304,7 +20304,7 @@ fn arrayInitEmpty(sema: *Sema, block: *Block, src: LazySrcLoc, obj_ty: Type) Com |
| 20304 | 20304 | const zcu = pt.zcu; |
| 20305 | 20305 | const arr_len = obj_ty.arrayLen(zcu); |
| 20306 | 20306 | if (arr_len != 0) { |
| 20307 | if (obj_ty.zigTypeTag(zcu) == .Array) { | |
| 20307 | if (obj_ty.zigTypeTag(zcu) == .array) { | |
| 20308 | 20308 | return sema.fail(block, src, "expected {d} array elements; found 0", .{arr_len}); |
| 20309 | 20309 | } else { |
| 20310 | 20310 | return sema.fail(block, src, "expected {d} vector elements; found 0", .{arr_len}); |
| ... | ... | @@ -20324,7 +20324,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 20324 | 20324 | const init_src = block.builtinCallArgSrc(inst_data.src_node, 2); |
| 20325 | 20325 | const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; |
| 20326 | 20326 | const union_ty = try sema.resolveType(block, ty_src, extra.union_type); |
| 20327 | if (union_ty.zigTypeTag(pt.zcu) != .Union) { | |
| 20327 | if (union_ty.zigTypeTag(pt.zcu) != .@"union") { | |
| 20328 | 20328 | return sema.fail(block, ty_src, "expected union type, found '{}'", .{union_ty.fmt(pt)}); |
| 20329 | 20329 | } |
| 20330 | 20330 | const field_name = try sema.resolveConstStringIntern(block, field_src, extra.field_name, .{ |
| ... | ... | @@ -20394,7 +20394,7 @@ fn zirStructInit( |
| 20394 | 20394 | const resolved_ty = result_ty.optEuBaseType(zcu); |
| 20395 | 20395 | try resolved_ty.resolveLayout(pt); |
| 20396 | 20396 | |
| 20397 | if (resolved_ty.zigTypeTag(zcu) == .Struct) { | |
| 20397 | if (resolved_ty.zigTypeTag(zcu) == .@"struct") { | |
| 20398 | 20398 | // This logic must be synchronized with that in `zirStructInitEmpty`. |
| 20399 | 20399 | |
| 20400 | 20400 | // Maps field index to field_type index of where it was already initialized. |
| ... | ... | @@ -20450,7 +20450,7 @@ fn zirStructInit( |
| 20450 | 20450 | } |
| 20451 | 20451 | |
| 20452 | 20452 | return sema.finishStructInit(block, src, src, field_inits, resolved_ty, result_ty, is_ref); |
| 20453 | } else if (resolved_ty.zigTypeTag(zcu) == .Union) { | |
| 20453 | } else if (resolved_ty.zigTypeTag(zcu) == .@"union") { | |
| 20454 | 20454 | if (extra.data.fields_len != 1) { |
| 20455 | 20455 | return sema.fail(block, src, "union initialization expects exactly one field", .{}); |
| 20456 | 20456 | } |
| ... | ... | @@ -20471,7 +20471,7 @@ fn zirStructInit( |
| 20471 | 20471 | const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index); |
| 20472 | 20472 | const field_ty = Type.fromInterned(zcu.typeToUnion(resolved_ty).?.field_types.get(ip)[field_index]); |
| 20473 | 20473 | |
| 20474 | if (field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 20474 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 20475 | 20475 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 20476 | 20476 | const msg = try sema.errMsg(src, "cannot initialize 'noreturn' field of union", .{}); |
| 20477 | 20477 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -20756,7 +20756,7 @@ fn structInitAnon( |
| 20756 | 20756 | |
| 20757 | 20757 | const init = try sema.resolveInst(item.data.init); |
| 20758 | 20758 | field_ty.* = sema.typeOf(init).toIntern(); |
| 20759 | if (Type.fromInterned(field_ty.*).zigTypeTag(zcu) == .Opaque) { | |
| 20759 | if (Type.fromInterned(field_ty.*).zigTypeTag(zcu) == .@"opaque") { | |
| 20760 | 20760 | const msg = msg: { |
| 20761 | 20761 | const field_src = block.src(.{ .init_elem = .{ |
| 20762 | 20762 | .init_node_offset = src.offset.node_offset.x, |
| ... | ... | @@ -20867,7 +20867,7 @@ fn zirArrayInit( |
| 20867 | 20867 | else => |e| return e, |
| 20868 | 20868 | }; |
| 20869 | 20869 | const array_ty = result_ty.optEuBaseType(zcu); |
| 20870 | const is_tuple = array_ty.zigTypeTag(zcu) == .Struct; | |
| 20870 | const is_tuple = array_ty.zigTypeTag(zcu) == .@"struct"; | |
| 20871 | 20871 | const sentinel_val = array_ty.sentinel(zcu); |
| 20872 | 20872 | |
| 20873 | 20873 | var root_msg: ?*Zcu.ErrorMsg = null; |
| ... | ... | @@ -21029,7 +21029,7 @@ fn arrayInitAnon( |
| 21029 | 21029 | const operand_src = src; // TODO better source location |
| 21030 | 21030 | const elem = try sema.resolveInst(operand); |
| 21031 | 21031 | types[i] = sema.typeOf(elem).toIntern(); |
| 21032 | if (Type.fromInterned(types[i]).zigTypeTag(zcu) == .Opaque) { | |
| 21032 | if (Type.fromInterned(types[i]).zigTypeTag(zcu) == .@"opaque") { | |
| 21033 | 21033 | const msg = msg: { |
| 21034 | 21034 | const msg = try sema.errMsg(operand_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); |
| 21035 | 21035 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -21148,7 +21148,7 @@ fn fieldType( |
| 21148 | 21148 | while (true) { |
| 21149 | 21149 | try cur_ty.resolveFields(pt); |
| 21150 | 21150 | switch (cur_ty.zigTypeTag(zcu)) { |
| 21151 | .Struct => switch (ip.indexToKey(cur_ty.toIntern())) { | |
| 21151 | .@"struct" => switch (ip.indexToKey(cur_ty.toIntern())) { | |
| 21152 | 21152 | .anon_struct_type => |anon_struct| { |
| 21153 | 21153 | const field_index = if (anon_struct.names.len == 0) |
| 21154 | 21154 | try sema.tupleFieldIndex(block, cur_ty, field_name, field_src) |
| ... | ... | @@ -21165,20 +21165,20 @@ fn fieldType( |
| 21165 | 21165 | }, |
| 21166 | 21166 | else => unreachable, |
| 21167 | 21167 | }, |
| 21168 | .Union => { | |
| 21168 | .@"union" => { | |
| 21169 | 21169 | const union_obj = zcu.typeToUnion(cur_ty).?; |
| 21170 | 21170 | const field_index = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse |
| 21171 | 21171 | return sema.failWithBadUnionFieldAccess(block, cur_ty, union_obj, field_src, field_name); |
| 21172 | 21172 | const field_ty = union_obj.field_types.get(ip)[field_index]; |
| 21173 | 21173 | return Air.internedToRef(field_ty); |
| 21174 | 21174 | }, |
| 21175 | .Optional => { | |
| 21175 | .optional => { | |
| 21176 | 21176 | // Struct/array init through optional requires the child type to not be a pointer. |
| 21177 | 21177 | // If the child of .optional is a pointer it'll error on the next loop. |
| 21178 | 21178 | cur_ty = Type.fromInterned(ip.indexToKey(cur_ty.toIntern()).opt_type); |
| 21179 | 21179 | continue; |
| 21180 | 21180 | }, |
| 21181 | .ErrorUnion => { | |
| 21181 | .error_union => { | |
| 21182 | 21182 | cur_ty = cur_ty.errorUnionPayload(zcu); |
| 21183 | 21183 | continue; |
| 21184 | 21184 | }, |
| ... | ... | @@ -21243,7 +21243,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 21243 | 21243 | const src = block.nodeOffset(inst_data.src_node); |
| 21244 | 21244 | const operand = try sema.resolveInst(inst_data.operand); |
| 21245 | 21245 | const operand_ty = sema.typeOf(operand); |
| 21246 | const is_vector = operand_ty.zigTypeTag(zcu) == .Vector; | |
| 21246 | const is_vector = operand_ty.zigTypeTag(zcu) == .vector; | |
| 21247 | 21247 | const operand_scalar_ty = operand_ty.scalarType(zcu); |
| 21248 | 21248 | if (operand_scalar_ty.toIntern() != .bool_type) { |
| 21249 | 21249 | return sema.fail(block, src, "expected 'bool', found '{}'", .{operand_scalar_ty.zigTypeTag(zcu)}); |
| ... | ... | @@ -21317,8 +21317,8 @@ fn zirAbs( |
| 21317 | 21317 | const scalar_ty = operand_ty.scalarType(zcu); |
| 21318 | 21318 | |
| 21319 | 21319 | const result_ty = switch (scalar_ty.zigTypeTag(zcu)) { |
| 21320 | .ComptimeFloat, .Float, .ComptimeInt => operand_ty, | |
| 21321 | .Int => if (scalar_ty.isSignedInt(zcu)) try operand_ty.toUnsigned(pt) else return operand, | |
| 21320 | .comptime_float, .float, .comptime_int => operand_ty, | |
| 21321 | .int => if (scalar_ty.isSignedInt(zcu)) try operand_ty.toUnsigned(pt) else return operand, | |
| 21322 | 21322 | else => return sema.fail( |
| 21323 | 21323 | block, |
| 21324 | 21324 | operand_src, |
| ... | ... | @@ -21342,7 +21342,7 @@ fn maybeConstantUnaryMath( |
| 21342 | 21342 | const pt = sema.pt; |
| 21343 | 21343 | const zcu = pt.zcu; |
| 21344 | 21344 | switch (result_ty.zigTypeTag(zcu)) { |
| 21345 | .Vector => if (try sema.resolveValue(operand)) |val| { | |
| 21345 | .vector => if (try sema.resolveValue(operand)) |val| { | |
| 21346 | 21346 | const scalar_ty = result_ty.scalarType(zcu); |
| 21347 | 21347 | const vec_len = result_ty.vectorLen(zcu); |
| 21348 | 21348 | if (val.isUndef(zcu)) |
| ... | ... | @@ -21387,7 +21387,7 @@ fn zirUnaryMath( |
| 21387 | 21387 | const scalar_ty = operand_ty.scalarType(zcu); |
| 21388 | 21388 | |
| 21389 | 21389 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 21390 | .ComptimeFloat, .Float => {}, | |
| 21390 | .comptime_float, .float => {}, | |
| 21391 | 21391 | else => return sema.fail( |
| 21392 | 21392 | block, |
| 21393 | 21393 | operand_src, |
| ... | ... | @@ -21414,13 +21414,13 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 21414 | 21414 | |
| 21415 | 21415 | try operand_ty.resolveLayout(pt); |
| 21416 | 21416 | const enum_ty = switch (operand_ty.zigTypeTag(zcu)) { |
| 21417 | .EnumLiteral => { | |
| 21417 | .enum_literal => { | |
| 21418 | 21418 | const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, operand, undefined); |
| 21419 | 21419 | const tag_name = ip.indexToKey(val.toIntern()).enum_literal; |
| 21420 | 21420 | return sema.addNullTerminatedStrLit(tag_name); |
| 21421 | 21421 | }, |
| 21422 | .Enum => operand_ty, | |
| 21423 | .Union => operand_ty.unionTagType(zcu) orelse | |
| 21422 | .@"enum" => operand_ty, | |
| 21423 | .@"union" => operand_ty.unionTagType(zcu) orelse | |
| 21424 | 21424 | return sema.fail(block, src, "union '{}' is untagged", .{operand_ty.fmt(pt)}), |
| 21425 | 21425 | else => return sema.fail(block, operand_src, "expected enum or union; found '{}'", .{ |
| 21426 | 21426 | operand_ty.fmt(pt), |
| ... | ... | @@ -21500,17 +21500,17 @@ fn zirReify( |
| 21500 | 21500 | } |
| 21501 | 21501 | const tag_index = type_info_ty.unionTagFieldIndex(Value.fromInterned(union_val.tag), zcu).?; |
| 21502 | 21502 | switch (@as(std.builtin.TypeId, @enumFromInt(tag_index))) { |
| 21503 | .Type => return .type_type, | |
| 21504 | .Void => return .void_type, | |
| 21505 | .Bool => return .bool_type, | |
| 21506 | .NoReturn => return .noreturn_type, | |
| 21507 | .ComptimeFloat => return .comptime_float_type, | |
| 21508 | .ComptimeInt => return .comptime_int_type, | |
| 21509 | .Undefined => return .undefined_type, | |
| 21510 | .Null => return .null_type, | |
| 21511 | .AnyFrame => return sema.failWithUseOfAsync(block, src), | |
| 21512 | .EnumLiteral => return .enum_literal_type, | |
| 21513 | .Int => { | |
| 21503 | .type => return .type_type, | |
| 21504 | .void => return .void_type, | |
| 21505 | .bool => return .bool_type, | |
| 21506 | .noreturn => return .noreturn_type, | |
| 21507 | .comptime_float => return .comptime_float_type, | |
| 21508 | .comptime_int => return .comptime_int_type, | |
| 21509 | .undefined => return .undefined_type, | |
| 21510 | .null => return .null_type, | |
| 21511 | .@"anyframe" => return sema.failWithUseOfAsync(block, src), | |
| 21512 | .enum_literal => return .enum_literal_type, | |
| 21513 | .int => { | |
| 21514 | 21514 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21515 | 21515 | const signedness_val = try Value.fromInterned(union_val.val).fieldValue( |
| 21516 | 21516 | pt, |
| ... | ... | @@ -21526,7 +21526,7 @@ fn zirReify( |
| 21526 | 21526 | const ty = try pt.intType(signedness, bits); |
| 21527 | 21527 | return Air.internedToRef(ty.toIntern()); |
| 21528 | 21528 | }, |
| 21529 | .Vector => { | |
| 21529 | .vector => { | |
| 21530 | 21530 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21531 | 21531 | const len_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21532 | 21532 | ip, |
| ... | ... | @@ -21548,7 +21548,7 @@ fn zirReify( |
| 21548 | 21548 | }); |
| 21549 | 21549 | return Air.internedToRef(ty.toIntern()); |
| 21550 | 21550 | }, |
| 21551 | .Float => { | |
| 21551 | .float => { | |
| 21552 | 21552 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21553 | 21553 | const bits_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21554 | 21554 | ip, |
| ... | ... | @@ -21566,7 +21566,7 @@ fn zirReify( |
| 21566 | 21566 | }; |
| 21567 | 21567 | return Air.internedToRef(ty.toIntern()); |
| 21568 | 21568 | }, |
| 21569 | .Pointer => { | |
| 21569 | .pointer => { | |
| 21570 | 21570 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21571 | 21571 | const size_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21572 | 21572 | ip, |
| ... | ... | @@ -21631,13 +21631,13 @@ fn zirReify( |
| 21631 | 21631 | break :s .none; |
| 21632 | 21632 | }; |
| 21633 | 21633 | |
| 21634 | if (elem_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 21634 | if (elem_ty.zigTypeTag(zcu) == .noreturn) { | |
| 21635 | 21635 | return sema.fail(block, src, "pointer to noreturn not allowed", .{}); |
| 21636 | } else if (elem_ty.zigTypeTag(zcu) == .Fn) { | |
| 21636 | } else if (elem_ty.zigTypeTag(zcu) == .@"fn") { | |
| 21637 | 21637 | if (ptr_size != .One) { |
| 21638 | 21638 | return sema.fail(block, src, "function pointers must be single pointers", .{}); |
| 21639 | 21639 | } |
| 21640 | } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .Opaque) { | |
| 21640 | } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 21641 | 21641 | return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{}); |
| 21642 | 21642 | } else if (ptr_size == .C) { |
| 21643 | 21643 | if (!try sema.validateExternType(elem_ty, .other)) { |
| ... | ... | @@ -21652,7 +21652,7 @@ fn zirReify( |
| 21652 | 21652 | }; |
| 21653 | 21653 | return sema.failWithOwnedErrorMsg(block, msg); |
| 21654 | 21654 | } |
| 21655 | if (elem_ty.zigTypeTag(zcu) == .Opaque) { | |
| 21655 | if (elem_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 21656 | 21656 | return sema.fail(block, src, "C pointers cannot point to opaque types", .{}); |
| 21657 | 21657 | } |
| 21658 | 21658 | } |
| ... | ... | @@ -21671,7 +21671,7 @@ fn zirReify( |
| 21671 | 21671 | }); |
| 21672 | 21672 | return Air.internedToRef(ty.toIntern()); |
| 21673 | 21673 | }, |
| 21674 | .Array => { | |
| 21674 | .array => { | |
| 21675 | 21675 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21676 | 21676 | const len_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21677 | 21677 | ip, |
| ... | ... | @@ -21700,7 +21700,7 @@ fn zirReify( |
| 21700 | 21700 | }); |
| 21701 | 21701 | return Air.internedToRef(ty.toIntern()); |
| 21702 | 21702 | }, |
| 21703 | .Optional => { | |
| 21703 | .optional => { | |
| 21704 | 21704 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21705 | 21705 | const child_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21706 | 21706 | ip, |
| ... | ... | @@ -21712,7 +21712,7 @@ fn zirReify( |
| 21712 | 21712 | const ty = try pt.optionalType(child_ty.toIntern()); |
| 21713 | 21713 | return Air.internedToRef(ty.toIntern()); |
| 21714 | 21714 | }, |
| 21715 | .ErrorUnion => { | |
| 21715 | .error_union => { | |
| 21716 | 21716 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21717 | 21717 | const error_set_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21718 | 21718 | ip, |
| ... | ... | @@ -21726,14 +21726,14 @@ fn zirReify( |
| 21726 | 21726 | const error_set_ty = error_set_val.toType(); |
| 21727 | 21727 | const payload_ty = payload_val.toType(); |
| 21728 | 21728 | |
| 21729 | if (error_set_ty.zigTypeTag(zcu) != .ErrorSet) { | |
| 21729 | if (error_set_ty.zigTypeTag(zcu) != .error_set) { | |
| 21730 | 21730 | return sema.fail(block, src, "Type.ErrorUnion.error_set must be an error set type", .{}); |
| 21731 | 21731 | } |
| 21732 | 21732 | |
| 21733 | 21733 | const ty = try pt.errorUnionType(error_set_ty, payload_ty); |
| 21734 | 21734 | return Air.internedToRef(ty.toIntern()); |
| 21735 | 21735 | }, |
| 21736 | .ErrorSet => { | |
| 21736 | .error_set => { | |
| 21737 | 21737 | const payload_val = Value.fromInterned(union_val.val).optionalValue(zcu) orelse |
| 21738 | 21738 | return Air.internedToRef(Type.anyerror.toIntern()); |
| 21739 | 21739 | |
| ... | ... | @@ -21767,7 +21767,7 @@ fn zirReify( |
| 21767 | 21767 | const ty = try pt.errorSetFromUnsortedNames(names.keys()); |
| 21768 | 21768 | return Air.internedToRef(ty.toIntern()); |
| 21769 | 21769 | }, |
| 21770 | .Struct => { | |
| 21770 | .@"struct" => { | |
| 21771 | 21771 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21772 | 21772 | const layout_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21773 | 21773 | ip, |
| ... | ... | @@ -21807,7 +21807,7 @@ fn zirReify( |
| 21807 | 21807 | |
| 21808 | 21808 | return try sema.reifyStruct(block, inst, src, layout, backing_integer_val, fields_arr, name_strategy, is_tuple_val.toBool()); |
| 21809 | 21809 | }, |
| 21810 | .Enum => { | |
| 21810 | .@"enum" => { | |
| 21811 | 21811 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21812 | 21812 | const tag_type_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21813 | 21813 | ip, |
| ... | ... | @@ -21836,7 +21836,7 @@ fn zirReify( |
| 21836 | 21836 | |
| 21837 | 21837 | return sema.reifyEnum(block, inst, src, tag_type_val.toType(), is_exhaustive_val.toBool(), fields_arr, name_strategy); |
| 21838 | 21838 | }, |
| 21839 | .Opaque => { | |
| 21839 | .@"opaque" => { | |
| 21840 | 21840 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21841 | 21841 | const decls_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21842 | 21842 | ip, |
| ... | ... | @@ -21879,7 +21879,7 @@ fn zirReify( |
| 21879 | 21879 | try sema.addTypeReferenceEntry(src, wip_ty.index); |
| 21880 | 21880 | return Air.internedToRef(wip_ty.finish(ip, .none, new_namespace_index)); |
| 21881 | 21881 | }, |
| 21882 | .Union => { | |
| 21882 | .@"union" => { | |
| 21883 | 21883 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21884 | 21884 | const layout_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21885 | 21885 | ip, |
| ... | ... | @@ -21909,7 +21909,7 @@ fn zirReify( |
| 21909 | 21909 | |
| 21910 | 21910 | return sema.reifyUnion(block, inst, src, layout, tag_type_val, fields_arr, name_strategy); |
| 21911 | 21911 | }, |
| 21912 | .Fn => { | |
| 21912 | .@"fn" => { | |
| 21913 | 21913 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); |
| 21914 | 21914 | const calling_convention_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21915 | 21915 | ip, |
| ... | ... | @@ -21996,7 +21996,7 @@ fn zirReify( |
| 21996 | 21996 | }); |
| 21997 | 21997 | return Air.internedToRef(ty.toIntern()); |
| 21998 | 21998 | }, |
| 21999 | .Frame => return sema.failWithUseOfAsync(block, src), | |
| 21999 | .frame => return sema.failWithUseOfAsync(block, src), | |
| 22000 | 22000 | } |
| 22001 | 22001 | } |
| 22002 | 22002 | |
| ... | ... | @@ -22067,7 +22067,7 @@ fn reifyEnum( |
| 22067 | 22067 | var done = false; |
| 22068 | 22068 | errdefer if (!done) wip_ty.cancel(ip, pt.tid); |
| 22069 | 22069 | |
| 22070 | if (tag_ty.zigTypeTag(zcu) != .Int) { | |
| 22070 | if (tag_ty.zigTypeTag(zcu) != .int) { | |
| 22071 | 22071 | return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{}); |
| 22072 | 22072 | } |
| 22073 | 22073 | |
| ... | ... | @@ -22344,7 +22344,7 @@ fn reifyUnion( |
| 22344 | 22344 | |
| 22345 | 22345 | for (field_types) |field_ty_ip| { |
| 22346 | 22346 | const field_ty = Type.fromInterned(field_ty_ip); |
| 22347 | if (field_ty.zigTypeTag(zcu) == .Opaque) { | |
| 22347 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 22348 | 22348 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22349 | 22349 | const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{}); |
| 22350 | 22350 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -22602,7 +22602,7 @@ fn reifyStruct( |
| 22602 | 22602 | struct_type.field_inits.get(ip)[field_idx] = field_default; |
| 22603 | 22603 | } |
| 22604 | 22604 | |
| 22605 | if (field_ty.zigTypeTag(zcu) == .Opaque) { | |
| 22605 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 22606 | 22606 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22607 | 22607 | const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); |
| 22608 | 22608 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -22611,7 +22611,7 @@ fn reifyStruct( |
| 22611 | 22611 | break :msg msg; |
| 22612 | 22612 | }); |
| 22613 | 22613 | } |
| 22614 | if (field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 22614 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 22615 | 22615 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22616 | 22616 | const msg = try sema.errMsg(src, "struct fields cannot be 'noreturn'", .{}); |
| 22617 | 22617 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -22794,7 +22794,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22794 | 22794 | const operand_ty = sema.typeOf(operand); |
| 22795 | 22795 | |
| 22796 | 22796 | try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src); |
| 22797 | const is_vector = dest_ty.zigTypeTag(zcu) == .Vector; | |
| 22797 | const is_vector = dest_ty.zigTypeTag(zcu) == .vector; | |
| 22798 | 22798 | |
| 22799 | 22799 | const dest_scalar_ty = dest_ty.scalarType(zcu); |
| 22800 | 22800 | const operand_scalar_ty = operand_ty.scalarType(zcu); |
| ... | ... | @@ -22805,7 +22805,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22805 | 22805 | if (try sema.resolveValue(operand)) |operand_val| { |
| 22806 | 22806 | const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate); |
| 22807 | 22807 | return Air.internedToRef(result_val.toIntern()); |
| 22808 | } else if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 22808 | } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) { | |
| 22809 | 22809 | return sema.failWithNeededComptime(block, operand_src, .{ |
| 22810 | 22810 | .needed_comptime_reason = "value being casted to 'comptime_int' must be comptime-known", |
| 22811 | 22811 | }); |
| ... | ... | @@ -22877,7 +22877,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22877 | 22877 | const operand_ty = sema.typeOf(operand); |
| 22878 | 22878 | |
| 22879 | 22879 | try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src); |
| 22880 | const is_vector = dest_ty.zigTypeTag(zcu) == .Vector; | |
| 22880 | const is_vector = dest_ty.zigTypeTag(zcu) == .vector; | |
| 22881 | 22881 | |
| 22882 | 22882 | const dest_scalar_ty = dest_ty.scalarType(zcu); |
| 22883 | 22883 | const operand_scalar_ty = operand_ty.scalarType(zcu); |
| ... | ... | @@ -22888,7 +22888,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22888 | 22888 | if (try sema.resolveValue(operand)) |operand_val| { |
| 22889 | 22889 | const result_val = try operand_val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, pt, .sema); |
| 22890 | 22890 | return Air.internedToRef(result_val.toIntern()); |
| 22891 | } else if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeFloat) { | |
| 22891 | } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_float) { | |
| 22892 | 22892 | return sema.failWithNeededComptime(block, operand_src, .{ |
| 22893 | 22893 | .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known", |
| 22894 | 22894 | }); |
| ... | ... | @@ -22923,7 +22923,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22923 | 22923 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt"); |
| 22924 | 22924 | try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, uncoerced_operand_ty, src, operand_src); |
| 22925 | 22925 | |
| 22926 | const is_vector = dest_ty.zigTypeTag(zcu) == .Vector; | |
| 22926 | const is_vector = dest_ty.zigTypeTag(zcu) == .vector; | |
| 22927 | 22927 | const operand_ty = if (is_vector) operand_ty: { |
| 22928 | 22928 | const len = dest_ty.vectorLen(zcu); |
| 22929 | 22929 | break :operand_ty try pt.vectorType(.{ .child = .usize_type, .len = len }); |
| ... | ... | @@ -22975,7 +22975,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22975 | 22975 | } |
| 22976 | 22976 | try sema.requireRuntimeBlock(block, src, operand_src); |
| 22977 | 22977 | if (!is_vector) { |
| 22978 | if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .Fn)) { | |
| 22978 | if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .@"fn")) { | |
| 22979 | 22979 | if (!ptr_ty.isAllowzeroPtr(zcu)) { |
| 22980 | 22980 | const is_non_zero = try block.addBinOp(.cmp_neq, operand_coerced, .zero_usize); |
| 22981 | 22981 | try sema.addSafetyCheck(block, src, is_non_zero, .cast_to_null); |
| ... | ... | @@ -22992,7 +22992,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22992 | 22992 | } |
| 22993 | 22993 | |
| 22994 | 22994 | const len = dest_ty.vectorLen(zcu); |
| 22995 | if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .Fn)) { | |
| 22995 | if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .@"fn")) { | |
| 22996 | 22996 | for (0..len) |i| { |
| 22997 | 22997 | const idx_ref = try pt.intRef(Type.usize, i); |
| 22998 | 22998 | const elem_coerced = try block.addBinOp(.array_elem_val, operand_coerced, idx_ref); |
| ... | ... | @@ -23042,11 +23042,11 @@ fn ptrFromIntVal( |
| 23042 | 23042 | return sema.fail(block, operand_src, "pointer type '{}' requires aligned address", .{ptr_ty.fmt(pt)}); |
| 23043 | 23043 | |
| 23044 | 23044 | return switch (ptr_ty.zigTypeTag(zcu)) { |
| 23045 | .Optional => Value.fromInterned(try pt.intern(.{ .opt = .{ | |
| 23045 | .optional => Value.fromInterned(try pt.intern(.{ .opt = .{ | |
| 23046 | 23046 | .ty = ptr_ty.toIntern(), |
| 23047 | 23047 | .val = if (addr == 0) .none else (try pt.ptrIntValue(ptr_ty.childType(zcu), addr)).toIntern(), |
| 23048 | 23048 | } })), |
| 23049 | .Pointer => try pt.ptrIntValue(ptr_ty, addr), | |
| 23049 | .pointer => try pt.ptrIntValue(ptr_ty, addr), | |
| 23050 | 23050 | else => unreachable, |
| 23051 | 23051 | }; |
| 23052 | 23052 | } |
| ... | ... | @@ -23064,16 +23064,16 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 23064 | 23064 | const dest_tag = base_dest_ty.zigTypeTag(zcu); |
| 23065 | 23065 | const operand_tag = base_operand_ty.zigTypeTag(zcu); |
| 23066 | 23066 | |
| 23067 | if (dest_tag != .ErrorSet and dest_tag != .ErrorUnion) { | |
| 23067 | if (dest_tag != .error_set and dest_tag != .error_union) { | |
| 23068 | 23068 | return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(dest_tag)}); |
| 23069 | 23069 | } |
| 23070 | if (operand_tag != .ErrorSet and operand_tag != .ErrorUnion) { | |
| 23070 | if (operand_tag != .error_set and operand_tag != .error_union) { | |
| 23071 | 23071 | return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(operand_tag)}); |
| 23072 | 23072 | } |
| 23073 | if (dest_tag == .ErrorSet and operand_tag == .ErrorUnion) { | |
| 23073 | if (dest_tag == .error_set and operand_tag == .error_union) { | |
| 23074 | 23074 | return sema.fail(block, src, "cannot cast an error union type to error set", .{}); |
| 23075 | 23075 | } |
| 23076 | if (dest_tag == .ErrorUnion and operand_tag == .ErrorUnion and | |
| 23076 | if (dest_tag == .error_union and operand_tag == .error_union and | |
| 23077 | 23077 | base_dest_ty.errorUnionPayload(zcu).toIntern() != base_operand_ty.errorUnionPayload(zcu).toIntern()) |
| 23078 | 23078 | { |
| 23079 | 23079 | return sema.failWithOwnedErrorMsg(block, msg: { |
| ... | ... | @@ -23088,8 +23088,8 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 23088 | 23088 | break :msg msg; |
| 23089 | 23089 | }); |
| 23090 | 23090 | } |
| 23091 | const dest_ty = if (dest_tag == .ErrorUnion) base_dest_ty.errorUnionSet(zcu) else base_dest_ty; | |
| 23092 | const operand_ty = if (operand_tag == .ErrorUnion) base_operand_ty.errorUnionSet(zcu) else base_operand_ty; | |
| 23091 | const dest_ty = if (dest_tag == .error_union) base_dest_ty.errorUnionSet(zcu) else base_dest_ty; | |
| 23092 | const operand_ty = if (operand_tag == .error_union) base_operand_ty.errorUnionSet(zcu) else base_operand_ty; | |
| 23093 | 23093 | |
| 23094 | 23094 | // operand must be defined since it can be an invalid error value |
| 23095 | 23095 | const maybe_operand_val = try sema.resolveDefinedValue(block, operand_src, operand); |
| ... | ... | @@ -23121,7 +23121,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 23121 | 23121 | |
| 23122 | 23122 | break :disjoint true; |
| 23123 | 23123 | }; |
| 23124 | if (disjoint and dest_tag != .ErrorUnion) { | |
| 23124 | if (disjoint and dest_tag != .error_union) { | |
| 23125 | 23125 | return sema.fail(block, src, "error sets '{}' and '{}' have no common errors", .{ |
| 23126 | 23126 | operand_ty.fmt(pt), dest_ty.fmt(pt), |
| 23127 | 23127 | }); |
| ... | ... | @@ -23131,7 +23131,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 23131 | 23131 | if (!dest_ty.isAnyError(zcu)) check: { |
| 23132 | 23132 | const operand_val = zcu.intern_pool.indexToKey(val.toIntern()); |
| 23133 | 23133 | var error_name: InternPool.NullTerminatedString = undefined; |
| 23134 | if (operand_tag == .ErrorUnion) { | |
| 23134 | if (operand_tag == .error_union) { | |
| 23135 | 23135 | if (operand_val.error_union.val != .err_name) break :check; |
| 23136 | 23136 | error_name = operand_val.error_union.val.err_name; |
| 23137 | 23137 | } else { |
| ... | ... | @@ -23153,7 +23153,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 23153 | 23153 | dest_ty.toIntern() != .adhoc_inferred_error_set_type and |
| 23154 | 23154 | zcu.backendSupportsFeature(.error_set_has_value)) |
| 23155 | 23155 | { |
| 23156 | if (dest_tag == .ErrorUnion) { | |
| 23156 | if (dest_tag == .error_union) { | |
| 23157 | 23157 | const err_code = try sema.analyzeErrUnionCode(block, operand_src, operand); |
| 23158 | 23158 | const err_int = try block.addBitCast(err_int_ty, err_code); |
| 23159 | 23159 | const zero_err = try pt.intRef(try pt.errorIntType(), 0); |
| ... | ... | @@ -23178,7 +23178,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 23178 | 23178 | } |
| 23179 | 23179 | |
| 23180 | 23180 | fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 23181 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; | |
| 23181 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | |
| 23182 | 23182 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 23183 | 23183 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 23184 | 23184 | const src = block.nodeOffset(extra.node); |
| ... | ... | @@ -23239,10 +23239,10 @@ fn ptrCastFull( |
| 23239 | 23239 | try Type.fromInterned(dest_info.child).resolveLayout(pt); |
| 23240 | 23240 | |
| 23241 | 23241 | const src_slice_like = src_info.flags.size == .Slice or |
| 23242 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .Array); | |
| 23242 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array); | |
| 23243 | 23243 | |
| 23244 | 23244 | const dest_slice_like = dest_info.flags.size == .Slice or |
| 23245 | (dest_info.flags.size == .One and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .Array); | |
| 23245 | (dest_info.flags.size == .One and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array); | |
| 23246 | 23246 | |
| 23247 | 23247 | if (dest_info.flags.size == .Slice and !src_slice_like) { |
| 23248 | 23248 | return sema.fail(block, src, "illegal pointer cast to slice", .{}); |
| ... | ... | @@ -23277,7 +23277,7 @@ fn ptrCastFull( |
| 23277 | 23277 | errdefer msg.destroy(sema.gpa); |
| 23278 | 23278 | if (dest_info.flags.size == .Many and |
| 23279 | 23279 | (src_info.flags.size == .Slice or |
| 23280 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .Array))) | |
| 23280 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array))) | |
| 23281 | 23281 | { |
| 23282 | 23282 | try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{}); |
| 23283 | 23283 | } else { |
| ... | ... | @@ -23473,7 +23473,7 @@ fn ptrCastFull( |
| 23473 | 23473 | } |
| 23474 | 23474 | |
| 23475 | 23475 | const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: { |
| 23476 | if (operand_ty.zigTypeTag(zcu) == .Optional) { | |
| 23476 | if (operand_ty.zigTypeTag(zcu) == .optional) { | |
| 23477 | 23477 | break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty); |
| 23478 | 23478 | } else { |
| 23479 | 23479 | break :ptr try sema.analyzeSlicePtr(block, operand_src, operand, operand_ty); |
| ... | ... | @@ -23485,7 +23485,7 @@ fn ptrCastFull( |
| 23485 | 23485 | var info = dest_info; |
| 23486 | 23486 | info.flags.size = .Many; |
| 23487 | 23487 | const ty = try pt.ptrTypeSema(info); |
| 23488 | if (dest_ty.zigTypeTag(zcu) == .Optional) { | |
| 23488 | if (dest_ty.zigTypeTag(zcu) == .optional) { | |
| 23489 | 23489 | break :blk try pt.optionalType(ty.toIntern()); |
| 23490 | 23490 | } else { |
| 23491 | 23491 | break :blk ty; |
| ... | ... | @@ -23535,7 +23535,7 @@ fn ptrCastFull( |
| 23535 | 23535 | try sema.validateRuntimeValue(block, operand_src, ptr); |
| 23536 | 23536 | |
| 23537 | 23537 | if (block.wantSafety() and operand_ty.ptrAllowsZero(zcu) and !dest_ty.ptrAllowsZero(zcu) and |
| 23538 | (try Type.fromInterned(dest_info.child).hasRuntimeBitsSema(pt) or Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .Fn)) | |
| 23538 | (try Type.fromInterned(dest_info.child).hasRuntimeBitsSema(pt) or Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .@"fn")) | |
| 23539 | 23539 | { |
| 23540 | 23540 | const ptr_int = try block.addUnOp(.int_from_ptr, ptr); |
| 23541 | 23541 | const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize); |
| ... | ... | @@ -23570,7 +23570,7 @@ fn ptrCastFull( |
| 23570 | 23570 | var intermediate_info = src_info; |
| 23571 | 23571 | intermediate_info.flags.address_space = dest_info.flags.address_space; |
| 23572 | 23572 | const intermediate_ptr_ty = try pt.ptrTypeSema(intermediate_info); |
| 23573 | const intermediate_ty = if (dest_ptr_ty.zigTypeTag(zcu) == .Optional) blk: { | |
| 23573 | const intermediate_ty = if (dest_ptr_ty.zigTypeTag(zcu) == .optional) blk: { | |
| 23574 | 23574 | break :blk try pt.optionalType(intermediate_ptr_ty.toIntern()); |
| 23575 | 23575 | } else intermediate_ptr_ty; |
| 23576 | 23576 | const intermediate = try block.addInst(.{ |
| ... | ... | @@ -23613,7 +23613,7 @@ fn ptrCastFull( |
| 23613 | 23613 | fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 23614 | 23614 | const pt = sema.pt; |
| 23615 | 23615 | const zcu = pt.zcu; |
| 23616 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; | |
| 23616 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | |
| 23617 | 23617 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 23618 | 23618 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 23619 | 23619 | const src = block.nodeOffset(extra.node); |
| ... | ... | @@ -23628,7 +23628,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst |
| 23628 | 23628 | |
| 23629 | 23629 | const dest_ty = blk: { |
| 23630 | 23630 | const dest_ty = try pt.ptrTypeSema(ptr_info); |
| 23631 | if (operand_ty.zigTypeTag(zcu) == .Optional) { | |
| 23631 | if (operand_ty.zigTypeTag(zcu) == .optional) { | |
| 23632 | 23632 | break :blk try pt.optionalType(dest_ty.toIntern()); |
| 23633 | 23633 | } |
| 23634 | 23634 | break :blk dest_ty; |
| ... | ... | @@ -23657,13 +23657,13 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 23657 | 23657 | const operand_ty = sema.typeOf(operand); |
| 23658 | 23658 | const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); |
| 23659 | 23659 | |
| 23660 | const operand_is_vector = operand_ty.zigTypeTag(zcu) == .Vector; | |
| 23661 | const dest_is_vector = dest_ty.zigTypeTag(zcu) == .Vector; | |
| 23660 | const operand_is_vector = operand_ty.zigTypeTag(zcu) == .vector; | |
| 23661 | const dest_is_vector = dest_ty.zigTypeTag(zcu) == .vector; | |
| 23662 | 23662 | if (operand_is_vector != dest_is_vector) { |
| 23663 | 23663 | return sema.fail(block, operand_src, "expected type '{}', found '{}'", .{ dest_ty.fmt(pt), operand_ty.fmt(pt) }); |
| 23664 | 23664 | } |
| 23665 | 23665 | |
| 23666 | if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 23666 | if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) { | |
| 23667 | 23667 | return sema.coerce(block, dest_ty, operand, operand_src); |
| 23668 | 23668 | } |
| 23669 | 23669 | |
| ... | ... | @@ -23673,7 +23673,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 23673 | 23673 | return Air.internedToRef(val.toIntern()); |
| 23674 | 23674 | } |
| 23675 | 23675 | |
| 23676 | if (operand_scalar_ty.zigTypeTag(zcu) != .ComptimeInt) { | |
| 23676 | if (operand_scalar_ty.zigTypeTag(zcu) != .comptime_int) { | |
| 23677 | 23677 | const operand_info = operand_ty.intInfo(zcu); |
| 23678 | 23678 | if (try sema.typeHasOnePossibleValue(operand_ty)) |val| { |
| 23679 | 23679 | return Air.internedToRef(val.toIntern()); |
| ... | ... | @@ -23751,7 +23751,7 @@ fn zirBitCount( |
| 23751 | 23751 | |
| 23752 | 23752 | const result_scalar_ty = try pt.smallestUnsignedInt(bits); |
| 23753 | 23753 | switch (operand_ty.zigTypeTag(zcu)) { |
| 23754 | .Vector => { | |
| 23754 | .vector => { | |
| 23755 | 23755 | const vec_len = operand_ty.vectorLen(zcu); |
| 23756 | 23756 | const result_ty = try pt.vectorType(.{ |
| 23757 | 23757 | .len = vec_len, |
| ... | ... | @@ -23776,7 +23776,7 @@ fn zirBitCount( |
| 23776 | 23776 | return block.addTyOp(air_tag, result_ty, operand); |
| 23777 | 23777 | } |
| 23778 | 23778 | }, |
| 23779 | .Int => { | |
| 23779 | .int => { | |
| 23780 | 23780 | if (try sema.resolveValueResolveLazy(operand)) |val| { |
| 23781 | 23781 | if (val.isUndef(zcu)) return pt.undefRef(result_scalar_ty); |
| 23782 | 23782 | return pt.intRef(result_scalar_ty, comptimeOp(val, operand_ty, zcu)); |
| ... | ... | @@ -23813,7 +23813,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 23813 | 23813 | } |
| 23814 | 23814 | |
| 23815 | 23815 | switch (operand_ty.zigTypeTag(zcu)) { |
| 23816 | .Int => { | |
| 23816 | .int => { | |
| 23817 | 23817 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 23818 | 23818 | if (val.isUndef(zcu)) return pt.undefRef(operand_ty); |
| 23819 | 23819 | const result_val = try val.byteSwap(operand_ty, pt, sema.arena); |
| ... | ... | @@ -23823,7 +23823,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 23823 | 23823 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 23824 | 23824 | return block.addTyOp(.byte_swap, operand_ty, operand); |
| 23825 | 23825 | }, |
| 23826 | .Vector => { | |
| 23826 | .vector => { | |
| 23827 | 23827 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 23828 | 23828 | if (val.isUndef(zcu)) |
| 23829 | 23829 | return pt.undefRef(operand_ty); |
| ... | ... | @@ -23862,7 +23862,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 23862 | 23862 | const pt = sema.pt; |
| 23863 | 23863 | const zcu = pt.zcu; |
| 23864 | 23864 | switch (operand_ty.zigTypeTag(zcu)) { |
| 23865 | .Int => { | |
| 23865 | .int => { | |
| 23866 | 23866 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 23867 | 23867 | if (val.isUndef(zcu)) return pt.undefRef(operand_ty); |
| 23868 | 23868 | const result_val = try val.bitReverse(operand_ty, pt, sema.arena); |
| ... | ... | @@ -23872,7 +23872,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 23872 | 23872 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 23873 | 23873 | return block.addTyOp(.bit_reverse, operand_ty, operand); |
| 23874 | 23874 | }, |
| 23875 | .Vector => { | |
| 23875 | .vector => { | |
| 23876 | 23876 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 23877 | 23877 | if (val.isUndef(zcu)) |
| 23878 | 23878 | return pt.undefRef(operand_ty); |
| ... | ... | @@ -23924,7 +23924,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 |
| 23924 | 23924 | const ip = &zcu.intern_pool; |
| 23925 | 23925 | try ty.resolveLayout(pt); |
| 23926 | 23926 | switch (ty.zigTypeTag(zcu)) { |
| 23927 | .Struct => {}, | |
| 23927 | .@"struct" => {}, | |
| 23928 | 23928 | else => return sema.fail(block, lhs_src, "expected struct type, found '{}'", .{ty.fmt(pt)}), |
| 23929 | 23929 | } |
| 23930 | 23930 | |
| ... | ... | @@ -23959,7 +23959,7 @@ fn checkNamespaceType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) Com |
| 23959 | 23959 | const pt = sema.pt; |
| 23960 | 23960 | const zcu = pt.zcu; |
| 23961 | 23961 | switch (ty.zigTypeTag(zcu)) { |
| 23962 | .Struct, .Enum, .Union, .Opaque => return, | |
| 23962 | .@"struct", .@"enum", .@"union", .@"opaque" => return, | |
| 23963 | 23963 | else => return sema.fail(block, src, "expected struct, enum, union, or opaque; found '{}'", .{ty.fmt(pt)}), |
| 23964 | 23964 | } |
| 23965 | 23965 | } |
| ... | ... | @@ -23969,8 +23969,8 @@ fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileEr |
| 23969 | 23969 | const pt = sema.pt; |
| 23970 | 23970 | const zcu = pt.zcu; |
| 23971 | 23971 | switch (try ty.zigTypeTagOrPoison(zcu)) { |
| 23972 | .ComptimeInt => return true, | |
| 23973 | .Int => return false, | |
| 23972 | .comptime_int => return true, | |
| 23973 | .int => return false, | |
| 23974 | 23974 | else => return sema.fail(block, src, "expected integer type, found '{}'", .{ty.fmt(pt)}), |
| 23975 | 23975 | } |
| 23976 | 23976 | } |
| ... | ... | @@ -23984,7 +23984,7 @@ fn checkInvalidPtrIntArithmetic( |
| 23984 | 23984 | const pt = sema.pt; |
| 23985 | 23985 | const zcu = pt.zcu; |
| 23986 | 23986 | switch (try ty.zigTypeTagOrPoison(zcu)) { |
| 23987 | .Pointer => switch (ty.ptrSize(zcu)) { | |
| 23987 | .pointer => switch (ty.ptrSize(zcu)) { | |
| 23988 | 23988 | .One, .Slice => return, |
| 23989 | 23989 | .Many, .C => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"), |
| 23990 | 23990 | }, |
| ... | ... | @@ -24001,8 +24001,8 @@ fn checkArithmeticOp( |
| 24001 | 24001 | rhs_zig_ty_tag: std.builtin.TypeId, |
| 24002 | 24002 | zir_tag: Zir.Inst.Tag, |
| 24003 | 24003 | ) CompileError!void { |
| 24004 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | |
| 24005 | const is_float = scalar_tag == .Float or scalar_tag == .ComptimeFloat; | |
| 24004 | const is_int = scalar_tag == .int or scalar_tag == .comptime_int; | |
| 24005 | const is_float = scalar_tag == .float or scalar_tag == .comptime_float; | |
| 24006 | 24006 | |
| 24007 | 24007 | if (!is_int and !(is_float and floatOpAllowed(zir_tag))) { |
| 24008 | 24008 | return sema.fail(block, src, "invalid operands to binary expression: '{s}' and '{s}'", .{ |
| ... | ... | @@ -24020,8 +24020,8 @@ fn checkPtrOperand( |
| 24020 | 24020 | const pt = sema.pt; |
| 24021 | 24021 | const zcu = pt.zcu; |
| 24022 | 24022 | switch (ty.zigTypeTag(zcu)) { |
| 24023 | .Pointer => return, | |
| 24024 | .Fn => { | |
| 24023 | .pointer => return, | |
| 24024 | .@"fn" => { | |
| 24025 | 24025 | const msg = msg: { |
| 24026 | 24026 | const msg = try sema.errMsg( |
| 24027 | 24027 | ty_src, |
| ... | ... | @@ -24036,7 +24036,7 @@ fn checkPtrOperand( |
| 24036 | 24036 | }; |
| 24037 | 24037 | return sema.failWithOwnedErrorMsg(block, msg); |
| 24038 | 24038 | }, |
| 24039 | .Optional => if (ty.childType(zcu).zigTypeTag(zcu) == .Pointer) return, | |
| 24039 | .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return, | |
| 24040 | 24040 | else => {}, |
| 24041 | 24041 | } |
| 24042 | 24042 | return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty.fmt(pt)}); |
| ... | ... | @@ -24052,8 +24052,8 @@ fn checkPtrType( |
| 24052 | 24052 | const pt = sema.pt; |
| 24053 | 24053 | const zcu = pt.zcu; |
| 24054 | 24054 | switch (ty.zigTypeTag(zcu)) { |
| 24055 | .Pointer => if (allow_slice or !ty.isSlice(zcu)) return, | |
| 24056 | .Fn => { | |
| 24055 | .pointer => if (allow_slice or !ty.isSlice(zcu)) return, | |
| 24056 | .@"fn" => { | |
| 24057 | 24057 | const msg = msg: { |
| 24058 | 24058 | const msg = try sema.errMsg( |
| 24059 | 24059 | ty_src, |
| ... | ... | @@ -24068,7 +24068,7 @@ fn checkPtrType( |
| 24068 | 24068 | }; |
| 24069 | 24069 | return sema.failWithOwnedErrorMsg(block, msg); |
| 24070 | 24070 | }, |
| 24071 | .Optional => if (ty.childType(zcu).zigTypeTag(zcu) == .Pointer) return, | |
| 24071 | .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return, | |
| 24072 | 24072 | else => {}, |
| 24073 | 24073 | } |
| 24074 | 24074 | return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty.fmt(pt)}); |
| ... | ... | @@ -24083,8 +24083,8 @@ fn checkVectorElemType( |
| 24083 | 24083 | const pt = sema.pt; |
| 24084 | 24084 | const zcu = pt.zcu; |
| 24085 | 24085 | switch (ty.zigTypeTag(zcu)) { |
| 24086 | .Int, .Float, .Bool => return, | |
| 24087 | .Optional, .Pointer => if (ty.isPtrAtRuntime(zcu)) return, | |
| 24086 | .int, .float, .bool => return, | |
| 24087 | .optional, .pointer => if (ty.isPtrAtRuntime(zcu)) return, | |
| 24088 | 24088 | else => {}, |
| 24089 | 24089 | } |
| 24090 | 24090 | return sema.fail(block, ty_src, "expected integer, float, bool, or pointer for the vector element type; found '{}'", .{ty.fmt(pt)}); |
| ... | ... | @@ -24099,7 +24099,7 @@ fn checkFloatType( |
| 24099 | 24099 | const pt = sema.pt; |
| 24100 | 24100 | const zcu = pt.zcu; |
| 24101 | 24101 | switch (ty.zigTypeTag(zcu)) { |
| 24102 | .ComptimeInt, .ComptimeFloat, .Float => {}, | |
| 24102 | .comptime_int, .comptime_float, .float => {}, | |
| 24103 | 24103 | else => return sema.fail(block, ty_src, "expected float type, found '{}'", .{ty.fmt(pt)}), |
| 24104 | 24104 | } |
| 24105 | 24105 | } |
| ... | ... | @@ -24113,9 +24113,9 @@ fn checkNumericType( |
| 24113 | 24113 | const pt = sema.pt; |
| 24114 | 24114 | const zcu = pt.zcu; |
| 24115 | 24115 | switch (ty.zigTypeTag(zcu)) { |
| 24116 | .ComptimeFloat, .Float, .ComptimeInt, .Int => {}, | |
| 24117 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 24118 | .ComptimeFloat, .Float, .ComptimeInt, .Int => {}, | |
| 24116 | .comptime_float, .float, .comptime_int, .int => {}, | |
| 24117 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 24118 | .comptime_float, .float, .comptime_int, .int => {}, | |
| 24119 | 24119 | else => |t| return sema.fail(block, ty_src, "expected number, found '{}'", .{t}), |
| 24120 | 24120 | }, |
| 24121 | 24121 | else => return sema.fail(block, ty_src, "expected number, found '{}'", .{ty.fmt(pt)}), |
| ... | ... | @@ -24167,7 +24167,7 @@ fn checkAtomicPtrOperand( |
| 24167 | 24167 | |
| 24168 | 24168 | const ptr_ty = sema.typeOf(ptr); |
| 24169 | 24169 | const ptr_data = switch (try ptr_ty.zigTypeTagOrPoison(zcu)) { |
| 24170 | .Pointer => ptr_ty.ptrInfo(zcu), | |
| 24170 | .pointer => ptr_ty.ptrInfo(zcu), | |
| 24171 | 24171 | else => { |
| 24172 | 24172 | const wanted_ptr_ty = try pt.ptrTypeSema(wanted_ptr_data); |
| 24173 | 24173 | _ = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); |
| ... | ... | @@ -24208,11 +24208,11 @@ fn checkIntOrVector( |
| 24208 | 24208 | const zcu = pt.zcu; |
| 24209 | 24209 | const operand_ty = sema.typeOf(operand); |
| 24210 | 24210 | switch (try operand_ty.zigTypeTagOrPoison(zcu)) { |
| 24211 | .Int => return operand_ty, | |
| 24212 | .Vector => { | |
| 24211 | .int => return operand_ty, | |
| 24212 | .vector => { | |
| 24213 | 24213 | const elem_ty = operand_ty.childType(zcu); |
| 24214 | 24214 | switch (try elem_ty.zigTypeTagOrPoison(zcu)) { |
| 24215 | .Int => return elem_ty, | |
| 24215 | .int => return elem_ty, | |
| 24216 | 24216 | else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{}'", .{ |
| 24217 | 24217 | elem_ty.fmt(pt), |
| 24218 | 24218 | }), |
| ... | ... | @@ -24233,11 +24233,11 @@ fn checkIntOrVectorAllowComptime( |
| 24233 | 24233 | const pt = sema.pt; |
| 24234 | 24234 | const zcu = pt.zcu; |
| 24235 | 24235 | switch (try operand_ty.zigTypeTagOrPoison(zcu)) { |
| 24236 | .Int, .ComptimeInt => return operand_ty, | |
| 24237 | .Vector => { | |
| 24236 | .int, .comptime_int => return operand_ty, | |
| 24237 | .vector => { | |
| 24238 | 24238 | const elem_ty = operand_ty.childType(zcu); |
| 24239 | 24239 | switch (try elem_ty.zigTypeTagOrPoison(zcu)) { |
| 24240 | .Int, .ComptimeInt => return elem_ty, | |
| 24240 | .int, .comptime_int => return elem_ty, | |
| 24241 | 24241 | else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{}'", .{ |
| 24242 | 24242 | elem_ty.fmt(pt), |
| 24243 | 24243 | }), |
| ... | ... | @@ -24277,7 +24277,7 @@ fn checkSimdBinOp( |
| 24277 | 24277 | const rhs_ty = sema.typeOf(uncasted_rhs); |
| 24278 | 24278 | |
| 24279 | 24279 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 24280 | const vec_len: ?usize = if (lhs_ty.zigTypeTag(zcu) == .Vector) lhs_ty.vectorLen(zcu) else null; | |
| 24280 | const vec_len: ?usize = if (lhs_ty.zigTypeTag(zcu) == .vector) lhs_ty.vectorLen(zcu) else null; | |
| 24281 | 24281 | const result_ty = try sema.resolvePeerTypes(block, src, &.{ uncasted_lhs, uncasted_rhs }, .{ |
| 24282 | 24282 | .override = &[_]?LazySrcLoc{ lhs_src, rhs_src }, |
| 24283 | 24283 | }); |
| ... | ... | @@ -24308,14 +24308,14 @@ fn checkVectorizableBinaryOperands( |
| 24308 | 24308 | const zcu = pt.zcu; |
| 24309 | 24309 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(zcu); |
| 24310 | 24310 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(zcu); |
| 24311 | if (lhs_zig_ty_tag != .Vector and rhs_zig_ty_tag != .Vector) return; | |
| 24311 | if (lhs_zig_ty_tag != .vector and rhs_zig_ty_tag != .vector) return; | |
| 24312 | 24312 | |
| 24313 | 24313 | const lhs_is_vector = switch (lhs_zig_ty_tag) { |
| 24314 | .Vector, .Array => true, | |
| 24314 | .vector, .array => true, | |
| 24315 | 24315 | else => false, |
| 24316 | 24316 | }; |
| 24317 | 24317 | const rhs_is_vector = switch (rhs_zig_ty_tag) { |
| 24318 | .Vector, .Array => true, | |
| 24318 | .vector, .array => true, | |
| 24319 | 24319 | else => false, |
| 24320 | 24320 | }; |
| 24321 | 24321 | |
| ... | ... | @@ -24477,7 +24477,7 @@ fn zirCmpxchg( |
| 24477 | 24477 | // zig fmt: on |
| 24478 | 24478 | const expected_value = try sema.resolveInst(extra.expected_value); |
| 24479 | 24479 | const elem_ty = sema.typeOf(expected_value); |
| 24480 | if (elem_ty.zigTypeTag(zcu) == .Float) { | |
| 24480 | if (elem_ty.zigTypeTag(zcu) == .float) { | |
| 24481 | 24481 | return sema.fail( |
| 24482 | 24482 | block, |
| 24483 | 24483 | elem_ty_src, |
| ... | ... | @@ -24602,7 +24602,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 24602 | 24602 | const pt = sema.pt; |
| 24603 | 24603 | const zcu = pt.zcu; |
| 24604 | 24604 | |
| 24605 | if (operand_ty.zigTypeTag(zcu) != .Vector) { | |
| 24605 | if (operand_ty.zigTypeTag(zcu) != .vector) { | |
| 24606 | 24606 | return sema.fail(block, operand_src, "expected vector, found '{}'", .{operand_ty.fmt(pt)}); |
| 24607 | 24607 | } |
| 24608 | 24608 | |
| ... | ... | @@ -24611,13 +24611,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 24611 | 24611 | // Type-check depending on operation. |
| 24612 | 24612 | switch (operation) { |
| 24613 | 24613 | .And, .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) { |
| 24614 | .Int, .Bool => {}, | |
| 24614 | .int, .bool => {}, | |
| 24615 | 24615 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found '{}'", .{ |
| 24616 | 24616 | @tagName(operation), operand_ty.fmt(pt), |
| 24617 | 24617 | }), |
| 24618 | 24618 | }, |
| 24619 | 24619 | .Min, .Max, .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) { |
| 24620 | .Int, .Float => {}, | |
| 24620 | .int, .float => {}, | |
| 24621 | 24621 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found '{}'", .{ |
| 24622 | 24622 | @tagName(operation), operand_ty.fmt(pt), |
| 24623 | 24623 | }), |
| ... | ... | @@ -24677,7 +24677,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 24677 | 24677 | var mask_ty = sema.typeOf(mask); |
| 24678 | 24678 | |
| 24679 | 24679 | const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) { |
| 24680 | .Array, .Vector => sema.typeOf(mask).arrayLen(zcu), | |
| 24680 | .array, .vector => sema.typeOf(mask).arrayLen(zcu), | |
| 24681 | 24681 | else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(pt)}), |
| 24682 | 24682 | }; |
| 24683 | 24683 | mask_ty = try pt.vectorType(.{ |
| ... | ... | @@ -24715,16 +24715,16 @@ fn analyzeShuffle( |
| 24715 | 24715 | }); |
| 24716 | 24716 | |
| 24717 | 24717 | const maybe_a_len = switch (sema.typeOf(a).zigTypeTag(zcu)) { |
| 24718 | .Array, .Vector => sema.typeOf(a).arrayLen(zcu), | |
| 24719 | .Undefined => null, | |
| 24718 | .array, .vector => sema.typeOf(a).arrayLen(zcu), | |
| 24719 | .undefined => null, | |
| 24720 | 24720 | else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{ |
| 24721 | 24721 | elem_ty.fmt(pt), |
| 24722 | 24722 | sema.typeOf(a).fmt(pt), |
| 24723 | 24723 | }), |
| 24724 | 24724 | }; |
| 24725 | 24725 | const maybe_b_len = switch (sema.typeOf(b).zigTypeTag(zcu)) { |
| 24726 | .Array, .Vector => sema.typeOf(b).arrayLen(zcu), | |
| 24727 | .Undefined => null, | |
| 24726 | .array, .vector => sema.typeOf(b).arrayLen(zcu), | |
| 24727 | .undefined => null, | |
| 24728 | 24728 | else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{ |
| 24729 | 24729 | elem_ty.fmt(pt), |
| 24730 | 24730 | sema.typeOf(b).fmt(pt), |
| ... | ... | @@ -24869,7 +24869,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 24869 | 24869 | const pred_ty = sema.typeOf(pred_uncoerced); |
| 24870 | 24870 | |
| 24871 | 24871 | const vec_len_u64 = switch (try pred_ty.zigTypeTagOrPoison(zcu)) { |
| 24872 | .Vector, .Array => pred_ty.arrayLen(zcu), | |
| 24872 | .vector, .array => pred_ty.arrayLen(zcu), | |
| 24873 | 24873 | else => return sema.fail(block, pred_src, "expected vector or array, found '{}'", .{pred_ty.fmt(pt)}), |
| 24874 | 24874 | }; |
| 24875 | 24875 | const vec_len: u32 = @intCast(try sema.usizeCast(block, pred_src, vec_len_u64)); |
| ... | ... | @@ -25011,13 +25011,13 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 25011 | 25011 | const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation); |
| 25012 | 25012 | |
| 25013 | 25013 | switch (elem_ty.zigTypeTag(zcu)) { |
| 25014 | .Enum => if (op != .Xchg) { | |
| 25014 | .@"enum" => if (op != .Xchg) { | |
| 25015 | 25015 | return sema.fail(block, op_src, "@atomicRmw with enum only allowed with .Xchg", .{}); |
| 25016 | 25016 | }, |
| 25017 | .Bool => if (op != .Xchg) { | |
| 25017 | .bool => if (op != .Xchg) { | |
| 25018 | 25018 | return sema.fail(block, op_src, "@atomicRmw with bool only allowed with .Xchg", .{}); |
| 25019 | 25019 | }, |
| 25020 | .Float => switch (op) { | |
| 25020 | .float => switch (op) { | |
| 25021 | 25021 | .Xchg, .Add, .Sub, .Max, .Min => {}, |
| 25022 | 25022 | else => return sema.fail(block, op_src, "@atomicRmw with float only allowed with .Xchg, .Add, .Sub, .Max, and .Min", .{}), |
| 25023 | 25023 | }, |
| ... | ... | @@ -25135,7 +25135,7 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 25135 | 25135 | const zcu = pt.zcu; |
| 25136 | 25136 | |
| 25137 | 25137 | switch (ty.scalarType(zcu).zigTypeTag(zcu)) { |
| 25138 | .ComptimeFloat, .Float => {}, | |
| 25138 | .comptime_float, .float => {}, | |
| 25139 | 25139 | else => return sema.fail(block, src, "expected vector of floats or float type, found '{}'", .{ty.fmt(pt)}), |
| 25140 | 25140 | } |
| 25141 | 25141 | |
| ... | ... | @@ -25281,7 +25281,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25281 | 25281 | const ip = &zcu.intern_pool; |
| 25282 | 25282 | |
| 25283 | 25283 | const extra = sema.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data; |
| 25284 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; | |
| 25284 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | |
| 25285 | 25285 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 25286 | 25286 | assert(!flags.ptr_cast); |
| 25287 | 25287 | const inst_src = block.nodeOffset(extra.src_node); |
| ... | ... | @@ -25296,7 +25296,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25296 | 25296 | } |
| 25297 | 25297 | const parent_ty = Type.fromInterned(parent_ptr_info.child); |
| 25298 | 25298 | switch (parent_ty.zigTypeTag(zcu)) { |
| 25299 | .Struct, .Union => {}, | |
| 25299 | .@"struct", .@"union" => {}, | |
| 25300 | 25300 | else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{}'", .{parent_ptr_ty.fmt(pt)}), |
| 25301 | 25301 | } |
| 25302 | 25302 | try parent_ty.resolveLayout(pt); |
| ... | ... | @@ -25305,7 +25305,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25305 | 25305 | .needed_comptime_reason = "field name must be comptime-known", |
| 25306 | 25306 | }); |
| 25307 | 25307 | const field_index = switch (parent_ty.zigTypeTag(zcu)) { |
| 25308 | .Struct => blk: { | |
| 25308 | .@"struct" => blk: { | |
| 25309 | 25309 | if (parent_ty.isTuple(zcu)) { |
| 25310 | 25310 | if (field_name.eqlSlice("len", ip)) { |
| 25311 | 25311 | return sema.fail(block, inst_src, "cannot get @fieldParentPtr of 'len' field of tuple", .{}); |
| ... | ... | @@ -25315,10 +25315,10 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25315 | 25315 | break :blk try sema.structFieldIndex(block, parent_ty, field_name, field_name_src); |
| 25316 | 25316 | } |
| 25317 | 25317 | }, |
| 25318 | .Union => try sema.unionFieldIndex(block, parent_ty, field_name, field_name_src), | |
| 25318 | .@"union" => try sema.unionFieldIndex(block, parent_ty, field_name, field_name_src), | |
| 25319 | 25319 | else => unreachable, |
| 25320 | 25320 | }; |
| 25321 | if (parent_ty.zigTypeTag(zcu) == .Struct and parent_ty.structFieldIsComptime(field_index, zcu)) { | |
| 25321 | if (parent_ty.zigTypeTag(zcu) == .@"struct" and parent_ty.structFieldIsComptime(field_index, zcu)) { | |
| 25322 | 25322 | return sema.fail(block, field_name_src, "cannot get @fieldParentPtr of a comptime field", .{}); |
| 25323 | 25323 | } |
| 25324 | 25324 | |
| ... | ... | @@ -25400,7 +25400,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25400 | 25400 | |
| 25401 | 25401 | const result = if (try sema.resolveDefinedValue(block, field_ptr_src, casted_field_ptr)) |field_ptr_val| result: { |
| 25402 | 25402 | switch (parent_ty.zigTypeTag(zcu)) { |
| 25403 | .Struct => switch (parent_ty.containerLayout(zcu)) { | |
| 25403 | .@"struct" => switch (parent_ty.containerLayout(zcu)) { | |
| 25404 | 25404 | .auto => {}, |
| 25405 | 25405 | .@"extern" => { |
| 25406 | 25406 | const byte_offset = parent_ty.structFieldOffset(field_index, zcu); |
| ... | ... | @@ -25417,7 +25417,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25417 | 25417 | break :result Air.internedToRef(parent_ptr_val.toIntern()); |
| 25418 | 25418 | }, |
| 25419 | 25419 | }, |
| 25420 | .Union => switch (parent_ty.containerLayout(zcu)) { | |
| 25420 | .@"union" => switch (parent_ty.containerLayout(zcu)) { | |
| 25421 | 25421 | .auto => {}, |
| 25422 | 25422 | .@"extern", .@"packed" => { |
| 25423 | 25423 | // For an extern or packed union, just coerce the pointer. |
| ... | ... | @@ -25914,7 +25914,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 25914 | 25914 | // lowering. The AIR instruction requires pointers with element types of |
| 25915 | 25915 | // equal ABI size. |
| 25916 | 25916 | |
| 25917 | if (dest_ty.zigTypeTag(zcu) != .Pointer or src_ty.zigTypeTag(zcu) != .Pointer) { | |
| 25917 | if (dest_ty.zigTypeTag(zcu) != .pointer or src_ty.zigTypeTag(zcu) != .pointer) { | |
| 25918 | 25918 | return sema.fail(block, src, "TODO: lower @memcpy to a for loop because the source or destination iterable is a tuple", .{}); |
| 25919 | 25919 | } |
| 25920 | 25920 | |
| ... | ... | @@ -26034,7 +26034,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 26034 | 26034 | switch (ptr_info.flags.size) { |
| 26035 | 26035 | .Slice => break :dest_elem_ty Type.fromInterned(ptr_info.child), |
| 26036 | 26036 | .One => { |
| 26037 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Array) { | |
| 26037 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { | |
| 26038 | 26038 | break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu); |
| 26039 | 26039 | } |
| 26040 | 26040 | }, |
| ... | ... | @@ -26533,7 +26533,7 @@ fn zirCDefine( |
| 26533 | 26533 | .needed_comptime_reason = "name of macro being undefined must be comptime-known", |
| 26534 | 26534 | }); |
| 26535 | 26535 | const rhs = try sema.resolveInst(extra.rhs); |
| 26536 | if (sema.typeOf(rhs).zigTypeTag(zcu) != .Void) { | |
| 26536 | if (sema.typeOf(rhs).zigTypeTag(zcu) != .void) { | |
| 26537 | 26537 | const value = try sema.resolveConstString(block, val_src, extra.rhs, .{ |
| 26538 | 26538 | .needed_comptime_reason = "value of macro being undefined must be comptime-known", |
| 26539 | 26539 | }); |
| ... | ... | @@ -26951,7 +26951,7 @@ fn validateVarType( |
| 26951 | 26951 | return sema.failWithOwnedErrorMsg(block, msg); |
| 26952 | 26952 | } |
| 26953 | 26953 | } else { |
| 26954 | if (var_ty.zigTypeTag(zcu) == .Opaque) { | |
| 26954 | if (var_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 26955 | 26955 | return sema.fail( |
| 26956 | 26956 | block, |
| 26957 | 26957 | src, |
| ... | ... | @@ -26968,7 +26968,7 @@ fn validateVarType( |
| 26968 | 26968 | errdefer msg.destroy(sema.gpa); |
| 26969 | 26969 | |
| 26970 | 26970 | try sema.explainWhyTypeIsComptime(msg, src, var_ty); |
| 26971 | if (var_ty.zigTypeTag(zcu) == .ComptimeInt or var_ty.zigTypeTag(zcu) == .ComptimeFloat) { | |
| 26971 | if (var_ty.zigTypeTag(zcu) == .comptime_int or var_ty.zigTypeTag(zcu) == .comptime_float) { | |
| 26972 | 26972 | try sema.errNote(src, msg, "to modify this variable at runtime, it must be given an explicit fixed-size number type", .{}); |
| 26973 | 26973 | } |
| 26974 | 26974 | |
| ... | ... | @@ -27003,42 +27003,42 @@ fn explainWhyTypeIsComptimeInner( |
| 27003 | 27003 | const zcu = pt.zcu; |
| 27004 | 27004 | const ip = &zcu.intern_pool; |
| 27005 | 27005 | switch (ty.zigTypeTag(zcu)) { |
| 27006 | .Bool, | |
| 27007 | .Int, | |
| 27008 | .Float, | |
| 27009 | .ErrorSet, | |
| 27010 | .Enum, | |
| 27011 | .Frame, | |
| 27012 | .AnyFrame, | |
| 27013 | .Void, | |
| 27006 | .bool, | |
| 27007 | .int, | |
| 27008 | .float, | |
| 27009 | .error_set, | |
| 27010 | .@"enum", | |
| 27011 | .frame, | |
| 27012 | .@"anyframe", | |
| 27013 | .void, | |
| 27014 | 27014 | => return, |
| 27015 | 27015 | |
| 27016 | .Fn => { | |
| 27016 | .@"fn" => { | |
| 27017 | 27017 | try sema.errNote(src_loc, msg, "use '*const {}' for a function pointer type", .{ty.fmt(pt)}); |
| 27018 | 27018 | }, |
| 27019 | 27019 | |
| 27020 | .Type => { | |
| 27020 | .type => { | |
| 27021 | 27021 | try sema.errNote(src_loc, msg, "types are not available at runtime", .{}); |
| 27022 | 27022 | }, |
| 27023 | 27023 | |
| 27024 | .ComptimeFloat, | |
| 27025 | .ComptimeInt, | |
| 27026 | .EnumLiteral, | |
| 27027 | .NoReturn, | |
| 27028 | .Undefined, | |
| 27029 | .Null, | |
| 27024 | .comptime_float, | |
| 27025 | .comptime_int, | |
| 27026 | .enum_literal, | |
| 27027 | .noreturn, | |
| 27028 | .undefined, | |
| 27029 | .null, | |
| 27030 | 27030 | => return, |
| 27031 | 27031 | |
| 27032 | .Opaque => { | |
| 27032 | .@"opaque" => { | |
| 27033 | 27033 | try sema.errNote(src_loc, msg, "opaque type '{}' has undefined size", .{ty.fmt(pt)}); |
| 27034 | 27034 | }, |
| 27035 | 27035 | |
| 27036 | .Array, .Vector => { | |
| 27036 | .array, .vector => { | |
| 27037 | 27037 | try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.childType(zcu), type_set); |
| 27038 | 27038 | }, |
| 27039 | .Pointer => { | |
| 27039 | .pointer => { | |
| 27040 | 27040 | const elem_ty = ty.elemType2(zcu); |
| 27041 | if (elem_ty.zigTypeTag(zcu) == .Fn) { | |
| 27041 | if (elem_ty.zigTypeTag(zcu) == .@"fn") { | |
| 27042 | 27042 | const fn_info = zcu.typeToFunc(elem_ty).?; |
| 27043 | 27043 | if (fn_info.is_generic) { |
| 27044 | 27044 | try sema.errNote(src_loc, msg, "function is generic", .{}); |
| ... | ... | @@ -27055,14 +27055,14 @@ fn explainWhyTypeIsComptimeInner( |
| 27055 | 27055 | try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.childType(zcu), type_set); |
| 27056 | 27056 | }, |
| 27057 | 27057 | |
| 27058 | .Optional => { | |
| 27058 | .optional => { | |
| 27059 | 27059 | try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.optionalChild(zcu), type_set); |
| 27060 | 27060 | }, |
| 27061 | .ErrorUnion => { | |
| 27061 | .error_union => { | |
| 27062 | 27062 | try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.errorUnionPayload(zcu), type_set); |
| 27063 | 27063 | }, |
| 27064 | 27064 | |
| 27065 | .Struct => { | |
| 27065 | .@"struct" => { | |
| 27066 | 27066 | if ((try type_set.getOrPut(sema.gpa, ty.toIntern())).found_existing) return; |
| 27067 | 27067 | |
| 27068 | 27068 | if (zcu.typeToStruct(ty)) |struct_type| { |
| ... | ... | @@ -27082,7 +27082,7 @@ fn explainWhyTypeIsComptimeInner( |
| 27082 | 27082 | // TODO tuples |
| 27083 | 27083 | }, |
| 27084 | 27084 | |
| 27085 | .Union => { | |
| 27085 | .@"union" => { | |
| 27086 | 27086 | if ((try type_set.getOrPut(sema.gpa, ty.toIntern())).found_existing) return; |
| 27087 | 27087 | |
| 27088 | 27088 | if (zcu.typeToUnion(ty)) |union_obj| { |
| ... | ... | @@ -27123,34 +27123,34 @@ fn validateExternType( |
| 27123 | 27123 | const pt = sema.pt; |
| 27124 | 27124 | const zcu = pt.zcu; |
| 27125 | 27125 | switch (ty.zigTypeTag(zcu)) { |
| 27126 | .Type, | |
| 27127 | .ComptimeFloat, | |
| 27128 | .ComptimeInt, | |
| 27129 | .EnumLiteral, | |
| 27130 | .Undefined, | |
| 27131 | .Null, | |
| 27132 | .ErrorUnion, | |
| 27133 | .ErrorSet, | |
| 27134 | .Frame, | |
| 27126 | .type, | |
| 27127 | .comptime_float, | |
| 27128 | .comptime_int, | |
| 27129 | .enum_literal, | |
| 27130 | .undefined, | |
| 27131 | .null, | |
| 27132 | .error_union, | |
| 27133 | .error_set, | |
| 27134 | .frame, | |
| 27135 | 27135 | => return false, |
| 27136 | .Void => return position == .union_field or position == .ret_ty or position == .struct_field or position == .element, | |
| 27137 | .NoReturn => return position == .ret_ty, | |
| 27138 | .Opaque, | |
| 27139 | .Bool, | |
| 27140 | .Float, | |
| 27141 | .AnyFrame, | |
| 27136 | .void => return position == .union_field or position == .ret_ty or position == .struct_field or position == .element, | |
| 27137 | .noreturn => return position == .ret_ty, | |
| 27138 | .@"opaque", | |
| 27139 | .bool, | |
| 27140 | .float, | |
| 27141 | .@"anyframe", | |
| 27142 | 27142 | => return true, |
| 27143 | .Pointer => { | |
| 27144 | if (ty.childType(zcu).zigTypeTag(zcu) == .Fn) { | |
| 27143 | .pointer => { | |
| 27144 | if (ty.childType(zcu).zigTypeTag(zcu) == .@"fn") { | |
| 27145 | 27145 | return ty.isConstPtr(zcu) and try sema.validateExternType(ty.childType(zcu), .other); |
| 27146 | 27146 | } |
| 27147 | 27147 | return !(ty.isSlice(zcu) or try ty.comptimeOnlySema(pt)); |
| 27148 | 27148 | }, |
| 27149 | .Int => switch (ty.intInfo(zcu).bits) { | |
| 27149 | .int => switch (ty.intInfo(zcu).bits) { | |
| 27150 | 27150 | 0, 8, 16, 32, 64, 128 => return true, |
| 27151 | 27151 | else => return false, |
| 27152 | 27152 | }, |
| 27153 | .Fn => { | |
| 27153 | .@"fn" => { | |
| 27154 | 27154 | if (position != .other) return false; |
| 27155 | 27155 | const target = zcu.getTarget(); |
| 27156 | 27156 | // For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI. |
| ... | ... | @@ -27160,10 +27160,10 @@ fn validateExternType( |
| 27160 | 27160 | } |
| 27161 | 27161 | return !target_util.fnCallConvAllowsZigTypes(target, ty.fnCallingConvention(zcu)); |
| 27162 | 27162 | }, |
| 27163 | .Enum => { | |
| 27163 | .@"enum" => { | |
| 27164 | 27164 | return sema.validateExternType(ty.intTagType(zcu), position); |
| 27165 | 27165 | }, |
| 27166 | .Struct, .Union => switch (ty.containerLayout(zcu)) { | |
| 27166 | .@"struct", .@"union" => switch (ty.containerLayout(zcu)) { | |
| 27167 | 27167 | .@"extern" => return true, |
| 27168 | 27168 | .@"packed" => { |
| 27169 | 27169 | const bit_size = try ty.bitSizeSema(pt); |
| ... | ... | @@ -27174,12 +27174,12 @@ fn validateExternType( |
| 27174 | 27174 | }, |
| 27175 | 27175 | .auto => return !(try ty.hasRuntimeBitsSema(pt)), |
| 27176 | 27176 | }, |
| 27177 | .Array => { | |
| 27177 | .array => { | |
| 27178 | 27178 | if (position == .ret_ty or position == .param_ty) return false; |
| 27179 | 27179 | return sema.validateExternType(ty.elemType2(zcu), .element); |
| 27180 | 27180 | }, |
| 27181 | .Vector => return sema.validateExternType(ty.elemType2(zcu), .element), | |
| 27182 | .Optional => return ty.isPtrLikeOptional(zcu), | |
| 27181 | .vector => return sema.validateExternType(ty.elemType2(zcu), .element), | |
| 27182 | .optional => return ty.isPtrLikeOptional(zcu), | |
| 27183 | 27183 | } |
| 27184 | 27184 | } |
| 27185 | 27185 | |
| ... | ... | @@ -27193,29 +27193,29 @@ fn explainWhyTypeIsNotExtern( |
| 27193 | 27193 | const pt = sema.pt; |
| 27194 | 27194 | const zcu = pt.zcu; |
| 27195 | 27195 | switch (ty.zigTypeTag(zcu)) { |
| 27196 | .Opaque, | |
| 27197 | .Bool, | |
| 27198 | .Float, | |
| 27199 | .AnyFrame, | |
| 27196 | .@"opaque", | |
| 27197 | .bool, | |
| 27198 | .float, | |
| 27199 | .@"anyframe", | |
| 27200 | 27200 | => return, |
| 27201 | 27201 | |
| 27202 | .Type, | |
| 27203 | .ComptimeFloat, | |
| 27204 | .ComptimeInt, | |
| 27205 | .EnumLiteral, | |
| 27206 | .Undefined, | |
| 27207 | .Null, | |
| 27208 | .ErrorUnion, | |
| 27209 | .ErrorSet, | |
| 27210 | .Frame, | |
| 27202 | .type, | |
| 27203 | .comptime_float, | |
| 27204 | .comptime_int, | |
| 27205 | .enum_literal, | |
| 27206 | .undefined, | |
| 27207 | .null, | |
| 27208 | .error_union, | |
| 27209 | .error_set, | |
| 27210 | .frame, | |
| 27211 | 27211 | => return, |
| 27212 | 27212 | |
| 27213 | .Pointer => { | |
| 27213 | .pointer => { | |
| 27214 | 27214 | if (ty.isSlice(zcu)) { |
| 27215 | 27215 | try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{}); |
| 27216 | 27216 | } else { |
| 27217 | 27217 | const pointee_ty = ty.childType(zcu); |
| 27218 | if (!ty.isConstPtr(zcu) and pointee_ty.zigTypeTag(zcu) == .Fn) { | |
| 27218 | if (!ty.isConstPtr(zcu) and pointee_ty.zigTypeTag(zcu) == .@"fn") { | |
| 27219 | 27219 | try sema.errNote(src_loc, msg, "pointer to extern function must be 'const'", .{}); |
| 27220 | 27220 | } else if (try ty.comptimeOnlySema(pt)) { |
| 27221 | 27221 | try sema.errNote(src_loc, msg, "pointer to comptime-only type '{}'", .{pointee_ty.fmt(pt)}); |
| ... | ... | @@ -27224,14 +27224,14 @@ fn explainWhyTypeIsNotExtern( |
| 27224 | 27224 | try sema.explainWhyTypeIsNotExtern(msg, src_loc, pointee_ty, .other); |
| 27225 | 27225 | } |
| 27226 | 27226 | }, |
| 27227 | .Void => try sema.errNote(src_loc, msg, "'void' is a zero bit type; for C 'void' use 'anyopaque'", .{}), | |
| 27228 | .NoReturn => try sema.errNote(src_loc, msg, "'noreturn' is only allowed as a return type", .{}), | |
| 27229 | .Int => if (!std.math.isPowerOfTwo(ty.intInfo(zcu).bits)) { | |
| 27227 | .void => try sema.errNote(src_loc, msg, "'void' is a zero bit type; for C 'void' use 'anyopaque'", .{}), | |
| 27228 | .noreturn => try sema.errNote(src_loc, msg, "'noreturn' is only allowed as a return type", .{}), | |
| 27229 | .int => if (!std.math.isPowerOfTwo(ty.intInfo(zcu).bits)) { | |
| 27230 | 27230 | try sema.errNote(src_loc, msg, "only integers with 0 or power of two bits are extern compatible", .{}); |
| 27231 | 27231 | } else { |
| 27232 | 27232 | try sema.errNote(src_loc, msg, "only integers with 0, 8, 16, 32, 64 and 128 bits are extern compatible", .{}); |
| 27233 | 27233 | }, |
| 27234 | .Fn => { | |
| 27234 | .@"fn" => { | |
| 27235 | 27235 | if (position != .other) { |
| 27236 | 27236 | try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{}); |
| 27237 | 27237 | try sema.errNote(src_loc, msg, "use '*const ' to make a function pointer type", .{}); |
| ... | ... | @@ -27244,14 +27244,14 @@ fn explainWhyTypeIsNotExtern( |
| 27244 | 27244 | else => return, |
| 27245 | 27245 | } |
| 27246 | 27246 | }, |
| 27247 | .Enum => { | |
| 27247 | .@"enum" => { | |
| 27248 | 27248 | const tag_ty = ty.intTagType(zcu); |
| 27249 | 27249 | try sema.errNote(src_loc, msg, "enum tag type '{}' is not extern compatible", .{tag_ty.fmt(pt)}); |
| 27250 | 27250 | try sema.explainWhyTypeIsNotExtern(msg, src_loc, tag_ty, position); |
| 27251 | 27251 | }, |
| 27252 | .Struct => try sema.errNote(src_loc, msg, "only extern structs and ABI sized packed structs are extern compatible", .{}), | |
| 27253 | .Union => try sema.errNote(src_loc, msg, "only extern unions and ABI sized packed unions are extern compatible", .{}), | |
| 27254 | .Array => { | |
| 27252 | .@"struct" => try sema.errNote(src_loc, msg, "only extern structs and ABI sized packed structs are extern compatible", .{}), | |
| 27253 | .@"union" => try sema.errNote(src_loc, msg, "only extern unions and ABI sized packed unions are extern compatible", .{}), | |
| 27254 | .array => { | |
| 27255 | 27255 | if (position == .ret_ty) { |
| 27256 | 27256 | return sema.errNote(src_loc, msg, "arrays are not allowed as a return type", .{}); |
| 27257 | 27257 | } else if (position == .param_ty) { |
| ... | ... | @@ -27259,8 +27259,8 @@ fn explainWhyTypeIsNotExtern( |
| 27259 | 27259 | } |
| 27260 | 27260 | try sema.explainWhyTypeIsNotExtern(msg, src_loc, ty.elemType2(zcu), .element); |
| 27261 | 27261 | }, |
| 27262 | .Vector => try sema.explainWhyTypeIsNotExtern(msg, src_loc, ty.elemType2(zcu), .element), | |
| 27263 | .Optional => try sema.errNote(src_loc, msg, "only pointer like optionals are extern compatible", .{}), | |
| 27262 | .vector => try sema.explainWhyTypeIsNotExtern(msg, src_loc, ty.elemType2(zcu), .element), | |
| 27263 | .optional => try sema.errNote(src_loc, msg, "only pointer like optionals are extern compatible", .{}), | |
| 27264 | 27264 | } |
| 27265 | 27265 | } |
| 27266 | 27266 | |
| ... | ... | @@ -27270,34 +27270,34 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool { |
| 27270 | 27270 | const pt = sema.pt; |
| 27271 | 27271 | const zcu = pt.zcu; |
| 27272 | 27272 | return switch (ty.zigTypeTag(zcu)) { |
| 27273 | .Type, | |
| 27274 | .ComptimeFloat, | |
| 27275 | .ComptimeInt, | |
| 27276 | .EnumLiteral, | |
| 27277 | .Undefined, | |
| 27278 | .Null, | |
| 27279 | .ErrorUnion, | |
| 27280 | .ErrorSet, | |
| 27281 | .Frame, | |
| 27282 | .NoReturn, | |
| 27283 | .Opaque, | |
| 27284 | .AnyFrame, | |
| 27285 | .Fn, | |
| 27286 | .Array, | |
| 27273 | .type, | |
| 27274 | .comptime_float, | |
| 27275 | .comptime_int, | |
| 27276 | .enum_literal, | |
| 27277 | .undefined, | |
| 27278 | .null, | |
| 27279 | .error_union, | |
| 27280 | .error_set, | |
| 27281 | .frame, | |
| 27282 | .noreturn, | |
| 27283 | .@"opaque", | |
| 27284 | .@"anyframe", | |
| 27285 | .@"fn", | |
| 27286 | .array, | |
| 27287 | 27287 | => false, |
| 27288 | .Optional => return ty.isPtrLikeOptional(zcu), | |
| 27289 | .Void, | |
| 27290 | .Bool, | |
| 27291 | .Float, | |
| 27292 | .Int, | |
| 27293 | .Vector, | |
| 27288 | .optional => return ty.isPtrLikeOptional(zcu), | |
| 27289 | .void, | |
| 27290 | .bool, | |
| 27291 | .float, | |
| 27292 | .int, | |
| 27293 | .vector, | |
| 27294 | 27294 | => true, |
| 27295 | .Enum => switch (zcu.intern_pool.loadEnumType(ty.toIntern()).tag_mode) { | |
| 27295 | .@"enum" => switch (zcu.intern_pool.loadEnumType(ty.toIntern()).tag_mode) { | |
| 27296 | 27296 | .auto => false, |
| 27297 | 27297 | .explicit, .nonexhaustive => true, |
| 27298 | 27298 | }, |
| 27299 | .Pointer => !ty.isSlice(zcu) and !try ty.comptimeOnlySema(pt), | |
| 27300 | .Struct, .Union => ty.containerLayout(zcu) == .@"packed", | |
| 27299 | .pointer => !ty.isSlice(zcu) and !try ty.comptimeOnlySema(pt), | |
| 27300 | .@"struct", .@"union" => ty.containerLayout(zcu) == .@"packed", | |
| 27301 | 27301 | }; |
| 27302 | 27302 | } |
| 27303 | 27303 | |
| ... | ... | @@ -27310,40 +27310,40 @@ fn explainWhyTypeIsNotPacked( |
| 27310 | 27310 | const pt = sema.pt; |
| 27311 | 27311 | const zcu = pt.zcu; |
| 27312 | 27312 | switch (ty.zigTypeTag(zcu)) { |
| 27313 | .Void, | |
| 27314 | .Bool, | |
| 27315 | .Float, | |
| 27316 | .Int, | |
| 27317 | .Vector, | |
| 27318 | .Enum, | |
| 27313 | .void, | |
| 27314 | .bool, | |
| 27315 | .float, | |
| 27316 | .int, | |
| 27317 | .vector, | |
| 27318 | .@"enum", | |
| 27319 | 27319 | => return, |
| 27320 | .Type, | |
| 27321 | .ComptimeFloat, | |
| 27322 | .ComptimeInt, | |
| 27323 | .EnumLiteral, | |
| 27324 | .Undefined, | |
| 27325 | .Null, | |
| 27326 | .Frame, | |
| 27327 | .NoReturn, | |
| 27328 | .Opaque, | |
| 27329 | .ErrorUnion, | |
| 27330 | .ErrorSet, | |
| 27331 | .AnyFrame, | |
| 27332 | .Optional, | |
| 27333 | .Array, | |
| 27320 | .type, | |
| 27321 | .comptime_float, | |
| 27322 | .comptime_int, | |
| 27323 | .enum_literal, | |
| 27324 | .undefined, | |
| 27325 | .null, | |
| 27326 | .frame, | |
| 27327 | .noreturn, | |
| 27328 | .@"opaque", | |
| 27329 | .error_union, | |
| 27330 | .error_set, | |
| 27331 | .@"anyframe", | |
| 27332 | .optional, | |
| 27333 | .array, | |
| 27334 | 27334 | => try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{}), |
| 27335 | .Pointer => if (ty.isSlice(zcu)) { | |
| 27335 | .pointer => if (ty.isSlice(zcu)) { | |
| 27336 | 27336 | try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{}); |
| 27337 | 27337 | } else { |
| 27338 | 27338 | try sema.errNote(src_loc, msg, "comptime-only pointer has no guaranteed in-memory representation", .{}); |
| 27339 | 27339 | try sema.explainWhyTypeIsComptime(msg, src_loc, ty); |
| 27340 | 27340 | }, |
| 27341 | .Fn => { | |
| 27341 | .@"fn" => { | |
| 27342 | 27342 | try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{}); |
| 27343 | 27343 | try sema.errNote(src_loc, msg, "use '*const ' to make a function pointer type", .{}); |
| 27344 | 27344 | }, |
| 27345 | .Struct => try sema.errNote(src_loc, msg, "only packed structs layout are allowed in packed types", .{}), | |
| 27346 | .Union => try sema.errNote(src_loc, msg, "only packed unions layout are allowed in packed types", .{}), | |
| 27345 | .@"struct" => try sema.errNote(src_loc, msg, "only packed structs layout are allowed in packed types", .{}), | |
| 27346 | .@"union" => try sema.errNote(src_loc, msg, "only packed unions layout are allowed in packed types", .{}), | |
| 27347 | 27347 | } |
| 27348 | 27348 | } |
| 27349 | 27349 | |
| ... | ... | @@ -27356,7 +27356,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 27356 | 27356 | const fn_val = try sema.resolveConstValue(block, src, fn_ref, .{ |
| 27357 | 27357 | .needed_comptime_reason = "panic handler must be comptime-known", |
| 27358 | 27358 | }); |
| 27359 | assert(fn_val.typeOf(zcu).zigTypeTag(zcu) == .Fn); | |
| 27359 | assert(fn_val.typeOf(zcu).zigTypeTag(zcu) == .@"fn"); | |
| 27360 | 27360 | assert(try fn_val.typeOf(zcu).fnHasRuntimeBitsSema(pt)); |
| 27361 | 27361 | try zcu.ensureFuncBodyAnalysisQueued(fn_val.toIntern()); |
| 27362 | 27362 | zcu.panic_func_index = fn_val.toIntern(); |
| ... | ... | @@ -27444,9 +27444,9 @@ fn addSafetyCheckExtra( |
| 27444 | 27444 | |
| 27445 | 27445 | try parent_block.instructions.ensureUnusedCapacity(gpa, 1); |
| 27446 | 27446 | |
| 27447 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + | |
| 27447 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len + | |
| 27448 | 27448 | 1 + // The main block only needs space for the cond_br. |
| 27449 | @typeInfo(Air.CondBr).Struct.fields.len + | |
| 27449 | @typeInfo(Air.CondBr).@"struct".fields.len + | |
| 27450 | 27450 | 1 + // The ok branch of the cond_br only needs space for the br. |
| 27451 | 27451 | fail_block.instructions.items.len); |
| 27452 | 27452 | |
| ... | ... | @@ -27614,7 +27614,7 @@ fn panicSentinelMismatch( |
| 27614 | 27614 | break :blk try parent_block.addTyOp(.load, sentinel_ty, sentinel_ptr); |
| 27615 | 27615 | }; |
| 27616 | 27616 | |
| 27617 | const ok = if (sentinel_ty.zigTypeTag(zcu) == .Vector) ok: { | |
| 27617 | const ok = if (sentinel_ty.zigTypeTag(zcu) == .vector) ok: { | |
| 27618 | 27618 | const eql = |
| 27619 | 27619 | try parent_block.addCmpVector(expected_sentinel, actual_sentinel, .eq); |
| 27620 | 27620 | break :ok try parent_block.addInst(.{ |
| ... | ... | @@ -27727,7 +27727,7 @@ fn fieldVal( |
| 27727 | 27727 | object_ty; |
| 27728 | 27728 | |
| 27729 | 27729 | switch (inner_ty.zigTypeTag(zcu)) { |
| 27730 | .Array => { | |
| 27730 | .array => { | |
| 27731 | 27731 | if (field_name.eqlSlice("len", ip)) { |
| 27732 | 27732 | return Air.internedToRef((try pt.intValue(Type.usize, inner_ty.arrayLen(zcu))).toIntern()); |
| 27733 | 27733 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { |
| ... | ... | @@ -27756,7 +27756,7 @@ fn fieldVal( |
| 27756 | 27756 | ); |
| 27757 | 27757 | } |
| 27758 | 27758 | }, |
| 27759 | .Pointer => { | |
| 27759 | .pointer => { | |
| 27760 | 27760 | const ptr_info = inner_ty.ptrInfo(zcu); |
| 27761 | 27761 | if (ptr_info.flags.size == .Slice) { |
| 27762 | 27762 | if (field_name.eqlSlice("ptr", ip)) { |
| ... | ... | @@ -27781,7 +27781,7 @@ fn fieldVal( |
| 27781 | 27781 | } |
| 27782 | 27782 | } |
| 27783 | 27783 | }, |
| 27784 | .Type => { | |
| 27784 | .type => { | |
| 27785 | 27785 | const dereffed_type = if (is_pointer_to) |
| 27786 | 27786 | try sema.analyzeLoad(block, src, object, object_src) |
| 27787 | 27787 | else |
| ... | ... | @@ -27791,7 +27791,7 @@ fn fieldVal( |
| 27791 | 27791 | const child_type = val.toType(); |
| 27792 | 27792 | |
| 27793 | 27793 | switch (try child_type.zigTypeTagOrPoison(zcu)) { |
| 27794 | .ErrorSet => { | |
| 27794 | .error_set => { | |
| 27795 | 27795 | switch (ip.indexToKey(child_type.toIntern())) { |
| 27796 | 27796 | .error_set_type => |error_set_type| blk: { |
| 27797 | 27797 | if (error_set_type.nameIndex(ip, field_name) != null) break :blk; |
| ... | ... | @@ -27818,7 +27818,7 @@ fn fieldVal( |
| 27818 | 27818 | .name = field_name, |
| 27819 | 27819 | } }))); |
| 27820 | 27820 | }, |
| 27821 | .Union => { | |
| 27821 | .@"union" => { | |
| 27822 | 27822 | if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| { |
| 27823 | 27823 | return inst; |
| 27824 | 27824 | } |
| ... | ... | @@ -27831,7 +27831,7 @@ fn fieldVal( |
| 27831 | 27831 | } |
| 27832 | 27832 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 27833 | 27833 | }, |
| 27834 | .Enum => { | |
| 27834 | .@"enum" => { | |
| 27835 | 27835 | if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| { |
| 27836 | 27836 | return inst; |
| 27837 | 27837 | } |
| ... | ... | @@ -27841,7 +27841,7 @@ fn fieldVal( |
| 27841 | 27841 | const enum_val = try pt.enumValueFieldIndex(child_type, field_index); |
| 27842 | 27842 | return Air.internedToRef(enum_val.toIntern()); |
| 27843 | 27843 | }, |
| 27844 | .Struct, .Opaque => { | |
| 27844 | .@"struct", .@"opaque" => { | |
| 27845 | 27845 | switch (child_type.toIntern()) { |
| 27846 | 27846 | .empty_struct_type, .anyopaque_type => {}, // no namespace |
| 27847 | 27847 | else => if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| { |
| ... | ... | @@ -27854,19 +27854,19 @@ fn fieldVal( |
| 27854 | 27854 | const msg = try sema.errMsg(src, "type '{}' has no members", .{child_type.fmt(pt)}); |
| 27855 | 27855 | errdefer msg.destroy(sema.gpa); |
| 27856 | 27856 | if (child_type.isSlice(zcu)) try sema.errNote(src, msg, "slice values have 'len' and 'ptr' members", .{}); |
| 27857 | if (child_type.zigTypeTag(zcu) == .Array) try sema.errNote(src, msg, "array values have 'len' member", .{}); | |
| 27857 | if (child_type.zigTypeTag(zcu) == .array) try sema.errNote(src, msg, "array values have 'len' member", .{}); | |
| 27858 | 27858 | break :msg msg; |
| 27859 | 27859 | }), |
| 27860 | 27860 | } |
| 27861 | 27861 | }, |
| 27862 | .Struct => if (is_pointer_to) { | |
| 27862 | .@"struct" => if (is_pointer_to) { | |
| 27863 | 27863 | // Avoid loading the entire struct by fetching a pointer and loading that |
| 27864 | 27864 | const field_ptr = try sema.structFieldPtr(block, src, object, field_name, field_name_src, inner_ty, false); |
| 27865 | 27865 | return sema.analyzeLoad(block, src, field_ptr, object_src); |
| 27866 | 27866 | } else { |
| 27867 | 27867 | return sema.structFieldVal(block, src, object, field_name, field_name_src, inner_ty); |
| 27868 | 27868 | }, |
| 27869 | .Union => if (is_pointer_to) { | |
| 27869 | .@"union" => if (is_pointer_to) { | |
| 27870 | 27870 | // Avoid loading the entire union by fetching a pointer and loading that |
| 27871 | 27871 | const field_ptr = try sema.unionFieldPtr(block, src, object, field_name, field_name_src, inner_ty, false); |
| 27872 | 27872 | return sema.analyzeLoad(block, src, field_ptr, object_src); |
| ... | ... | @@ -27896,7 +27896,7 @@ fn fieldPtr( |
| 27896 | 27896 | const object_ptr_src = src; // TODO better source location |
| 27897 | 27897 | const object_ptr_ty = sema.typeOf(object_ptr); |
| 27898 | 27898 | const object_ty = switch (object_ptr_ty.zigTypeTag(zcu)) { |
| 27899 | .Pointer => object_ptr_ty.childType(zcu), | |
| 27899 | .pointer => object_ptr_ty.childType(zcu), | |
| 27900 | 27900 | else => return sema.fail(block, object_ptr_src, "expected pointer, found '{}'", .{object_ptr_ty.fmt(pt)}), |
| 27901 | 27901 | }; |
| 27902 | 27902 | |
| ... | ... | @@ -27911,7 +27911,7 @@ fn fieldPtr( |
| 27911 | 27911 | object_ty; |
| 27912 | 27912 | |
| 27913 | 27913 | switch (inner_ty.zigTypeTag(zcu)) { |
| 27914 | .Array => { | |
| 27914 | .array => { | |
| 27915 | 27915 | if (field_name.eqlSlice("len", ip)) { |
| 27916 | 27916 | const int_val = try pt.intValue(Type.usize, inner_ty.arrayLen(zcu)); |
| 27917 | 27917 | return uavRef(sema, int_val.toIntern()); |
| ... | ... | @@ -27955,7 +27955,7 @@ fn fieldPtr( |
| 27955 | 27955 | ); |
| 27956 | 27956 | } |
| 27957 | 27957 | }, |
| 27958 | .Pointer => if (inner_ty.isSlice(zcu)) { | |
| 27958 | .pointer => if (inner_ty.isSlice(zcu)) { | |
| 27959 | 27959 | const inner_ptr = if (is_pointer_to) |
| 27960 | 27960 | try sema.analyzeLoad(block, src, object_ptr, object_ptr_src) |
| 27961 | 27961 | else |
| ... | ... | @@ -28010,7 +28010,7 @@ fn fieldPtr( |
| 28010 | 28010 | ); |
| 28011 | 28011 | } |
| 28012 | 28012 | }, |
| 28013 | .Type => { | |
| 28013 | .type => { | |
| 28014 | 28014 | _ = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, object_ptr, undefined); |
| 28015 | 28015 | const result = try sema.analyzeLoad(block, src, object_ptr, object_ptr_src); |
| 28016 | 28016 | const inner = if (is_pointer_to) |
| ... | ... | @@ -28022,7 +28022,7 @@ fn fieldPtr( |
| 28022 | 28022 | const child_type = val.toType(); |
| 28023 | 28023 | |
| 28024 | 28024 | switch (child_type.zigTypeTag(zcu)) { |
| 28025 | .ErrorSet => { | |
| 28025 | .error_set => { | |
| 28026 | 28026 | switch (ip.indexToKey(child_type.toIntern())) { |
| 28027 | 28027 | .error_set_type => |error_set_type| blk: { |
| 28028 | 28028 | if (error_set_type.nameIndex(ip, field_name) != null) { |
| ... | ... | @@ -28051,7 +28051,7 @@ fn fieldPtr( |
| 28051 | 28051 | .name = field_name, |
| 28052 | 28052 | } })); |
| 28053 | 28053 | }, |
| 28054 | .Union => { | |
| 28054 | .@"union" => { | |
| 28055 | 28055 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| { |
| 28056 | 28056 | return inst; |
| 28057 | 28057 | } |
| ... | ... | @@ -28065,7 +28065,7 @@ fn fieldPtr( |
| 28065 | 28065 | } |
| 28066 | 28066 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 28067 | 28067 | }, |
| 28068 | .Enum => { | |
| 28068 | .@"enum" => { | |
| 28069 | 28069 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| { |
| 28070 | 28070 | return inst; |
| 28071 | 28071 | } |
| ... | ... | @@ -28076,7 +28076,7 @@ fn fieldPtr( |
| 28076 | 28076 | const idx_val = try pt.enumValueFieldIndex(child_type, field_index_u32); |
| 28077 | 28077 | return uavRef(sema, idx_val.toIntern()); |
| 28078 | 28078 | }, |
| 28079 | .Struct, .Opaque => { | |
| 28079 | .@"struct", .@"opaque" => { | |
| 28080 | 28080 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| { |
| 28081 | 28081 | return inst; |
| 28082 | 28082 | } |
| ... | ... | @@ -28085,7 +28085,7 @@ fn fieldPtr( |
| 28085 | 28085 | else => return sema.fail(block, src, "type '{}' has no members", .{child_type.fmt(pt)}), |
| 28086 | 28086 | } |
| 28087 | 28087 | }, |
| 28088 | .Struct => { | |
| 28088 | .@"struct" => { | |
| 28089 | 28089 | const inner_ptr = if (is_pointer_to) |
| 28090 | 28090 | try sema.analyzeLoad(block, src, object_ptr, object_ptr_src) |
| 28091 | 28091 | else |
| ... | ... | @@ -28094,7 +28094,7 @@ fn fieldPtr( |
| 28094 | 28094 | try sema.checkKnownAllocPtr(block, inner_ptr, field_ptr); |
| 28095 | 28095 | return field_ptr; |
| 28096 | 28096 | }, |
| 28097 | .Union => { | |
| 28097 | .@"union" => { | |
| 28098 | 28098 | const inner_ptr = if (is_pointer_to) |
| 28099 | 28099 | try sema.analyzeLoad(block, src, object_ptr, object_ptr_src) |
| 28100 | 28100 | else |
| ... | ... | @@ -28134,13 +28134,13 @@ fn fieldCallBind( |
| 28134 | 28134 | const ip = &zcu.intern_pool; |
| 28135 | 28135 | const raw_ptr_src = src; // TODO better source location |
| 28136 | 28136 | const raw_ptr_ty = sema.typeOf(raw_ptr); |
| 28137 | const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .Pointer and (raw_ptr_ty.ptrSize(zcu) == .One or raw_ptr_ty.ptrSize(zcu) == .C)) | |
| 28137 | const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .One or raw_ptr_ty.ptrSize(zcu) == .C)) | |
| 28138 | 28138 | raw_ptr_ty.childType(zcu) |
| 28139 | 28139 | else |
| 28140 | 28140 | return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)}); |
| 28141 | 28141 | |
| 28142 | 28142 | // Optionally dereference a second pointer to get the concrete type. |
| 28143 | const is_double_ptr = inner_ty.zigTypeTag(zcu) == .Pointer and inner_ty.ptrSize(zcu) == .One; | |
| 28143 | const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .One; | |
| 28144 | 28144 | const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty; |
| 28145 | 28145 | const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty; |
| 28146 | 28146 | const object_ptr = if (is_double_ptr) |
| ... | ... | @@ -28150,7 +28150,7 @@ fn fieldCallBind( |
| 28150 | 28150 | |
| 28151 | 28151 | find_field: { |
| 28152 | 28152 | switch (concrete_ty.zigTypeTag(zcu)) { |
| 28153 | .Struct => { | |
| 28153 | .@"struct" => { | |
| 28154 | 28154 | try concrete_ty.resolveFields(pt); |
| 28155 | 28155 | if (zcu.typeToStruct(concrete_ty)) |struct_type| { |
| 28156 | 28156 | const field_index = struct_type.nameIndex(ip, field_name) orelse |
| ... | ... | @@ -28176,14 +28176,14 @@ fn fieldCallBind( |
| 28176 | 28176 | } |
| 28177 | 28177 | } |
| 28178 | 28178 | }, |
| 28179 | .Union => { | |
| 28179 | .@"union" => { | |
| 28180 | 28180 | try concrete_ty.resolveFields(pt); |
| 28181 | 28181 | const union_obj = zcu.typeToUnion(concrete_ty).?; |
| 28182 | 28182 | _ = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse break :find_field; |
| 28183 | 28183 | const field_ptr = try unionFieldPtr(sema, block, src, object_ptr, field_name, field_name_src, concrete_ty, false); |
| 28184 | 28184 | return .{ .direct = try sema.analyzeLoad(block, src, field_ptr, src) }; |
| 28185 | 28185 | }, |
| 28186 | .Type => { | |
| 28186 | .type => { | |
| 28187 | 28187 | const namespace = try sema.analyzeLoad(block, src, object_ptr, src); |
| 28188 | 28188 | return .{ .direct = try sema.fieldVal(block, src, namespace, field_name, field_name_src) }; |
| 28189 | 28189 | }, |
| ... | ... | @@ -28205,7 +28205,7 @@ fn fieldCallBind( |
| 28205 | 28205 | |
| 28206 | 28206 | const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]); |
| 28207 | 28207 | if (first_param_type.isGenericPoison() or |
| 28208 | (first_param_type.zigTypeTag(zcu) == .Pointer and | |
| 28208 | (first_param_type.zigTypeTag(zcu) == .pointer and | |
| 28209 | 28209 | (first_param_type.ptrSize(zcu) == .One or |
| 28210 | 28210 | first_param_type.ptrSize(zcu) == .C) and |
| 28211 | 28211 | first_param_type.childType(zcu).eql(concrete_ty, zcu))) |
| ... | ... | @@ -28225,7 +28225,7 @@ fn fieldCallBind( |
| 28225 | 28225 | .func_inst = decl_val, |
| 28226 | 28226 | .arg0_inst = deref, |
| 28227 | 28227 | } }; |
| 28228 | } else if (first_param_type.zigTypeTag(zcu) == .Optional) { | |
| 28228 | } else if (first_param_type.zigTypeTag(zcu) == .optional) { | |
| 28229 | 28229 | const child = first_param_type.optionalChild(zcu); |
| 28230 | 28230 | if (child.eql(concrete_ty, zcu)) { |
| 28231 | 28231 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); |
| ... | ... | @@ -28233,7 +28233,7 @@ fn fieldCallBind( |
| 28233 | 28233 | .func_inst = decl_val, |
| 28234 | 28234 | .arg0_inst = deref, |
| 28235 | 28235 | } }; |
| 28236 | } else if (child.zigTypeTag(zcu) == .Pointer and | |
| 28236 | } else if (child.zigTypeTag(zcu) == .pointer and | |
| 28237 | 28237 | child.ptrSize(zcu) == .One and |
| 28238 | 28238 | child.childType(zcu).eql(concrete_ty, zcu)) |
| 28239 | 28239 | { |
| ... | ... | @@ -28242,7 +28242,7 @@ fn fieldCallBind( |
| 28242 | 28242 | .arg0_inst = object_ptr, |
| 28243 | 28243 | } }; |
| 28244 | 28244 | } |
| 28245 | } else if (first_param_type.zigTypeTag(zcu) == .ErrorUnion and | |
| 28245 | } else if (first_param_type.zigTypeTag(zcu) == .error_union and | |
| 28246 | 28246 | first_param_type.errorUnionPayload(zcu).eql(concrete_ty, zcu)) |
| 28247 | 28247 | { |
| 28248 | 28248 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); |
| ... | ... | @@ -28270,7 +28270,7 @@ fn fieldCallBind( |
| 28270 | 28270 | .{field_name.fmt(ip)}, |
| 28271 | 28271 | ); |
| 28272 | 28272 | } |
| 28273 | if (concrete_ty.zigTypeTag(zcu) == .ErrorUnion) { | |
| 28273 | if (concrete_ty.zigTypeTag(zcu) == .error_union) { | |
| 28274 | 28274 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| 28275 | 28275 | } |
| 28276 | 28276 | if (is_double_ptr) { |
| ... | ... | @@ -28302,7 +28302,7 @@ fn finishFieldCallBind( |
| 28302 | 28302 | }); |
| 28303 | 28303 | |
| 28304 | 28304 | const container_ty = ptr_ty.childType(zcu); |
| 28305 | if (container_ty.zigTypeTag(zcu) == .Struct) { | |
| 28305 | if (container_ty.zigTypeTag(zcu) == .@"struct") { | |
| 28306 | 28306 | if (container_ty.structFieldIsComptime(field_index, zcu)) { |
| 28307 | 28307 | try container_ty.resolveStructFieldInits(pt); |
| 28308 | 28308 | const default_val = (try container_ty.structFieldValueComptime(pt, field_index)).?; |
| ... | ... | @@ -28382,7 +28382,7 @@ fn structFieldPtr( |
| 28382 | 28382 | const pt = sema.pt; |
| 28383 | 28383 | const zcu = pt.zcu; |
| 28384 | 28384 | const ip = &zcu.intern_pool; |
| 28385 | assert(struct_ty.zigTypeTag(zcu) == .Struct); | |
| 28385 | assert(struct_ty.zigTypeTag(zcu) == .@"struct"); | |
| 28386 | 28386 | |
| 28387 | 28387 | try struct_ty.resolveFields(pt); |
| 28388 | 28388 | try struct_ty.resolveLayout(pt); |
| ... | ... | @@ -28508,7 +28508,7 @@ fn structFieldVal( |
| 28508 | 28508 | const pt = sema.pt; |
| 28509 | 28509 | const zcu = pt.zcu; |
| 28510 | 28510 | const ip = &zcu.intern_pool; |
| 28511 | assert(struct_ty.zigTypeTag(zcu) == .Struct); | |
| 28511 | assert(struct_ty.zigTypeTag(zcu) == .@"struct"); | |
| 28512 | 28512 | |
| 28513 | 28513 | try struct_ty.resolveFields(pt); |
| 28514 | 28514 | |
| ... | ... | @@ -28646,7 +28646,7 @@ fn unionFieldPtr( |
| 28646 | 28646 | const zcu = pt.zcu; |
| 28647 | 28647 | const ip = &zcu.intern_pool; |
| 28648 | 28648 | |
| 28649 | assert(union_ty.zigTypeTag(zcu) == .Union); | |
| 28649 | assert(union_ty.zigTypeTag(zcu) == .@"union"); | |
| 28650 | 28650 | |
| 28651 | 28651 | const union_ptr_ty = sema.typeOf(union_ptr); |
| 28652 | 28652 | const union_ptr_info = union_ptr_ty.ptrInfo(zcu); |
| ... | ... | @@ -28673,7 +28673,7 @@ fn unionFieldPtr( |
| 28673 | 28673 | }); |
| 28674 | 28674 | const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_ty).enumFieldIndex(field_name, zcu).?); |
| 28675 | 28675 | |
| 28676 | if (initializing and field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 28676 | if (initializing and field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 28677 | 28677 | const msg = msg: { |
| 28678 | 28678 | const msg = try sema.errMsg(src, "cannot initialize 'noreturn' field of union", .{}); |
| 28679 | 28679 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -28736,7 +28736,7 @@ fn unionFieldPtr( |
| 28736 | 28736 | const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_val); |
| 28737 | 28737 | try sema.panicInactiveUnionField(block, src, active_tag, wanted_tag); |
| 28738 | 28738 | } |
| 28739 | if (field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 28739 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 28740 | 28740 | _ = try block.addNoOp(.unreach); |
| 28741 | 28741 | return .unreachable_value; |
| 28742 | 28742 | } |
| ... | ... | @@ -28755,7 +28755,7 @@ fn unionFieldVal( |
| 28755 | 28755 | const pt = sema.pt; |
| 28756 | 28756 | const zcu = pt.zcu; |
| 28757 | 28757 | const ip = &zcu.intern_pool; |
| 28758 | assert(union_ty.zigTypeTag(zcu) == .Union); | |
| 28758 | assert(union_ty.zigTypeTag(zcu) == .@"union"); | |
| 28759 | 28759 | |
| 28760 | 28760 | try union_ty.resolveFields(pt); |
| 28761 | 28761 | const union_obj = zcu.typeToUnion(union_ty).?; |
| ... | ... | @@ -28811,7 +28811,7 @@ fn unionFieldVal( |
| 28811 | 28811 | const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_byval); |
| 28812 | 28812 | try sema.panicInactiveUnionField(block, src, active_tag, wanted_tag); |
| 28813 | 28813 | } |
| 28814 | if (field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 28814 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 28815 | 28815 | _ = try block.addNoOp(.unreach); |
| 28816 | 28816 | return .unreachable_value; |
| 28817 | 28817 | } |
| ... | ... | @@ -28835,14 +28835,14 @@ fn elemPtr( |
| 28835 | 28835 | const indexable_ptr_ty = sema.typeOf(indexable_ptr); |
| 28836 | 28836 | |
| 28837 | 28837 | const indexable_ty = switch (indexable_ptr_ty.zigTypeTag(zcu)) { |
| 28838 | .Pointer => indexable_ptr_ty.childType(zcu), | |
| 28838 | .pointer => indexable_ptr_ty.childType(zcu), | |
| 28839 | 28839 | else => return sema.fail(block, indexable_ptr_src, "expected pointer, found '{}'", .{indexable_ptr_ty.fmt(pt)}), |
| 28840 | 28840 | }; |
| 28841 | 28841 | try checkIndexable(sema, block, src, indexable_ty); |
| 28842 | 28842 | |
| 28843 | 28843 | const elem_ptr = switch (indexable_ty.zigTypeTag(zcu)) { |
| 28844 | .Array, .Vector => try sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init, oob_safety), | |
| 28845 | .Struct => blk: { | |
| 28844 | .array, .vector => try sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init, oob_safety), | |
| 28845 | .@"struct" => blk: { | |
| 28846 | 28846 | // Tuple field access. |
| 28847 | 28847 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 28848 | 28848 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| ... | ... | @@ -28898,8 +28898,8 @@ fn elemPtrOneLayerOnly( |
| 28898 | 28898 | .One => { |
| 28899 | 28899 | const child_ty = indexable_ty.childType(zcu); |
| 28900 | 28900 | const elem_ptr = switch (child_ty.zigTypeTag(zcu)) { |
| 28901 | .Array, .Vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety), | |
| 28902 | .Struct => blk: { | |
| 28901 | .array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety), | |
| 28902 | .@"struct" => blk: { | |
| 28903 | 28903 | assert(child_ty.isTuple(zcu)); |
| 28904 | 28904 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 28905 | 28905 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| ... | ... | @@ -28936,7 +28936,7 @@ fn elemVal( |
| 28936 | 28936 | const elem_index = try sema.coerce(block, Type.usize, elem_index_uncasted, elem_index_src); |
| 28937 | 28937 | |
| 28938 | 28938 | switch (indexable_ty.zigTypeTag(zcu)) { |
| 28939 | .Pointer => switch (indexable_ty.ptrSize(zcu)) { | |
| 28939 | .pointer => switch (indexable_ty.ptrSize(zcu)) { | |
| 28940 | 28940 | .Slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety), |
| 28941 | 28941 | .Many, .C => { |
| 28942 | 28942 | const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable); |
| ... | ... | @@ -28963,7 +28963,7 @@ fn elemVal( |
| 28963 | 28963 | .One => { |
| 28964 | 28964 | arr_sent: { |
| 28965 | 28965 | const inner_ty = indexable_ty.childType(zcu); |
| 28966 | if (inner_ty.zigTypeTag(zcu) != .Array) break :arr_sent; | |
| 28966 | if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent; | |
| 28967 | 28967 | const sentinel = inner_ty.sentinel(zcu) orelse break :arr_sent; |
| 28968 | 28968 | const index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index) orelse break :arr_sent; |
| 28969 | 28969 | const index = try sema.usizeCast(block, src, try index_val.toUnsignedIntSema(pt)); |
| ... | ... | @@ -28974,12 +28974,12 @@ fn elemVal( |
| 28974 | 28974 | return sema.analyzeLoad(block, indexable_src, elem_ptr, elem_index_src); |
| 28975 | 28975 | }, |
| 28976 | 28976 | }, |
| 28977 | .Array => return sema.elemValArray(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety), | |
| 28978 | .Vector => { | |
| 28977 | .array => return sema.elemValArray(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety), | |
| 28978 | .vector => { | |
| 28979 | 28979 | // TODO: If the index is a vector, the result should be a vector. |
| 28980 | 28980 | return sema.elemValArray(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety); |
| 28981 | 28981 | }, |
| 28982 | .Struct => { | |
| 28982 | .@"struct" => { | |
| 28983 | 28983 | // Tuple field access. |
| 28984 | 28984 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 28985 | 28985 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| ... | ... | @@ -29448,7 +29448,7 @@ fn coerceExtra( |
| 29448 | 29448 | } |
| 29449 | 29449 | |
| 29450 | 29450 | switch (dest_ty.zigTypeTag(zcu)) { |
| 29451 | .Optional => optional: { | |
| 29451 | .optional => optional: { | |
| 29452 | 29452 | if (maybe_inst_val) |val| { |
| 29453 | 29453 | // undefined sets the optional bit also to undefined. |
| 29454 | 29454 | if (val.toIntern() == .undef) { |
| ... | ... | @@ -29472,7 +29472,7 @@ fn coerceExtra( |
| 29472 | 29472 | anyopaque_check: { |
| 29473 | 29473 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :optional; |
| 29474 | 29474 | const elem_ty = inst_ty.elemType2(zcu); |
| 29475 | if (elem_ty.zigTypeTag(zcu) == .Pointer or elem_ty.isPtrLikeOptional(zcu)) { | |
| 29475 | if (elem_ty.zigTypeTag(zcu) == .pointer or elem_ty.isPtrLikeOptional(zcu)) { | |
| 29476 | 29476 | in_memory_result = .{ .double_ptr_to_anyopaque = .{ |
| 29477 | 29477 | .actual = inst_ty, |
| 29478 | 29478 | .wanted = dest_ty, |
| ... | ... | @@ -29499,11 +29499,11 @@ fn coerceExtra( |
| 29499 | 29499 | }; |
| 29500 | 29500 | return try sema.wrapOptional(block, dest_ty, intermediate, inst_src); |
| 29501 | 29501 | }, |
| 29502 | .Pointer => pointer: { | |
| 29502 | .pointer => pointer: { | |
| 29503 | 29503 | const dest_info = dest_ty.ptrInfo(zcu); |
| 29504 | 29504 | |
| 29505 | 29505 | // Function body to function pointer. |
| 29506 | if (inst_ty.zigTypeTag(zcu) == .Fn) { | |
| 29506 | if (inst_ty.zigTypeTag(zcu) == .@"fn") { | |
| 29507 | 29507 | const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined); |
| 29508 | 29508 | const fn_nav = switch (zcu.intern_pool.indexToKey(fn_val.toIntern())) { |
| 29509 | 29509 | .func => |f| f.owner_nav, |
| ... | ... | @@ -29521,7 +29521,7 @@ fn coerceExtra( |
| 29521 | 29521 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 29522 | 29522 | const ptr_elem_ty = inst_ty.childType(zcu); |
| 29523 | 29523 | const array_ty = Type.fromInterned(dest_info.child); |
| 29524 | if (array_ty.zigTypeTag(zcu) != .Array) break :single_item; | |
| 29524 | if (array_ty.zigTypeTag(zcu) != .array) break :single_item; | |
| 29525 | 29525 | const array_elem_ty = array_ty.childType(zcu); |
| 29526 | 29526 | if (array_ty.arrayLen(zcu) != 1) break :single_item; |
| 29527 | 29527 | const dest_is_mut = !dest_info.flags.is_const; |
| ... | ... | @@ -29537,7 +29537,7 @@ fn coerceExtra( |
| 29537 | 29537 | if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr; |
| 29538 | 29538 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 29539 | 29539 | const array_ty = inst_ty.childType(zcu); |
| 29540 | if (array_ty.zigTypeTag(zcu) != .Array) break :src_array_ptr; | |
| 29540 | if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr; | |
| 29541 | 29541 | const array_elem_type = array_ty.childType(zcu); |
| 29542 | 29542 | const dest_is_mut = !dest_info.flags.is_const; |
| 29543 | 29543 | |
| ... | ... | @@ -29612,10 +29612,10 @@ fn coerceExtra( |
| 29612 | 29612 | |
| 29613 | 29613 | // cast from *T and [*]T to *anyopaque |
| 29614 | 29614 | // but don't do it if the source type is a double pointer |
| 29615 | if (dest_info.child == .anyopaque_type and inst_ty.zigTypeTag(zcu) == .Pointer) to_anyopaque: { | |
| 29615 | if (dest_info.child == .anyopaque_type and inst_ty.zigTypeTag(zcu) == .pointer) to_anyopaque: { | |
| 29616 | 29616 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 29617 | 29617 | const elem_ty = inst_ty.elemType2(zcu); |
| 29618 | if (elem_ty.zigTypeTag(zcu) == .Pointer or elem_ty.isPtrLikeOptional(zcu)) { | |
| 29618 | if (elem_ty.zigTypeTag(zcu) == .pointer or elem_ty.isPtrLikeOptional(zcu)) { | |
| 29619 | 29619 | in_memory_result = .{ .double_ptr_to_anyopaque = .{ |
| 29620 | 29620 | .actual = inst_ty, |
| 29621 | 29621 | .wanted = dest_ty, |
| ... | ... | @@ -29636,19 +29636,19 @@ fn coerceExtra( |
| 29636 | 29636 | switch (dest_info.flags.size) { |
| 29637 | 29637 | // coercion to C pointer |
| 29638 | 29638 | .C => switch (inst_ty.zigTypeTag(zcu)) { |
| 29639 | .Null => return Air.internedToRef(try pt.intern(.{ .ptr = .{ | |
| 29639 | .null => return Air.internedToRef(try pt.intern(.{ .ptr = .{ | |
| 29640 | 29640 | .ty = dest_ty.toIntern(), |
| 29641 | 29641 | .base_addr = .int, |
| 29642 | 29642 | .byte_offset = 0, |
| 29643 | 29643 | } })), |
| 29644 | .ComptimeInt => { | |
| 29644 | .comptime_int => { | |
| 29645 | 29645 | const addr = sema.coerceExtra(block, Type.usize, inst, inst_src, .{ .report_err = false }) catch |err| switch (err) { |
| 29646 | 29646 | error.NotCoercible => break :pointer, |
| 29647 | 29647 | else => |e| return e, |
| 29648 | 29648 | }; |
| 29649 | 29649 | return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src); |
| 29650 | 29650 | }, |
| 29651 | .Int => { | |
| 29651 | .int => { | |
| 29652 | 29652 | const ptr_size_ty = switch (inst_ty.intInfo(zcu).signedness) { |
| 29653 | 29653 | .signed => Type.isize, |
| 29654 | 29654 | .unsigned => Type.usize, |
| ... | ... | @@ -29663,7 +29663,7 @@ fn coerceExtra( |
| 29663 | 29663 | }; |
| 29664 | 29664 | return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src); |
| 29665 | 29665 | }, |
| 29666 | .Pointer => p: { | |
| 29666 | .pointer => p: { | |
| 29667 | 29667 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p; |
| 29668 | 29668 | const inst_info = inst_ty.ptrInfo(zcu); |
| 29669 | 29669 | switch (try sema.coerceInMemoryAllowed( |
| ... | ... | @@ -29693,7 +29693,7 @@ fn coerceExtra( |
| 29693 | 29693 | else => {}, |
| 29694 | 29694 | }, |
| 29695 | 29695 | .One => switch (Type.fromInterned(dest_info.child).zigTypeTag(zcu)) { |
| 29696 | .Union => { | |
| 29696 | .@"union" => { | |
| 29697 | 29697 | // pointer to anonymous struct to pointer to union |
| 29698 | 29698 | if (inst_ty.isSinglePointer(zcu) and |
| 29699 | 29699 | inst_ty.childType(zcu).isAnonStruct(zcu) and |
| ... | ... | @@ -29702,7 +29702,7 @@ fn coerceExtra( |
| 29702 | 29702 | return sema.coerceAnonStructToUnionPtrs(block, dest_ty, dest_ty_src, inst, inst_src); |
| 29703 | 29703 | } |
| 29704 | 29704 | }, |
| 29705 | .Struct => { | |
| 29705 | .@"struct" => { | |
| 29706 | 29706 | // pointer to anonymous struct to pointer to struct |
| 29707 | 29707 | if (inst_ty.isSinglePointer(zcu) and |
| 29708 | 29708 | inst_ty.childType(zcu).isAnonStruct(zcu) and |
| ... | ... | @@ -29714,7 +29714,7 @@ fn coerceExtra( |
| 29714 | 29714 | }; |
| 29715 | 29715 | } |
| 29716 | 29716 | }, |
| 29717 | .Array => { | |
| 29717 | .array => { | |
| 29718 | 29718 | // pointer to tuple to pointer to array |
| 29719 | 29719 | if (inst_ty.isSinglePointer(zcu) and |
| 29720 | 29720 | inst_ty.childType(zcu).isTuple(zcu) and |
| ... | ... | @@ -29726,7 +29726,7 @@ fn coerceExtra( |
| 29726 | 29726 | else => {}, |
| 29727 | 29727 | }, |
| 29728 | 29728 | .Slice => to_slice: { |
| 29729 | if (inst_ty.zigTypeTag(zcu) == .Array) { | |
| 29729 | if (inst_ty.zigTypeTag(zcu) == .array) { | |
| 29730 | 29730 | return sema.fail( |
| 29731 | 29731 | block, |
| 29732 | 29732 | inst_src, |
| ... | ... | @@ -29795,10 +29795,10 @@ fn coerceExtra( |
| 29795 | 29795 | }, |
| 29796 | 29796 | } |
| 29797 | 29797 | }, |
| 29798 | .Int, .ComptimeInt => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29799 | .Float, .ComptimeFloat => float: { | |
| 29798 | .int, .comptime_int => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29799 | .float, .comptime_float => float: { | |
| 29800 | 29800 | const val = maybe_inst_val orelse { |
| 29801 | if (dest_ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 29801 | if (dest_ty.zigTypeTag(zcu) == .comptime_int) { | |
| 29802 | 29802 | if (!opts.report_err) return error.NotCoercible; |
| 29803 | 29803 | return sema.failWithNeededComptime(block, inst_src, .{ |
| 29804 | 29804 | .needed_comptime_reason = "value being casted to 'comptime_int' must be comptime-known", |
| ... | ... | @@ -29809,7 +29809,7 @@ fn coerceExtra( |
| 29809 | 29809 | const result_val = try sema.intFromFloat(block, inst_src, val, inst_ty, dest_ty, .exact); |
| 29810 | 29810 | return Air.internedToRef(result_val.toIntern()); |
| 29811 | 29811 | }, |
| 29812 | .Int, .ComptimeInt => { | |
| 29812 | .int, .comptime_int => { | |
| 29813 | 29813 | if (maybe_inst_val) |val| { |
| 29814 | 29814 | // comptime-known integer to other number |
| 29815 | 29815 | if (!(try sema.intFitsInType(val, dest_ty, null))) { |
| ... | ... | @@ -29824,7 +29824,7 @@ fn coerceExtra( |
| 29824 | 29824 | else => unreachable, |
| 29825 | 29825 | }; |
| 29826 | 29826 | } |
| 29827 | if (dest_ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 29827 | if (dest_ty.zigTypeTag(zcu) == .comptime_int) { | |
| 29828 | 29828 | if (!opts.report_err) return error.NotCoercible; |
| 29829 | 29829 | if (opts.no_cast_to_comptime_int) return inst; |
| 29830 | 29830 | return sema.failWithNeededComptime(block, inst_src, .{ |
| ... | ... | @@ -29845,13 +29845,13 @@ fn coerceExtra( |
| 29845 | 29845 | }, |
| 29846 | 29846 | else => {}, |
| 29847 | 29847 | }, |
| 29848 | .Float, .ComptimeFloat => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29849 | .ComptimeFloat => { | |
| 29848 | .float, .comptime_float => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29849 | .comptime_float => { | |
| 29850 | 29850 | const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined); |
| 29851 | 29851 | const result_val = try val.floatCast(dest_ty, pt); |
| 29852 | 29852 | return Air.internedToRef(result_val.toIntern()); |
| 29853 | 29853 | }, |
| 29854 | .Float => { | |
| 29854 | .float => { | |
| 29855 | 29855 | if (maybe_inst_val) |val| { |
| 29856 | 29856 | const result_val = try val.floatCast(dest_ty, pt); |
| 29857 | 29857 | if (!val.eql(try result_val.floatCast(inst_ty, pt), inst_ty, zcu)) { |
| ... | ... | @@ -29863,7 +29863,7 @@ fn coerceExtra( |
| 29863 | 29863 | ); |
| 29864 | 29864 | } |
| 29865 | 29865 | return Air.internedToRef(result_val.toIntern()); |
| 29866 | } else if (dest_ty.zigTypeTag(zcu) == .ComptimeFloat) { | |
| 29866 | } else if (dest_ty.zigTypeTag(zcu) == .comptime_float) { | |
| 29867 | 29867 | if (!opts.report_err) return error.NotCoercible; |
| 29868 | 29868 | return sema.failWithNeededComptime(block, inst_src, .{ |
| 29869 | 29869 | .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known", |
| ... | ... | @@ -29878,9 +29878,9 @@ fn coerceExtra( |
| 29878 | 29878 | return block.addTyOp(.fpext, dest_ty, inst); |
| 29879 | 29879 | } |
| 29880 | 29880 | }, |
| 29881 | .Int, .ComptimeInt => int: { | |
| 29881 | .int, .comptime_int => int: { | |
| 29882 | 29882 | const val = maybe_inst_val orelse { |
| 29883 | if (dest_ty.zigTypeTag(zcu) == .ComptimeFloat) { | |
| 29883 | if (dest_ty.zigTypeTag(zcu) == .comptime_float) { | |
| 29884 | 29884 | if (!opts.report_err) return error.NotCoercible; |
| 29885 | 29885 | return sema.failWithNeededComptime(block, inst_src, .{ |
| 29886 | 29886 | .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known", |
| ... | ... | @@ -29903,8 +29903,8 @@ fn coerceExtra( |
| 29903 | 29903 | }, |
| 29904 | 29904 | else => {}, |
| 29905 | 29905 | }, |
| 29906 | .Enum => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29907 | .EnumLiteral => { | |
| 29906 | .@"enum" => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29907 | .enum_literal => { | |
| 29908 | 29908 | // enum literal to enum |
| 29909 | 29909 | const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined); |
| 29910 | 29910 | const string = zcu.intern_pool.indexToKey(val.toIntern()).enum_literal; |
| ... | ... | @@ -29915,7 +29915,7 @@ fn coerceExtra( |
| 29915 | 29915 | }; |
| 29916 | 29916 | return Air.internedToRef((try pt.enumValueFieldIndex(dest_ty, @intCast(field_index))).toIntern()); |
| 29917 | 29917 | }, |
| 29918 | .Union => blk: { | |
| 29918 | .@"union" => blk: { | |
| 29919 | 29919 | // union to its own tag type |
| 29920 | 29920 | const union_tag_ty = inst_ty.unionTagType(zcu) orelse break :blk; |
| 29921 | 29921 | if (union_tag_ty.eql(dest_ty, zcu)) { |
| ... | ... | @@ -29924,8 +29924,8 @@ fn coerceExtra( |
| 29924 | 29924 | }, |
| 29925 | 29925 | else => {}, |
| 29926 | 29926 | }, |
| 29927 | .ErrorUnion => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29928 | .ErrorUnion => eu: { | |
| 29927 | .error_union => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29928 | .error_union => eu: { | |
| 29929 | 29929 | if (maybe_inst_val) |inst_val| { |
| 29930 | 29930 | switch (inst_val.toIntern()) { |
| 29931 | 29931 | .undef => return pt.undefRef(dest_ty), |
| ... | ... | @@ -29952,7 +29952,7 @@ fn coerceExtra( |
| 29952 | 29952 | } |
| 29953 | 29953 | } |
| 29954 | 29954 | }, |
| 29955 | .ErrorSet => { | |
| 29955 | .error_set => { | |
| 29956 | 29956 | // E to E!T |
| 29957 | 29957 | return sema.wrapErrorUnionSet(block, dest_ty, inst, inst_src); |
| 29958 | 29958 | }, |
| ... | ... | @@ -29971,17 +29971,17 @@ fn coerceExtra( |
| 29971 | 29971 | }; |
| 29972 | 29972 | }, |
| 29973 | 29973 | }, |
| 29974 | .Union => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29975 | .Enum, .EnumLiteral => return sema.coerceEnumToUnion(block, dest_ty, dest_ty_src, inst, inst_src), | |
| 29976 | .Struct => { | |
| 29974 | .@"union" => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29975 | .@"enum", .enum_literal => return sema.coerceEnumToUnion(block, dest_ty, dest_ty_src, inst, inst_src), | |
| 29976 | .@"struct" => { | |
| 29977 | 29977 | if (inst_ty.isAnonStruct(zcu)) { |
| 29978 | 29978 | return sema.coerceAnonStructToUnion(block, dest_ty, dest_ty_src, inst, inst_src); |
| 29979 | 29979 | } |
| 29980 | 29980 | }, |
| 29981 | 29981 | else => {}, |
| 29982 | 29982 | }, |
| 29983 | .Array => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29984 | .Array => array_to_array: { | |
| 29983 | .array => switch (inst_ty.zigTypeTag(zcu)) { | |
| 29984 | .array => array_to_array: { | |
| 29985 | 29985 | // Array coercions are allowed only if the child is IMC and the sentinel is unchanged or removed. |
| 29986 | 29986 | if (.ok != try sema.coerceInMemoryAllowed( |
| 29987 | 29987 | block, |
| ... | ... | @@ -30005,8 +30005,8 @@ fn coerceExtra( |
| 30005 | 30005 | |
| 30006 | 30006 | return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src); |
| 30007 | 30007 | }, |
| 30008 | .Vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src), | |
| 30009 | .Struct => { | |
| 30008 | .vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src), | |
| 30009 | .@"struct" => { | |
| 30010 | 30010 | if (inst == .empty_struct) { |
| 30011 | 30011 | return sema.arrayInitEmpty(block, inst_src, dest_ty); |
| 30012 | 30012 | } |
| ... | ... | @@ -30016,16 +30016,16 @@ fn coerceExtra( |
| 30016 | 30016 | }, |
| 30017 | 30017 | else => {}, |
| 30018 | 30018 | }, |
| 30019 | .Vector => switch (inst_ty.zigTypeTag(zcu)) { | |
| 30020 | .Array, .Vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src), | |
| 30021 | .Struct => { | |
| 30019 | .vector => switch (inst_ty.zigTypeTag(zcu)) { | |
| 30020 | .array, .vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src), | |
| 30021 | .@"struct" => { | |
| 30022 | 30022 | if (inst_ty.isTuple(zcu)) { |
| 30023 | 30023 | return sema.coerceTupleToArray(block, dest_ty, dest_ty_src, inst, inst_src); |
| 30024 | 30024 | } |
| 30025 | 30025 | }, |
| 30026 | 30026 | else => {}, |
| 30027 | 30027 | }, |
| 30028 | .Struct => blk: { | |
| 30028 | .@"struct" => blk: { | |
| 30029 | 30029 | if (inst == .empty_struct) { |
| 30030 | 30030 | return sema.structInitEmpty(block, dest_ty, dest_ty_src, inst_src); |
| 30031 | 30031 | } |
| ... | ... | @@ -30046,7 +30046,7 @@ fn coerceExtra( |
| 30046 | 30046 | |
| 30047 | 30047 | if (!opts.report_err) return error.NotCoercible; |
| 30048 | 30048 | |
| 30049 | if (opts.is_ret and dest_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 30049 | if (opts.is_ret and dest_ty.zigTypeTag(zcu) == .noreturn) { | |
| 30050 | 30050 | const msg = msg: { |
| 30051 | 30051 | const msg = try sema.errMsg(inst_src, "function declared 'noreturn' returns", .{}); |
| 30052 | 30052 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -30066,7 +30066,7 @@ fn coerceExtra( |
| 30066 | 30066 | errdefer msg.destroy(sema.gpa); |
| 30067 | 30067 | |
| 30068 | 30068 | // E!T to T |
| 30069 | if (inst_ty.zigTypeTag(zcu) == .ErrorUnion and | |
| 30069 | if (inst_ty.zigTypeTag(zcu) == .error_union and | |
| 30070 | 30070 | (try sema.coerceInMemoryAllowed(block, inst_ty.errorUnionPayload(zcu), dest_ty, false, target, dest_ty_src, inst_src, maybe_inst_val)) == .ok) |
| 30071 | 30071 | { |
| 30072 | 30072 | try sema.errNote(inst_src, msg, "cannot convert error union to payload type", .{}); |
| ... | ... | @@ -30074,7 +30074,7 @@ fn coerceExtra( |
| 30074 | 30074 | } |
| 30075 | 30075 | |
| 30076 | 30076 | // ?T to T |
| 30077 | if (inst_ty.zigTypeTag(zcu) == .Optional and | |
| 30077 | if (inst_ty.zigTypeTag(zcu) == .optional and | |
| 30078 | 30078 | (try sema.coerceInMemoryAllowed(block, inst_ty.optionalChild(zcu), dest_ty, false, target, dest_ty_src, inst_src, maybe_inst_val)) == .ok) |
| 30079 | 30079 | { |
| 30080 | 30080 | try sema.errNote(inst_src, msg, "cannot convert optional to payload type", .{}); |
| ... | ... | @@ -30515,7 +30515,7 @@ pub fn coerceInMemoryAllowed( |
| 30515 | 30515 | const src_tag = src_ty.zigTypeTag(zcu); |
| 30516 | 30516 | |
| 30517 | 30517 | // Differently-named integers with the same number of bits. |
| 30518 | if (dest_tag == .Int and src_tag == .Int) { | |
| 30518 | if (dest_tag == .int and src_tag == .int) { | |
| 30519 | 30519 | const dest_info = dest_ty.intInfo(zcu); |
| 30520 | 30520 | const src_info = src_ty.intInfo(zcu); |
| 30521 | 30521 | |
| ... | ... | @@ -30540,7 +30540,7 @@ pub fn coerceInMemoryAllowed( |
| 30540 | 30540 | } |
| 30541 | 30541 | |
| 30542 | 30542 | // Comptime int to regular int. |
| 30543 | if (dest_tag == .Int and src_tag == .ComptimeInt) { | |
| 30543 | if (dest_tag == .int and src_tag == .comptime_int) { | |
| 30544 | 30544 | if (src_val) |val| { |
| 30545 | 30545 | if (!(try sema.intFitsInType(val, dest_ty, null))) { |
| 30546 | 30546 | return .{ .comptime_int_not_coercible = .{ .wanted = dest_ty, .actual = val } }; |
| ... | ... | @@ -30549,7 +30549,7 @@ pub fn coerceInMemoryAllowed( |
| 30549 | 30549 | } |
| 30550 | 30550 | |
| 30551 | 30551 | // Differently-named floats with the same number of bits. |
| 30552 | if (dest_tag == .Float and src_tag == .Float) { | |
| 30552 | if (dest_tag == .float and src_tag == .float) { | |
| 30553 | 30553 | const dest_bits = dest_ty.floatBits(target); |
| 30554 | 30554 | const src_bits = src_ty.floatBits(target); |
| 30555 | 30555 | if (dest_bits == src_bits) { |
| ... | ... | @@ -30572,12 +30572,12 @@ pub fn coerceInMemoryAllowed( |
| 30572 | 30572 | } |
| 30573 | 30573 | |
| 30574 | 30574 | // Functions |
| 30575 | if (dest_tag == .Fn and src_tag == .Fn) { | |
| 30575 | if (dest_tag == .@"fn" and src_tag == .@"fn") { | |
| 30576 | 30576 | return try sema.coerceInMemoryAllowedFns(block, dest_ty, src_ty, target, dest_src, src_src); |
| 30577 | 30577 | } |
| 30578 | 30578 | |
| 30579 | 30579 | // Error Unions |
| 30580 | if (dest_tag == .ErrorUnion and src_tag == .ErrorUnion) { | |
| 30580 | if (dest_tag == .error_union and src_tag == .error_union) { | |
| 30581 | 30581 | const dest_payload = dest_ty.errorUnionPayload(zcu); |
| 30582 | 30582 | const src_payload = src_ty.errorUnionPayload(zcu); |
| 30583 | 30583 | const child = try sema.coerceInMemoryAllowed(block, dest_payload, src_payload, dest_is_mut, target, dest_src, src_src, null); |
| ... | ... | @@ -30592,12 +30592,12 @@ pub fn coerceInMemoryAllowed( |
| 30592 | 30592 | } |
| 30593 | 30593 | |
| 30594 | 30594 | // Error Sets |
| 30595 | if (dest_tag == .ErrorSet and src_tag == .ErrorSet) { | |
| 30595 | if (dest_tag == .error_set and src_tag == .error_set) { | |
| 30596 | 30596 | return try sema.coerceInMemoryAllowedErrorSets(block, dest_ty, src_ty, dest_src, src_src); |
| 30597 | 30597 | } |
| 30598 | 30598 | |
| 30599 | 30599 | // Arrays |
| 30600 | if (dest_tag == .Array and src_tag == .Array) { | |
| 30600 | if (dest_tag == .array and src_tag == .array) { | |
| 30601 | 30601 | const dest_info = dest_ty.arrayInfo(zcu); |
| 30602 | 30602 | const src_info = src_ty.arrayInfo(zcu); |
| 30603 | 30603 | if (dest_info.len != src_info.len) { |
| ... | ... | @@ -30638,7 +30638,7 @@ pub fn coerceInMemoryAllowed( |
| 30638 | 30638 | } |
| 30639 | 30639 | |
| 30640 | 30640 | // Vectors |
| 30641 | if (dest_tag == .Vector and src_tag == .Vector) { | |
| 30641 | if (dest_tag == .vector and src_tag == .vector) { | |
| 30642 | 30642 | const dest_len = dest_ty.vectorLen(zcu); |
| 30643 | 30643 | const src_len = src_ty.vectorLen(zcu); |
| 30644 | 30644 | if (dest_len != src_len) { |
| ... | ... | @@ -30663,8 +30663,8 @@ pub fn coerceInMemoryAllowed( |
| 30663 | 30663 | } |
| 30664 | 30664 | |
| 30665 | 30665 | // Arrays <-> Vectors |
| 30666 | if ((dest_tag == .Vector and src_tag == .Array) or | |
| 30667 | (dest_tag == .Array and src_tag == .Vector)) | |
| 30666 | if ((dest_tag == .vector and src_tag == .array) or | |
| 30667 | (dest_tag == .array and src_tag == .vector)) | |
| 30668 | 30668 | { |
| 30669 | 30669 | const dest_len = dest_ty.arrayLen(zcu); |
| 30670 | 30670 | const src_len = src_ty.arrayLen(zcu); |
| ... | ... | @@ -30686,7 +30686,7 @@ pub fn coerceInMemoryAllowed( |
| 30686 | 30686 | } }; |
| 30687 | 30687 | } |
| 30688 | 30688 | |
| 30689 | if (dest_tag == .Array) { | |
| 30689 | if (dest_tag == .array) { | |
| 30690 | 30690 | const dest_info = dest_ty.arrayInfo(zcu); |
| 30691 | 30691 | if (dest_info.sentinel != null) { |
| 30692 | 30692 | return InMemoryCoercionResult{ .array_sentinel = .{ |
| ... | ... | @@ -30707,7 +30707,7 @@ pub fn coerceInMemoryAllowed( |
| 30707 | 30707 | } |
| 30708 | 30708 | |
| 30709 | 30709 | // Optionals |
| 30710 | if (dest_tag == .Optional and src_tag == .Optional) { | |
| 30710 | if (dest_tag == .optional and src_tag == .optional) { | |
| 30711 | 30711 | if ((maybe_dest_ptr_ty != null) != (maybe_src_ptr_ty != null)) { |
| 30712 | 30712 | return InMemoryCoercionResult{ .optional_shape = .{ |
| 30713 | 30713 | .actual = src_ty, |
| ... | ... | @@ -31000,7 +31000,7 @@ fn coerceInMemoryAllowedPtrs( |
| 31000 | 31000 | if (child != .ok) allow: { |
| 31001 | 31001 | // As a special case, we also allow coercing `*[n:s]T` to `*[n]T`, akin to dropping the sentinel from a slice. |
| 31002 | 31002 | // `*[n:s]T` cannot coerce in memory to `*[n]T` since they have different sizes. |
| 31003 | if (src_child.zigTypeTag(zcu) == .Array and dest_child.zigTypeTag(zcu) == .Array and | |
| 31003 | if (src_child.zigTypeTag(zcu) == .array and dest_child.zigTypeTag(zcu) == .array and | |
| 31004 | 31004 | src_child.sentinel(zcu) != null and dest_child.sentinel(zcu) == null and |
| 31005 | 31005 | .ok == try sema.coerceInMemoryAllowed(block, dest_child.childType(zcu), src_child.childType(zcu), !dest_info.flags.is_const, target, dest_src, src_src, null)) |
| 31006 | 31006 | { |
| ... | ... | @@ -31095,19 +31095,19 @@ fn coerceVarArgParam( |
| 31095 | 31095 | const uncasted_ty = sema.typeOf(inst); |
| 31096 | 31096 | const coerced = switch (uncasted_ty.zigTypeTag(zcu)) { |
| 31097 | 31097 | // TODO consider casting to c_int/f64 if they fit |
| 31098 | .ComptimeInt, .ComptimeFloat => return sema.fail( | |
| 31098 | .comptime_int, .comptime_float => return sema.fail( | |
| 31099 | 31099 | block, |
| 31100 | 31100 | inst_src, |
| 31101 | 31101 | "integer and float literals passed to variadic function must be casted to a fixed-size number type", |
| 31102 | 31102 | .{}, |
| 31103 | 31103 | ), |
| 31104 | .Fn => fn_ptr: { | |
| 31104 | .@"fn" => fn_ptr: { | |
| 31105 | 31105 | const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined); |
| 31106 | 31106 | const fn_nav = zcu.funcInfo(fn_val.toIntern()).owner_nav; |
| 31107 | 31107 | break :fn_ptr try sema.analyzeNavRef(inst_src, fn_nav); |
| 31108 | 31108 | }, |
| 31109 | .Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), | |
| 31110 | .Float => float: { | |
| 31109 | .array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), | |
| 31110 | .float => float: { | |
| 31111 | 31111 | const target = zcu.getTarget(); |
| 31112 | 31112 | const double_bits = target.cTypeBitSize(.double); |
| 31113 | 31113 | const inst_bits = uncasted_ty.floatBits(target); |
| ... | ... | @@ -31202,7 +31202,7 @@ fn storePtr2( |
| 31202 | 31202 | // this code does not handle tuple-to-struct coercion which requires dealing with missing |
| 31203 | 31203 | // fields. |
| 31204 | 31204 | const operand_ty = sema.typeOf(uncasted_operand); |
| 31205 | if (operand_ty.isTuple(zcu) and elem_ty.zigTypeTag(zcu) == .Array) { | |
| 31205 | if (operand_ty.isTuple(zcu) and elem_ty.zigTypeTag(zcu) == .array) { | |
| 31206 | 31206 | const field_count = operand_ty.structFieldCount(zcu); |
| 31207 | 31207 | var i: u32 = 0; |
| 31208 | 31208 | while (i < field_count) : (i += 1) { |
| ... | ... | @@ -31397,16 +31397,16 @@ fn obtainBitCastedVectorPtr(sema: *Sema, ptr: Air.Inst.Ref) ?Air.Inst.Ref { |
| 31397 | 31397 | const pt = sema.pt; |
| 31398 | 31398 | const zcu = pt.zcu; |
| 31399 | 31399 | const array_ty = sema.typeOf(ptr).childType(zcu); |
| 31400 | if (array_ty.zigTypeTag(zcu) != .Array) return null; | |
| 31400 | if (array_ty.zigTypeTag(zcu) != .array) return null; | |
| 31401 | 31401 | var ptr_ref = ptr; |
| 31402 | 31402 | var ptr_inst = ptr_ref.toIndex() orelse return null; |
| 31403 | 31403 | const air_datas = sema.air_instructions.items(.data); |
| 31404 | 31404 | const air_tags = sema.air_instructions.items(.tag); |
| 31405 | 31405 | const vector_ty = while (air_tags[@intFromEnum(ptr_inst)] == .bitcast) { |
| 31406 | 31406 | ptr_ref = air_datas[@intFromEnum(ptr_inst)].ty_op.operand; |
| 31407 | if (!sema.isKnownZigType(ptr_ref, .Pointer)) return null; | |
| 31407 | if (!sema.isKnownZigType(ptr_ref, .pointer)) return null; | |
| 31408 | 31408 | const child_ty = sema.typeOf(ptr_ref).childType(zcu); |
| 31409 | if (child_ty.zigTypeTag(zcu) == .Vector) break child_ty; | |
| 31409 | if (child_ty.zigTypeTag(zcu) == .vector) break child_ty; | |
| 31410 | 31410 | ptr_inst = ptr_ref.toIndex() orelse return null; |
| 31411 | 31411 | } else return null; |
| 31412 | 31412 | |
| ... | ... | @@ -31504,7 +31504,7 @@ fn bitCast( |
| 31504 | 31504 | if (try sema.resolveValue(inst)) |val| { |
| 31505 | 31505 | if (val.isUndef(zcu)) |
| 31506 | 31506 | return pt.undefRef(dest_ty); |
| 31507 | if (old_ty.zigTypeTag(zcu) == .ErrorSet and dest_ty.zigTypeTag(zcu) == .ErrorSet) { | |
| 31507 | if (old_ty.zigTypeTag(zcu) == .error_set and dest_ty.zigTypeTag(zcu) == .error_set) { | |
| 31508 | 31508 | // Special case: we sometimes call `bitCast` on error set values, but they |
| 31509 | 31509 | // don't have a well-defined layout, so we can't use `bitCastVal` on them. |
| 31510 | 31510 | return Air.internedToRef((try pt.getCoerced(val, dest_ty)).toIntern()); |
| ... | ... | @@ -31548,7 +31548,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul |
| 31548 | 31548 | const zcu = pt.zcu; |
| 31549 | 31549 | const dest_info = dest_ty.ptrInfo(zcu); |
| 31550 | 31550 | const inst_info = inst_ty.ptrInfo(zcu); |
| 31551 | const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .Array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or | |
| 31551 | const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or | |
| 31552 | 31552 | (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .C and dest_info.flags.size != .Many))) or |
| 31553 | 31553 | (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0); |
| 31554 | 31554 | |
| ... | ... | @@ -31615,9 +31615,9 @@ fn coerceCompatiblePtrs( |
| 31615 | 31615 | ); |
| 31616 | 31616 | } |
| 31617 | 31617 | try sema.requireRuntimeBlock(block, inst_src, null); |
| 31618 | const inst_allows_zero = inst_ty.zigTypeTag(zcu) != .Pointer or inst_ty.ptrAllowsZero(zcu); | |
| 31618 | const inst_allows_zero = inst_ty.zigTypeTag(zcu) != .pointer or inst_ty.ptrAllowsZero(zcu); | |
| 31619 | 31619 | if (block.wantSafety() and inst_allows_zero and !dest_ty.ptrAllowsZero(zcu) and |
| 31620 | (try dest_ty.elemType2(zcu).hasRuntimeBitsSema(pt) or dest_ty.elemType2(zcu).zigTypeTag(zcu) == .Fn)) | |
| 31620 | (try dest_ty.elemType2(zcu).hasRuntimeBitsSema(pt) or dest_ty.elemType2(zcu).zigTypeTag(zcu) == .@"fn")) | |
| 31621 | 31621 | { |
| 31622 | 31622 | const actual_ptr = if (inst_ty.isSlice(zcu)) |
| 31623 | 31623 | try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty) |
| ... | ... | @@ -31674,7 +31674,7 @@ fn coerceEnumToUnion( |
| 31674 | 31674 | const union_obj = zcu.typeToUnion(union_ty).?; |
| 31675 | 31675 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 31676 | 31676 | try field_ty.resolveFields(pt); |
| 31677 | if (field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 31677 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 31678 | 31678 | const msg = msg: { |
| 31679 | 31679 | const msg = try sema.errMsg(inst_src, "cannot initialize 'noreturn' field of union", .{}); |
| 31680 | 31680 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -31729,7 +31729,7 @@ fn coerceEnumToUnion( |
| 31729 | 31729 | errdefer if (msg) |some| some.destroy(sema.gpa); |
| 31730 | 31730 | |
| 31731 | 31731 | for (union_obj.field_types.get(ip), 0..) |field_ty, field_index| { |
| 31732 | if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .NoReturn) { | |
| 31732 | if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .noreturn) { | |
| 31733 | 31733 | const err_msg = msg orelse try sema.errMsg( |
| 31734 | 31734 | inst_src, |
| 31735 | 31735 | "runtime coercion from enum '{}' to union '{}' which has a 'noreturn' field", |
| ... | ... | @@ -31911,7 +31911,7 @@ fn coerceArrayLike( |
| 31911 | 31911 | if (dest_ty.isVector(zcu) and inst_ty.isVector(zcu) and (try sema.resolveValue(inst)) == null) { |
| 31912 | 31912 | const inst_elem_ty = inst_ty.childType(zcu); |
| 31913 | 31913 | switch (dest_elem_ty.zigTypeTag(zcu)) { |
| 31914 | .Int => if (inst_elem_ty.isInt(zcu)) { | |
| 31914 | .int => if (inst_elem_ty.isInt(zcu)) { | |
| 31915 | 31915 | // integer widening |
| 31916 | 31916 | const dst_info = dest_elem_ty.intInfo(zcu); |
| 31917 | 31917 | const src_info = inst_elem_ty.intInfo(zcu); |
| ... | ... | @@ -31923,7 +31923,7 @@ fn coerceArrayLike( |
| 31923 | 31923 | return block.addTyOp(.intcast, dest_ty, inst); |
| 31924 | 31924 | } |
| 31925 | 31925 | }, |
| 31926 | .Float => if (inst_elem_ty.isRuntimeFloat()) { | |
| 31926 | .float => if (inst_elem_ty.isRuntimeFloat()) { | |
| 31927 | 31927 | // float widening |
| 31928 | 31928 | const src_bits = inst_elem_ty.floatBits(target); |
| 31929 | 31929 | const dst_bits = dest_elem_ty.floatBits(target); |
| ... | ... | @@ -32504,10 +32504,10 @@ fn analyzeLoad( |
| 32504 | 32504 | const zcu = pt.zcu; |
| 32505 | 32505 | const ptr_ty = sema.typeOf(ptr); |
| 32506 | 32506 | const elem_ty = switch (ptr_ty.zigTypeTag(zcu)) { |
| 32507 | .Pointer => ptr_ty.childType(zcu), | |
| 32507 | .pointer => ptr_ty.childType(zcu), | |
| 32508 | 32508 | else => return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(pt)}), |
| 32509 | 32509 | }; |
| 32510 | if (elem_ty.zigTypeTag(zcu) == .Opaque) { | |
| 32510 | if (elem_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 32511 | 32511 | return sema.fail(block, ptr_src, "cannot load opaque type '{}'", .{elem_ty.fmt(pt)}); |
| 32512 | 32512 | } |
| 32513 | 32513 | |
| ... | ... | @@ -32621,10 +32621,10 @@ fn analyzeIsNull( |
| 32621 | 32621 | |
| 32622 | 32622 | const inverted_non_null_res: Air.Inst.Ref = if (invert_logic) .bool_true else .bool_false; |
| 32623 | 32623 | const operand_ty = sema.typeOf(operand); |
| 32624 | if (operand_ty.zigTypeTag(zcu) == .Optional and operand_ty.optionalChild(zcu).zigTypeTag(zcu) == .NoReturn) { | |
| 32624 | if (operand_ty.zigTypeTag(zcu) == .optional and operand_ty.optionalChild(zcu).zigTypeTag(zcu) == .noreturn) { | |
| 32625 | 32625 | return inverted_non_null_res; |
| 32626 | 32626 | } |
| 32627 | if (operand_ty.zigTypeTag(zcu) != .Optional and !operand_ty.isPtrLikeOptional(zcu)) { | |
| 32627 | if (operand_ty.zigTypeTag(zcu) != .optional and !operand_ty.isPtrLikeOptional(zcu)) { | |
| 32628 | 32628 | return inverted_non_null_res; |
| 32629 | 32629 | } |
| 32630 | 32630 | try sema.requireRuntimeBlock(block, src, null); |
| ... | ... | @@ -32641,13 +32641,13 @@ fn analyzePtrIsNonErrComptimeOnly( |
| 32641 | 32641 | const pt = sema.pt; |
| 32642 | 32642 | const zcu = pt.zcu; |
| 32643 | 32643 | const ptr_ty = sema.typeOf(operand); |
| 32644 | assert(ptr_ty.zigTypeTag(zcu) == .Pointer); | |
| 32644 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); | |
| 32645 | 32645 | const child_ty = ptr_ty.childType(zcu); |
| 32646 | 32646 | |
| 32647 | 32647 | const child_tag = child_ty.zigTypeTag(zcu); |
| 32648 | if (child_tag != .ErrorSet and child_tag != .ErrorUnion) return .bool_true; | |
| 32649 | if (child_tag == .ErrorSet) return .bool_false; | |
| 32650 | assert(child_tag == .ErrorUnion); | |
| 32648 | if (child_tag != .error_set and child_tag != .error_union) return .bool_true; | |
| 32649 | if (child_tag == .error_set) return .bool_false; | |
| 32650 | assert(child_tag == .error_union); | |
| 32651 | 32651 | |
| 32652 | 32652 | _ = block; |
| 32653 | 32653 | _ = src; |
| ... | ... | @@ -32666,12 +32666,12 @@ fn analyzeIsNonErrComptimeOnly( |
| 32666 | 32666 | const ip = &zcu.intern_pool; |
| 32667 | 32667 | const operand_ty = sema.typeOf(operand); |
| 32668 | 32668 | const ot = operand_ty.zigTypeTag(zcu); |
| 32669 | if (ot != .ErrorSet and ot != .ErrorUnion) return .bool_true; | |
| 32670 | if (ot == .ErrorSet) return .bool_false; | |
| 32671 | assert(ot == .ErrorUnion); | |
| 32669 | if (ot != .error_set and ot != .error_union) return .bool_true; | |
| 32670 | if (ot == .error_set) return .bool_false; | |
| 32671 | assert(ot == .error_union); | |
| 32672 | 32672 | |
| 32673 | 32673 | const payload_ty = operand_ty.errorUnionPayload(zcu); |
| 32674 | if (payload_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 32674 | if (payload_ty.zigTypeTag(zcu) == .noreturn) { | |
| 32675 | 32675 | return .bool_false; |
| 32676 | 32676 | } |
| 32677 | 32677 | |
| ... | ... | @@ -32828,7 +32828,7 @@ fn analyzeSlice( |
| 32828 | 32828 | // the slice operand to be a pointer. In the case of a non-array, it will be a double pointer. |
| 32829 | 32829 | const ptr_ptr_ty = sema.typeOf(ptr_ptr); |
| 32830 | 32830 | const ptr_ptr_child_ty = switch (ptr_ptr_ty.zigTypeTag(zcu)) { |
| 32831 | .Pointer => ptr_ptr_ty.childType(zcu), | |
| 32831 | .pointer => ptr_ptr_ty.childType(zcu), | |
| 32832 | 32832 | else => return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ptr_ty.fmt(pt)}), |
| 32833 | 32833 | }; |
| 32834 | 32834 | |
| ... | ... | @@ -32838,15 +32838,15 @@ fn analyzeSlice( |
| 32838 | 32838 | var elem_ty: Type = undefined; |
| 32839 | 32839 | var ptr_sentinel: ?Value = null; |
| 32840 | 32840 | switch (ptr_ptr_child_ty.zigTypeTag(zcu)) { |
| 32841 | .Array => { | |
| 32841 | .array => { | |
| 32842 | 32842 | ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu); |
| 32843 | 32843 | elem_ty = ptr_ptr_child_ty.childType(zcu); |
| 32844 | 32844 | }, |
| 32845 | .Pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) { | |
| 32845 | .pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) { | |
| 32846 | 32846 | .One => { |
| 32847 | 32847 | const double_child_ty = ptr_ptr_child_ty.childType(zcu); |
| 32848 | 32848 | ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src); |
| 32849 | if (double_child_ty.zigTypeTag(zcu) == .Array) { | |
| 32849 | if (double_child_ty.zigTypeTag(zcu) == .array) { | |
| 32850 | 32850 | ptr_sentinel = double_child_ty.sentinel(zcu); |
| 32851 | 32851 | slice_ty = ptr_ptr_child_ty; |
| 32852 | 32852 | array_ty = double_child_ty; |
| ... | ... | @@ -32961,7 +32961,7 @@ fn analyzeSlice( |
| 32961 | 32961 | |
| 32962 | 32962 | const ptr = if (slice_ty.isSlice(zcu)) |
| 32963 | 32963 | try sema.analyzeSlicePtr(block, ptr_src, ptr_or_slice, slice_ty) |
| 32964 | else if (array_ty.zigTypeTag(zcu) == .Array) ptr: { | |
| 32964 | else if (array_ty.zigTypeTag(zcu) == .array) ptr: { | |
| 32965 | 32965 | var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type; |
| 32966 | 32966 | assert(manyptr_ty_key.child == array_ty.toIntern()); |
| 32967 | 32967 | assert(manyptr_ty_key.flags.size == .One); |
| ... | ... | @@ -32980,7 +32980,7 @@ fn analyzeSlice( |
| 32980 | 32980 | // we might learn of the length because it is a comptime-known slice value. |
| 32981 | 32981 | var end_is_len = uncasted_end_opt == .none; |
| 32982 | 32982 | const end = e: { |
| 32983 | if (array_ty.zigTypeTag(zcu) == .Array) { | |
| 32983 | if (array_ty.zigTypeTag(zcu) == .array) { | |
| 32984 | 32984 | const len_val = try pt.intValue(Type.usize, array_ty.arrayLen(zcu)); |
| 32985 | 32985 | |
| 32986 | 32986 | if (!end_is_len) { |
| ... | ... | @@ -33215,7 +33215,7 @@ fn analyzeSlice( |
| 33215 | 33215 | } |
| 33216 | 33216 | |
| 33217 | 33217 | bounds_check: { |
| 33218 | const actual_len = if (array_ty.zigTypeTag(zcu) == .Array) | |
| 33218 | const actual_len = if (array_ty.zigTypeTag(zcu) == .array) | |
| 33219 | 33219 | try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu)) |
| 33220 | 33220 | else if (slice_ty.isSlice(zcu)) l: { |
| 33221 | 33221 | const slice_len_inst = try block.addTyOp(.slice_len, Type.usize, ptr_or_slice); |
| ... | ... | @@ -33273,7 +33273,7 @@ fn analyzeSlice( |
| 33273 | 33273 | } |
| 33274 | 33274 | |
| 33275 | 33275 | // requirement: end <= len |
| 33276 | const opt_len_inst = if (array_ty.zigTypeTag(zcu) == .Array) | |
| 33276 | const opt_len_inst = if (array_ty.zigTypeTag(zcu) == .array) | |
| 33277 | 33277 | try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu)) |
| 33278 | 33278 | else if (slice_ty.isSlice(zcu)) blk: { |
| 33279 | 33279 | if (try sema.resolveDefinedValue(block, src, ptr_or_slice)) |slice_val| { |
| ... | ... | @@ -33342,12 +33342,12 @@ fn cmpNumeric( |
| 33342 | 33342 | // One exception to heterogeneous comparison: comptime_float needs to |
| 33343 | 33343 | // coerce to fixed-width float. |
| 33344 | 33344 | |
| 33345 | const lhs = if (lhs_ty_tag == .ComptimeFloat and rhs_ty_tag == .Float) | |
| 33345 | const lhs = if (lhs_ty_tag == .comptime_float and rhs_ty_tag == .float) | |
| 33346 | 33346 | try sema.coerce(block, rhs_ty, uncasted_lhs, lhs_src) |
| 33347 | 33347 | else |
| 33348 | 33348 | uncasted_lhs; |
| 33349 | 33349 | |
| 33350 | const rhs = if (lhs_ty_tag == .Float and rhs_ty_tag == .ComptimeFloat) | |
| 33350 | const rhs = if (lhs_ty_tag == .float and rhs_ty_tag == .comptime_float) | |
| 33351 | 33351 | try sema.coerce(block, lhs_ty, uncasted_rhs, rhs_src) |
| 33352 | 33352 | else |
| 33353 | 33353 | uncasted_rhs; |
| ... | ... | @@ -33356,11 +33356,11 @@ fn cmpNumeric( |
| 33356 | 33356 | if (try sema.resolveValue(lhs)) |lhs_val| { |
| 33357 | 33357 | if (try sema.resolveValue(rhs)) |rhs_val| { |
| 33358 | 33358 | // Compare ints: const vs. undefined (or vice versa) |
| 33359 | if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(zcu) and rhs_val.isUndef(zcu)) { | |
| 33359 | if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .comptime_int) and rhs_ty.isInt(zcu) and rhs_val.isUndef(zcu)) { | |
| 33360 | 33360 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { |
| 33361 | 33361 | return if (res) .bool_true else .bool_false; |
| 33362 | 33362 | } |
| 33363 | } else if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(zcu) and lhs_val.isUndef(zcu)) { | |
| 33363 | } else if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .comptime_int) and lhs_ty.isInt(zcu) and lhs_val.isUndef(zcu)) { | |
| 33364 | 33364 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { |
| 33365 | 33365 | return if (res) .bool_true else .bool_false; |
| 33366 | 33366 | } |
| ... | ... | @@ -33377,7 +33377,7 @@ fn cmpNumeric( |
| 33377 | 33377 | else |
| 33378 | 33378 | .bool_false; |
| 33379 | 33379 | } else { |
| 33380 | if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(zcu)) { | |
| 33380 | if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .comptime_int) and rhs_ty.isInt(zcu)) { | |
| 33381 | 33381 | // Compare ints: const vs. var |
| 33382 | 33382 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { |
| 33383 | 33383 | return if (res) .bool_true else .bool_false; |
| ... | ... | @@ -33387,7 +33387,7 @@ fn cmpNumeric( |
| 33387 | 33387 | } |
| 33388 | 33388 | } else { |
| 33389 | 33389 | if (try sema.resolveValueResolveLazy(rhs)) |rhs_val| { |
| 33390 | if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(zcu)) { | |
| 33390 | if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .comptime_int) and lhs_ty.isInt(zcu)) { | |
| 33391 | 33391 | // Compare ints: var vs. const |
| 33392 | 33392 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { |
| 33393 | 33393 | return if (res) .bool_true else .bool_false; |
| ... | ... | @@ -33407,11 +33407,11 @@ fn cmpNumeric( |
| 33407 | 33407 | |
| 33408 | 33408 | // For floats, emit a float comparison instruction. |
| 33409 | 33409 | const lhs_is_float = switch (lhs_ty_tag) { |
| 33410 | .Float, .ComptimeFloat => true, | |
| 33410 | .float, .comptime_float => true, | |
| 33411 | 33411 | else => false, |
| 33412 | 33412 | }; |
| 33413 | 33413 | const rhs_is_float = switch (rhs_ty_tag) { |
| 33414 | .Float, .ComptimeFloat => true, | |
| 33414 | .float, .comptime_float => true, | |
| 33415 | 33415 | else => false, |
| 33416 | 33416 | }; |
| 33417 | 33417 | |
| ... | ... | @@ -33419,9 +33419,9 @@ fn cmpNumeric( |
| 33419 | 33419 | // Smaller fixed-width floats coerce to larger fixed-width floats. |
| 33420 | 33420 | // comptime_float coerces to fixed-width float. |
| 33421 | 33421 | const dest_ty = x: { |
| 33422 | if (lhs_ty_tag == .ComptimeFloat) { | |
| 33422 | if (lhs_ty_tag == .comptime_float) { | |
| 33423 | 33423 | break :x rhs_ty; |
| 33424 | } else if (rhs_ty_tag == .ComptimeFloat) { | |
| 33424 | } else if (rhs_ty_tag == .comptime_float) { | |
| 33425 | 33425 | break :x lhs_ty; |
| 33426 | 33426 | } |
| 33427 | 33427 | if (lhs_ty.floatBits(target) >= rhs_ty.floatBits(target)) { |
| ... | ... | @@ -33691,8 +33691,8 @@ fn cmpVector( |
| 33691 | 33691 | const zcu = pt.zcu; |
| 33692 | 33692 | const lhs_ty = sema.typeOf(lhs); |
| 33693 | 33693 | const rhs_ty = sema.typeOf(rhs); |
| 33694 | assert(lhs_ty.zigTypeTag(zcu) == .Vector); | |
| 33695 | assert(rhs_ty.zigTypeTag(zcu) == .Vector); | |
| 33694 | assert(lhs_ty.zigTypeTag(zcu) == .vector); | |
| 33695 | assert(rhs_ty.zigTypeTag(zcu) == .vector); | |
| 33696 | 33696 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 33697 | 33697 | |
| 33698 | 33698 | const resolved_ty = try sema.resolvePeerTypes(block, src, &.{ lhs, rhs }, .{ .override = &.{ lhs_src, rhs_src } }); |
| ... | ... | @@ -34005,22 +34005,22 @@ const PeerResolveStrategy = enum { |
| 34005 | 34005 | |
| 34006 | 34006 | fn select(ty: Type, zcu: *Zcu) PeerResolveStrategy { |
| 34007 | 34007 | return switch (ty.zigTypeTag(zcu)) { |
| 34008 | .Type, .Void, .Bool, .Opaque, .Frame, .AnyFrame => .exact, | |
| 34009 | .NoReturn, .Undefined => .unknown, | |
| 34010 | .Null => .nullable, | |
| 34011 | .ComptimeInt => .comptime_int, | |
| 34012 | .Int => .fixed_int, | |
| 34013 | .ComptimeFloat => .comptime_float, | |
| 34014 | .Float => .fixed_float, | |
| 34015 | .Pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr, | |
| 34016 | .Array => .array, | |
| 34017 | .Vector => .vector, | |
| 34018 | .Optional => .optional, | |
| 34019 | .ErrorSet => .error_set, | |
| 34020 | .ErrorUnion => .error_union, | |
| 34021 | .EnumLiteral, .Enum, .Union => .enum_or_union, | |
| 34022 | .Struct => if (ty.isTupleOrAnonStruct(zcu)) .coercible_struct else .exact, | |
| 34023 | .Fn => .func, | |
| 34008 | .type, .void, .bool, .@"opaque", .frame, .@"anyframe" => .exact, | |
| 34009 | .noreturn, .undefined => .unknown, | |
| 34010 | .null => .nullable, | |
| 34011 | .comptime_int => .comptime_int, | |
| 34012 | .int => .fixed_int, | |
| 34013 | .comptime_float => .comptime_float, | |
| 34014 | .float => .fixed_float, | |
| 34015 | .pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr, | |
| 34016 | .array => .array, | |
| 34017 | .vector => .vector, | |
| 34018 | .optional => .optional, | |
| 34019 | .error_set => .error_set, | |
| 34020 | .error_union => .error_union, | |
| 34021 | .enum_literal, .@"enum", .@"union" => .enum_or_union, | |
| 34022 | .@"struct" => if (ty.isTupleOrAnonStruct(zcu)) .coercible_struct else .exact, | |
| 34023 | .@"fn" => .func, | |
| 34024 | 34024 | }; |
| 34025 | 34025 | } |
| 34026 | 34026 | }; |
| ... | ... | @@ -34213,7 +34213,7 @@ fn resolvePeerTypesInner( |
| 34213 | 34213 | for (peer_tys) |*ty_ptr| { |
| 34214 | 34214 | const ty = ty_ptr.* orelse continue; |
| 34215 | 34215 | switch (ty.zigTypeTag(zcu)) { |
| 34216 | .NoReturn, .Undefined => ty_ptr.* = null, | |
| 34216 | .noreturn, .undefined => ty_ptr.* = null, | |
| 34217 | 34217 | else => {}, |
| 34218 | 34218 | } |
| 34219 | 34219 | } |
| ... | ... | @@ -34228,7 +34228,7 @@ fn resolvePeerTypesInner( |
| 34228 | 34228 | var final_set: ?Type = null; |
| 34229 | 34229 | for (peer_tys, 0..) |opt_ty, i| { |
| 34230 | 34230 | const ty = opt_ty orelse continue; |
| 34231 | if (ty.zigTypeTag(zcu) != .ErrorSet) return .{ .conflict = .{ | |
| 34231 | if (ty.zigTypeTag(zcu) != .error_set) return .{ .conflict = .{ | |
| 34232 | 34232 | .peer_idx_a = strat_reason, |
| 34233 | 34233 | .peer_idx_b = i, |
| 34234 | 34234 | } }; |
| ... | ... | @@ -34246,12 +34246,12 @@ fn resolvePeerTypesInner( |
| 34246 | 34246 | for (peer_tys, peer_vals) |*ty_ptr, *val_ptr| { |
| 34247 | 34247 | const ty = ty_ptr.* orelse continue; |
| 34248 | 34248 | const set_ty = switch (ty.zigTypeTag(zcu)) { |
| 34249 | .ErrorSet => blk: { | |
| 34249 | .error_set => blk: { | |
| 34250 | 34250 | ty_ptr.* = null; // no payload to decide on |
| 34251 | 34251 | val_ptr.* = null; |
| 34252 | 34252 | break :blk ty; |
| 34253 | 34253 | }, |
| 34254 | .ErrorUnion => blk: { | |
| 34254 | .error_union => blk: { | |
| 34255 | 34255 | const set_ty = ty.errorUnionSet(zcu); |
| 34256 | 34256 | ty_ptr.* = ty.errorUnionPayload(zcu); |
| 34257 | 34257 | if (val_ptr.*) |eu_val| switch (ip.indexToKey(eu_val.toIntern())) { |
| ... | ... | @@ -34300,11 +34300,11 @@ fn resolvePeerTypesInner( |
| 34300 | 34300 | for (peer_tys, peer_vals) |*ty_ptr, *val_ptr| { |
| 34301 | 34301 | const ty = ty_ptr.* orelse continue; |
| 34302 | 34302 | switch (ty.zigTypeTag(zcu)) { |
| 34303 | .Null => { | |
| 34303 | .null => { | |
| 34304 | 34304 | ty_ptr.* = null; |
| 34305 | 34305 | val_ptr.* = null; |
| 34306 | 34306 | }, |
| 34307 | .Optional => { | |
| 34307 | .optional => { | |
| 34308 | 34308 | ty_ptr.* = ty.optionalChild(zcu); |
| 34309 | 34309 | if (val_ptr.*) |opt_val| val_ptr.* = if (!opt_val.isUndef(zcu)) opt_val.optionalValue(zcu) else null; |
| 34310 | 34310 | }, |
| ... | ... | @@ -34482,8 +34482,8 @@ fn resolvePeerTypesInner( |
| 34482 | 34482 | for (peer_tys, peer_vals, 0..) |opt_ty, opt_val, i| { |
| 34483 | 34483 | const ty = opt_ty orelse continue; |
| 34484 | 34484 | switch (ty.zigTypeTag(zcu)) { |
| 34485 | .ComptimeInt => continue, // comptime-known integers can always coerce to C pointers | |
| 34486 | .Int => { | |
| 34485 | .comptime_int => continue, // comptime-known integers can always coerce to C pointers | |
| 34486 | .int => { | |
| 34487 | 34487 | if (opt_val != null) { |
| 34488 | 34488 | // Always allow the coercion for comptime-known ints |
| 34489 | 34489 | continue; |
| ... | ... | @@ -34494,7 +34494,7 @@ fn resolvePeerTypesInner( |
| 34494 | 34494 | if (bits <= ptr_bits) continue; |
| 34495 | 34495 | } |
| 34496 | 34496 | }, |
| 34497 | .Null => continue, | |
| 34497 | .null => continue, | |
| 34498 | 34498 | else => {}, |
| 34499 | 34499 | } |
| 34500 | 34500 | |
| ... | ... | @@ -34581,8 +34581,8 @@ fn resolvePeerTypesInner( |
| 34581 | 34581 | for (peer_tys, 0..) |opt_ty, i| { |
| 34582 | 34582 | const ty = opt_ty orelse continue; |
| 34583 | 34583 | const peer_info: InternPool.Key.PtrType = switch (ty.zigTypeTag(zcu)) { |
| 34584 | .Pointer => ty.ptrInfo(zcu), | |
| 34585 | .Fn => .{ | |
| 34584 | .pointer => ty.ptrInfo(zcu), | |
| 34585 | .@"fn" => .{ | |
| 34586 | 34586 | .child = ty.toIntern(), |
| 34587 | 34587 | .flags = .{ |
| 34588 | 34588 | .address_space = target_util.defaultAddressSpace(target, .global_constant), |
| ... | ... | @@ -34889,7 +34889,7 @@ fn resolvePeerTypesInner( |
| 34889 | 34889 | first_idx = i; |
| 34890 | 34890 | continue; |
| 34891 | 34891 | }; |
| 34892 | if (ty.zigTypeTag(zcu) != .Fn) return .{ .conflict = .{ | |
| 34892 | if (ty.zigTypeTag(zcu) != .@"fn") return .{ .conflict = .{ | |
| 34893 | 34893 | .peer_idx_a = strat_reason, |
| 34894 | 34894 | .peer_idx_b = i, |
| 34895 | 34895 | } }; |
| ... | ... | @@ -34918,7 +34918,7 @@ fn resolvePeerTypesInner( |
| 34918 | 34918 | for (peer_tys, 0..) |opt_ty, i| { |
| 34919 | 34919 | const ty = opt_ty orelse continue; |
| 34920 | 34920 | switch (ty.zigTypeTag(zcu)) { |
| 34921 | .EnumLiteral, .Enum, .Union => {}, | |
| 34921 | .enum_literal, .@"enum", .@"union" => {}, | |
| 34922 | 34922 | else => return .{ .conflict = .{ |
| 34923 | 34923 | .peer_idx_a = strat_reason, |
| 34924 | 34924 | .peer_idx_b = i, |
| ... | ... | @@ -34937,16 +34937,16 @@ fn resolvePeerTypesInner( |
| 34937 | 34937 | } }; |
| 34938 | 34938 | |
| 34939 | 34939 | switch (cur_ty.zigTypeTag(zcu)) { |
| 34940 | .EnumLiteral => { | |
| 34940 | .enum_literal => { | |
| 34941 | 34941 | opt_cur_ty = ty; |
| 34942 | 34942 | cur_ty_idx = i; |
| 34943 | 34943 | }, |
| 34944 | .Enum => switch (ty.zigTypeTag(zcu)) { | |
| 34945 | .EnumLiteral => {}, | |
| 34946 | .Enum => { | |
| 34944 | .@"enum" => switch (ty.zigTypeTag(zcu)) { | |
| 34945 | .enum_literal => {}, | |
| 34946 | .@"enum" => { | |
| 34947 | 34947 | if (!ty.eql(cur_ty, zcu)) return generic_err; |
| 34948 | 34948 | }, |
| 34949 | .Union => { | |
| 34949 | .@"union" => { | |
| 34950 | 34950 | const tag_ty = ty.unionTagTypeHypothetical(zcu); |
| 34951 | 34951 | if (!tag_ty.eql(cur_ty, zcu)) return generic_err; |
| 34952 | 34952 | opt_cur_ty = ty; |
| ... | ... | @@ -34954,13 +34954,13 @@ fn resolvePeerTypesInner( |
| 34954 | 34954 | }, |
| 34955 | 34955 | else => unreachable, |
| 34956 | 34956 | }, |
| 34957 | .Union => switch (ty.zigTypeTag(zcu)) { | |
| 34958 | .EnumLiteral => {}, | |
| 34959 | .Enum => { | |
| 34957 | .@"union" => switch (ty.zigTypeTag(zcu)) { | |
| 34958 | .enum_literal => {}, | |
| 34959 | .@"enum" => { | |
| 34960 | 34960 | const cur_tag_ty = cur_ty.unionTagTypeHypothetical(zcu); |
| 34961 | 34961 | if (!ty.eql(cur_tag_ty, zcu)) return generic_err; |
| 34962 | 34962 | }, |
| 34963 | .Union => { | |
| 34963 | .@"union" => { | |
| 34964 | 34964 | if (!ty.eql(cur_ty, zcu)) return generic_err; |
| 34965 | 34965 | }, |
| 34966 | 34966 | else => unreachable, |
| ... | ... | @@ -34975,7 +34975,7 @@ fn resolvePeerTypesInner( |
| 34975 | 34975 | for (peer_tys, 0..) |opt_ty, i| { |
| 34976 | 34976 | const ty = opt_ty orelse continue; |
| 34977 | 34977 | switch (ty.zigTypeTag(zcu)) { |
| 34978 | .ComptimeInt => {}, | |
| 34978 | .comptime_int => {}, | |
| 34979 | 34979 | else => return .{ .conflict = .{ |
| 34980 | 34980 | .peer_idx_a = strat_reason, |
| 34981 | 34981 | .peer_idx_b = i, |
| ... | ... | @@ -34989,7 +34989,7 @@ fn resolvePeerTypesInner( |
| 34989 | 34989 | for (peer_tys, 0..) |opt_ty, i| { |
| 34990 | 34990 | const ty = opt_ty orelse continue; |
| 34991 | 34991 | switch (ty.zigTypeTag(zcu)) { |
| 34992 | .ComptimeInt, .ComptimeFloat => {}, | |
| 34992 | .comptime_int, .comptime_float => {}, | |
| 34993 | 34993 | else => return .{ .conflict = .{ |
| 34994 | 34994 | .peer_idx_a = strat_reason, |
| 34995 | 34995 | .peer_idx_b = i, |
| ... | ... | @@ -35012,7 +35012,7 @@ fn resolvePeerTypesInner( |
| 35012 | 35012 | |
| 35013 | 35013 | const peer_tag = ty.zigTypeTag(zcu); |
| 35014 | 35014 | switch (peer_tag) { |
| 35015 | .ComptimeInt => { | |
| 35015 | .comptime_int => { | |
| 35016 | 35016 | // If the value is undefined, we can't refine to a fixed-width int |
| 35017 | 35017 | if (opt_val == null or opt_val.?.isUndef(zcu)) return .{ .conflict = .{ |
| 35018 | 35018 | .peer_idx_a = strat_reason, |
| ... | ... | @@ -35022,7 +35022,7 @@ fn resolvePeerTypesInner( |
| 35022 | 35022 | ptr_opt_val.* = try sema.resolveLazyValue(opt_val.?); |
| 35023 | 35023 | continue; |
| 35024 | 35024 | }, |
| 35025 | .Int => {}, | |
| 35025 | .int => {}, | |
| 35026 | 35026 | else => return .{ .conflict = .{ |
| 35027 | 35027 | .peer_idx_a = strat_reason, |
| 35028 | 35028 | .peer_idx_b = i, |
| ... | ... | @@ -35091,14 +35091,14 @@ fn resolvePeerTypesInner( |
| 35091 | 35091 | for (peer_tys, peer_vals, 0..) |opt_ty, opt_val, i| { |
| 35092 | 35092 | const ty = opt_ty orelse continue; |
| 35093 | 35093 | switch (ty.zigTypeTag(zcu)) { |
| 35094 | .ComptimeFloat, .ComptimeInt => {}, | |
| 35095 | .Int => { | |
| 35094 | .comptime_float, .comptime_int => {}, | |
| 35095 | .int => { | |
| 35096 | 35096 | if (opt_val == null) return .{ .conflict = .{ |
| 35097 | 35097 | .peer_idx_a = strat_reason, |
| 35098 | 35098 | .peer_idx_b = i, |
| 35099 | 35099 | } }; |
| 35100 | 35100 | }, |
| 35101 | .Float => { | |
| 35101 | .float => { | |
| 35102 | 35102 | if (opt_cur_ty) |cur_ty| { |
| 35103 | 35103 | if (cur_ty.eql(ty, zcu)) continue; |
| 35104 | 35104 | // Recreate the type so we eliminate any c_longdouble |
| ... | ... | @@ -35330,11 +35330,11 @@ fn typeIsArrayLike(sema: *Sema, ty: Type) ?ArrayLike { |
| 35330 | 35330 | const pt = sema.pt; |
| 35331 | 35331 | const zcu = pt.zcu; |
| 35332 | 35332 | return switch (ty.zigTypeTag(zcu)) { |
| 35333 | .Array => .{ | |
| 35333 | .array => .{ | |
| 35334 | 35334 | .len = ty.arrayLen(zcu), |
| 35335 | 35335 | .elem_ty = ty.childType(zcu), |
| 35336 | 35336 | }, |
| 35337 | .Struct => { | |
| 35337 | .@"struct" => { | |
| 35338 | 35338 | const field_count = ty.structFieldCount(zcu); |
| 35339 | 35339 | if (field_count == 0) return .{ |
| 35340 | 35340 | .len = 0, |
| ... | ... | @@ -35625,7 +35625,7 @@ fn backingIntType( |
| 35625 | 35625 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 35626 | 35626 | |
| 35627 | 35627 | if (small.has_backing_int) { |
| 35628 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len; | |
| 35628 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len; | |
| 35629 | 35629 | const captures_len = if (small.has_captures_len) blk: { |
| 35630 | 35630 | const captures_len = zir.extra[extra_index]; |
| 35631 | 35631 | extra_index += 1; |
| ... | ... | @@ -35700,12 +35700,12 @@ fn checkIndexable(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| 35700 | 35700 | fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| 35701 | 35701 | const pt = sema.pt; |
| 35702 | 35702 | const zcu = pt.zcu; |
| 35703 | if (ty.zigTypeTag(zcu) == .Pointer) { | |
| 35703 | if (ty.zigTypeTag(zcu) == .pointer) { | |
| 35704 | 35704 | switch (ty.ptrSize(zcu)) { |
| 35705 | 35705 | .Slice, .Many, .C => return, |
| 35706 | 35706 | .One => { |
| 35707 | 35707 | const elem_ty = ty.childType(zcu); |
| 35708 | if (elem_ty.zigTypeTag(zcu) == .Array) return; | |
| 35708 | if (elem_ty.zigTypeTag(zcu) == .array) return; | |
| 35709 | 35709 | // TODO https://github.com/ziglang/zig/issues/15479 |
| 35710 | 35710 | // if (elem_ty.isTuple()) return; |
| 35711 | 35711 | }, |
| ... | ... | @@ -35797,7 +35797,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35797 | 35797 | for (0..union_type.field_types.len) |field_index| { |
| 35798 | 35798 | const field_ty = Type.fromInterned(union_type.field_types.get(ip)[field_index]); |
| 35799 | 35799 | |
| 35800 | if (try field_ty.comptimeOnlySema(pt) or field_ty.zigTypeTag(pt.zcu) == .NoReturn) continue; // TODO: should this affect alignment? | |
| 35800 | if (try field_ty.comptimeOnlySema(pt) or field_ty.zigTypeTag(pt.zcu) == .noreturn) continue; // TODO: should this affect alignment? | |
| 35801 | 35801 | |
| 35802 | 35802 | max_size = @max(max_size, field_ty.abiSizeSema(pt) catch |err| switch (err) { |
| 35803 | 35803 | error.AnalysisFail => { |
| ... | ... | @@ -36185,7 +36185,7 @@ fn structZirInfo(zir: Zir, zir_index: Zir.Inst.Index) struct { |
| 36185 | 36185 | const extended = zir.instructions.items(.data)[@intFromEnum(zir_index)].extended; |
| 36186 | 36186 | assert(extended.opcode == .struct_decl); |
| 36187 | 36187 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 36188 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len; | |
| 36188 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len; | |
| 36189 | 36189 | |
| 36190 | 36190 | const captures_len = if (small.has_captures_len) blk: { |
| 36191 | 36191 | const captures_len = zir.extra[extra_index]; |
| ... | ... | @@ -36357,7 +36357,7 @@ fn structFields( |
| 36357 | 36357 | |
| 36358 | 36358 | struct_type.field_types.get(ip)[field_i] = field_ty.toIntern(); |
| 36359 | 36359 | |
| 36360 | if (field_ty.zigTypeTag(zcu) == .Opaque) { | |
| 36360 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 36361 | 36361 | const msg = msg: { |
| 36362 | 36362 | const msg = try sema.errMsg(ty_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); |
| 36363 | 36363 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -36367,7 +36367,7 @@ fn structFields( |
| 36367 | 36367 | }; |
| 36368 | 36368 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 36369 | 36369 | } |
| 36370 | if (field_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 36370 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | |
| 36371 | 36371 | const msg = msg: { |
| 36372 | 36372 | const msg = try sema.errMsg(ty_src, "struct fields cannot be 'noreturn'", .{}); |
| 36373 | 36373 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -36635,7 +36635,7 @@ fn unionFields( |
| 36635 | 36635 | if (small.auto_enum_tag) { |
| 36636 | 36636 | // The provided type is an integer type and we must construct the enum tag type here. |
| 36637 | 36637 | int_tag_ty = provided_ty; |
| 36638 | if (int_tag_ty.zigTypeTag(zcu) != .Int and int_tag_ty.zigTypeTag(zcu) != .ComptimeInt) { | |
| 36638 | if (int_tag_ty.zigTypeTag(zcu) != .int and int_tag_ty.zigTypeTag(zcu) != .comptime_int) { | |
| 36639 | 36639 | return sema.fail(&block_scope, tag_ty_src, "expected integer tag type, found '{}'", .{int_tag_ty.fmt(pt)}); |
| 36640 | 36640 | } |
| 36641 | 36641 | |
| ... | ... | @@ -36834,7 +36834,7 @@ fn unionFields( |
| 36834 | 36834 | } |
| 36835 | 36835 | } |
| 36836 | 36836 | |
| 36837 | if (field_ty.zigTypeTag(zcu) == .Opaque) { | |
| 36837 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | |
| 36838 | 36838 | const msg = msg: { |
| 36839 | 36839 | const msg = try sema.errMsg(type_src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{}); |
| 36840 | 36840 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -36932,7 +36932,7 @@ fn generateUnionTagTypeNumbered( |
| 36932 | 36932 | const name = try ip.getOrPutStringFmt( |
| 36933 | 36933 | gpa, |
| 36934 | 36934 | pt.tid, |
| 36935 | "@typeInfo({}).Union.tag_type.?", | |
| 36935 | "@typeInfo({}).@\"union\".tag_type.?", | |
| 36936 | 36936 | .{union_name.fmt(ip)}, |
| 36937 | 36937 | .no_embedded_nulls, |
| 36938 | 36938 | ); |
| ... | ... | @@ -36968,7 +36968,7 @@ fn generateUnionTagTypeSimple( |
| 36968 | 36968 | const name = try ip.getOrPutStringFmt( |
| 36969 | 36969 | gpa, |
| 36970 | 36970 | pt.tid, |
| 36971 | "@typeInfo({}).Union.tag_type.?", | |
| 36971 | "@typeInfo({}).@\"union\".tag_type.?", | |
| 36972 | 36972 | .{union_name.fmt(ip)}, |
| 36973 | 36973 | .no_embedded_nulls, |
| 36974 | 36974 | ); |
| ... | ... | @@ -37637,7 +37637,7 @@ fn intAdd(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize) |
| 37637 | 37637 | fn intAddInner(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize) !Value { |
| 37638 | 37638 | const pt = sema.pt; |
| 37639 | 37639 | const zcu = pt.zcu; |
| 37640 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 37640 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 37641 | 37641 | const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 37642 | 37642 | const scalar_ty = ty.scalarType(zcu); |
| 37643 | 37643 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -37693,7 +37693,7 @@ fn numberAddWrapScalar( |
| 37693 | 37693 | const zcu = pt.zcu; |
| 37694 | 37694 | if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return pt.undefValue(ty); |
| 37695 | 37695 | |
| 37696 | if (ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 37696 | if (ty.zigTypeTag(zcu) == .comptime_int) { | |
| 37697 | 37697 | return sema.intAdd(lhs, rhs, ty, undefined); |
| 37698 | 37698 | } |
| 37699 | 37699 | |
| ... | ... | @@ -37729,7 +37729,7 @@ fn intSub(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize) |
| 37729 | 37729 | |
| 37730 | 37730 | fn intSubInner(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize) !Value { |
| 37731 | 37731 | const pt = sema.pt; |
| 37732 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 37732 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 37733 | 37733 | const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 37734 | 37734 | const scalar_ty = ty.scalarType(pt.zcu); |
| 37735 | 37735 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -37786,7 +37786,7 @@ fn numberSubWrapScalar( |
| 37786 | 37786 | const zcu = pt.zcu; |
| 37787 | 37787 | if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return pt.undefValue(ty); |
| 37788 | 37788 | |
| 37789 | if (ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 37789 | if (ty.zigTypeTag(zcu) == .comptime_int) { | |
| 37790 | 37790 | return sema.intSub(lhs, rhs, ty, undefined); |
| 37791 | 37791 | } |
| 37792 | 37792 | |
| ... | ... | @@ -37806,7 +37806,7 @@ fn intSubWithOverflow( |
| 37806 | 37806 | ) !Value.OverflowArithmeticResult { |
| 37807 | 37807 | const pt = sema.pt; |
| 37808 | 37808 | const zcu = pt.zcu; |
| 37809 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 37809 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 37810 | 37810 | const vec_len = ty.vectorLen(zcu); |
| 37811 | 37811 | const overflowed_data = try sema.arena.alloc(InternPool.Index, vec_len); |
| 37812 | 37812 | const result_data = try sema.arena.alloc(InternPool.Index, vec_len); |
| ... | ... | @@ -37879,7 +37879,7 @@ fn intFromFloat( |
| 37879 | 37879 | ) CompileError!Value { |
| 37880 | 37880 | const pt = sema.pt; |
| 37881 | 37881 | const zcu = pt.zcu; |
| 37882 | if (float_ty.zigTypeTag(zcu) == .Vector) { | |
| 37882 | if (float_ty.zigTypeTag(zcu) == .vector) { | |
| 37883 | 37883 | const result_data = try sema.arena.alloc(InternPool.Index, float_ty.vectorLen(zcu)); |
| 37884 | 37884 | for (result_data, 0..) |*scalar, i| { |
| 37885 | 37885 | const elem_val = try val.elemValue(pt, i); |
| ... | ... | @@ -38015,7 +38015,7 @@ fn intFitsInType( |
| 38015 | 38015 | }, |
| 38016 | 38016 | }, |
| 38017 | 38017 | .aggregate => |aggregate| { |
| 38018 | assert(ty.zigTypeTag(zcu) == .Vector); | |
| 38018 | assert(ty.zigTypeTag(zcu) == .vector); | |
| 38019 | 38019 | return switch (aggregate.storage) { |
| 38020 | 38020 | .bytes => |bytes| for (bytes.toSlice(ty.vectorLen(zcu), &zcu.intern_pool), 0..) |byte, i| { |
| 38021 | 38021 | if (byte == 0) continue; |
| ... | ... | @@ -38070,7 +38070,7 @@ fn intAddWithOverflow( |
| 38070 | 38070 | ) !Value.OverflowArithmeticResult { |
| 38071 | 38071 | const pt = sema.pt; |
| 38072 | 38072 | const zcu = pt.zcu; |
| 38073 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 38073 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 38074 | 38074 | const vec_len = ty.vectorLen(zcu); |
| 38075 | 38075 | const overflowed_data = try sema.arena.alloc(InternPool.Index, vec_len); |
| 38076 | 38076 | const result_data = try sema.arena.alloc(InternPool.Index, vec_len); |
| ... | ... | @@ -38143,7 +38143,7 @@ fn compareAll( |
| 38143 | 38143 | ) CompileError!bool { |
| 38144 | 38144 | const pt = sema.pt; |
| 38145 | 38145 | const zcu = pt.zcu; |
| 38146 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 38146 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 38147 | 38147 | var i: usize = 0; |
| 38148 | 38148 | while (i < ty.vectorLen(zcu)) : (i += 1) { |
| 38149 | 38149 | const lhs_elem = try lhs.elemValue(pt, i); |
| ... | ... | @@ -38194,7 +38194,7 @@ fn compareVector( |
| 38194 | 38194 | ) !Value { |
| 38195 | 38195 | const pt = sema.pt; |
| 38196 | 38196 | const zcu = pt.zcu; |
| 38197 | assert(ty.zigTypeTag(zcu) == .Vector); | |
| 38197 | assert(ty.zigTypeTag(zcu) == .vector); | |
| 38198 | 38198 | const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 38199 | 38199 | for (result_data, 0..) |*scalar, i| { |
| 38200 | 38200 | const lhs_elem = try lhs.elemValue(pt, i); |
| ... | ... | @@ -38555,7 +38555,7 @@ pub fn resolveDeclaredEnum( |
| 38555 | 38555 | |
| 38556 | 38556 | if (tag_type_ref != .none) { |
| 38557 | 38557 | const ty = try sema.resolveType(&block, tag_ty_src, tag_type_ref); |
| 38558 | if (ty.zigTypeTag(zcu) != .Int and ty.zigTypeTag(zcu) != .ComptimeInt) { | |
| 38558 | if (ty.zigTypeTag(zcu) != .int and ty.zigTypeTag(zcu) != .comptime_int) { | |
| 38559 | 38559 | return sema.fail(&block, tag_ty_src, "expected integer tag type, found '{}'", .{ty.fmt(pt)}); |
| 38560 | 38560 | } |
| 38561 | 38561 | break :ty ty; |
src/Sema/bitcast.zig+7-7| ... | ... | @@ -274,7 +274,7 @@ const UnpackValueBits = struct { |
| 274 | 274 | => try unpack.primitive(val), |
| 275 | 275 | |
| 276 | 276 | .aggregate => switch (ty.zigTypeTag(zcu)) { |
| 277 | .Vector => { | |
| 277 | .vector => { | |
| 278 | 278 | const len: usize = @intCast(ty.arrayLen(zcu)); |
| 279 | 279 | for (0..len) |i| { |
| 280 | 280 | // We reverse vector elements in packed memory on BE targets. |
| ... | ... | @@ -286,7 +286,7 @@ const UnpackValueBits = struct { |
| 286 | 286 | try unpack.add(elem_val); |
| 287 | 287 | } |
| 288 | 288 | }, |
| 289 | .Array => { | |
| 289 | .array => { | |
| 290 | 290 | // Each element is padded up to its ABI size. Padding bits are undefined. |
| 291 | 291 | // The final element does not have trailing padding. |
| 292 | 292 | // Elements are reversed in packed memory on BE targets. |
| ... | ... | @@ -316,7 +316,7 @@ const UnpackValueBits = struct { |
| 316 | 316 | try unpack.add(s); |
| 317 | 317 | }; |
| 318 | 318 | }, |
| 319 | .Struct => switch (ty.containerLayout(zcu)) { | |
| 319 | .@"struct" => switch (ty.containerLayout(zcu)) { | |
| 320 | 320 | .auto => unreachable, // ill-defined layout |
| 321 | 321 | .@"extern" => switch (endian) { |
| 322 | 322 | .little => { |
| ... | ... | @@ -473,7 +473,7 @@ const PackValueBits = struct { |
| 473 | 473 | const ip = &zcu.intern_pool; |
| 474 | 474 | const arena = pack.arena; |
| 475 | 475 | switch (ty.zigTypeTag(zcu)) { |
| 476 | .Vector => { | |
| 476 | .vector => { | |
| 477 | 477 | // Elements are bit-packed. |
| 478 | 478 | const len = ty.arrayLen(zcu); |
| 479 | 479 | const elem_ty = ty.childType(zcu); |
| ... | ... | @@ -496,7 +496,7 @@ const PackValueBits = struct { |
| 496 | 496 | .storage = .{ .elems = elems }, |
| 497 | 497 | } })); |
| 498 | 498 | }, |
| 499 | .Array => { | |
| 499 | .array => { | |
| 500 | 500 | // Each element is padded up to its ABI size. The final element does not have trailing padding. |
| 501 | 501 | const len = ty.arrayLen(zcu); |
| 502 | 502 | const elem_ty = ty.childType(zcu); |
| ... | ... | @@ -530,7 +530,7 @@ const PackValueBits = struct { |
| 530 | 530 | .storage = .{ .elems = elems }, |
| 531 | 531 | } })); |
| 532 | 532 | }, |
| 533 | .Struct => switch (ty.containerLayout(zcu)) { | |
| 533 | .@"struct" => switch (ty.containerLayout(zcu)) { | |
| 534 | 534 | .auto => unreachable, // ill-defined layout |
| 535 | 535 | .@"extern" => { |
| 536 | 536 | const elems = try arena.alloc(InternPool.Index, ty.structFieldCount(zcu)); |
| ... | ... | @@ -587,7 +587,7 @@ const PackValueBits = struct { |
| 587 | 587 | } })); |
| 588 | 588 | }, |
| 589 | 589 | }, |
| 590 | .Union => { | |
| 590 | .@"union" => { | |
| 591 | 591 | // We will attempt to read as the backing representation. If this emits |
| 592 | 592 | // `error.ReinterpretDeclRef`, we will try each union field, preferring larger ones. |
| 593 | 593 | // We will also attempt smaller fields when we get `undefined`, as if some bits are |
src/Sema/comptime_ptr_access.zig+64-64| ... | ... | @@ -226,7 +226,7 @@ fn loadComptimePtrInner( |
| 226 | 226 | .variable => return .runtime_load, |
| 227 | 227 | // We let `.@"extern"` through here if it's a function. |
| 228 | 228 | // This allows you to alias `extern fn`s. |
| 229 | .@"extern" => |e| if (Type.fromInterned(e.ty).zigTypeTag(zcu) == .Fn) | |
| 229 | .@"extern" => |e| if (Type.fromInterned(e.ty).zigTypeTag(zcu) == .@"fn") | |
| 230 | 230 | break :val .{ .interned = val } |
| 231 | 231 | else |
| 232 | 232 | return .runtime_load, |
| ... | ... | @@ -296,8 +296,8 @@ fn loadComptimePtrInner( |
| 296 | 296 | |
| 297 | 297 | const agg_ty = agg_val.typeOf(zcu); |
| 298 | 298 | switch (agg_ty.zigTypeTag(zcu)) { |
| 299 | .Struct, .Pointer => break :val try agg_val.getElem(sema.pt, @intCast(base_index.index)), | |
| 300 | .Union => { | |
| 299 | .@"struct", .pointer => break :val try agg_val.getElem(sema.pt, @intCast(base_index.index)), | |
| 300 | .@"union" => { | |
| 301 | 301 | const tag_val: Value, const payload_mv: MutableValue = switch (agg_val) { |
| 302 | 302 | .un => |un| .{ Value.fromInterned(un.tag), un.payload.* }, |
| 303 | 303 | .interned => |ip_index| switch (ip.indexToKey(ip_index)) { |
| ... | ... | @@ -321,7 +321,7 @@ fn loadComptimePtrInner( |
| 321 | 321 | }; |
| 322 | 322 | |
| 323 | 323 | if (ptr.byte_offset == 0 and host_bits == 0) { |
| 324 | if (load_ty.zigTypeTag(zcu) != .Array or array_offset == 0) { | |
| 324 | if (load_ty.zigTypeTag(zcu) != .array or array_offset == 0) { | |
| 325 | 325 | if (.ok == try sema.coerceInMemoryAllowed( |
| 326 | 326 | block, |
| 327 | 327 | load_ty, |
| ... | ... | @@ -366,7 +366,7 @@ fn loadComptimePtrInner( |
| 366 | 366 | null, |
| 367 | 367 | )) { |
| 368 | 368 | // Changing the length of an array. |
| 369 | const skip_base: u64 = extra_base_index + if (load_ty.zigTypeTag(zcu) == .Array) skip: { | |
| 369 | const skip_base: u64 = extra_base_index + if (load_ty.zigTypeTag(zcu) == .array) skip: { | |
| 370 | 370 | break :skip load_ty.childType(zcu).arrayBase(zcu)[1] * array_offset; |
| 371 | 371 | } else 0; |
| 372 | 372 | if (skip_base + load_count > val_count) return .{ .out_of_bounds = base_val.typeOf(zcu) }; |
| ... | ... | @@ -394,7 +394,7 @@ fn loadComptimePtrInner( |
| 394 | 394 | var cur_val = base_val; |
| 395 | 395 | var cur_offset = ptr.byte_offset; |
| 396 | 396 | |
| 397 | if (load_ty.zigTypeTag(zcu) == .Array and array_offset > 0) { | |
| 397 | if (load_ty.zigTypeTag(zcu) == .array and array_offset > 0) { | |
| 398 | 398 | cur_offset += try load_ty.childType(zcu).abiSizeSema(pt) * array_offset; |
| 399 | 399 | } |
| 400 | 400 | |
| ... | ... | @@ -410,30 +410,30 @@ fn loadComptimePtrInner( |
| 410 | 410 | while (true) { |
| 411 | 411 | const cur_ty = cur_val.typeOf(zcu); |
| 412 | 412 | switch (cur_ty.zigTypeTag(zcu)) { |
| 413 | .NoReturn, | |
| 414 | .Type, | |
| 415 | .ComptimeInt, | |
| 416 | .ComptimeFloat, | |
| 417 | .Null, | |
| 418 | .Undefined, | |
| 419 | .EnumLiteral, | |
| 420 | .Opaque, | |
| 421 | .Fn, | |
| 422 | .ErrorUnion, | |
| 413 | .noreturn, | |
| 414 | .type, | |
| 415 | .comptime_int, | |
| 416 | .comptime_float, | |
| 417 | .null, | |
| 418 | .undefined, | |
| 419 | .enum_literal, | |
| 420 | .@"opaque", | |
| 421 | .@"fn", | |
| 422 | .error_union, | |
| 423 | 423 | => unreachable, // ill-defined layout |
| 424 | .Int, | |
| 425 | .Float, | |
| 426 | .Bool, | |
| 427 | .Void, | |
| 428 | .Pointer, | |
| 429 | .ErrorSet, | |
| 430 | .AnyFrame, | |
| 431 | .Frame, | |
| 432 | .Enum, | |
| 433 | .Vector, | |
| 424 | .int, | |
| 425 | .float, | |
| 426 | .bool, | |
| 427 | .void, | |
| 428 | .pointer, | |
| 429 | .error_set, | |
| 430 | .@"anyframe", | |
| 431 | .frame, | |
| 432 | .@"enum", | |
| 433 | .vector, | |
| 434 | 434 | => break, // terminal types (no sub-values) |
| 435 | .Optional => break, // this can only be a pointer-like optional so is terminal | |
| 436 | .Array => { | |
| 435 | .optional => break, // this can only be a pointer-like optional so is terminal | |
| 436 | .array => { | |
| 437 | 437 | const elem_ty = cur_ty.childType(zcu); |
| 438 | 438 | const elem_size = try elem_ty.abiSizeSema(pt); |
| 439 | 439 | const elem_idx = cur_offset / elem_size; |
| ... | ... | @@ -446,7 +446,7 @@ fn loadComptimePtrInner( |
| 446 | 446 | break; |
| 447 | 447 | } |
| 448 | 448 | }, |
| 449 | .Struct => switch (cur_ty.containerLayout(zcu)) { | |
| 449 | .@"struct" => switch (cur_ty.containerLayout(zcu)) { | |
| 450 | 450 | .auto => unreachable, // ill-defined layout |
| 451 | 451 | .@"packed" => break, // let the bitcast logic handle this |
| 452 | 452 | .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| { |
| ... | ... | @@ -459,7 +459,7 @@ fn loadComptimePtrInner( |
| 459 | 459 | } |
| 460 | 460 | } else break, // pointer spans multiple fields |
| 461 | 461 | }, |
| 462 | .Union => switch (cur_ty.containerLayout(zcu)) { | |
| 462 | .@"union" => switch (cur_ty.containerLayout(zcu)) { | |
| 463 | 463 | .auto => unreachable, // ill-defined layout |
| 464 | 464 | .@"packed" => break, // let the bitcast logic handle this |
| 465 | 465 | .@"extern" => { |
| ... | ... | @@ -692,11 +692,11 @@ fn prepareComptimePtrStore( |
| 692 | 692 | |
| 693 | 693 | const agg_ty = agg_val.typeOf(zcu); |
| 694 | 694 | switch (agg_ty.zigTypeTag(zcu)) { |
| 695 | .Struct, .Pointer => break :strat .{ .direct = .{ | |
| 695 | .@"struct", .pointer => break :strat .{ .direct = .{ | |
| 696 | 696 | .val = try agg_val.elem(pt, sema.arena, @intCast(base_index.index)), |
| 697 | 697 | .alloc = alloc, |
| 698 | 698 | } }, |
| 699 | .Union => { | |
| 699 | .@"union" => { | |
| 700 | 700 | if (agg_val.* == .interned and Value.fromInterned(agg_val.interned).isUndef(zcu)) { |
| 701 | 701 | return .undef; |
| 702 | 702 | } |
| ... | ... | @@ -717,7 +717,7 @@ fn prepareComptimePtrStore( |
| 717 | 717 | }; |
| 718 | 718 | |
| 719 | 719 | if (ptr.byte_offset == 0) { |
| 720 | if (store_ty.zigTypeTag(zcu) != .Array or array_offset == 0) direct: { | |
| 720 | if (store_ty.zigTypeTag(zcu) != .array or array_offset == 0) direct: { | |
| 721 | 721 | const base_val_ty = switch (base_strat) { |
| 722 | 722 | .direct => |direct| direct.val.typeOf(zcu), |
| 723 | 723 | .index => |index| index.val.typeOf(zcu).childType(zcu), |
| ... | ... | @@ -770,7 +770,7 @@ fn prepareComptimePtrStore( |
| 770 | 770 | } |
| 771 | 771 | if (base_elem_offset + extra_base_index + store_count > val_count) return .{ .out_of_bounds = oob_ty }; |
| 772 | 772 | |
| 773 | if (store_ty.zigTypeTag(zcu) == .Array) { | |
| 773 | if (store_ty.zigTypeTag(zcu) == .array) { | |
| 774 | 774 | const skip = store_ty.childType(zcu).arrayBase(zcu)[1] * array_offset; |
| 775 | 775 | return .{ .flat_index = .{ |
| 776 | 776 | .alloc = base_strat.alloc(), |
| ... | ... | @@ -780,7 +780,7 @@ fn prepareComptimePtrStore( |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | // `base_val` must be an array, since otherwise the "direct reinterpret" logic above noticed it. |
| 783 | assert(base_val.typeOf(zcu).zigTypeTag(zcu) == .Array); | |
| 783 | assert(base_val.typeOf(zcu).zigTypeTag(zcu) == .array); | |
| 784 | 784 | |
| 785 | 785 | var index: u64 = base_elem_offset + extra_base_index; |
| 786 | 786 | const arr_val, const arr_index = (try recursiveIndex(sema, base_val, &index)).?; |
| ... | ... | @@ -816,7 +816,7 @@ fn prepareComptimePtrStore( |
| 816 | 816 | return .{ .needed_well_defined = cur_val.typeOf(zcu) }; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | if (store_ty.zigTypeTag(zcu) == .Array and array_offset > 0) { | |
| 819 | if (store_ty.zigTypeTag(zcu) == .array and array_offset > 0) { | |
| 820 | 820 | cur_offset += try store_ty.childType(zcu).abiSizeSema(pt) * array_offset; |
| 821 | 821 | } |
| 822 | 822 | |
| ... | ... | @@ -832,30 +832,30 @@ fn prepareComptimePtrStore( |
| 832 | 832 | while (true) { |
| 833 | 833 | const cur_ty = cur_val.typeOf(zcu); |
| 834 | 834 | switch (cur_ty.zigTypeTag(zcu)) { |
| 835 | .NoReturn, | |
| 836 | .Type, | |
| 837 | .ComptimeInt, | |
| 838 | .ComptimeFloat, | |
| 839 | .Null, | |
| 840 | .Undefined, | |
| 841 | .EnumLiteral, | |
| 842 | .Opaque, | |
| 843 | .Fn, | |
| 844 | .ErrorUnion, | |
| 835 | .noreturn, | |
| 836 | .type, | |
| 837 | .comptime_int, | |
| 838 | .comptime_float, | |
| 839 | .null, | |
| 840 | .undefined, | |
| 841 | .enum_literal, | |
| 842 | .@"opaque", | |
| 843 | .@"fn", | |
| 844 | .error_union, | |
| 845 | 845 | => unreachable, // ill-defined layout |
| 846 | .Int, | |
| 847 | .Float, | |
| 848 | .Bool, | |
| 849 | .Void, | |
| 850 | .Pointer, | |
| 851 | .ErrorSet, | |
| 852 | .AnyFrame, | |
| 853 | .Frame, | |
| 854 | .Enum, | |
| 855 | .Vector, | |
| 846 | .int, | |
| 847 | .float, | |
| 848 | .bool, | |
| 849 | .void, | |
| 850 | .pointer, | |
| 851 | .error_set, | |
| 852 | .@"anyframe", | |
| 853 | .frame, | |
| 854 | .@"enum", | |
| 855 | .vector, | |
| 856 | 856 | => break, // terminal types (no sub-values) |
| 857 | .Optional => break, // this can only be a pointer-like optional so is terminal | |
| 858 | .Array => { | |
| 857 | .optional => break, // this can only be a pointer-like optional so is terminal | |
| 858 | .array => { | |
| 859 | 859 | const elem_ty = cur_ty.childType(zcu); |
| 860 | 860 | const elem_size = try elem_ty.abiSizeSema(pt); |
| 861 | 861 | const elem_idx = cur_offset / elem_size; |
| ... | ... | @@ -868,7 +868,7 @@ fn prepareComptimePtrStore( |
| 868 | 868 | break; |
| 869 | 869 | } |
| 870 | 870 | }, |
| 871 | .Struct => switch (cur_ty.containerLayout(zcu)) { | |
| 871 | .@"struct" => switch (cur_ty.containerLayout(zcu)) { | |
| 872 | 872 | .auto => unreachable, // ill-defined layout |
| 873 | 873 | .@"packed" => break, // let the bitcast logic handle this |
| 874 | 874 | .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| { |
| ... | ... | @@ -881,7 +881,7 @@ fn prepareComptimePtrStore( |
| 881 | 881 | } |
| 882 | 882 | } else break, // pointer spans multiple fields |
| 883 | 883 | }, |
| 884 | .Union => switch (cur_ty.containerLayout(zcu)) { | |
| 884 | .@"union" => switch (cur_ty.containerLayout(zcu)) { | |
| 885 | 885 | .auto => unreachable, // ill-defined layout |
| 886 | 886 | .@"packed" => break, // let the bitcast logic handle this |
| 887 | 887 | .@"extern" => { |
| ... | ... | @@ -942,7 +942,7 @@ fn flattenArray( |
| 942 | 942 | return; |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | if (ty.zigTypeTag(zcu) != .Array) { | |
| 945 | if (ty.zigTypeTag(zcu) != .array) { | |
| 946 | 946 | out[@intCast(next_idx.*)] = (try val.intern(sema.pt, sema.arena)).toIntern(); |
| 947 | 947 | next_idx.* += 1; |
| 948 | 948 | return; |
| ... | ... | @@ -975,7 +975,7 @@ fn unflattenArray( |
| 975 | 975 | const zcu = sema.pt.zcu; |
| 976 | 976 | const arena = sema.arena; |
| 977 | 977 | |
| 978 | if (ty.zigTypeTag(zcu) != .Array) { | |
| 978 | if (ty.zigTypeTag(zcu) != .array) { | |
| 979 | 979 | const val = Value.fromInterned(elems[@intCast(next_idx.*)]); |
| 980 | 980 | next_idx.* += 1; |
| 981 | 981 | return sema.pt.getCoerced(val, ty); |
| ... | ... | @@ -1008,7 +1008,7 @@ fn recursiveIndex( |
| 1008 | 1008 | const pt = sema.pt; |
| 1009 | 1009 | |
| 1010 | 1010 | const ty = mv.typeOf(pt.zcu); |
| 1011 | assert(ty.zigTypeTag(pt.zcu) == .Array); | |
| 1011 | assert(ty.zigTypeTag(pt.zcu) == .array); | |
| 1012 | 1012 | |
| 1013 | 1013 | const ty_base_elems = ty.arrayBase(pt.zcu)[1]; |
| 1014 | 1014 | if (index.* >= ty_base_elems) { |
| ... | ... | @@ -1017,7 +1017,7 @@ fn recursiveIndex( |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | const elem_ty = ty.childType(pt.zcu); |
| 1020 | if (elem_ty.zigTypeTag(pt.zcu) != .Array) { | |
| 1020 | if (elem_ty.zigTypeTag(pt.zcu) != .array) { | |
| 1021 | 1021 | assert(index.* < ty.arrayLenIncludingSentinel(pt.zcu)); // should be handled by initial check |
| 1022 | 1022 | return .{ mv, index.* }; |
| 1023 | 1023 | } |
src/Type.zig+93-93| ... | ... | @@ -31,8 +31,8 @@ pub fn zigTypeTagOrPoison(ty: Type, zcu: *const Zcu) error{GenericPoison}!std.bu |
| 31 | 31 | |
| 32 | 32 | pub fn baseZigTypeTag(self: Type, mod: *Zcu) std.builtin.TypeId { |
| 33 | 33 | return switch (self.zigTypeTag(mod)) { |
| 34 | .ErrorUnion => self.errorUnionPayload(mod).baseZigTypeTag(mod), | |
| 35 | .Optional => { | |
| 34 | .error_union => self.errorUnionPayload(mod).baseZigTypeTag(mod), | |
| 35 | .optional => { | |
| 36 | 36 | return self.optionalChild(mod).baseZigTypeTag(mod); |
| 37 | 37 | }, |
| 38 | 38 | else => |t| t, |
| ... | ... | @@ -41,37 +41,37 @@ pub fn baseZigTypeTag(self: Type, mod: *Zcu) std.builtin.TypeId { |
| 41 | 41 | |
| 42 | 42 | pub fn isSelfComparable(ty: Type, zcu: *const Zcu, is_equality_cmp: bool) bool { |
| 43 | 43 | return switch (ty.zigTypeTag(zcu)) { |
| 44 | .Int, | |
| 45 | .Float, | |
| 46 | .ComptimeFloat, | |
| 47 | .ComptimeInt, | |
| 44 | .int, | |
| 45 | .float, | |
| 46 | .comptime_float, | |
| 47 | .comptime_int, | |
| 48 | 48 | => true, |
| 49 | 49 | |
| 50 | .Vector => ty.elemType2(zcu).isSelfComparable(zcu, is_equality_cmp), | |
| 51 | ||
| 52 | .Bool, | |
| 53 | .Type, | |
| 54 | .Void, | |
| 55 | .ErrorSet, | |
| 56 | .Fn, | |
| 57 | .Opaque, | |
| 58 | .AnyFrame, | |
| 59 | .Enum, | |
| 60 | .EnumLiteral, | |
| 50 | .vector => ty.elemType2(zcu).isSelfComparable(zcu, is_equality_cmp), | |
| 51 | ||
| 52 | .bool, | |
| 53 | .type, | |
| 54 | .void, | |
| 55 | .error_set, | |
| 56 | .@"fn", | |
| 57 | .@"opaque", | |
| 58 | .@"anyframe", | |
| 59 | .@"enum", | |
| 60 | .enum_literal, | |
| 61 | 61 | => is_equality_cmp, |
| 62 | 62 | |
| 63 | .NoReturn, | |
| 64 | .Array, | |
| 65 | .Struct, | |
| 66 | .Undefined, | |
| 67 | .Null, | |
| 68 | .ErrorUnion, | |
| 69 | .Union, | |
| 70 | .Frame, | |
| 63 | .noreturn, | |
| 64 | .array, | |
| 65 | .@"struct", | |
| 66 | .undefined, | |
| 67 | .null, | |
| 68 | .error_union, | |
| 69 | .@"union", | |
| 70 | .frame, | |
| 71 | 71 | => false, |
| 72 | 72 | |
| 73 | .Pointer => !ty.isSlice(zcu) and (is_equality_cmp or ty.isCPtr(zcu)), | |
| 74 | .Optional => { | |
| 73 | .pointer => !ty.isSlice(zcu) and (is_equality_cmp or ty.isCPtr(zcu)), | |
| 74 | .optional => { | |
| 75 | 75 | if (!is_equality_cmp) return false; |
| 76 | 76 | return ty.optionalChild(zcu).isSelfComparable(zcu, is_equality_cmp); |
| 77 | 77 | }, |
| ... | ... | @@ -80,9 +80,9 @@ pub fn isSelfComparable(ty: Type, zcu: *const Zcu, is_equality_cmp: bool) bool { |
| 80 | 80 | |
| 81 | 81 | /// If it is a function pointer, returns the function type. Otherwise returns null. |
| 82 | 82 | pub fn castPtrToFn(ty: Type, zcu: *const Zcu) ?Type { |
| 83 | if (ty.zigTypeTag(zcu) != .Pointer) return null; | |
| 83 | if (ty.zigTypeTag(zcu) != .pointer) return null; | |
| 84 | 84 | const elem_ty = ty.childType(zcu); |
| 85 | if (elem_ty.zigTypeTag(zcu) != .Fn) return null; | |
| 85 | if (elem_ty.zigTypeTag(zcu) != .@"fn") return null; | |
| 86 | 86 | return elem_ty; |
| 87 | 87 | } |
| 88 | 88 | |
| ... | ... | @@ -267,7 +267,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error |
| 267 | 267 | }, |
| 268 | 268 | .inferred_error_set_type => |func_index| { |
| 269 | 269 | const func_nav = ip.getNav(zcu.funcInfo(func_index).owner_nav); |
| 270 | try writer.print("@typeInfo(@typeInfo(@TypeOf({})).Fn.return_type.?).ErrorUnion.error_set", .{ | |
| 270 | try writer.print("@typeInfo(@typeInfo(@TypeOf({})).@\"fn\".return_type.?).error_union.error_set", .{ | |
| 271 | 271 | func_nav.fqn.fmt(ip), |
| 272 | 272 | }); |
| 273 | 273 | }, |
| ... | ... | @@ -796,7 +796,7 @@ pub fn fnHasRuntimeBitsInner( |
| 796 | 796 | |
| 797 | 797 | pub fn isFnOrHasRuntimeBits(ty: Type, zcu: *Zcu) bool { |
| 798 | 798 | switch (ty.zigTypeTag(zcu)) { |
| 799 | .Fn => return ty.fnHasRuntimeBits(zcu), | |
| 799 | .@"fn" => return ty.fnHasRuntimeBits(zcu), | |
| 800 | 800 | else => return ty.hasRuntimeBits(zcu), |
| 801 | 801 | } |
| 802 | 802 | } |
| ... | ... | @@ -804,7 +804,7 @@ pub fn isFnOrHasRuntimeBits(ty: Type, zcu: *Zcu) bool { |
| 804 | 804 | /// Same as `isFnOrHasRuntimeBits` but comptime-only types may return a false positive. |
| 805 | 805 | pub fn isFnOrHasRuntimeBitsIgnoreComptime(ty: Type, zcu: *Zcu) bool { |
| 806 | 806 | return switch (ty.zigTypeTag(zcu)) { |
| 807 | .Fn => true, | |
| 807 | .@"fn" => true, | |
| 808 | 808 | else => return ty.hasRuntimeBitsIgnoreComptime(zcu), |
| 809 | 809 | }; |
| 810 | 810 | } |
| ... | ... | @@ -1216,9 +1216,9 @@ fn abiAlignmentInnerOptional( |
| 1216 | 1216 | const child_type = ty.optionalChild(zcu); |
| 1217 | 1217 | |
| 1218 | 1218 | switch (child_type.zigTypeTag(zcu)) { |
| 1219 | .Pointer => return .{ .scalar = ptrAbiAlignment(target) }, | |
| 1220 | .ErrorSet => return Type.anyerror.abiAlignmentInner(strat, zcu, tid), | |
| 1221 | .NoReturn => return .{ .scalar = .@"1" }, | |
| 1219 | .pointer => return .{ .scalar = ptrAbiAlignment(target) }, | |
| 1220 | .error_set => return Type.anyerror.abiAlignmentInner(strat, zcu, tid), | |
| 1221 | .noreturn => return .{ .scalar = .@"1" }, | |
| 1222 | 1222 | else => {}, |
| 1223 | 1223 | } |
| 1224 | 1224 | |
| ... | ... | @@ -2053,7 +2053,7 @@ pub fn elemType2(ty: Type, zcu: *const Zcu) Type { |
| 2053 | 2053 | |
| 2054 | 2054 | fn shallowElemType(child_ty: Type, zcu: *const Zcu) Type { |
| 2055 | 2055 | return switch (child_ty.zigTypeTag(zcu)) { |
| 2056 | .Array, .Vector => child_ty.childType(zcu), | |
| 2056 | .array, .vector => child_ty.childType(zcu), | |
| 2057 | 2057 | else => child_ty, |
| 2058 | 2058 | }; |
| 2059 | 2059 | } |
| ... | ... | @@ -2061,7 +2061,7 @@ fn shallowElemType(child_ty: Type, zcu: *const Zcu) Type { |
| 2061 | 2061 | /// For vectors, returns the element type. Otherwise returns self. |
| 2062 | 2062 | pub fn scalarType(ty: Type, zcu: *const Zcu) Type { |
| 2063 | 2063 | return switch (ty.zigTypeTag(zcu)) { |
| 2064 | .Vector => ty.childType(zcu), | |
| 2064 | .vector => ty.childType(zcu), | |
| 2065 | 2065 | else => ty, |
| 2066 | 2066 | }; |
| 2067 | 2067 | } |
| ... | ... | @@ -2217,7 +2217,7 @@ pub fn isAnyError(ty: Type, zcu: *const Zcu) bool { |
| 2217 | 2217 | |
| 2218 | 2218 | pub fn isError(ty: Type, zcu: *const Zcu) bool { |
| 2219 | 2219 | return switch (ty.zigTypeTag(zcu)) { |
| 2220 | .ErrorUnion, .ErrorSet => true, | |
| 2220 | .error_union, .error_set => true, | |
| 2221 | 2221 | else => false, |
| 2222 | 2222 | }; |
| 2223 | 2223 | } |
| ... | ... | @@ -2341,8 +2341,8 @@ pub fn isUnsignedInt(ty: Type, zcu: *const Zcu) bool { |
| 2341 | 2341 | /// If this function returns true, then intInfo() can be called on the type. |
| 2342 | 2342 | pub fn isAbiInt(ty: Type, zcu: *const Zcu) bool { |
| 2343 | 2343 | return switch (ty.zigTypeTag(zcu)) { |
| 2344 | .Int, .Enum, .ErrorSet => true, | |
| 2345 | .Struct => ty.containerLayout(zcu) == .@"packed", | |
| 2344 | .int, .@"enum", .error_set => true, | |
| 2345 | .@"struct" => ty.containerLayout(zcu) == .@"packed", | |
| 2346 | 2346 | else => false, |
| 2347 | 2347 | }; |
| 2348 | 2348 | } |
| ... | ... | @@ -2494,14 +2494,14 @@ pub fn fnCallingConvention(ty: Type, zcu: *const Zcu) std.builtin.CallingConvent |
| 2494 | 2494 | |
| 2495 | 2495 | pub fn isValidParamType(self: Type, zcu: *const Zcu) bool { |
| 2496 | 2496 | return switch (self.zigTypeTagOrPoison(zcu) catch return true) { |
| 2497 | .Opaque, .NoReturn => false, | |
| 2497 | .@"opaque", .noreturn => false, | |
| 2498 | 2498 | else => true, |
| 2499 | 2499 | }; |
| 2500 | 2500 | } |
| 2501 | 2501 | |
| 2502 | 2502 | pub fn isValidReturnType(self: Type, zcu: *const Zcu) bool { |
| 2503 | 2503 | return switch (self.zigTypeTagOrPoison(zcu) catch return true) { |
| 2504 | .Opaque => false, | |
| 2504 | .@"opaque" => false, | |
| 2505 | 2505 | else => true, |
| 2506 | 2506 | }; |
| 2507 | 2507 | } |
| ... | ... | @@ -2782,8 +2782,8 @@ pub fn comptimeOnlyInner( |
| 2782 | 2782 | .ptr_type => |ptr_type| { |
| 2783 | 2783 | const child_ty = Type.fromInterned(ptr_type.child); |
| 2784 | 2784 | switch (child_ty.zigTypeTag(zcu)) { |
| 2785 | .Fn => return !try child_ty.fnHasRuntimeBitsInner(strat, zcu, tid), | |
| 2786 | .Opaque => return false, | |
| 2785 | .@"fn" => return !try child_ty.fnHasRuntimeBitsInner(strat, zcu, tid), | |
| 2786 | .@"opaque" => return false, | |
| 2787 | 2787 | else => return child_ty.comptimeOnlyInner(strat, zcu, tid), |
| 2788 | 2788 | } |
| 2789 | 2789 | }, |
| ... | ... | @@ -2954,7 +2954,7 @@ pub fn comptimeOnlyInner( |
| 2954 | 2954 | } |
| 2955 | 2955 | |
| 2956 | 2956 | pub fn isVector(ty: Type, zcu: *const Zcu) bool { |
| 2957 | return ty.zigTypeTag(zcu) == .Vector; | |
| 2957 | return ty.zigTypeTag(zcu) == .vector; | |
| 2958 | 2958 | } |
| 2959 | 2959 | |
| 2960 | 2960 | /// Returns 0 if not a vector, otherwise returns @bitSizeOf(Element) * vector_len. |
| ... | ... | @@ -2966,40 +2966,40 @@ pub fn totalVectorBits(ty: Type, zcu: *Zcu) u64 { |
| 2966 | 2966 | |
| 2967 | 2967 | pub fn isArrayOrVector(ty: Type, zcu: *const Zcu) bool { |
| 2968 | 2968 | return switch (ty.zigTypeTag(zcu)) { |
| 2969 | .Array, .Vector => true, | |
| 2969 | .array, .vector => true, | |
| 2970 | 2970 | else => false, |
| 2971 | 2971 | }; |
| 2972 | 2972 | } |
| 2973 | 2973 | |
| 2974 | 2974 | pub fn isIndexable(ty: Type, zcu: *const Zcu) bool { |
| 2975 | 2975 | return switch (ty.zigTypeTag(zcu)) { |
| 2976 | .Array, .Vector => true, | |
| 2977 | .Pointer => switch (ty.ptrSize(zcu)) { | |
| 2976 | .array, .vector => true, | |
| 2977 | .pointer => switch (ty.ptrSize(zcu)) { | |
| 2978 | 2978 | .Slice, .Many, .C => true, |
| 2979 | 2979 | .One => switch (ty.childType(zcu).zigTypeTag(zcu)) { |
| 2980 | .Array, .Vector => true, | |
| 2981 | .Struct => ty.childType(zcu).isTuple(zcu), | |
| 2980 | .array, .vector => true, | |
| 2981 | .@"struct" => ty.childType(zcu).isTuple(zcu), | |
| 2982 | 2982 | else => false, |
| 2983 | 2983 | }, |
| 2984 | 2984 | }, |
| 2985 | .Struct => ty.isTuple(zcu), | |
| 2985 | .@"struct" => ty.isTuple(zcu), | |
| 2986 | 2986 | else => false, |
| 2987 | 2987 | }; |
| 2988 | 2988 | } |
| 2989 | 2989 | |
| 2990 | 2990 | pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool { |
| 2991 | 2991 | return switch (ty.zigTypeTag(zcu)) { |
| 2992 | .Array, .Vector => true, | |
| 2993 | .Pointer => switch (ty.ptrSize(zcu)) { | |
| 2992 | .array, .vector => true, | |
| 2993 | .pointer => switch (ty.ptrSize(zcu)) { | |
| 2994 | 2994 | .Many, .C => false, |
| 2995 | 2995 | .Slice => true, |
| 2996 | 2996 | .One => switch (ty.childType(zcu).zigTypeTag(zcu)) { |
| 2997 | .Array, .Vector => true, | |
| 2998 | .Struct => ty.childType(zcu).isTuple(zcu), | |
| 2997 | .array, .vector => true, | |
| 2998 | .@"struct" => ty.childType(zcu).isTuple(zcu), | |
| 2999 | 2999 | else => false, |
| 3000 | 3000 | }, |
| 3001 | 3001 | }, |
| 3002 | .Struct => ty.isTuple(zcu), | |
| 3002 | .@"struct" => ty.isTuple(zcu), | |
| 3003 | 3003 | else => false, |
| 3004 | 3004 | }; |
| 3005 | 3005 | } |
| ... | ... | @@ -3030,7 +3030,7 @@ pub fn getParentNamespace(ty: Type, zcu: *Zcu) InternPool.OptionalNamespaceIndex |
| 3030 | 3030 | pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3031 | 3031 | const zcu = pt.zcu; |
| 3032 | 3032 | const scalar = try minIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu)); |
| 3033 | return if (ty.zigTypeTag(zcu) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ | |
| 3033 | return if (ty.zigTypeTag(zcu) == .vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ | |
| 3034 | 3034 | .ty = dest_ty.toIntern(), |
| 3035 | 3035 | .storage = .{ .repeated_elem = scalar.toIntern() }, |
| 3036 | 3036 | } })) else scalar; |
| ... | ... | @@ -3061,7 +3061,7 @@ pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3061 | 3061 | pub fn maxInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3062 | 3062 | const zcu = pt.zcu; |
| 3063 | 3063 | const scalar = try maxIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu)); |
| 3064 | return if (ty.zigTypeTag(zcu) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ | |
| 3064 | return if (ty.zigTypeTag(zcu) == .vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ | |
| 3065 | 3065 | .ty = dest_ty.toIntern(), |
| 3066 | 3066 | .storage = .{ .repeated_elem = scalar.toIntern() }, |
| 3067 | 3067 | } })) else scalar; |
| ... | ... | @@ -3539,8 +3539,8 @@ pub fn isSimpleTupleOrAnonStruct(ty: Type, zcu: *const Zcu) bool { |
| 3539 | 3539 | pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type { |
| 3540 | 3540 | var cur = ty; |
| 3541 | 3541 | while (true) switch (cur.zigTypeTag(zcu)) { |
| 3542 | .Optional => cur = cur.optionalChild(zcu), | |
| 3543 | .ErrorUnion => cur = cur.errorUnionPayload(zcu), | |
| 3542 | .optional => cur = cur.optionalChild(zcu), | |
| 3543 | .error_union => cur = cur.errorUnionPayload(zcu), | |
| 3544 | 3544 | else => return cur, |
| 3545 | 3545 | }; |
| 3546 | 3546 | } |
| ... | ... | @@ -3548,8 +3548,8 @@ pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type { |
| 3548 | 3548 | pub fn toUnsigned(ty: Type, pt: Zcu.PerThread) !Type { |
| 3549 | 3549 | const zcu = pt.zcu; |
| 3550 | 3550 | return switch (ty.zigTypeTag(zcu)) { |
| 3551 | .Int => pt.intType(.unsigned, ty.intInfo(zcu).bits), | |
| 3552 | .Vector => try pt.vectorType(.{ | |
| 3551 | .int => pt.intType(.unsigned, ty.intInfo(zcu).bits), | |
| 3552 | .vector => try pt.vectorType(.{ | |
| 3553 | 3553 | .len = ty.vectorLen(zcu), |
| 3554 | 3554 | .child = (try ty.childType(zcu).toUnsigned(pt)).toIntern(), |
| 3555 | 3555 | }), |
| ... | ... | @@ -3625,7 +3625,7 @@ pub fn getCaptures(ty: Type, zcu: *const Zcu) InternPool.CaptureValue.Slice { |
| 3625 | 3625 | pub fn arrayBase(ty: Type, zcu: *const Zcu) struct { Type, u64 } { |
| 3626 | 3626 | var cur_ty: Type = ty; |
| 3627 | 3627 | var cur_len: u64 = 1; |
| 3628 | while (cur_ty.zigTypeTag(zcu) == .Array) { | |
| 3628 | while (cur_ty.zigTypeTag(zcu) == .array) { | |
| 3629 | 3629 | cur_len *= cur_ty.arrayLenIncludingSentinel(zcu); |
| 3630 | 3630 | cur_ty = cur_ty.childType(zcu); |
| 3631 | 3631 | } |
| ... | ... | @@ -3692,7 +3692,7 @@ pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3692 | 3692 | const zcu = pt.zcu; |
| 3693 | 3693 | const ip = &zcu.intern_pool; |
| 3694 | 3694 | switch (ty.zigTypeTag(zcu)) { |
| 3695 | .Struct => switch (ip.indexToKey(ty.toIntern())) { | |
| 3695 | .@"struct" => switch (ip.indexToKey(ty.toIntern())) { | |
| 3696 | 3696 | .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| { |
| 3697 | 3697 | const field_ty = Type.fromInterned(anon_struct_type.types.get(ip)[i]); |
| 3698 | 3698 | try field_ty.resolveLayout(pt); |
| ... | ... | @@ -3700,21 +3700,21 @@ pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3700 | 3700 | .struct_type => return ty.resolveStructInner(pt, .layout), |
| 3701 | 3701 | else => unreachable, |
| 3702 | 3702 | }, |
| 3703 | .Union => return ty.resolveUnionInner(pt, .layout), | |
| 3704 | .Array => { | |
| 3703 | .@"union" => return ty.resolveUnionInner(pt, .layout), | |
| 3704 | .array => { | |
| 3705 | 3705 | if (ty.arrayLenIncludingSentinel(zcu) == 0) return; |
| 3706 | 3706 | const elem_ty = ty.childType(zcu); |
| 3707 | 3707 | return elem_ty.resolveLayout(pt); |
| 3708 | 3708 | }, |
| 3709 | .Optional => { | |
| 3709 | .optional => { | |
| 3710 | 3710 | const payload_ty = ty.optionalChild(zcu); |
| 3711 | 3711 | return payload_ty.resolveLayout(pt); |
| 3712 | 3712 | }, |
| 3713 | .ErrorUnion => { | |
| 3713 | .error_union => { | |
| 3714 | 3714 | const payload_ty = ty.errorUnionPayload(zcu); |
| 3715 | 3715 | return payload_ty.resolveLayout(pt); |
| 3716 | 3716 | }, |
| 3717 | .Fn => { | |
| 3717 | .@"fn" => { | |
| 3718 | 3718 | const info = zcu.typeToFunc(ty).?; |
| 3719 | 3719 | if (info.is_generic) { |
| 3720 | 3720 | // Resolving of generic function types is deferred to when |
| ... | ... | @@ -3830,30 +3830,30 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3830 | 3830 | const ip = &zcu.intern_pool; |
| 3831 | 3831 | |
| 3832 | 3832 | switch (ty.zigTypeTag(zcu)) { |
| 3833 | .Type, | |
| 3834 | .Void, | |
| 3835 | .Bool, | |
| 3836 | .NoReturn, | |
| 3837 | .Int, | |
| 3838 | .Float, | |
| 3839 | .ComptimeFloat, | |
| 3840 | .ComptimeInt, | |
| 3841 | .Undefined, | |
| 3842 | .Null, | |
| 3843 | .ErrorSet, | |
| 3844 | .Enum, | |
| 3845 | .Opaque, | |
| 3846 | .Frame, | |
| 3847 | .AnyFrame, | |
| 3848 | .Vector, | |
| 3849 | .EnumLiteral, | |
| 3833 | .type, | |
| 3834 | .void, | |
| 3835 | .bool, | |
| 3836 | .noreturn, | |
| 3837 | .int, | |
| 3838 | .float, | |
| 3839 | .comptime_float, | |
| 3840 | .comptime_int, | |
| 3841 | .undefined, | |
| 3842 | .null, | |
| 3843 | .error_set, | |
| 3844 | .@"enum", | |
| 3845 | .@"opaque", | |
| 3846 | .frame, | |
| 3847 | .@"anyframe", | |
| 3848 | .vector, | |
| 3849 | .enum_literal, | |
| 3850 | 3850 | => {}, |
| 3851 | 3851 | |
| 3852 | .Pointer => return ty.childType(zcu).resolveFully(pt), | |
| 3853 | .Array => return ty.childType(zcu).resolveFully(pt), | |
| 3854 | .Optional => return ty.optionalChild(zcu).resolveFully(pt), | |
| 3855 | .ErrorUnion => return ty.errorUnionPayload(zcu).resolveFully(pt), | |
| 3856 | .Fn => { | |
| 3852 | .pointer => return ty.childType(zcu).resolveFully(pt), | |
| 3853 | .array => return ty.childType(zcu).resolveFully(pt), | |
| 3854 | .optional => return ty.optionalChild(zcu).resolveFully(pt), | |
| 3855 | .error_union => return ty.errorUnionPayload(zcu).resolveFully(pt), | |
| 3856 | .@"fn" => { | |
| 3857 | 3857 | const info = zcu.typeToFunc(ty).?; |
| 3858 | 3858 | if (info.is_generic) return; |
| 3859 | 3859 | for (0..info.param_types.len) |i| { |
| ... | ... | @@ -3863,7 +3863,7 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3863 | 3863 | try Type.fromInterned(info.return_type).resolveFully(pt); |
| 3864 | 3864 | }, |
| 3865 | 3865 | |
| 3866 | .Struct => switch (ip.indexToKey(ty.toIntern())) { | |
| 3866 | .@"struct" => switch (ip.indexToKey(ty.toIntern())) { | |
| 3867 | 3867 | .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| { |
| 3868 | 3868 | const field_ty = Type.fromInterned(anon_struct_type.types.get(ip)[i]); |
| 3869 | 3869 | try field_ty.resolveFully(pt); |
| ... | ... | @@ -3871,7 +3871,7 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3871 | 3871 | .struct_type => return ty.resolveStructInner(pt, .full), |
| 3872 | 3872 | else => unreachable, |
| 3873 | 3873 | }, |
| 3874 | .Union => return ty.resolveUnionInner(pt, .full), | |
| 3874 | .@"union" => return ty.resolveUnionInner(pt, .full), | |
| 3875 | 3875 | } |
| 3876 | 3876 | } |
| 3877 | 3877 |
src/Value.zig+130-130| ... | ... | @@ -64,7 +64,7 @@ pub fn fmtValueSemaFull(ctx: print_value.FormatContext) std.fmt.Formatter(print_ |
| 64 | 64 | /// Asserts `val` is an array of `u8` |
| 65 | 65 | pub fn toIpString(val: Value, ty: Type, pt: Zcu.PerThread) !InternPool.NullTerminatedString { |
| 66 | 66 | const zcu = pt.zcu; |
| 67 | assert(ty.zigTypeTag(zcu) == .Array); | |
| 67 | assert(ty.zigTypeTag(zcu) == .array); | |
| 68 | 68 | assert(ty.childType(zcu).toIntern() == .u8_type); |
| 69 | 69 | const ip = &zcu.intern_pool; |
| 70 | 70 | switch (zcu.intern_pool.indexToKey(val.toIntern()).aggregate.storage) { |
| ... | ... | @@ -349,12 +349,12 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{ |
| 349 | 349 | return; |
| 350 | 350 | } |
| 351 | 351 | switch (ty.zigTypeTag(zcu)) { |
| 352 | .Void => {}, | |
| 353 | .Bool => { | |
| 352 | .void => {}, | |
| 353 | .bool => { | |
| 354 | 354 | buffer[0] = @intFromBool(val.toBool()); |
| 355 | 355 | }, |
| 356 | .Int, .Enum, .ErrorSet, .Pointer => |tag| { | |
| 357 | const int_ty = if (tag == .Pointer) int_ty: { | |
| 356 | .int, .@"enum", .error_set, .pointer => |tag| { | |
| 357 | const int_ty = if (tag == .pointer) int_ty: { | |
| 358 | 358 | if (ty.isSlice(zcu)) return error.IllDefinedMemoryLayout; |
| 359 | 359 | if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef; |
| 360 | 360 | break :int_ty Type.usize; |
| ... | ... | @@ -367,7 +367,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{ |
| 367 | 367 | const bigint = val.toBigInt(&bigint_buffer, zcu); |
| 368 | 368 | bigint.writeTwosComplement(buffer[0..byte_count], endian); |
| 369 | 369 | }, |
| 370 | .Float => switch (ty.floatBits(target)) { | |
| 370 | .float => switch (ty.floatBits(target)) { | |
| 371 | 371 | 16 => std.mem.writeInt(u16, buffer[0..2], @bitCast(val.toFloat(f16, zcu)), endian), |
| 372 | 372 | 32 => std.mem.writeInt(u32, buffer[0..4], @bitCast(val.toFloat(f32, zcu)), endian), |
| 373 | 373 | 64 => std.mem.writeInt(u64, buffer[0..8], @bitCast(val.toFloat(f64, zcu)), endian), |
| ... | ... | @@ -375,7 +375,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{ |
| 375 | 375 | 128 => std.mem.writeInt(u128, buffer[0..16], @bitCast(val.toFloat(f128, zcu)), endian), |
| 376 | 376 | else => unreachable, |
| 377 | 377 | }, |
| 378 | .Array => { | |
| 378 | .array => { | |
| 379 | 379 | const len = ty.arrayLen(zcu); |
| 380 | 380 | const elem_ty = ty.childType(zcu); |
| 381 | 381 | const elem_size: usize = @intCast(elem_ty.abiSize(zcu)); |
| ... | ... | @@ -387,13 +387,13 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{ |
| 387 | 387 | buf_off += elem_size; |
| 388 | 388 | } |
| 389 | 389 | }, |
| 390 | .Vector => { | |
| 390 | .vector => { | |
| 391 | 391 | // We use byte_count instead of abi_size here, so that any padding bytes |
| 392 | 392 | // follow the data bytes, on both big- and little-endian systems. |
| 393 | 393 | const byte_count = (@as(usize, @intCast(ty.bitSize(zcu))) + 7) / 8; |
| 394 | 394 | return writeToPackedMemory(val, ty, pt, buffer[0..byte_count], 0); |
| 395 | 395 | }, |
| 396 | .Struct => { | |
| 396 | .@"struct" => { | |
| 397 | 397 | const struct_type = zcu.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout; |
| 398 | 398 | switch (struct_type.layout) { |
| 399 | 399 | .auto => return error.IllDefinedMemoryLayout, |
| ... | ... | @@ -415,7 +415,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{ |
| 415 | 415 | }, |
| 416 | 416 | } |
| 417 | 417 | }, |
| 418 | .Union => switch (ty.containerLayout(zcu)) { | |
| 418 | .@"union" => switch (ty.containerLayout(zcu)) { | |
| 419 | 419 | .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already |
| 420 | 420 | .@"extern" => { |
| 421 | 421 | if (val.unionTag(zcu)) |union_tag| { |
| ... | ... | @@ -437,7 +437,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{ |
| 437 | 437 | return writeToPackedMemory(val, ty, pt, buffer[0..byte_count], 0); |
| 438 | 438 | }, |
| 439 | 439 | }, |
| 440 | .Optional => { | |
| 440 | .optional => { | |
| 441 | 441 | if (!ty.isPtrLikeOptional(zcu)) return error.IllDefinedMemoryLayout; |
| 442 | 442 | const opt_val = val.optionalValue(zcu); |
| 443 | 443 | if (opt_val) |some| { |
| ... | ... | @@ -473,8 +473,8 @@ pub fn writeToPackedMemory( |
| 473 | 473 | return; |
| 474 | 474 | } |
| 475 | 475 | switch (ty.zigTypeTag(zcu)) { |
| 476 | .Void => {}, | |
| 477 | .Bool => { | |
| 476 | .void => {}, | |
| 477 | .bool => { | |
| 478 | 478 | const byte_index = switch (endian) { |
| 479 | 479 | .little => bit_offset / 8, |
| 480 | 480 | .big => buffer.len - bit_offset / 8 - 1, |
| ... | ... | @@ -485,7 +485,7 @@ pub fn writeToPackedMemory( |
| 485 | 485 | buffer[byte_index] &= ~(@as(u8, 1) << @as(u3, @intCast(bit_offset % 8))); |
| 486 | 486 | } |
| 487 | 487 | }, |
| 488 | .Int, .Enum => { | |
| 488 | .int, .@"enum" => { | |
| 489 | 489 | if (buffer.len == 0) return; |
| 490 | 490 | const bits = ty.intInfo(zcu).bits; |
| 491 | 491 | if (bits == 0) return; |
| ... | ... | @@ -503,7 +503,7 @@ pub fn writeToPackedMemory( |
| 503 | 503 | }, |
| 504 | 504 | } |
| 505 | 505 | }, |
| 506 | .Float => switch (ty.floatBits(target)) { | |
| 506 | .float => switch (ty.floatBits(target)) { | |
| 507 | 507 | 16 => std.mem.writePackedInt(u16, buffer, bit_offset, @bitCast(val.toFloat(f16, zcu)), endian), |
| 508 | 508 | 32 => std.mem.writePackedInt(u32, buffer, bit_offset, @bitCast(val.toFloat(f32, zcu)), endian), |
| 509 | 509 | 64 => std.mem.writePackedInt(u64, buffer, bit_offset, @bitCast(val.toFloat(f64, zcu)), endian), |
| ... | ... | @@ -511,7 +511,7 @@ pub fn writeToPackedMemory( |
| 511 | 511 | 128 => std.mem.writePackedInt(u128, buffer, bit_offset, @bitCast(val.toFloat(f128, zcu)), endian), |
| 512 | 512 | else => unreachable, |
| 513 | 513 | }, |
| 514 | .Vector => { | |
| 514 | .vector => { | |
| 515 | 515 | const elem_ty = ty.childType(zcu); |
| 516 | 516 | const elem_bit_size: u16 = @intCast(elem_ty.bitSize(zcu)); |
| 517 | 517 | const len: usize = @intCast(ty.arrayLen(zcu)); |
| ... | ... | @@ -526,7 +526,7 @@ pub fn writeToPackedMemory( |
| 526 | 526 | bits += elem_bit_size; |
| 527 | 527 | } |
| 528 | 528 | }, |
| 529 | .Struct => { | |
| 529 | .@"struct" => { | |
| 530 | 530 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 531 | 531 | // Sema is supposed to have emitted a compile error already in the case of Auto, |
| 532 | 532 | // and Extern is handled in non-packed writeToMemory. |
| ... | ... | @@ -544,7 +544,7 @@ pub fn writeToPackedMemory( |
| 544 | 544 | bits += field_bits; |
| 545 | 545 | } |
| 546 | 546 | }, |
| 547 | .Union => { | |
| 547 | .@"union" => { | |
| 548 | 548 | const union_obj = zcu.typeToUnion(ty).?; |
| 549 | 549 | switch (union_obj.flagsUnordered(ip).layout) { |
| 550 | 550 | .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory |
| ... | ... | @@ -561,12 +561,12 @@ pub fn writeToPackedMemory( |
| 561 | 561 | }, |
| 562 | 562 | } |
| 563 | 563 | }, |
| 564 | .Pointer => { | |
| 564 | .pointer => { | |
| 565 | 565 | assert(!ty.isSlice(zcu)); // No well defined layout. |
| 566 | 566 | if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef; |
| 567 | 567 | return val.writeToPackedMemory(Type.usize, pt, buffer, bit_offset); |
| 568 | 568 | }, |
| 569 | .Optional => { | |
| 569 | .optional => { | |
| 570 | 570 | assert(ty.isPtrLikeOptional(zcu)); |
| 571 | 571 | const child = ty.optionalChild(zcu); |
| 572 | 572 | const opt_val = val.optionalValue(zcu); |
| ... | ... | @@ -599,18 +599,18 @@ pub fn readFromMemory( |
| 599 | 599 | const target = zcu.getTarget(); |
| 600 | 600 | const endian = target.cpu.arch.endian(); |
| 601 | 601 | switch (ty.zigTypeTag(zcu)) { |
| 602 | .Void => return Value.void, | |
| 603 | .Bool => { | |
| 602 | .void => return Value.void, | |
| 603 | .bool => { | |
| 604 | 604 | if (buffer[0] == 0) { |
| 605 | 605 | return Value.false; |
| 606 | 606 | } else { |
| 607 | 607 | return Value.true; |
| 608 | 608 | } |
| 609 | 609 | }, |
| 610 | .Int, .Enum => |ty_tag| { | |
| 610 | .int, .@"enum" => |ty_tag| { | |
| 611 | 611 | const int_ty = switch (ty_tag) { |
| 612 | .Int => ty, | |
| 613 | .Enum => ty.intTagType(zcu), | |
| 612 | .int => ty, | |
| 613 | .@"enum" => ty.intTagType(zcu), | |
| 614 | 614 | else => unreachable, |
| 615 | 615 | }; |
| 616 | 616 | const int_info = int_ty.intInfo(zcu); |
| ... | ... | @@ -639,7 +639,7 @@ pub fn readFromMemory( |
| 639 | 639 | return zcu.getCoerced(try zcu.intValue_big(int_ty, bigint.toConst()), ty); |
| 640 | 640 | } |
| 641 | 641 | }, |
| 642 | .Float => return Value.fromInterned(try pt.intern(.{ .float = .{ | |
| 642 | .float => return Value.fromInterned(try pt.intern(.{ .float = .{ | |
| 643 | 643 | .ty = ty.toIntern(), |
| 644 | 644 | .storage = switch (ty.floatBits(target)) { |
| 645 | 645 | 16 => .{ .f16 = @bitCast(std.mem.readInt(u16, buffer[0..2], endian)) }, |
| ... | ... | @@ -650,7 +650,7 @@ pub fn readFromMemory( |
| 650 | 650 | else => unreachable, |
| 651 | 651 | }, |
| 652 | 652 | } })), |
| 653 | .Array => { | |
| 653 | .array => { | |
| 654 | 654 | const elem_ty = ty.childType(zcu); |
| 655 | 655 | const elem_size = elem_ty.abiSize(zcu); |
| 656 | 656 | const elems = try arena.alloc(InternPool.Index, @intCast(ty.arrayLen(zcu))); |
| ... | ... | @@ -664,13 +664,13 @@ pub fn readFromMemory( |
| 664 | 664 | .storage = .{ .elems = elems }, |
| 665 | 665 | } })); |
| 666 | 666 | }, |
| 667 | .Vector => { | |
| 667 | .vector => { | |
| 668 | 668 | // We use byte_count instead of abi_size here, so that any padding bytes |
| 669 | 669 | // follow the data bytes, on both big- and little-endian systems. |
| 670 | 670 | const byte_count = (@as(usize, @intCast(ty.bitSize(zcu))) + 7) / 8; |
| 671 | 671 | return readFromPackedMemory(ty, zcu, buffer[0..byte_count], 0, arena); |
| 672 | 672 | }, |
| 673 | .Struct => { | |
| 673 | .@"struct" => { | |
| 674 | 674 | const struct_type = zcu.typeToStruct(ty).?; |
| 675 | 675 | switch (struct_type.layout) { |
| 676 | 676 | .auto => unreachable, // Sema is supposed to have emitted a compile error already |
| ... | ... | @@ -694,7 +694,7 @@ pub fn readFromMemory( |
| 694 | 694 | }, |
| 695 | 695 | } |
| 696 | 696 | }, |
| 697 | .ErrorSet => { | |
| 697 | .error_set => { | |
| 698 | 698 | const bits = zcu.errorSetBits(); |
| 699 | 699 | const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8); |
| 700 | 700 | const int = std.mem.readVarInt(u64, buffer[0..byte_count], endian); |
| ... | ... | @@ -706,7 +706,7 @@ pub fn readFromMemory( |
| 706 | 706 | .name = name, |
| 707 | 707 | } })); |
| 708 | 708 | }, |
| 709 | .Union => switch (ty.containerLayout(zcu)) { | |
| 709 | .@"union" => switch (ty.containerLayout(zcu)) { | |
| 710 | 710 | .auto => return error.IllDefinedMemoryLayout, |
| 711 | 711 | .@"extern" => { |
| 712 | 712 | const union_size = ty.abiSize(zcu); |
| ... | ... | @@ -723,7 +723,7 @@ pub fn readFromMemory( |
| 723 | 723 | return readFromPackedMemory(ty, zcu, buffer[0..byte_count], 0, arena); |
| 724 | 724 | }, |
| 725 | 725 | }, |
| 726 | .Pointer => { | |
| 726 | .pointer => { | |
| 727 | 727 | assert(!ty.isSlice(zcu)); // No well defined layout. |
| 728 | 728 | const int_val = try readFromMemory(Type.usize, zcu, buffer, arena); |
| 729 | 729 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| ... | ... | @@ -732,7 +732,7 @@ pub fn readFromMemory( |
| 732 | 732 | .byte_offset = int_val.toUnsignedInt(zcu), |
| 733 | 733 | } })); |
| 734 | 734 | }, |
| 735 | .Optional => { | |
| 735 | .optional => { | |
| 736 | 736 | assert(ty.isPtrLikeOptional(zcu)); |
| 737 | 737 | const child_ty = ty.optionalChild(zcu); |
| 738 | 738 | const child_val = try readFromMemory(child_ty, zcu, buffer, arena); |
| ... | ... | @@ -768,8 +768,8 @@ pub fn readFromPackedMemory( |
| 768 | 768 | const target = zcu.getTarget(); |
| 769 | 769 | const endian = target.cpu.arch.endian(); |
| 770 | 770 | switch (ty.zigTypeTag(zcu)) { |
| 771 | .Void => return Value.void, | |
| 772 | .Bool => { | |
| 771 | .void => return Value.void, | |
| 772 | .bool => { | |
| 773 | 773 | const byte = switch (endian) { |
| 774 | 774 | .big => buffer[buffer.len - bit_offset / 8 - 1], |
| 775 | 775 | .little => buffer[bit_offset / 8], |
| ... | ... | @@ -780,7 +780,7 @@ pub fn readFromPackedMemory( |
| 780 | 780 | return Value.true; |
| 781 | 781 | } |
| 782 | 782 | }, |
| 783 | .Int => { | |
| 783 | .int => { | |
| 784 | 784 | if (buffer.len == 0) return pt.intValue(ty, 0); |
| 785 | 785 | const int_info = ty.intInfo(zcu); |
| 786 | 786 | const bits = int_info.bits; |
| ... | ... | @@ -804,12 +804,12 @@ pub fn readFromPackedMemory( |
| 804 | 804 | bigint.readPackedTwosComplement(buffer, bit_offset, bits, endian, int_info.signedness); |
| 805 | 805 | return pt.intValue_big(ty, bigint.toConst()); |
| 806 | 806 | }, |
| 807 | .Enum => { | |
| 807 | .@"enum" => { | |
| 808 | 808 | const int_ty = ty.intTagType(zcu); |
| 809 | 809 | const int_val = try Value.readFromPackedMemory(int_ty, pt, buffer, bit_offset, arena); |
| 810 | 810 | return pt.getCoerced(int_val, ty); |
| 811 | 811 | }, |
| 812 | .Float => return Value.fromInterned(try pt.intern(.{ .float = .{ | |
| 812 | .float => return Value.fromInterned(try pt.intern(.{ .float = .{ | |
| 813 | 813 | .ty = ty.toIntern(), |
| 814 | 814 | .storage = switch (ty.floatBits(target)) { |
| 815 | 815 | 16 => .{ .f16 = @bitCast(std.mem.readPackedInt(u16, buffer, bit_offset, endian)) }, |
| ... | ... | @@ -820,7 +820,7 @@ pub fn readFromPackedMemory( |
| 820 | 820 | else => unreachable, |
| 821 | 821 | }, |
| 822 | 822 | } })), |
| 823 | .Vector => { | |
| 823 | .vector => { | |
| 824 | 824 | const elem_ty = ty.childType(zcu); |
| 825 | 825 | const elems = try arena.alloc(InternPool.Index, @intCast(ty.arrayLen(zcu))); |
| 826 | 826 | |
| ... | ... | @@ -837,7 +837,7 @@ pub fn readFromPackedMemory( |
| 837 | 837 | .storage = .{ .elems = elems }, |
| 838 | 838 | } })); |
| 839 | 839 | }, |
| 840 | .Struct => { | |
| 840 | .@"struct" => { | |
| 841 | 841 | // Sema is supposed to have emitted a compile error already for Auto layout structs, |
| 842 | 842 | // and Extern is handled by non-packed readFromMemory. |
| 843 | 843 | const struct_type = zcu.typeToPackedStruct(ty).?; |
| ... | ... | @@ -854,7 +854,7 @@ pub fn readFromPackedMemory( |
| 854 | 854 | .storage = .{ .elems = field_vals }, |
| 855 | 855 | } })); |
| 856 | 856 | }, |
| 857 | .Union => switch (ty.containerLayout(zcu)) { | |
| 857 | .@"union" => switch (ty.containerLayout(zcu)) { | |
| 858 | 858 | .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory |
| 859 | 859 | .@"packed" => { |
| 860 | 860 | const backing_ty = try ty.unionBackingType(pt); |
| ... | ... | @@ -866,7 +866,7 @@ pub fn readFromPackedMemory( |
| 866 | 866 | } })); |
| 867 | 867 | }, |
| 868 | 868 | }, |
| 869 | .Pointer => { | |
| 869 | .pointer => { | |
| 870 | 870 | assert(!ty.isSlice(zcu)); // No well defined layout. |
| 871 | 871 | const int_val = try readFromPackedMemory(Type.usize, pt, buffer, bit_offset, arena); |
| 872 | 872 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| ... | ... | @@ -875,7 +875,7 @@ pub fn readFromPackedMemory( |
| 875 | 875 | .byte_offset = int_val.toUnsignedInt(zcu), |
| 876 | 876 | } })); |
| 877 | 877 | }, |
| 878 | .Optional => { | |
| 878 | .optional => { | |
| 879 | 879 | assert(ty.isPtrLikeOptional(zcu)); |
| 880 | 880 | const child_ty = ty.optionalChild(zcu); |
| 881 | 881 | const child_val = try readFromPackedMemory(child_ty, pt, buffer, bit_offset, arena); |
| ... | ... | @@ -1155,7 +1155,7 @@ pub fn compareHeteroAdvanced( |
| 1155 | 1155 | /// For vectors, returns true if comparison is true for ALL elements. |
| 1156 | 1156 | pub fn compareAll(lhs: Value, op: std.math.CompareOperator, rhs: Value, ty: Type, pt: Zcu.PerThread) !bool { |
| 1157 | 1157 | const zcu = pt.zcu; |
| 1158 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 1158 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 1159 | 1159 | const scalar_ty = ty.scalarType(zcu); |
| 1160 | 1160 | for (0..ty.vectorLen(zcu)) |i| { |
| 1161 | 1161 | const lhs_elem = try lhs.elemValue(pt, i); |
| ... | ... | @@ -1519,7 +1519,7 @@ pub fn floatFromIntAdvanced( |
| 1519 | 1519 | comptime strat: ResolveStrat, |
| 1520 | 1520 | ) !Value { |
| 1521 | 1521 | const zcu = pt.zcu; |
| 1522 | if (int_ty.zigTypeTag(zcu) == .Vector) { | |
| 1522 | if (int_ty.zigTypeTag(zcu) == .vector) { | |
| 1523 | 1523 | const result_data = try arena.alloc(InternPool.Index, int_ty.vectorLen(zcu)); |
| 1524 | 1524 | const scalar_ty = float_ty.scalarType(zcu); |
| 1525 | 1525 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -1573,7 +1573,7 @@ fn calcLimbLenFloat(scalar: anytype) usize { |
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | 1575 | const w_value = @abs(scalar); |
| 1576 | return @divFloor(@as(std.math.big.Limb, @intFromFloat(std.math.log2(w_value))), @typeInfo(std.math.big.Limb).Int.bits) + 1; | |
| 1576 | return @divFloor(@as(std.math.big.Limb, @intFromFloat(std.math.log2(w_value))), @typeInfo(std.math.big.Limb).int.bits) + 1; | |
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | 1579 | pub const OverflowArithmeticResult = struct { |
| ... | ... | @@ -1589,7 +1589,7 @@ pub fn intAddSat( |
| 1589 | 1589 | arena: Allocator, |
| 1590 | 1590 | pt: Zcu.PerThread, |
| 1591 | 1591 | ) !Value { |
| 1592 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 1592 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 1593 | 1593 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 1594 | 1594 | const scalar_ty = ty.scalarType(pt.zcu); |
| 1595 | 1595 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -1640,7 +1640,7 @@ pub fn intSubSat( |
| 1640 | 1640 | arena: Allocator, |
| 1641 | 1641 | pt: Zcu.PerThread, |
| 1642 | 1642 | ) !Value { |
| 1643 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 1643 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 1644 | 1644 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 1645 | 1645 | const scalar_ty = ty.scalarType(pt.zcu); |
| 1646 | 1646 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -1692,7 +1692,7 @@ pub fn intMulWithOverflow( |
| 1692 | 1692 | pt: Zcu.PerThread, |
| 1693 | 1693 | ) !OverflowArithmeticResult { |
| 1694 | 1694 | const zcu = pt.zcu; |
| 1695 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 1695 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 1696 | 1696 | const vec_len = ty.vectorLen(zcu); |
| 1697 | 1697 | const overflowed_data = try arena.alloc(InternPool.Index, vec_len); |
| 1698 | 1698 | const result_data = try arena.alloc(InternPool.Index, vec_len); |
| ... | ... | @@ -1770,7 +1770,7 @@ pub fn numberMulWrap( |
| 1770 | 1770 | pt: Zcu.PerThread, |
| 1771 | 1771 | ) !Value { |
| 1772 | 1772 | const zcu = pt.zcu; |
| 1773 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 1773 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 1774 | 1774 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 1775 | 1775 | const scalar_ty = ty.scalarType(zcu); |
| 1776 | 1776 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -1797,7 +1797,7 @@ pub fn numberMulWrapScalar( |
| 1797 | 1797 | const zcu = pt.zcu; |
| 1798 | 1798 | if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return Value.undef; |
| 1799 | 1799 | |
| 1800 | if (ty.zigTypeTag(zcu) == .ComptimeInt) { | |
| 1800 | if (ty.zigTypeTag(zcu) == .comptime_int) { | |
| 1801 | 1801 | return intMul(lhs, rhs, ty, undefined, arena, pt); |
| 1802 | 1802 | } |
| 1803 | 1803 | |
| ... | ... | @@ -1817,7 +1817,7 @@ pub fn intMulSat( |
| 1817 | 1817 | arena: Allocator, |
| 1818 | 1818 | pt: Zcu.PerThread, |
| 1819 | 1819 | ) !Value { |
| 1820 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 1820 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 1821 | 1821 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 1822 | 1822 | const scalar_ty = ty.scalarType(pt.zcu); |
| 1823 | 1823 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -1897,7 +1897,7 @@ pub fn numberMin(lhs: Value, rhs: Value, zcu: *Zcu) Value { |
| 1897 | 1897 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 1898 | 1898 | pub fn bitwiseNot(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 1899 | 1899 | const zcu = pt.zcu; |
| 1900 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 1900 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 1901 | 1901 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 1902 | 1902 | const scalar_ty = ty.scalarType(zcu); |
| 1903 | 1903 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -1941,7 +1941,7 @@ pub fn bitwiseNotScalar(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThrea |
| 1941 | 1941 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 1942 | 1942 | pub fn bitwiseAnd(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 1943 | 1943 | const zcu = pt.zcu; |
| 1944 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 1944 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 1945 | 1945 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 1946 | 1946 | const scalar_ty = ty.scalarType(zcu); |
| 1947 | 1947 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2014,7 +2014,7 @@ fn intValueAa(ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 2014 | 2014 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 2015 | 2015 | pub fn bitwiseNand(lhs: Value, rhs: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 2016 | 2016 | const zcu = pt.zcu; |
| 2017 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2017 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2018 | 2018 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 2019 | 2019 | const scalar_ty = ty.scalarType(zcu); |
| 2020 | 2020 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2044,7 +2044,7 @@ pub fn bitwiseNandScalar(lhs: Value, rhs: Value, ty: Type, arena: Allocator, pt: |
| 2044 | 2044 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 2045 | 2045 | pub fn bitwiseOr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2046 | 2046 | const zcu = pt.zcu; |
| 2047 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2047 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2048 | 2048 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 2049 | 2049 | const scalar_ty = ty.scalarType(zcu); |
| 2050 | 2050 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2097,7 +2097,7 @@ pub fn bitwiseOrScalar(orig_lhs: Value, orig_rhs: Value, ty: Type, arena: Alloca |
| 2097 | 2097 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 2098 | 2098 | pub fn bitwiseXor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2099 | 2099 | const zcu = pt.zcu; |
| 2100 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2100 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2101 | 2101 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 2102 | 2102 | const scalar_ty = ty.scalarType(zcu); |
| 2103 | 2103 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2157,7 +2157,7 @@ pub fn intDiv(lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize, allocator |
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | 2159 | fn intDivInner(lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2160 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 2160 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 2161 | 2161 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 2162 | 2162 | const scalar_ty = ty.scalarType(pt.zcu); |
| 2163 | 2163 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2213,7 +2213,7 @@ pub fn intDivScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: |
| 2213 | 2213 | } |
| 2214 | 2214 | |
| 2215 | 2215 | pub fn intDivFloor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2216 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 2216 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 2217 | 2217 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 2218 | 2218 | const scalar_ty = ty.scalarType(pt.zcu); |
| 2219 | 2219 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2256,7 +2256,7 @@ pub fn intDivFloorScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, |
| 2256 | 2256 | } |
| 2257 | 2257 | |
| 2258 | 2258 | pub fn intMod(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2259 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 2259 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 2260 | 2260 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 2261 | 2261 | const scalar_ty = ty.scalarType(pt.zcu); |
| 2262 | 2262 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2328,7 +2328,7 @@ pub fn isNegativeInf(val: Value, zcu: *const Zcu) bool { |
| 2328 | 2328 | } |
| 2329 | 2329 | |
| 2330 | 2330 | pub fn floatRem(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 2331 | if (float_type.zigTypeTag(pt.zcu) == .Vector) { | |
| 2331 | if (float_type.zigTypeTag(pt.zcu) == .vector) { | |
| 2332 | 2332 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu)); |
| 2333 | 2333 | const scalar_ty = float_type.scalarType(pt.zcu); |
| 2334 | 2334 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2362,7 +2362,7 @@ pub fn floatRemScalar(lhs: Value, rhs: Value, float_type: Type, pt: Zcu.PerThrea |
| 2362 | 2362 | } |
| 2363 | 2363 | |
| 2364 | 2364 | pub fn floatMod(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 2365 | if (float_type.zigTypeTag(pt.zcu) == .Vector) { | |
| 2365 | if (float_type.zigTypeTag(pt.zcu) == .vector) { | |
| 2366 | 2366 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu)); |
| 2367 | 2367 | const scalar_ty = float_type.scalarType(pt.zcu); |
| 2368 | 2368 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2419,7 +2419,7 @@ pub fn intMul(lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize, allocator |
| 2419 | 2419 | |
| 2420 | 2420 | fn intMulInner(lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2421 | 2421 | const zcu = pt.zcu; |
| 2422 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2422 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2423 | 2423 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 2424 | 2424 | const scalar_ty = ty.scalarType(zcu); |
| 2425 | 2425 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2471,7 +2471,7 @@ pub fn intMulScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: |
| 2471 | 2471 | |
| 2472 | 2472 | pub fn intTrunc(val: Value, ty: Type, allocator: Allocator, signedness: std.builtin.Signedness, bits: u16, pt: Zcu.PerThread) !Value { |
| 2473 | 2473 | const zcu = pt.zcu; |
| 2474 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2474 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2475 | 2475 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 2476 | 2476 | const scalar_ty = ty.scalarType(zcu); |
| 2477 | 2477 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2496,7 +2496,7 @@ pub fn intTruncBitsAsValue( |
| 2496 | 2496 | pt: Zcu.PerThread, |
| 2497 | 2497 | ) !Value { |
| 2498 | 2498 | const zcu = pt.zcu; |
| 2499 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2499 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2500 | 2500 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 2501 | 2501 | const scalar_ty = ty.scalarType(zcu); |
| 2502 | 2502 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2540,7 +2540,7 @@ pub fn intTruncScalar( |
| 2540 | 2540 | |
| 2541 | 2541 | pub fn shl(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2542 | 2542 | const zcu = pt.zcu; |
| 2543 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2543 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2544 | 2544 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 2545 | 2545 | const scalar_ty = ty.scalarType(zcu); |
| 2546 | 2546 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2588,7 +2588,7 @@ pub fn shlWithOverflow( |
| 2588 | 2588 | allocator: Allocator, |
| 2589 | 2589 | pt: Zcu.PerThread, |
| 2590 | 2590 | ) !OverflowArithmeticResult { |
| 2591 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 2591 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 2592 | 2592 | const vec_len = ty.vectorLen(pt.zcu); |
| 2593 | 2593 | const overflowed_data = try allocator.alloc(InternPool.Index, vec_len); |
| 2594 | 2594 | const result_data = try allocator.alloc(InternPool.Index, vec_len); |
| ... | ... | @@ -2653,7 +2653,7 @@ pub fn shlSat( |
| 2653 | 2653 | arena: Allocator, |
| 2654 | 2654 | pt: Zcu.PerThread, |
| 2655 | 2655 | ) !Value { |
| 2656 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 2656 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 2657 | 2657 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 2658 | 2658 | const scalar_ty = ty.scalarType(pt.zcu); |
| 2659 | 2659 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2704,7 +2704,7 @@ pub fn shlTrunc( |
| 2704 | 2704 | arena: Allocator, |
| 2705 | 2705 | pt: Zcu.PerThread, |
| 2706 | 2706 | ) !Value { |
| 2707 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 2707 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 2708 | 2708 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 2709 | 2709 | const scalar_ty = ty.scalarType(pt.zcu); |
| 2710 | 2710 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2734,7 +2734,7 @@ pub fn shlTruncScalar( |
| 2734 | 2734 | } |
| 2735 | 2735 | |
| 2736 | 2736 | pub fn shr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value { |
| 2737 | if (ty.zigTypeTag(pt.zcu) == .Vector) { | |
| 2737 | if (ty.zigTypeTag(pt.zcu) == .vector) { | |
| 2738 | 2738 | const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu)); |
| 2739 | 2739 | const scalar_ty = ty.scalarType(pt.zcu); |
| 2740 | 2740 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2789,7 +2789,7 @@ pub fn floatNeg( |
| 2789 | 2789 | pt: Zcu.PerThread, |
| 2790 | 2790 | ) !Value { |
| 2791 | 2791 | const zcu = pt.zcu; |
| 2792 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 2792 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 2793 | 2793 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 2794 | 2794 | const scalar_ty = float_type.scalarType(zcu); |
| 2795 | 2795 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2829,7 +2829,7 @@ pub fn floatAdd( |
| 2829 | 2829 | pt: Zcu.PerThread, |
| 2830 | 2830 | ) !Value { |
| 2831 | 2831 | const zcu = pt.zcu; |
| 2832 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 2832 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 2833 | 2833 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 2834 | 2834 | const scalar_ty = float_type.scalarType(zcu); |
| 2835 | 2835 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2875,7 +2875,7 @@ pub fn floatSub( |
| 2875 | 2875 | pt: Zcu.PerThread, |
| 2876 | 2876 | ) !Value { |
| 2877 | 2877 | const zcu = pt.zcu; |
| 2878 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 2878 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 2879 | 2879 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 2880 | 2880 | const scalar_ty = float_type.scalarType(zcu); |
| 2881 | 2881 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2920,7 +2920,7 @@ pub fn floatDiv( |
| 2920 | 2920 | arena: Allocator, |
| 2921 | 2921 | pt: Zcu.PerThread, |
| 2922 | 2922 | ) !Value { |
| 2923 | if (float_type.zigTypeTag(pt.zcu) == .Vector) { | |
| 2923 | if (float_type.zigTypeTag(pt.zcu) == .vector) { | |
| 2924 | 2924 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu)); |
| 2925 | 2925 | const scalar_ty = float_type.scalarType(pt.zcu); |
| 2926 | 2926 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -2965,7 +2965,7 @@ pub fn floatDivFloor( |
| 2965 | 2965 | arena: Allocator, |
| 2966 | 2966 | pt: Zcu.PerThread, |
| 2967 | 2967 | ) !Value { |
| 2968 | if (float_type.zigTypeTag(pt.zcu) == .Vector) { | |
| 2968 | if (float_type.zigTypeTag(pt.zcu) == .vector) { | |
| 2969 | 2969 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu)); |
| 2970 | 2970 | const scalar_ty = float_type.scalarType(pt.zcu); |
| 2971 | 2971 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3010,7 +3010,7 @@ pub fn floatDivTrunc( |
| 3010 | 3010 | arena: Allocator, |
| 3011 | 3011 | pt: Zcu.PerThread, |
| 3012 | 3012 | ) !Value { |
| 3013 | if (float_type.zigTypeTag(pt.zcu) == .Vector) { | |
| 3013 | if (float_type.zigTypeTag(pt.zcu) == .vector) { | |
| 3014 | 3014 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu)); |
| 3015 | 3015 | const scalar_ty = float_type.scalarType(pt.zcu); |
| 3016 | 3016 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3056,7 +3056,7 @@ pub fn floatMul( |
| 3056 | 3056 | pt: Zcu.PerThread, |
| 3057 | 3057 | ) !Value { |
| 3058 | 3058 | const zcu = pt.zcu; |
| 3059 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3059 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3060 | 3060 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3061 | 3061 | const scalar_ty = float_type.scalarType(zcu); |
| 3062 | 3062 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3095,7 +3095,7 @@ pub fn floatMulScalar( |
| 3095 | 3095 | } |
| 3096 | 3096 | |
| 3097 | 3097 | pub fn sqrt(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3098 | if (float_type.zigTypeTag(pt.zcu) == .Vector) { | |
| 3098 | if (float_type.zigTypeTag(pt.zcu) == .vector) { | |
| 3099 | 3099 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu)); |
| 3100 | 3100 | const scalar_ty = float_type.scalarType(pt.zcu); |
| 3101 | 3101 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3129,7 +3129,7 @@ pub fn sqrtScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err |
| 3129 | 3129 | |
| 3130 | 3130 | pub fn sin(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3131 | 3131 | const zcu = pt.zcu; |
| 3132 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3132 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3133 | 3133 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3134 | 3134 | const scalar_ty = float_type.scalarType(zcu); |
| 3135 | 3135 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3163,7 +3163,7 @@ pub fn sinScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro |
| 3163 | 3163 | |
| 3164 | 3164 | pub fn cos(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3165 | 3165 | const zcu = pt.zcu; |
| 3166 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3166 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3167 | 3167 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3168 | 3168 | const scalar_ty = float_type.scalarType(zcu); |
| 3169 | 3169 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3197,7 +3197,7 @@ pub fn cosScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro |
| 3197 | 3197 | |
| 3198 | 3198 | pub fn tan(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3199 | 3199 | const zcu = pt.zcu; |
| 3200 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3200 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3201 | 3201 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3202 | 3202 | const scalar_ty = float_type.scalarType(zcu); |
| 3203 | 3203 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3231,7 +3231,7 @@ pub fn tanScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro |
| 3231 | 3231 | |
| 3232 | 3232 | pub fn exp(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3233 | 3233 | const zcu = pt.zcu; |
| 3234 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3234 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3235 | 3235 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3236 | 3236 | const scalar_ty = float_type.scalarType(zcu); |
| 3237 | 3237 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3265,7 +3265,7 @@ pub fn expScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro |
| 3265 | 3265 | |
| 3266 | 3266 | pub fn exp2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3267 | 3267 | const zcu = pt.zcu; |
| 3268 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3268 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3269 | 3269 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3270 | 3270 | const scalar_ty = float_type.scalarType(zcu); |
| 3271 | 3271 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3299,7 +3299,7 @@ pub fn exp2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err |
| 3299 | 3299 | |
| 3300 | 3300 | pub fn log(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3301 | 3301 | const zcu = pt.zcu; |
| 3302 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3302 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3303 | 3303 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3304 | 3304 | const scalar_ty = float_type.scalarType(zcu); |
| 3305 | 3305 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3333,7 +3333,7 @@ pub fn logScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro |
| 3333 | 3333 | |
| 3334 | 3334 | pub fn log2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3335 | 3335 | const zcu = pt.zcu; |
| 3336 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3336 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3337 | 3337 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3338 | 3338 | const scalar_ty = float_type.scalarType(zcu); |
| 3339 | 3339 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3367,7 +3367,7 @@ pub fn log2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err |
| 3367 | 3367 | |
| 3368 | 3368 | pub fn log10(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3369 | 3369 | const zcu = pt.zcu; |
| 3370 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3370 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3371 | 3371 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3372 | 3372 | const scalar_ty = float_type.scalarType(zcu); |
| 3373 | 3373 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3401,7 +3401,7 @@ pub fn log10Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er |
| 3401 | 3401 | |
| 3402 | 3402 | pub fn abs(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3403 | 3403 | const zcu = pt.zcu; |
| 3404 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 3404 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 3405 | 3405 | const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu)); |
| 3406 | 3406 | const scalar_ty = ty.scalarType(zcu); |
| 3407 | 3407 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3419,21 +3419,21 @@ pub fn abs(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3419 | 3419 | pub fn absScalar(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) Allocator.Error!Value { |
| 3420 | 3420 | const zcu = pt.zcu; |
| 3421 | 3421 | switch (ty.zigTypeTag(zcu)) { |
| 3422 | .Int => { | |
| 3422 | .int => { | |
| 3423 | 3423 | var buffer: Value.BigIntSpace = undefined; |
| 3424 | 3424 | var operand_bigint = try val.toBigInt(&buffer, zcu).toManaged(arena); |
| 3425 | 3425 | operand_bigint.abs(); |
| 3426 | 3426 | |
| 3427 | 3427 | return pt.intValue_big(try ty.toUnsigned(pt), operand_bigint.toConst()); |
| 3428 | 3428 | }, |
| 3429 | .ComptimeInt => { | |
| 3429 | .comptime_int => { | |
| 3430 | 3430 | var buffer: Value.BigIntSpace = undefined; |
| 3431 | 3431 | var operand_bigint = try val.toBigInt(&buffer, zcu).toManaged(arena); |
| 3432 | 3432 | operand_bigint.abs(); |
| 3433 | 3433 | |
| 3434 | 3434 | return pt.intValue_big(ty, operand_bigint.toConst()); |
| 3435 | 3435 | }, |
| 3436 | .ComptimeFloat, .Float => { | |
| 3436 | .comptime_float, .float => { | |
| 3437 | 3437 | const target = zcu.getTarget(); |
| 3438 | 3438 | const storage: InternPool.Key.Float.Storage = switch (ty.floatBits(target)) { |
| 3439 | 3439 | 16 => .{ .f16 = @abs(val.toFloat(f16, zcu)) }, |
| ... | ... | @@ -3454,7 +3454,7 @@ pub fn absScalar(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) Allo |
| 3454 | 3454 | |
| 3455 | 3455 | pub fn floor(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3456 | 3456 | const zcu = pt.zcu; |
| 3457 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3457 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3458 | 3458 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3459 | 3459 | const scalar_ty = float_type.scalarType(zcu); |
| 3460 | 3460 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3488,7 +3488,7 @@ pub fn floorScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er |
| 3488 | 3488 | |
| 3489 | 3489 | pub fn ceil(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3490 | 3490 | const zcu = pt.zcu; |
| 3491 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3491 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3492 | 3492 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3493 | 3493 | const scalar_ty = float_type.scalarType(zcu); |
| 3494 | 3494 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3522,7 +3522,7 @@ pub fn ceilScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err |
| 3522 | 3522 | |
| 3523 | 3523 | pub fn round(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3524 | 3524 | const zcu = pt.zcu; |
| 3525 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3525 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3526 | 3526 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3527 | 3527 | const scalar_ty = float_type.scalarType(zcu); |
| 3528 | 3528 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3556,7 +3556,7 @@ pub fn roundScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er |
| 3556 | 3556 | |
| 3557 | 3557 | pub fn trunc(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value { |
| 3558 | 3558 | const zcu = pt.zcu; |
| 3559 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3559 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3560 | 3560 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3561 | 3561 | const scalar_ty = float_type.scalarType(zcu); |
| 3562 | 3562 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3597,7 +3597,7 @@ pub fn mulAdd( |
| 3597 | 3597 | pt: Zcu.PerThread, |
| 3598 | 3598 | ) !Value { |
| 3599 | 3599 | const zcu = pt.zcu; |
| 3600 | if (float_type.zigTypeTag(zcu) == .Vector) { | |
| 3600 | if (float_type.zigTypeTag(zcu) == .vector) { | |
| 3601 | 3601 | const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu)); |
| 3602 | 3602 | const scalar_ty = float_type.scalarType(zcu); |
| 3603 | 3603 | for (result_data, 0..) |*scalar, i| { |
| ... | ... | @@ -3720,7 +3720,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 3720 | 3720 | const opt_ty = parent_ptr_ty.childType(zcu); |
| 3721 | 3721 | |
| 3722 | 3722 | assert(parent_ptr_ty.ptrSize(zcu) == .One); |
| 3723 | assert(opt_ty.zigTypeTag(zcu) == .Optional); | |
| 3723 | assert(opt_ty.zigTypeTag(zcu) == .optional); | |
| 3724 | 3724 | |
| 3725 | 3725 | const result_ty = try pt.ptrTypeSema(info: { |
| 3726 | 3726 | var new = parent_ptr_ty.ptrInfo(zcu); |
| ... | ... | @@ -3754,7 +3754,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 3754 | 3754 | const eu_ty = parent_ptr_ty.childType(zcu); |
| 3755 | 3755 | |
| 3756 | 3756 | assert(parent_ptr_ty.ptrSize(zcu) == .One); |
| 3757 | assert(eu_ty.zigTypeTag(zcu) == .ErrorUnion); | |
| 3757 | assert(eu_ty.zigTypeTag(zcu) == .error_union); | |
| 3758 | 3758 | |
| 3759 | 3759 | const result_ty = try pt.ptrTypeSema(info: { |
| 3760 | 3760 | var new = parent_ptr_ty.ptrInfo(zcu); |
| ... | ... | @@ -3789,7 +3789,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { |
| 3789 | 3789 | // Exiting this `switch` indicates that the `field` pointer representation should be used. |
| 3790 | 3790 | // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily. |
| 3791 | 3791 | const field_ty: Type, const field_align: InternPool.Alignment = switch (aggregate_ty.zigTypeTag(zcu)) { |
| 3792 | .Struct => field: { | |
| 3792 | .@"struct" => field: { | |
| 3793 | 3793 | const field_ty = aggregate_ty.fieldType(field_idx, zcu); |
| 3794 | 3794 | switch (aggregate_ty.containerLayout(zcu)) { |
| 3795 | 3795 | .auto => break :field .{ field_ty, try aggregate_ty.fieldAlignmentSema(field_idx, pt) }, |
| ... | ... | @@ -3839,7 +3839,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { |
| 3839 | 3839 | }, |
| 3840 | 3840 | } |
| 3841 | 3841 | }, |
| 3842 | .Union => field: { | |
| 3842 | .@"union" => field: { | |
| 3843 | 3843 | const union_obj = zcu.typeToUnion(aggregate_ty).?; |
| 3844 | 3844 | const field_ty = Type.fromInterned(union_obj.field_types.get(&zcu.intern_pool)[field_idx]); |
| 3845 | 3845 | switch (aggregate_ty.containerLayout(zcu)) { |
| ... | ... | @@ -3887,7 +3887,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { |
| 3887 | 3887 | }, |
| 3888 | 3888 | } |
| 3889 | 3889 | }, |
| 3890 | .Pointer => field_ty: { | |
| 3890 | .pointer => field_ty: { | |
| 3891 | 3891 | assert(aggregate_ty.isSlice(zcu)); |
| 3892 | 3892 | break :field_ty switch (field_idx) { |
| 3893 | 3893 | Value.slice_ptr_index => .{ aggregate_ty.slicePtrFieldType(zcu), Type.usize.abiAlignment(zcu) }, |
| ... | ... | @@ -3944,7 +3944,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value |
| 3944 | 3944 | |
| 3945 | 3945 | if (result_ty.ptrInfo(zcu).packed_offset.host_size != 0) { |
| 3946 | 3946 | // Since we have a bit-pointer, the pointer address should be unchanged. |
| 3947 | assert(elem_ty.zigTypeTag(zcu) == .Vector); | |
| 3947 | assert(elem_ty.zigTypeTag(zcu) == .vector); | |
| 3948 | 3948 | return pt.getCoerced(parent_ptr, result_ty); |
| 3949 | 3949 | } |
| 3950 | 3950 | |
| ... | ... | @@ -3955,8 +3955,8 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value |
| 3955 | 3955 | |
| 3956 | 3956 | const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) { |
| 3957 | 3957 | .One => switch (elem_ty.zigTypeTag(zcu)) { |
| 3958 | .Vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) }, | |
| 3959 | .Array => strat: { | |
| 3958 | .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) }, | |
| 3959 | .array => strat: { | |
| 3960 | 3960 | const arr_elem_ty = elem_ty.childType(zcu); |
| 3961 | 3961 | if (try arr_elem_ty.comptimeOnlySema(pt)) { |
| 3962 | 3962 | break :strat .{ .elem_ptr = arr_elem_ty }; |
| ... | ... | @@ -4178,19 +4178,19 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh |
| 4178 | 4178 | const base_ptr_ty = base_ptr.typeOf(zcu); |
| 4179 | 4179 | const agg_ty = base_ptr_ty.childType(zcu); |
| 4180 | 4180 | const field_ty, const field_align = switch (agg_ty.zigTypeTag(zcu)) { |
| 4181 | .Struct => .{ agg_ty.fieldType(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner( | |
| 4181 | .@"struct" => .{ agg_ty.fieldType(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner( | |
| 4182 | 4182 | @intCast(field.index), |
| 4183 | 4183 | if (have_sema) .sema else .normal, |
| 4184 | 4184 | pt.zcu, |
| 4185 | 4185 | if (have_sema) pt.tid else {}, |
| 4186 | 4186 | ) }, |
| 4187 | .Union => .{ agg_ty.unionFieldTypeByIndex(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner( | |
| 4187 | .@"union" => .{ agg_ty.unionFieldTypeByIndex(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner( | |
| 4188 | 4188 | @intCast(field.index), |
| 4189 | 4189 | if (have_sema) .sema else .normal, |
| 4190 | 4190 | pt.zcu, |
| 4191 | 4191 | if (have_sema) pt.tid else {}, |
| 4192 | 4192 | ) }, |
| 4193 | .Pointer => .{ switch (field.index) { | |
| 4193 | .pointer => .{ switch (field.index) { | |
| 4194 | 4194 | Value.slice_ptr_index => agg_ty.slicePtrFieldType(zcu), |
| 4195 | 4195 | Value.slice_len_index => Type.usize, |
| 4196 | 4196 | else => unreachable, |
| ... | ... | @@ -4268,31 +4268,31 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh |
| 4268 | 4268 | break; |
| 4269 | 4269 | } |
| 4270 | 4270 | switch (cur_ty.zigTypeTag(zcu)) { |
| 4271 | .NoReturn, | |
| 4272 | .Type, | |
| 4273 | .ComptimeInt, | |
| 4274 | .ComptimeFloat, | |
| 4275 | .Null, | |
| 4276 | .Undefined, | |
| 4277 | .EnumLiteral, | |
| 4278 | .Opaque, | |
| 4279 | .Fn, | |
| 4280 | .ErrorUnion, | |
| 4281 | .Int, | |
| 4282 | .Float, | |
| 4283 | .Bool, | |
| 4284 | .Void, | |
| 4285 | .Pointer, | |
| 4286 | .ErrorSet, | |
| 4287 | .AnyFrame, | |
| 4288 | .Frame, | |
| 4289 | .Enum, | |
| 4290 | .Vector, | |
| 4291 | .Optional, | |
| 4292 | .Union, | |
| 4271 | .noreturn, | |
| 4272 | .type, | |
| 4273 | .comptime_int, | |
| 4274 | .comptime_float, | |
| 4275 | .null, | |
| 4276 | .undefined, | |
| 4277 | .enum_literal, | |
| 4278 | .@"opaque", | |
| 4279 | .@"fn", | |
| 4280 | .error_union, | |
| 4281 | .int, | |
| 4282 | .float, | |
| 4283 | .bool, | |
| 4284 | .void, | |
| 4285 | .pointer, | |
| 4286 | .error_set, | |
| 4287 | .@"anyframe", | |
| 4288 | .frame, | |
| 4289 | .@"enum", | |
| 4290 | .vector, | |
| 4291 | .optional, | |
| 4292 | .@"union", | |
| 4293 | 4293 | => break, |
| 4294 | 4294 | |
| 4295 | .Array => { | |
| 4295 | .array => { | |
| 4296 | 4296 | const elem_ty = cur_ty.childType(zcu); |
| 4297 | 4297 | const elem_size = elem_ty.abiSize(zcu); |
| 4298 | 4298 | const start_idx = cur_offset / elem_size; |
| ... | ... | @@ -4321,7 +4321,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh |
| 4321 | 4321 | break; |
| 4322 | 4322 | } |
| 4323 | 4323 | }, |
| 4324 | .Struct => switch (cur_ty.containerLayout(zcu)) { | |
| 4324 | .@"struct" => switch (cur_ty.containerLayout(zcu)) { | |
| 4325 | 4325 | .auto, .@"packed" => break, |
| 4326 | 4326 | .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| { |
| 4327 | 4327 | const field_ty = cur_ty.fieldType(field_idx, zcu); |
src/Zcu.zig+4-4| ... | ... | @@ -43,9 +43,9 @@ const dev = @import("dev.zig"); |
| 43 | 43 | comptime { |
| 44 | 44 | @setEvalBranchQuota(4000); |
| 45 | 45 | for ( |
| 46 | @typeInfo(Zir.Inst.Ref).Enum.fields, | |
| 47 | @typeInfo(Air.Inst.Ref).Enum.fields, | |
| 48 | @typeInfo(InternPool.Index).Enum.fields, | |
| 46 | @typeInfo(Zir.Inst.Ref).@"enum".fields, | |
| 47 | @typeInfo(Air.Inst.Ref).@"enum".fields, | |
| 48 | @typeInfo(InternPool.Index).@"enum".fields, | |
| 49 | 49 | ) |zir_field, air_field, ip_field| { |
| 50 | 50 | assert(mem.eql(u8, zir_field.name, ip_field.name)); |
| 51 | 51 | assert(mem.eql(u8, air_field.name, ip_field.name)); |
| ... | ... | @@ -246,7 +246,7 @@ pub const PanicId = enum { |
| 246 | 246 | memcpy_alias, |
| 247 | 247 | noreturn_returned, |
| 248 | 248 | |
| 249 | pub const len = @typeInfo(PanicId).Enum.fields.len; | |
| 249 | pub const len = @typeInfo(PanicId).@"enum".fields.len; | |
| 250 | 250 | }; |
| 251 | 251 | |
| 252 | 252 | pub const GlobalErrorSet = std.AutoArrayHashMapUnmanaged(InternPool.NullTerminatedString, void); |
src/Zcu/PerThread.zig+7-7| ... | ... | @@ -921,7 +921,7 @@ fn createFileRootStruct( |
| 921 | 921 | assert(!small.has_captures_len); |
| 922 | 922 | assert(!small.has_backing_int); |
| 923 | 923 | assert(small.layout == .auto); |
| 924 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len; | |
| 924 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len; | |
| 925 | 925 | const fields_len = if (small.has_fields_len) blk: { |
| 926 | 926 | const fields_len = file.zir.extra[extra_index]; |
| 927 | 927 | extra_index += 1; |
| ... | ... | @@ -1005,7 +1005,7 @@ fn updateFileNamespace(pt: Zcu.PerThread, file_index: Zcu.File.Index) Allocator. |
| 1005 | 1005 | const extended = file.zir.instructions.items(.data)[@intFromEnum(Zir.Inst.Index.main_struct_inst)].extended; |
| 1006 | 1006 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 1007 | 1007 | |
| 1008 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len; | |
| 1008 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len; | |
| 1009 | 1009 | extra_index += @intFromBool(small.has_fields_len); |
| 1010 | 1010 | const decls_len = if (small.has_decls_len) blk: { |
| 1011 | 1011 | const decls_len = file.zir.extra[extra_index]; |
| ... | ... | @@ -2080,7 +2080,7 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError! |
| 2080 | 2080 | func.setCallsOrAwaitsErrorableFn(ip, false); |
| 2081 | 2081 | |
| 2082 | 2082 | // First few indexes of extra are reserved and set at the end. |
| 2083 | const reserved_count = @typeInfo(Air.ExtraIndex).Enum.fields.len; | |
| 2083 | const reserved_count = @typeInfo(Air.ExtraIndex).@"enum".fields.len; | |
| 2084 | 2084 | try sema.air_extra.ensureTotalCapacity(gpa, reserved_count); |
| 2085 | 2085 | sema.air_extra.items.len += reserved_count; |
| 2086 | 2086 | |
| ... | ... | @@ -2204,7 +2204,7 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError! |
| 2204 | 2204 | } |
| 2205 | 2205 | |
| 2206 | 2206 | // Copy the block into place and mark that as the main block. |
| 2207 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + | |
| 2207 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len + | |
| 2208 | 2208 | inner_block.instructions.items.len); |
| 2209 | 2209 | const main_block_index = sema.addExtraAssumeCapacity(Air.Block{ |
| 2210 | 2210 | .body_len = @intCast(inner_block.instructions.items.len), |
| ... | ... | @@ -2405,7 +2405,7 @@ fn processExportsInner( |
| 2405 | 2405 | .resolved => |r| Value.fromInterned(r.val), |
| 2406 | 2406 | }; |
| 2407 | 2407 | // If the value is a function, we also need to check if that function succeeded analysis. |
| 2408 | if (val.typeOf(zcu).zigTypeTag(zcu) == .Fn) { | |
| 2408 | if (val.typeOf(zcu).zigTypeTag(zcu) == .@"fn") { | |
| 2409 | 2409 | const func_unit = AnalUnit.wrap(.{ .func = val.toIntern() }); |
| 2410 | 2410 | if (zcu.failed_analysis.contains(func_unit)) break :failed true; |
| 2411 | 2411 | if (zcu.transitive_failed_analysis.contains(func_unit)) break :failed true; |
| ... | ... | @@ -2869,7 +2869,7 @@ pub fn errorSetFromUnsortedNames( |
| 2869 | 2869 | /// Supports only pointers, not pointer-like optionals. |
| 2870 | 2870 | pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value { |
| 2871 | 2871 | const zcu = pt.zcu; |
| 2872 | assert(ty.zigTypeTag(zcu) == .Pointer and !ty.isSlice(zcu)); | |
| 2872 | assert(ty.zigTypeTag(zcu) == .pointer and !ty.isSlice(zcu)); | |
| 2873 | 2873 | assert(x != 0 or ty.isAllowzeroPtr(zcu)); |
| 2874 | 2874 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| 2875 | 2875 | .ty = ty.toIntern(), |
| ... | ... | @@ -2882,7 +2882,7 @@ pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value { |
| 2882 | 2882 | pub fn enumValue(pt: Zcu.PerThread, ty: Type, tag_int: InternPool.Index) Allocator.Error!Value { |
| 2883 | 2883 | if (std.debug.runtime_safety) { |
| 2884 | 2884 | const tag = ty.zigTypeTag(pt.zcu); |
| 2885 | assert(tag == .Enum); | |
| 2885 | assert(tag == .@"enum"); | |
| 2886 | 2886 | } |
| 2887 | 2887 | return Value.fromInterned(try pt.intern(.{ .enum_tag = .{ |
| 2888 | 2888 | .ty = ty.toIntern(), |
src/arch/aarch64/CodeGen.zig+56-56| ... | ... | @@ -1324,7 +1324,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 1324 | 1324 | .compare_flags => |cond| break :result MCValue{ .compare_flags = cond.negate() }, |
| 1325 | 1325 | else => { |
| 1326 | 1326 | switch (operand_ty.zigTypeTag(zcu)) { |
| 1327 | .Bool => { | |
| 1327 | .bool => { | |
| 1328 | 1328 | // TODO convert this to mvn + and |
| 1329 | 1329 | const op_reg = switch (operand) { |
| 1330 | 1330 | .register => |r| r, |
| ... | ... | @@ -1355,8 +1355,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 1355 | 1355 | |
| 1356 | 1356 | break :result MCValue{ .register = dest_reg }; |
| 1357 | 1357 | }, |
| 1358 | .Vector => return self.fail("TODO bitwise not for vectors", .{}), | |
| 1359 | .Int => { | |
| 1358 | .vector => return self.fail("TODO bitwise not for vectors", .{}), | |
| 1359 | .int => { | |
| 1360 | 1360 | const int_info = operand_ty.intInfo(zcu); |
| 1361 | 1361 | if (int_info.bits <= 64) { |
| 1362 | 1362 | const op_reg = switch (operand) { |
| ... | ... | @@ -1412,9 +1412,9 @@ fn minMax( |
| 1412 | 1412 | const pt = self.pt; |
| 1413 | 1413 | const zcu = pt.zcu; |
| 1414 | 1414 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 1415 | .Float => return self.fail("TODO ARM min/max on floats", .{}), | |
| 1416 | .Vector => return self.fail("TODO ARM min/max on vectors", .{}), | |
| 1417 | .Int => { | |
| 1415 | .float => return self.fail("TODO ARM min/max on floats", .{}), | |
| 1416 | .vector => return self.fail("TODO ARM min/max on vectors", .{}), | |
| 1417 | .int => { | |
| 1418 | 1418 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 1419 | 1419 | const int_info = lhs_ty.intInfo(zcu); |
| 1420 | 1420 | if (int_info.bits <= 64) { |
| ... | ... | @@ -1903,9 +1903,9 @@ fn addSub( |
| 1903 | 1903 | const pt = self.pt; |
| 1904 | 1904 | const zcu = pt.zcu; |
| 1905 | 1905 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 1906 | .Float => return self.fail("TODO binary operations on floats", .{}), | |
| 1907 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 1908 | .Int => { | |
| 1906 | .float => return self.fail("TODO binary operations on floats", .{}), | |
| 1907 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 1908 | .int => { | |
| 1909 | 1909 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 1910 | 1910 | const int_info = lhs_ty.intInfo(zcu); |
| 1911 | 1911 | if (int_info.bits <= 64) { |
| ... | ... | @@ -1965,8 +1965,8 @@ fn mul( |
| 1965 | 1965 | const pt = self.pt; |
| 1966 | 1966 | const zcu = pt.zcu; |
| 1967 | 1967 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 1968 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 1969 | .Int => { | |
| 1968 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 1969 | .int => { | |
| 1970 | 1970 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 1971 | 1971 | const int_info = lhs_ty.intInfo(zcu); |
| 1972 | 1972 | if (int_info.bits <= 64) { |
| ... | ... | @@ -1998,8 +1998,8 @@ fn divFloat( |
| 1998 | 1998 | const pt = self.pt; |
| 1999 | 1999 | const zcu = pt.zcu; |
| 2000 | 2000 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2001 | .Float => return self.fail("TODO div_float", .{}), | |
| 2002 | .Vector => return self.fail("TODO div_float on vectors", .{}), | |
| 2001 | .float => return self.fail("TODO div_float", .{}), | |
| 2002 | .vector => return self.fail("TODO div_float on vectors", .{}), | |
| 2003 | 2003 | else => unreachable, |
| 2004 | 2004 | } |
| 2005 | 2005 | } |
| ... | ... | @@ -2015,9 +2015,9 @@ fn divTrunc( |
| 2015 | 2015 | const pt = self.pt; |
| 2016 | 2016 | const zcu = pt.zcu; |
| 2017 | 2017 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2018 | .Float => return self.fail("TODO div on floats", .{}), | |
| 2019 | .Vector => return self.fail("TODO div on vectors", .{}), | |
| 2020 | .Int => { | |
| 2018 | .float => return self.fail("TODO div on floats", .{}), | |
| 2019 | .vector => return self.fail("TODO div on vectors", .{}), | |
| 2020 | .int => { | |
| 2021 | 2021 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2022 | 2022 | const int_info = lhs_ty.intInfo(zcu); |
| 2023 | 2023 | if (int_info.bits <= 64) { |
| ... | ... | @@ -2050,9 +2050,9 @@ fn divFloor( |
| 2050 | 2050 | const pt = self.pt; |
| 2051 | 2051 | const zcu = pt.zcu; |
| 2052 | 2052 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2053 | .Float => return self.fail("TODO div on floats", .{}), | |
| 2054 | .Vector => return self.fail("TODO div on vectors", .{}), | |
| 2055 | .Int => { | |
| 2053 | .float => return self.fail("TODO div on floats", .{}), | |
| 2054 | .vector => return self.fail("TODO div on vectors", .{}), | |
| 2055 | .int => { | |
| 2056 | 2056 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2057 | 2057 | const int_info = lhs_ty.intInfo(zcu); |
| 2058 | 2058 | if (int_info.bits <= 64) { |
| ... | ... | @@ -2084,9 +2084,9 @@ fn divExact( |
| 2084 | 2084 | const pt = self.pt; |
| 2085 | 2085 | const zcu = pt.zcu; |
| 2086 | 2086 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2087 | .Float => return self.fail("TODO div on floats", .{}), | |
| 2088 | .Vector => return self.fail("TODO div on vectors", .{}), | |
| 2089 | .Int => { | |
| 2087 | .float => return self.fail("TODO div on floats", .{}), | |
| 2088 | .vector => return self.fail("TODO div on vectors", .{}), | |
| 2089 | .int => { | |
| 2090 | 2090 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2091 | 2091 | const int_info = lhs_ty.intInfo(zcu); |
| 2092 | 2092 | if (int_info.bits <= 64) { |
| ... | ... | @@ -2121,9 +2121,9 @@ fn rem( |
| 2121 | 2121 | const pt = self.pt; |
| 2122 | 2122 | const zcu = pt.zcu; |
| 2123 | 2123 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2124 | .Float => return self.fail("TODO rem/zcu on floats", .{}), | |
| 2125 | .Vector => return self.fail("TODO rem/zcu on vectors", .{}), | |
| 2126 | .Int => { | |
| 2124 | .float => return self.fail("TODO rem/zcu on floats", .{}), | |
| 2125 | .vector => return self.fail("TODO rem/zcu on vectors", .{}), | |
| 2126 | .int => { | |
| 2127 | 2127 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2128 | 2128 | const int_info = lhs_ty.intInfo(zcu); |
| 2129 | 2129 | if (int_info.bits <= 64) { |
| ... | ... | @@ -2193,9 +2193,9 @@ fn modulo( |
| 2193 | 2193 | const pt = self.pt; |
| 2194 | 2194 | const zcu = pt.zcu; |
| 2195 | 2195 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2196 | .Float => return self.fail("TODO zcu on floats", .{}), | |
| 2197 | .Vector => return self.fail("TODO zcu on vectors", .{}), | |
| 2198 | .Int => return self.fail("TODO zcu on ints", .{}), | |
| 2196 | .float => return self.fail("TODO zcu on floats", .{}), | |
| 2197 | .vector => return self.fail("TODO zcu on vectors", .{}), | |
| 2198 | .int => return self.fail("TODO zcu on ints", .{}), | |
| 2199 | 2199 | else => unreachable, |
| 2200 | 2200 | } |
| 2201 | 2201 | } |
| ... | ... | @@ -2212,8 +2212,8 @@ fn wrappingArithmetic( |
| 2212 | 2212 | const pt = self.pt; |
| 2213 | 2213 | const zcu = pt.zcu; |
| 2214 | 2214 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2215 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2216 | .Int => { | |
| 2215 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2216 | .int => { | |
| 2217 | 2217 | const int_info = lhs_ty.intInfo(zcu); |
| 2218 | 2218 | if (int_info.bits <= 64) { |
| 2219 | 2219 | // Generate an add/sub/mul |
| ... | ... | @@ -2248,8 +2248,8 @@ fn bitwise( |
| 2248 | 2248 | const pt = self.pt; |
| 2249 | 2249 | const zcu = pt.zcu; |
| 2250 | 2250 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2251 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2252 | .Int => { | |
| 2251 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2252 | .int => { | |
| 2253 | 2253 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2254 | 2254 | const int_info = lhs_ty.intInfo(zcu); |
| 2255 | 2255 | if (int_info.bits <= 64) { |
| ... | ... | @@ -2284,8 +2284,8 @@ fn shiftExact( |
| 2284 | 2284 | const pt = self.pt; |
| 2285 | 2285 | const zcu = pt.zcu; |
| 2286 | 2286 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2287 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2288 | .Int => { | |
| 2287 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2288 | .int => { | |
| 2289 | 2289 | const int_info = lhs_ty.intInfo(zcu); |
| 2290 | 2290 | if (int_info.bits <= 64) { |
| 2291 | 2291 | const rhs_immediate = try rhs_bind.resolveToImmediate(self); |
| ... | ... | @@ -2335,8 +2335,8 @@ fn shiftNormal( |
| 2335 | 2335 | const pt = self.pt; |
| 2336 | 2336 | const zcu = pt.zcu; |
| 2337 | 2337 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2338 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2339 | .Int => { | |
| 2338 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2339 | .int => { | |
| 2340 | 2340 | const int_info = lhs_ty.intInfo(zcu); |
| 2341 | 2341 | if (int_info.bits <= 64) { |
| 2342 | 2342 | // Generate a shl_exact/shr_exact |
| ... | ... | @@ -2376,7 +2376,7 @@ fn booleanOp( |
| 2376 | 2376 | const pt = self.pt; |
| 2377 | 2377 | const zcu = pt.zcu; |
| 2378 | 2378 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2379 | .Bool => { | |
| 2379 | .bool => { | |
| 2380 | 2380 | assert((try lhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema |
| 2381 | 2381 | assert((try rhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema |
| 2382 | 2382 | |
| ... | ... | @@ -2404,7 +2404,7 @@ fn ptrArithmetic( |
| 2404 | 2404 | const pt = self.pt; |
| 2405 | 2405 | const zcu = pt.zcu; |
| 2406 | 2406 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2407 | .Pointer => { | |
| 2407 | .pointer => { | |
| 2408 | 2408 | assert(rhs_ty.eql(Type.usize, zcu)); |
| 2409 | 2409 | |
| 2410 | 2410 | const ptr_ty = lhs_ty; |
| ... | ... | @@ -2539,8 +2539,8 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2539 | 2539 | const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu))); |
| 2540 | 2540 | |
| 2541 | 2541 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2542 | .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), | |
| 2543 | .Int => { | |
| 2542 | .vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), | |
| 2543 | .int => { | |
| 2544 | 2544 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2545 | 2545 | const int_info = lhs_ty.intInfo(zcu); |
| 2546 | 2546 | switch (int_info.bits) { |
| ... | ... | @@ -2667,8 +2667,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2667 | 2667 | const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu))); |
| 2668 | 2668 | |
| 2669 | 2669 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2670 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 2671 | .Int => { | |
| 2670 | .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 2671 | .int => { | |
| 2672 | 2672 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2673 | 2673 | const int_info = lhs_ty.intInfo(zcu); |
| 2674 | 2674 | if (int_info.bits <= 32) { |
| ... | ... | @@ -2892,8 +2892,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2892 | 2892 | const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu))); |
| 2893 | 2893 | |
| 2894 | 2894 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2895 | .Vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}), | |
| 2896 | .Int => { | |
| 2895 | .vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}), | |
| 2896 | .int => { | |
| 2897 | 2897 | const int_info = lhs_ty.intInfo(zcu); |
| 2898 | 2898 | if (int_info.bits <= 64) { |
| 2899 | 2899 | const stack_offset = try self.allocMem(tuple_size, tuple_align, inst); |
| ... | ... | @@ -4279,8 +4279,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 4279 | 4279 | const ip = &zcu.intern_pool; |
| 4280 | 4280 | |
| 4281 | 4281 | const fn_ty = switch (ty.zigTypeTag(zcu)) { |
| 4282 | .Fn => ty, | |
| 4283 | .Pointer => ty.childType(zcu), | |
| 4282 | .@"fn" => ty, | |
| 4283 | .pointer => ty.childType(zcu), | |
| 4284 | 4284 | else => unreachable, |
| 4285 | 4285 | }; |
| 4286 | 4286 | |
| ... | ... | @@ -4388,7 +4388,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 4388 | 4388 | }, |
| 4389 | 4389 | else => return self.fail("TODO implement calling bitcasted functions", .{}), |
| 4390 | 4390 | } else { |
| 4391 | assert(ty.zigTypeTag(zcu) == .Pointer); | |
| 4391 | assert(ty.zigTypeTag(zcu) == .pointer); | |
| 4392 | 4392 | const mcv = try self.resolveInst(callee); |
| 4393 | 4393 | try self.genSetReg(ty, .x30, mcv); |
| 4394 | 4394 | |
| ... | ... | @@ -4523,7 +4523,7 @@ fn cmp( |
| 4523 | 4523 | const pt = self.pt; |
| 4524 | 4524 | const zcu = pt.zcu; |
| 4525 | 4525 | const int_ty = switch (lhs_ty.zigTypeTag(zcu)) { |
| 4526 | .Optional => blk: { | |
| 4526 | .optional => blk: { | |
| 4527 | 4527 | const payload_ty = lhs_ty.optionalChild(zcu); |
| 4528 | 4528 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 4529 | 4529 | break :blk Type.u1; |
| ... | ... | @@ -4533,12 +4533,12 @@ fn cmp( |
| 4533 | 4533 | return self.fail("TODO ARM cmp non-pointer optionals", .{}); |
| 4534 | 4534 | } |
| 4535 | 4535 | }, |
| 4536 | .Float => return self.fail("TODO ARM cmp floats", .{}), | |
| 4537 | .Enum => lhs_ty.intTagType(zcu), | |
| 4538 | .Int => lhs_ty, | |
| 4539 | .Bool => Type.u1, | |
| 4540 | .Pointer => Type.usize, | |
| 4541 | .ErrorSet => Type.u16, | |
| 4536 | .float => return self.fail("TODO ARM cmp floats", .{}), | |
| 4537 | .@"enum" => lhs_ty.intTagType(zcu), | |
| 4538 | .int => lhs_ty, | |
| 4539 | .bool => Type.u1, | |
| 4540 | .pointer => Type.usize, | |
| 4541 | .error_set => Type.u16, | |
| 4542 | 4542 | else => unreachable, |
| 4543 | 4543 | }; |
| 4544 | 4544 | |
| ... | ... | @@ -6243,7 +6243,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues { |
| 6243 | 6243 | var ncrn: usize = 0; // Next Core Register Number |
| 6244 | 6244 | var nsaa: u32 = 0; // Next stacked argument address |
| 6245 | 6245 | |
| 6246 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 6246 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 6247 | 6247 | result.return_value = .{ .unreach = {} }; |
| 6248 | 6248 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) { |
| 6249 | 6249 | result.return_value = .{ .none = {} }; |
| ... | ... | @@ -6301,7 +6301,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues { |
| 6301 | 6301 | result.stack_align = 16; |
| 6302 | 6302 | }, |
| 6303 | 6303 | .Unspecified => { |
| 6304 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 6304 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 6305 | 6305 | result.return_value = .{ .unreach = {} }; |
| 6306 | 6306 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) { |
| 6307 | 6307 | result.return_value = .{ .none = {} }; |
src/arch/aarch64/abi.zig+27-27| ... | ... | @@ -20,7 +20,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class { |
| 20 | 20 | |
| 21 | 21 | var maybe_float_bits: ?u16 = null; |
| 22 | 22 | switch (ty.zigTypeTag(zcu)) { |
| 23 | .Struct => { | |
| 23 | .@"struct" => { | |
| 24 | 24 | if (ty.containerLayout(zcu) == .@"packed") return .byval; |
| 25 | 25 | const float_count = countFloats(ty, zcu, &maybe_float_bits); |
| 26 | 26 | if (float_count <= sret_float_count) return .{ .float_array = float_count }; |
| ... | ... | @@ -30,7 +30,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class { |
| 30 | 30 | if (bit_size > 64) return .double_integer; |
| 31 | 31 | return .integer; |
| 32 | 32 | }, |
| 33 | .Union => { | |
| 33 | .@"union" => { | |
| 34 | 34 | if (ty.containerLayout(zcu) == .@"packed") return .byval; |
| 35 | 35 | const float_count = countFloats(ty, zcu, &maybe_float_bits); |
| 36 | 36 | if (float_count <= sret_float_count) return .{ .float_array = float_count }; |
| ... | ... | @@ -40,35 +40,35 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class { |
| 40 | 40 | if (bit_size > 64) return .double_integer; |
| 41 | 41 | return .integer; |
| 42 | 42 | }, |
| 43 | .Int, .Enum, .ErrorSet, .Float, .Bool => return .byval, | |
| 44 | .Vector => { | |
| 43 | .int, .@"enum", .error_set, .float, .bool => return .byval, | |
| 44 | .vector => { | |
| 45 | 45 | const bit_size = ty.bitSize(zcu); |
| 46 | 46 | // TODO is this controlled by a cpu feature? |
| 47 | 47 | if (bit_size > 128) return .memory; |
| 48 | 48 | return .byval; |
| 49 | 49 | }, |
| 50 | .Optional => { | |
| 50 | .optional => { | |
| 51 | 51 | std.debug.assert(ty.isPtrLikeOptional(zcu)); |
| 52 | 52 | return .byval; |
| 53 | 53 | }, |
| 54 | .Pointer => { | |
| 54 | .pointer => { | |
| 55 | 55 | std.debug.assert(!ty.isSlice(zcu)); |
| 56 | 56 | return .byval; |
| 57 | 57 | }, |
| 58 | .ErrorUnion, | |
| 59 | .Frame, | |
| 60 | .AnyFrame, | |
| 61 | .NoReturn, | |
| 62 | .Void, | |
| 63 | .Type, | |
| 64 | .ComptimeFloat, | |
| 65 | .ComptimeInt, | |
| 66 | .Undefined, | |
| 67 | .Null, | |
| 68 | .Fn, | |
| 69 | .Opaque, | |
| 70 | .EnumLiteral, | |
| 71 | .Array, | |
| 58 | .error_union, | |
| 59 | .frame, | |
| 60 | .@"anyframe", | |
| 61 | .noreturn, | |
| 62 | .void, | |
| 63 | .type, | |
| 64 | .comptime_float, | |
| 65 | .comptime_int, | |
| 66 | .undefined, | |
| 67 | .null, | |
| 68 | .@"fn", | |
| 69 | .@"opaque", | |
| 70 | .enum_literal, | |
| 71 | .array, | |
| 72 | 72 | => unreachable, |
| 73 | 73 | } |
| 74 | 74 | } |
| ... | ... | @@ -79,7 +79,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 { |
| 79 | 79 | const target = zcu.getTarget(); |
| 80 | 80 | const invalid = std.math.maxInt(u8); |
| 81 | 81 | switch (ty.zigTypeTag(zcu)) { |
| 82 | .Union => { | |
| 82 | .@"union" => { | |
| 83 | 83 | const union_obj = zcu.typeToUnion(ty).?; |
| 84 | 84 | var max_count: u8 = 0; |
| 85 | 85 | for (union_obj.field_types.get(ip)) |field_ty| { |
| ... | ... | @@ -90,7 +90,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 { |
| 90 | 90 | } |
| 91 | 91 | return max_count; |
| 92 | 92 | }, |
| 93 | .Struct => { | |
| 93 | .@"struct" => { | |
| 94 | 94 | const fields_len = ty.structFieldCount(zcu); |
| 95 | 95 | var count: u8 = 0; |
| 96 | 96 | var i: u32 = 0; |
| ... | ... | @@ -103,7 +103,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 { |
| 103 | 103 | } |
| 104 | 104 | return count; |
| 105 | 105 | }, |
| 106 | .Float => { | |
| 106 | .float => { | |
| 107 | 107 | const float_bits = maybe_float_bits.* orelse { |
| 108 | 108 | maybe_float_bits.* = ty.floatBits(target); |
| 109 | 109 | return 1; |
| ... | ... | @@ -111,7 +111,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 { |
| 111 | 111 | if (ty.floatBits(target) == float_bits) return 1; |
| 112 | 112 | return invalid; |
| 113 | 113 | }, |
| 114 | .Void => return 0, | |
| 114 | .void => return 0, | |
| 115 | 115 | else => return invalid, |
| 116 | 116 | } |
| 117 | 117 | } |
| ... | ... | @@ -119,14 +119,14 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 { |
| 119 | 119 | pub fn getFloatArrayType(ty: Type, zcu: *Zcu) ?Type { |
| 120 | 120 | const ip = &zcu.intern_pool; |
| 121 | 121 | switch (ty.zigTypeTag(zcu)) { |
| 122 | .Union => { | |
| 122 | .@"union" => { | |
| 123 | 123 | const union_obj = zcu.typeToUnion(ty).?; |
| 124 | 124 | for (union_obj.field_types.get(ip)) |field_ty| { |
| 125 | 125 | if (getFloatArrayType(Type.fromInterned(field_ty), zcu)) |some| return some; |
| 126 | 126 | } |
| 127 | 127 | return null; |
| 128 | 128 | }, |
| 129 | .Struct => { | |
| 129 | .@"struct" => { | |
| 130 | 130 | const fields_len = ty.structFieldCount(zcu); |
| 131 | 131 | var i: u32 = 0; |
| 132 | 132 | while (i < fields_len) : (i += 1) { |
| ... | ... | @@ -135,7 +135,7 @@ pub fn getFloatArrayType(ty: Type, zcu: *Zcu) ?Type { |
| 135 | 135 | } |
| 136 | 136 | return null; |
| 137 | 137 | }, |
| 138 | .Float => return ty, | |
| 138 | .float => return ty, | |
| 139 | 139 | else => return null, |
| 140 | 140 | } |
| 141 | 141 | } |
src/arch/arm/CodeGen.zig+58-58| ... | ... | @@ -1286,7 +1286,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 1286 | 1286 | .cpsr_flags => |cond| break :result MCValue{ .cpsr_flags = cond.negate() }, |
| 1287 | 1287 | else => { |
| 1288 | 1288 | switch (operand_ty.zigTypeTag(zcu)) { |
| 1289 | .Bool => { | |
| 1289 | .bool => { | |
| 1290 | 1290 | var op_reg: Register = undefined; |
| 1291 | 1291 | var dest_reg: Register = undefined; |
| 1292 | 1292 | |
| ... | ... | @@ -1316,8 +1316,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 1316 | 1316 | |
| 1317 | 1317 | break :result MCValue{ .register = dest_reg }; |
| 1318 | 1318 | }, |
| 1319 | .Vector => return self.fail("TODO bitwise not for vectors", .{}), | |
| 1320 | .Int => { | |
| 1319 | .vector => return self.fail("TODO bitwise not for vectors", .{}), | |
| 1320 | .int => { | |
| 1321 | 1321 | const int_info = operand_ty.intInfo(zcu); |
| 1322 | 1322 | if (int_info.bits <= 32) { |
| 1323 | 1323 | var op_reg: Register = undefined; |
| ... | ... | @@ -1375,9 +1375,9 @@ fn minMax( |
| 1375 | 1375 | const pt = self.pt; |
| 1376 | 1376 | const zcu = pt.zcu; |
| 1377 | 1377 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 1378 | .Float => return self.fail("TODO ARM min/max on floats", .{}), | |
| 1379 | .Vector => return self.fail("TODO ARM min/max on vectors", .{}), | |
| 1380 | .Int => { | |
| 1378 | .float => return self.fail("TODO ARM min/max on floats", .{}), | |
| 1379 | .vector => return self.fail("TODO ARM min/max on vectors", .{}), | |
| 1380 | .int => { | |
| 1381 | 1381 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 1382 | 1382 | const int_info = lhs_ty.intInfo(zcu); |
| 1383 | 1383 | if (int_info.bits <= 32) { |
| ... | ... | @@ -1596,8 +1596,8 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 1596 | 1596 | const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu)); |
| 1597 | 1597 | |
| 1598 | 1598 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 1599 | .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), | |
| 1600 | .Int => { | |
| 1599 | .vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), | |
| 1600 | .int => { | |
| 1601 | 1601 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 1602 | 1602 | const int_info = lhs_ty.intInfo(zcu); |
| 1603 | 1603 | if (int_info.bits < 32) { |
| ... | ... | @@ -1710,8 +1710,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 1710 | 1710 | const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu)); |
| 1711 | 1711 | |
| 1712 | 1712 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 1713 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 1714 | .Int => { | |
| 1713 | .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 1714 | .int => { | |
| 1715 | 1715 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 1716 | 1716 | const int_info = lhs_ty.intInfo(zcu); |
| 1717 | 1717 | if (int_info.bits <= 16) { |
| ... | ... | @@ -1873,8 +1873,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 1873 | 1873 | const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu)); |
| 1874 | 1874 | |
| 1875 | 1875 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 1876 | .Vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}), | |
| 1877 | .Int => { | |
| 1876 | .vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}), | |
| 1877 | .int => { | |
| 1878 | 1878 | const int_info = lhs_ty.intInfo(zcu); |
| 1879 | 1879 | if (int_info.bits <= 32) { |
| 1880 | 1880 | const stack_offset = try self.allocMem(tuple_size, tuple_align, inst); |
| ... | ... | @@ -3021,7 +3021,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 3021 | 3021 | const field_ptr = try self.resolveInst(extra.field_ptr); |
| 3022 | 3022 | const struct_ty = ty_pl.ty.toType().childType(zcu); |
| 3023 | 3023 | |
| 3024 | if (struct_ty.zigTypeTag(zcu) == .Union) { | |
| 3024 | if (struct_ty.zigTypeTag(zcu) == .@"union") { | |
| 3025 | 3025 | return self.fail("TODO implement @fieldParentPtr codegen for unions", .{}); |
| 3026 | 3026 | } |
| 3027 | 3027 | |
| ... | ... | @@ -3411,9 +3411,9 @@ fn addSub( |
| 3411 | 3411 | const pt = self.pt; |
| 3412 | 3412 | const zcu = pt.zcu; |
| 3413 | 3413 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3414 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3415 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3416 | .Int => { | |
| 3414 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3415 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3416 | .int => { | |
| 3417 | 3417 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 3418 | 3418 | const int_info = lhs_ty.intInfo(zcu); |
| 3419 | 3419 | if (int_info.bits <= 32) { |
| ... | ... | @@ -3468,9 +3468,9 @@ fn mul( |
| 3468 | 3468 | const pt = self.pt; |
| 3469 | 3469 | const zcu = pt.zcu; |
| 3470 | 3470 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3471 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3472 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3473 | .Int => { | |
| 3471 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3472 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3473 | .int => { | |
| 3474 | 3474 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 3475 | 3475 | const int_info = lhs_ty.intInfo(zcu); |
| 3476 | 3476 | if (int_info.bits <= 32) { |
| ... | ... | @@ -3502,8 +3502,8 @@ fn divFloat( |
| 3502 | 3502 | const pt = self.pt; |
| 3503 | 3503 | const zcu = pt.zcu; |
| 3504 | 3504 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3505 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3506 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3505 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3506 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3507 | 3507 | else => unreachable, |
| 3508 | 3508 | } |
| 3509 | 3509 | } |
| ... | ... | @@ -3519,9 +3519,9 @@ fn divTrunc( |
| 3519 | 3519 | const pt = self.pt; |
| 3520 | 3520 | const zcu = pt.zcu; |
| 3521 | 3521 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3522 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3523 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3524 | .Int => { | |
| 3522 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3523 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3524 | .int => { | |
| 3525 | 3525 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 3526 | 3526 | const int_info = lhs_ty.intInfo(zcu); |
| 3527 | 3527 | if (int_info.bits <= 32) { |
| ... | ... | @@ -3563,9 +3563,9 @@ fn divFloor( |
| 3563 | 3563 | const pt = self.pt; |
| 3564 | 3564 | const zcu = pt.zcu; |
| 3565 | 3565 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3566 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3567 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3568 | .Int => { | |
| 3566 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3567 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3568 | .int => { | |
| 3569 | 3569 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 3570 | 3570 | const int_info = lhs_ty.intInfo(zcu); |
| 3571 | 3571 | if (int_info.bits <= 32) { |
| ... | ... | @@ -3612,9 +3612,9 @@ fn divExact( |
| 3612 | 3612 | const pt = self.pt; |
| 3613 | 3613 | const zcu = pt.zcu; |
| 3614 | 3614 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3615 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3616 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3617 | .Int => return self.fail("TODO ARM div_exact", .{}), | |
| 3615 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3616 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3617 | .int => return self.fail("TODO ARM div_exact", .{}), | |
| 3618 | 3618 | else => unreachable, |
| 3619 | 3619 | } |
| 3620 | 3620 | } |
| ... | ... | @@ -3630,9 +3630,9 @@ fn rem( |
| 3630 | 3630 | const pt = self.pt; |
| 3631 | 3631 | const zcu = pt.zcu; |
| 3632 | 3632 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3633 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3634 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3635 | .Int => { | |
| 3633 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3634 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3635 | .int => { | |
| 3636 | 3636 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 3637 | 3637 | const int_info = lhs_ty.intInfo(zcu); |
| 3638 | 3638 | if (int_info.bits <= 32) { |
| ... | ... | @@ -3700,9 +3700,9 @@ fn modulo( |
| 3700 | 3700 | const pt = self.pt; |
| 3701 | 3701 | const zcu = pt.zcu; |
| 3702 | 3702 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3703 | .Float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3704 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3705 | .Int => return self.fail("TODO ARM zcu", .{}), | |
| 3703 | .float => return self.fail("TODO ARM binary operations on floats", .{}), | |
| 3704 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3705 | .int => return self.fail("TODO ARM zcu", .{}), | |
| 3706 | 3706 | else => unreachable, |
| 3707 | 3707 | } |
| 3708 | 3708 | } |
| ... | ... | @@ -3719,8 +3719,8 @@ fn wrappingArithmetic( |
| 3719 | 3719 | const pt = self.pt; |
| 3720 | 3720 | const zcu = pt.zcu; |
| 3721 | 3721 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3722 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3723 | .Int => { | |
| 3722 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3723 | .int => { | |
| 3724 | 3724 | const int_info = lhs_ty.intInfo(zcu); |
| 3725 | 3725 | if (int_info.bits <= 32) { |
| 3726 | 3726 | // Generate an add/sub/mul |
| ... | ... | @@ -3758,8 +3758,8 @@ fn bitwise( |
| 3758 | 3758 | const pt = self.pt; |
| 3759 | 3759 | const zcu = pt.zcu; |
| 3760 | 3760 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3761 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3762 | .Int => { | |
| 3761 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3762 | .int => { | |
| 3763 | 3763 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 3764 | 3764 | const int_info = lhs_ty.intInfo(zcu); |
| 3765 | 3765 | if (int_info.bits <= 32) { |
| ... | ... | @@ -3804,8 +3804,8 @@ fn shiftExact( |
| 3804 | 3804 | const pt = self.pt; |
| 3805 | 3805 | const zcu = pt.zcu; |
| 3806 | 3806 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3807 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3808 | .Int => { | |
| 3807 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3808 | .int => { | |
| 3809 | 3809 | const int_info = lhs_ty.intInfo(zcu); |
| 3810 | 3810 | if (int_info.bits <= 32) { |
| 3811 | 3811 | const rhs_immediate = try rhs_bind.resolveToImmediate(self); |
| ... | ... | @@ -3844,8 +3844,8 @@ fn shiftNormal( |
| 3844 | 3844 | const pt = self.pt; |
| 3845 | 3845 | const zcu = pt.zcu; |
| 3846 | 3846 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3847 | .Vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3848 | .Int => { | |
| 3847 | .vector => return self.fail("TODO ARM binary operations on vectors", .{}), | |
| 3848 | .int => { | |
| 3849 | 3849 | const int_info = lhs_ty.intInfo(zcu); |
| 3850 | 3850 | if (int_info.bits <= 32) { |
| 3851 | 3851 | // Generate a shl_exact/shr_exact |
| ... | ... | @@ -3888,7 +3888,7 @@ fn booleanOp( |
| 3888 | 3888 | const pt = self.pt; |
| 3889 | 3889 | const zcu = pt.zcu; |
| 3890 | 3890 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3891 | .Bool => { | |
| 3891 | .bool => { | |
| 3892 | 3892 | const lhs_immediate = try lhs_bind.resolveToImmediate(self); |
| 3893 | 3893 | const rhs_immediate = try rhs_bind.resolveToImmediate(self); |
| 3894 | 3894 | |
| ... | ... | @@ -3923,7 +3923,7 @@ fn ptrArithmetic( |
| 3923 | 3923 | const pt = self.pt; |
| 3924 | 3924 | const zcu = pt.zcu; |
| 3925 | 3925 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3926 | .Pointer => { | |
| 3926 | .pointer => { | |
| 3927 | 3927 | assert(rhs_ty.eql(Type.usize, zcu)); |
| 3928 | 3928 | |
| 3929 | 3929 | const ptr_ty = lhs_ty; |
| ... | ... | @@ -4259,8 +4259,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 4259 | 4259 | const ip = &zcu.intern_pool; |
| 4260 | 4260 | |
| 4261 | 4261 | const fn_ty = switch (ty.zigTypeTag(zcu)) { |
| 4262 | .Fn => ty, | |
| 4263 | .Pointer => ty.childType(zcu), | |
| 4262 | .@"fn" => ty, | |
| 4263 | .pointer => ty.childType(zcu), | |
| 4264 | 4264 | else => unreachable, |
| 4265 | 4265 | }; |
| 4266 | 4266 | |
| ... | ... | @@ -4337,7 +4337,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 4337 | 4337 | return self.fail("TODO implement calling bitcasted functions", .{}); |
| 4338 | 4338 | }, |
| 4339 | 4339 | } else { |
| 4340 | assert(ty.zigTypeTag(zcu) == .Pointer); | |
| 4340 | assert(ty.zigTypeTag(zcu) == .pointer); | |
| 4341 | 4341 | const mcv = try self.resolveInst(callee); |
| 4342 | 4342 | |
| 4343 | 4343 | try self.genSetReg(Type.usize, .lr, mcv); |
| ... | ... | @@ -4494,7 +4494,7 @@ fn cmp( |
| 4494 | 4494 | const pt = self.pt; |
| 4495 | 4495 | const zcu = pt.zcu; |
| 4496 | 4496 | const int_ty = switch (lhs_ty.zigTypeTag(zcu)) { |
| 4497 | .Optional => blk: { | |
| 4497 | .optional => blk: { | |
| 4498 | 4498 | const payload_ty = lhs_ty.optionalChild(zcu); |
| 4499 | 4499 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 4500 | 4500 | break :blk Type.u1; |
| ... | ... | @@ -4504,12 +4504,12 @@ fn cmp( |
| 4504 | 4504 | return self.fail("TODO ARM cmp non-pointer optionals", .{}); |
| 4505 | 4505 | } |
| 4506 | 4506 | }, |
| 4507 | .Float => return self.fail("TODO ARM cmp floats", .{}), | |
| 4508 | .Enum => lhs_ty.intTagType(zcu), | |
| 4509 | .Int => lhs_ty, | |
| 4510 | .Bool => Type.u1, | |
| 4511 | .Pointer => Type.usize, | |
| 4512 | .ErrorSet => Type.u16, | |
| 4507 | .float => return self.fail("TODO ARM cmp floats", .{}), | |
| 4508 | .@"enum" => lhs_ty.intTagType(zcu), | |
| 4509 | .int => lhs_ty, | |
| 4510 | .bool => Type.u1, | |
| 4511 | .pointer => Type.usize, | |
| 4512 | .error_set => Type.u16, | |
| 4513 | 4513 | else => unreachable, |
| 4514 | 4514 | }; |
| 4515 | 4515 | |
| ... | ... | @@ -6211,7 +6211,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues { |
| 6211 | 6211 | var ncrn: usize = 0; // Next Core Register Number |
| 6212 | 6212 | var nsaa: u32 = 0; // Next stacked argument address |
| 6213 | 6213 | |
| 6214 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 6214 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 6215 | 6215 | result.return_value = .{ .unreach = {} }; |
| 6216 | 6216 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 6217 | 6217 | result.return_value = .{ .none = {} }; |
| ... | ... | @@ -6258,7 +6258,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues { |
| 6258 | 6258 | result.stack_align = 8; |
| 6259 | 6259 | }, |
| 6260 | 6260 | .Unspecified => { |
| 6261 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 6261 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 6262 | 6262 | result.return_value = .{ .unreach = {} }; |
| 6263 | 6263 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) { |
| 6264 | 6264 | result.return_value = .{ .none = {} }; |
src/arch/arm/abi.zig+26-26| ... | ... | @@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class { |
| 31 | 31 | const max_byval_size = 512; |
| 32 | 32 | const ip = &zcu.intern_pool; |
| 33 | 33 | switch (ty.zigTypeTag(zcu)) { |
| 34 | .Struct => { | |
| 34 | .@"struct" => { | |
| 35 | 35 | const bit_size = ty.bitSize(zcu); |
| 36 | 36 | if (ty.containerLayout(zcu) == .@"packed") { |
| 37 | 37 | if (bit_size > 64) return .memory; |
| ... | ... | @@ -53,7 +53,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class { |
| 53 | 53 | } |
| 54 | 54 | return Class.arrSize(bit_size, 32); |
| 55 | 55 | }, |
| 56 | .Union => { | |
| 56 | .@"union" => { | |
| 57 | 57 | const bit_size = ty.bitSize(zcu); |
| 58 | 58 | const union_obj = zcu.typeToUnion(ty).?; |
| 59 | 59 | if (union_obj.flagsUnordered(ip).layout == .@"packed") { |
| ... | ... | @@ -73,48 +73,48 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class { |
| 73 | 73 | } |
| 74 | 74 | return Class.arrSize(bit_size, 32); |
| 75 | 75 | }, |
| 76 | .Bool, .Float => return .byval, | |
| 77 | .Int => { | |
| 76 | .bool, .float => return .byval, | |
| 77 | .int => { | |
| 78 | 78 | // TODO this is incorrect for _BitInt(128) but implementing |
| 79 | 79 | // this correctly makes implementing compiler-rt impossible. |
| 80 | 80 | // const bit_size = ty.bitSize(zcu); |
| 81 | 81 | // if (bit_size > 64) return .memory; |
| 82 | 82 | return .byval; |
| 83 | 83 | }, |
| 84 | .Enum, .ErrorSet => { | |
| 84 | .@"enum", .error_set => { | |
| 85 | 85 | const bit_size = ty.bitSize(zcu); |
| 86 | 86 | if (bit_size > 64) return .memory; |
| 87 | 87 | return .byval; |
| 88 | 88 | }, |
| 89 | .Vector => { | |
| 89 | .vector => { | |
| 90 | 90 | const bit_size = ty.bitSize(zcu); |
| 91 | 91 | // TODO is this controlled by a cpu feature? |
| 92 | 92 | if (ctx == .ret and bit_size > 128) return .memory; |
| 93 | 93 | if (bit_size > 512) return .memory; |
| 94 | 94 | return .byval; |
| 95 | 95 | }, |
| 96 | .Optional => { | |
| 96 | .optional => { | |
| 97 | 97 | assert(ty.isPtrLikeOptional(zcu)); |
| 98 | 98 | return .byval; |
| 99 | 99 | }, |
| 100 | .Pointer => { | |
| 100 | .pointer => { | |
| 101 | 101 | assert(!ty.isSlice(zcu)); |
| 102 | 102 | return .byval; |
| 103 | 103 | }, |
| 104 | .ErrorUnion, | |
| 105 | .Frame, | |
| 106 | .AnyFrame, | |
| 107 | .NoReturn, | |
| 108 | .Void, | |
| 109 | .Type, | |
| 110 | .ComptimeFloat, | |
| 111 | .ComptimeInt, | |
| 112 | .Undefined, | |
| 113 | .Null, | |
| 114 | .Fn, | |
| 115 | .Opaque, | |
| 116 | .EnumLiteral, | |
| 117 | .Array, | |
| 104 | .error_union, | |
| 105 | .frame, | |
| 106 | .@"anyframe", | |
| 107 | .noreturn, | |
| 108 | .void, | |
| 109 | .type, | |
| 110 | .comptime_float, | |
| 111 | .comptime_int, | |
| 112 | .undefined, | |
| 113 | .null, | |
| 114 | .@"fn", | |
| 115 | .@"opaque", | |
| 116 | .enum_literal, | |
| 117 | .array, | |
| 118 | 118 | => unreachable, |
| 119 | 119 | } |
| 120 | 120 | } |
| ... | ... | @@ -125,7 +125,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 { |
| 125 | 125 | const target = zcu.getTarget(); |
| 126 | 126 | const invalid = std.math.maxInt(u32); |
| 127 | 127 | switch (ty.zigTypeTag(zcu)) { |
| 128 | .Union => { | |
| 128 | .@"union" => { | |
| 129 | 129 | const union_obj = zcu.typeToUnion(ty).?; |
| 130 | 130 | var max_count: u32 = 0; |
| 131 | 131 | for (union_obj.field_types.get(ip)) |field_ty| { |
| ... | ... | @@ -136,7 +136,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 { |
| 136 | 136 | } |
| 137 | 137 | return max_count; |
| 138 | 138 | }, |
| 139 | .Struct => { | |
| 139 | .@"struct" => { | |
| 140 | 140 | const fields_len = ty.structFieldCount(zcu); |
| 141 | 141 | var count: u32 = 0; |
| 142 | 142 | var i: u32 = 0; |
| ... | ... | @@ -149,7 +149,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 { |
| 149 | 149 | } |
| 150 | 150 | return count; |
| 151 | 151 | }, |
| 152 | .Float => { | |
| 152 | .float => { | |
| 153 | 153 | const float_bits = maybe_float_bits.* orelse { |
| 154 | 154 | const float_bits = ty.floatBits(target); |
| 155 | 155 | if (float_bits != 32 and float_bits != 64) return invalid; |
| ... | ... | @@ -159,7 +159,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 { |
| 159 | 159 | if (ty.floatBits(target) == float_bits) return 1; |
| 160 | 160 | return invalid; |
| 161 | 161 | }, |
| 162 | .Void => return 0, | |
| 162 | .void => return 0, | |
| 163 | 163 | else => return invalid, |
| 164 | 164 | } |
| 165 | 165 | } |
src/arch/arm/bits.zig+2-2| ... | ... | @@ -1299,7 +1299,7 @@ pub const Instruction = union(enum) { |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | pub fn pop(cond: Condition, args: anytype) Instruction { |
| 1302 | if (@typeInfo(@TypeOf(args)) != .Struct) { | |
| 1302 | if (@typeInfo(@TypeOf(args)) != .@"struct") { | |
| 1303 | 1303 | @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args))); |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| ... | ... | @@ -1323,7 +1323,7 @@ pub const Instruction = union(enum) { |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | pub fn push(cond: Condition, args: anytype) Instruction { |
| 1326 | if (@typeInfo(@TypeOf(args)) != .Struct) { | |
| 1326 | if (@typeInfo(@TypeOf(args)) != .@"struct") { | |
| 1327 | 1327 | @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args))); |
| 1328 | 1328 | } |
| 1329 | 1329 |
src/arch/riscv64/CodeGen.zig+55-55| ... | ... | @@ -675,14 +675,14 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt |
| 675 | 675 | ) |inst, *tracking| tracking.resurrect(inst, state.scope_generation); |
| 676 | 676 | for (deaths) |death| try func.processDeath(death); |
| 677 | 677 | |
| 678 | const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).Array.len]RegisterLock; | |
| 678 | const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock; | |
| 679 | 679 | var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) = |
| 680 | 680 | if (opts.update_tracking) |
| 681 | 681 | {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa); |
| 682 | 682 | |
| 683 | 683 | var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity( |
| 684 | 684 | stack.get(), |
| 685 | @typeInfo(ExpectedContents).Array.len, | |
| 685 | @typeInfo(ExpectedContents).array.len, | |
| 686 | 686 | ); |
| 687 | 687 | defer if (!opts.update_tracking) { |
| 688 | 688 | for (reg_locks.items) |lock| func.register_manager.unlockReg(lock); |
| ... | ... | @@ -1382,7 +1382,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 1382 | 1382 | const zcu = pt.zcu; |
| 1383 | 1383 | const ip = &zcu.intern_pool; |
| 1384 | 1384 | switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) { |
| 1385 | .Enum => { | |
| 1385 | .@"enum" => { | |
| 1386 | 1386 | const enum_ty = Type.fromInterned(lazy_sym.ty); |
| 1387 | 1387 | wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)}); |
| 1388 | 1388 | |
| ... | ... | @@ -1945,7 +1945,7 @@ fn memSize(func: *Func, ty: Type) Memory.Size { |
| 1945 | 1945 | const pt = func.pt; |
| 1946 | 1946 | const zcu = pt.zcu; |
| 1947 | 1947 | return switch (ty.zigTypeTag(zcu)) { |
| 1948 | .Float => Memory.Size.fromBitSize(ty.floatBits(func.target.*)), | |
| 1948 | .float => Memory.Size.fromBitSize(ty.floatBits(func.target.*)), | |
| 1949 | 1949 | else => Memory.Size.fromByteSize(ty.abiSize(zcu)), |
| 1950 | 1950 | }; |
| 1951 | 1951 | } |
| ... | ... | @@ -2094,24 +2094,24 @@ fn typeRegClass(func: *Func, ty: Type) abi.RegisterClass { |
| 2094 | 2094 | const pt = func.pt; |
| 2095 | 2095 | const zcu = pt.zcu; |
| 2096 | 2096 | return switch (ty.zigTypeTag(zcu)) { |
| 2097 | .Float => .float, | |
| 2098 | .Vector => .vector, | |
| 2097 | .float => .float, | |
| 2098 | .vector => .vector, | |
| 2099 | 2099 | else => .int, |
| 2100 | 2100 | }; |
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | fn regGeneralClassForType(func: *Func, ty: Type) RegisterManager.RegisterBitSet { |
| 2104 | 2104 | return switch (ty.zigTypeTag(func.pt.zcu)) { |
| 2105 | .Float => abi.Registers.Float.general_purpose, | |
| 2106 | .Vector => abi.Registers.Vector.general_purpose, | |
| 2105 | .float => abi.Registers.Float.general_purpose, | |
| 2106 | .vector => abi.Registers.Vector.general_purpose, | |
| 2107 | 2107 | else => abi.Registers.Integer.general_purpose, |
| 2108 | 2108 | }; |
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | 2111 | fn regTempClassForType(func: *Func, ty: Type) RegisterManager.RegisterBitSet { |
| 2112 | 2112 | return switch (ty.zigTypeTag(func.pt.zcu)) { |
| 2113 | .Float => abi.Registers.Float.temporary, | |
| 2114 | .Vector => abi.Registers.Vector.general_purpose, // there are no temporary vector registers | |
| 2113 | .float => abi.Registers.Float.temporary, | |
| 2114 | .vector => abi.Registers.Vector.general_purpose, // there are no temporary vector registers | |
| 2115 | 2115 | else => abi.Registers.Integer.temporary, |
| 2116 | 2116 | }; |
| 2117 | 2117 | } |
| ... | ... | @@ -2122,8 +2122,8 @@ fn allocRegOrMem(func: *Func, elem_ty: Type, inst: ?Air.Inst.Index, reg_ok: bool |
| 2122 | 2122 | |
| 2123 | 2123 | const bit_size = elem_ty.bitSize(zcu); |
| 2124 | 2124 | const min_size: u64 = switch (elem_ty.zigTypeTag(zcu)) { |
| 2125 | .Float => if (func.hasFeature(.d)) 64 else 32, | |
| 2126 | .Vector => 256, // TODO: calculate it from avl * vsew | |
| 2125 | .float => if (func.hasFeature(.d)) 64 else 32, | |
| 2126 | .vector => 256, // TODO: calculate it from avl * vsew | |
| 2127 | 2127 | else => 64, |
| 2128 | 2128 | }; |
| 2129 | 2129 | |
| ... | ... | @@ -2131,7 +2131,7 @@ fn allocRegOrMem(func: *Func, elem_ty: Type, inst: ?Air.Inst.Index, reg_ok: bool |
| 2131 | 2131 | if (func.register_manager.tryAllocReg(inst, func.regGeneralClassForType(elem_ty))) |reg| { |
| 2132 | 2132 | return .{ .register = reg }; |
| 2133 | 2133 | } |
| 2134 | } else if (reg_ok and elem_ty.zigTypeTag(zcu) == .Vector) { | |
| 2134 | } else if (reg_ok and elem_ty.zigTypeTag(zcu) == .vector) { | |
| 2135 | 2135 | return func.fail("did you forget to extend vector registers before allocating", .{}); |
| 2136 | 2136 | } |
| 2137 | 2137 | |
| ... | ... | @@ -2358,7 +2358,7 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void { |
| 2358 | 2358 | (try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register; |
| 2359 | 2359 | |
| 2360 | 2360 | switch (ty.zigTypeTag(zcu)) { |
| 2361 | .Bool => { | |
| 2361 | .bool => { | |
| 2362 | 2362 | _ = try func.addInst(.{ |
| 2363 | 2363 | .tag = .pseudo_not, |
| 2364 | 2364 | .data = .{ |
| ... | ... | @@ -2369,7 +2369,7 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void { |
| 2369 | 2369 | }, |
| 2370 | 2370 | }); |
| 2371 | 2371 | }, |
| 2372 | .Int => { | |
| 2372 | .int => { | |
| 2373 | 2373 | const size = ty.bitSize(zcu); |
| 2374 | 2374 | if (!math.isPowerOfTwo(size)) |
| 2375 | 2375 | return func.fail("TODO: airNot non-pow 2 int size", .{}); |
| ... | ... | @@ -2485,7 +2485,7 @@ fn binOp( |
| 2485 | 2485 | |
| 2486 | 2486 | // don't have support for certain sizes of addition |
| 2487 | 2487 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2488 | .Vector => {}, // works differently and fails in a different place | |
| 2488 | .vector => {}, // works differently and fails in a different place | |
| 2489 | 2489 | else => if (lhs_ty.bitSize(zcu) > 64) return func.fail("TODO: binOp >= 64 bits", .{}), |
| 2490 | 2490 | } |
| 2491 | 2491 | |
| ... | ... | @@ -2578,7 +2578,7 @@ fn genBinOp( |
| 2578 | 2578 | } |
| 2579 | 2579 | |
| 2580 | 2580 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2581 | .Int => { | |
| 2581 | .int => { | |
| 2582 | 2582 | const mnem: Mnemonic = switch (tag) { |
| 2583 | 2583 | .add, .add_wrap => switch (bit_size) { |
| 2584 | 2584 | 8, 16, 64 => .add, |
| ... | ... | @@ -2617,7 +2617,7 @@ fn genBinOp( |
| 2617 | 2617 | }, |
| 2618 | 2618 | }); |
| 2619 | 2619 | }, |
| 2620 | .Float => { | |
| 2620 | .float => { | |
| 2621 | 2621 | const mir_tag: Mnemonic = switch (tag) { |
| 2622 | 2622 | .add => switch (bit_size) { |
| 2623 | 2623 | 32 => .fadds, |
| ... | ... | @@ -2648,7 +2648,7 @@ fn genBinOp( |
| 2648 | 2648 | }, |
| 2649 | 2649 | }); |
| 2650 | 2650 | }, |
| 2651 | .Vector => { | |
| 2651 | .vector => { | |
| 2652 | 2652 | const num_elem = lhs_ty.vectorLen(zcu); |
| 2653 | 2653 | const elem_size = lhs_ty.childType(zcu).bitSize(zcu); |
| 2654 | 2654 | |
| ... | ... | @@ -2656,18 +2656,18 @@ fn genBinOp( |
| 2656 | 2656 | |
| 2657 | 2657 | const mir_tag: Mnemonic = switch (tag) { |
| 2658 | 2658 | .add => switch (child_ty.zigTypeTag(zcu)) { |
| 2659 | .Int => .vaddvv, | |
| 2660 | .Float => .vfaddvv, | |
| 2659 | .int => .vaddvv, | |
| 2660 | .float => .vfaddvv, | |
| 2661 | 2661 | else => unreachable, |
| 2662 | 2662 | }, |
| 2663 | 2663 | .sub => switch (child_ty.zigTypeTag(zcu)) { |
| 2664 | .Int => .vsubvv, | |
| 2665 | .Float => .vfsubvv, | |
| 2664 | .int => .vsubvv, | |
| 2665 | .float => .vfsubvv, | |
| 2666 | 2666 | else => unreachable, |
| 2667 | 2667 | }, |
| 2668 | 2668 | .mul => switch (child_ty.zigTypeTag(zcu)) { |
| 2669 | .Int => .vmulvv, | |
| 2670 | .Float => .vfmulvv, | |
| 2669 | .int => .vmulvv, | |
| 2670 | .float => .vfmulvv, | |
| 2671 | 2671 | else => unreachable, |
| 2672 | 2672 | }, |
| 2673 | 2673 | else => return func.fail("TODO: genBinOp {s} Vector", .{@tagName(tag)}), |
| ... | ... | @@ -2905,7 +2905,7 @@ fn genBinOp( |
| 2905 | 2905 | // s0 was 0, leaving a2 unchanged as a0. |
| 2906 | 2906 | .min, .max => { |
| 2907 | 2907 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2908 | .Int => { | |
| 2908 | .int => { | |
| 2909 | 2909 | const int_info = lhs_ty.intInfo(zcu); |
| 2910 | 2910 | |
| 2911 | 2911 | const mask_reg, const mask_lock = try func.allocReg(.int); |
| ... | ... | @@ -2981,8 +2981,8 @@ fn airAddWithOverflow(func: *Func, inst: Air.Inst.Index) !void { |
| 2981 | 2981 | |
| 2982 | 2982 | const result: MCValue = if (func.liveness.isUnused(inst)) .unreach else result: { |
| 2983 | 2983 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2984 | .Vector => return func.fail("TODO implement add with overflow for Vector type", .{}), | |
| 2985 | .Int => { | |
| 2984 | .vector => return func.fail("TODO implement add with overflow for Vector type", .{}), | |
| 2985 | .int => { | |
| 2986 | 2986 | const int_info = lhs_ty.intInfo(zcu); |
| 2987 | 2987 | |
| 2988 | 2988 | const tuple_ty = func.typeOfIndex(inst); |
| ... | ... | @@ -3263,7 +3263,7 @@ fn airMulWithOverflow(func: *Func, inst: Air.Inst.Index) !void { |
| 3263 | 3263 | |
| 3264 | 3264 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3265 | 3265 | else => |x| return func.fail("TODO: airMulWithOverflow {s}", .{@tagName(x)}), |
| 3266 | .Int => { | |
| 3266 | .int => { | |
| 3267 | 3267 | if (std.debug.runtime_safety) assert(lhs_ty.eql(rhs_ty, zcu)); |
| 3268 | 3268 | |
| 3269 | 3269 | const trunc_reg = try func.copyToTmpRegister(lhs_ty, .{ .register = dest_reg }); |
| ... | ... | @@ -4129,7 +4129,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { |
| 4129 | 4129 | const operand = try func.resolveInst(ty_op.operand); |
| 4130 | 4130 | |
| 4131 | 4131 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 4132 | .Int => if (ty.zigTypeTag(zcu) == .Vector) { | |
| 4132 | .int => if (ty.zigTypeTag(zcu) == .vector) { | |
| 4133 | 4133 | return func.fail("TODO implement airAbs for {}", .{ty.fmt(pt)}); |
| 4134 | 4134 | } else { |
| 4135 | 4135 | const int_info = scalar_ty.intInfo(zcu); |
| ... | ... | @@ -4182,7 +4182,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { |
| 4182 | 4182 | |
| 4183 | 4183 | break :result return_mcv; |
| 4184 | 4184 | }, |
| 4185 | .Float => { | |
| 4185 | .float => { | |
| 4186 | 4186 | const float_bits = scalar_ty.floatBits(zcu.getTarget()); |
| 4187 | 4187 | const mnem: Mnemonic = switch (float_bits) { |
| 4188 | 4188 | 16 => return func.fail("TODO: airAbs 16-bit float", .{}), |
| ... | ... | @@ -4228,7 +4228,7 @@ fn airByteSwap(func: *Func, inst: Air.Inst.Index) !void { |
| 4228 | 4228 | const operand = try func.resolveInst(ty_op.operand); |
| 4229 | 4229 | |
| 4230 | 4230 | switch (ty.zigTypeTag(zcu)) { |
| 4231 | .Int => { | |
| 4231 | .int => { | |
| 4232 | 4232 | const int_bits = ty.intInfo(zcu).bits; |
| 4233 | 4233 | |
| 4234 | 4234 | // bytes are no-op |
| ... | ... | @@ -4308,7 +4308,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 4308 | 4308 | defer func.register_manager.unlockReg(dst_lock); |
| 4309 | 4309 | |
| 4310 | 4310 | switch (ty.zigTypeTag(zcu)) { |
| 4311 | .Float => { | |
| 4311 | .float => { | |
| 4312 | 4312 | assert(dst_class == .float); |
| 4313 | 4313 | |
| 4314 | 4314 | switch (operand_bit_size) { |
| ... | ... | @@ -4334,7 +4334,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 4334 | 4334 | else => return func.fail("TODO: airUnaryMath Float {s}", .{@tagName(tag)}), |
| 4335 | 4335 | } |
| 4336 | 4336 | }, |
| 4337 | .Int => { | |
| 4337 | .int => { | |
| 4338 | 4338 | assert(dst_class == .int); |
| 4339 | 4339 | |
| 4340 | 4340 | switch (tag) { |
| ... | ... | @@ -4824,8 +4824,8 @@ fn genCall( |
| 4824 | 4824 | .air => |callee| fn_info: { |
| 4825 | 4825 | const callee_ty = func.typeOf(callee); |
| 4826 | 4826 | break :fn_info switch (callee_ty.zigTypeTag(zcu)) { |
| 4827 | .Fn => callee_ty, | |
| 4828 | .Pointer => callee_ty.childType(zcu), | |
| 4827 | .@"fn" => callee_ty, | |
| 4828 | .pointer => callee_ty.childType(zcu), | |
| 4829 | 4829 | else => unreachable, |
| 4830 | 4830 | }; |
| 4831 | 4831 | }, |
| ... | ... | @@ -4977,7 +4977,7 @@ fn genCall( |
| 4977 | 4977 | else => return func.fail("TODO implement calling bitcasted functions", .{}), |
| 4978 | 4978 | } |
| 4979 | 4979 | } else { |
| 4980 | assert(func.typeOf(callee).zigTypeTag(zcu) == .Pointer); | |
| 4980 | assert(func.typeOf(callee).zigTypeTag(zcu) == .pointer); | |
| 4981 | 4981 | const addr_reg, const addr_lock = try func.allocReg(.int); |
| 4982 | 4982 | defer func.register_manager.unlockReg(addr_lock); |
| 4983 | 4983 | try func.genSetReg(Type.u64, addr_reg, .{ .air_ref = callee }); |
| ... | ... | @@ -5105,20 +5105,20 @@ fn airCmp(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 5105 | 5105 | const lhs_ty = func.typeOf(bin_op.lhs); |
| 5106 | 5106 | |
| 5107 | 5107 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 5108 | .Int, | |
| 5109 | .Enum, | |
| 5110 | .Bool, | |
| 5111 | .Pointer, | |
| 5112 | .ErrorSet, | |
| 5113 | .Optional, | |
| 5108 | .int, | |
| 5109 | .@"enum", | |
| 5110 | .bool, | |
| 5111 | .pointer, | |
| 5112 | .error_set, | |
| 5113 | .optional, | |
| 5114 | 5114 | => { |
| 5115 | 5115 | const int_ty = switch (lhs_ty.zigTypeTag(zcu)) { |
| 5116 | .Enum => lhs_ty.intTagType(zcu), | |
| 5117 | .Int => lhs_ty, | |
| 5118 | .Bool => Type.u1, | |
| 5119 | .Pointer => Type.u64, | |
| 5120 | .ErrorSet => Type.anyerror, | |
| 5121 | .Optional => blk: { | |
| 5116 | .@"enum" => lhs_ty.intTagType(zcu), | |
| 5117 | .int => lhs_ty, | |
| 5118 | .bool => Type.u1, | |
| 5119 | .pointer => Type.u64, | |
| 5120 | .error_set => Type.anyerror, | |
| 5121 | .optional => blk: { | |
| 5122 | 5122 | const payload_ty = lhs_ty.optionalChild(zcu); |
| 5123 | 5123 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 5124 | 5124 | break :blk Type.u1; |
| ... | ... | @@ -5138,7 +5138,7 @@ fn airCmp(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 5138 | 5138 | return func.fail("TODO riscv cmp for ints > 64 bits", .{}); |
| 5139 | 5139 | } |
| 5140 | 5140 | }, |
| 5141 | .Float => { | |
| 5141 | .float => { | |
| 5142 | 5142 | const float_bits = lhs_ty.floatBits(func.target.*); |
| 5143 | 5143 | const float_reg_size: u32 = if (func.hasFeature(.d)) 64 else 32; |
| 5144 | 5144 | if (float_bits > float_reg_size) { |
| ... | ... | @@ -7456,8 +7456,8 @@ fn airAtomicRmw(func: *Func, inst: Air.Inst.Index) !void { |
| 7456 | 7456 | return func.fail("TODO: airAtomicRmw non-pow 2", .{}); |
| 7457 | 7457 | |
| 7458 | 7458 | switch (val_ty.zigTypeTag(pt.zcu)) { |
| 7459 | .Enum, .Int => {}, | |
| 7460 | inline .Bool, .Float, .Pointer => |ty| return func.fail("TODO: airAtomicRmw {s}", .{@tagName(ty)}), | |
| 7459 | .@"enum", .int => {}, | |
| 7460 | inline .bool, .float, .pointer => |ty| return func.fail("TODO: airAtomicRmw {s}", .{@tagName(ty)}), | |
| 7461 | 7461 | else => unreachable, |
| 7462 | 7462 | } |
| 7463 | 7463 | |
| ... | ... | @@ -7861,7 +7861,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void { |
| 7861 | 7861 | |
| 7862 | 7862 | const result: MCValue = result: { |
| 7863 | 7863 | switch (result_ty.zigTypeTag(zcu)) { |
| 7864 | .Struct => { | |
| 7864 | .@"struct" => { | |
| 7865 | 7865 | const frame_index = try func.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu)); |
| 7866 | 7866 | if (result_ty.containerLayout(zcu) == .@"packed") { |
| 7867 | 7867 | const struct_obj = zcu.typeToStruct(result_ty).?; |
| ... | ... | @@ -7916,7 +7916,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void { |
| 7916 | 7916 | } |
| 7917 | 7917 | break :result .{ .load_frame = .{ .index = frame_index } }; |
| 7918 | 7918 | }, |
| 7919 | .Array => { | |
| 7919 | .array => { | |
| 7920 | 7920 | const elem_ty = result_ty.childType(zcu); |
| 7921 | 7921 | const frame_index = try func.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu)); |
| 7922 | 7922 | const elem_size: u32 = @intCast(elem_ty.abiSize(zcu)); |
| ... | ... | @@ -8099,7 +8099,7 @@ fn resolveCallingConventionValues( |
| 8099 | 8099 | result.stack_align = .@"16"; |
| 8100 | 8100 | |
| 8101 | 8101 | // Return values |
| 8102 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 8102 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 8103 | 8103 | result.return_value = InstTracking.init(.unreach); |
| 8104 | 8104 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 8105 | 8105 | result.return_value = InstTracking.init(.none); |
src/arch/riscv64/abi.zig+31-31| ... | ... | @@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class { |
| 15 | 15 | |
| 16 | 16 | const max_byval_size = target.ptrBitWidth() * 2; |
| 17 | 17 | switch (ty.zigTypeTag(zcu)) { |
| 18 | .Struct => { | |
| 18 | .@"struct" => { | |
| 19 | 19 | const bit_size = ty.bitSize(zcu); |
| 20 | 20 | if (ty.containerLayout(zcu) == .@"packed") { |
| 21 | 21 | if (bit_size > max_byval_size) return .memory; |
| ... | ... | @@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class { |
| 44 | 44 | if (bit_size > max_byval_size / 2) return .double_integer; |
| 45 | 45 | return .integer; |
| 46 | 46 | }, |
| 47 | .Union => { | |
| 47 | .@"union" => { | |
| 48 | 48 | const bit_size = ty.bitSize(zcu); |
| 49 | 49 | if (ty.containerLayout(zcu) == .@"packed") { |
| 50 | 50 | if (bit_size > max_byval_size) return .memory; |
| ... | ... | @@ -55,40 +55,40 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class { |
| 55 | 55 | if (bit_size > max_byval_size / 2) return .double_integer; |
| 56 | 56 | return .integer; |
| 57 | 57 | }, |
| 58 | .Bool => return .integer, | |
| 59 | .Float => return .byval, | |
| 60 | .Int, .Enum, .ErrorSet => { | |
| 58 | .bool => return .integer, | |
| 59 | .float => return .byval, | |
| 60 | .int, .@"enum", .error_set => { | |
| 61 | 61 | const bit_size = ty.bitSize(zcu); |
| 62 | 62 | if (bit_size > max_byval_size) return .memory; |
| 63 | 63 | return .byval; |
| 64 | 64 | }, |
| 65 | .Vector => { | |
| 65 | .vector => { | |
| 66 | 66 | const bit_size = ty.bitSize(zcu); |
| 67 | 67 | if (bit_size > max_byval_size) return .memory; |
| 68 | 68 | return .integer; |
| 69 | 69 | }, |
| 70 | .Optional => { | |
| 70 | .optional => { | |
| 71 | 71 | std.debug.assert(ty.isPtrLikeOptional(zcu)); |
| 72 | 72 | return .byval; |
| 73 | 73 | }, |
| 74 | .Pointer => { | |
| 74 | .pointer => { | |
| 75 | 75 | std.debug.assert(!ty.isSlice(zcu)); |
| 76 | 76 | return .byval; |
| 77 | 77 | }, |
| 78 | .ErrorUnion, | |
| 79 | .Frame, | |
| 80 | .AnyFrame, | |
| 81 | .NoReturn, | |
| 82 | .Void, | |
| 83 | .Type, | |
| 84 | .ComptimeFloat, | |
| 85 | .ComptimeInt, | |
| 86 | .Undefined, | |
| 87 | .Null, | |
| 88 | .Fn, | |
| 89 | .Opaque, | |
| 90 | .EnumLiteral, | |
| 91 | .Array, | |
| 78 | .error_union, | |
| 79 | .frame, | |
| 80 | .@"anyframe", | |
| 81 | .noreturn, | |
| 82 | .void, | |
| 83 | .type, | |
| 84 | .comptime_float, | |
| 85 | .comptime_int, | |
| 86 | .undefined, | |
| 87 | .null, | |
| 88 | .@"fn", | |
| 89 | .@"opaque", | |
| 90 | .enum_literal, | |
| 91 | .array, | |
| 92 | 92 | => unreachable, |
| 93 | 93 | } |
| 94 | 94 | } |
| ... | ... | @@ -104,11 +104,11 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 104 | 104 | .none, .none, .none, .none, |
| 105 | 105 | }; |
| 106 | 106 | switch (ty.zigTypeTag(zcu)) { |
| 107 | .Bool, .Void, .NoReturn => { | |
| 107 | .bool, .void, .noreturn => { | |
| 108 | 108 | result[0] = .integer; |
| 109 | 109 | return result; |
| 110 | 110 | }, |
| 111 | .Pointer => switch (ty.ptrSize(zcu)) { | |
| 111 | .pointer => switch (ty.ptrSize(zcu)) { | |
| 112 | 112 | .Slice => { |
| 113 | 113 | result[0] = .integer; |
| 114 | 114 | result[1] = .integer; |
| ... | ... | @@ -119,14 +119,14 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 119 | 119 | return result; |
| 120 | 120 | }, |
| 121 | 121 | }, |
| 122 | .Optional => { | |
| 122 | .optional => { | |
| 123 | 123 | if (ty.isPtrLikeOptional(zcu)) { |
| 124 | 124 | result[0] = .integer; |
| 125 | 125 | return result; |
| 126 | 126 | } |
| 127 | 127 | return memory_class; |
| 128 | 128 | }, |
| 129 | .Int, .Enum, .ErrorSet => { | |
| 129 | .int, .@"enum", .error_set => { | |
| 130 | 130 | const int_bits = ty.intInfo(zcu).bits; |
| 131 | 131 | if (int_bits <= 64) { |
| 132 | 132 | result[0] = .integer; |
| ... | ... | @@ -139,7 +139,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 139 | 139 | } |
| 140 | 140 | unreachable; // support > 128 bit int arguments |
| 141 | 141 | }, |
| 142 | .Float => { | |
| 142 | .float => { | |
| 143 | 143 | const target = zcu.getTarget(); |
| 144 | 144 | const features = target.cpu.features; |
| 145 | 145 | |
| ... | ... | @@ -151,7 +151,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 151 | 151 | } |
| 152 | 152 | unreachable; // support split float args |
| 153 | 153 | }, |
| 154 | .ErrorUnion => { | |
| 154 | .error_union => { | |
| 155 | 155 | const payload_ty = ty.errorUnionPayload(zcu); |
| 156 | 156 | const payload_bits = payload_ty.bitSize(zcu); |
| 157 | 157 | |
| ... | ... | @@ -163,7 +163,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 163 | 163 | |
| 164 | 164 | return memory_class; |
| 165 | 165 | }, |
| 166 | .Struct, .Union => { | |
| 166 | .@"struct", .@"union" => { | |
| 167 | 167 | const layout = ty.containerLayout(zcu); |
| 168 | 168 | const ty_size = ty.abiSize(zcu); |
| 169 | 169 | |
| ... | ... | @@ -176,7 +176,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 176 | 176 | |
| 177 | 177 | return memory_class; |
| 178 | 178 | }, |
| 179 | .Array => { | |
| 179 | .array => { | |
| 180 | 180 | const ty_size = ty.abiSize(zcu); |
| 181 | 181 | if (ty_size <= 8) { |
| 182 | 182 | result[0] = .integer; |
| ... | ... | @@ -189,7 +189,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 189 | 189 | } |
| 190 | 190 | return memory_class; |
| 191 | 191 | }, |
| 192 | .Vector => { | |
| 192 | .vector => { | |
| 193 | 193 | // we pass vectors through integer registers if they are small enough to fit. |
| 194 | 194 | const vec_bits = ty.totalVectorBits(zcu); |
| 195 | 195 | if (vec_bits <= 64) { |
src/arch/riscv64/bits.zig+3-3| ... | ... | @@ -115,7 +115,7 @@ pub const Immediate = union(enum) { |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | pub fn asBits(imm: Immediate, comptime T: type) T { |
| 118 | const int_info = @typeInfo(T).Int; | |
| 118 | const int_info = @typeInfo(T).int; | |
| 119 | 119 | if (int_info.signedness != .unsigned) @compileError("Immediate.asBits needs unsigned T"); |
| 120 | 120 | return switch (imm) { |
| 121 | 121 | .signed => |x| @bitCast(@as(std.meta.Int(.signed, int_info.bits), @intCast(x))), |
| ... | ... | @@ -189,7 +189,7 @@ pub const Register = enum(u8) { |
| 189 | 189 | /// The goal of this function is to return the same ID for `zero` and `x0` but two |
| 190 | 190 | /// seperate IDs for `x0` and `f0`. We will assume that each register set has 32 registers |
| 191 | 191 | /// and is repeated twice, once for the named version, once for the number version. |
| 192 | pub fn id(reg: Register) std.math.IntFittingRange(0, @typeInfo(Register).Enum.fields.len) { | |
| 192 | pub fn id(reg: Register) std.math.IntFittingRange(0, @typeInfo(Register).@"enum".fields.len) { | |
| 193 | 193 | const base = switch (@intFromEnum(reg)) { |
| 194 | 194 | // zig fmt: off |
| 195 | 195 | @intFromEnum(Register.zero) ... @intFromEnum(Register.x31) => @intFromEnum(Register.zero), |
| ... | ... | @@ -252,7 +252,7 @@ pub const FrameIndex = enum(u32) { |
| 252 | 252 | /// Other indices are used for local variable stack slots |
| 253 | 253 | _, |
| 254 | 254 | |
| 255 | pub const named_count = @typeInfo(FrameIndex).Enum.fields.len; | |
| 255 | pub const named_count = @typeInfo(FrameIndex).@"enum".fields.len; | |
| 256 | 256 | |
| 257 | 257 | pub fn isNamed(fi: FrameIndex) bool { |
| 258 | 258 | return @intFromEnum(fi) < named_count; |
src/arch/sparc64/CodeGen.zig+39-39| ... | ... | @@ -770,8 +770,8 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 770 | 770 | const rhs_ty = self.typeOf(extra.rhs); |
| 771 | 771 | |
| 772 | 772 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 773 | .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), | |
| 774 | .Int => { | |
| 773 | .vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), | |
| 774 | .int => { | |
| 775 | 775 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 776 | 776 | const int_info = lhs_ty.intInfo(zcu); |
| 777 | 777 | switch (int_info.bits) { |
| ... | ... | @@ -1231,8 +1231,8 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void { |
| 1231 | 1231 | const operand = try self.resolveInst(ty_op.operand); |
| 1232 | 1232 | const operand_ty = self.typeOf(ty_op.operand); |
| 1233 | 1233 | switch (operand_ty.zigTypeTag(zcu)) { |
| 1234 | .Vector => return self.fail("TODO byteswap for vectors", .{}), | |
| 1235 | .Int => { | |
| 1234 | .vector => return self.fail("TODO byteswap for vectors", .{}), | |
| 1235 | .int => { | |
| 1236 | 1236 | const int_info = operand_ty.intInfo(zcu); |
| 1237 | 1237 | if (int_info.bits == 8) break :result operand; |
| 1238 | 1238 | |
| ... | ... | @@ -1310,8 +1310,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 1310 | 1310 | const zcu = pt.zcu; |
| 1311 | 1311 | const ip = &zcu.intern_pool; |
| 1312 | 1312 | const fn_ty = switch (ty.zigTypeTag(zcu)) { |
| 1313 | .Fn => ty, | |
| 1314 | .Pointer => ty.childType(zcu), | |
| 1313 | .@"fn" => ty, | |
| 1314 | .pointer => ty.childType(zcu), | |
| 1315 | 1315 | else => unreachable, |
| 1316 | 1316 | }; |
| 1317 | 1317 | |
| ... | ... | @@ -1363,7 +1363,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 1363 | 1363 | return self.fail("TODO implement calling bitcasted functions", .{}); |
| 1364 | 1364 | }, |
| 1365 | 1365 | } else { |
| 1366 | assert(ty.zigTypeTag(zcu) == .Pointer); | |
| 1366 | assert(ty.zigTypeTag(zcu) == .pointer); | |
| 1367 | 1367 | const mcv = try self.resolveInst(callee); |
| 1368 | 1368 | try self.genSetReg(ty, .o7, mcv); |
| 1369 | 1369 | |
| ... | ... | @@ -1419,13 +1419,13 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void { |
| 1419 | 1419 | const lhs_ty = self.typeOf(bin_op.lhs); |
| 1420 | 1420 | |
| 1421 | 1421 | const int_ty = switch (lhs_ty.zigTypeTag(zcu)) { |
| 1422 | .Vector => unreachable, // Handled by cmp_vector. | |
| 1423 | .Enum => lhs_ty.intTagType(zcu), | |
| 1424 | .Int => lhs_ty, | |
| 1425 | .Bool => Type.u1, | |
| 1426 | .Pointer => Type.usize, | |
| 1427 | .ErrorSet => Type.u16, | |
| 1428 | .Optional => blk: { | |
| 1422 | .vector => unreachable, // Handled by cmp_vector. | |
| 1423 | .@"enum" => lhs_ty.intTagType(zcu), | |
| 1424 | .int => lhs_ty, | |
| 1425 | .bool => Type.u1, | |
| 1426 | .pointer => Type.usize, | |
| 1427 | .error_set => Type.u16, | |
| 1428 | .optional => blk: { | |
| 1429 | 1429 | const payload_ty = lhs_ty.optionalChild(zcu); |
| 1430 | 1430 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 1431 | 1431 | break :blk Type.u1; |
| ... | ... | @@ -1435,7 +1435,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void { |
| 1435 | 1435 | return self.fail("TODO SPARCv9 cmp non-pointer optionals", .{}); |
| 1436 | 1436 | } |
| 1437 | 1437 | }, |
| 1438 | .Float => return self.fail("TODO SPARCv9 cmp floats", .{}), | |
| 1438 | .float => return self.fail("TODO SPARCv9 cmp floats", .{}), | |
| 1439 | 1439 | else => unreachable, |
| 1440 | 1440 | }; |
| 1441 | 1441 | |
| ... | ... | @@ -2031,8 +2031,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2031 | 2031 | const rhs_ty = self.typeOf(extra.rhs); |
| 2032 | 2032 | |
| 2033 | 2033 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2034 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 2035 | .Int => { | |
| 2034 | .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 2035 | .int => { | |
| 2036 | 2036 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2037 | 2037 | const int_info = lhs_ty.intInfo(zcu); |
| 2038 | 2038 | switch (int_info.bits) { |
| ... | ... | @@ -2105,7 +2105,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 2105 | 2105 | }, |
| 2106 | 2106 | else => { |
| 2107 | 2107 | switch (operand_ty.zigTypeTag(zcu)) { |
| 2108 | .Bool => { | |
| 2108 | .bool => { | |
| 2109 | 2109 | const op_reg = switch (operand) { |
| 2110 | 2110 | .register => |r| r, |
| 2111 | 2111 | else => try self.copyToTmpRegister(operand_ty, operand), |
| ... | ... | @@ -2136,8 +2136,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 2136 | 2136 | |
| 2137 | 2137 | break :result MCValue{ .register = dest_reg }; |
| 2138 | 2138 | }, |
| 2139 | .Vector => return self.fail("TODO bitwise not for vectors", .{}), | |
| 2140 | .Int => { | |
| 2139 | .vector => return self.fail("TODO bitwise not for vectors", .{}), | |
| 2140 | .int => { | |
| 2141 | 2141 | const int_info = operand_ty.intInfo(zcu); |
| 2142 | 2142 | if (int_info.bits <= 64) { |
| 2143 | 2143 | const op_reg = switch (operand) { |
| ... | ... | @@ -2329,8 +2329,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2329 | 2329 | const rhs_ty = self.typeOf(extra.rhs); |
| 2330 | 2330 | |
| 2331 | 2331 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2332 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 2333 | .Int => { | |
| 2332 | .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | |
| 2333 | .int => { | |
| 2334 | 2334 | const int_info = lhs_ty.intInfo(zcu); |
| 2335 | 2335 | if (int_info.bits <= 64) { |
| 2336 | 2336 | try self.spillConditionFlagsIfOccupied(); |
| ... | ... | @@ -2858,9 +2858,9 @@ fn binOp( |
| 2858 | 2858 | .cmp_eq, |
| 2859 | 2859 | => { |
| 2860 | 2860 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2861 | .Float => return self.fail("TODO binary operations on floats", .{}), | |
| 2862 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2863 | .Int => { | |
| 2861 | .float => return self.fail("TODO binary operations on floats", .{}), | |
| 2862 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2863 | .int => { | |
| 2864 | 2864 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2865 | 2865 | const int_info = lhs_ty.intInfo(zcu); |
| 2866 | 2866 | if (int_info.bits <= 64) { |
| ... | ... | @@ -2932,8 +2932,8 @@ fn binOp( |
| 2932 | 2932 | |
| 2933 | 2933 | // Truncate if necessary |
| 2934 | 2934 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2935 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2936 | .Int => { | |
| 2935 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2936 | .int => { | |
| 2937 | 2937 | const int_info = lhs_ty.intInfo(zcu); |
| 2938 | 2938 | if (int_info.bits <= 64) { |
| 2939 | 2939 | const result_reg = result.register; |
| ... | ... | @@ -2949,8 +2949,8 @@ fn binOp( |
| 2949 | 2949 | |
| 2950 | 2950 | .div_trunc => { |
| 2951 | 2951 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2952 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2953 | .Int => { | |
| 2952 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 2953 | .int => { | |
| 2954 | 2954 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2955 | 2955 | const int_info = lhs_ty.intInfo(zcu); |
| 2956 | 2956 | if (int_info.bits <= 64) { |
| ... | ... | @@ -2982,7 +2982,7 @@ fn binOp( |
| 2982 | 2982 | |
| 2983 | 2983 | .ptr_add => { |
| 2984 | 2984 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2985 | .Pointer => { | |
| 2985 | .pointer => { | |
| 2986 | 2986 | const ptr_ty = lhs_ty; |
| 2987 | 2987 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { |
| 2988 | 2988 | .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type |
| ... | ... | @@ -3014,7 +3014,7 @@ fn binOp( |
| 3014 | 3014 | .bool_or, |
| 3015 | 3015 | => { |
| 3016 | 3016 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3017 | .Bool => { | |
| 3017 | .bool => { | |
| 3018 | 3018 | assert(lhs != .immediate); // should have been handled by Sema |
| 3019 | 3019 | assert(rhs != .immediate); // should have been handled by Sema |
| 3020 | 3020 | |
| ... | ... | @@ -3044,8 +3044,8 @@ fn binOp( |
| 3044 | 3044 | |
| 3045 | 3045 | // Truncate if necessary |
| 3046 | 3046 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3047 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 3048 | .Int => { | |
| 3047 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 3048 | .int => { | |
| 3049 | 3049 | const int_info = lhs_ty.intInfo(zcu); |
| 3050 | 3050 | if (int_info.bits <= 64) { |
| 3051 | 3051 | // 32 and 64 bit operands doesn't need truncating |
| ... | ... | @@ -3066,8 +3066,8 @@ fn binOp( |
| 3066 | 3066 | .shr_exact, |
| 3067 | 3067 | => { |
| 3068 | 3068 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 3069 | .Vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 3070 | .Int => { | |
| 3069 | .vector => return self.fail("TODO binary operations on vectors", .{}), | |
| 3070 | .int => { | |
| 3071 | 3071 | const int_info = lhs_ty.intInfo(zcu); |
| 3072 | 3072 | if (int_info.bits <= 64) { |
| 3073 | 3073 | const rhs_immediate_ok = rhs == .immediate; |
| ... | ... | @@ -4329,9 +4329,9 @@ fn minMax( |
| 4329 | 4329 | const zcu = pt.zcu; |
| 4330 | 4330 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 4331 | 4331 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 4332 | .Float => return self.fail("TODO min/max on floats", .{}), | |
| 4333 | .Vector => return self.fail("TODO min/max on vectors", .{}), | |
| 4334 | .Int => { | |
| 4332 | .float => return self.fail("TODO min/max on floats", .{}), | |
| 4333 | .vector => return self.fail("TODO min/max on vectors", .{}), | |
| 4334 | .int => { | |
| 4335 | 4335 | const int_info = lhs_ty.intInfo(zcu); |
| 4336 | 4336 | if (int_info.bits <= 64) { |
| 4337 | 4337 | // TODO skip register setting when one of the operands |
| ... | ... | @@ -4515,7 +4515,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView) |
| 4515 | 4515 | result.stack_byte_count = next_stack_offset; |
| 4516 | 4516 | result.stack_align = .@"16"; |
| 4517 | 4517 | |
| 4518 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 4518 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 4519 | 4519 | result.return_value = .{ .unreach = {} }; |
| 4520 | 4520 | } else if (!ret_ty.hasRuntimeBits(zcu)) { |
| 4521 | 4521 | result.return_value = .{ .none = {} }; |
src/arch/wasm/CodeGen.zig+92-92| ... | ... | @@ -1004,19 +1004,19 @@ fn typeToValtype(ty: Type, pt: Zcu.PerThread, target: std.Target) wasm.Valtype { |
| 1004 | 1004 | const zcu = pt.zcu; |
| 1005 | 1005 | const ip = &zcu.intern_pool; |
| 1006 | 1006 | return switch (ty.zigTypeTag(zcu)) { |
| 1007 | .Float => switch (ty.floatBits(target)) { | |
| 1007 | .float => switch (ty.floatBits(target)) { | |
| 1008 | 1008 | 16 => .i32, // stored/loaded as u16 |
| 1009 | 1009 | 32 => .f32, |
| 1010 | 1010 | 64 => .f64, |
| 1011 | 1011 | 80, 128 => .i32, |
| 1012 | 1012 | else => unreachable, |
| 1013 | 1013 | }, |
| 1014 | .Int, .Enum => switch (ty.intInfo(zcu).bits) { | |
| 1014 | .int, .@"enum" => switch (ty.intInfo(zcu).bits) { | |
| 1015 | 1015 | 0...32 => .i32, |
| 1016 | 1016 | 33...64 => .i64, |
| 1017 | 1017 | else => .i32, |
| 1018 | 1018 | }, |
| 1019 | .Struct => blk: { | |
| 1019 | .@"struct" => blk: { | |
| 1020 | 1020 | if (zcu.typeToPackedStruct(ty)) |packed_struct| { |
| 1021 | 1021 | const backing_int_ty = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)); |
| 1022 | 1022 | break :blk typeToValtype(backing_int_ty, pt, target); |
| ... | ... | @@ -1024,11 +1024,11 @@ fn typeToValtype(ty: Type, pt: Zcu.PerThread, target: std.Target) wasm.Valtype { |
| 1024 | 1024 | break :blk .i32; |
| 1025 | 1025 | } |
| 1026 | 1026 | }, |
| 1027 | .Vector => switch (determineSimdStoreStrategy(ty, zcu, target)) { | |
| 1027 | .vector => switch (determineSimdStoreStrategy(ty, zcu, target)) { | |
| 1028 | 1028 | .direct => .v128, |
| 1029 | 1029 | .unrolled => .i32, |
| 1030 | 1030 | }, |
| 1031 | .Union => switch (ty.containerLayout(zcu)) { | |
| 1031 | .@"union" => switch (ty.containerLayout(zcu)) { | |
| 1032 | 1032 | .@"packed" => blk: { |
| 1033 | 1033 | const int_ty = pt.intType(.unsigned, @as(u16, @intCast(ty.bitSize(zcu)))) catch @panic("out of memory"); |
| 1034 | 1034 | break :blk typeToValtype(int_ty, pt, target); |
| ... | ... | @@ -1430,7 +1430,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: |
| 1430 | 1430 | const ty_classes = abi.classifyType(ty, zcu); |
| 1431 | 1431 | assert(ty_classes[0] != .none); |
| 1432 | 1432 | switch (ty.zigTypeTag(zcu)) { |
| 1433 | .Struct, .Union => { | |
| 1433 | .@"struct", .@"union" => { | |
| 1434 | 1434 | if (ty_classes[0] == .indirect) { |
| 1435 | 1435 | return func.lowerToStack(value); |
| 1436 | 1436 | } |
| ... | ... | @@ -1445,7 +1445,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: |
| 1445 | 1445 | else => try func.emitWValue(value), |
| 1446 | 1446 | } |
| 1447 | 1447 | }, |
| 1448 | .Int, .Float => { | |
| 1448 | .int, .float => { | |
| 1449 | 1449 | if (ty_classes[1] == .none) { |
| 1450 | 1450 | return func.lowerToStack(value); |
| 1451 | 1451 | } |
| ... | ... | @@ -1719,27 +1719,27 @@ fn isByRef(ty: Type, pt: Zcu.PerThread, target: std.Target) bool { |
| 1719 | 1719 | const zcu = pt.zcu; |
| 1720 | 1720 | const ip = &zcu.intern_pool; |
| 1721 | 1721 | switch (ty.zigTypeTag(zcu)) { |
| 1722 | .Type, | |
| 1723 | .ComptimeInt, | |
| 1724 | .ComptimeFloat, | |
| 1725 | .EnumLiteral, | |
| 1726 | .Undefined, | |
| 1727 | .Null, | |
| 1728 | .Opaque, | |
| 1722 | .type, | |
| 1723 | .comptime_int, | |
| 1724 | .comptime_float, | |
| 1725 | .enum_literal, | |
| 1726 | .undefined, | |
| 1727 | .null, | |
| 1728 | .@"opaque", | |
| 1729 | 1729 | => unreachable, |
| 1730 | 1730 | |
| 1731 | .NoReturn, | |
| 1732 | .Void, | |
| 1733 | .Bool, | |
| 1734 | .ErrorSet, | |
| 1735 | .Fn, | |
| 1736 | .AnyFrame, | |
| 1731 | .noreturn, | |
| 1732 | .void, | |
| 1733 | .bool, | |
| 1734 | .error_set, | |
| 1735 | .@"fn", | |
| 1736 | .@"anyframe", | |
| 1737 | 1737 | => return false, |
| 1738 | 1738 | |
| 1739 | .Array, | |
| 1740 | .Frame, | |
| 1739 | .array, | |
| 1740 | .frame, | |
| 1741 | 1741 | => return ty.hasRuntimeBitsIgnoreComptime(zcu), |
| 1742 | .Union => { | |
| 1742 | .@"union" => { | |
| 1743 | 1743 | if (zcu.typeToUnion(ty)) |union_obj| { |
| 1744 | 1744 | if (union_obj.flagsUnordered(ip).layout == .@"packed") { |
| 1745 | 1745 | return ty.abiSize(zcu) > 8; |
| ... | ... | @@ -1747,30 +1747,30 @@ fn isByRef(ty: Type, pt: Zcu.PerThread, target: std.Target) bool { |
| 1747 | 1747 | } |
| 1748 | 1748 | return ty.hasRuntimeBitsIgnoreComptime(zcu); |
| 1749 | 1749 | }, |
| 1750 | .Struct => { | |
| 1750 | .@"struct" => { | |
| 1751 | 1751 | if (zcu.typeToPackedStruct(ty)) |packed_struct| { |
| 1752 | 1752 | return isByRef(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), pt, target); |
| 1753 | 1753 | } |
| 1754 | 1754 | return ty.hasRuntimeBitsIgnoreComptime(zcu); |
| 1755 | 1755 | }, |
| 1756 | .Vector => return determineSimdStoreStrategy(ty, zcu, target) == .unrolled, | |
| 1757 | .Int => return ty.intInfo(zcu).bits > 64, | |
| 1758 | .Enum => return ty.intInfo(zcu).bits > 64, | |
| 1759 | .Float => return ty.floatBits(target) > 64, | |
| 1760 | .ErrorUnion => { | |
| 1756 | .vector => return determineSimdStoreStrategy(ty, zcu, target) == .unrolled, | |
| 1757 | .int => return ty.intInfo(zcu).bits > 64, | |
| 1758 | .@"enum" => return ty.intInfo(zcu).bits > 64, | |
| 1759 | .float => return ty.floatBits(target) > 64, | |
| 1760 | .error_union => { | |
| 1761 | 1761 | const pl_ty = ty.errorUnionPayload(zcu); |
| 1762 | 1762 | if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 1763 | 1763 | return false; |
| 1764 | 1764 | } |
| 1765 | 1765 | return true; |
| 1766 | 1766 | }, |
| 1767 | .Optional => { | |
| 1767 | .optional => { | |
| 1768 | 1768 | if (ty.isPtrLikeOptional(zcu)) return false; |
| 1769 | 1769 | const pl_type = ty.optionalChild(zcu); |
| 1770 | if (pl_type.zigTypeTag(zcu) == .ErrorSet) return false; | |
| 1770 | if (pl_type.zigTypeTag(zcu) == .error_set) return false; | |
| 1771 | 1771 | return pl_type.hasRuntimeBitsIgnoreComptime(zcu); |
| 1772 | 1772 | }, |
| 1773 | .Pointer => { | |
| 1773 | .pointer => { | |
| 1774 | 1774 | // Slices act like struct and will be passed by reference |
| 1775 | 1775 | if (ty.isSlice(zcu)) return true; |
| 1776 | 1776 | return false; |
| ... | ... | @@ -1788,7 +1788,7 @@ const SimdStoreStrategy = enum { |
| 1788 | 1788 | /// features are enabled, the function will return `.direct`. This would allow to store |
| 1789 | 1789 | /// it using a instruction, rather than an unrolled version. |
| 1790 | 1790 | fn determineSimdStoreStrategy(ty: Type, zcu: *Zcu, target: std.Target) SimdStoreStrategy { |
| 1791 | std.debug.assert(ty.zigTypeTag(zcu) == .Vector); | |
| 1791 | std.debug.assert(ty.zigTypeTag(zcu) == .vector); | |
| 1792 | 1792 | if (ty.bitSize(zcu) != 128) return .unrolled; |
| 1793 | 1793 | const hasFeature = std.Target.wasm.featureSetHas; |
| 1794 | 1794 | const features = target.cpu.features; |
| ... | ... | @@ -2106,7 +2106,7 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2106 | 2106 | } else if (fn_info.cc == .C and ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 2107 | 2107 | switch (ret_ty.zigTypeTag(zcu)) { |
| 2108 | 2108 | // Aggregate types can be lowered as a singular value |
| 2109 | .Struct, .Union => { | |
| 2109 | .@"struct", .@"union" => { | |
| 2110 | 2110 | const scalar_type = abi.scalarType(ret_ty, zcu); |
| 2111 | 2111 | try func.emitWValue(operand); |
| 2112 | 2112 | const opcode = buildOpcode(.{ |
| ... | ... | @@ -2189,8 +2189,8 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif |
| 2189 | 2189 | const zcu = pt.zcu; |
| 2190 | 2190 | const ip = &zcu.intern_pool; |
| 2191 | 2191 | const fn_ty = switch (ty.zigTypeTag(zcu)) { |
| 2192 | .Fn => ty, | |
| 2193 | .Pointer => ty.childType(zcu), | |
| 2192 | .@"fn" => ty, | |
| 2193 | .pointer => ty.childType(zcu), | |
| 2194 | 2194 | else => unreachable, |
| 2195 | 2195 | }; |
| 2196 | 2196 | const ret_ty = fn_ty.fnReturnType(zcu); |
| ... | ... | @@ -2261,7 +2261,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif |
| 2261 | 2261 | } else { |
| 2262 | 2262 | // in this case we call a function pointer |
| 2263 | 2263 | // so load its value onto the stack |
| 2264 | std.debug.assert(ty.zigTypeTag(zcu) == .Pointer); | |
| 2264 | std.debug.assert(ty.zigTypeTag(zcu) == .pointer); | |
| 2265 | 2265 | const operand = try func.resolveInst(pl_op.operand); |
| 2266 | 2266 | try func.emitWValue(operand); |
| 2267 | 2267 | |
| ... | ... | @@ -2281,7 +2281,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif |
| 2281 | 2281 | } else if (first_param_sret) { |
| 2282 | 2282 | break :result_value sret; |
| 2283 | 2283 | // TODO: Make this less fragile and optimize |
| 2284 | } else if (zcu.typeToFunc(fn_ty).?.cc == .C and ret_ty.zigTypeTag(zcu) == .Struct or ret_ty.zigTypeTag(zcu) == .Union) { | |
| 2284 | } else if (zcu.typeToFunc(fn_ty).?.cc == .C and ret_ty.zigTypeTag(zcu) == .@"struct" or ret_ty.zigTypeTag(zcu) == .@"union") { | |
| 2285 | 2285 | const result_local = try func.allocLocal(ret_ty); |
| 2286 | 2286 | try func.addLabel(.local_set, result_local.local.value); |
| 2287 | 2287 | const scalar_type = abi.scalarType(ret_ty, zcu); |
| ... | ... | @@ -2371,7 +2371,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE |
| 2371 | 2371 | const zcu = pt.zcu; |
| 2372 | 2372 | const abi_size = ty.abiSize(zcu); |
| 2373 | 2373 | switch (ty.zigTypeTag(zcu)) { |
| 2374 | .ErrorUnion => { | |
| 2374 | .error_union => { | |
| 2375 | 2375 | const pl_ty = ty.errorUnionPayload(zcu); |
| 2376 | 2376 | if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 2377 | 2377 | return func.store(lhs, rhs, Type.anyerror, 0); |
| ... | ... | @@ -2380,7 +2380,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE |
| 2380 | 2380 | const len = @as(u32, @intCast(abi_size)); |
| 2381 | 2381 | return func.memcpy(lhs, rhs, .{ .imm32 = len }); |
| 2382 | 2382 | }, |
| 2383 | .Optional => { | |
| 2383 | .optional => { | |
| 2384 | 2384 | if (ty.isPtrLikeOptional(zcu)) { |
| 2385 | 2385 | return func.store(lhs, rhs, Type.usize, 0); |
| 2386 | 2386 | } |
| ... | ... | @@ -2388,18 +2388,18 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE |
| 2388 | 2388 | if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 2389 | 2389 | return func.store(lhs, rhs, Type.u8, 0); |
| 2390 | 2390 | } |
| 2391 | if (pl_ty.zigTypeTag(zcu) == .ErrorSet) { | |
| 2391 | if (pl_ty.zigTypeTag(zcu) == .error_set) { | |
| 2392 | 2392 | return func.store(lhs, rhs, Type.anyerror, 0); |
| 2393 | 2393 | } |
| 2394 | 2394 | |
| 2395 | 2395 | const len = @as(u32, @intCast(abi_size)); |
| 2396 | 2396 | return func.memcpy(lhs, rhs, .{ .imm32 = len }); |
| 2397 | 2397 | }, |
| 2398 | .Struct, .Array, .Union => if (isByRef(ty, pt, func.target.*)) { | |
| 2398 | .@"struct", .array, .@"union" => if (isByRef(ty, pt, func.target.*)) { | |
| 2399 | 2399 | const len = @as(u32, @intCast(abi_size)); |
| 2400 | 2400 | return func.memcpy(lhs, rhs, .{ .imm32 = len }); |
| 2401 | 2401 | }, |
| 2402 | .Vector => switch (determineSimdStoreStrategy(ty, zcu, func.target.*)) { | |
| 2402 | .vector => switch (determineSimdStoreStrategy(ty, zcu, func.target.*)) { | |
| 2403 | 2403 | .unrolled => { |
| 2404 | 2404 | const len: u32 = @intCast(abi_size); |
| 2405 | 2405 | return func.memcpy(lhs, rhs, .{ .imm32 = len }); |
| ... | ... | @@ -2418,7 +2418,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE |
| 2418 | 2418 | return func.addInst(.{ .tag = .simd_prefix, .data = .{ .payload = extra_index } }); |
| 2419 | 2419 | }, |
| 2420 | 2420 | }, |
| 2421 | .Pointer => { | |
| 2421 | .pointer => { | |
| 2422 | 2422 | if (ty.isSlice(zcu)) { |
| 2423 | 2423 | // store pointer first |
| 2424 | 2424 | // lower it to the stack so we do not have to store rhs into a local first |
| ... | ... | @@ -2433,7 +2433,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE |
| 2433 | 2433 | return; |
| 2434 | 2434 | } |
| 2435 | 2435 | }, |
| 2436 | .Int, .Enum, .Float => if (abi_size > 8 and abi_size <= 16) { | |
| 2436 | .int, .@"enum", .float => if (abi_size > 8 and abi_size <= 16) { | |
| 2437 | 2437 | try func.emitWValue(lhs); |
| 2438 | 2438 | const lsb = try func.load(rhs, Type.u64, 0); |
| 2439 | 2439 | try func.store(.stack, lsb, Type.u64, 0 + lhs.offset()); |
| ... | ... | @@ -2521,7 +2521,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu |
| 2521 | 2521 | // load local's value from memory by its stack position |
| 2522 | 2522 | try func.emitWValue(operand); |
| 2523 | 2523 | |
| 2524 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2524 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2525 | 2525 | // TODO: Add helper functions for simd opcodes |
| 2526 | 2526 | const extra_index = @as(u32, @intCast(func.mir_extra.items.len)); |
| 2527 | 2527 | // stores as := opcode, offset, alignment (opcode::memarg) |
| ... | ... | @@ -2571,7 +2571,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2571 | 2571 | // When we have an argument that's passed using more than a single parameter, |
| 2572 | 2572 | // we combine them into a single stack value |
| 2573 | 2573 | if (arg_classes[0] == .direct and arg_classes[1] == .direct) { |
| 2574 | if (arg_ty.zigTypeTag(zcu) != .Int and arg_ty.zigTypeTag(zcu) != .Float) { | |
| 2574 | if (arg_ty.zigTypeTag(zcu) != .int and arg_ty.zigTypeTag(zcu) != .float) { | |
| 2575 | 2575 | return func.fail( |
| 2576 | 2576 | "TODO: Implement C-ABI argument for type '{}'", |
| 2577 | 2577 | .{arg_ty.fmt(pt)}, |
| ... | ... | @@ -2647,7 +2647,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError! |
| 2647 | 2647 | } |
| 2648 | 2648 | |
| 2649 | 2649 | if (isByRef(ty, pt, func.target.*)) { |
| 2650 | if (ty.zigTypeTag(zcu) == .Int) { | |
| 2650 | if (ty.zigTypeTag(zcu) == .int) { | |
| 2651 | 2651 | return func.binOpBigInt(lhs, rhs, ty, op); |
| 2652 | 2652 | } else { |
| 2653 | 2653 | return func.fail( |
| ... | ... | @@ -2822,7 +2822,7 @@ fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2822 | 2822 | const scalar_ty = ty.scalarType(zcu); |
| 2823 | 2823 | |
| 2824 | 2824 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 2825 | .Int => if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2825 | .int => if (ty.zigTypeTag(zcu) == .vector) { | |
| 2826 | 2826 | return func.fail("TODO implement airAbs for {}", .{ty.fmt(pt)}); |
| 2827 | 2827 | } else { |
| 2828 | 2828 | const int_bits = ty.intInfo(zcu).bits; |
| ... | ... | @@ -2887,7 +2887,7 @@ fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2887 | 2887 | else => unreachable, |
| 2888 | 2888 | } |
| 2889 | 2889 | }, |
| 2890 | .Float => { | |
| 2890 | .float => { | |
| 2891 | 2891 | const result = try func.floatOp(.fabs, ty, &.{operand}); |
| 2892 | 2892 | return func.finishAir(inst, result, &.{ty_op.operand}); |
| 2893 | 2893 | }, |
| ... | ... | @@ -2907,7 +2907,7 @@ fn airUnaryFloatOp(func: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError |
| 2907 | 2907 | fn floatOp(func: *CodeGen, float_op: FloatOp, ty: Type, args: []const WValue) InnerError!WValue { |
| 2908 | 2908 | const pt = func.pt; |
| 2909 | 2909 | const zcu = pt.zcu; |
| 2910 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 2910 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 2911 | 2911 | return func.fail("TODO: Implement floatOps for vectors", .{}); |
| 2912 | 2912 | } |
| 2913 | 2913 | |
| ... | ... | @@ -3021,7 +3021,7 @@ fn airWrapBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 3021 | 3021 | const lhs_ty = func.typeOf(bin_op.lhs); |
| 3022 | 3022 | const rhs_ty = func.typeOf(bin_op.rhs); |
| 3023 | 3023 | |
| 3024 | if (lhs_ty.zigTypeTag(zcu) == .Vector or rhs_ty.zigTypeTag(zcu) == .Vector) { | |
| 3024 | if (lhs_ty.zigTypeTag(zcu) == .vector or rhs_ty.zigTypeTag(zcu) == .vector) { | |
| 3025 | 3025 | return func.fail("TODO: Implement wrapping arithmetic for vectors", .{}); |
| 3026 | 3026 | } |
| 3027 | 3027 | |
| ... | ... | @@ -3139,7 +3139,7 @@ fn lowerPtr(func: *CodeGen, ptr_val: InternPool.Index, prev_offset: u64) InnerEr |
| 3139 | 3139 | const base_ptr = Value.fromInterned(field.base); |
| 3140 | 3140 | const base_ty = base_ptr.typeOf(zcu).childType(zcu); |
| 3141 | 3141 | const field_off: u64 = switch (base_ty.zigTypeTag(zcu)) { |
| 3142 | .Pointer => off: { | |
| 3142 | .pointer => off: { | |
| 3143 | 3143 | assert(base_ty.isSlice(zcu)); |
| 3144 | 3144 | break :off switch (field.index) { |
| 3145 | 3145 | Value.slice_ptr_index => 0, |
| ... | ... | @@ -3147,11 +3147,11 @@ fn lowerPtr(func: *CodeGen, ptr_val: InternPool.Index, prev_offset: u64) InnerEr |
| 3147 | 3147 | else => unreachable, |
| 3148 | 3148 | }; |
| 3149 | 3149 | }, |
| 3150 | .Struct => switch (base_ty.containerLayout(zcu)) { | |
| 3150 | .@"struct" => switch (base_ty.containerLayout(zcu)) { | |
| 3151 | 3151 | .auto => base_ty.structFieldOffset(@intCast(field.index), zcu), |
| 3152 | 3152 | .@"extern", .@"packed" => unreachable, |
| 3153 | 3153 | }, |
| 3154 | .Union => switch (base_ty.containerLayout(zcu)) { | |
| 3154 | .@"union" => switch (base_ty.containerLayout(zcu)) { | |
| 3155 | 3155 | .auto => off: { |
| 3156 | 3156 | // Keep in sync with the `un` case of `generateSymbol`. |
| 3157 | 3157 | const layout = base_ty.unionGetLayout(zcu); |
| ... | ... | @@ -3184,7 +3184,7 @@ fn lowerUavRef( |
| 3184 | 3184 | const zcu = pt.zcu; |
| 3185 | 3185 | const ty = Type.fromInterned(zcu.intern_pool.typeOf(uav.val)); |
| 3186 | 3186 | |
| 3187 | const is_fn_body = ty.zigTypeTag(zcu) == .Fn; | |
| 3187 | const is_fn_body = ty.zigTypeTag(zcu) == .@"fn"; | |
| 3188 | 3188 | if (!is_fn_body and !ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 3189 | 3189 | return .{ .imm32 = 0xaaaaaaaa }; |
| 3190 | 3190 | } |
| ... | ... | @@ -3404,34 +3404,34 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue { |
| 3404 | 3404 | const zcu = pt.zcu; |
| 3405 | 3405 | const ip = &zcu.intern_pool; |
| 3406 | 3406 | switch (ty.zigTypeTag(zcu)) { |
| 3407 | .Bool, .ErrorSet => return .{ .imm32 = 0xaaaaaaaa }, | |
| 3408 | .Int, .Enum => switch (ty.intInfo(zcu).bits) { | |
| 3407 | .bool, .error_set => return .{ .imm32 = 0xaaaaaaaa }, | |
| 3408 | .int, .@"enum" => switch (ty.intInfo(zcu).bits) { | |
| 3409 | 3409 | 0...32 => return .{ .imm32 = 0xaaaaaaaa }, |
| 3410 | 3410 | 33...64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa }, |
| 3411 | 3411 | else => unreachable, |
| 3412 | 3412 | }, |
| 3413 | .Float => switch (ty.floatBits(func.target.*)) { | |
| 3413 | .float => switch (ty.floatBits(func.target.*)) { | |
| 3414 | 3414 | 16 => return .{ .imm32 = 0xaaaaaaaa }, |
| 3415 | 3415 | 32 => return .{ .float32 = @as(f32, @bitCast(@as(u32, 0xaaaaaaaa))) }, |
| 3416 | 3416 | 64 => return .{ .float64 = @as(f64, @bitCast(@as(u64, 0xaaaaaaaaaaaaaaaa))) }, |
| 3417 | 3417 | else => unreachable, |
| 3418 | 3418 | }, |
| 3419 | .Pointer => switch (func.arch()) { | |
| 3419 | .pointer => switch (func.arch()) { | |
| 3420 | 3420 | .wasm32 => return .{ .imm32 = 0xaaaaaaaa }, |
| 3421 | 3421 | .wasm64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa }, |
| 3422 | 3422 | else => unreachable, |
| 3423 | 3423 | }, |
| 3424 | .Optional => { | |
| 3424 | .optional => { | |
| 3425 | 3425 | const pl_ty = ty.optionalChild(zcu); |
| 3426 | 3426 | if (ty.optionalReprIsPayload(zcu)) { |
| 3427 | 3427 | return func.emitUndefined(pl_ty); |
| 3428 | 3428 | } |
| 3429 | 3429 | return .{ .imm32 = 0xaaaaaaaa }; |
| 3430 | 3430 | }, |
| 3431 | .ErrorUnion => { | |
| 3431 | .error_union => { | |
| 3432 | 3432 | return .{ .imm32 = 0xaaaaaaaa }; |
| 3433 | 3433 | }, |
| 3434 | .Struct => { | |
| 3434 | .@"struct" => { | |
| 3435 | 3435 | const packed_struct = zcu.typeToPackedStruct(ty).?; |
| 3436 | 3436 | return func.emitUndefined(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip))); |
| 3437 | 3437 | }, |
| ... | ... | @@ -3604,7 +3604,7 @@ fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareO |
| 3604 | 3604 | assert(!(lhs != .stack and rhs == .stack)); |
| 3605 | 3605 | const pt = func.pt; |
| 3606 | 3606 | const zcu = pt.zcu; |
| 3607 | if (ty.zigTypeTag(zcu) == .Optional and !ty.optionalReprIsPayload(zcu)) { | |
| 3607 | if (ty.zigTypeTag(zcu) == .optional and !ty.optionalReprIsPayload(zcu)) { | |
| 3608 | 3608 | const payload_ty = ty.optionalChild(zcu); |
| 3609 | 3609 | if (payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 3610 | 3610 | // When we hit this case, we must check the value of optionals |
| ... | ... | @@ -3620,7 +3620,7 @@ fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareO |
| 3620 | 3620 | |
| 3621 | 3621 | const signedness: std.builtin.Signedness = blk: { |
| 3622 | 3622 | // by default we tell the operand type is unsigned (i.e. bools and enum values) |
| 3623 | if (ty.zigTypeTag(zcu) != .Int) break :blk .unsigned; | |
| 3623 | if (ty.zigTypeTag(zcu) != .int) break :blk .unsigned; | |
| 3624 | 3624 | |
| 3625 | 3625 | // incase of an actual integer, we emit the correct signedness |
| 3626 | 3626 | break :blk ty.intInfo(zcu).signedness; |
| ... | ... | @@ -3743,7 +3743,7 @@ fn airNot(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3743 | 3743 | const zcu = pt.zcu; |
| 3744 | 3744 | |
| 3745 | 3745 | const result = result: { |
| 3746 | if (operand_ty.zigTypeTag(zcu) == .Bool) { | |
| 3746 | if (operand_ty.zigTypeTag(zcu) == .bool) { | |
| 3747 | 3747 | try func.emitWValue(operand); |
| 3748 | 3748 | try func.addTag(.i32_eqz); |
| 3749 | 3749 | const not_tmp = try func.allocLocal(operand_ty); |
| ... | ... | @@ -3922,14 +3922,14 @@ fn structFieldPtr( |
| 3922 | 3922 | |
| 3923 | 3923 | const offset = switch (struct_ty.containerLayout(zcu)) { |
| 3924 | 3924 | .@"packed" => switch (struct_ty.zigTypeTag(zcu)) { |
| 3925 | .Struct => offset: { | |
| 3925 | .@"struct" => offset: { | |
| 3926 | 3926 | if (result_ty.ptrInfo(zcu).packed_offset.host_size != 0) { |
| 3927 | 3927 | break :offset @as(u32, 0); |
| 3928 | 3928 | } |
| 3929 | 3929 | const struct_type = zcu.typeToStruct(struct_ty).?; |
| 3930 | 3930 | break :offset @divExact(pt.structPackedFieldBitOffset(struct_type, index) + struct_ptr_ty_info.packed_offset.bit_offset, 8); |
| 3931 | 3931 | }, |
| 3932 | .Union => 0, | |
| 3932 | .@"union" => 0, | |
| 3933 | 3933 | else => unreachable, |
| 3934 | 3934 | }, |
| 3935 | 3935 | else => struct_ty.structFieldOffset(index, zcu), |
| ... | ... | @@ -3961,7 +3961,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3961 | 3961 | |
| 3962 | 3962 | const result: WValue = switch (struct_ty.containerLayout(zcu)) { |
| 3963 | 3963 | .@"packed" => switch (struct_ty.zigTypeTag(zcu)) { |
| 3964 | .Struct => result: { | |
| 3964 | .@"struct" => result: { | |
| 3965 | 3965 | const packed_struct = zcu.typeToPackedStruct(struct_ty).?; |
| 3966 | 3966 | const offset = pt.structPackedFieldBitOffset(packed_struct, field_index); |
| 3967 | 3967 | const backing_ty = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)); |
| ... | ... | @@ -3981,7 +3981,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3981 | 3981 | else |
| 3982 | 3982 | try func.binOp(operand, const_wvalue, backing_ty, .shr); |
| 3983 | 3983 | |
| 3984 | if (field_ty.zigTypeTag(zcu) == .Float) { | |
| 3984 | if (field_ty.zigTypeTag(zcu) == .float) { | |
| 3985 | 3985 | const int_type = try pt.intType(.unsigned, @as(u16, @intCast(field_ty.bitSize(zcu)))); |
| 3986 | 3986 | const truncated = try func.trunc(shifted_value, int_type, backing_ty); |
| 3987 | 3987 | break :result try func.bitcast(field_ty, int_type, truncated); |
| ... | ... | @@ -3995,7 +3995,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3995 | 3995 | } |
| 3996 | 3996 | break :result try func.trunc(shifted_value, field_ty, backing_ty); |
| 3997 | 3997 | }, |
| 3998 | .Union => result: { | |
| 3998 | .@"union" => result: { | |
| 3999 | 3999 | if (isByRef(struct_ty, pt, func.target.*)) { |
| 4000 | 4000 | if (!isByRef(field_ty, pt, func.target.*)) { |
| 4001 | 4001 | break :result try func.load(operand, field_ty, 0); |
| ... | ... | @@ -4007,7 +4007,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4007 | 4007 | } |
| 4008 | 4008 | |
| 4009 | 4009 | const union_int_type = try pt.intType(.unsigned, @as(u16, @intCast(struct_ty.bitSize(zcu)))); |
| 4010 | if (field_ty.zigTypeTag(zcu) == .Float) { | |
| 4010 | if (field_ty.zigTypeTag(zcu) == .float) { | |
| 4011 | 4011 | const int_type = try pt.intType(.unsigned, @as(u16, @intCast(field_ty.bitSize(zcu)))); |
| 4012 | 4012 | const truncated = try func.trunc(operand, int_type, union_int_type); |
| 4013 | 4013 | break :result try func.bitcast(field_ty, int_type, truncated); |
| ... | ... | @@ -4136,7 +4136,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4136 | 4136 | // for errors that are not present in any branch. This is fine as this default |
| 4137 | 4137 | // case will never be hit for those cases but we do save runtime cost and size |
| 4138 | 4138 | // by using a jump table for this instead of if-else chains. |
| 4139 | break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .ErrorSet) switch_br.cases_len else unreachable; | |
| 4139 | break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .error_set) switch_br.cases_len else unreachable; | |
| 4140 | 4140 | }; |
| 4141 | 4141 | func.mir_extra.appendAssumeCapacity(idx); |
| 4142 | 4142 | } else if (has_else_body) { |
| ... | ... | @@ -4147,7 +4147,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4147 | 4147 | |
| 4148 | 4148 | const signedness: std.builtin.Signedness = blk: { |
| 4149 | 4149 | // by default we tell the operand type is unsigned (i.e. bools and enum values) |
| 4150 | if (target_ty.zigTypeTag(zcu) != .Int) break :blk .unsigned; | |
| 4150 | if (target_ty.zigTypeTag(zcu) != .int) break :blk .unsigned; | |
| 4151 | 4151 | |
| 4152 | 4152 | // incase of an actual integer, we emit the correct signedness |
| 4153 | 4153 | break :blk target_ty.intInfo(zcu).signedness; |
| ... | ... | @@ -4364,7 +4364,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4364 | 4364 | const operand_ty = func.typeOf(ty_op.operand); |
| 4365 | 4365 | const pt = func.pt; |
| 4366 | 4366 | const zcu = pt.zcu; |
| 4367 | if (ty.zigTypeTag(zcu) == .Vector or operand_ty.zigTypeTag(zcu) == .Vector) { | |
| 4367 | if (ty.zigTypeTag(zcu) == .vector or operand_ty.zigTypeTag(zcu) == .vector) { | |
| 4368 | 4368 | return func.fail("todo Wasm intcast for vectors", .{}); |
| 4369 | 4369 | } |
| 4370 | 4370 | if (ty.abiSize(zcu) > 16 or operand_ty.abiSize(zcu) > 16) { |
| ... | ... | @@ -4682,7 +4682,7 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4682 | 4682 | const pt = func.pt; |
| 4683 | 4683 | const zcu = pt.zcu; |
| 4684 | 4684 | |
| 4685 | if (wanted_ty.zigTypeTag(zcu) == .Vector or op_ty.zigTypeTag(zcu) == .Vector) { | |
| 4685 | if (wanted_ty.zigTypeTag(zcu) == .vector or op_ty.zigTypeTag(zcu) == .vector) { | |
| 4686 | 4686 | return func.fail("TODO: trunc for vectors", .{}); |
| 4687 | 4687 | } |
| 4688 | 4688 | |
| ... | ... | @@ -4990,7 +4990,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4990 | 4990 | try func.addTag(.i32_mul); |
| 4991 | 4991 | try func.addTag(.i32_add); |
| 4992 | 4992 | } else { |
| 4993 | std.debug.assert(array_ty.zigTypeTag(zcu) == .Vector); | |
| 4993 | std.debug.assert(array_ty.zigTypeTag(zcu) == .vector); | |
| 4994 | 4994 | |
| 4995 | 4995 | switch (index) { |
| 4996 | 4996 | inline .imm32, .imm64 => |lane| { |
| ... | ... | @@ -5281,7 +5281,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5281 | 5281 | |
| 5282 | 5282 | const result: WValue = result_value: { |
| 5283 | 5283 | switch (result_ty.zigTypeTag(zcu)) { |
| 5284 | .Array => { | |
| 5284 | .array => { | |
| 5285 | 5285 | const result = try func.allocStack(result_ty); |
| 5286 | 5286 | const elem_ty = result_ty.childType(zcu); |
| 5287 | 5287 | const elem_size = @as(u32, @intCast(elem_ty.abiSize(zcu))); |
| ... | ... | @@ -5320,7 +5320,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5320 | 5320 | } |
| 5321 | 5321 | break :result_value result; |
| 5322 | 5322 | }, |
| 5323 | .Struct => switch (result_ty.containerLayout(zcu)) { | |
| 5323 | .@"struct" => switch (result_ty.containerLayout(zcu)) { | |
| 5324 | 5324 | .@"packed" => { |
| 5325 | 5325 | if (isByRef(result_ty, pt, func.target.*)) { |
| 5326 | 5326 | return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{}); |
| ... | ... | @@ -5386,7 +5386,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5386 | 5386 | break :result_value result; |
| 5387 | 5387 | }, |
| 5388 | 5388 | }, |
| 5389 | .Vector => return func.fail("TODO: Wasm backend: implement airAggregateInit for vectors", .{}), | |
| 5389 | .vector => return func.fail("TODO: Wasm backend: implement airAggregateInit for vectors", .{}), | |
| 5390 | 5390 | else => unreachable, |
| 5391 | 5391 | } |
| 5392 | 5392 | }; |
| ... | ... | @@ -5458,7 +5458,7 @@ fn airUnionInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5458 | 5458 | } else { |
| 5459 | 5459 | const operand = try func.resolveInst(extra.init); |
| 5460 | 5460 | const union_int_type = try pt.intType(.unsigned, @as(u16, @intCast(union_ty.bitSize(zcu)))); |
| 5461 | if (field_ty.zigTypeTag(zcu) == .Float) { | |
| 5461 | if (field_ty.zigTypeTag(zcu) == .float) { | |
| 5462 | 5462 | const int_type = try pt.intType(.unsigned, @intCast(field_ty.bitSize(zcu))); |
| 5463 | 5463 | const bitcasted = try func.bitcast(field_ty, int_type, operand); |
| 5464 | 5464 | break :result try func.trunc(bitcasted, int_type, union_int_type); |
| ... | ... | @@ -5810,7 +5810,7 @@ fn airPopcount(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5810 | 5810 | const operand = try func.resolveInst(ty_op.operand); |
| 5811 | 5811 | const op_ty = func.typeOf(ty_op.operand); |
| 5812 | 5812 | |
| 5813 | if (op_ty.zigTypeTag(zcu) == .Vector) { | |
| 5813 | if (op_ty.zigTypeTag(zcu) == .vector) { | |
| 5814 | 5814 | return func.fail("TODO: Implement @popCount for vectors", .{}); |
| 5815 | 5815 | } |
| 5816 | 5816 | |
| ... | ... | @@ -5862,7 +5862,7 @@ fn airBitReverse(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5862 | 5862 | const operand = try func.resolveInst(ty_op.operand); |
| 5863 | 5863 | const ty = func.typeOf(ty_op.operand); |
| 5864 | 5864 | |
| 5865 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 5865 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 5866 | 5866 | return func.fail("TODO: Implement @bitReverse for vectors", .{}); |
| 5867 | 5867 | } |
| 5868 | 5868 | |
| ... | ... | @@ -6028,7 +6028,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro |
| 6028 | 6028 | const pt = func.pt; |
| 6029 | 6029 | const zcu = pt.zcu; |
| 6030 | 6030 | |
| 6031 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6031 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6032 | 6032 | return func.fail("TODO: Implement overflow arithmetic for vectors", .{}); |
| 6033 | 6033 | } |
| 6034 | 6034 | |
| ... | ... | @@ -6075,7 +6075,7 @@ fn airShlWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6075 | 6075 | const ty = func.typeOf(extra.lhs); |
| 6076 | 6076 | const rhs_ty = func.typeOf(extra.rhs); |
| 6077 | 6077 | |
| 6078 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6078 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6079 | 6079 | return func.fail("TODO: Implement overflow arithmetic for vectors", .{}); |
| 6080 | 6080 | } |
| 6081 | 6081 | |
| ... | ... | @@ -6121,7 +6121,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6121 | 6121 | const pt = func.pt; |
| 6122 | 6122 | const zcu = pt.zcu; |
| 6123 | 6123 | |
| 6124 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6124 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6125 | 6125 | return func.fail("TODO: Implement overflow arithmetic for vectors", .{}); |
| 6126 | 6126 | } |
| 6127 | 6127 | |
| ... | ... | @@ -6251,7 +6251,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 6251 | 6251 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 6252 | 6252 | |
| 6253 | 6253 | const ty = func.typeOfIndex(inst); |
| 6254 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6254 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6255 | 6255 | return func.fail("TODO: `@maximum` and `@minimum` for vectors", .{}); |
| 6256 | 6256 | } |
| 6257 | 6257 | |
| ... | ... | @@ -6262,7 +6262,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 6262 | 6262 | const lhs = try func.resolveInst(bin_op.lhs); |
| 6263 | 6263 | const rhs = try func.resolveInst(bin_op.rhs); |
| 6264 | 6264 | |
| 6265 | if (ty.zigTypeTag(zcu) == .Float) { | |
| 6265 | if (ty.zigTypeTag(zcu) == .float) { | |
| 6266 | 6266 | var fn_name_buf: [64]u8 = undefined; |
| 6267 | 6267 | const float_bits = ty.floatBits(func.target.*); |
| 6268 | 6268 | const fn_name = std.fmt.bufPrint(&fn_name_buf, "{s}f{s}{s}", .{ |
| ... | ... | @@ -6292,7 +6292,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6292 | 6292 | const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data; |
| 6293 | 6293 | |
| 6294 | 6294 | const ty = func.typeOfIndex(inst); |
| 6295 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6295 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6296 | 6296 | return func.fail("TODO: `@mulAdd` for vectors", .{}); |
| 6297 | 6297 | } |
| 6298 | 6298 | |
| ... | ... | @@ -6326,7 +6326,7 @@ fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6326 | 6326 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 6327 | 6327 | |
| 6328 | 6328 | const ty = func.typeOf(ty_op.operand); |
| 6329 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6329 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6330 | 6330 | return func.fail("TODO: `@clz` for vectors", .{}); |
| 6331 | 6331 | } |
| 6332 | 6332 | |
| ... | ... | @@ -6378,7 +6378,7 @@ fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6378 | 6378 | |
| 6379 | 6379 | const ty = func.typeOf(ty_op.operand); |
| 6380 | 6380 | |
| 6381 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6381 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6382 | 6382 | return func.fail("TODO: `@ctz` for vectors", .{}); |
| 6383 | 6383 | } |
| 6384 | 6384 | |
| ... | ... | @@ -6571,7 +6571,7 @@ fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6571 | 6571 | const ty = func.typeOfIndex(inst); |
| 6572 | 6572 | const operand = try func.resolveInst(ty_op.operand); |
| 6573 | 6573 | |
| 6574 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 6574 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 6575 | 6575 | return func.fail("TODO: @byteSwap for vectors", .{}); |
| 6576 | 6576 | } |
| 6577 | 6577 | const int_info = ty.intInfo(zcu); |
src/arch/wasm/abi.zig+24-24| ... | ... | @@ -27,7 +27,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class { |
| 27 | 27 | const target = zcu.getTarget(); |
| 28 | 28 | if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return none; |
| 29 | 29 | switch (ty.zigTypeTag(zcu)) { |
| 30 | .Struct => { | |
| 30 | .@"struct" => { | |
| 31 | 31 | const struct_type = zcu.typeToStruct(ty).?; |
| 32 | 32 | if (struct_type.layout == .@"packed") { |
| 33 | 33 | if (ty.bitSize(zcu) <= 64) return direct; |
| ... | ... | @@ -45,30 +45,30 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class { |
| 45 | 45 | } |
| 46 | 46 | return classifyType(field_ty, zcu); |
| 47 | 47 | }, |
| 48 | .Int, .Enum, .ErrorSet => { | |
| 48 | .int, .@"enum", .error_set => { | |
| 49 | 49 | const int_bits = ty.intInfo(zcu).bits; |
| 50 | 50 | if (int_bits <= 64) return direct; |
| 51 | 51 | if (int_bits <= 128) return .{ .direct, .direct }; |
| 52 | 52 | return memory; |
| 53 | 53 | }, |
| 54 | .Float => { | |
| 54 | .float => { | |
| 55 | 55 | const float_bits = ty.floatBits(target); |
| 56 | 56 | if (float_bits <= 64) return direct; |
| 57 | 57 | if (float_bits <= 128) return .{ .direct, .direct }; |
| 58 | 58 | return memory; |
| 59 | 59 | }, |
| 60 | .Bool => return direct, | |
| 61 | .Vector => return direct, | |
| 62 | .Array => return memory, | |
| 63 | .Optional => { | |
| 60 | .bool => return direct, | |
| 61 | .vector => return direct, | |
| 62 | .array => return memory, | |
| 63 | .optional => { | |
| 64 | 64 | assert(ty.isPtrLikeOptional(zcu)); |
| 65 | 65 | return direct; |
| 66 | 66 | }, |
| 67 | .Pointer => { | |
| 67 | .pointer => { | |
| 68 | 68 | assert(!ty.isSlice(zcu)); |
| 69 | 69 | return direct; |
| 70 | 70 | }, |
| 71 | .Union => { | |
| 71 | .@"union" => { | |
| 72 | 72 | const union_obj = zcu.typeToUnion(ty).?; |
| 73 | 73 | if (union_obj.flagsUnordered(ip).layout == .@"packed") { |
| 74 | 74 | if (ty.bitSize(zcu) <= 64) return direct; |
| ... | ... | @@ -80,19 +80,19 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class { |
| 80 | 80 | const first_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[0]); |
| 81 | 81 | return classifyType(first_field_ty, zcu); |
| 82 | 82 | }, |
| 83 | .ErrorUnion, | |
| 84 | .Frame, | |
| 85 | .AnyFrame, | |
| 86 | .NoReturn, | |
| 87 | .Void, | |
| 88 | .Type, | |
| 89 | .ComptimeFloat, | |
| 90 | .ComptimeInt, | |
| 91 | .Undefined, | |
| 92 | .Null, | |
| 93 | .Fn, | |
| 94 | .Opaque, | |
| 95 | .EnumLiteral, | |
| 83 | .error_union, | |
| 84 | .frame, | |
| 85 | .@"anyframe", | |
| 86 | .noreturn, | |
| 87 | .void, | |
| 88 | .type, | |
| 89 | .comptime_float, | |
| 90 | .comptime_int, | |
| 91 | .undefined, | |
| 92 | .null, | |
| 93 | .@"fn", | |
| 94 | .@"opaque", | |
| 95 | .enum_literal, | |
| 96 | 96 | => unreachable, |
| 97 | 97 | } |
| 98 | 98 | } |
| ... | ... | @@ -103,7 +103,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class { |
| 103 | 103 | pub fn scalarType(ty: Type, zcu: *Zcu) Type { |
| 104 | 104 | const ip = &zcu.intern_pool; |
| 105 | 105 | switch (ty.zigTypeTag(zcu)) { |
| 106 | .Struct => { | |
| 106 | .@"struct" => { | |
| 107 | 107 | if (zcu.typeToPackedStruct(ty)) |packed_struct| { |
| 108 | 108 | return scalarType(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), zcu); |
| 109 | 109 | } else { |
| ... | ... | @@ -111,7 +111,7 @@ pub fn scalarType(ty: Type, zcu: *Zcu) Type { |
| 111 | 111 | return scalarType(ty.fieldType(0, zcu), zcu); |
| 112 | 112 | } |
| 113 | 113 | }, |
| 114 | .Union => { | |
| 114 | .@"union" => { | |
| 115 | 115 | const union_obj = zcu.typeToUnion(ty).?; |
| 116 | 116 | if (union_obj.flagsUnordered(ip).layout != .@"packed") { |
| 117 | 117 | const layout = Type.getUnionLayout(union_obj, zcu); |
src/arch/x86_64/CodeGen.zig+118-118| ... | ... | @@ -2419,7 +2419,7 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 2419 | 2419 | const zcu = pt.zcu; |
| 2420 | 2420 | const ip = &zcu.intern_pool; |
| 2421 | 2421 | switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) { |
| 2422 | .Enum => { | |
| 2422 | .@"enum" => { | |
| 2423 | 2423 | const enum_ty = Type.fromInterned(lazy_sym.ty); |
| 2424 | 2424 | wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)}); |
| 2425 | 2425 | |
| ... | ... | @@ -2704,13 +2704,13 @@ fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: b |
| 2704 | 2704 | |
| 2705 | 2705 | if (reg_ok) need_mem: { |
| 2706 | 2706 | if (abi_size <= @as(u32, switch (ty.zigTypeTag(zcu)) { |
| 2707 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 2707 | .float => switch (ty.floatBits(self.target.*)) { | |
| 2708 | 2708 | 16, 32, 64, 128 => 16, |
| 2709 | 2709 | 80 => break :need_mem, |
| 2710 | 2710 | else => unreachable, |
| 2711 | 2711 | }, |
| 2712 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 2713 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 2712 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 2713 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 2714 | 2714 | 16, 32, 64, 128 => if (self.hasFeature(.avx)) 32 else 16, |
| 2715 | 2715 | 80 => break :need_mem, |
| 2716 | 2716 | else => unreachable, |
| ... | ... | @@ -2733,11 +2733,11 @@ fn regClassForType(self: *Self, ty: Type) RegisterManager.RegisterBitSet { |
| 2733 | 2733 | const pt = self.pt; |
| 2734 | 2734 | const zcu = pt.zcu; |
| 2735 | 2735 | return switch (ty.zigTypeTag(zcu)) { |
| 2736 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 2736 | .float => switch (ty.floatBits(self.target.*)) { | |
| 2737 | 2737 | 80 => abi.RegisterClass.x87, |
| 2738 | 2738 | else => abi.RegisterClass.sse, |
| 2739 | 2739 | }, |
| 2740 | .Vector => switch (ty.childType(zcu).toIntern()) { | |
| 2740 | .vector => switch (ty.childType(zcu).toIntern()) { | |
| 2741 | 2741 | .bool_type, .u1_type => abi.RegisterClass.gp, |
| 2742 | 2742 | else => if (ty.isAbiInt(zcu) and ty.intInfo(zcu).bits == 1) |
| 2743 | 2743 | abi.RegisterClass.gp |
| ... | ... | @@ -2801,14 +2801,14 @@ fn restoreState(self: *Self, state: State, deaths: []const Air.Inst.Index, compt |
| 2801 | 2801 | ) |inst, *tracking| tracking.resurrect(inst, state.scope_generation); |
| 2802 | 2802 | for (deaths) |death| try self.processDeath(death); |
| 2803 | 2803 | |
| 2804 | const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).Array.len]RegisterLock; | |
| 2804 | const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock; | |
| 2805 | 2805 | var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) = |
| 2806 | 2806 | if (opts.update_tracking) |
| 2807 | 2807 | {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa); |
| 2808 | 2808 | |
| 2809 | 2809 | var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity( |
| 2810 | 2810 | stack.get(), |
| 2811 | @typeInfo(ExpectedContents).Array.len, | |
| 2811 | @typeInfo(ExpectedContents).array.len, | |
| 2812 | 2812 | ); |
| 2813 | 2813 | defer if (!opts.update_tracking) { |
| 2814 | 2814 | for (reg_locks.items) |lock| self.register_manager.unlockReg(lock); |
| ... | ... | @@ -3475,8 +3475,8 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void { |
| 3475 | 3475 | break :dst dst_mcv; |
| 3476 | 3476 | }; |
| 3477 | 3477 | |
| 3478 | if (dst_ty.zigTypeTag(zcu) == .Vector) { | |
| 3479 | assert(src_ty.zigTypeTag(zcu) == .Vector and dst_ty.vectorLen(zcu) == src_ty.vectorLen(zcu)); | |
| 3478 | if (dst_ty.zigTypeTag(zcu) == .vector) { | |
| 3479 | assert(src_ty.zigTypeTag(zcu) == .vector and dst_ty.vectorLen(zcu) == src_ty.vectorLen(zcu)); | |
| 3480 | 3480 | const dst_elem_ty = dst_ty.childType(zcu); |
| 3481 | 3481 | const dst_elem_abi_size: u32 = @intCast(dst_elem_ty.abiSize(zcu)); |
| 3482 | 3482 | const src_elem_ty = src_ty.childType(zcu); |
| ... | ... | @@ -3714,7 +3714,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void { |
| 3714 | 3714 | const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)]; |
| 3715 | 3715 | const dst_ty = self.typeOfIndex(inst); |
| 3716 | 3716 | switch (dst_ty.zigTypeTag(zcu)) { |
| 3717 | .Float, .Vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs), | |
| 3717 | .float, .vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs), | |
| 3718 | 3718 | else => {}, |
| 3719 | 3719 | } |
| 3720 | 3720 | const dst_abi_size: u32 = @intCast(dst_ty.abiSize(zcu)); |
| ... | ... | @@ -3941,7 +3941,7 @@ fn airAddSat(self: *Self, inst: Air.Inst.Index) !void { |
| 3941 | 3941 | const zcu = pt.zcu; |
| 3942 | 3942 | const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 3943 | 3943 | const ty = self.typeOf(bin_op.lhs); |
| 3944 | if (ty.zigTypeTag(zcu) == .Vector or ty.abiSize(zcu) > 8) return self.fail( | |
| 3944 | if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail( | |
| 3945 | 3945 | "TODO implement airAddSat for {}", |
| 3946 | 3946 | .{ty.fmt(pt)}, |
| 3947 | 3947 | ); |
| ... | ... | @@ -4042,7 +4042,7 @@ fn airSubSat(self: *Self, inst: Air.Inst.Index) !void { |
| 4042 | 4042 | const zcu = pt.zcu; |
| 4043 | 4043 | const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 4044 | 4044 | const ty = self.typeOf(bin_op.lhs); |
| 4045 | if (ty.zigTypeTag(zcu) == .Vector or ty.abiSize(zcu) > 8) return self.fail( | |
| 4045 | if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail( | |
| 4046 | 4046 | "TODO implement airSubSat for {}", |
| 4047 | 4047 | .{ty.fmt(pt)}, |
| 4048 | 4048 | ); |
| ... | ... | @@ -4216,7 +4216,7 @@ fn airMulSat(self: *Self, inst: Air.Inst.Index) !void { |
| 4216 | 4216 | break :result dst_mcv; |
| 4217 | 4217 | } |
| 4218 | 4218 | |
| 4219 | if (ty.zigTypeTag(zcu) == .Vector or ty.abiSize(zcu) > 8) return self.fail( | |
| 4219 | if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail( | |
| 4220 | 4220 | "TODO implement airMulSat for {}", |
| 4221 | 4221 | .{ty.fmt(pt)}, |
| 4222 | 4222 | ); |
| ... | ... | @@ -4287,8 +4287,8 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 4287 | 4287 | const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)]; |
| 4288 | 4288 | const ty = self.typeOf(bin_op.lhs); |
| 4289 | 4289 | switch (ty.zigTypeTag(zcu)) { |
| 4290 | .Vector => return self.fail("TODO implement add/sub with overflow for Vector type", .{}), | |
| 4291 | .Int => { | |
| 4290 | .vector => return self.fail("TODO implement add/sub with overflow for Vector type", .{}), | |
| 4291 | .int => { | |
| 4292 | 4292 | try self.spillEflagsIfOccupied(); |
| 4293 | 4293 | try self.spillRegisters(&.{ .rcx, .rdi, .rsi }); |
| 4294 | 4294 | const reg_locks = self.register_manager.lockRegsAssumeUnused(3, .{ .rcx, .rdi, .rsi }); |
| ... | ... | @@ -4354,8 +4354,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 4354 | 4354 | const lhs_ty = self.typeOf(bin_op.lhs); |
| 4355 | 4355 | const rhs_ty = self.typeOf(bin_op.rhs); |
| 4356 | 4356 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 4357 | .Vector => return self.fail("TODO implement shl with overflow for Vector type", .{}), | |
| 4358 | .Int => { | |
| 4357 | .vector => return self.fail("TODO implement shl with overflow for Vector type", .{}), | |
| 4358 | .int => { | |
| 4359 | 4359 | try self.spillEflagsIfOccupied(); |
| 4360 | 4360 | try self.spillRegisters(&.{ .rcx, .rdi, .rsi }); |
| 4361 | 4361 | const reg_locks = self.register_manager.lockRegsAssumeUnused(3, .{ .rcx, .rdi, .rsi }); |
| ... | ... | @@ -4510,8 +4510,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 4510 | 4510 | const tuple_ty = self.typeOfIndex(inst); |
| 4511 | 4511 | const dst_ty = self.typeOf(bin_op.lhs); |
| 4512 | 4512 | const result: MCValue = switch (dst_ty.zigTypeTag(zcu)) { |
| 4513 | .Vector => return self.fail("TODO implement airMulWithOverflow for {}", .{dst_ty.fmt(pt)}), | |
| 4514 | .Int => result: { | |
| 4513 | .vector => return self.fail("TODO implement airMulWithOverflow for {}", .{dst_ty.fmt(pt)}), | |
| 4514 | .int => result: { | |
| 4515 | 4515 | const dst_info = dst_ty.intInfo(zcu); |
| 4516 | 4516 | if (dst_info.bits > 128 and dst_info.signedness == .unsigned) { |
| 4517 | 4517 | const slow_inc = self.hasFeature(.slow_incdec); |
| ... | ... | @@ -5005,7 +5005,7 @@ fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void { |
| 5005 | 5005 | const rhs_ty = self.typeOf(bin_op.rhs); |
| 5006 | 5006 | const result: MCValue = result: { |
| 5007 | 5007 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 5008 | .Int => { | |
| 5008 | .int => { | |
| 5009 | 5009 | try self.spillRegisters(&.{.rcx}); |
| 5010 | 5010 | try self.register_manager.getKnownReg(.rcx, null); |
| 5011 | 5011 | const lhs_mcv = try self.resolveInst(bin_op.lhs); |
| ... | ... | @@ -5047,8 +5047,8 @@ fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void { |
| 5047 | 5047 | } |
| 5048 | 5048 | break :result dst_mcv; |
| 5049 | 5049 | }, |
| 5050 | .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 5051 | .Int => if (@as(?Mir.Inst.FixedTag, switch (lhs_ty.childType(zcu).intInfo(zcu).bits) { | |
| 5050 | .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 5051 | .int => if (@as(?Mir.Inst.FixedTag, switch (lhs_ty.childType(zcu).intInfo(zcu).bits) { | |
| 5052 | 5052 | else => null, |
| 5053 | 5053 | 16 => switch (lhs_ty.vectorLen(zcu)) { |
| 5054 | 5054 | else => null, |
| ... | ... | @@ -6212,7 +6212,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void { |
| 6212 | 6212 | |
| 6213 | 6213 | const dst_ty = self.typeOfIndex(inst); |
| 6214 | 6214 | const src_ty = self.typeOf(ty_op.operand); |
| 6215 | if (src_ty.zigTypeTag(zcu) == .Vector) return self.fail("TODO implement airClz for {}", .{ | |
| 6215 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airClz for {}", .{ | |
| 6216 | 6216 | src_ty.fmt(pt), |
| 6217 | 6217 | }); |
| 6218 | 6218 | |
| ... | ... | @@ -6409,7 +6409,7 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void { |
| 6409 | 6409 | |
| 6410 | 6410 | const dst_ty = self.typeOfIndex(inst); |
| 6411 | 6411 | const src_ty = self.typeOf(ty_op.operand); |
| 6412 | if (src_ty.zigTypeTag(zcu) == .Vector) return self.fail("TODO implement airCtz for {}", .{ | |
| 6412 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airCtz for {}", .{ | |
| 6413 | 6413 | src_ty.fmt(pt), |
| 6414 | 6414 | }); |
| 6415 | 6415 | |
| ... | ... | @@ -6571,7 +6571,7 @@ fn airPopCount(self: *Self, inst: Air.Inst.Index) !void { |
| 6571 | 6571 | |
| 6572 | 6572 | const src_ty = self.typeOf(ty_op.operand); |
| 6573 | 6573 | const src_abi_size: u32 = @intCast(src_ty.abiSize(zcu)); |
| 6574 | if (src_ty.zigTypeTag(zcu) == .Vector or src_abi_size > 16) | |
| 6574 | if (src_ty.zigTypeTag(zcu) == .vector or src_abi_size > 16) | |
| 6575 | 6575 | return self.fail("TODO implement airPopCount for {}", .{src_ty.fmt(pt)}); |
| 6576 | 6576 | const src_mcv = try self.resolveInst(ty_op.operand); |
| 6577 | 6577 | |
| ... | ... | @@ -6724,7 +6724,7 @@ fn genByteSwap( |
| 6724 | 6724 | const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 6725 | 6725 | const has_movbe = self.hasFeature(.movbe); |
| 6726 | 6726 | |
| 6727 | if (src_ty.zigTypeTag(zcu) == .Vector) return self.fail( | |
| 6727 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail( | |
| 6728 | 6728 | "TODO implement genByteSwap for {}", |
| 6729 | 6729 | .{src_ty.fmt(pt)}, |
| 6730 | 6730 | ); |
| ... | ... | @@ -7036,7 +7036,7 @@ fn floatSign(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Type) |
| 7036 | 7036 | const result = result: { |
| 7037 | 7037 | const scalar_bits = ty.scalarType(zcu).floatBits(self.target.*); |
| 7038 | 7038 | if (scalar_bits == 80) { |
| 7039 | if (ty.zigTypeTag(zcu) != .Float) return self.fail("TODO implement floatSign for {}", .{ | |
| 7039 | if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement floatSign for {}", .{ | |
| 7040 | 7040 | ty.fmt(pt), |
| 7041 | 7041 | }); |
| 7042 | 7042 | |
| ... | ... | @@ -7209,14 +7209,14 @@ fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag { |
| 7209 | 7209 | const pt = self.pt; |
| 7210 | 7210 | const zcu = pt.zcu; |
| 7211 | 7211 | return if (self.hasFeature(.sse4_1)) switch (ty.zigTypeTag(zcu)) { |
| 7212 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 7212 | .float => switch (ty.floatBits(self.target.*)) { | |
| 7213 | 7213 | 32 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round }, |
| 7214 | 7214 | 64 => if (self.hasFeature(.avx)) .{ .v_sd, .round } else .{ ._sd, .round }, |
| 7215 | 7215 | 16, 80, 128 => null, |
| 7216 | 7216 | else => unreachable, |
| 7217 | 7217 | }, |
| 7218 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 7219 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 7218 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 7219 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 7220 | 7220 | 32 => switch (ty.vectorLen(zcu)) { |
| 7221 | 7221 | 1 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round }, |
| 7222 | 7222 | 2...4 => if (self.hasFeature(.avx)) .{ .v_ps, .round } else .{ ._ps, .round }, |
| ... | ... | @@ -7243,7 +7243,7 @@ fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MC |
| 7243 | 7243 | const zcu = pt.zcu; |
| 7244 | 7244 | if (self.getRoundTag(ty)) |_| return .none; |
| 7245 | 7245 | |
| 7246 | if (ty.zigTypeTag(zcu) != .Float) | |
| 7246 | if (ty.zigTypeTag(zcu) != .float) | |
| 7247 | 7247 | return self.fail("TODO implement genRound for {}", .{ty.fmt(pt)}); |
| 7248 | 7248 | |
| 7249 | 7249 | var callee_buf: ["__trunc?".len]u8 = undefined; |
| ... | ... | @@ -7314,7 +7314,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void { |
| 7314 | 7314 | const result: MCValue = result: { |
| 7315 | 7315 | const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.zigTypeTag(zcu)) { |
| 7316 | 7316 | else => null, |
| 7317 | .Int => switch (ty.abiSize(zcu)) { | |
| 7317 | .int => switch (ty.abiSize(zcu)) { | |
| 7318 | 7318 | 0 => unreachable, |
| 7319 | 7319 | 1...8 => { |
| 7320 | 7320 | try self.spillEflagsIfOccupied(); |
| ... | ... | @@ -7442,10 +7442,10 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void { |
| 7442 | 7442 | break :result dst_mcv; |
| 7443 | 7443 | }, |
| 7444 | 7444 | }, |
| 7445 | .Float => return self.floatSign(inst, ty_op.operand, ty), | |
| 7446 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 7445 | .float => return self.floatSign(inst, ty_op.operand, ty), | |
| 7446 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 7447 | 7447 | else => null, |
| 7448 | .Int => switch (ty.childType(zcu).intInfo(zcu).bits) { | |
| 7448 | .int => switch (ty.childType(zcu).intInfo(zcu).bits) { | |
| 7449 | 7449 | else => null, |
| 7450 | 7450 | 8 => switch (ty.vectorLen(zcu)) { |
| 7451 | 7451 | else => null, |
| ... | ... | @@ -7478,7 +7478,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void { |
| 7478 | 7478 | 5...8 => if (self.hasFeature(.avx2)) .{ .vp_d, .abs } else null, |
| 7479 | 7479 | }, |
| 7480 | 7480 | }, |
| 7481 | .Float => return self.floatSign(inst, ty_op.operand, ty), | |
| 7481 | .float => return self.floatSign(inst, ty_op.operand, ty), | |
| 7482 | 7482 | }, |
| 7483 | 7483 | }) orelse return self.fail("TODO implement airAbs for {}", .{ty.fmt(pt)}); |
| 7484 | 7484 | |
| ... | ... | @@ -7515,7 +7515,7 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void { |
| 7515 | 7515 | |
| 7516 | 7516 | const result: MCValue = result: { |
| 7517 | 7517 | switch (ty.zigTypeTag(zcu)) { |
| 7518 | .Float => { | |
| 7518 | .float => { | |
| 7519 | 7519 | const float_bits = ty.floatBits(self.target.*); |
| 7520 | 7520 | if (switch (float_bits) { |
| 7521 | 7521 | 16 => !self.hasFeature(.f16c), |
| ... | ... | @@ -7547,7 +7547,7 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void { |
| 7547 | 7547 | defer if (dst_lock) |lock| self.register_manager.unlockReg(lock); |
| 7548 | 7548 | |
| 7549 | 7549 | const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.zigTypeTag(zcu)) { |
| 7550 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 7550 | .float => switch (ty.floatBits(self.target.*)) { | |
| 7551 | 7551 | 16 => { |
| 7552 | 7552 | assert(self.hasFeature(.f16c)); |
| 7553 | 7553 | const mat_src_reg = if (src_mcv.isRegister()) |
| ... | ... | @@ -7568,8 +7568,8 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void { |
| 7568 | 7568 | 64 => if (self.hasFeature(.avx)) .{ .v_sd, .sqrt } else .{ ._sd, .sqrt }, |
| 7569 | 7569 | else => unreachable, |
| 7570 | 7570 | }, |
| 7571 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 7572 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 7571 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 7572 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 7573 | 7573 | 16 => if (self.hasFeature(.f16c)) switch (ty.vectorLen(zcu)) { |
| 7574 | 7574 | 1 => { |
| 7575 | 7575 | try self.asmRegisterRegister( |
| ... | ... | @@ -8496,7 +8496,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air: |
| 8496 | 8496 | const pt = self.pt; |
| 8497 | 8497 | const zcu = pt.zcu; |
| 8498 | 8498 | const src_ty = self.typeOf(src_air); |
| 8499 | if (src_ty.zigTypeTag(zcu) == .Vector) | |
| 8499 | if (src_ty.zigTypeTag(zcu) == .vector) | |
| 8500 | 8500 | return self.fail("TODO implement genUnOp for {}", .{src_ty.fmt(pt)}); |
| 8501 | 8501 | |
| 8502 | 8502 | var src_mcv = try self.resolveInst(src_air); |
| ... | ... | @@ -9291,7 +9291,7 @@ fn genShiftBinOp( |
| 9291 | 9291 | ) !MCValue { |
| 9292 | 9292 | const pt = self.pt; |
| 9293 | 9293 | const zcu = pt.zcu; |
| 9294 | if (lhs_ty.zigTypeTag(zcu) == .Vector) return self.fail("TODO implement genShiftBinOp for {}", .{ | |
| 9294 | if (lhs_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement genShiftBinOp for {}", .{ | |
| 9295 | 9295 | lhs_ty.fmt(pt), |
| 9296 | 9296 | }); |
| 9297 | 9297 | |
| ... | ... | @@ -9350,7 +9350,7 @@ fn genMulDivBinOp( |
| 9350 | 9350 | ) !MCValue { |
| 9351 | 9351 | const pt = self.pt; |
| 9352 | 9352 | const zcu = pt.zcu; |
| 9353 | if (dst_ty.zigTypeTag(zcu) == .Vector or dst_ty.zigTypeTag(zcu) == .Float) return self.fail( | |
| 9353 | if (dst_ty.zigTypeTag(zcu) == .vector or dst_ty.zigTypeTag(zcu) == .float) return self.fail( | |
| 9354 | 9354 | "TODO implement genMulDivBinOp for {s} from {} to {}", |
| 9355 | 9355 | .{ @tagName(tag), src_ty.fmt(pt), dst_ty.fmt(pt) }, |
| 9356 | 9356 | ); |
| ... | ... | @@ -9938,8 +9938,8 @@ fn genBinOp( |
| 9938 | 9938 | |
| 9939 | 9939 | const sse_op = switch (lhs_ty.zigTypeTag(zcu)) { |
| 9940 | 9940 | else => false, |
| 9941 | .Float => true, | |
| 9942 | .Vector => switch (lhs_ty.childType(zcu).toIntern()) { | |
| 9941 | .float => true, | |
| 9942 | .vector => switch (lhs_ty.childType(zcu).toIntern()) { | |
| 9943 | 9943 | .bool_type, .u1_type => false, |
| 9944 | 9944 | else => true, |
| 9945 | 9945 | }, |
| ... | ... | @@ -9966,12 +9966,12 @@ fn genBinOp( |
| 9966 | 9966 | |
| 9967 | 9967 | const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and |
| 9968 | 9968 | switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { |
| 9969 | .Bool => false, | |
| 9970 | .Int => switch (air_tag) { | |
| 9969 | .bool => false, | |
| 9970 | .int => switch (air_tag) { | |
| 9971 | 9971 | .cmp_lt, .cmp_gte => true, |
| 9972 | 9972 | else => false, |
| 9973 | 9973 | }, |
| 9974 | .Float => switch (air_tag) { | |
| 9974 | .float => switch (air_tag) { | |
| 9975 | 9975 | .cmp_gte, .cmp_gt => true, |
| 9976 | 9976 | else => false, |
| 9977 | 9977 | }, |
| ... | ... | @@ -10337,7 +10337,7 @@ fn genBinOp( |
| 10337 | 10337 | const dst_reg = registerAlias(dst_mcv.getReg().?, abi_size); |
| 10338 | 10338 | const mir_tag = @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) { |
| 10339 | 10339 | else => unreachable, |
| 10340 | .Float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 10340 | .float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 10341 | 10341 | 16 => { |
| 10342 | 10342 | assert(self.hasFeature(.f16c)); |
| 10343 | 10343 | const tmp_reg = |
| ... | ... | @@ -10430,9 +10430,9 @@ fn genBinOp( |
| 10430 | 10430 | 80, 128 => null, |
| 10431 | 10431 | else => unreachable, |
| 10432 | 10432 | }, |
| 10433 | .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 10433 | .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 10434 | 10434 | else => null, |
| 10435 | .Int => switch (lhs_ty.childType(zcu).intInfo(zcu).bits) { | |
| 10435 | .int => switch (lhs_ty.childType(zcu).intInfo(zcu).bits) { | |
| 10436 | 10436 | 8 => switch (lhs_ty.vectorLen(zcu)) { |
| 10437 | 10437 | 1...16 => switch (air_tag) { |
| 10438 | 10438 | .add, |
| ... | ... | @@ -10779,7 +10779,7 @@ fn genBinOp( |
| 10779 | 10779 | }, |
| 10780 | 10780 | else => null, |
| 10781 | 10781 | }, |
| 10782 | .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 10782 | .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 10783 | 10783 | 16 => tag: { |
| 10784 | 10784 | assert(self.hasFeature(.f16c)); |
| 10785 | 10785 | switch (lhs_ty.vectorLen(zcu)) { |
| ... | ... | @@ -11101,7 +11101,7 @@ fn genBinOp( |
| 11101 | 11101 | lhs_reg, |
| 11102 | 11102 | try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11103 | 11103 | else => Memory.Size.fromSize(abi_size), |
| 11104 | .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11104 | .vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11105 | 11105 | }), |
| 11106 | 11106 | ) else try self.asmRegisterRegisterRegister( |
| 11107 | 11107 | mir_tag, |
| ... | ... | @@ -11119,7 +11119,7 @@ fn genBinOp( |
| 11119 | 11119 | dst_reg, |
| 11120 | 11120 | try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11121 | 11121 | else => Memory.Size.fromSize(abi_size), |
| 11122 | .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11122 | .vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11123 | 11123 | }), |
| 11124 | 11124 | ) else try self.asmRegisterRegister( |
| 11125 | 11125 | mir_tag, |
| ... | ... | @@ -11147,7 +11147,7 @@ fn genBinOp( |
| 11147 | 11147 | lhs_reg, |
| 11148 | 11148 | try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11149 | 11149 | else => Memory.Size.fromSize(abi_size), |
| 11150 | .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11150 | .vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11151 | 11151 | }), |
| 11152 | 11152 | imm, |
| 11153 | 11153 | ) else try self.asmRegisterRegisterRegisterImmediate( |
| ... | ... | @@ -11167,7 +11167,7 @@ fn genBinOp( |
| 11167 | 11167 | dst_reg, |
| 11168 | 11168 | try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11169 | 11169 | else => Memory.Size.fromSize(abi_size), |
| 11170 | .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11170 | .vector => Memory.Size.fromBitSize(dst_reg.bitSize()), | |
| 11171 | 11171 | }), |
| 11172 | 11172 | imm, |
| 11173 | 11173 | ) else try self.asmRegisterRegisterImmediate( |
| ... | ... | @@ -11199,14 +11199,14 @@ fn genBinOp( |
| 11199 | 11199 | |
| 11200 | 11200 | try self.asmRegisterRegisterRegisterImmediate( |
| 11201 | 11201 | @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11202 | .Float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11202 | .float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11203 | 11203 | 32 => .{ .v_ss, .cmp }, |
| 11204 | 11204 | 64 => .{ .v_sd, .cmp }, |
| 11205 | 11205 | 16, 80, 128 => null, |
| 11206 | 11206 | else => unreachable, |
| 11207 | 11207 | }, |
| 11208 | .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11209 | .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11208 | .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11209 | .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11210 | 11210 | 32 => switch (lhs_ty.vectorLen(zcu)) { |
| 11211 | 11211 | 1 => .{ .v_ss, .cmp }, |
| 11212 | 11212 | 2...8 => .{ .v_ps, .cmp }, |
| ... | ... | @@ -11233,14 +11233,14 @@ fn genBinOp( |
| 11233 | 11233 | ); |
| 11234 | 11234 | try self.asmRegisterRegisterRegisterRegister( |
| 11235 | 11235 | @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11236 | .Float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11236 | .float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11237 | 11237 | 32 => .{ .v_ps, .blendv }, |
| 11238 | 11238 | 64 => .{ .v_pd, .blendv }, |
| 11239 | 11239 | 16, 80, 128 => null, |
| 11240 | 11240 | else => unreachable, |
| 11241 | 11241 | }, |
| 11242 | .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11243 | .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11242 | .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11243 | .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11244 | 11244 | 32 => switch (lhs_ty.vectorLen(zcu)) { |
| 11245 | 11245 | 1...8 => .{ .v_ps, .blendv }, |
| 11246 | 11246 | else => null, |
| ... | ... | @@ -11267,14 +11267,14 @@ fn genBinOp( |
| 11267 | 11267 | const has_blend = self.hasFeature(.sse4_1); |
| 11268 | 11268 | try self.asmRegisterRegisterImmediate( |
| 11269 | 11269 | @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11270 | .Float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11270 | .float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11271 | 11271 | 32 => .{ ._ss, .cmp }, |
| 11272 | 11272 | 64 => .{ ._sd, .cmp }, |
| 11273 | 11273 | 16, 80, 128 => null, |
| 11274 | 11274 | else => unreachable, |
| 11275 | 11275 | }, |
| 11276 | .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11277 | .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11276 | .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11277 | .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11278 | 11278 | 32 => switch (lhs_ty.vectorLen(zcu)) { |
| 11279 | 11279 | 1 => .{ ._ss, .cmp }, |
| 11280 | 11280 | 2...4 => .{ ._ps, .cmp }, |
| ... | ... | @@ -11300,14 +11300,14 @@ fn genBinOp( |
| 11300 | 11300 | ); |
| 11301 | 11301 | if (has_blend) try self.asmRegisterRegisterRegister( |
| 11302 | 11302 | @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11303 | .Float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11303 | .float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11304 | 11304 | 32 => .{ ._ps, .blendv }, |
| 11305 | 11305 | 64 => .{ ._pd, .blendv }, |
| 11306 | 11306 | 16, 80, 128 => null, |
| 11307 | 11307 | else => unreachable, |
| 11308 | 11308 | }, |
| 11309 | .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11310 | .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11309 | .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11310 | .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11311 | 11311 | 32 => switch (lhs_ty.vectorLen(zcu)) { |
| 11312 | 11312 | 1...4 => .{ ._ps, .blendv }, |
| 11313 | 11313 | else => null, |
| ... | ... | @@ -11330,14 +11330,14 @@ fn genBinOp( |
| 11330 | 11330 | mask_reg, |
| 11331 | 11331 | ) else { |
| 11332 | 11332 | const mir_fixes = @as(?Mir.Inst.Fixes, switch (lhs_ty.zigTypeTag(zcu)) { |
| 11333 | .Float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11333 | .float => switch (lhs_ty.floatBits(self.target.*)) { | |
| 11334 | 11334 | 32 => ._ps, |
| 11335 | 11335 | 64 => ._pd, |
| 11336 | 11336 | 16, 80, 128 => null, |
| 11337 | 11337 | else => unreachable, |
| 11338 | 11338 | }, |
| 11339 | .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11340 | .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11339 | .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { | |
| 11340 | .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) { | |
| 11341 | 11341 | 32 => switch (lhs_ty.vectorLen(zcu)) { |
| 11342 | 11342 | 1...4 => ._ps, |
| 11343 | 11343 | else => null, |
| ... | ... | @@ -11362,7 +11362,7 @@ fn genBinOp( |
| 11362 | 11362 | }, |
| 11363 | 11363 | .cmp_lt, .cmp_lte, .cmp_eq, .cmp_gte, .cmp_gt, .cmp_neq => { |
| 11364 | 11364 | switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) { |
| 11365 | .Int => switch (air_tag) { | |
| 11365 | .int => switch (air_tag) { | |
| 11366 | 11366 | .cmp_lt, |
| 11367 | 11367 | .cmp_eq, |
| 11368 | 11368 | .cmp_gt, |
| ... | ... | @@ -11396,7 +11396,7 @@ fn genBinOp( |
| 11396 | 11396 | }, |
| 11397 | 11397 | else => unreachable, |
| 11398 | 11398 | }, |
| 11399 | .Float => {}, | |
| 11399 | .float => {}, | |
| 11400 | 11400 | else => unreachable, |
| 11401 | 11401 | } |
| 11402 | 11402 | |
| ... | ... | @@ -12268,8 +12268,8 @@ fn genCall(self: *Self, info: union(enum) { |
| 12268 | 12268 | .air => |callee| fn_info: { |
| 12269 | 12269 | const callee_ty = self.typeOf(callee); |
| 12270 | 12270 | break :fn_info switch (callee_ty.zigTypeTag(zcu)) { |
| 12271 | .Fn => callee_ty, | |
| 12272 | .Pointer => callee_ty.childType(zcu), | |
| 12271 | .@"fn" => callee_ty, | |
| 12272 | .pointer => callee_ty.childType(zcu), | |
| 12273 | 12273 | else => unreachable, |
| 12274 | 12274 | }; |
| 12275 | 12275 | }, |
| ... | ... | @@ -12544,7 +12544,7 @@ fn genCall(self: *Self, info: union(enum) { |
| 12544 | 12544 | else => return self.fail("TODO implement calling bitcasted functions", .{}), |
| 12545 | 12545 | } |
| 12546 | 12546 | } else { |
| 12547 | assert(self.typeOf(callee).zigTypeTag(zcu) == .Pointer); | |
| 12547 | assert(self.typeOf(callee).zigTypeTag(zcu) == .pointer); | |
| 12548 | 12548 | try self.genSetReg(.rax, Type.usize, .{ .air_ref = callee }, .{}); |
| 12549 | 12549 | try self.asmRegister(.{ ._, .call }, .rax); |
| 12550 | 12550 | }, |
| ... | ... | @@ -12650,7 +12650,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void { |
| 12650 | 12650 | defer for (rhs_locks) |rhs_lock| if (rhs_lock) |lock| self.register_manager.unlockReg(lock); |
| 12651 | 12651 | |
| 12652 | 12652 | switch (ty.zigTypeTag(zcu)) { |
| 12653 | .Float => { | |
| 12653 | .float => { | |
| 12654 | 12654 | const float_bits = ty.floatBits(self.target.*); |
| 12655 | 12655 | if (switch (float_bits) { |
| 12656 | 12656 | 16 => !self.hasFeature(.f16c), |
| ... | ... | @@ -12685,7 +12685,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void { |
| 12685 | 12685 | }; |
| 12686 | 12686 | } |
| 12687 | 12687 | }, |
| 12688 | .Optional => if (!ty.optionalReprIsPayload(zcu)) { | |
| 12688 | .optional => if (!ty.optionalReprIsPayload(zcu)) { | |
| 12689 | 12689 | const opt_ty = ty; |
| 12690 | 12690 | const opt_abi_size: u31 = @intCast(opt_ty.abiSize(zcu)); |
| 12691 | 12691 | ty = opt_ty.optionalChild(zcu); |
| ... | ... | @@ -12982,7 +12982,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void { |
| 12982 | 12982 | }, |
| 12983 | 12983 | ); |
| 12984 | 12984 | }, |
| 12985 | .Float => { | |
| 12985 | .float => { | |
| 12986 | 12986 | const flipped = switch (op) { |
| 12987 | 12987 | .lt, .lte => true, |
| 12988 | 12988 | .eq, .gte, .gt, .neq => false, |
| ... | ... | @@ -14659,7 +14659,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo |
| 14659 | 14659 | else => {}, |
| 14660 | 14660 | } |
| 14661 | 14661 | }, |
| 14662 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 14662 | .float => switch (ty.floatBits(self.target.*)) { | |
| 14663 | 14663 | 16 => return if (self.hasFeature(.avx)) .{ .vex_insert_extract = .{ |
| 14664 | 14664 | .insert = .{ .vp_w, .insr }, |
| 14665 | 14665 | .extract = .{ .vp_w, .extr }, |
| ... | ... | @@ -14680,15 +14680,15 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo |
| 14680 | 14680 | else if (aligned) .{ ._, .movdqa } else .{ ._, .movdqu } }, |
| 14681 | 14681 | else => {}, |
| 14682 | 14682 | }, |
| 14683 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 14684 | .Bool => switch (ty.vectorLen(zcu)) { | |
| 14683 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 14684 | .bool => switch (ty.vectorLen(zcu)) { | |
| 14685 | 14685 | 33...64 => return .{ .move = if (self.hasFeature(.avx)) |
| 14686 | 14686 | .{ .v_q, .mov } |
| 14687 | 14687 | else |
| 14688 | 14688 | .{ ._q, .mov } }, |
| 14689 | 14689 | else => {}, |
| 14690 | 14690 | }, |
| 14691 | .Int => switch (ty.childType(zcu).intInfo(zcu).bits) { | |
| 14691 | .int => switch (ty.childType(zcu).intInfo(zcu).bits) { | |
| 14692 | 14692 | 1...8 => switch (ty.vectorLen(zcu)) { |
| 14693 | 14693 | 1...16 => return .{ .move = if (self.hasFeature(.avx)) |
| 14694 | 14694 | if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu } |
| ... | ... | @@ -14754,7 +14754,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo |
| 14754 | 14754 | }, |
| 14755 | 14755 | else => {}, |
| 14756 | 14756 | }, |
| 14757 | .Pointer, .Optional => if (ty.childType(zcu).isPtrAtRuntime(zcu)) | |
| 14757 | .pointer, .optional => if (ty.childType(zcu).isPtrAtRuntime(zcu)) | |
| 14758 | 14758 | switch (ty.vectorLen(zcu)) { |
| 14759 | 14759 | 1...2 => return .{ .move = if (self.hasFeature(.avx)) |
| 14760 | 14760 | if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu } |
| ... | ... | @@ -14768,7 +14768,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo |
| 14768 | 14768 | } |
| 14769 | 14769 | else |
| 14770 | 14770 | unreachable, |
| 14771 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 14771 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 14772 | 14772 | 16 => switch (ty.vectorLen(zcu)) { |
| 14773 | 14773 | 1...8 => return .{ .move = if (self.hasFeature(.avx)) |
| 14774 | 14774 | if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu } |
| ... | ... | @@ -15072,7 +15072,7 @@ fn genSetReg( |
| 15072 | 15072 | 17...32 => if (self.hasFeature(.avx)) .{ .v_, .movdqa } else null, |
| 15073 | 15073 | else => null, |
| 15074 | 15074 | }, |
| 15075 | .Float => switch (ty.scalarType(zcu).floatBits(self.target.*)) { | |
| 15075 | .float => switch (ty.scalarType(zcu).floatBits(self.target.*)) { | |
| 15076 | 15076 | 16, 128 => switch (abi_size) { |
| 15077 | 15077 | 2...16 => if (self.hasFeature(.avx)) |
| 15078 | 15078 | .{ .v_, .movdqa } |
| ... | ... | @@ -15368,7 +15368,7 @@ fn genSetMem( |
| 15368 | 15368 | } |
| 15369 | 15369 | }, |
| 15370 | 15370 | .register_overflow => |ro| switch (ty.zigTypeTag(zcu)) { |
| 15371 | .Struct => { | |
| 15371 | .@"struct" => { | |
| 15372 | 15372 | try self.genSetMem( |
| 15373 | 15373 | base, |
| 15374 | 15374 | disp + @as(i32, @intCast(ty.structFieldOffset(0, zcu))), |
| ... | ... | @@ -15384,7 +15384,7 @@ fn genSetMem( |
| 15384 | 15384 | opts, |
| 15385 | 15385 | ); |
| 15386 | 15386 | }, |
| 15387 | .Optional => { | |
| 15387 | .optional => { | |
| 15388 | 15388 | assert(!ty.optionalReprIsPayload(zcu)); |
| 15389 | 15389 | const child_ty = ty.optionalChild(zcu); |
| 15390 | 15390 | try self.genSetMem(base, disp, child_ty, .{ .register = ro.reg }, opts); |
| ... | ... | @@ -15768,7 +15768,7 @@ fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void { |
| 15768 | 15768 | defer self.register_manager.unlockReg(dst_lock); |
| 15769 | 15769 | |
| 15770 | 15770 | const mir_tag = @as(?Mir.Inst.FixedTag, switch (dst_ty.zigTypeTag(zcu)) { |
| 15771 | .Float => switch (dst_ty.floatBits(self.target.*)) { | |
| 15771 | .float => switch (dst_ty.floatBits(self.target.*)) { | |
| 15772 | 15772 | 32 => if (self.hasFeature(.avx)) .{ .v_ss, .cvtsi2 } else .{ ._ss, .cvtsi2 }, |
| 15773 | 15773 | 64 => if (self.hasFeature(.avx)) .{ .v_sd, .cvtsi2 } else .{ ._sd, .cvtsi2 }, |
| 15774 | 15774 | 16, 80, 128 => null, |
| ... | ... | @@ -16702,7 +16702,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { |
| 16702 | 16702 | const result: MCValue = result: { |
| 16703 | 16703 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 16704 | 16704 | else => {}, |
| 16705 | .Bool => { | |
| 16705 | .bool => { | |
| 16706 | 16706 | const regs = |
| 16707 | 16707 | try self.register_manager.allocRegs(2, .{ inst, null }, abi.RegisterClass.gp); |
| 16708 | 16708 | const reg_locks = self.register_manager.lockRegsAssumeUnused(2, regs); |
| ... | ... | @@ -16742,7 +16742,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { |
| 16742 | 16742 | ); |
| 16743 | 16743 | break :result .{ .register = regs[0] }; |
| 16744 | 16744 | }, |
| 16745 | .Int => if (self.hasFeature(.avx2)) avx2: { | |
| 16745 | .int => if (self.hasFeature(.avx2)) avx2: { | |
| 16746 | 16746 | const mir_tag = @as(?Mir.Inst.FixedTag, switch (scalar_ty.intInfo(zcu).bits) { |
| 16747 | 16747 | else => null, |
| 16748 | 16748 | 1...8 => switch (vector_len) { |
| ... | ... | @@ -16835,7 +16835,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { |
| 16835 | 16835 | ); |
| 16836 | 16836 | break :result .{ .register = dst_reg }; |
| 16837 | 16837 | }, |
| 16838 | .Float => switch (scalar_ty.floatBits(self.target.*)) { | |
| 16838 | .float => switch (scalar_ty.floatBits(self.target.*)) { | |
| 16839 | 16839 | 32 => switch (vector_len) { |
| 16840 | 16840 | 1 => { |
| 16841 | 16841 | const src_mcv = try self.resolveInst(ty_op.operand); |
| ... | ... | @@ -17264,7 +17264,7 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void { |
| 17264 | 17264 | |
| 17265 | 17265 | const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.childType(zcu).zigTypeTag(zcu)) { |
| 17266 | 17266 | else => null, |
| 17267 | .Int => switch (abi_size) { | |
| 17267 | .int => switch (abi_size) { | |
| 17268 | 17268 | 0 => unreachable, |
| 17269 | 17269 | 1...16 => if (has_avx) |
| 17270 | 17270 | .{ .vp_b, .blendv } |
| ... | ... | @@ -17278,7 +17278,7 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void { |
| 17278 | 17278 | null, |
| 17279 | 17279 | else => null, |
| 17280 | 17280 | }, |
| 17281 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 17281 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 17282 | 17282 | else => unreachable, |
| 17283 | 17283 | 16, 80, 128 => null, |
| 17284 | 17284 | 32 => switch (vec_len) { |
| ... | ... | @@ -17334,8 +17334,8 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void { |
| 17334 | 17334 | ) else { |
| 17335 | 17335 | const mir_fixes = @as(?Mir.Inst.Fixes, switch (elem_ty.zigTypeTag(zcu)) { |
| 17336 | 17336 | else => null, |
| 17337 | .Int => .p_, | |
| 17338 | .Float => switch (elem_ty.floatBits(self.target.*)) { | |
| 17337 | .int => .p_, | |
| 17338 | .float => switch (elem_ty.floatBits(self.target.*)) { | |
| 17339 | 17339 | 32 => ._ps, |
| 17340 | 17340 | 64 => ._pd, |
| 17341 | 17341 | 16, 80, 128 => null, |
| ... | ... | @@ -18132,8 +18132,8 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { |
| 18132 | 18132 | if (has_avx) try self.asmRegisterRegisterRegister( |
| 18133 | 18133 | .{ switch (elem_ty.zigTypeTag(zcu)) { |
| 18134 | 18134 | else => break :result null, |
| 18135 | .Int => .vp_, | |
| 18136 | .Float => switch (elem_ty.floatBits(self.target.*)) { | |
| 18135 | .int => .vp_, | |
| 18136 | .float => switch (elem_ty.floatBits(self.target.*)) { | |
| 18137 | 18137 | 32 => .v_ps, |
| 18138 | 18138 | 64 => .v_pd, |
| 18139 | 18139 | 16, 80, 128 => break :result null, |
| ... | ... | @@ -18146,8 +18146,8 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { |
| 18146 | 18146 | ) else try self.asmRegisterRegister( |
| 18147 | 18147 | .{ switch (elem_ty.zigTypeTag(zcu)) { |
| 18148 | 18148 | else => break :result null, |
| 18149 | .Int => .p_, | |
| 18150 | .Float => switch (elem_ty.floatBits(self.target.*)) { | |
| 18149 | .int => .p_, | |
| 18150 | .float => switch (elem_ty.floatBits(self.target.*)) { | |
| 18151 | 18151 | 32 => ._ps, |
| 18152 | 18152 | 64 => ._pd, |
| 18153 | 18153 | 16, 80, 128 => break :result null, |
| ... | ... | @@ -18235,7 +18235,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { |
| 18235 | 18235 | const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]); |
| 18236 | 18236 | const result: MCValue = result: { |
| 18237 | 18237 | switch (result_ty.zigTypeTag(zcu)) { |
| 18238 | .Struct => { | |
| 18238 | .@"struct" => { | |
| 18239 | 18239 | const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu)); |
| 18240 | 18240 | if (result_ty.containerLayout(zcu) == .@"packed") { |
| 18241 | 18241 | const struct_obj = zcu.typeToStruct(result_ty).?; |
| ... | ... | @@ -18342,7 +18342,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { |
| 18342 | 18342 | } |
| 18343 | 18343 | break :result .{ .load_frame = .{ .index = frame_index } }; |
| 18344 | 18344 | }, |
| 18345 | .Array, .Vector => { | |
| 18345 | .array, .vector => { | |
| 18346 | 18346 | const elem_ty = result_ty.childType(zcu); |
| 18347 | 18347 | if (result_ty.isVector(zcu) and elem_ty.toIntern() == .bool_type) { |
| 18348 | 18348 | const result_size: u32 = @intCast(result_ty.abiSize(zcu)); |
| ... | ... | @@ -18483,7 +18483,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void { |
| 18483 | 18483 | 32, 64 => !self.hasFeature(.fma), |
| 18484 | 18484 | else => unreachable, |
| 18485 | 18485 | }) { |
| 18486 | if (ty.zigTypeTag(zcu) != .Float) return self.fail("TODO implement airMulAdd for {}", .{ | |
| 18486 | if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement airMulAdd for {}", .{ | |
| 18487 | 18487 | ty.fmt(pt), |
| 18488 | 18488 | }); |
| 18489 | 18489 | |
| ... | ... | @@ -18533,14 +18533,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void { |
| 18533 | 18533 | const mir_tag = @as(?Mir.Inst.FixedTag, if (mem.eql(u2, &order, &.{ 1, 3, 2 }) or |
| 18534 | 18534 | mem.eql(u2, &order, &.{ 3, 1, 2 })) |
| 18535 | 18535 | switch (ty.zigTypeTag(zcu)) { |
| 18536 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 18536 | .float => switch (ty.floatBits(self.target.*)) { | |
| 18537 | 18537 | 32 => .{ .v_ss, .fmadd132 }, |
| 18538 | 18538 | 64 => .{ .v_sd, .fmadd132 }, |
| 18539 | 18539 | 16, 80, 128 => null, |
| 18540 | 18540 | else => unreachable, |
| 18541 | 18541 | }, |
| 18542 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 18543 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 18542 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 18543 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 18544 | 18544 | 32 => switch (ty.vectorLen(zcu)) { |
| 18545 | 18545 | 1 => .{ .v_ss, .fmadd132 }, |
| 18546 | 18546 | 2...8 => .{ .v_ps, .fmadd132 }, |
| ... | ... | @@ -18560,14 +18560,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void { |
| 18560 | 18560 | } |
| 18561 | 18561 | else if (mem.eql(u2, &order, &.{ 2, 1, 3 }) or mem.eql(u2, &order, &.{ 1, 2, 3 })) |
| 18562 | 18562 | switch (ty.zigTypeTag(zcu)) { |
| 18563 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 18563 | .float => switch (ty.floatBits(self.target.*)) { | |
| 18564 | 18564 | 32 => .{ .v_ss, .fmadd213 }, |
| 18565 | 18565 | 64 => .{ .v_sd, .fmadd213 }, |
| 18566 | 18566 | 16, 80, 128 => null, |
| 18567 | 18567 | else => unreachable, |
| 18568 | 18568 | }, |
| 18569 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 18570 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 18569 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 18570 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 18571 | 18571 | 32 => switch (ty.vectorLen(zcu)) { |
| 18572 | 18572 | 1 => .{ .v_ss, .fmadd213 }, |
| 18573 | 18573 | 2...8 => .{ .v_ps, .fmadd213 }, |
| ... | ... | @@ -18587,14 +18587,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void { |
| 18587 | 18587 | } |
| 18588 | 18588 | else if (mem.eql(u2, &order, &.{ 2, 3, 1 }) or mem.eql(u2, &order, &.{ 3, 2, 1 })) |
| 18589 | 18589 | switch (ty.zigTypeTag(zcu)) { |
| 18590 | .Float => switch (ty.floatBits(self.target.*)) { | |
| 18590 | .float => switch (ty.floatBits(self.target.*)) { | |
| 18591 | 18591 | 32 => .{ .v_ss, .fmadd231 }, |
| 18592 | 18592 | 64 => .{ .v_sd, .fmadd231 }, |
| 18593 | 18593 | 16, 80, 128 => null, |
| 18594 | 18594 | else => unreachable, |
| 18595 | 18595 | }, |
| 18596 | .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 18597 | .Float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 18596 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | |
| 18597 | .float => switch (ty.childType(zcu).floatBits(self.target.*)) { | |
| 18598 | 18598 | 32 => switch (ty.vectorLen(zcu)) { |
| 18599 | 18599 | 1 => .{ .v_ss, .fmadd231 }, |
| 18600 | 18600 | 2...8 => .{ .v_ps, .fmadd231 }, |
| ... | ... | @@ -18971,7 +18971,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) *InstTracking { |
| 18971 | 18971 | /// and as a register. |
| 18972 | 18972 | fn limitImmediateType(self: *Self, operand: Air.Inst.Ref, comptime T: type) !MCValue { |
| 18973 | 18973 | const mcv = try self.resolveInst(operand); |
| 18974 | const ti = @typeInfo(T).Int; | |
| 18974 | const ti = @typeInfo(T).int; | |
| 18975 | 18975 | switch (mcv) { |
| 18976 | 18976 | .immediate => |imm| { |
| 18977 | 18977 | // This immediate is unsigned. |
| ... | ... | @@ -19078,7 +19078,7 @@ fn resolveCallingConventionValues( |
| 19078 | 19078 | } |
| 19079 | 19079 | |
| 19080 | 19080 | // Return values |
| 19081 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 19081 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 19082 | 19082 | result.return_value = InstTracking.init(.unreach); |
| 19083 | 19083 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 19084 | 19084 | // TODO: is this even possible for C calling convention? |
| ... | ... | @@ -19266,7 +19266,7 @@ fn resolveCallingConventionValues( |
| 19266 | 19266 | result.stack_align = .@"16"; |
| 19267 | 19267 | |
| 19268 | 19268 | // Return values |
| 19269 | if (ret_ty.zigTypeTag(zcu) == .NoReturn) { | |
| 19269 | if (ret_ty.zigTypeTag(zcu) == .noreturn) { | |
| 19270 | 19270 | result.return_value = InstTracking.init(.unreach); |
| 19271 | 19271 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 19272 | 19272 | result.return_value = InstTracking.init(.none); |
| ... | ... | @@ -19372,7 +19372,7 @@ fn memSize(self: *Self, ty: Type) Memory.Size { |
| 19372 | 19372 | const pt = self.pt; |
| 19373 | 19373 | const zcu = pt.zcu; |
| 19374 | 19374 | return switch (ty.zigTypeTag(zcu)) { |
| 19375 | .Float => Memory.Size.fromBitSize(ty.floatBits(self.target.*)), | |
| 19375 | .float => Memory.Size.fromBitSize(ty.floatBits(self.target.*)), | |
| 19376 | 19376 | else => Memory.Size.fromSize(@intCast(ty.abiSize(zcu))), |
| 19377 | 19377 | }; |
| 19378 | 19378 | } |
| ... | ... | @@ -19467,7 +19467,7 @@ fn regBitSize(self: *Self, ty: Type) u64 { |
| 19467 | 19467 | 5...8 => 64, |
| 19468 | 19468 | else => unreachable, |
| 19469 | 19469 | }, |
| 19470 | .Float => switch (abi_size) { | |
| 19470 | .float => switch (abi_size) { | |
| 19471 | 19471 | 1...16 => 128, |
| 19472 | 19472 | 17...32 => 256, |
| 19473 | 19473 | else => unreachable, |
src/arch/x86_64/Encoding.zig+3-3| ... | ... | @@ -845,7 +845,7 @@ fn estimateInstructionLength(prefix: Prefix, encoding: Encoding, ops: []const Op |
| 845 | 845 | |
| 846 | 846 | const mnemonic_to_encodings_map = init: { |
| 847 | 847 | @setEvalBranchQuota(5_000); |
| 848 | const mnemonic_count = @typeInfo(Mnemonic).Enum.fields.len; | |
| 848 | const mnemonic_count = @typeInfo(Mnemonic).@"enum".fields.len; | |
| 849 | 849 | var mnemonic_map: [mnemonic_count][]Data = .{&.{}} ** mnemonic_count; |
| 850 | 850 | const encodings = @import("encodings.zig"); |
| 851 | 851 | for (encodings.table) |entry| mnemonic_map[@intFromEnum(entry[0])].len += 1; |
| ... | ... | @@ -856,8 +856,8 @@ const mnemonic_to_encodings_map = init: { |
| 856 | 856 | storage_i += value.len; |
| 857 | 857 | } |
| 858 | 858 | var mnemonic_i: [mnemonic_count]usize = .{0} ** mnemonic_count; |
| 859 | const ops_len = @typeInfo(std.meta.FieldType(Data, .ops)).Array.len; | |
| 860 | const opc_len = @typeInfo(std.meta.FieldType(Data, .opc)).Array.len; | |
| 859 | const ops_len = @typeInfo(std.meta.FieldType(Data, .ops)).array.len; | |
| 860 | const opc_len = @typeInfo(std.meta.FieldType(Data, .opc)).array.len; | |
| 861 | 861 | for (encodings.table) |entry| { |
| 862 | 862 | const i = &mnemonic_i[@intFromEnum(entry[0])]; |
| 863 | 863 | mnemonic_map[@intFromEnum(entry[0])][i.*] = .{ |
src/arch/x86_64/Lower.zig+1-1| ... | ... | @@ -571,7 +571,7 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void { |
| 571 | 571 | @setEvalBranchQuota(2_000); |
| 572 | 572 | |
| 573 | 573 | comptime var max_len = 0; |
| 574 | inline for (@typeInfo(Mnemonic).Enum.fields) |field| max_len = @max(field.name.len, max_len); | |
| 574 | inline for (@typeInfo(Mnemonic).@"enum".fields) |field| max_len = @max(field.name.len, max_len); | |
| 575 | 575 | var buf: [max_len]u8 = undefined; |
| 576 | 576 | |
| 577 | 577 | const fixes_name = @tagName(fixes); |
src/arch/x86_64/Mir.zig+2-2| ... | ... | @@ -1185,8 +1185,8 @@ pub const Memory = struct { |
| 1185 | 1185 | extra: u32, |
| 1186 | 1186 | |
| 1187 | 1187 | pub const Info = packed struct(u32) { |
| 1188 | base: @typeInfo(bits.Memory.Base).Union.tag_type.?, | |
| 1189 | mod: @typeInfo(bits.Memory.Mod).Union.tag_type.?, | |
| 1188 | base: @typeInfo(bits.Memory.Base).@"union".tag_type.?, | |
| 1189 | mod: @typeInfo(bits.Memory.Mod).@"union".tag_type.?, | |
| 1190 | 1190 | size: bits.Memory.Size, |
| 1191 | 1191 | index: Register, |
| 1192 | 1192 | scale: bits.Memory.Scale, |
src/arch/x86_64/abi.zig+33-33| ... | ... | @@ -54,26 +54,26 @@ pub fn classifyWindows(ty: Type, zcu: *Zcu) Class { |
| 54 | 54 | // "Structs and unions of size 8, 16, 32, or 64 bits, and __m64 types, are passed |
| 55 | 55 | // as if they were integers of the same size." |
| 56 | 56 | switch (ty.zigTypeTag(zcu)) { |
| 57 | .Pointer, | |
| 58 | .Int, | |
| 59 | .Bool, | |
| 60 | .Enum, | |
| 61 | .Void, | |
| 62 | .NoReturn, | |
| 63 | .ErrorSet, | |
| 64 | .Struct, | |
| 65 | .Union, | |
| 66 | .Optional, | |
| 67 | .Array, | |
| 68 | .ErrorUnion, | |
| 69 | .AnyFrame, | |
| 70 | .Frame, | |
| 57 | .pointer, | |
| 58 | .int, | |
| 59 | .bool, | |
| 60 | .@"enum", | |
| 61 | .void, | |
| 62 | .noreturn, | |
| 63 | .error_set, | |
| 64 | .@"struct", | |
| 65 | .@"union", | |
| 66 | .optional, | |
| 67 | .array, | |
| 68 | .error_union, | |
| 69 | .@"anyframe", | |
| 70 | .frame, | |
| 71 | 71 | => switch (ty.abiSize(zcu)) { |
| 72 | 72 | 0 => unreachable, |
| 73 | 73 | 1, 2, 4, 8 => return .integer, |
| 74 | 74 | else => switch (ty.zigTypeTag(zcu)) { |
| 75 | .Int => return .win_i128, | |
| 76 | .Struct, .Union => if (ty.containerLayout(zcu) == .@"packed") { | |
| 75 | .int => return .win_i128, | |
| 76 | .@"struct", .@"union" => if (ty.containerLayout(zcu) == .@"packed") { | |
| 77 | 77 | return .win_i128; |
| 78 | 78 | } else { |
| 79 | 79 | return .memory; |
| ... | ... | @@ -82,16 +82,16 @@ pub fn classifyWindows(ty: Type, zcu: *Zcu) Class { |
| 82 | 82 | }, |
| 83 | 83 | }, |
| 84 | 84 | |
| 85 | .Float, .Vector => return .sse, | |
| 85 | .float, .vector => return .sse, | |
| 86 | 86 | |
| 87 | .Type, | |
| 88 | .ComptimeFloat, | |
| 89 | .ComptimeInt, | |
| 90 | .Undefined, | |
| 91 | .Null, | |
| 92 | .Fn, | |
| 93 | .Opaque, | |
| 94 | .EnumLiteral, | |
| 87 | .type, | |
| 88 | .comptime_float, | |
| 89 | .comptime_int, | |
| 90 | .undefined, | |
| 91 | .null, | |
| 92 | .@"fn", | |
| 93 | .@"opaque", | |
| 94 | .enum_literal, | |
| 95 | 95 | => unreachable, |
| 96 | 96 | } |
| 97 | 97 | } |
| ... | ... | @@ -107,7 +107,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 |
| 107 | 107 | }; |
| 108 | 108 | var result = [1]Class{.none} ** 8; |
| 109 | 109 | switch (ty.zigTypeTag(zcu)) { |
| 110 | .Pointer => switch (ty.ptrSize(zcu)) { | |
| 110 | .pointer => switch (ty.ptrSize(zcu)) { | |
| 111 | 111 | .Slice => { |
| 112 | 112 | result[0] = .integer; |
| 113 | 113 | result[1] = .integer; |
| ... | ... | @@ -118,7 +118,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 |
| 118 | 118 | return result; |
| 119 | 119 | }, |
| 120 | 120 | }, |
| 121 | .Int, .Enum, .ErrorSet => { | |
| 121 | .int, .@"enum", .error_set => { | |
| 122 | 122 | const bits = ty.intInfo(zcu).bits; |
| 123 | 123 | if (bits <= 64) { |
| 124 | 124 | result[0] = .integer; |
| ... | ... | @@ -144,11 +144,11 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 |
| 144 | 144 | } |
| 145 | 145 | return memory_class; |
| 146 | 146 | }, |
| 147 | .Bool, .Void, .NoReturn => { | |
| 147 | .bool, .void, .noreturn => { | |
| 148 | 148 | result[0] = .integer; |
| 149 | 149 | return result; |
| 150 | 150 | }, |
| 151 | .Float => switch (ty.floatBits(target)) { | |
| 151 | .float => switch (ty.floatBits(target)) { | |
| 152 | 152 | 16 => { |
| 153 | 153 | if (ctx == .field) { |
| 154 | 154 | result[0] = .memory; |
| ... | ... | @@ -184,7 +184,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 |
| 184 | 184 | }, |
| 185 | 185 | else => unreachable, |
| 186 | 186 | }, |
| 187 | .Vector => { | |
| 187 | .vector => { | |
| 188 | 188 | const elem_ty = ty.childType(zcu); |
| 189 | 189 | const bits = elem_ty.bitSize(zcu) * ty.arrayLen(zcu); |
| 190 | 190 | if (elem_ty.toIntern() == .bool_type) { |
| ... | ... | @@ -249,14 +249,14 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 |
| 249 | 249 | }; |
| 250 | 250 | return memory_class; |
| 251 | 251 | }, |
| 252 | .Optional => { | |
| 252 | .optional => { | |
| 253 | 253 | if (ty.isPtrLikeOptional(zcu)) { |
| 254 | 254 | result[0] = .integer; |
| 255 | 255 | return result; |
| 256 | 256 | } |
| 257 | 257 | return memory_class; |
| 258 | 258 | }, |
| 259 | .Struct, .Union => { | |
| 259 | .@"struct", .@"union" => { | |
| 260 | 260 | // "If the size of an object is larger than eight eightbytes, or |
| 261 | 261 | // it contains unaligned fields, it has class MEMORY" |
| 262 | 262 | // "If the size of the aggregate exceeds a single eightbyte, each is classified |
| ... | ... | @@ -305,7 +305,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 |
| 305 | 305 | } |
| 306 | 306 | return result; |
| 307 | 307 | }, |
| 308 | .Array => { | |
| 308 | .array => { | |
| 309 | 309 | const ty_size = ty.abiSize(zcu); |
| 310 | 310 | if (ty_size <= 8) { |
| 311 | 311 | result[0] = .integer; |
src/arch/x86_64/bits.zig+2-2| ... | ... | @@ -423,7 +423,7 @@ pub const FrameIndex = enum(u32) { |
| 423 | 423 | // Other indices are used for local variable stack slots |
| 424 | 424 | _, |
| 425 | 425 | |
| 426 | pub const named_count = @typeInfo(FrameIndex).Enum.fields.len; | |
| 426 | pub const named_count = @typeInfo(FrameIndex).@"enum".fields.len; | |
| 427 | 427 | |
| 428 | 428 | pub fn isNamed(fi: FrameIndex) bool { |
| 429 | 429 | return @intFromEnum(fi) < named_count; |
| ... | ... | @@ -463,7 +463,7 @@ pub const Memory = struct { |
| 463 | 463 | frame: FrameIndex, |
| 464 | 464 | reloc: u32, |
| 465 | 465 | |
| 466 | pub const Tag = @typeInfo(Base).Union.tag_type.?; | |
| 466 | pub const Tag = @typeInfo(Base).@"union".tag_type.?; | |
| 467 | 467 | |
| 468 | 468 | pub fn isExtended(self: Base) bool { |
| 469 | 469 | return switch (self) { |
src/arch/x86_64/encoder.zig+4-4| ... | ... | @@ -2262,7 +2262,7 @@ const Assembler = struct { |
| 2262 | 2262 | } |
| 2263 | 2263 | |
| 2264 | 2264 | fn mnemonicFromString(bytes: []const u8) ?Instruction.Mnemonic { |
| 2265 | const ti = @typeInfo(Instruction.Mnemonic).Enum; | |
| 2265 | const ti = @typeInfo(Instruction.Mnemonic).@"enum"; | |
| 2266 | 2266 | inline for (ti.fields) |field| { |
| 2267 | 2267 | if (std.mem.eql(u8, bytes, field.name)) { |
| 2268 | 2268 | return @field(Instruction.Mnemonic, field.name); |
| ... | ... | @@ -2278,7 +2278,7 @@ const Assembler = struct { |
| 2278 | 2278 | _ = try as.expect(.comma); |
| 2279 | 2279 | try as.skip(1, .{.space}); |
| 2280 | 2280 | } |
| 2281 | if (@typeInfo(@TypeOf(cond)) != .EnumLiteral) { | |
| 2281 | if (@typeInfo(@TypeOf(cond)) != .enum_literal) { | |
| 2282 | 2282 | @compileError("invalid condition in the rule: " ++ @typeName(@TypeOf(cond))); |
| 2283 | 2283 | } |
| 2284 | 2284 | switch (cond) { |
| ... | ... | @@ -2315,7 +2315,7 @@ const Assembler = struct { |
| 2315 | 2315 | } |
| 2316 | 2316 | |
| 2317 | 2317 | fn registerFromString(bytes: []const u8) ?Register { |
| 2318 | const ti = @typeInfo(Register).Enum; | |
| 2318 | const ti = @typeInfo(Register).@"enum"; | |
| 2319 | 2319 | inline for (ti.fields) |field| { |
| 2320 | 2320 | if (std.mem.eql(u8, bytes, field.name)) { |
| 2321 | 2321 | return @field(Register, field.name); |
| ... | ... | @@ -2405,7 +2405,7 @@ const Assembler = struct { |
| 2405 | 2405 | fn parseMemoryRule(as: *Assembler, rule: anytype) ParseError!MemoryParseResult { |
| 2406 | 2406 | var res: MemoryParseResult = .{}; |
| 2407 | 2407 | inline for (rule, 0..) |cond, i| { |
| 2408 | if (@typeInfo(@TypeOf(cond)) != .EnumLiteral) { | |
| 2408 | if (@typeInfo(@TypeOf(cond)) != .enum_literal) { | |
| 2409 | 2409 | @compileError("unsupported condition type in the rule: " ++ @typeName(@TypeOf(cond))); |
| 2410 | 2410 | } |
| 2411 | 2411 | switch (cond) { |
src/codegen.zig+25-25| ... | ... | @@ -113,8 +113,8 @@ pub fn generateLazyFunction( |
| 113 | 113 | |
| 114 | 114 | fn writeFloat(comptime F: type, f: F, target: std.Target, endian: std.builtin.Endian, code: []u8) void { |
| 115 | 115 | _ = target; |
| 116 | const bits = @typeInfo(F).Float.bits; | |
| 117 | const Int = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = bits } }); | |
| 116 | const bits = @typeInfo(F).float.bits; | |
| 117 | const Int = @Type(.{ .int = .{ .signedness = .unsigned, .bits = bits } }); | |
| 118 | 118 | const int: Int = @bitCast(f); |
| 119 | 119 | mem.writeInt(Int, code[0..@divExact(bits, 8)], int, endian); |
| 120 | 120 | } |
| ... | ... | @@ -167,7 +167,7 @@ pub fn generateLazySymbol( |
| 167 | 167 | } |
| 168 | 168 | mem.writeInt(u32, code.items[offset..][0..4], @intCast(code.items.len), endian); |
| 169 | 169 | return Result.ok; |
| 170 | } else if (Type.fromInterned(lazy_sym.ty).zigTypeTag(pt.zcu) == .Enum) { | |
| 170 | } else if (Type.fromInterned(lazy_sym.ty).zigTypeTag(pt.zcu) == .@"enum") { | |
| 171 | 171 | alignment.* = .@"1"; |
| 172 | 172 | const enum_ty = Type.fromInterned(lazy_sym.ty); |
| 173 | 173 | const tag_names = enum_ty.enumFields(pt.zcu); |
| ... | ... | @@ -519,7 +519,7 @@ pub fn generateSymbol( |
| 519 | 519 | |
| 520 | 520 | // pointer may point to a decl which must be marked used |
| 521 | 521 | // but can also result in a relocation. Therefore we handle those separately. |
| 522 | if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .Pointer) { | |
| 522 | if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .pointer) { | |
| 523 | 523 | const field_size = math.cast(usize, Type.fromInterned(field_ty).abiSize(zcu)) orelse |
| 524 | 524 | return error.Overflow; |
| 525 | 525 | var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size); |
| ... | ... | @@ -678,7 +678,7 @@ fn lowerPtr( |
| 678 | 678 | const base_ptr = Value.fromInterned(field.base); |
| 679 | 679 | const base_ty = base_ptr.typeOf(zcu).childType(zcu); |
| 680 | 680 | const field_off: u64 = switch (base_ty.zigTypeTag(zcu)) { |
| 681 | .Pointer => off: { | |
| 681 | .pointer => off: { | |
| 682 | 682 | assert(base_ty.isSlice(zcu)); |
| 683 | 683 | break :off switch (field.index) { |
| 684 | 684 | Value.slice_ptr_index => 0, |
| ... | ... | @@ -686,7 +686,7 @@ fn lowerPtr( |
| 686 | 686 | else => unreachable, |
| 687 | 687 | }; |
| 688 | 688 | }, |
| 689 | .Struct, .Union => switch (base_ty.containerLayout(zcu)) { | |
| 689 | .@"struct", .@"union" => switch (base_ty.containerLayout(zcu)) { | |
| 690 | 690 | .auto => base_ty.structFieldOffset(@intCast(field.index), zcu), |
| 691 | 691 | .@"extern", .@"packed" => unreachable, |
| 692 | 692 | }, |
| ... | ... | @@ -721,7 +721,7 @@ fn lowerUavRef( |
| 721 | 721 | const uav_val = uav.val; |
| 722 | 722 | const uav_ty = Type.fromInterned(ip.typeOf(uav_val)); |
| 723 | 723 | log.debug("lowerUavRef: ty = {}", .{uav_ty.fmt(pt)}); |
| 724 | const is_fn_body = uav_ty.zigTypeTag(zcu) == .Fn; | |
| 724 | const is_fn_body = uav_ty.zigTypeTag(zcu) == .@"fn"; | |
| 725 | 725 | if (!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) { |
| 726 | 726 | try code.appendNTimes(0xaa, ptr_width_bytes); |
| 727 | 727 | return Result.ok; |
| ... | ... | @@ -768,7 +768,7 @@ fn lowerNavRef( |
| 768 | 768 | |
| 769 | 769 | const ptr_width = target.ptrBitWidth(); |
| 770 | 770 | const nav_ty = Type.fromInterned(ip.getNav(nav_index).typeOf(ip)); |
| 771 | const is_fn_body = nav_ty.zigTypeTag(zcu) == .Fn; | |
| 771 | const is_fn_body = nav_ty.zigTypeTag(zcu) == .@"fn"; | |
| 772 | 772 | if (!is_fn_body and !nav_ty.hasRuntimeBits(zcu)) { |
| 773 | 773 | try code.appendNTimes(0xaa, @divExact(ptr_width, 8)); |
| 774 | 774 | return Result.ok; |
| ... | ... | @@ -880,7 +880,7 @@ fn genNavRef( |
| 880 | 880 | if (zcu.typeToFunc(fn_ty).?.is_generic) { |
| 881 | 881 | return .{ .mcv = .{ .immediate = fn_ty.abiAlignment(zcu).toByteUnits().? } }; |
| 882 | 882 | } |
| 883 | } else if (ty.zigTypeTag(zcu) == .Pointer) { | |
| 883 | } else if (ty.zigTypeTag(zcu) == .pointer) { | |
| 884 | 884 | const elem_ty = ty.elemType2(zcu); |
| 885 | 885 | if (!elem_ty.hasRuntimeBits(zcu)) { |
| 886 | 886 | return .{ .mcv = .{ .immediate = elem_ty.abiAlignment(zcu).toByteUnits().? } }; |
| ... | ... | @@ -955,8 +955,8 @@ pub fn genTypedValue( |
| 955 | 955 | if (val.isUndef(zcu)) return .{ .mcv = .undef }; |
| 956 | 956 | |
| 957 | 957 | switch (ty.zigTypeTag(zcu)) { |
| 958 | .Void => return .{ .mcv = .none }, | |
| 959 | .Pointer => switch (ty.ptrSize(zcu)) { | |
| 958 | .void => return .{ .mcv = .none }, | |
| 959 | .pointer => switch (ty.ptrSize(zcu)) { | |
| 960 | 960 | .Slice => {}, |
| 961 | 961 | else => switch (val.toIntern()) { |
| 962 | 962 | .null_value => { |
| ... | ... | @@ -991,7 +991,7 @@ pub fn genTypedValue( |
| 991 | 991 | }, |
| 992 | 992 | }, |
| 993 | 993 | }, |
| 994 | .Int => { | |
| 994 | .int => { | |
| 995 | 995 | const info = ty.intInfo(zcu); |
| 996 | 996 | if (info.bits <= target.ptrBitWidth()) { |
| 997 | 997 | const unsigned: u64 = switch (info.signedness) { |
| ... | ... | @@ -1001,10 +1001,10 @@ pub fn genTypedValue( |
| 1001 | 1001 | return .{ .mcv = .{ .immediate = unsigned } }; |
| 1002 | 1002 | } |
| 1003 | 1003 | }, |
| 1004 | .Bool => { | |
| 1004 | .bool => { | |
| 1005 | 1005 | return .{ .mcv = .{ .immediate = @intFromBool(val.toBool()) } }; |
| 1006 | 1006 | }, |
| 1007 | .Optional => { | |
| 1007 | .optional => { | |
| 1008 | 1008 | if (ty.isPtrLikeOptional(zcu)) { |
| 1009 | 1009 | return genTypedValue( |
| 1010 | 1010 | lf, |
| ... | ... | @@ -1017,7 +1017,7 @@ pub fn genTypedValue( |
| 1017 | 1017 | return .{ .mcv = .{ .immediate = @intFromBool(!val.isNull(zcu)) } }; |
| 1018 | 1018 | } |
| 1019 | 1019 | }, |
| 1020 | .Enum => { | |
| 1020 | .@"enum" => { | |
| 1021 | 1021 | const enum_tag = ip.indexToKey(val.toIntern()).enum_tag; |
| 1022 | 1022 | return genTypedValue( |
| 1023 | 1023 | lf, |
| ... | ... | @@ -1027,12 +1027,12 @@ pub fn genTypedValue( |
| 1027 | 1027 | target, |
| 1028 | 1028 | ); |
| 1029 | 1029 | }, |
| 1030 | .ErrorSet => { | |
| 1030 | .error_set => { | |
| 1031 | 1031 | const err_name = ip.indexToKey(val.toIntern()).err.name; |
| 1032 | 1032 | const error_index = try pt.getErrorValue(err_name); |
| 1033 | 1033 | return .{ .mcv = .{ .immediate = error_index } }; |
| 1034 | 1034 | }, |
| 1035 | .ErrorUnion => { | |
| 1035 | .error_union => { | |
| 1036 | 1036 | const err_type = ty.errorUnionSet(zcu); |
| 1037 | 1037 | const payload_type = ty.errorUnionPayload(zcu); |
| 1038 | 1038 | if (!payload_type.hasRuntimeBitsIgnoreComptime(zcu)) { |
| ... | ... | @@ -1060,14 +1060,14 @@ pub fn genTypedValue( |
| 1060 | 1060 | } |
| 1061 | 1061 | }, |
| 1062 | 1062 | |
| 1063 | .ComptimeInt => unreachable, | |
| 1064 | .ComptimeFloat => unreachable, | |
| 1065 | .Type => unreachable, | |
| 1066 | .EnumLiteral => unreachable, | |
| 1067 | .NoReturn => unreachable, | |
| 1068 | .Undefined => unreachable, | |
| 1069 | .Null => unreachable, | |
| 1070 | .Opaque => unreachable, | |
| 1063 | .comptime_int => unreachable, | |
| 1064 | .comptime_float => unreachable, | |
| 1065 | .type => unreachable, | |
| 1066 | .enum_literal => unreachable, | |
| 1067 | .noreturn => unreachable, | |
| 1068 | .undefined => unreachable, | |
| 1069 | .null => unreachable, | |
| 1070 | .@"opaque" => unreachable, | |
| 1071 | 1071 | |
| 1072 | 1072 | else => {}, |
| 1073 | 1073 | } |
src/codegen/c.zig+29-29| ... | ... | @@ -1401,7 +1401,7 @@ pub const DeclGen = struct { |
| 1401 | 1401 | try writer.writeByte('('); |
| 1402 | 1402 | try dg.renderCType(writer, ctype); |
| 1403 | 1403 | try writer.writeByte(')'); |
| 1404 | } else if (field_ty.zigTypeTag(zcu) == .Float) { | |
| 1404 | } else if (field_ty.zigTypeTag(zcu) == .float) { | |
| 1405 | 1405 | try writer.writeByte('('); |
| 1406 | 1406 | try dg.renderCType(writer, ctype); |
| 1407 | 1407 | try writer.writeByte(')'); |
| ... | ... | @@ -4473,8 +4473,8 @@ fn airCall( |
| 4473 | 4473 | |
| 4474 | 4474 | const callee_ty = f.typeOf(pl_op.operand); |
| 4475 | 4475 | const fn_info = zcu.typeToFunc(switch (callee_ty.zigTypeTag(zcu)) { |
| 4476 | .Fn => callee_ty, | |
| 4477 | .Pointer => callee_ty.childType(zcu), | |
| 4476 | .@"fn" => callee_ty, | |
| 4477 | .pointer => callee_ty.childType(zcu), | |
| 4478 | 4478 | else => unreachable, |
| 4479 | 4479 | }).?; |
| 4480 | 4480 | const ret_ty = Type.fromInterned(fn_info.return_type); |
| ... | ... | @@ -5848,7 +5848,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5848 | 5848 | const operand_ty = f.typeOf(ty_op.operand); |
| 5849 | 5849 | try reap(f, inst, &.{ty_op.operand}); |
| 5850 | 5850 | |
| 5851 | const operand_is_ptr = operand_ty.zigTypeTag(zcu) == .Pointer; | |
| 5851 | const operand_is_ptr = operand_ty.zigTypeTag(zcu) == .pointer; | |
| 5852 | 5852 | const error_union_ty = if (operand_is_ptr) operand_ty.childType(zcu) else operand_ty; |
| 5853 | 5853 | const error_ty = error_union_ty.errorUnionSet(zcu); |
| 5854 | 5854 | const payload_ty = error_union_ty.errorUnionPayload(zcu); |
| ... | ... | @@ -7011,23 +7011,23 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7011 | 7011 | .Or => if (use_operator) .{ .infix = " |= " } else .{ .builtin = .{ .operation = "or" } }, |
| 7012 | 7012 | .Xor => if (use_operator) .{ .infix = " ^= " } else .{ .builtin = .{ .operation = "xor" } }, |
| 7013 | 7013 | .Min => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7014 | .Int => if (use_operator) .{ .ternary = " < " } else .{ .builtin = .{ .operation = "min" } }, | |
| 7015 | .Float => .{ .builtin = .{ .operation = "min" } }, | |
| 7014 | .int => if (use_operator) .{ .ternary = " < " } else .{ .builtin = .{ .operation = "min" } }, | |
| 7015 | .float => .{ .builtin = .{ .operation = "min" } }, | |
| 7016 | 7016 | else => unreachable, |
| 7017 | 7017 | }, |
| 7018 | 7018 | .Max => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7019 | .Int => if (use_operator) .{ .ternary = " > " } else .{ .builtin = .{ .operation = "max" } }, | |
| 7020 | .Float => .{ .builtin = .{ .operation = "max" } }, | |
| 7019 | .int => if (use_operator) .{ .ternary = " > " } else .{ .builtin = .{ .operation = "max" } }, | |
| 7020 | .float => .{ .builtin = .{ .operation = "max" } }, | |
| 7021 | 7021 | else => unreachable, |
| 7022 | 7022 | }, |
| 7023 | 7023 | .Add => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7024 | .Int => if (use_operator) .{ .infix = " += " } else .{ .builtin = .{ .operation = "addw", .info = .bits } }, | |
| 7025 | .Float => .{ .builtin = .{ .operation = "add" } }, | |
| 7024 | .int => if (use_operator) .{ .infix = " += " } else .{ .builtin = .{ .operation = "addw", .info = .bits } }, | |
| 7025 | .float => .{ .builtin = .{ .operation = "add" } }, | |
| 7026 | 7026 | else => unreachable, |
| 7027 | 7027 | }, |
| 7028 | 7028 | .Mul => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7029 | .Int => if (use_operator) .{ .infix = " *= " } else .{ .builtin = .{ .operation = "mulw", .info = .bits } }, | |
| 7030 | .Float => .{ .builtin = .{ .operation = "mul" } }, | |
| 7029 | .int => if (use_operator) .{ .infix = " *= " } else .{ .builtin = .{ .operation = "mulw", .info = .bits } }, | |
| 7030 | .float => .{ .builtin = .{ .operation = "mul" } }, | |
| 7031 | 7031 | else => unreachable, |
| 7032 | 7032 | }, |
| 7033 | 7033 | }; |
| ... | ... | @@ -7050,38 +7050,38 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7050 | 7050 | |
| 7051 | 7051 | try f.object.dg.renderValue(writer, switch (reduce.operation) { |
| 7052 | 7052 | .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7053 | .Bool => Value.false, | |
| 7054 | .Int => try pt.intValue(scalar_ty, 0), | |
| 7053 | .bool => Value.false, | |
| 7054 | .int => try pt.intValue(scalar_ty, 0), | |
| 7055 | 7055 | else => unreachable, |
| 7056 | 7056 | }, |
| 7057 | 7057 | .And => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7058 | .Bool => Value.true, | |
| 7059 | .Int => switch (scalar_ty.intInfo(zcu).signedness) { | |
| 7058 | .bool => Value.true, | |
| 7059 | .int => switch (scalar_ty.intInfo(zcu).signedness) { | |
| 7060 | 7060 | .unsigned => try scalar_ty.maxIntScalar(pt, scalar_ty), |
| 7061 | 7061 | .signed => try pt.intValue(scalar_ty, -1), |
| 7062 | 7062 | }, |
| 7063 | 7063 | else => unreachable, |
| 7064 | 7064 | }, |
| 7065 | 7065 | .Add => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7066 | .Int => try pt.intValue(scalar_ty, 0), | |
| 7067 | .Float => try pt.floatValue(scalar_ty, 0.0), | |
| 7066 | .int => try pt.intValue(scalar_ty, 0), | |
| 7067 | .float => try pt.floatValue(scalar_ty, 0.0), | |
| 7068 | 7068 | else => unreachable, |
| 7069 | 7069 | }, |
| 7070 | 7070 | .Mul => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7071 | .Int => try pt.intValue(scalar_ty, 1), | |
| 7072 | .Float => try pt.floatValue(scalar_ty, 1.0), | |
| 7071 | .int => try pt.intValue(scalar_ty, 1), | |
| 7072 | .float => try pt.floatValue(scalar_ty, 1.0), | |
| 7073 | 7073 | else => unreachable, |
| 7074 | 7074 | }, |
| 7075 | 7075 | .Min => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7076 | .Bool => Value.true, | |
| 7077 | .Int => try scalar_ty.maxIntScalar(pt, scalar_ty), | |
| 7078 | .Float => try pt.floatValue(scalar_ty, std.math.nan(f128)), | |
| 7076 | .bool => Value.true, | |
| 7077 | .int => try scalar_ty.maxIntScalar(pt, scalar_ty), | |
| 7078 | .float => try pt.floatValue(scalar_ty, std.math.nan(f128)), | |
| 7079 | 7079 | else => unreachable, |
| 7080 | 7080 | }, |
| 7081 | 7081 | .Max => switch (scalar_ty.zigTypeTag(zcu)) { |
| 7082 | .Bool => Value.false, | |
| 7083 | .Int => try scalar_ty.minIntScalar(pt, scalar_ty), | |
| 7084 | .Float => try pt.floatValue(scalar_ty, std.math.nan(f128)), | |
| 7082 | .bool => Value.false, | |
| 7083 | .int => try scalar_ty.minIntScalar(pt, scalar_ty), | |
| 7084 | .float => try pt.floatValue(scalar_ty, std.math.nan(f128)), | |
| 7085 | 7085 | else => unreachable, |
| 7086 | 7086 | }, |
| 7087 | 7087 | }, .Initializer); |
| ... | ... | @@ -7765,7 +7765,7 @@ fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Formatter(formatStri |
| 7765 | 7765 | } |
| 7766 | 7766 | |
| 7767 | 7767 | fn undefPattern(comptime IntType: type) IntType { |
| 7768 | const int_info = @typeInfo(IntType).Int; | |
| 7768 | const int_info = @typeInfo(IntType).int; | |
| 7769 | 7769 | const UnsignedType = std.meta.Int(.unsigned, int_info.bits); |
| 7770 | 7770 | return @as(IntType, @bitCast(@as(UnsignedType, (1 << (int_info.bits | 1)) / 3))); |
| 7771 | 7771 | } |
| ... | ... | @@ -8027,7 +8027,7 @@ const Vectorize = struct { |
| 8027 | 8027 | pub fn start(f: *Function, inst: Air.Inst.Index, writer: anytype, ty: Type) !Vectorize { |
| 8028 | 8028 | const pt = f.object.dg.pt; |
| 8029 | 8029 | const zcu = pt.zcu; |
| 8030 | return if (ty.zigTypeTag(zcu) == .Vector) index: { | |
| 8030 | return if (ty.zigTypeTag(zcu) == .vector) index: { | |
| 8031 | 8031 | const local = try f.allocLocal(inst, Type.usize); |
| 8032 | 8032 | |
| 8033 | 8033 | try writer.writeAll("for ("); |
| ... | ... | @@ -8063,7 +8063,7 @@ const Vectorize = struct { |
| 8063 | 8063 | fn lowersToArray(ty: Type, pt: Zcu.PerThread) bool { |
| 8064 | 8064 | const zcu = pt.zcu; |
| 8065 | 8065 | return switch (ty.zigTypeTag(zcu)) { |
| 8066 | .Array, .Vector => return true, | |
| 8066 | .array, .vector => return true, | |
| 8067 | 8067 | else => return ty.isAbiInt(zcu) and toCIntBits(@as(u32, @intCast(ty.bitSize(zcu)))) == null, |
| 8068 | 8068 | }; |
| 8069 | 8069 | } |
src/codegen/c/Type.zig+25-25| ... | ... | @@ -669,7 +669,7 @@ const Index = enum(u32) { |
| 669 | 669 | |
| 670 | 670 | _, |
| 671 | 671 | |
| 672 | const first_pool_index: u32 = @typeInfo(CType.Index).Enum.fields.len; | |
| 672 | const first_pool_index: u32 = @typeInfo(CType.Index).@"enum".fields.len; | |
| 673 | 673 | const basic_hashes = init: { |
| 674 | 674 | @setEvalBranchQuota(1_600); |
| 675 | 675 | var basic_hashes_init: [first_pool_index]Pool.Map.Hash = undefined; |
| ... | ... | @@ -740,7 +740,7 @@ pub const Info = union(enum) { |
| 740 | 740 | aggregate: Aggregate, |
| 741 | 741 | function: Function, |
| 742 | 742 | |
| 743 | const Tag = @typeInfo(Info).Union.tag_type.?; | |
| 743 | const Tag = @typeInfo(Info).@"union".tag_type.?; | |
| 744 | 744 | |
| 745 | 745 | pub const Pointer = struct { |
| 746 | 746 | elem_ctype: CType, |
| ... | ... | @@ -783,7 +783,7 @@ pub const Info = union(enum) { |
| 783 | 783 | pub fn at(slice: Field.Slice, index: usize, pool: *const Pool) Field { |
| 784 | 784 | assert(index < slice.len); |
| 785 | 785 | const extra = pool.getExtra(Pool.Field, @intCast(slice.extra_index + |
| 786 | index * @typeInfo(Pool.Field).Struct.fields.len)); | |
| 786 | index * @typeInfo(Pool.Field).@"struct".fields.len)); | |
| 787 | 787 | return .{ |
| 788 | 788 | .name = .{ .index = extra.name }, |
| 789 | 789 | .ctype = .{ .index = extra.ctype }, |
| ... | ... | @@ -991,7 +991,7 @@ pub const Pool = struct { |
| 991 | 991 | _, |
| 992 | 992 | |
| 993 | 993 | const first_named_index: u32 = 1 << 31; |
| 994 | const first_pool_index: u32 = first_named_index + @typeInfo(String.Index).Enum.fields.len; | |
| 994 | const first_pool_index: u32 = first_named_index + @typeInfo(String.Index).@"enum".fields.len; | |
| 995 | 995 | }; |
| 996 | 996 | |
| 997 | 997 | const Adapter = struct { |
| ... | ... | @@ -1127,7 +1127,7 @@ pub const Pool = struct { |
| 1127 | 1127 | allocator, |
| 1128 | 1128 | FwdDeclAnon, |
| 1129 | 1129 | extra, |
| 1130 | fields.len * @typeInfo(Field).Struct.fields.len, | |
| 1130 | fields.len * @typeInfo(Field).@"struct".fields.len, | |
| 1131 | 1131 | ); |
| 1132 | 1132 | for (fields, field_ctypes) |field, field_ctype| pool.addHashedExtraAssumeCapacity( |
| 1133 | 1133 | &hasher, |
| ... | ... | @@ -1184,7 +1184,7 @@ pub const Pool = struct { |
| 1184 | 1184 | allocator, |
| 1185 | 1185 | AggregateAnon, |
| 1186 | 1186 | extra, |
| 1187 | aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len, | |
| 1187 | aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len, | |
| 1188 | 1188 | ); |
| 1189 | 1189 | for (aggregate_info.fields) |field| pool.addHashedExtraAssumeCapacity(&hasher, Field, .{ |
| 1190 | 1190 | .name = field.name.index, |
| ... | ... | @@ -1213,7 +1213,7 @@ pub const Pool = struct { |
| 1213 | 1213 | allocator, |
| 1214 | 1214 | Aggregate, |
| 1215 | 1215 | extra, |
| 1216 | aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len, | |
| 1216 | aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len, | |
| 1217 | 1217 | ); |
| 1218 | 1218 | for (aggregate_info.fields) |field| pool.addHashedExtraAssumeCapacity(&hasher, Field, .{ |
| 1219 | 1219 | .name = field.name.index, |
| ... | ... | @@ -1672,7 +1672,7 @@ pub const Pool = struct { |
| 1672 | 1672 | defer scratch.shrinkRetainingCapacity(scratch_top); |
| 1673 | 1673 | try scratch.ensureUnusedCapacity( |
| 1674 | 1674 | allocator, |
| 1675 | loaded_struct.field_types.len * @typeInfo(Field).Struct.fields.len, | |
| 1675 | loaded_struct.field_types.len * @typeInfo(Field).@"struct".fields.len, | |
| 1676 | 1676 | ); |
| 1677 | 1677 | var hasher = Hasher.init; |
| 1678 | 1678 | var tag: Pool.Tag = .aggregate_struct; |
| ... | ... | @@ -1709,14 +1709,14 @@ pub const Pool = struct { |
| 1709 | 1709 | } |
| 1710 | 1710 | const fields_len: u32 = @intCast(@divExact( |
| 1711 | 1711 | scratch.items.len - scratch_top, |
| 1712 | @typeInfo(Field).Struct.fields.len, | |
| 1712 | @typeInfo(Field).@"struct".fields.len, | |
| 1713 | 1713 | )); |
| 1714 | 1714 | if (fields_len == 0) return CType.void; |
| 1715 | 1715 | try pool.ensureUnusedCapacity(allocator, 1); |
| 1716 | 1716 | const extra_index = try pool.addHashedExtra(allocator, &hasher, Aggregate, .{ |
| 1717 | 1717 | .fwd_decl = fwd_decl.index, |
| 1718 | 1718 | .fields_len = fields_len, |
| 1719 | }, fields_len * @typeInfo(Field).Struct.fields.len); | |
| 1719 | }, fields_len * @typeInfo(Field).@"struct".fields.len); | |
| 1720 | 1720 | pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]); |
| 1721 | 1721 | return pool.tagTrailingExtraAssumeCapacity(hasher, tag, extra_index); |
| 1722 | 1722 | }, |
| ... | ... | @@ -1734,7 +1734,7 @@ pub const Pool = struct { |
| 1734 | 1734 | const scratch_top = scratch.items.len; |
| 1735 | 1735 | defer scratch.shrinkRetainingCapacity(scratch_top); |
| 1736 | 1736 | try scratch.ensureUnusedCapacity(allocator, anon_struct_info.types.len * |
| 1737 | @typeInfo(Field).Struct.fields.len); | |
| 1737 | @typeInfo(Field).@"struct".fields.len); | |
| 1738 | 1738 | var hasher = Hasher.init; |
| 1739 | 1739 | for (0..anon_struct_info.types.len) |field_index| { |
| 1740 | 1740 | if (anon_struct_info.values.get(ip)[field_index] != .none) continue; |
| ... | ... | @@ -1765,7 +1765,7 @@ pub const Pool = struct { |
| 1765 | 1765 | } |
| 1766 | 1766 | const fields_len: u32 = @intCast(@divExact( |
| 1767 | 1767 | scratch.items.len - scratch_top, |
| 1768 | @typeInfo(Field).Struct.fields.len, | |
| 1768 | @typeInfo(Field).@"struct".fields.len, | |
| 1769 | 1769 | )); |
| 1770 | 1770 | if (fields_len == 0) return CType.void; |
| 1771 | 1771 | if (kind.isForward()) { |
| ... | ... | @@ -1775,7 +1775,7 @@ pub const Pool = struct { |
| 1775 | 1775 | &hasher, |
| 1776 | 1776 | FwdDeclAnon, |
| 1777 | 1777 | .{ .fields_len = fields_len }, |
| 1778 | fields_len * @typeInfo(Field).Struct.fields.len, | |
| 1778 | fields_len * @typeInfo(Field).@"struct".fields.len, | |
| 1779 | 1779 | ); |
| 1780 | 1780 | pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]); |
| 1781 | 1781 | return pool.tagTrailingExtra( |
| ... | ... | @@ -1790,7 +1790,7 @@ pub const Pool = struct { |
| 1790 | 1790 | const extra_index = try pool.addHashedExtra(allocator, &hasher, Aggregate, .{ |
| 1791 | 1791 | .fwd_decl = fwd_decl.index, |
| 1792 | 1792 | .fields_len = fields_len, |
| 1793 | }, fields_len * @typeInfo(Field).Struct.fields.len); | |
| 1793 | }, fields_len * @typeInfo(Field).@"struct".fields.len); | |
| 1794 | 1794 | pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]); |
| 1795 | 1795 | return pool.tagTrailingExtraAssumeCapacity(hasher, .aggregate_struct, extra_index); |
| 1796 | 1796 | }, |
| ... | ... | @@ -1812,7 +1812,7 @@ pub const Pool = struct { |
| 1812 | 1812 | defer scratch.shrinkRetainingCapacity(scratch_top); |
| 1813 | 1813 | try scratch.ensureUnusedCapacity( |
| 1814 | 1814 | allocator, |
| 1815 | loaded_union.field_types.len * @typeInfo(Field).Struct.fields.len, | |
| 1815 | loaded_union.field_types.len * @typeInfo(Field).@"struct".fields.len, | |
| 1816 | 1816 | ); |
| 1817 | 1817 | var hasher = Hasher.init; |
| 1818 | 1818 | var tag: Pool.Tag = .aggregate_union; |
| ... | ... | @@ -1850,7 +1850,7 @@ pub const Pool = struct { |
| 1850 | 1850 | } |
| 1851 | 1851 | const fields_len: u32 = @intCast(@divExact( |
| 1852 | 1852 | scratch.items.len - scratch_top, |
| 1853 | @typeInfo(Field).Struct.fields.len, | |
| 1853 | @typeInfo(Field).@"struct".fields.len, | |
| 1854 | 1854 | )); |
| 1855 | 1855 | if (!has_tag) { |
| 1856 | 1856 | if (fields_len == 0) return CType.void; |
| ... | ... | @@ -1860,7 +1860,7 @@ pub const Pool = struct { |
| 1860 | 1860 | &hasher, |
| 1861 | 1861 | Aggregate, |
| 1862 | 1862 | .{ .fwd_decl = fwd_decl.index, .fields_len = fields_len }, |
| 1863 | fields_len * @typeInfo(Field).Struct.fields.len, | |
| 1863 | fields_len * @typeInfo(Field).@"struct".fields.len, | |
| 1864 | 1864 | ); |
| 1865 | 1865 | pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]); |
| 1866 | 1866 | return pool.tagTrailingExtraAssumeCapacity(hasher, tag, extra_index); |
| ... | ... | @@ -1898,7 +1898,7 @@ pub const Pool = struct { |
| 1898 | 1898 | .id = 0, |
| 1899 | 1899 | .fields_len = fields_len, |
| 1900 | 1900 | }, |
| 1901 | fields_len * @typeInfo(Field).Struct.fields.len, | |
| 1901 | fields_len * @typeInfo(Field).@"struct".fields.len, | |
| 1902 | 1902 | ); |
| 1903 | 1903 | pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]); |
| 1904 | 1904 | break :payload_ctype pool.tagTrailingExtraAssumeCapacity( |
| ... | ... | @@ -2087,7 +2087,7 @@ pub const Pool = struct { |
| 2087 | 2087 | .tag = tag, |
| 2088 | 2088 | .data = try pool.addExtra(allocator, FwdDeclAnon, .{ |
| 2089 | 2089 | .fields_len = fields.len, |
| 2090 | }, fields.len * @typeInfo(Field).Struct.fields.len), | |
| 2090 | }, fields.len * @typeInfo(Field).@"struct".fields.len), | |
| 2091 | 2091 | }); |
| 2092 | 2092 | for (0..fields.len) |field_index| { |
| 2093 | 2093 | const field = fields.at(field_index, source_pool); |
| ... | ... | @@ -2115,11 +2115,11 @@ pub const Pool = struct { |
| 2115 | 2115 | .index = anon.index, |
| 2116 | 2116 | .id = anon.id, |
| 2117 | 2117 | .fields_len = aggregate_info.fields.len, |
| 2118 | }, aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len), | |
| 2118 | }, aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len), | |
| 2119 | 2119 | .fwd_decl => |fwd_decl| try pool.addExtra(allocator, Aggregate, .{ |
| 2120 | 2120 | .fwd_decl = pool_adapter.copy(fwd_decl).index, |
| 2121 | 2121 | .fields_len = aggregate_info.fields.len, |
| 2122 | }, aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len), | |
| 2122 | }, aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len), | |
| 2123 | 2123 | }, |
| 2124 | 2124 | }); |
| 2125 | 2125 | for (0..aggregate_info.fields.len) |field_index| { |
| ... | ... | @@ -2182,7 +2182,7 @@ pub const Pool = struct { |
| 2182 | 2182 | const init: Hasher = .{ .impl = Impl.init(0) }; |
| 2183 | 2183 | |
| 2184 | 2184 | fn updateExtra(hasher: *Hasher, comptime Extra: type, extra: Extra, pool: *const Pool) void { |
| 2185 | inline for (@typeInfo(Extra).Struct.fields) |field| { | |
| 2185 | inline for (@typeInfo(Extra).@"struct".fields) |field| { | |
| 2186 | 2186 | const value = @field(extra, field.name); |
| 2187 | 2187 | switch (field.type) { |
| 2188 | 2188 | Pool.Tag, String, CType => unreachable, |
| ... | ... | @@ -2429,7 +2429,7 @@ pub const Pool = struct { |
| 2429 | 2429 | ) !ExtraIndex { |
| 2430 | 2430 | try pool.extra.ensureUnusedCapacity( |
| 2431 | 2431 | allocator, |
| 2432 | @typeInfo(Extra).Struct.fields.len + trailing_len, | |
| 2432 | @typeInfo(Extra).@"struct".fields.len + trailing_len, | |
| 2433 | 2433 | ); |
| 2434 | 2434 | defer pool.addExtraAssumeCapacity(Extra, extra); |
| 2435 | 2435 | return @intCast(pool.extra.items.len); |
| ... | ... | @@ -2442,7 +2442,7 @@ pub const Pool = struct { |
| 2442 | 2442 | comptime Extra: type, |
| 2443 | 2443 | extra: Extra, |
| 2444 | 2444 | ) void { |
| 2445 | inline for (@typeInfo(Extra).Struct.fields) |field| { | |
| 2445 | inline for (@typeInfo(Extra).@"struct".fields) |field| { | |
| 2446 | 2446 | const value = @field(extra, field.name); |
| 2447 | 2447 | array.appendAssumeCapacity(switch (field.type) { |
| 2448 | 2448 | u32 => value, |
| ... | ... | @@ -2505,7 +2505,7 @@ pub const Pool = struct { |
| 2505 | 2505 | extra_index: ExtraIndex, |
| 2506 | 2506 | ) struct { extra: Extra, trail: ExtraTrail } { |
| 2507 | 2507 | var extra: Extra = undefined; |
| 2508 | const fields = @typeInfo(Extra).Struct.fields; | |
| 2508 | const fields = @typeInfo(Extra).@"struct".fields; | |
| 2509 | 2509 | inline for (fields, pool.extra.items[extra_index..][0..fields.len]) |field, value| |
| 2510 | 2510 | @field(extra, field.name) = switch (field.type) { |
| 2511 | 2511 | u32 => value, |
src/codegen/llvm.zig+113-113| ... | ... | @@ -1538,7 +1538,7 @@ pub const Object = struct { |
| 1538 | 1538 | try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder); |
| 1539 | 1539 | } |
| 1540 | 1540 | } |
| 1541 | if (param_ty.zigTypeTag(zcu) != .Optional) { | |
| 1541 | if (param_ty.zigTypeTag(zcu) != .optional) { | |
| 1542 | 1542 | try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder); |
| 1543 | 1543 | } |
| 1544 | 1544 | if (ptr_info.flags.is_const) { |
| ... | ... | @@ -1907,8 +1907,8 @@ pub const Object = struct { |
| 1907 | 1907 | if (o.debug_type_map.get(ty)) |debug_type| return debug_type; |
| 1908 | 1908 | |
| 1909 | 1909 | switch (ty.zigTypeTag(zcu)) { |
| 1910 | .Void, | |
| 1911 | .NoReturn, | |
| 1910 | .void, | |
| 1911 | .noreturn, | |
| 1912 | 1912 | => { |
| 1913 | 1913 | const debug_void_type = try o.builder.debugSignedType( |
| 1914 | 1914 | try o.builder.metadataString("void"), |
| ... | ... | @@ -1917,7 +1917,7 @@ pub const Object = struct { |
| 1917 | 1917 | try o.debug_type_map.put(gpa, ty, debug_void_type); |
| 1918 | 1918 | return debug_void_type; |
| 1919 | 1919 | }, |
| 1920 | .Int => { | |
| 1920 | .int => { | |
| 1921 | 1921 | const info = ty.intInfo(zcu); |
| 1922 | 1922 | assert(info.bits != 0); |
| 1923 | 1923 | const name = try o.allocTypeName(ty); |
| ... | ... | @@ -1931,7 +1931,7 @@ pub const Object = struct { |
| 1931 | 1931 | try o.debug_type_map.put(gpa, ty, debug_int_type); |
| 1932 | 1932 | return debug_int_type; |
| 1933 | 1933 | }, |
| 1934 | .Enum => { | |
| 1934 | .@"enum" => { | |
| 1935 | 1935 | if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 1936 | 1936 | const debug_enum_type = try o.makeEmptyNamespaceDebugType(ty); |
| 1937 | 1937 | try o.debug_type_map.put(gpa, ty, debug_enum_type); |
| ... | ... | @@ -1985,7 +1985,7 @@ pub const Object = struct { |
| 1985 | 1985 | try o.debug_enums.append(gpa, debug_enum_type); |
| 1986 | 1986 | return debug_enum_type; |
| 1987 | 1987 | }, |
| 1988 | .Float => { | |
| 1988 | .float => { | |
| 1989 | 1989 | const bits = ty.floatBits(target); |
| 1990 | 1990 | const name = try o.allocTypeName(ty); |
| 1991 | 1991 | defer gpa.free(name); |
| ... | ... | @@ -1996,7 +1996,7 @@ pub const Object = struct { |
| 1996 | 1996 | try o.debug_type_map.put(gpa, ty, debug_float_type); |
| 1997 | 1997 | return debug_float_type; |
| 1998 | 1998 | }, |
| 1999 | .Bool => { | |
| 1999 | .bool => { | |
| 2000 | 2000 | const debug_bool_type = try o.builder.debugBoolType( |
| 2001 | 2001 | try o.builder.metadataString("bool"), |
| 2002 | 2002 | 8, // lldb cannot handle non-byte sized types |
| ... | ... | @@ -2004,7 +2004,7 @@ pub const Object = struct { |
| 2004 | 2004 | try o.debug_type_map.put(gpa, ty, debug_bool_type); |
| 2005 | 2005 | return debug_bool_type; |
| 2006 | 2006 | }, |
| 2007 | .Pointer => { | |
| 2007 | .pointer => { | |
| 2008 | 2008 | // Normalize everything that the debug info does not represent. |
| 2009 | 2009 | const ptr_info = ty.ptrInfo(zcu); |
| 2010 | 2010 | |
| ... | ... | @@ -2126,7 +2126,7 @@ pub const Object = struct { |
| 2126 | 2126 | |
| 2127 | 2127 | return debug_ptr_type; |
| 2128 | 2128 | }, |
| 2129 | .Opaque => { | |
| 2129 | .@"opaque" => { | |
| 2130 | 2130 | if (ty.toIntern() == .anyopaque_type) { |
| 2131 | 2131 | const debug_opaque_type = try o.builder.debugSignedType( |
| 2132 | 2132 | try o.builder.metadataString("anyopaque"), |
| ... | ... | @@ -2158,7 +2158,7 @@ pub const Object = struct { |
| 2158 | 2158 | try o.debug_type_map.put(gpa, ty, debug_opaque_type); |
| 2159 | 2159 | return debug_opaque_type; |
| 2160 | 2160 | }, |
| 2161 | .Array => { | |
| 2161 | .array => { | |
| 2162 | 2162 | const debug_array_type = try o.builder.debugArrayType( |
| 2163 | 2163 | .none, // Name |
| 2164 | 2164 | .none, // File |
| ... | ... | @@ -2177,14 +2177,14 @@ pub const Object = struct { |
| 2177 | 2177 | try o.debug_type_map.put(gpa, ty, debug_array_type); |
| 2178 | 2178 | return debug_array_type; |
| 2179 | 2179 | }, |
| 2180 | .Vector => { | |
| 2180 | .vector => { | |
| 2181 | 2181 | const elem_ty = ty.elemType2(zcu); |
| 2182 | 2182 | // Vector elements cannot be padded since that would make |
| 2183 | 2183 | // @bitSizOf(elem) * len > @bitSizOf(vec). |
| 2184 | 2184 | // Neither gdb nor lldb seem to be able to display non-byte sized |
| 2185 | 2185 | // vectors properly. |
| 2186 | 2186 | const debug_elem_type = switch (elem_ty.zigTypeTag(zcu)) { |
| 2187 | .Int => blk: { | |
| 2187 | .int => blk: { | |
| 2188 | 2188 | const info = elem_ty.intInfo(zcu); |
| 2189 | 2189 | assert(info.bits != 0); |
| 2190 | 2190 | const name = try o.allocTypeName(ty); |
| ... | ... | @@ -2195,7 +2195,7 @@ pub const Object = struct { |
| 2195 | 2195 | .unsigned => try o.builder.debugUnsignedType(builder_name, info.bits), |
| 2196 | 2196 | }; |
| 2197 | 2197 | }, |
| 2198 | .Bool => try o.builder.debugBoolType( | |
| 2198 | .bool => try o.builder.debugBoolType( | |
| 2199 | 2199 | try o.builder.metadataString("bool"), |
| 2200 | 2200 | 1, |
| 2201 | 2201 | ), |
| ... | ... | @@ -2221,7 +2221,7 @@ pub const Object = struct { |
| 2221 | 2221 | try o.debug_type_map.put(gpa, ty, debug_vector_type); |
| 2222 | 2222 | return debug_vector_type; |
| 2223 | 2223 | }, |
| 2224 | .Optional => { | |
| 2224 | .optional => { | |
| 2225 | 2225 | const name = try o.allocTypeName(ty); |
| 2226 | 2226 | defer gpa.free(name); |
| 2227 | 2227 | const child_ty = ty.optionalChild(zcu); |
| ... | ... | @@ -2302,7 +2302,7 @@ pub const Object = struct { |
| 2302 | 2302 | |
| 2303 | 2303 | return debug_optional_type; |
| 2304 | 2304 | }, |
| 2305 | .ErrorUnion => { | |
| 2305 | .error_union => { | |
| 2306 | 2306 | const payload_ty = ty.errorUnionPayload(zcu); |
| 2307 | 2307 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 2308 | 2308 | // TODO: Maybe remove? |
| ... | ... | @@ -2375,7 +2375,7 @@ pub const Object = struct { |
| 2375 | 2375 | try o.debug_type_map.put(gpa, ty, debug_error_union_type); |
| 2376 | 2376 | return debug_error_union_type; |
| 2377 | 2377 | }, |
| 2378 | .ErrorSet => { | |
| 2378 | .error_set => { | |
| 2379 | 2379 | const debug_error_set = try o.builder.debugUnsignedType( |
| 2380 | 2380 | try o.builder.metadataString("anyerror"), |
| 2381 | 2381 | 16, |
| ... | ... | @@ -2383,7 +2383,7 @@ pub const Object = struct { |
| 2383 | 2383 | try o.debug_type_map.put(gpa, ty, debug_error_set); |
| 2384 | 2384 | return debug_error_set; |
| 2385 | 2385 | }, |
| 2386 | .Struct => { | |
| 2386 | .@"struct" => { | |
| 2387 | 2387 | const name = try o.allocTypeName(ty); |
| 2388 | 2388 | defer gpa.free(name); |
| 2389 | 2389 | |
| ... | ... | @@ -2531,7 +2531,7 @@ pub const Object = struct { |
| 2531 | 2531 | |
| 2532 | 2532 | return debug_struct_type; |
| 2533 | 2533 | }, |
| 2534 | .Union => { | |
| 2534 | .@"union" => { | |
| 2535 | 2535 | const name = try o.allocTypeName(ty); |
| 2536 | 2536 | defer gpa.free(name); |
| 2537 | 2537 | |
| ... | ... | @@ -2693,7 +2693,7 @@ pub const Object = struct { |
| 2693 | 2693 | |
| 2694 | 2694 | return debug_tagged_union_type; |
| 2695 | 2695 | }, |
| 2696 | .Fn => { | |
| 2696 | .@"fn" => { | |
| 2697 | 2697 | const fn_info = zcu.typeToFunc(ty).?; |
| 2698 | 2698 | |
| 2699 | 2699 | var debug_param_types = std.ArrayList(Builder.Metadata).init(gpa); |
| ... | ... | @@ -2741,15 +2741,15 @@ pub const Object = struct { |
| 2741 | 2741 | try o.debug_type_map.put(gpa, ty, debug_function_type); |
| 2742 | 2742 | return debug_function_type; |
| 2743 | 2743 | }, |
| 2744 | .ComptimeInt => unreachable, | |
| 2745 | .ComptimeFloat => unreachable, | |
| 2746 | .Type => unreachable, | |
| 2747 | .Undefined => unreachable, | |
| 2748 | .Null => unreachable, | |
| 2749 | .EnumLiteral => unreachable, | |
| 2744 | .comptime_int => unreachable, | |
| 2745 | .comptime_float => unreachable, | |
| 2746 | .type => unreachable, | |
| 2747 | .undefined => unreachable, | |
| 2748 | .null => unreachable, | |
| 2749 | .enum_literal => unreachable, | |
| 2750 | 2750 | |
| 2751 | .Frame => @panic("TODO implement lowerDebugType for Frame types"), | |
| 2752 | .AnyFrame => @panic("TODO implement lowerDebugType for AnyFrame types"), | |
| 2751 | .frame => @panic("TODO implement lowerDebugType for Frame types"), | |
| 2752 | .@"anyframe" => @panic("TODO implement lowerDebugType for AnyFrame types"), | |
| 2753 | 2753 | } |
| 2754 | 2754 | } |
| 2755 | 2755 | |
| ... | ... | @@ -3539,9 +3539,9 @@ pub const Object = struct { |
| 3539 | 3539 | const pt = o.pt; |
| 3540 | 3540 | const zcu = pt.zcu; |
| 3541 | 3541 | const lower_elem_ty = switch (elem_ty.zigTypeTag(zcu)) { |
| 3542 | .Opaque => true, | |
| 3543 | .Fn => !zcu.typeToFunc(elem_ty).?.is_generic, | |
| 3544 | .Array => elem_ty.childType(zcu).hasRuntimeBitsIgnoreComptime(zcu), | |
| 3542 | .@"opaque" => true, | |
| 3543 | .@"fn" => !zcu.typeToFunc(elem_ty).?.is_generic, | |
| 3544 | .array => elem_ty.childType(zcu).hasRuntimeBitsIgnoreComptime(zcu), | |
| 3545 | 3545 | else => elem_ty.hasRuntimeBitsIgnoreComptime(zcu), |
| 3546 | 3546 | }; |
| 3547 | 3547 | return if (lower_elem_ty) try o.lowerType(elem_ty) else .i8; |
| ... | ... | @@ -3883,7 +3883,7 @@ pub const Object = struct { |
| 3883 | 3883 | }, |
| 3884 | 3884 | else => |payload| try o.lowerValue(payload), |
| 3885 | 3885 | }; |
| 3886 | assert(payload_ty.zigTypeTag(zcu) != .Fn); | |
| 3886 | assert(payload_ty.zigTypeTag(zcu) != .@"fn"); | |
| 3887 | 3887 | |
| 3888 | 3888 | var fields: [3]Builder.Type = undefined; |
| 3889 | 3889 | var vals: [3]Builder.Constant = undefined; |
| ... | ... | @@ -4303,7 +4303,7 @@ pub const Object = struct { |
| 4303 | 4303 | .field => |field| { |
| 4304 | 4304 | const agg_ty = Value.fromInterned(field.base).typeOf(zcu).childType(zcu); |
| 4305 | 4305 | const field_off: u64 = switch (agg_ty.zigTypeTag(zcu)) { |
| 4306 | .Pointer => off: { | |
| 4306 | .pointer => off: { | |
| 4307 | 4307 | assert(agg_ty.isSlice(zcu)); |
| 4308 | 4308 | break :off switch (field.index) { |
| 4309 | 4309 | Value.slice_ptr_index => 0, |
| ... | ... | @@ -4311,7 +4311,7 @@ pub const Object = struct { |
| 4311 | 4311 | else => unreachable, |
| 4312 | 4312 | }; |
| 4313 | 4313 | }, |
| 4314 | .Struct, .Union => switch (agg_ty.containerLayout(zcu)) { | |
| 4314 | .@"struct", .@"union" => switch (agg_ty.containerLayout(zcu)) { | |
| 4315 | 4315 | .auto => agg_ty.structFieldOffset(@intCast(field.index), zcu), |
| 4316 | 4316 | .@"extern", .@"packed" => unreachable, |
| 4317 | 4317 | }, |
| ... | ... | @@ -4344,7 +4344,7 @@ pub const Object = struct { |
| 4344 | 4344 | |
| 4345 | 4345 | const ptr_ty = Type.fromInterned(uav.orig_ty); |
| 4346 | 4346 | |
| 4347 | const is_fn_body = uav_ty.zigTypeTag(zcu) == .Fn; | |
| 4347 | const is_fn_body = uav_ty.zigTypeTag(zcu) == .@"fn"; | |
| 4348 | 4348 | if ((!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) or |
| 4349 | 4349 | (is_fn_body and zcu.typeToFunc(uav_ty).?.is_generic)) return o.lowerPtrToVoid(ptr_ty); |
| 4350 | 4350 | |
| ... | ... | @@ -4383,7 +4383,7 @@ pub const Object = struct { |
| 4383 | 4383 | const nav_ty = Type.fromInterned(owner_nav.typeOf(ip)); |
| 4384 | 4384 | const ptr_ty = try pt.navPtrType(owner_nav_index); |
| 4385 | 4385 | |
| 4386 | const is_fn_body = nav_ty.zigTypeTag(zcu) == .Fn; | |
| 4386 | const is_fn_body = nav_ty.zigTypeTag(zcu) == .@"fn"; | |
| 4387 | 4387 | if ((!is_fn_body and !nav_ty.hasRuntimeBits(zcu)) or |
| 4388 | 4388 | (is_fn_body and zcu.typeToFunc(nav_ty).?.is_generic)) |
| 4389 | 4389 | { |
| ... | ... | @@ -4435,13 +4435,13 @@ pub const Object = struct { |
| 4435 | 4435 | const pt = o.pt; |
| 4436 | 4436 | const zcu = pt.zcu; |
| 4437 | 4437 | const int_ty = switch (ty.zigTypeTag(zcu)) { |
| 4438 | .Int => ty, | |
| 4439 | .Enum => ty.intTagType(zcu), | |
| 4440 | .Float => { | |
| 4438 | .int => ty, | |
| 4439 | .@"enum" => ty.intTagType(zcu), | |
| 4440 | .float => { | |
| 4441 | 4441 | if (!is_rmw_xchg) return .none; |
| 4442 | 4442 | return o.builder.intType(@intCast(ty.abiSize(zcu) * 8)); |
| 4443 | 4443 | }, |
| 4444 | .Bool => return .i8, | |
| 4444 | .bool => return .i8, | |
| 4445 | 4445 | else => return .none, |
| 4446 | 4446 | }; |
| 4447 | 4447 | const bit_count = int_ty.intInfo(zcu).bits; |
| ... | ... | @@ -4693,7 +4693,7 @@ pub const NavGen = struct { |
| 4693 | 4693 | const global_index = o.nav_map.get(nav_index).?; |
| 4694 | 4694 | |
| 4695 | 4695 | const decl_name = decl_name: { |
| 4696 | if (zcu.getTarget().isWasm() and ty.zigTypeTag(zcu) == .Fn) { | |
| 4696 | if (zcu.getTarget().isWasm() and ty.zigTypeTag(zcu) == .@"fn") { | |
| 4697 | 4697 | if (lib_name.toSlice(ip)) |lib_name_slice| { |
| 4698 | 4698 | if (!std.mem.eql(u8, lib_name_slice, "c")) { |
| 4699 | 4699 | break :decl_name try o.builder.strtabStringFmt("{}|{s}", .{ nav.name.fmt(ip), lib_name_slice }); |
| ... | ... | @@ -5192,8 +5192,8 @@ pub const FuncGen = struct { |
| 5192 | 5192 | const ip = &zcu.intern_pool; |
| 5193 | 5193 | const callee_ty = self.typeOf(pl_op.operand); |
| 5194 | 5194 | const zig_fn_ty = switch (callee_ty.zigTypeTag(zcu)) { |
| 5195 | .Fn => callee_ty, | |
| 5196 | .Pointer => callee_ty.childType(zcu), | |
| 5195 | .@"fn" => callee_ty, | |
| 5196 | .pointer => callee_ty.childType(zcu), | |
| 5197 | 5197 | else => unreachable, |
| 5198 | 5198 | }; |
| 5199 | 5199 | const fn_info = zcu.typeToFunc(zig_fn_ty).?; |
| ... | ... | @@ -5410,7 +5410,7 @@ pub const FuncGen = struct { |
| 5410 | 5410 | try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder); |
| 5411 | 5411 | } |
| 5412 | 5412 | } |
| 5413 | if (param_ty.zigTypeTag(zcu) != .Optional) { | |
| 5413 | if (param_ty.zigTypeTag(zcu) != .optional) { | |
| 5414 | 5414 | try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder); |
| 5415 | 5415 | } |
| 5416 | 5416 | if (ptr_info.flags.is_const) { |
| ... | ... | @@ -5773,9 +5773,9 @@ pub const FuncGen = struct { |
| 5773 | 5773 | const zcu = pt.zcu; |
| 5774 | 5774 | const scalar_ty = operand_ty.scalarType(zcu); |
| 5775 | 5775 | const int_ty = switch (scalar_ty.zigTypeTag(zcu)) { |
| 5776 | .Enum => scalar_ty.intTagType(zcu), | |
| 5777 | .Int, .Bool, .Pointer, .ErrorSet => scalar_ty, | |
| 5778 | .Optional => blk: { | |
| 5776 | .@"enum" => scalar_ty.intTagType(zcu), | |
| 5777 | .int, .bool, .pointer, .error_set => scalar_ty, | |
| 5778 | .optional => blk: { | |
| 5779 | 5779 | const payload_ty = operand_ty.optionalChild(zcu); |
| 5780 | 5780 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu) or |
| 5781 | 5781 | operand_ty.optionalReprIsPayload(zcu)) |
| ... | ... | @@ -5848,7 +5848,7 @@ pub const FuncGen = struct { |
| 5848 | 5848 | ); |
| 5849 | 5849 | return phi.toValue(); |
| 5850 | 5850 | }, |
| 5851 | .Float => return self.buildFloatCmp(fast, op, operand_ty, .{ lhs, rhs }), | |
| 5851 | .float => return self.buildFloatCmp(fast, op, operand_ty, .{ lhs, rhs }), | |
| 5852 | 5852 | else => unreachable, |
| 5853 | 5853 | }; |
| 5854 | 5854 | const is_signed = int_ty.isSignedInt(zcu); |
| ... | ... | @@ -5909,7 +5909,7 @@ pub const FuncGen = struct { |
| 5909 | 5909 | // a pointer to it. LLVM IR allows the call instruction to use function bodies instead |
| 5910 | 5910 | // of function pointers, however the phi makes it a runtime value and therefore |
| 5911 | 5911 | // the LLVM type has to be wrapped in a pointer. |
| 5912 | if (inst_ty.zigTypeTag(zcu) == .Fn or isByRef(inst_ty, zcu)) { | |
| 5912 | if (inst_ty.zigTypeTag(zcu) == .@"fn" or isByRef(inst_ty, zcu)) { | |
| 5913 | 5913 | break :ty .ptr; |
| 5914 | 5914 | } |
| 5915 | 5915 | break :ty raw_llvm_ty; |
| ... | ... | @@ -6605,7 +6605,7 @@ pub const FuncGen = struct { |
| 6605 | 6605 | if (!isByRef(struct_ty, zcu)) { |
| 6606 | 6606 | assert(!isByRef(field_ty, zcu)); |
| 6607 | 6607 | switch (struct_ty.zigTypeTag(zcu)) { |
| 6608 | .Struct => switch (struct_ty.containerLayout(zcu)) { | |
| 6608 | .@"struct" => switch (struct_ty.containerLayout(zcu)) { | |
| 6609 | 6609 | .@"packed" => { |
| 6610 | 6610 | const struct_type = zcu.typeToStruct(struct_ty).?; |
| 6611 | 6611 | const bit_offset = pt.structPackedFieldBitOffset(struct_type, field_index); |
| ... | ... | @@ -6614,7 +6614,7 @@ pub const FuncGen = struct { |
| 6614 | 6614 | try o.builder.intValue(containing_int.typeOfWip(&self.wip), bit_offset); |
| 6615 | 6615 | const shifted_value = try self.wip.bin(.lshr, containing_int, shift_amt, ""); |
| 6616 | 6616 | const elem_llvm_ty = try o.lowerType(field_ty); |
| 6617 | if (field_ty.zigTypeTag(zcu) == .Float or field_ty.zigTypeTag(zcu) == .Vector) { | |
| 6617 | if (field_ty.zigTypeTag(zcu) == .float or field_ty.zigTypeTag(zcu) == .vector) { | |
| 6618 | 6618 | const same_size_int = try o.builder.intType(@intCast(field_ty.bitSize(zcu))); |
| 6619 | 6619 | const truncated_int = |
| 6620 | 6620 | try self.wip.cast(.trunc, shifted_value, same_size_int, ""); |
| ... | ... | @@ -6632,11 +6632,11 @@ pub const FuncGen = struct { |
| 6632 | 6632 | return self.wip.extractValue(struct_llvm_val, &.{llvm_field_index}, ""); |
| 6633 | 6633 | }, |
| 6634 | 6634 | }, |
| 6635 | .Union => { | |
| 6635 | .@"union" => { | |
| 6636 | 6636 | assert(struct_ty.containerLayout(zcu) == .@"packed"); |
| 6637 | 6637 | const containing_int = struct_llvm_val; |
| 6638 | 6638 | const elem_llvm_ty = try o.lowerType(field_ty); |
| 6639 | if (field_ty.zigTypeTag(zcu) == .Float or field_ty.zigTypeTag(zcu) == .Vector) { | |
| 6639 | if (field_ty.zigTypeTag(zcu) == .float or field_ty.zigTypeTag(zcu) == .vector) { | |
| 6640 | 6640 | const same_size_int = try o.builder.intType(@intCast(field_ty.bitSize(zcu))); |
| 6641 | 6641 | const truncated_int = |
| 6642 | 6642 | try self.wip.cast(.trunc, containing_int, same_size_int, ""); |
| ... | ... | @@ -6654,7 +6654,7 @@ pub const FuncGen = struct { |
| 6654 | 6654 | } |
| 6655 | 6655 | |
| 6656 | 6656 | switch (struct_ty.zigTypeTag(zcu)) { |
| 6657 | .Struct => { | |
| 6657 | .@"struct" => { | |
| 6658 | 6658 | const layout = struct_ty.containerLayout(zcu); |
| 6659 | 6659 | assert(layout != .@"packed"); |
| 6660 | 6660 | const struct_llvm_ty = try o.lowerType(struct_ty); |
| ... | ... | @@ -6677,7 +6677,7 @@ pub const FuncGen = struct { |
| 6677 | 6677 | return self.load(field_ptr, field_ptr_ty); |
| 6678 | 6678 | } |
| 6679 | 6679 | }, |
| 6680 | .Union => { | |
| 6680 | .@"union" => { | |
| 6681 | 6681 | const union_llvm_ty = try o.lowerType(struct_ty); |
| 6682 | 6682 | const layout = struct_ty.unionGetLayout(zcu); |
| 6683 | 6683 | const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align)); |
| ... | ... | @@ -6934,7 +6934,7 @@ pub const FuncGen = struct { |
| 6934 | 6934 | if (output != .none) { |
| 6935 | 6935 | const output_inst = try self.resolveInst(output); |
| 6936 | 6936 | const output_ty = self.typeOf(output); |
| 6937 | assert(output_ty.zigTypeTag(zcu) == .Pointer); | |
| 6937 | assert(output_ty.zigTypeTag(zcu) == .pointer); | |
| 6938 | 6938 | const elem_llvm_ty = try o.lowerPtrElemTy(output_ty.childType(zcu)); |
| 6939 | 6939 | |
| 6940 | 6940 | switch (constraint[0]) { |
| ... | ... | @@ -8280,7 +8280,7 @@ pub const FuncGen = struct { |
| 8280 | 8280 | .gte => .sge, |
| 8281 | 8281 | }; |
| 8282 | 8282 | |
| 8283 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 8283 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 8284 | 8284 | const vec_len = ty.vectorLen(zcu); |
| 8285 | 8285 | const vector_result_ty = try o.builder.vectorType(.normal, vec_len, .i32); |
| 8286 | 8286 | |
| ... | ... | @@ -8457,7 +8457,7 @@ pub const FuncGen = struct { |
| 8457 | 8457 | ([1]Builder.Type{scalar_llvm_ty} ** 3)[0..params.len], |
| 8458 | 8458 | scalar_llvm_ty, |
| 8459 | 8459 | ); |
| 8460 | if (ty.zigTypeTag(zcu) == .Vector) { | |
| 8460 | if (ty.zigTypeTag(zcu) == .vector) { | |
| 8461 | 8461 | const result = try o.builder.poisonValue(llvm_ty); |
| 8462 | 8462 | return self.buildElementwiseCall(libc_fn, &params, result, ty.vectorLen(zcu)); |
| 8463 | 8463 | } |
| ... | ... | @@ -8658,7 +8658,7 @@ pub const FuncGen = struct { |
| 8658 | 8658 | const scalar_ty = operand_ty.scalarType(zcu); |
| 8659 | 8659 | |
| 8660 | 8660 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 8661 | .Int => return self.wip.callIntrinsic( | |
| 8661 | .int => return self.wip.callIntrinsic( | |
| 8662 | 8662 | .normal, |
| 8663 | 8663 | .none, |
| 8664 | 8664 | .abs, |
| ... | ... | @@ -8666,7 +8666,7 @@ pub const FuncGen = struct { |
| 8666 | 8666 | &.{ operand, try o.builder.intValue(.i1, 0) }, |
| 8667 | 8667 | "", |
| 8668 | 8668 | ), |
| 8669 | .Float => return self.buildFloatOp(.fabs, .normal, operand_ty, 1, .{operand}), | |
| 8669 | .float => return self.buildFloatOp(.fabs, .normal, operand_ty, 1, .{operand}), | |
| 8670 | 8670 | else => unreachable, |
| 8671 | 8671 | } |
| 8672 | 8672 | } |
| ... | ... | @@ -8806,11 +8806,11 @@ pub const FuncGen = struct { |
| 8806 | 8806 | return self.wip.conv(.unsigned, operand, llvm_dest_ty, ""); |
| 8807 | 8807 | } |
| 8808 | 8808 | |
| 8809 | if (operand_ty.zigTypeTag(zcu) == .Int and inst_ty.isPtrAtRuntime(zcu)) { | |
| 8809 | if (operand_ty.zigTypeTag(zcu) == .int and inst_ty.isPtrAtRuntime(zcu)) { | |
| 8810 | 8810 | return self.wip.cast(.inttoptr, operand, llvm_dest_ty, ""); |
| 8811 | 8811 | } |
| 8812 | 8812 | |
| 8813 | if (operand_ty.zigTypeTag(zcu) == .Vector and inst_ty.zigTypeTag(zcu) == .Array) { | |
| 8813 | if (operand_ty.zigTypeTag(zcu) == .vector and inst_ty.zigTypeTag(zcu) == .array) { | |
| 8814 | 8814 | const elem_ty = operand_ty.childType(zcu); |
| 8815 | 8815 | if (!result_is_ref) { |
| 8816 | 8816 | return self.ng.todo("implement bitcast vector to non-ref array", .{}); |
| ... | ... | @@ -8837,7 +8837,7 @@ pub const FuncGen = struct { |
| 8837 | 8837 | } |
| 8838 | 8838 | } |
| 8839 | 8839 | return array_ptr; |
| 8840 | } else if (operand_ty.zigTypeTag(zcu) == .Array and inst_ty.zigTypeTag(zcu) == .Vector) { | |
| 8840 | } else if (operand_ty.zigTypeTag(zcu) == .array and inst_ty.zigTypeTag(zcu) == .vector) { | |
| 8841 | 8841 | const elem_ty = operand_ty.childType(zcu); |
| 8842 | 8842 | const llvm_vector_ty = try o.lowerType(inst_ty); |
| 8843 | 8843 | if (!operand_is_ref) return self.ng.todo("implement bitcast non-ref array to vector", .{}); |
| ... | ... | @@ -8883,7 +8883,7 @@ pub const FuncGen = struct { |
| 8883 | 8883 | } |
| 8884 | 8884 | |
| 8885 | 8885 | if (llvm_dest_ty.isStruct(&o.builder) or |
| 8886 | ((operand_ty.zigTypeTag(zcu) == .Vector or inst_ty.zigTypeTag(zcu) == .Vector) and | |
| 8886 | ((operand_ty.zigTypeTag(zcu) == .vector or inst_ty.zigTypeTag(zcu) == .vector) and | |
| 8887 | 8887 | operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu))) |
| 8888 | 8888 | { |
| 8889 | 8889 | // Both our operand and our result are values, not pointers, |
| ... | ... | @@ -9687,7 +9687,7 @@ pub const FuncGen = struct { |
| 9687 | 9687 | // If not an even byte-multiple, we need zero-extend + shift-left 1 byte |
| 9688 | 9688 | // The truncated result at the end will be the correct bswap |
| 9689 | 9689 | const scalar_ty = try o.builder.intType(@intCast(bits + 8)); |
| 9690 | if (operand_ty.zigTypeTag(zcu) == .Vector) { | |
| 9690 | if (operand_ty.zigTypeTag(zcu) == .vector) { | |
| 9691 | 9691 | const vec_len = operand_ty.vectorLen(zcu); |
| 9692 | 9692 | llvm_operand_ty = try o.builder.vectorType(.normal, vec_len, scalar_ty); |
| 9693 | 9693 | } else llvm_operand_ty = scalar_ty; |
| ... | ... | @@ -9993,7 +9993,7 @@ pub const FuncGen = struct { |
| 9993 | 9993 | else => unreachable, |
| 9994 | 9994 | }, &.{llvm_operand_ty}, &.{operand}, ""), |
| 9995 | 9995 | .Min, .Max => switch (scalar_ty.zigTypeTag(zcu)) { |
| 9996 | .Int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) { | |
| 9996 | .int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) { | |
| 9997 | 9997 | .Min => if (scalar_ty.isSignedInt(zcu)) |
| 9998 | 9998 | .@"vector.reduce.smin" |
| 9999 | 9999 | else |
| ... | ... | @@ -10004,7 +10004,7 @@ pub const FuncGen = struct { |
| 10004 | 10004 | .@"vector.reduce.umax", |
| 10005 | 10005 | else => unreachable, |
| 10006 | 10006 | }, &.{llvm_operand_ty}, &.{operand}, ""), |
| 10007 | .Float => if (intrinsicsAllowed(scalar_ty, target)) | |
| 10007 | .float => if (intrinsicsAllowed(scalar_ty, target)) | |
| 10008 | 10008 | return self.wip.callIntrinsic(fast, .none, switch (reduce.operation) { |
| 10009 | 10009 | .Min => .@"vector.reduce.fmin", |
| 10010 | 10010 | .Max => .@"vector.reduce.fmax", |
| ... | ... | @@ -10013,12 +10013,12 @@ pub const FuncGen = struct { |
| 10013 | 10013 | else => unreachable, |
| 10014 | 10014 | }, |
| 10015 | 10015 | .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) { |
| 10016 | .Int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) { | |
| 10016 | .int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) { | |
| 10017 | 10017 | .Add => .@"vector.reduce.add", |
| 10018 | 10018 | .Mul => .@"vector.reduce.mul", |
| 10019 | 10019 | else => unreachable, |
| 10020 | 10020 | }, &.{llvm_operand_ty}, &.{operand}, ""), |
| 10021 | .Float => if (intrinsicsAllowed(scalar_ty, target)) | |
| 10021 | .float => if (intrinsicsAllowed(scalar_ty, target)) | |
| 10022 | 10022 | return self.wip.callIntrinsic(fast, .none, switch (reduce.operation) { |
| 10023 | 10023 | .Add => .@"vector.reduce.fadd", |
| 10024 | 10024 | .Mul => .@"vector.reduce.fmul", |
| ... | ... | @@ -10095,7 +10095,7 @@ pub const FuncGen = struct { |
| 10095 | 10095 | const llvm_result_ty = try o.lowerType(result_ty); |
| 10096 | 10096 | |
| 10097 | 10097 | switch (result_ty.zigTypeTag(zcu)) { |
| 10098 | .Vector => { | |
| 10098 | .vector => { | |
| 10099 | 10099 | var vector = try o.builder.poisonValue(llvm_result_ty); |
| 10100 | 10100 | for (elements, 0..) |elem, i| { |
| 10101 | 10101 | const index_u32 = try o.builder.intValue(.i32, i); |
| ... | ... | @@ -10104,7 +10104,7 @@ pub const FuncGen = struct { |
| 10104 | 10104 | } |
| 10105 | 10105 | return vector; |
| 10106 | 10106 | }, |
| 10107 | .Struct => { | |
| 10107 | .@"struct" => { | |
| 10108 | 10108 | if (zcu.typeToPackedStruct(result_ty)) |struct_type| { |
| 10109 | 10109 | const backing_int_ty = struct_type.backingIntTypeUnordered(ip); |
| 10110 | 10110 | assert(backing_int_ty != .none); |
| ... | ... | @@ -10170,7 +10170,7 @@ pub const FuncGen = struct { |
| 10170 | 10170 | return result; |
| 10171 | 10171 | } |
| 10172 | 10172 | }, |
| 10173 | .Array => { | |
| 10173 | .array => { | |
| 10174 | 10174 | assert(isByRef(result_ty, zcu)); |
| 10175 | 10175 | |
| 10176 | 10176 | const llvm_usize = try o.lowerType(Type.usize); |
| ... | ... | @@ -10577,7 +10577,7 @@ pub const FuncGen = struct { |
| 10577 | 10577 | const zcu = pt.zcu; |
| 10578 | 10578 | const struct_ty = struct_ptr_ty.childType(zcu); |
| 10579 | 10579 | switch (struct_ty.zigTypeTag(zcu)) { |
| 10580 | .Struct => switch (struct_ty.containerLayout(zcu)) { | |
| 10580 | .@"struct" => switch (struct_ty.containerLayout(zcu)) { | |
| 10581 | 10581 | .@"packed" => { |
| 10582 | 10582 | const result_ty = self.typeOfIndex(inst); |
| 10583 | 10583 | const result_ty_info = result_ty.ptrInfo(zcu); |
| ... | ... | @@ -10618,7 +10618,7 @@ pub const FuncGen = struct { |
| 10618 | 10618 | } |
| 10619 | 10619 | }, |
| 10620 | 10620 | }, |
| 10621 | .Union => { | |
| 10621 | .@"union" => { | |
| 10622 | 10622 | const layout = struct_ty.unionGetLayout(zcu); |
| 10623 | 10623 | if (layout.payload_size == 0 or struct_ty.containerLayout(zcu) == .@"packed") return struct_ptr; |
| 10624 | 10624 | const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align)); |
| ... | ... | @@ -10761,7 +10761,7 @@ pub const FuncGen = struct { |
| 10761 | 10761 | return result_ptr; |
| 10762 | 10762 | } |
| 10763 | 10763 | |
| 10764 | if (elem_ty.zigTypeTag(zcu) == .Float or elem_ty.zigTypeTag(zcu) == .Vector) { | |
| 10764 | if (elem_ty.zigTypeTag(zcu) == .float or elem_ty.zigTypeTag(zcu) == .vector) { | |
| 10765 | 10765 | const same_size_int = try o.builder.intType(@intCast(elem_bits)); |
| 10766 | 10766 | const truncated_int = try self.wip.cast(.trunc, shifted_value, same_size_int, ""); |
| 10767 | 10767 | return self.wip.cast(.bitcast, truncated_int, elem_llvm_ty, ""); |
| ... | ... | @@ -11432,7 +11432,7 @@ const ParamTypeIterator = struct { |
| 11432 | 11432 | it.zig_index += 1; |
| 11433 | 11433 | it.llvm_index += 1; |
| 11434 | 11434 | if (ty.isSlice(zcu) or |
| 11435 | (ty.zigTypeTag(zcu) == .Optional and ty.optionalChild(zcu).isSlice(zcu) and !ty.ptrAllowsZero(zcu))) | |
| 11435 | (ty.zigTypeTag(zcu) == .optional and ty.optionalChild(zcu).isSlice(zcu) and !ty.ptrAllowsZero(zcu))) | |
| 11436 | 11436 | { |
| 11437 | 11437 | it.llvm_index += 1; |
| 11438 | 11438 | return .slice; |
| ... | ... | @@ -11707,8 +11707,8 @@ fn ccAbiPromoteInt( |
| 11707 | 11707 | else => {}, |
| 11708 | 11708 | } |
| 11709 | 11709 | const int_info = switch (ty.zigTypeTag(zcu)) { |
| 11710 | .Bool => Type.u1.intInfo(zcu), | |
| 11711 | .Int, .Enum, .ErrorSet => ty.intInfo(zcu), | |
| 11710 | .bool => Type.u1.intInfo(zcu), | |
| 11711 | .int, .@"enum", .error_set => ty.intInfo(zcu), | |
| 11712 | 11712 | else => return null, |
| 11713 | 11713 | }; |
| 11714 | 11714 | return switch (target.os.tag) { |
| ... | ... | @@ -11753,30 +11753,30 @@ fn isByRef(ty: Type, zcu: *Zcu) bool { |
| 11753 | 11753 | const ip = &zcu.intern_pool; |
| 11754 | 11754 | |
| 11755 | 11755 | switch (ty.zigTypeTag(zcu)) { |
| 11756 | .Type, | |
| 11757 | .ComptimeInt, | |
| 11758 | .ComptimeFloat, | |
| 11759 | .EnumLiteral, | |
| 11760 | .Undefined, | |
| 11761 | .Null, | |
| 11762 | .Opaque, | |
| 11756 | .type, | |
| 11757 | .comptime_int, | |
| 11758 | .comptime_float, | |
| 11759 | .enum_literal, | |
| 11760 | .undefined, | |
| 11761 | .null, | |
| 11762 | .@"opaque", | |
| 11763 | 11763 | => unreachable, |
| 11764 | 11764 | |
| 11765 | .NoReturn, | |
| 11766 | .Void, | |
| 11767 | .Bool, | |
| 11768 | .Int, | |
| 11769 | .Float, | |
| 11770 | .Pointer, | |
| 11771 | .ErrorSet, | |
| 11772 | .Fn, | |
| 11773 | .Enum, | |
| 11774 | .Vector, | |
| 11775 | .AnyFrame, | |
| 11765 | .noreturn, | |
| 11766 | .void, | |
| 11767 | .bool, | |
| 11768 | .int, | |
| 11769 | .float, | |
| 11770 | .pointer, | |
| 11771 | .error_set, | |
| 11772 | .@"fn", | |
| 11773 | .@"enum", | |
| 11774 | .vector, | |
| 11775 | .@"anyframe", | |
| 11776 | 11776 | => return false, |
| 11777 | 11777 | |
| 11778 | .Array, .Frame => return ty.hasRuntimeBits(zcu), | |
| 11779 | .Struct => { | |
| 11778 | .array, .frame => return ty.hasRuntimeBits(zcu), | |
| 11779 | .@"struct" => { | |
| 11780 | 11780 | const struct_type = switch (ip.indexToKey(ty.toIntern())) { |
| 11781 | 11781 | .anon_struct_type => |tuple| { |
| 11782 | 11782 | var count: usize = 0; |
| ... | ... | @@ -11807,18 +11807,18 @@ fn isByRef(ty: Type, zcu: *Zcu) bool { |
| 11807 | 11807 | } |
| 11808 | 11808 | return false; |
| 11809 | 11809 | }, |
| 11810 | .Union => switch (ty.containerLayout(zcu)) { | |
| 11810 | .@"union" => switch (ty.containerLayout(zcu)) { | |
| 11811 | 11811 | .@"packed" => return false, |
| 11812 | 11812 | else => return ty.hasRuntimeBits(zcu), |
| 11813 | 11813 | }, |
| 11814 | .ErrorUnion => { | |
| 11814 | .error_union => { | |
| 11815 | 11815 | const payload_ty = ty.errorUnionPayload(zcu); |
| 11816 | 11816 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 11817 | 11817 | return false; |
| 11818 | 11818 | } |
| 11819 | 11819 | return true; |
| 11820 | 11820 | }, |
| 11821 | .Optional => { | |
| 11821 | .optional => { | |
| 11822 | 11822 | const payload_ty = ty.optionalChild(zcu); |
| 11823 | 11823 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 11824 | 11824 | return false; |
| ... | ... | @@ -11833,21 +11833,21 @@ fn isByRef(ty: Type, zcu: *Zcu) bool { |
| 11833 | 11833 | |
| 11834 | 11834 | fn isScalar(zcu: *Zcu, ty: Type) bool { |
| 11835 | 11835 | return switch (ty.zigTypeTag(zcu)) { |
| 11836 | .Void, | |
| 11837 | .Bool, | |
| 11838 | .NoReturn, | |
| 11839 | .Int, | |
| 11840 | .Float, | |
| 11841 | .Pointer, | |
| 11842 | .Optional, | |
| 11843 | .ErrorSet, | |
| 11844 | .Enum, | |
| 11845 | .AnyFrame, | |
| 11846 | .Vector, | |
| 11836 | .void, | |
| 11837 | .bool, | |
| 11838 | .noreturn, | |
| 11839 | .int, | |
| 11840 | .float, | |
| 11841 | .pointer, | |
| 11842 | .optional, | |
| 11843 | .error_set, | |
| 11844 | .@"enum", | |
| 11845 | .@"anyframe", | |
| 11846 | .vector, | |
| 11847 | 11847 | => true, |
| 11848 | 11848 | |
| 11849 | .Struct => ty.containerLayout(zcu) == .@"packed", | |
| 11850 | .Union => ty.containerLayout(zcu) == .@"packed", | |
| 11849 | .@"struct" => ty.containerLayout(zcu) == .@"packed", | |
| 11850 | .@"union" => ty.containerLayout(zcu) == .@"packed", | |
| 11851 | 11851 | else => false, |
| 11852 | 11852 | }; |
| 11853 | 11853 | } |
src/codegen/llvm/BitcodeReader.zig+3-3| ... | ... | @@ -273,7 +273,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void { |
| 273 | 273 | }; |
| 274 | 274 | try state.abbrevs.abbrevs.ensureTotalCapacity( |
| 275 | 275 | bc.allocator, |
| 276 | @typeInfo(Abbrev.Builtin).Enum.fields.len + abbrevs.len, | |
| 276 | @typeInfo(Abbrev.Builtin).@"enum".fields.len + abbrevs.len, | |
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | 279 | assert(state.abbrevs.abbrevs.items.len == @intFromEnum(Abbrev.Builtin.end_block)); |
| ... | ... | @@ -309,7 +309,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void { |
| 309 | 309 | .{ .encoding = .{ .vbr = 6 } }, // ops |
| 310 | 310 | }, |
| 311 | 311 | }); |
| 312 | assert(state.abbrevs.abbrevs.items.len == @typeInfo(Abbrev.Builtin).Enum.fields.len); | |
| 312 | assert(state.abbrevs.abbrevs.items.len == @typeInfo(Abbrev.Builtin).@"enum".fields.len); | |
| 313 | 313 | for (abbrevs) |abbrev| try state.abbrevs.addAbbrevAssumeCapacity(bc.allocator, abbrev); |
| 314 | 314 | } |
| 315 | 315 | |
| ... | ... | @@ -448,7 +448,7 @@ const Abbrev = struct { |
| 448 | 448 | define_abbrev, |
| 449 | 449 | unabbrev_record, |
| 450 | 450 | |
| 451 | const first_record_id: u32 = std.math.maxInt(u32) - @typeInfo(Builtin).Enum.fields.len + 1; | |
| 451 | const first_record_id: u32 = std.math.maxInt(u32) - @typeInfo(Builtin).@"enum".fields.len + 1; | |
| 452 | 452 | fn toRecordId(builtin: Builtin) u32 { |
| 453 | 453 | return first_record_id + @intFromEnum(builtin); |
| 454 | 454 | } |
src/codegen/llvm/Builder.zig+47-47| ... | ... | @@ -1115,7 +1115,7 @@ pub const Attribute = union(Kind) { |
| 1115 | 1115 | => |kind| { |
| 1116 | 1116 | const field = comptime blk: { |
| 1117 | 1117 | @setEvalBranchQuota(10_000); |
| 1118 | for (@typeInfo(Attribute).Union.fields) |field| { | |
| 1118 | for (@typeInfo(Attribute).@"union".fields) |field| { | |
| 1119 | 1119 | if (std.mem.eql(u8, field.name, @tagName(kind))) break :blk field; |
| 1120 | 1120 | } |
| 1121 | 1121 | unreachable; |
| ... | ... | @@ -1232,11 +1232,11 @@ pub const Attribute = union(Kind) { |
| 1232 | 1232 | .dereferenceable_or_null, |
| 1233 | 1233 | => |size| try writer.print(" {s}({d})", .{ @tagName(attribute), size }), |
| 1234 | 1234 | .nofpclass => |fpclass| { |
| 1235 | const Int = @typeInfo(FpClass).Struct.backing_integer.?; | |
| 1235 | const Int = @typeInfo(FpClass).@"struct".backing_integer.?; | |
| 1236 | 1236 | try writer.print(" {s}(", .{@tagName(attribute)}); |
| 1237 | 1237 | var any = false; |
| 1238 | 1238 | var remaining: Int = @bitCast(fpclass); |
| 1239 | inline for (@typeInfo(FpClass).Struct.decls) |decl| { | |
| 1239 | inline for (@typeInfo(FpClass).@"struct".decls) |decl| { | |
| 1240 | 1240 | const pattern: Int = @bitCast(@field(FpClass, decl.name)); |
| 1241 | 1241 | if (remaining & pattern == pattern) { |
| 1242 | 1242 | if (!any) { |
| ... | ... | @@ -1259,7 +1259,7 @@ pub const Attribute = union(Kind) { |
| 1259 | 1259 | .allockind => |allockind| { |
| 1260 | 1260 | try writer.print(" {s}(\"", .{@tagName(attribute)}); |
| 1261 | 1261 | var any = false; |
| 1262 | inline for (@typeInfo(AllocKind).Struct.fields) |field| { | |
| 1262 | inline for (@typeInfo(AllocKind).@"struct".fields) |field| { | |
| 1263 | 1263 | if (comptime std.mem.eql(u8, field.name, "_")) continue; |
| 1264 | 1264 | if (@field(allockind, field.name)) { |
| 1265 | 1265 | if (!any) { |
| ... | ... | @@ -1418,7 +1418,7 @@ pub const Attribute = union(Kind) { |
| 1418 | 1418 | none = std.math.maxInt(u32), |
| 1419 | 1419 | _, |
| 1420 | 1420 | |
| 1421 | pub const len = @typeInfo(Kind).Enum.fields.len - 2; | |
| 1421 | pub const len = @typeInfo(Kind).@"enum".fields.len - 2; | |
| 1422 | 1422 | |
| 1423 | 1423 | pub fn fromString(str: String) Kind { |
| 1424 | 1424 | assert(!str.isAnon()); |
| ... | ... | @@ -5037,7 +5037,7 @@ pub const Function = struct { |
| 5037 | 5037 | index: Instruction.ExtraIndex, |
| 5038 | 5038 | ) struct { data: T, trail: ExtraDataTrail } { |
| 5039 | 5039 | var result: T = undefined; |
| 5040 | const fields = @typeInfo(T).Struct.fields; | |
| 5040 | const fields = @typeInfo(T).@"struct".fields; | |
| 5041 | 5041 | inline for (fields, self.extra[index..][0..fields.len]) |field, value| |
| 5042 | 5042 | @field(result, field.name) = switch (field.type) { |
| 5043 | 5043 | u32 => value, |
| ... | ... | @@ -6151,7 +6151,7 @@ pub const WipFunction = struct { |
| 6151 | 6151 | |
| 6152 | 6152 | fn addExtra(wip_extra: *@This(), extra: anytype) Instruction.ExtraIndex { |
| 6153 | 6153 | const result = wip_extra.index; |
| 6154 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { | |
| 6154 | inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| { | |
| 6155 | 6155 | const value = @field(extra, field.name); |
| 6156 | 6156 | wip_extra.items[wip_extra.index] = switch (field.type) { |
| 6157 | 6157 | u32 => value, |
| ... | ... | @@ -6175,7 +6175,7 @@ pub const WipFunction = struct { |
| 6175 | 6175 | } |
| 6176 | 6176 | |
| 6177 | 6177 | fn appendSlice(wip_extra: *@This(), slice: anytype) void { |
| 6178 | if (@typeInfo(@TypeOf(slice)).Pointer.child == Value) | |
| 6178 | if (@typeInfo(@TypeOf(slice)).pointer.child == Value) | |
| 6179 | 6179 | @compileError("use appendMappedValues"); |
| 6180 | 6180 | const data: []const u32 = @ptrCast(slice); |
| 6181 | 6181 | @memcpy(wip_extra.items[wip_extra.index..][0..data.len], data); |
| ... | ... | @@ -6760,7 +6760,7 @@ pub const WipFunction = struct { |
| 6760 | 6760 | ) Allocator.Error!void { |
| 6761 | 6761 | try self.extra.ensureUnusedCapacity( |
| 6762 | 6762 | self.builder.gpa, |
| 6763 | count * (@typeInfo(Extra).Struct.fields.len + trail_len), | |
| 6763 | count * (@typeInfo(Extra).@"struct".fields.len + trail_len), | |
| 6764 | 6764 | ); |
| 6765 | 6765 | } |
| 6766 | 6766 | |
| ... | ... | @@ -6799,7 +6799,7 @@ pub const WipFunction = struct { |
| 6799 | 6799 | |
| 6800 | 6800 | fn addExtraAssumeCapacity(self: *WipFunction, extra: anytype) Instruction.ExtraIndex { |
| 6801 | 6801 | const result: Instruction.ExtraIndex = @intCast(self.extra.items.len); |
| 6802 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { | |
| 6802 | inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| { | |
| 6803 | 6803 | const value = @field(extra, field.name); |
| 6804 | 6804 | self.extra.appendAssumeCapacity(switch (field.type) { |
| 6805 | 6805 | u32 => value, |
| ... | ... | @@ -6848,7 +6848,7 @@ pub const WipFunction = struct { |
| 6848 | 6848 | index: Instruction.ExtraIndex, |
| 6849 | 6849 | ) struct { data: T, trail: ExtraDataTrail } { |
| 6850 | 6850 | var result: T = undefined; |
| 6851 | const fields = @typeInfo(T).Struct.fields; | |
| 6851 | const fields = @typeInfo(T).@"struct".fields; | |
| 6852 | 6852 | inline for (fields, self.extra.items[index..][0..fields.len]) |field, value| |
| 6853 | 6853 | @field(result, field.name) = switch (field.type) { |
| 6854 | 6854 | u32 => value, |
| ... | ... | @@ -7926,17 +7926,17 @@ pub const Metadata = enum(u32) { |
| 7926 | 7926 | writer: anytype, |
| 7927 | 7927 | ) @TypeOf(writer).Error!void { |
| 7928 | 7928 | var need_pipe = false; |
| 7929 | inline for (@typeInfo(DIFlags).Struct.fields) |field| { | |
| 7929 | inline for (@typeInfo(DIFlags).@"struct".fields) |field| { | |
| 7930 | 7930 | switch (@typeInfo(field.type)) { |
| 7931 | .Bool => if (@field(self, field.name)) { | |
| 7931 | .bool => if (@field(self, field.name)) { | |
| 7932 | 7932 | if (need_pipe) try writer.writeAll(" | ") else need_pipe = true; |
| 7933 | 7933 | try writer.print("DIFlag{s}", .{field.name}); |
| 7934 | 7934 | }, |
| 7935 | .Enum => if (@field(self, field.name) != .Zero) { | |
| 7935 | .@"enum" => if (@field(self, field.name) != .Zero) { | |
| 7936 | 7936 | if (need_pipe) try writer.writeAll(" | ") else need_pipe = true; |
| 7937 | 7937 | try writer.print("DIFlag{s}", .{@tagName(@field(self, field.name))}); |
| 7938 | 7938 | }, |
| 7939 | .Int => assert(@field(self, field.name) == 0), | |
| 7939 | .int => assert(@field(self, field.name) == 0), | |
| 7940 | 7940 | else => @compileError("bad field type: " ++ field.name ++ ": " ++ |
| 7941 | 7941 | @typeName(field.type)), |
| 7942 | 7942 | } |
| ... | ... | @@ -7988,17 +7988,17 @@ pub const Metadata = enum(u32) { |
| 7988 | 7988 | writer: anytype, |
| 7989 | 7989 | ) @TypeOf(writer).Error!void { |
| 7990 | 7990 | var need_pipe = false; |
| 7991 | inline for (@typeInfo(DISPFlags).Struct.fields) |field| { | |
| 7991 | inline for (@typeInfo(DISPFlags).@"struct".fields) |field| { | |
| 7992 | 7992 | switch (@typeInfo(field.type)) { |
| 7993 | .Bool => if (@field(self, field.name)) { | |
| 7993 | .bool => if (@field(self, field.name)) { | |
| 7994 | 7994 | if (need_pipe) try writer.writeAll(" | ") else need_pipe = true; |
| 7995 | 7995 | try writer.print("DISPFlag{s}", .{field.name}); |
| 7996 | 7996 | }, |
| 7997 | .Enum => if (@field(self, field.name) != .Zero) { | |
| 7997 | .@"enum" => if (@field(self, field.name) != .Zero) { | |
| 7998 | 7998 | if (need_pipe) try writer.writeAll(" | ") else need_pipe = true; |
| 7999 | 7999 | try writer.print("DISPFlag{s}", .{@tagName(@field(self, field.name))}); |
| 8000 | 8000 | }, |
| 8001 | .Int => assert(@field(self, field.name) == 0), | |
| 8001 | .int => assert(@field(self, field.name) == 0), | |
| 8002 | 8002 | else => @compileError("bad field type: " ++ field.name ++ ": " ++ |
| 8003 | 8003 | @typeName(field.type)), |
| 8004 | 8004 | } |
| ... | ... | @@ -8281,16 +8281,16 @@ pub const Metadata = enum(u32) { |
| 8281 | 8281 | }!std.fmt.Formatter(format) { |
| 8282 | 8282 | const Node = @TypeOf(node); |
| 8283 | 8283 | const MaybeNode = switch (@typeInfo(Node)) { |
| 8284 | .Optional => Node, | |
| 8285 | .Null => ?noreturn, | |
| 8284 | .optional => Node, | |
| 8285 | .null => ?noreturn, | |
| 8286 | 8286 | else => ?Node, |
| 8287 | 8287 | }; |
| 8288 | const Some = @typeInfo(MaybeNode).Optional.child; | |
| 8288 | const Some = @typeInfo(MaybeNode).optional.child; | |
| 8289 | 8289 | return .{ .data = .{ |
| 8290 | 8290 | .formatter = formatter, |
| 8291 | 8291 | .prefix = prefix, |
| 8292 | 8292 | .node = if (@as(MaybeNode, node)) |some| switch (@typeInfo(Some)) { |
| 8293 | .Enum => |enum_info| switch (Some) { | |
| 8293 | .@"enum" => |enum_info| switch (Some) { | |
| 8294 | 8294 | Metadata => switch (some) { |
| 8295 | 8295 | .none => .none, |
| 8296 | 8296 | else => try formatter.refUnwrapped(some.unwrap(formatter.builder)), |
| ... | ... | @@ -8301,18 +8301,18 @@ pub const Metadata = enum(u32) { |
| 8301 | 8301 | else |
| 8302 | 8302 | @compileError("unknown type to format: " ++ @typeName(Node)), |
| 8303 | 8303 | }, |
| 8304 | .EnumLiteral => .{ .raw = @tagName(some) }, | |
| 8305 | .Bool => .{ .bool = some }, | |
| 8306 | .Struct => switch (Some) { | |
| 8304 | .enum_literal => .{ .raw = @tagName(some) }, | |
| 8305 | .bool => .{ .bool = some }, | |
| 8306 | .@"struct" => switch (Some) { | |
| 8307 | 8307 | DIFlags => .{ .di_flags = some }, |
| 8308 | 8308 | Subprogram.DISPFlags => .{ .sp_flags = some }, |
| 8309 | 8309 | else => @compileError("unknown type to format: " ++ @typeName(Node)), |
| 8310 | 8310 | }, |
| 8311 | .Int, .ComptimeInt => .{ .u64 = some }, | |
| 8312 | .Pointer => .{ .raw = some }, | |
| 8311 | .int, .comptime_int => .{ .u64 = some }, | |
| 8312 | .pointer => .{ .raw = some }, | |
| 8313 | 8313 | else => @compileError("unknown type to format: " ++ @typeName(Node)), |
| 8314 | 8314 | } else switch (@typeInfo(Node)) { |
| 8315 | .Optional, .Null => .none, | |
| 8315 | .optional, .null => .none, | |
| 8316 | 8316 | else => unreachable, |
| 8317 | 8317 | }, |
| 8318 | 8318 | } }; |
| ... | ... | @@ -8414,7 +8414,7 @@ pub const Metadata = enum(u32) { |
| 8414 | 8414 | } |
| 8415 | 8415 | fmt_str = fmt_str ++ ")\n"; |
| 8416 | 8416 | |
| 8417 | var fmt_args: @Type(.{ .Struct = .{ | |
| 8417 | var fmt_args: @Type(.{ .@"struct" = .{ | |
| 8418 | 8418 | .layout = .auto, |
| 8419 | 8419 | .fields = &fields, |
| 8420 | 8420 | .decls = &.{}, |
| ... | ... | @@ -8501,10 +8501,10 @@ pub fn init(options: Options) Allocator.Error!Builder { |
| 8501 | 8501 | } |
| 8502 | 8502 | |
| 8503 | 8503 | { |
| 8504 | const static_len = @typeInfo(Type).Enum.fields.len - 1; | |
| 8504 | const static_len = @typeInfo(Type).@"enum".fields.len - 1; | |
| 8505 | 8505 | try self.type_map.ensureTotalCapacity(self.gpa, static_len); |
| 8506 | 8506 | try self.type_items.ensureTotalCapacity(self.gpa, static_len); |
| 8507 | inline for (@typeInfo(Type.Simple).Enum.fields) |simple_field| { | |
| 8507 | inline for (@typeInfo(Type.Simple).@"enum".fields) |simple_field| { | |
| 8508 | 8508 | const result = self.getOrPutTypeNoExtraAssumeCapacity( |
| 8509 | 8509 | .{ .tag = .simple, .data = simple_field.value }, |
| 8510 | 8510 | ); |
| ... | ... | @@ -9031,14 +9031,14 @@ pub fn getIntrinsic( |
| 9031 | 9031 | |
| 9032 | 9032 | pub fn intConst(self: *Builder, ty: Type, value: anytype) Allocator.Error!Constant { |
| 9033 | 9033 | const int_value = switch (@typeInfo(@TypeOf(value))) { |
| 9034 | .Int, .ComptimeInt => value, | |
| 9035 | .Enum => @intFromEnum(value), | |
| 9034 | .int, .comptime_int => value, | |
| 9035 | .@"enum" => @intFromEnum(value), | |
| 9036 | 9036 | else => @compileError("intConst expected an integral value, got " ++ @typeName(@TypeOf(value))), |
| 9037 | 9037 | }; |
| 9038 | 9038 | var limbs: [ |
| 9039 | 9039 | switch (@typeInfo(@TypeOf(int_value))) { |
| 9040 | .Int => |info| std.math.big.int.calcTwosCompLimbCount(info.bits), | |
| 9041 | .ComptimeInt => std.math.big.int.calcLimbLen(int_value), | |
| 9040 | .int => |info| std.math.big.int.calcTwosCompLimbCount(info.bits), | |
| 9041 | .comptime_int => std.math.big.int.calcLimbLen(int_value), | |
| 9042 | 9042 | else => unreachable, |
| 9043 | 9043 | } |
| 9044 | 9044 | ]std.math.big.Limb = undefined; |
| ... | ... | @@ -10759,7 +10759,7 @@ fn ensureUnusedTypeCapacity( |
| 10759 | 10759 | try self.type_items.ensureUnusedCapacity(self.gpa, count); |
| 10760 | 10760 | try self.type_extra.ensureUnusedCapacity( |
| 10761 | 10761 | self.gpa, |
| 10762 | count * (@typeInfo(Extra).Struct.fields.len + trail_len), | |
| 10762 | count * (@typeInfo(Extra).@"struct".fields.len + trail_len), | |
| 10763 | 10763 | ); |
| 10764 | 10764 | } |
| 10765 | 10765 | |
| ... | ... | @@ -10789,7 +10789,7 @@ fn getOrPutTypeNoExtraAssumeCapacity(self: *Builder, item: Type.Item) struct { n |
| 10789 | 10789 | |
| 10790 | 10790 | fn addTypeExtraAssumeCapacity(self: *Builder, extra: anytype) Type.Item.ExtraIndex { |
| 10791 | 10791 | const result: Type.Item.ExtraIndex = @intCast(self.type_extra.items.len); |
| 10792 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { | |
| 10792 | inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| { | |
| 10793 | 10793 | const value = @field(extra, field.name); |
| 10794 | 10794 | self.type_extra.appendAssumeCapacity(switch (field.type) { |
| 10795 | 10795 | u32 => value, |
| ... | ... | @@ -10827,7 +10827,7 @@ fn typeExtraDataTrail( |
| 10827 | 10827 | index: Type.Item.ExtraIndex, |
| 10828 | 10828 | ) struct { data: T, trail: TypeExtraDataTrail } { |
| 10829 | 10829 | var result: T = undefined; |
| 10830 | const fields = @typeInfo(T).Struct.fields; | |
| 10830 | const fields = @typeInfo(T).@"struct".fields; | |
| 10831 | 10831 | inline for (fields, self.type_extra.items[index..][0..fields.len]) |field, value| |
| 10832 | 10832 | @field(result, field.name) = switch (field.type) { |
| 10833 | 10833 | u32 => value, |
| ... | ... | @@ -11642,7 +11642,7 @@ fn ensureUnusedConstantCapacity( |
| 11642 | 11642 | try self.constant_items.ensureUnusedCapacity(self.gpa, count); |
| 11643 | 11643 | try self.constant_extra.ensureUnusedCapacity( |
| 11644 | 11644 | self.gpa, |
| 11645 | count * (@typeInfo(Extra).Struct.fields.len + trail_len), | |
| 11645 | count * (@typeInfo(Extra).@"struct".fields.len + trail_len), | |
| 11646 | 11646 | ); |
| 11647 | 11647 | } |
| 11648 | 11648 | |
| ... | ... | @@ -11717,7 +11717,7 @@ fn getOrPutConstantAggregateAssumeCapacity( |
| 11717 | 11717 | |
| 11718 | 11718 | fn addConstantExtraAssumeCapacity(self: *Builder, extra: anytype) Constant.Item.ExtraIndex { |
| 11719 | 11719 | const result: Constant.Item.ExtraIndex = @intCast(self.constant_extra.items.len); |
| 11720 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { | |
| 11720 | inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| { | |
| 11721 | 11721 | const value = @field(extra, field.name); |
| 11722 | 11722 | self.constant_extra.appendAssumeCapacity(switch (field.type) { |
| 11723 | 11723 | u32 => value, |
| ... | ... | @@ -11756,7 +11756,7 @@ fn constantExtraDataTrail( |
| 11756 | 11756 | index: Constant.Item.ExtraIndex, |
| 11757 | 11757 | ) struct { data: T, trail: ConstantExtraDataTrail } { |
| 11758 | 11758 | var result: T = undefined; |
| 11759 | const fields = @typeInfo(T).Struct.fields; | |
| 11759 | const fields = @typeInfo(T).@"struct".fields; | |
| 11760 | 11760 | inline for (fields, self.constant_extra.items[index..][0..fields.len]) |field, value| |
| 11761 | 11761 | @field(result, field.name) = switch (field.type) { |
| 11762 | 11762 | u32 => value, |
| ... | ... | @@ -11784,13 +11784,13 @@ fn ensureUnusedMetadataCapacity( |
| 11784 | 11784 | try self.metadata_items.ensureUnusedCapacity(self.gpa, count); |
| 11785 | 11785 | try self.metadata_extra.ensureUnusedCapacity( |
| 11786 | 11786 | self.gpa, |
| 11787 | count * (@typeInfo(Extra).Struct.fields.len + trail_len), | |
| 11787 | count * (@typeInfo(Extra).@"struct".fields.len + trail_len), | |
| 11788 | 11788 | ); |
| 11789 | 11789 | } |
| 11790 | 11790 | |
| 11791 | 11791 | fn addMetadataExtraAssumeCapacity(self: *Builder, extra: anytype) Metadata.Item.ExtraIndex { |
| 11792 | 11792 | const result: Metadata.Item.ExtraIndex = @intCast(self.metadata_extra.items.len); |
| 11793 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { | |
| 11793 | inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| { | |
| 11794 | 11794 | const value = @field(extra, field.name); |
| 11795 | 11795 | self.metadata_extra.appendAssumeCapacity(switch (field.type) { |
| 11796 | 11796 | u32 => value, |
| ... | ... | @@ -11829,7 +11829,7 @@ fn metadataExtraDataTrail( |
| 11829 | 11829 | index: Metadata.Item.ExtraIndex, |
| 11830 | 11830 | ) struct { data: T, trail: MetadataExtraDataTrail } { |
| 11831 | 11831 | var result: T = undefined; |
| 11832 | const fields = @typeInfo(T).Struct.fields; | |
| 11832 | const fields = @typeInfo(T).@"struct".fields; | |
| 11833 | 11833 | inline for (fields, self.metadata_extra.items[index..][0..fields.len]) |field, value| |
| 11834 | 11834 | @field(result, field.name) = switch (field.type) { |
| 11835 | 11835 | u32 => value, |
| ... | ... | @@ -13921,7 +13921,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13921 | 13921 | const MetadataKindBlock = ir.MetadataKindBlock; |
| 13922 | 13922 | var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true); |
| 13923 | 13923 | |
| 13924 | inline for (@typeInfo(ir.FixedMetadataKind).Enum.fields) |field| { | |
| 13924 | inline for (@typeInfo(ir.FixedMetadataKind).@"enum".fields) |field| { | |
| 13925 | 13925 | // don't include `dbg` in stripped functions |
| 13926 | 13926 | if (!(self.strip and std.mem.eql(u8, field.name, "dbg"))) { |
| 13927 | 13927 | try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{ |
| ... | ... | @@ -14197,7 +14197,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14197 | 14197 | const limbs_len = std.math.divCeil(u32, extra.bit_width, 64) catch unreachable; |
| 14198 | 14198 | try record.ensureTotalCapacity(self.gpa, 3 + limbs_len); |
| 14199 | 14199 | record.appendAssumeCapacity(@as( |
| 14200 | @typeInfo(MetadataBlock.Enumerator.Flags).Struct.backing_integer.?, | |
| 14200 | @typeInfo(MetadataBlock.Enumerator.Flags).@"struct".backing_integer.?, | |
| 14201 | 14201 | @bitCast(flags), |
| 14202 | 14202 | )); |
| 14203 | 14203 | record.appendAssumeCapacity(extra.bit_width); |
src/codegen/llvm/bitcode_writer.zig+9-9| ... | ... | @@ -407,14 +407,14 @@ fn charTo6Bit(c: u8) u8 { |
| 407 | 407 | |
| 408 | 408 | fn BufType(comptime T: type, comptime min_len: usize) type { |
| 409 | 409 | return std.meta.Int(.unsigned, @max(min_len, @bitSizeOf(switch (@typeInfo(T)) { |
| 410 | .ComptimeInt => u32, | |
| 411 | .Int => |info| if (info.signedness == .unsigned) | |
| 410 | .comptime_int => u32, | |
| 411 | .int => |info| if (info.signedness == .unsigned) | |
| 412 | 412 | T |
| 413 | 413 | else |
| 414 | 414 | @compileError("Unsupported type: " ++ @typeName(T)), |
| 415 | .Enum => |info| info.tag_type, | |
| 416 | .Bool => u1, | |
| 417 | .Struct => |info| switch (info.layout) { | |
| 415 | .@"enum" => |info| info.tag_type, | |
| 416 | .bool => u1, | |
| 417 | .@"struct" => |info| switch (info.layout) { | |
| 418 | 418 | .auto, .@"extern" => @compileError("Unsupported type: " ++ @typeName(T)), |
| 419 | 419 | .@"packed" => std.meta.Int(.unsigned, @bitSizeOf(T)), |
| 420 | 420 | }, |
| ... | ... | @@ -424,10 +424,10 @@ fn BufType(comptime T: type, comptime min_len: usize) type { |
| 424 | 424 | |
| 425 | 425 | fn bufValue(value: anytype, comptime min_len: usize) BufType(@TypeOf(value), min_len) { |
| 426 | 426 | return switch (@typeInfo(@TypeOf(value))) { |
| 427 | .ComptimeInt, .Int => @intCast(value), | |
| 428 | .Enum => @intFromEnum(value), | |
| 429 | .Bool => @intFromBool(value), | |
| 430 | .Struct => @intCast(@as(std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(value))), @bitCast(value))), | |
| 427 | .comptime_int, .int => @intCast(value), | |
| 428 | .@"enum" => @intFromEnum(value), | |
| 429 | .bool => @intFromBool(value), | |
| 430 | .@"struct" => @intCast(@as(std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(value))), @bitCast(value))), | |
| 431 | 431 | else => unreachable, |
| 432 | 432 | }; |
| 433 | 433 | } |
src/codegen/spirv.zig+65-65| ... | ... | @@ -439,7 +439,7 @@ const NavGen = struct { |
| 439 | 439 | const zcu = pt.zcu; |
| 440 | 440 | if (try self.air.value(inst, pt)) |val| { |
| 441 | 441 | const ty = self.typeOf(inst); |
| 442 | if (ty.zigTypeTag(zcu) == .Fn) { | |
| 442 | if (ty.zigTypeTag(zcu) == .@"fn") { | |
| 443 | 443 | const fn_nav = switch (zcu.intern_pool.indexToKey(val.ip_index)) { |
| 444 | 444 | .@"extern" => |@"extern"| @"extern".owner_nav, |
| 445 | 445 | .func => |func| func.owner_nav, |
| ... | ... | @@ -641,16 +641,16 @@ const NavGen = struct { |
| 641 | 641 | fn isSpvVector(self: *NavGen, ty: Type) bool { |
| 642 | 642 | const zcu = self.pt.zcu; |
| 643 | 643 | const target = self.getTarget(); |
| 644 | if (ty.zigTypeTag(zcu) != .Vector) return false; | |
| 644 | if (ty.zigTypeTag(zcu) != .vector) return false; | |
| 645 | 645 | |
| 646 | 646 | // TODO: This check must be expanded for types that can be represented |
| 647 | 647 | // as integers (enums / packed structs?) and types that are represented |
| 648 | 648 | // by multiple SPIR-V values. |
| 649 | 649 | const scalar_ty = ty.scalarType(zcu); |
| 650 | 650 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 651 | .Bool, | |
| 652 | .Int, | |
| 653 | .Float, | |
| 651 | .bool, | |
| 652 | .int, | |
| 653 | .float, | |
| 654 | 654 | => {}, |
| 655 | 655 | else => return false, |
| 656 | 656 | } |
| ... | ... | @@ -668,26 +668,26 @@ const NavGen = struct { |
| 668 | 668 | const zcu = self.pt.zcu; |
| 669 | 669 | const target = self.getTarget(); |
| 670 | 670 | var scalar_ty = ty.scalarType(zcu); |
| 671 | if (scalar_ty.zigTypeTag(zcu) == .Enum) { | |
| 671 | if (scalar_ty.zigTypeTag(zcu) == .@"enum") { | |
| 672 | 672 | scalar_ty = scalar_ty.intTagType(zcu); |
| 673 | 673 | } |
| 674 | 674 | const vector_len = if (ty.isVector(zcu)) ty.vectorLen(zcu) else null; |
| 675 | 675 | return switch (scalar_ty.zigTypeTag(zcu)) { |
| 676 | .Bool => ArithmeticTypeInfo{ | |
| 676 | .bool => ArithmeticTypeInfo{ | |
| 677 | 677 | .bits = 1, // Doesn't matter for this class. |
| 678 | 678 | .backing_bits = self.backingIntBits(1).?, |
| 679 | 679 | .vector_len = vector_len, |
| 680 | 680 | .signedness = .unsigned, // Technically, but doesn't matter for this class. |
| 681 | 681 | .class = .bool, |
| 682 | 682 | }, |
| 683 | .Float => ArithmeticTypeInfo{ | |
| 683 | .float => ArithmeticTypeInfo{ | |
| 684 | 684 | .bits = scalar_ty.floatBits(target), |
| 685 | 685 | .backing_bits = scalar_ty.floatBits(target), // TODO: F80? |
| 686 | 686 | .vector_len = vector_len, |
| 687 | 687 | .signedness = .signed, // Technically, but doesn't matter for this class. |
| 688 | 688 | .class = .float, |
| 689 | 689 | }, |
| 690 | .Int => blk: { | |
| 690 | .int => blk: { | |
| 691 | 691 | const int_info = scalar_ty.intInfo(zcu); |
| 692 | 692 | // TODO: Maybe it's useful to also return this value. |
| 693 | 693 | const maybe_backing_bits = self.backingIntBits(int_info.bits); |
| ... | ... | @@ -705,8 +705,8 @@ const NavGen = struct { |
| 705 | 705 | .composite_integer, |
| 706 | 706 | }; |
| 707 | 707 | }, |
| 708 | .Enum => unreachable, | |
| 709 | .Vector => unreachable, | |
| 708 | .@"enum" => unreachable, | |
| 709 | .vector => unreachable, | |
| 710 | 710 | else => unreachable, // Unhandled arithmetic type |
| 711 | 711 | }; |
| 712 | 712 | } |
| ... | ... | @@ -748,8 +748,8 @@ const NavGen = struct { |
| 748 | 748 | const backing_bits = self.backingIntBits(int_info.bits).?; // Assertion failure means big int |
| 749 | 749 | |
| 750 | 750 | const signedness: Signedness = switch (@typeInfo(@TypeOf(value))) { |
| 751 | .Int => |int| int.signedness, | |
| 752 | .ComptimeInt => if (value < 0) .signed else .unsigned, | |
| 751 | .int => |int| int.signedness, | |
| 752 | .comptime_int => if (value < 0) .signed else .unsigned, | |
| 753 | 753 | else => unreachable, |
| 754 | 754 | }; |
| 755 | 755 | |
| ... | ... | @@ -1243,7 +1243,7 @@ const NavGen = struct { |
| 1243 | 1243 | else => {}, |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | // const is_fn_body = decl_ty.zigTypeTag(zcu) == .Fn; | |
| 1246 | // const is_fn_body = decl_ty.zigTypeTag(zcu) == .@"fn"; | |
| 1247 | 1247 | if (!uav_ty.isFnOrHasRuntimeBitsIgnoreComptime(zcu)) { |
| 1248 | 1248 | // Pointer to nothing - return undefined |
| 1249 | 1249 | return self.spv.constUndef(ty_id); |
| ... | ... | @@ -1539,11 +1539,11 @@ const NavGen = struct { |
| 1539 | 1539 | const section = &self.spv.sections.types_globals_constants; |
| 1540 | 1540 | |
| 1541 | 1541 | switch (ty.zigTypeTag(zcu)) { |
| 1542 | .NoReturn => { | |
| 1542 | .noreturn => { | |
| 1543 | 1543 | assert(repr == .direct); |
| 1544 | 1544 | return try self.spv.voidType(); |
| 1545 | 1545 | }, |
| 1546 | .Void => switch (repr) { | |
| 1546 | .void => switch (repr) { | |
| 1547 | 1547 | .direct => { |
| 1548 | 1548 | return try self.spv.voidType(); |
| 1549 | 1549 | }, |
| ... | ... | @@ -1557,11 +1557,11 @@ const NavGen = struct { |
| 1557 | 1557 | return result_id; |
| 1558 | 1558 | }, |
| 1559 | 1559 | }, |
| 1560 | .Bool => switch (repr) { | |
| 1560 | .bool => switch (repr) { | |
| 1561 | 1561 | .direct => return try self.spv.boolType(), |
| 1562 | 1562 | .indirect => return try self.resolveType(Type.u1, .indirect), |
| 1563 | 1563 | }, |
| 1564 | .Int => { | |
| 1564 | .int => { | |
| 1565 | 1565 | const int_info = ty.intInfo(zcu); |
| 1566 | 1566 | if (int_info.bits == 0) { |
| 1567 | 1567 | // Some times, the backend will be asked to generate a pointer to i0. OpTypeInt |
| ... | ... | @@ -1576,11 +1576,11 @@ const NavGen = struct { |
| 1576 | 1576 | } |
| 1577 | 1577 | return try self.intType(int_info.signedness, int_info.bits); |
| 1578 | 1578 | }, |
| 1579 | .Enum => { | |
| 1579 | .@"enum" => { | |
| 1580 | 1580 | const tag_ty = ty.intTagType(zcu); |
| 1581 | 1581 | return try self.resolveType(tag_ty, repr); |
| 1582 | 1582 | }, |
| 1583 | .Float => { | |
| 1583 | .float => { | |
| 1584 | 1584 | // We can (and want) not really emulate floating points with other floating point types like with the integer types, |
| 1585 | 1585 | // so if the float is not supported, just return an error. |
| 1586 | 1586 | const bits = ty.floatBits(target); |
| ... | ... | @@ -1598,7 +1598,7 @@ const NavGen = struct { |
| 1598 | 1598 | |
| 1599 | 1599 | return try self.spv.floatType(bits); |
| 1600 | 1600 | }, |
| 1601 | .Array => { | |
| 1601 | .array => { | |
| 1602 | 1602 | const elem_ty = ty.childType(zcu); |
| 1603 | 1603 | const elem_ty_id = try self.resolveType(elem_ty, .indirect); |
| 1604 | 1604 | const total_len = std.math.cast(u32, ty.arrayLenIncludingSentinel(zcu)) orelse { |
| ... | ... | @@ -1633,7 +1633,7 @@ const NavGen = struct { |
| 1633 | 1633 | return try self.arrayType(total_len, elem_ty_id); |
| 1634 | 1634 | } |
| 1635 | 1635 | }, |
| 1636 | .Fn => switch (repr) { | |
| 1636 | .@"fn" => switch (repr) { | |
| 1637 | 1637 | .direct => { |
| 1638 | 1638 | const fn_info = zcu.typeToFunc(ty).?; |
| 1639 | 1639 | |
| ... | ... | @@ -1676,7 +1676,7 @@ const NavGen = struct { |
| 1676 | 1676 | return try self.resolveType(Type.usize, .indirect); |
| 1677 | 1677 | }, |
| 1678 | 1678 | }, |
| 1679 | .Pointer => { | |
| 1679 | .pointer => { | |
| 1680 | 1680 | const ptr_info = ty.ptrInfo(zcu); |
| 1681 | 1681 | |
| 1682 | 1682 | const storage_class = self.spvStorageClass(ptr_info.flags.address_space); |
| ... | ... | @@ -1692,7 +1692,7 @@ const NavGen = struct { |
| 1692 | 1692 | &.{ "ptr", "len" }, |
| 1693 | 1693 | ); |
| 1694 | 1694 | }, |
| 1695 | .Vector => { | |
| 1695 | .vector => { | |
| 1696 | 1696 | const elem_ty = ty.childType(zcu); |
| 1697 | 1697 | const elem_ty_id = try self.resolveType(elem_ty, repr); |
| 1698 | 1698 | const len = ty.vectorLen(zcu); |
| ... | ... | @@ -1703,7 +1703,7 @@ const NavGen = struct { |
| 1703 | 1703 | return try self.arrayType(len, elem_ty_id); |
| 1704 | 1704 | } |
| 1705 | 1705 | }, |
| 1706 | .Struct => { | |
| 1706 | .@"struct" => { | |
| 1707 | 1707 | const struct_type = switch (ip.indexToKey(ty.toIntern())) { |
| 1708 | 1708 | .anon_struct_type => |tuple| { |
| 1709 | 1709 | const member_types = try self.gpa.alloc(IdRef, tuple.values.len); |
| ... | ... | @@ -1757,7 +1757,7 @@ const NavGen = struct { |
| 1757 | 1757 | try self.spv.debugName(result_id, type_name); |
| 1758 | 1758 | return result_id; |
| 1759 | 1759 | }, |
| 1760 | .Optional => { | |
| 1760 | .optional => { | |
| 1761 | 1761 | const payload_ty = ty.optionalChild(zcu); |
| 1762 | 1762 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 1763 | 1763 | // Just use a bool. |
| ... | ... | @@ -1779,9 +1779,9 @@ const NavGen = struct { |
| 1779 | 1779 | &.{ "payload", "valid" }, |
| 1780 | 1780 | ); |
| 1781 | 1781 | }, |
| 1782 | .Union => return try self.resolveUnionType(ty), | |
| 1783 | .ErrorSet => return try self.resolveType(Type.u16, repr), | |
| 1784 | .ErrorUnion => { | |
| 1782 | .@"union" => return try self.resolveUnionType(ty), | |
| 1783 | .error_set => return try self.resolveType(Type.u16, repr), | |
| 1784 | .error_union => { | |
| 1785 | 1785 | const payload_ty = ty.errorUnionPayload(zcu); |
| 1786 | 1786 | const error_ty_id = try self.resolveType(Type.anyerror, .indirect); |
| 1787 | 1787 | |
| ... | ... | @@ -1808,7 +1808,7 @@ const NavGen = struct { |
| 1808 | 1808 | |
| 1809 | 1809 | return try self.spv.structType(&member_types, &member_names); |
| 1810 | 1810 | }, |
| 1811 | .Opaque => { | |
| 1811 | .@"opaque" => { | |
| 1812 | 1812 | const type_name = try self.resolveTypeName(ty); |
| 1813 | 1813 | defer self.gpa.free(type_name); |
| 1814 | 1814 | |
| ... | ... | @@ -1820,15 +1820,15 @@ const NavGen = struct { |
| 1820 | 1820 | return result_id; |
| 1821 | 1821 | }, |
| 1822 | 1822 | |
| 1823 | .Null, | |
| 1824 | .Undefined, | |
| 1825 | .EnumLiteral, | |
| 1826 | .ComptimeFloat, | |
| 1827 | .ComptimeInt, | |
| 1828 | .Type, | |
| 1823 | .null, | |
| 1824 | .undefined, | |
| 1825 | .enum_literal, | |
| 1826 | .comptime_float, | |
| 1827 | .comptime_int, | |
| 1828 | .type, | |
| 1829 | 1829 | => unreachable, // Must be comptime. |
| 1830 | 1830 | |
| 1831 | .Frame, .AnyFrame => unreachable, // TODO | |
| 1831 | .frame, .@"anyframe" => unreachable, // TODO | |
| 1832 | 1832 | } |
| 1833 | 1833 | } |
| 1834 | 1834 | |
| ... | ... | @@ -2429,7 +2429,7 @@ const NavGen = struct { |
| 2429 | 2429 | const op_result_ty_id = try self.resolveType(op_result_ty, .direct); |
| 2430 | 2430 | const result_ty = try v.resultType(self, lhs.ty); |
| 2431 | 2431 | |
| 2432 | assert(condition.ty.scalarType(zcu).zigTypeTag(zcu) == .Bool); | |
| 2432 | assert(condition.ty.scalarType(zcu).zigTypeTag(zcu) == .bool); | |
| 2433 | 2433 | |
| 2434 | 2434 | const cond = try v.prepare(self, condition); |
| 2435 | 2435 | const object_1 = try v.prepare(self, lhs); |
| ... | ... | @@ -3119,7 +3119,7 @@ const NavGen = struct { |
| 3119 | 3119 | fn convertToDirect(self: *NavGen, ty: Type, operand_id: IdRef) !IdRef { |
| 3120 | 3120 | const zcu = self.pt.zcu; |
| 3121 | 3121 | switch (ty.scalarType(zcu).zigTypeTag(zcu)) { |
| 3122 | .Bool => { | |
| 3122 | .bool => { | |
| 3123 | 3123 | const false_id = try self.constBool(false, .indirect); |
| 3124 | 3124 | // The operation below requires inputs in direct representation, but the operand |
| 3125 | 3125 | // is actually in indirect representation. |
| ... | ... | @@ -3145,7 +3145,7 @@ const NavGen = struct { |
| 3145 | 3145 | fn convertToIndirect(self: *NavGen, ty: Type, operand_id: IdRef) !IdRef { |
| 3146 | 3146 | const zcu = self.pt.zcu; |
| 3147 | 3147 | switch (ty.scalarType(zcu).zigTypeTag(zcu)) { |
| 3148 | .Bool => { | |
| 3148 | .bool => { | |
| 3149 | 3149 | const result = try self.intFromBool(Temporary.init(ty, operand_id)); |
| 3150 | 3150 | return try result.materialize(self); |
| 3151 | 3151 | }, |
| ... | ... | @@ -4281,17 +4281,17 @@ const NavGen = struct { |
| 4281 | 4281 | const is_vector = lhs.ty.isVector(zcu); |
| 4282 | 4282 | |
| 4283 | 4283 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 4284 | .Int, .Bool, .Float => {}, | |
| 4285 | .Enum => { | |
| 4284 | .int, .bool, .float => {}, | |
| 4285 | .@"enum" => { | |
| 4286 | 4286 | assert(!is_vector); |
| 4287 | 4287 | const ty = lhs.ty.intTagType(zcu); |
| 4288 | 4288 | return try self.cmp(op, lhs.pun(ty), rhs.pun(ty)); |
| 4289 | 4289 | }, |
| 4290 | .ErrorSet => { | |
| 4290 | .error_set => { | |
| 4291 | 4291 | assert(!is_vector); |
| 4292 | 4292 | return try self.cmp(op, lhs.pun(Type.u16), rhs.pun(Type.u16)); |
| 4293 | 4293 | }, |
| 4294 | .Pointer => { | |
| 4294 | .pointer => { | |
| 4295 | 4295 | assert(!is_vector); |
| 4296 | 4296 | // Note that while SPIR-V offers OpPtrEqual and OpPtrNotEqual, they are |
| 4297 | 4297 | // currently not implemented in the SPIR-V LLVM translator. Thus, we emit these using |
| ... | ... | @@ -4317,7 +4317,7 @@ const NavGen = struct { |
| 4317 | 4317 | const rhs_int = Temporary.init(Type.usize, rhs_int_id); |
| 4318 | 4318 | return try self.cmp(op, lhs_int, rhs_int); |
| 4319 | 4319 | }, |
| 4320 | .Optional => { | |
| 4320 | .optional => { | |
| 4321 | 4321 | assert(!is_vector); |
| 4322 | 4322 | |
| 4323 | 4323 | const ty = lhs.ty; |
| ... | ... | @@ -4478,7 +4478,7 @@ const NavGen = struct { |
| 4478 | 4478 | // TODO: Some more cases are missing here |
| 4479 | 4479 | // See fn bitCast in llvm.zig |
| 4480 | 4480 | |
| 4481 | if (src_ty.zigTypeTag(zcu) == .Int and dst_ty.isPtrAtRuntime(zcu)) { | |
| 4481 | if (src_ty.zigTypeTag(zcu) == .int and dst_ty.isPtrAtRuntime(zcu)) { | |
| 4482 | 4482 | const result_id = self.spv.allocId(); |
| 4483 | 4483 | try self.func.body.emit(self.spv.gpa, .OpConvertUToPtr, .{ |
| 4484 | 4484 | .id_result_type = dst_ty_id, |
| ... | ... | @@ -4520,7 +4520,7 @@ const NavGen = struct { |
| 4520 | 4520 | // the result here. |
| 4521 | 4521 | // TODO: This detail could cause stuff like @as(*const i1, @ptrCast(&@as(u1, 1))) to break |
| 4522 | 4522 | // should we change the representation of strange integers? |
| 4523 | if (dst_ty.zigTypeTag(zcu) == .Int) { | |
| 4523 | if (dst_ty.zigTypeTag(zcu) == .int) { | |
| 4524 | 4524 | const info = self.arithmeticTypeInfo(dst_ty); |
| 4525 | 4525 | const result = try self.normalize(Temporary.init(dst_ty, result_id), info); |
| 4526 | 4526 | return try result.materialize(self); |
| ... | ... | @@ -4729,7 +4729,7 @@ const NavGen = struct { |
| 4729 | 4729 | const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]); |
| 4730 | 4730 | |
| 4731 | 4731 | switch (result_ty.zigTypeTag(zcu)) { |
| 4732 | .Struct => { | |
| 4732 | .@"struct" => { | |
| 4733 | 4733 | if (zcu.typeToPackedStruct(result_ty)) |struct_type| { |
| 4734 | 4734 | _ = struct_type; |
| 4735 | 4735 | unreachable; // TODO |
| ... | ... | @@ -4777,7 +4777,7 @@ const NavGen = struct { |
| 4777 | 4777 | constituents[0..index], |
| 4778 | 4778 | ); |
| 4779 | 4779 | }, |
| 4780 | .Vector => { | |
| 4780 | .vector => { | |
| 4781 | 4781 | const n_elems = result_ty.vectorLen(zcu); |
| 4782 | 4782 | const elem_ids = try self.gpa.alloc(IdRef, n_elems); |
| 4783 | 4783 | defer self.gpa.free(elem_ids); |
| ... | ... | @@ -4788,7 +4788,7 @@ const NavGen = struct { |
| 4788 | 4788 | |
| 4789 | 4789 | return try self.constructVector(result_ty, elem_ids); |
| 4790 | 4790 | }, |
| 4791 | .Array => { | |
| 4791 | .array => { | |
| 4792 | 4792 | const array_info = result_ty.arrayInfo(zcu); |
| 4793 | 4793 | const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(zcu)); |
| 4794 | 4794 | const elem_ids = try self.gpa.alloc(IdRef, n_elems); |
| ... | ... | @@ -5153,11 +5153,11 @@ const NavGen = struct { |
| 5153 | 5153 | if (!field_ty.hasRuntimeBitsIgnoreComptime(zcu)) return null; |
| 5154 | 5154 | |
| 5155 | 5155 | switch (object_ty.zigTypeTag(zcu)) { |
| 5156 | .Struct => switch (object_ty.containerLayout(zcu)) { | |
| 5156 | .@"struct" => switch (object_ty.containerLayout(zcu)) { | |
| 5157 | 5157 | .@"packed" => unreachable, // TODO |
| 5158 | 5158 | else => return try self.extractField(field_ty, object_id, field_index), |
| 5159 | 5159 | }, |
| 5160 | .Union => switch (object_ty.containerLayout(zcu)) { | |
| 5160 | .@"union" => switch (object_ty.containerLayout(zcu)) { | |
| 5161 | 5161 | .@"packed" => unreachable, // TODO |
| 5162 | 5162 | else => { |
| 5163 | 5163 | // Store, ptr-elem-ptr, pointer-cast, load |
| ... | ... | @@ -5229,17 +5229,17 @@ const NavGen = struct { |
| 5229 | 5229 | const zcu = self.pt.zcu; |
| 5230 | 5230 | const object_ty = object_ptr_ty.childType(zcu); |
| 5231 | 5231 | switch (object_ty.zigTypeTag(zcu)) { |
| 5232 | .Pointer => { | |
| 5232 | .pointer => { | |
| 5233 | 5233 | assert(object_ty.isSlice(zcu)); |
| 5234 | 5234 | return self.accessChain(result_ty_id, object_ptr, &.{field_index}); |
| 5235 | 5235 | }, |
| 5236 | .Struct => switch (object_ty.containerLayout(zcu)) { | |
| 5236 | .@"struct" => switch (object_ty.containerLayout(zcu)) { | |
| 5237 | 5237 | .@"packed" => unreachable, // TODO |
| 5238 | 5238 | else => { |
| 5239 | 5239 | return try self.accessChain(result_ty_id, object_ptr, &.{field_index}); |
| 5240 | 5240 | }, |
| 5241 | 5241 | }, |
| 5242 | .Union => switch (object_ty.containerLayout(zcu)) { | |
| 5242 | .@"union" => switch (object_ty.containerLayout(zcu)) { | |
| 5243 | 5243 | .@"packed" => unreachable, // TODO |
| 5244 | 5244 | else => { |
| 5245 | 5245 | const layout = self.unionLayout(object_ty); |
| ... | ... | @@ -6179,15 +6179,15 @@ const NavGen = struct { |
| 6179 | 6179 | var cond_indirect = try self.convertToIndirect(cond_ty, cond); |
| 6180 | 6180 | |
| 6181 | 6181 | const cond_words: u32 = switch (cond_ty.zigTypeTag(zcu)) { |
| 6182 | .Bool, .ErrorSet => 1, | |
| 6183 | .Int => blk: { | |
| 6182 | .bool, .error_set => 1, | |
| 6183 | .int => blk: { | |
| 6184 | 6184 | const bits = cond_ty.intInfo(zcu).bits; |
| 6185 | 6185 | const backing_bits = self.backingIntBits(bits) orelse { |
| 6186 | 6186 | return self.todo("implement composite int switch", .{}); |
| 6187 | 6187 | }; |
| 6188 | 6188 | break :blk if (backing_bits <= 32) 1 else 2; |
| 6189 | 6189 | }, |
| 6190 | .Enum => blk: { | |
| 6190 | .@"enum" => blk: { | |
| 6191 | 6191 | const int_ty = cond_ty.intTagType(zcu); |
| 6192 | 6192 | const int_info = int_ty.intInfo(zcu); |
| 6193 | 6193 | const backing_bits = self.backingIntBits(int_info.bits) orelse { |
| ... | ... | @@ -6195,7 +6195,7 @@ const NavGen = struct { |
| 6195 | 6195 | }; |
| 6196 | 6196 | break :blk if (backing_bits <= 32) 1 else 2; |
| 6197 | 6197 | }, |
| 6198 | .Pointer => blk: { | |
| 6198 | .pointer => blk: { | |
| 6199 | 6199 | cond_indirect = try self.intFromPtr(cond_indirect); |
| 6200 | 6200 | break :blk target.ptrBitWidth() / 32; |
| 6201 | 6201 | }, |
| ... | ... | @@ -6248,13 +6248,13 @@ const NavGen = struct { |
| 6248 | 6248 | for (case.items) |item| { |
| 6249 | 6249 | const value = (try self.air.value(item, pt)) orelse unreachable; |
| 6250 | 6250 | const int_val: u64 = switch (cond_ty.zigTypeTag(zcu)) { |
| 6251 | .Bool, .Int => if (cond_ty.isSignedInt(zcu)) @bitCast(value.toSignedInt(zcu)) else value.toUnsignedInt(zcu), | |
| 6252 | .Enum => blk: { | |
| 6251 | .bool, .int => if (cond_ty.isSignedInt(zcu)) @bitCast(value.toSignedInt(zcu)) else value.toUnsignedInt(zcu), | |
| 6252 | .@"enum" => blk: { | |
| 6253 | 6253 | // TODO: figure out of cond_ty is correct (something with enum literals) |
| 6254 | 6254 | break :blk (try value.intFromEnum(cond_ty, pt)).toUnsignedInt(zcu); // TODO: composite integer constants |
| 6255 | 6255 | }, |
| 6256 | .ErrorSet => value.getErrorInt(zcu), | |
| 6257 | .Pointer => value.toUnsignedInt(zcu), | |
| 6256 | .error_set => value.getErrorInt(zcu), | |
| 6257 | .pointer => value.toUnsignedInt(zcu), | |
| 6258 | 6258 | else => unreachable, |
| 6259 | 6259 | }; |
| 6260 | 6260 | const int_lit: spec.LiteralContextDependentNumber = switch (cond_words) { |
| ... | ... | @@ -6496,8 +6496,8 @@ const NavGen = struct { |
| 6496 | 6496 | const args: []const Air.Inst.Ref = @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]); |
| 6497 | 6497 | const callee_ty = self.typeOf(pl_op.operand); |
| 6498 | 6498 | const zig_fn_ty = switch (callee_ty.zigTypeTag(zcu)) { |
| 6499 | .Fn => callee_ty, | |
| 6500 | .Pointer => return self.fail("cannot call function pointers", .{}), | |
| 6499 | .@"fn" => callee_ty, | |
| 6500 | .pointer => return self.fail("cannot call function pointers", .{}), | |
| 6501 | 6501 | else => unreachable, |
| 6502 | 6502 | }; |
| 6503 | 6503 | const fn_info = zcu.typeToFunc(zig_fn_ty).?; |
src/codegen/spirv/Section.zig+26-26| ... | ... | @@ -98,7 +98,7 @@ pub fn emitSpecConstantOp( |
| 98 | 98 | section.writeOperand(spec.IdRef, operands.id_result); |
| 99 | 99 | section.writeOperand(Opcode, opcode); |
| 100 | 100 | |
| 101 | const fields = @typeInfo(opcode.Operands()).Struct.fields; | |
| 101 | const fields = @typeInfo(opcode.Operands()).@"struct".fields; | |
| 102 | 102 | // First 2 fields are always id_result_type and id_result. |
| 103 | 103 | inline for (fields[2..]) |field| { |
| 104 | 104 | section.writeOperand(field.type, @field(operands, field.name)); |
| ... | ... | @@ -122,8 +122,8 @@ pub fn writeDoubleWord(section: *Section, dword: DoubleWord) void { |
| 122 | 122 | |
| 123 | 123 | fn writeOperands(section: *Section, comptime Operands: type, operands: Operands) void { |
| 124 | 124 | const fields = switch (@typeInfo(Operands)) { |
| 125 | .Struct => |info| info.fields, | |
| 126 | .Void => return, | |
| 125 | .@"struct" => |info| info.fields, | |
| 126 | .void => return, | |
| 127 | 127 | else => unreachable, |
| 128 | 128 | }; |
| 129 | 129 | |
| ... | ... | @@ -154,24 +154,24 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand) |
| 154 | 154 | spec.PairIdRefIdRef => section.writeWords(&.{ @intFromEnum(operand[0]), @intFromEnum(operand[1]) }), |
| 155 | 155 | |
| 156 | 156 | else => switch (@typeInfo(Operand)) { |
| 157 | .Enum => section.writeWord(@intFromEnum(operand)), | |
| 158 | .Optional => |info| if (operand) |child| { | |
| 157 | .@"enum" => section.writeWord(@intFromEnum(operand)), | |
| 158 | .optional => |info| if (operand) |child| { | |
| 159 | 159 | section.writeOperand(info.child, child); |
| 160 | 160 | }, |
| 161 | .Pointer => |info| { | |
| 161 | .pointer => |info| { | |
| 162 | 162 | std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec. |
| 163 | 163 | for (operand) |item| { |
| 164 | 164 | section.writeOperand(info.child, item); |
| 165 | 165 | } |
| 166 | 166 | }, |
| 167 | .Struct => |info| { | |
| 167 | .@"struct" => |info| { | |
| 168 | 168 | if (info.layout == .@"packed") { |
| 169 | 169 | section.writeWord(@as(Word, @bitCast(operand))); |
| 170 | 170 | } else { |
| 171 | 171 | section.writeExtendedMask(Operand, operand); |
| 172 | 172 | } |
| 173 | 173 | }, |
| 174 | .Union => section.writeExtendedUnion(Operand, operand), | |
| 174 | .@"union" => section.writeExtendedUnion(Operand, operand), | |
| 175 | 175 | else => unreachable, |
| 176 | 176 | }, |
| 177 | 177 | } |
| ... | ... | @@ -207,12 +207,12 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe |
| 207 | 207 | |
| 208 | 208 | fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void { |
| 209 | 209 | var mask: Word = 0; |
| 210 | inline for (@typeInfo(Operand).Struct.fields, 0..) |field, bit| { | |
| 210 | inline for (@typeInfo(Operand).@"struct".fields, 0..) |field, bit| { | |
| 211 | 211 | switch (@typeInfo(field.type)) { |
| 212 | .Optional => if (@field(operand, field.name) != null) { | |
| 212 | .optional => if (@field(operand, field.name) != null) { | |
| 213 | 213 | mask |= 1 << @as(u5, @intCast(bit)); |
| 214 | 214 | }, |
| 215 | .Bool => if (@field(operand, field.name)) { | |
| 215 | .bool => if (@field(operand, field.name)) { | |
| 216 | 216 | mask |= 1 << @as(u5, @intCast(bit)); |
| 217 | 217 | }, |
| 218 | 218 | else => unreachable, |
| ... | ... | @@ -221,12 +221,12 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand |
| 221 | 221 | |
| 222 | 222 | section.writeWord(mask); |
| 223 | 223 | |
| 224 | inline for (@typeInfo(Operand).Struct.fields) |field| { | |
| 224 | inline for (@typeInfo(Operand).@"struct".fields) |field| { | |
| 225 | 225 | switch (@typeInfo(field.type)) { |
| 226 | .Optional => |info| if (@field(operand, field.name)) |child| { | |
| 226 | .optional => |info| if (@field(operand, field.name)) |child| { | |
| 227 | 227 | section.writeOperands(info.child, child); |
| 228 | 228 | }, |
| 229 | .Bool => {}, | |
| 229 | .bool => {}, | |
| 230 | 230 | else => unreachable, |
| 231 | 231 | } |
| 232 | 232 | } |
| ... | ... | @@ -236,7 +236,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan |
| 236 | 236 | const tag = std.meta.activeTag(operand); |
| 237 | 237 | section.writeWord(@intFromEnum(tag)); |
| 238 | 238 | |
| 239 | inline for (@typeInfo(Operand).Union.fields) |field| { | |
| 239 | inline for (@typeInfo(Operand).@"union".fields) |field| { | |
| 240 | 240 | if (@field(Operand, field.name) == tag) { |
| 241 | 241 | section.writeOperands(field.type, @field(operand, field.name)); |
| 242 | 242 | return; |
| ... | ... | @@ -251,8 +251,8 @@ fn instructionSize(comptime opcode: spec.Opcode, operands: opcode.Operands()) us |
| 251 | 251 | |
| 252 | 252 | fn operandsSize(comptime Operands: type, operands: Operands) usize { |
| 253 | 253 | const fields = switch (@typeInfo(Operands)) { |
| 254 | .Struct => |info| info.fields, | |
| 255 | .Void => return 0, | |
| 254 | .@"struct" => |info| info.fields, | |
| 255 | .void => return 0, | |
| 256 | 256 | else => unreachable, |
| 257 | 257 | }; |
| 258 | 258 | |
| ... | ... | @@ -289,9 +289,9 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { |
| 289 | 289 | => 2, |
| 290 | 290 | |
| 291 | 291 | else => switch (@typeInfo(Operand)) { |
| 292 | .Enum => 1, | |
| 293 | .Optional => |info| if (operand) |child| operandSize(info.child, child) else 0, | |
| 294 | .Pointer => |info| blk: { | |
| 292 | .@"enum" => 1, | |
| 293 | .optional => |info| if (operand) |child| operandSize(info.child, child) else 0, | |
| 294 | .pointer => |info| blk: { | |
| 295 | 295 | std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec. |
| 296 | 296 | var total: usize = 0; |
| 297 | 297 | for (operand) |item| { |
| ... | ... | @@ -299,8 +299,8 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { |
| 299 | 299 | } |
| 300 | 300 | break :blk total; |
| 301 | 301 | }, |
| 302 | .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand), | |
| 303 | .Union => extendedUnionSize(Operand, operand), | |
| 302 | .@"struct" => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand), | |
| 303 | .@"union" => extendedUnionSize(Operand, operand), | |
| 304 | 304 | else => unreachable, |
| 305 | 305 | }, |
| 306 | 306 | }; |
| ... | ... | @@ -309,13 +309,13 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { |
| 309 | 309 | fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { |
| 310 | 310 | var total: usize = 0; |
| 311 | 311 | var any_set = false; |
| 312 | inline for (@typeInfo(Operand).Struct.fields) |field| { | |
| 312 | inline for (@typeInfo(Operand).@"struct".fields) |field| { | |
| 313 | 313 | switch (@typeInfo(field.type)) { |
| 314 | .Optional => |info| if (@field(operand, field.name)) |child| { | |
| 314 | .optional => |info| if (@field(operand, field.name)) |child| { | |
| 315 | 315 | total += operandsSize(info.child, child); |
| 316 | 316 | any_set = true; |
| 317 | 317 | }, |
| 318 | .Bool => if (@field(operand, field.name)) { | |
| 318 | .bool => if (@field(operand, field.name)) { | |
| 319 | 319 | any_set = true; |
| 320 | 320 | }, |
| 321 | 321 | else => unreachable, |
| ... | ... | @@ -326,7 +326,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { |
| 326 | 326 | |
| 327 | 327 | fn extendedUnionSize(comptime Operand: type, operand: Operand) usize { |
| 328 | 328 | const tag = std.meta.activeTag(operand); |
| 329 | inline for (@typeInfo(Operand).Union.fields) |field| { | |
| 329 | inline for (@typeInfo(Operand).@"union".fields) |field| { | |
| 330 | 330 | if (@field(Operand, field.name) == tag) { |
| 331 | 331 | // Add one for the tag itself. |
| 332 | 332 | return 1 + operandsSize(field.type, @field(operand, field.name)); |
src/link.zig+5-7| ... | ... | @@ -936,13 +936,11 @@ pub const File = struct { |
| 936 | 936 | missing_libc: bool = false, |
| 937 | 937 | |
| 938 | 938 | const Int = blk: { |
| 939 | const bits = @typeInfo(@This()).Struct.fields.len; | |
| 940 | break :blk @Type(.{ | |
| 941 | .Int = .{ | |
| 942 | .signedness = .unsigned, | |
| 943 | .bits = bits, | |
| 944 | }, | |
| 945 | }); | |
| 939 | const bits = @typeInfo(@This()).@"struct".fields.len; | |
| 940 | break :blk @Type(.{ .int = .{ | |
| 941 | .signedness = .unsigned, | |
| 942 | .bits = bits, | |
| 943 | } }); | |
| 946 | 944 | }; |
| 947 | 945 | |
| 948 | 946 | fn isSet(ef: ErrorFlags) bool { |
src/link/Coff.zig+1-1| ... | ... | @@ -1368,7 +1368,7 @@ fn getNavOutputSection(self: *Coff, nav_index: InternPool.Nav.Index) u16 { |
| 1368 | 1368 | |
| 1369 | 1369 | switch (zig_ty) { |
| 1370 | 1370 | // TODO: what if this is a function pointer? |
| 1371 | .Fn => break :blk self.text_section_index.?, | |
| 1371 | .@"fn" => break :blk self.text_section_index.?, | |
| 1372 | 1372 | else => { |
| 1373 | 1373 | if (val.getVariable(zcu)) |_| { |
| 1374 | 1374 | break :blk self.data_section_index.?; |
src/link/Dwarf.zig+18-10| ... | ... | @@ -1756,7 +1756,7 @@ pub const WipNav = struct { |
| 1756 | 1756 | var bit: usize = 0; |
| 1757 | 1757 | var carry: u1 = 1; |
| 1758 | 1758 | while (bit < bits) : (bit += 7) { |
| 1759 | const limb_bits = @typeInfo(std.math.big.Limb).Int.bits; | |
| 1759 | const limb_bits = @typeInfo(std.math.big.Limb).int.bits; | |
| 1760 | 1760 | const limb_index = bit / limb_bits; |
| 1761 | 1761 | const limb_shift: std.math.Log2Int(std.math.big.Limb) = @intCast(bit % limb_bits); |
| 1762 | 1762 | const low_abs_part: u7 = @truncate(big_int.limbs[limb_index] >> limb_shift); |
| ... | ... | @@ -2477,6 +2477,18 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2477 | 2477 | assert(file.zir_loaded); |
| 2478 | 2478 | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); |
| 2479 | 2479 | assert(decl_inst.tag == .declaration); |
| 2480 | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index); | |
| 2481 | ||
| 2482 | const is_test = switch (decl_extra.data.name) { | |
| 2483 | .unnamed_test, .decltest => true, | |
| 2484 | .@"comptime", .@"usingnamespace" => false, | |
| 2485 | _ => decl_extra.data.name.isNamedTest(file.zir), | |
| 2486 | }; | |
| 2487 | if (is_test) { | |
| 2488 | // This isn't actually a comptime Nav! It's a test, so it'll definitely never be referenced at comptime. | |
| 2489 | return; | |
| 2490 | } | |
| 2491 | ||
| 2480 | 2492 | const tree = try file.getTree(dwarf.gpa); |
| 2481 | 2493 | const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]); |
| 2482 | 2494 | assert(loc.line == zcu.navSrcLine(nav_index)); |
| ... | ... | @@ -2515,7 +2527,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2515 | 2527 | ) != abbrev_code_buf.len) return error.InputOutput; |
| 2516 | 2528 | var abbrev_code_fbs = std.io.fixedBufferStream(&abbrev_code_buf); |
| 2517 | 2529 | const abbrev_code: AbbrevCode = @enumFromInt( |
| 2518 | std.leb.readUleb128(@typeInfo(AbbrevCode).Enum.tag_type, abbrev_code_fbs.reader()) catch unreachable, | |
| 2530 | std.leb.readUleb128(@typeInfo(AbbrevCode).@"enum".tag_type, abbrev_code_fbs.reader()) catch unreachable, | |
| 2519 | 2531 | ); |
| 2520 | 2532 | switch (abbrev_code) { |
| 2521 | 2533 | else => unreachable, |
| ... | ... | @@ -2582,7 +2594,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2582 | 2594 | if (loaded_struct.zir_index == .none) break :decl_struct; |
| 2583 | 2595 | |
| 2584 | 2596 | const value_inst = value_inst: { |
| 2585 | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index); | |
| 2586 | 2597 | const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body; |
| 2587 | 2598 | const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1])); |
| 2588 | 2599 | if (break_inst.tag != .break_inline) break :value_inst null; |
| ... | ... | @@ -2704,7 +2715,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2704 | 2715 | if (loaded_enum.zir_index == .none) break :decl_enum; |
| 2705 | 2716 | |
| 2706 | 2717 | const value_inst = value_inst: { |
| 2707 | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index); | |
| 2708 | 2718 | const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body; |
| 2709 | 2719 | const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1])); |
| 2710 | 2720 | if (break_inst.tag != .break_inline) break :value_inst null; |
| ... | ... | @@ -2788,7 +2798,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2788 | 2798 | |
| 2789 | 2799 | decl_union: { |
| 2790 | 2800 | const value_inst = value_inst: { |
| 2791 | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index); | |
| 2792 | 2801 | const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body; |
| 2793 | 2802 | const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1])); |
| 2794 | 2803 | if (break_inst.tag != .break_inline) break :value_inst null; |
| ... | ... | @@ -2911,7 +2920,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2911 | 2920 | |
| 2912 | 2921 | decl_opaque: { |
| 2913 | 2922 | const value_inst = value_inst: { |
| 2914 | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index); | |
| 2915 | 2923 | const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body; |
| 2916 | 2924 | const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1])); |
| 2917 | 2925 | if (break_inst.tag != .break_inline) break :value_inst null; |
| ... | ... | @@ -3685,7 +3693,7 @@ pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void { |
| 3685 | 3693 | _ = nav_index; |
| 3686 | 3694 | } |
| 3687 | 3695 | |
| 3688 | fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(AbbrevCode).Enum.tag_type { | |
| 3696 | fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(AbbrevCode).@"enum".tag_type { | |
| 3689 | 3697 | assert(abbrev_code != .null); |
| 3690 | 3698 | const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code)); |
| 3691 | 3699 | if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code); |
| ... | ... | @@ -4087,7 +4095,7 @@ pub fn resolveRelocs(dwarf: *Dwarf) RelocError!void { |
| 4087 | 4095 | } |
| 4088 | 4096 | |
| 4089 | 4097 | fn DeclValEnum(comptime T: type) type { |
| 4090 | const decls = @typeInfo(T).Struct.decls; | |
| 4098 | const decls = @typeInfo(T).@"struct".decls; | |
| 4091 | 4099 | @setEvalBranchQuota(7 * decls.len); |
| 4092 | 4100 | var fields: [decls.len]std.builtin.Type.EnumField = undefined; |
| 4093 | 4101 | var fields_len = 0; |
| ... | ... | @@ -4101,7 +4109,7 @@ fn DeclValEnum(comptime T: type) type { |
| 4101 | 4109 | if (min_value == null or min_value.? > value) min_value = value; |
| 4102 | 4110 | if (max_value == null or max_value.? < value) max_value = value; |
| 4103 | 4111 | } |
| 4104 | return @Type(.{ .Enum = .{ | |
| 4112 | return @Type(.{ .@"enum" = .{ | |
| 4105 | 4113 | .tag_type = std.math.IntFittingRange(min_value orelse 0, max_value orelse 0), |
| 4106 | 4114 | .fields = fields[0..fields_len], |
| 4107 | 4115 | .decls = &.{}, |
| ... | ... | @@ -4665,7 +4673,7 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index { |
| 4665 | 4673 | |
| 4666 | 4674 | fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void { |
| 4667 | 4675 | switch (buf.len) { |
| 4668 | inline 0...8 => |len| std.mem.writeInt(@Type(.{ .Int = .{ | |
| 4676 | inline 0...8 => |len| std.mem.writeInt(@Type(.{ .int = .{ | |
| 4669 | 4677 | .signedness = .unsigned, |
| 4670 | 4678 | .bits = len * 8, |
| 4671 | 4679 | } }), buf[0..len], @intCast(int), dwarf.endian), |
src/link/Elf/Atom.zig+1-1| ... | ... | @@ -1008,7 +1008,7 @@ const AddExtraOpts = struct { |
| 1008 | 1008 | pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) void { |
| 1009 | 1009 | const file_ptr = atom.file(elf_file).?; |
| 1010 | 1010 | var extras = file_ptr.atomExtra(atom.extra_index); |
| 1011 | inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| { | |
| 1011 | inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| { | |
| 1012 | 1012 | if (@field(opts, field.name)) |x| { |
| 1013 | 1013 | @field(extras, field.name) = x; |
| 1014 | 1014 | } |
src/link/Elf/LdScript.zig+1-1| ... | ... | @@ -108,7 +108,7 @@ const Command = enum { |
| 108 | 108 | as_needed, |
| 109 | 109 | |
| 110 | 110 | fn fromString(s: []const u8) ?Command { |
| 111 | inline for (@typeInfo(Command).Enum.fields) |field| { | |
| 111 | inline for (@typeInfo(Command).@"enum".fields) |field| { | |
| 112 | 112 | const upper_name = n: { |
| 113 | 113 | comptime var buf: [field.name.len]u8 = undefined; |
| 114 | 114 | inline for (field.name, 0..) |c, i| { |
src/link/Elf/LinkerDefined.zig+4-4| ... | ... | @@ -394,14 +394,14 @@ fn addSymbolAssumeCapacity(self: *LinkerDefined) Symbol.Index { |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | pub fn addSymbolExtra(self: *LinkerDefined, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 397 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 397 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 398 | 398 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 399 | 399 | return self.addSymbolExtraAssumeCapacity(extra); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | pub fn addSymbolExtraAssumeCapacity(self: *LinkerDefined, extra: Symbol.Extra) u32 { |
| 403 | 403 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 404 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 404 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 405 | 405 | inline for (fields) |field| { |
| 406 | 406 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 407 | 407 | u32 => @field(extra, field.name), |
| ... | ... | @@ -412,7 +412,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *LinkerDefined, extra: Symbol.Extra) u |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | pub fn symbolExtra(self: *LinkerDefined, index: u32) Symbol.Extra { |
| 415 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 415 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 416 | 416 | var i: usize = index; |
| 417 | 417 | var result: Symbol.Extra = undefined; |
| 418 | 418 | inline for (fields) |field| { |
| ... | ... | @@ -426,7 +426,7 @@ pub fn symbolExtra(self: *LinkerDefined, index: u32) Symbol.Extra { |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | pub fn setSymbolExtra(self: *LinkerDefined, index: u32, extra: Symbol.Extra) void { |
| 429 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 429 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 430 | 430 | inline for (fields, 0..) |field, i| { |
| 431 | 431 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 432 | 432 | u32 => @field(extra, field.name), |
src/link/Elf/Object.zig+8-8| ... | ... | @@ -1215,14 +1215,14 @@ fn addSymbolAssumeCapacity(self: *Object) Symbol.Index { |
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | pub fn addSymbolExtra(self: *Object, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 1218 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1218 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1219 | 1219 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 1220 | 1220 | return self.addSymbolExtraAssumeCapacity(extra); |
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 { |
| 1224 | 1224 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 1225 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1225 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1226 | 1226 | inline for (fields) |field| { |
| 1227 | 1227 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 1228 | 1228 | u32 => @field(extra, field.name), |
| ... | ... | @@ -1233,7 +1233,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 { |
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | pub fn symbolExtra(self: *Object, index: u32) Symbol.Extra { |
| 1236 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1236 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1237 | 1237 | var i: usize = index; |
| 1238 | 1238 | var result: Symbol.Extra = undefined; |
| 1239 | 1239 | inline for (fields) |field| { |
| ... | ... | @@ -1247,7 +1247,7 @@ pub fn symbolExtra(self: *Object, index: u32) Symbol.Extra { |
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | pub fn setSymbolExtra(self: *Object, index: u32, extra: Symbol.Extra) void { |
| 1250 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1250 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1251 | 1251 | inline for (fields, 0..) |field, i| { |
| 1252 | 1252 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 1253 | 1253 | u32 => @field(extra, field.name), |
| ... | ... | @@ -1325,14 +1325,14 @@ pub fn atom(self: *Object, atom_index: Atom.Index) ?*Atom { |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | pub fn addAtomExtra(self: *Object, allocator: Allocator, extra: Atom.Extra) !u32 { |
| 1328 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1328 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1329 | 1329 | try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len); |
| 1330 | 1330 | return self.addAtomExtraAssumeCapacity(extra); |
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 { |
| 1334 | 1334 | const index = @as(u32, @intCast(self.atoms_extra.items.len)); |
| 1335 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1335 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1336 | 1336 | inline for (fields) |field| { |
| 1337 | 1337 | self.atoms_extra.appendAssumeCapacity(switch (field.type) { |
| 1338 | 1338 | u32 => @field(extra, field.name), |
| ... | ... | @@ -1343,7 +1343,7 @@ pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 { |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | pub fn atomExtra(self: *Object, index: u32) Atom.Extra { |
| 1346 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1346 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1347 | 1347 | var i: usize = index; |
| 1348 | 1348 | var result: Atom.Extra = undefined; |
| 1349 | 1349 | inline for (fields) |field| { |
| ... | ... | @@ -1357,7 +1357,7 @@ pub fn atomExtra(self: *Object, index: u32) Atom.Extra { |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | 1359 | pub fn setAtomExtra(self: *Object, index: u32, extra: Atom.Extra) void { |
| 1360 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1360 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1361 | 1361 | inline for (fields, 0..) |field, i| { |
| 1362 | 1362 | self.atoms_extra.items[index + i] = switch (field.type) { |
| 1363 | 1363 | u32 => @field(extra, field.name), |
src/link/Elf/SharedObject.zig+4-4| ... | ... | @@ -423,14 +423,14 @@ fn addSymbolAssumeCapacity(self: *SharedObject) Symbol.Index { |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | pub fn addSymbolExtra(self: *SharedObject, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 426 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 426 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 427 | 427 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 428 | 428 | return self.addSymbolExtraAssumeCapacity(extra); |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u32 { |
| 432 | 432 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 433 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 433 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 434 | 434 | inline for (fields) |field| { |
| 435 | 435 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 436 | 436 | u32 => @field(extra, field.name), |
| ... | ... | @@ -441,7 +441,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u3 |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | pub fn symbolExtra(self: *SharedObject, index: u32) Symbol.Extra { |
| 444 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 444 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 445 | 445 | var i: usize = index; |
| 446 | 446 | var result: Symbol.Extra = undefined; |
| 447 | 447 | inline for (fields) |field| { |
| ... | ... | @@ -455,7 +455,7 @@ pub fn symbolExtra(self: *SharedObject, index: u32) Symbol.Extra { |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void { |
| 458 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 458 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 459 | 459 | inline for (fields, 0..) |field, i| { |
| 460 | 460 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 461 | 461 | u32 => @field(extra, field.name), |
src/link/Elf/Symbol.zig+1-1| ... | ... | @@ -255,7 +255,7 @@ const AddExtraOpts = struct { |
| 255 | 255 | |
| 256 | 256 | pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, elf_file: *Elf) void { |
| 257 | 257 | var extras = symbol.extra(elf_file); |
| 258 | inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| { | |
| 258 | inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| { | |
| 259 | 259 | if (@field(opts, field.name)) |x| { |
| 260 | 260 | @field(extras, field.name) = x; |
| 261 | 261 | } |
src/link/Elf/ZigObject.zig+8-8| ... | ... | @@ -2034,14 +2034,14 @@ pub fn atom(self: *ZigObject, atom_index: Atom.Index) ?*Atom { |
| 2034 | 2034 | } |
| 2035 | 2035 | |
| 2036 | 2036 | fn addAtomExtra(self: *ZigObject, allocator: Allocator, extra: Atom.Extra) !u32 { |
| 2037 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2037 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2038 | 2038 | try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len); |
| 2039 | 2039 | return self.addAtomExtraAssumeCapacity(extra); |
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | 2042 | fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 { |
| 2043 | 2043 | const index = @as(u32, @intCast(self.atoms_extra.items.len)); |
| 2044 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2044 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2045 | 2045 | inline for (fields) |field| { |
| 2046 | 2046 | self.atoms_extra.appendAssumeCapacity(switch (field.type) { |
| 2047 | 2047 | u32 => @field(extra, field.name), |
| ... | ... | @@ -2052,7 +2052,7 @@ fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 { |
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | 2054 | pub fn atomExtra(self: ZigObject, index: u32) Atom.Extra { |
| 2055 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2055 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2056 | 2056 | var i: usize = index; |
| 2057 | 2057 | var result: Atom.Extra = undefined; |
| 2058 | 2058 | inline for (fields) |field| { |
| ... | ... | @@ -2067,7 +2067,7 @@ pub fn atomExtra(self: ZigObject, index: u32) Atom.Extra { |
| 2067 | 2067 | |
| 2068 | 2068 | pub fn setAtomExtra(self: *ZigObject, index: u32, extra: Atom.Extra) void { |
| 2069 | 2069 | assert(index > 0); |
| 2070 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2070 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2071 | 2071 | inline for (fields, 0..) |field, i| { |
| 2072 | 2072 | self.atoms_extra.items[index + i] = switch (field.type) { |
| 2073 | 2073 | u32 => @field(extra, field.name), |
| ... | ... | @@ -2106,14 +2106,14 @@ fn addSymbolAssumeCapacity(self: *ZigObject) Symbol.Index { |
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | 2108 | pub fn addSymbolExtra(self: *ZigObject, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 2109 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2109 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2110 | 2110 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 2111 | 2111 | return self.addSymbolExtraAssumeCapacity(extra); |
| 2112 | 2112 | } |
| 2113 | 2113 | |
| 2114 | 2114 | pub fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 { |
| 2115 | 2115 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 2116 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2116 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2117 | 2117 | inline for (fields) |field| { |
| 2118 | 2118 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 2119 | 2119 | u32 => @field(extra, field.name), |
| ... | ... | @@ -2124,7 +2124,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 { |
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | 2126 | pub fn symbolExtra(self: *ZigObject, index: u32) Symbol.Extra { |
| 2127 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2127 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2128 | 2128 | var i: usize = index; |
| 2129 | 2129 | var result: Symbol.Extra = undefined; |
| 2130 | 2130 | inline for (fields) |field| { |
| ... | ... | @@ -2138,7 +2138,7 @@ pub fn symbolExtra(self: *ZigObject, index: u32) Symbol.Extra { |
| 2138 | 2138 | } |
| 2139 | 2139 | |
| 2140 | 2140 | pub fn setSymbolExtra(self: *ZigObject, index: u32, extra: Symbol.Extra) void { |
| 2141 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2141 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2142 | 2142 | inline for (fields, 0..) |field, i| { |
| 2143 | 2143 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 2144 | 2144 | u32 => @field(extra, field.name), |
src/link/MachO/Archive.zig+1-1| ... | ... | @@ -90,7 +90,7 @@ pub fn writeHeader( |
| 90 | 90 | .ar_fmag = undefined, |
| 91 | 91 | }; |
| 92 | 92 | @memset(mem.asBytes(&hdr), 0x20); |
| 93 | inline for (@typeInfo(ar_hdr).Struct.fields) |field| { | |
| 93 | inline for (@typeInfo(ar_hdr).@"struct".fields) |field| { | |
| 94 | 94 | var stream = std.io.fixedBufferStream(&@field(hdr, field.name)); |
| 95 | 95 | stream.writer().print("0", .{}) catch unreachable; |
| 96 | 96 | } |
src/link/MachO/Atom.zig+1-1| ... | ... | @@ -129,7 +129,7 @@ const AddExtraOpts = struct { |
| 129 | 129 | pub fn addExtra(atom: *Atom, opts: AddExtraOpts, macho_file: *MachO) void { |
| 130 | 130 | const file = atom.getFile(macho_file); |
| 131 | 131 | var extra = file.getAtomExtra(atom.extra); |
| 132 | inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| { | |
| 132 | inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| { | |
| 133 | 133 | if (@field(opts, field.name)) |x| { |
| 134 | 134 | @field(extra, field.name) = x; |
| 135 | 135 | } |
src/link/MachO/Dylib.zig+4-4| ... | ... | @@ -650,14 +650,14 @@ pub fn getSymbolRef(self: Dylib, index: Symbol.Index, macho_file: *MachO) MachO. |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | pub fn addSymbolExtra(self: *Dylib, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 653 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 653 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 654 | 654 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 655 | 655 | return self.addSymbolExtraAssumeCapacity(extra); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | fn addSymbolExtraAssumeCapacity(self: *Dylib, extra: Symbol.Extra) u32 { |
| 659 | 659 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 660 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 660 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 661 | 661 | inline for (fields) |field| { |
| 662 | 662 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 663 | 663 | u32 => @field(extra, field.name), |
| ... | ... | @@ -668,7 +668,7 @@ fn addSymbolExtraAssumeCapacity(self: *Dylib, extra: Symbol.Extra) u32 { |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | pub fn getSymbolExtra(self: Dylib, index: u32) Symbol.Extra { |
| 671 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 671 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 672 | 672 | var i: usize = index; |
| 673 | 673 | var result: Symbol.Extra = undefined; |
| 674 | 674 | inline for (fields) |field| { |
| ... | ... | @@ -682,7 +682,7 @@ pub fn getSymbolExtra(self: Dylib, index: u32) Symbol.Extra { |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | pub fn setSymbolExtra(self: *Dylib, index: u32, extra: Symbol.Extra) void { |
| 685 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 685 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 686 | 686 | inline for (fields, 0..) |field, i| { |
| 687 | 687 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 688 | 688 | u32 => @field(extra, field.name), |
src/link/MachO/InternalObject.zig+8-8| ... | ... | @@ -669,14 +669,14 @@ pub fn getAtoms(self: InternalObject) []const Atom.Index { |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | fn addAtomExtra(self: *InternalObject, allocator: Allocator, extra: Atom.Extra) !u32 { |
| 672 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 672 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 673 | 673 | try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len); |
| 674 | 674 | return self.addAtomExtraAssumeCapacity(extra); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | fn addAtomExtraAssumeCapacity(self: *InternalObject, extra: Atom.Extra) u32 { |
| 678 | 678 | const index = @as(u32, @intCast(self.atoms_extra.items.len)); |
| 679 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 679 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 680 | 680 | inline for (fields) |field| { |
| 681 | 681 | self.atoms_extra.appendAssumeCapacity(switch (field.type) { |
| 682 | 682 | u32 => @field(extra, field.name), |
| ... | ... | @@ -687,7 +687,7 @@ fn addAtomExtraAssumeCapacity(self: *InternalObject, extra: Atom.Extra) u32 { |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | pub fn getAtomExtra(self: InternalObject, index: u32) Atom.Extra { |
| 690 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 690 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 691 | 691 | var i: usize = index; |
| 692 | 692 | var result: Atom.Extra = undefined; |
| 693 | 693 | inline for (fields) |field| { |
| ... | ... | @@ -702,7 +702,7 @@ pub fn getAtomExtra(self: InternalObject, index: u32) Atom.Extra { |
| 702 | 702 | |
| 703 | 703 | pub fn setAtomExtra(self: *InternalObject, index: u32, extra: Atom.Extra) void { |
| 704 | 704 | assert(index > 0); |
| 705 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 705 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 706 | 706 | inline for (fields, 0..) |field, i| { |
| 707 | 707 | self.atoms_extra.items[index + i] = switch (field.type) { |
| 708 | 708 | u32 => @field(extra, field.name), |
| ... | ... | @@ -750,14 +750,14 @@ pub fn getSymbolRef(self: InternalObject, index: Symbol.Index, macho_file: *Mach |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | pub fn addSymbolExtra(self: *InternalObject, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 753 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 753 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 754 | 754 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 755 | 755 | return self.addSymbolExtraAssumeCapacity(extra); |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra) u32 { |
| 759 | 759 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 760 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 760 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 761 | 761 | inline for (fields) |field| { |
| 762 | 762 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 763 | 763 | u32 => @field(extra, field.name), |
| ... | ... | @@ -768,7 +768,7 @@ fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra) u32 |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | pub fn getSymbolExtra(self: InternalObject, index: u32) Symbol.Extra { |
| 771 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 771 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 772 | 772 | var i: usize = index; |
| 773 | 773 | var result: Symbol.Extra = undefined; |
| 774 | 774 | inline for (fields) |field| { |
| ... | ... | @@ -782,7 +782,7 @@ pub fn getSymbolExtra(self: InternalObject, index: u32) Symbol.Extra { |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | pub fn setSymbolExtra(self: *InternalObject, index: u32, extra: Symbol.Extra) void { |
| 785 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 785 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 786 | 786 | inline for (fields, 0..) |field, i| { |
| 787 | 787 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 788 | 788 | u32 => @field(extra, field.name), |
src/link/MachO/Object.zig+8-8| ... | ... | @@ -2386,14 +2386,14 @@ pub fn getAtoms(self: *Object) []const Atom.Index { |
| 2386 | 2386 | } |
| 2387 | 2387 | |
| 2388 | 2388 | fn addAtomExtra(self: *Object, allocator: Allocator, extra: Atom.Extra) !u32 { |
| 2389 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2389 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2390 | 2390 | try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len); |
| 2391 | 2391 | return self.addAtomExtraAssumeCapacity(extra); |
| 2392 | 2392 | } |
| 2393 | 2393 | |
| 2394 | 2394 | fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 { |
| 2395 | 2395 | const index = @as(u32, @intCast(self.atoms_extra.items.len)); |
| 2396 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2396 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2397 | 2397 | inline for (fields) |field| { |
| 2398 | 2398 | self.atoms_extra.appendAssumeCapacity(switch (field.type) { |
| 2399 | 2399 | u32 => @field(extra, field.name), |
| ... | ... | @@ -2404,7 +2404,7 @@ fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 { |
| 2404 | 2404 | } |
| 2405 | 2405 | |
| 2406 | 2406 | pub fn getAtomExtra(self: Object, index: u32) Atom.Extra { |
| 2407 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2407 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2408 | 2408 | var i: usize = index; |
| 2409 | 2409 | var result: Atom.Extra = undefined; |
| 2410 | 2410 | inline for (fields) |field| { |
| ... | ... | @@ -2419,7 +2419,7 @@ pub fn getAtomExtra(self: Object, index: u32) Atom.Extra { |
| 2419 | 2419 | |
| 2420 | 2420 | pub fn setAtomExtra(self: *Object, index: u32, extra: Atom.Extra) void { |
| 2421 | 2421 | assert(index > 0); |
| 2422 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 2422 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 2423 | 2423 | inline for (fields, 0..) |field, i| { |
| 2424 | 2424 | self.atoms_extra.items[index + i] = switch (field.type) { |
| 2425 | 2425 | u32 => @field(extra, field.name), |
| ... | ... | @@ -2447,14 +2447,14 @@ pub fn getSymbolRef(self: Object, index: Symbol.Index, macho_file: *MachO) MachO |
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | pub fn addSymbolExtra(self: *Object, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 2450 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2450 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2451 | 2451 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 2452 | 2452 | return self.addSymbolExtraAssumeCapacity(extra); |
| 2453 | 2453 | } |
| 2454 | 2454 | |
| 2455 | 2455 | fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 { |
| 2456 | 2456 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 2457 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2457 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2458 | 2458 | inline for (fields) |field| { |
| 2459 | 2459 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 2460 | 2460 | u32 => @field(extra, field.name), |
| ... | ... | @@ -2465,7 +2465,7 @@ fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 { |
| 2465 | 2465 | } |
| 2466 | 2466 | |
| 2467 | 2467 | pub fn getSymbolExtra(self: Object, index: u32) Symbol.Extra { |
| 2468 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2468 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2469 | 2469 | var i: usize = index; |
| 2470 | 2470 | var result: Symbol.Extra = undefined; |
| 2471 | 2471 | inline for (fields) |field| { |
| ... | ... | @@ -2479,7 +2479,7 @@ pub fn getSymbolExtra(self: Object, index: u32) Symbol.Extra { |
| 2479 | 2479 | } |
| 2480 | 2480 | |
| 2481 | 2481 | pub fn setSymbolExtra(self: *Object, index: u32, extra: Symbol.Extra) void { |
| 2482 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 2482 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 2483 | 2483 | inline for (fields, 0..) |field, i| { |
| 2484 | 2484 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 2485 | 2485 | u32 => @field(extra, field.name), |
src/link/MachO/Symbol.zig+1-1| ... | ... | @@ -211,7 +211,7 @@ const AddExtraOpts = struct { |
| 211 | 211 | |
| 212 | 212 | pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, macho_file: *MachO) void { |
| 213 | 213 | var extra = symbol.getExtra(macho_file); |
| 214 | inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| { | |
| 214 | inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| { | |
| 215 | 215 | if (@field(opts, field.name)) |x| { |
| 216 | 216 | @field(extra, field.name) = x; |
| 217 | 217 | } |
src/link/MachO/ZigObject.zig+8-8| ... | ... | @@ -1581,14 +1581,14 @@ pub fn getAtoms(self: *ZigObject) []const Atom.Index { |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | 1583 | fn addAtomExtra(self: *ZigObject, allocator: Allocator, extra: Atom.Extra) !u32 { |
| 1584 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1584 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1585 | 1585 | try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len); |
| 1586 | 1586 | return self.addAtomExtraAssumeCapacity(extra); |
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 { |
| 1590 | 1590 | const index = @as(u32, @intCast(self.atoms_extra.items.len)); |
| 1591 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1591 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1592 | 1592 | inline for (fields) |field| { |
| 1593 | 1593 | self.atoms_extra.appendAssumeCapacity(switch (field.type) { |
| 1594 | 1594 | u32 => @field(extra, field.name), |
| ... | ... | @@ -1599,7 +1599,7 @@ fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 { |
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | pub fn getAtomExtra(self: ZigObject, index: u32) Atom.Extra { |
| 1602 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1602 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1603 | 1603 | var i: usize = index; |
| 1604 | 1604 | var result: Atom.Extra = undefined; |
| 1605 | 1605 | inline for (fields) |field| { |
| ... | ... | @@ -1614,7 +1614,7 @@ pub fn getAtomExtra(self: ZigObject, index: u32) Atom.Extra { |
| 1614 | 1614 | |
| 1615 | 1615 | pub fn setAtomExtra(self: *ZigObject, index: u32, extra: Atom.Extra) void { |
| 1616 | 1616 | assert(index > 0); |
| 1617 | const fields = @typeInfo(Atom.Extra).Struct.fields; | |
| 1617 | const fields = @typeInfo(Atom.Extra).@"struct".fields; | |
| 1618 | 1618 | inline for (fields, 0..) |field, i| { |
| 1619 | 1619 | self.atoms_extra.items[index + i] = switch (field.type) { |
| 1620 | 1620 | u32 => @field(extra, field.name), |
| ... | ... | @@ -1642,14 +1642,14 @@ pub fn getSymbolRef(self: ZigObject, index: Symbol.Index, macho_file: *MachO) Ma |
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | 1644 | pub fn addSymbolExtra(self: *ZigObject, allocator: Allocator, extra: Symbol.Extra) !u32 { |
| 1645 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1645 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1646 | 1646 | try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len); |
| 1647 | 1647 | return self.addSymbolExtraAssumeCapacity(extra); |
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | 1650 | fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 { |
| 1651 | 1651 | const index = @as(u32, @intCast(self.symbols_extra.items.len)); |
| 1652 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1652 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1653 | 1653 | inline for (fields) |field| { |
| 1654 | 1654 | self.symbols_extra.appendAssumeCapacity(switch (field.type) { |
| 1655 | 1655 | u32 => @field(extra, field.name), |
| ... | ... | @@ -1660,7 +1660,7 @@ fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 { |
| 1660 | 1660 | } |
| 1661 | 1661 | |
| 1662 | 1662 | pub fn getSymbolExtra(self: ZigObject, index: u32) Symbol.Extra { |
| 1663 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1663 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1664 | 1664 | var i: usize = index; |
| 1665 | 1665 | var result: Symbol.Extra = undefined; |
| 1666 | 1666 | inline for (fields) |field| { |
| ... | ... | @@ -1674,7 +1674,7 @@ pub fn getSymbolExtra(self: ZigObject, index: u32) Symbol.Extra { |
| 1674 | 1674 | } |
| 1675 | 1675 | |
| 1676 | 1676 | pub fn setSymbolExtra(self: *ZigObject, index: u32, extra: Symbol.Extra) void { |
| 1677 | const fields = @typeInfo(Symbol.Extra).Struct.fields; | |
| 1677 | const fields = @typeInfo(Symbol.Extra).@"struct".fields; | |
| 1678 | 1678 | inline for (fields, 0..) |field, i| { |
| 1679 | 1679 | self.symbols_extra.items[index + i] = switch (field.type) { |
| 1680 | 1680 | u32 => @field(extra, field.name), |
src/link/Wasm.zig+6-6| ... | ... | @@ -1169,7 +1169,7 @@ fn setupTLSRelocationsFunction(wasm: *Wasm) !void { |
| 1169 | 1169 | |
| 1170 | 1170 | fn validateFeatures( |
| 1171 | 1171 | wasm: *const Wasm, |
| 1172 | to_emit: *[@typeInfo(types.Feature.Tag).Enum.fields.len]bool, | |
| 1172 | to_emit: *[@typeInfo(types.Feature.Tag).@"enum".fields.len]bool, | |
| 1173 | 1173 | emit_features_count: *u32, |
| 1174 | 1174 | ) !void { |
| 1175 | 1175 | const comp = wasm.base.comp; |
| ... | ... | @@ -1177,7 +1177,7 @@ fn validateFeatures( |
| 1177 | 1177 | const shared_memory = comp.config.shared_memory; |
| 1178 | 1178 | const cpu_features = target.cpu.features; |
| 1179 | 1179 | const infer = cpu_features.isEmpty(); // when the user did not define any features, we infer them from linked objects. |
| 1180 | const known_features_count = @typeInfo(types.Feature.Tag).Enum.fields.len; | |
| 1180 | const known_features_count = @typeInfo(types.Feature.Tag).@"enum".fields.len; | |
| 1181 | 1181 | |
| 1182 | 1182 | var allowed = [_]bool{false} ** known_features_count; |
| 1183 | 1183 | var used = [_]u17{0} ** known_features_count; |
| ... | ... | @@ -1192,7 +1192,7 @@ fn validateFeatures( |
| 1192 | 1192 | // When the user has given an explicit list of features to enable, |
| 1193 | 1193 | // we extract them and insert each into the 'allowed' list. |
| 1194 | 1194 | if (!infer) { |
| 1195 | inline for (@typeInfo(std.Target.wasm.Feature).Enum.fields) |feature_field| { | |
| 1195 | inline for (@typeInfo(std.Target.wasm.Feature).@"enum".fields) |feature_field| { | |
| 1196 | 1196 | if (cpu_features.isEnabled(feature_field.value)) { |
| 1197 | 1197 | allowed[feature_field.value] = true; |
| 1198 | 1198 | emit_features_count.* += 1; |
| ... | ... | @@ -2576,7 +2576,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 2576 | 2576 | if (wasm.base.hasErrors()) return error.FlushFailure; |
| 2577 | 2577 | |
| 2578 | 2578 | var emit_features_count: u32 = 0; |
| 2579 | var enabled_features: [@typeInfo(types.Feature.Tag).Enum.fields.len]bool = undefined; | |
| 2579 | var enabled_features: [@typeInfo(types.Feature.Tag).@"enum".fields.len]bool = undefined; | |
| 2580 | 2580 | try wasm.validateFeatures(&enabled_features, &emit_features_count); |
| 2581 | 2581 | try wasm.resolveSymbolsInArchives(); |
| 2582 | 2582 | if (wasm.base.hasErrors()) return error.FlushFailure; |
| ... | ... | @@ -2610,7 +2610,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 2610 | 2610 | /// Writes the WebAssembly in-memory module to the file |
| 2611 | 2611 | fn writeToFile( |
| 2612 | 2612 | wasm: *Wasm, |
| 2613 | enabled_features: [@typeInfo(types.Feature.Tag).Enum.fields.len]bool, | |
| 2613 | enabled_features: [@typeInfo(types.Feature.Tag).@"enum".fields.len]bool, | |
| 2614 | 2614 | feature_count: u32, |
| 2615 | 2615 | arena: Allocator, |
| 2616 | 2616 | ) !void { |
| ... | ... | @@ -3867,7 +3867,7 @@ fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void { |
| 3867 | 3867 | |
| 3868 | 3868 | pub fn getUleb128Size(uint_value: anytype) u32 { |
| 3869 | 3869 | const T = @TypeOf(uint_value); |
| 3870 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; | |
| 3870 | const U = if (@typeInfo(T).int.bits < 8) u8 else T; | |
| 3871 | 3871 | var value = @as(U, @intCast(uint_value)); |
| 3872 | 3872 | |
| 3873 | 3873 | var size: u32 = 0; |
src/link/Wasm/Object.zig+2-2| ... | ... | @@ -871,7 +871,7 @@ fn ElementType(comptime ptr: type) type { |
| 871 | 871 | /// signedness of the given type `T`. |
| 872 | 872 | /// Asserts `T` is an integer. |
| 873 | 873 | fn readLeb(comptime T: type, reader: anytype) !T { |
| 874 | return switch (@typeInfo(T).Int.signedness) { | |
| 874 | return switch (@typeInfo(T).int.signedness) { | |
| 875 | 875 | .signed => try leb.readIleb128(T, reader), |
| 876 | 876 | .unsigned => try leb.readUleb128(T, reader), |
| 877 | 877 | }; |
| ... | ... | @@ -881,7 +881,7 @@ fn readLeb(comptime T: type, reader: anytype) !T { |
| 881 | 881 | /// Asserts `T` is an enum |
| 882 | 882 | fn readEnum(comptime T: type, reader: anytype) !T { |
| 883 | 883 | switch (@typeInfo(T)) { |
| 884 | .Enum => |enum_type| return @as(T, @enumFromInt(try readLeb(enum_type.tag_type, reader))), | |
| 884 | .@"enum" => |enum_type| return @as(T, @enumFromInt(try readLeb(enum_type.tag_type, reader))), | |
| 885 | 885 | else => @compileError("T must be an enum. Instead was given type " ++ @typeName(T)), |
| 886 | 886 | } |
| 887 | 887 | } |
src/link/Wasm/ZigObject.zig+1-1| ... | ... | @@ -805,7 +805,7 @@ pub fn getUavVAddr( |
| 805 | 805 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 806 | 806 | const zcu = wasm_file.base.comp.zcu.?; |
| 807 | 807 | const ty = Type.fromInterned(zcu.intern_pool.typeOf(uav)); |
| 808 | if (ty.zigTypeTag(zcu) == .Fn) { | |
| 808 | if (ty.zigTypeTag(zcu) == .@"fn") { | |
| 809 | 809 | std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations |
| 810 | 810 | try parent_atom.relocs.append(gpa, .{ |
| 811 | 811 | .index = target_symbol_index, |
src/link/riscv.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ pub fn writeSetSub6(comptime op: enum { set, sub }, code: *[1]u8, addend: anytyp |
| 12 | 12 | pub fn writeAddend( |
| 13 | 13 | comptime Int: type, |
| 14 | 14 | comptime op: enum { add, sub }, |
| 15 | code: *[@typeInfo(Int).Int.bits / 8]u8, | |
| 15 | code: *[@typeInfo(Int).int.bits / 8]u8, | |
| 16 | 16 | value: anytype, |
| 17 | 17 | ) void { |
| 18 | 18 | var V: Int = mem.readInt(Int, code, .little); |
src/link/tapi/yaml.zig+28-28| ... | ... | @@ -204,13 +204,13 @@ pub const Value = union(enum) { |
| 204 | 204 | |
| 205 | 205 | fn encode(arena: Allocator, input: anytype) YamlError!?Value { |
| 206 | 206 | switch (@typeInfo(@TypeOf(input))) { |
| 207 | .ComptimeInt, | |
| 208 | .Int, | |
| 207 | .comptime_int, | |
| 208 | .int, | |
| 209 | 209 | => return Value{ .int = math.cast(i64, input) orelse return error.Overflow }, |
| 210 | 210 | |
| 211 | .Float => return Value{ .float = math.lossyCast(f64, input) }, | |
| 211 | .float => return Value{ .float = math.lossyCast(f64, input) }, | |
| 212 | 212 | |
| 213 | .Struct => |info| if (info.is_tuple) { | |
| 213 | .@"struct" => |info| if (info.is_tuple) { | |
| 214 | 214 | var list = std.ArrayList(Value).init(arena); |
| 215 | 215 | errdefer list.deinit(); |
| 216 | 216 | try list.ensureTotalCapacityPrecise(info.fields.len); |
| ... | ... | @@ -237,7 +237,7 @@ pub const Value = union(enum) { |
| 237 | 237 | return Value{ .map = map }; |
| 238 | 238 | }, |
| 239 | 239 | |
| 240 | .Union => |info| if (info.tag_type) |tag_type| { | |
| 240 | .@"union" => |info| if (info.tag_type) |tag_type| { | |
| 241 | 241 | inline for (info.fields) |field| { |
| 242 | 242 | if (@field(tag_type, field.name) == input) { |
| 243 | 243 | return try encode(arena, @field(input, field.name)); |
| ... | ... | @@ -245,11 +245,11 @@ pub const Value = union(enum) { |
| 245 | 245 | } else unreachable; |
| 246 | 246 | } else return error.UntaggedUnion, |
| 247 | 247 | |
| 248 | .Array => return encode(arena, &input), | |
| 248 | .array => return encode(arena, &input), | |
| 249 | 249 | |
| 250 | .Pointer => |info| switch (info.size) { | |
| 250 | .pointer => |info| switch (info.size) { | |
| 251 | 251 | .One => switch (@typeInfo(info.child)) { |
| 252 | .Array => |child_info| { | |
| 252 | .array => |child_info| { | |
| 253 | 253 | const Slice = []const child_info.child; |
| 254 | 254 | return encode(arena, @as(Slice, input)); |
| 255 | 255 | }, |
| ... | ... | @@ -284,9 +284,9 @@ pub const Value = union(enum) { |
| 284 | 284 | |
| 285 | 285 | // TODO we should probably have an option to encode `null` and also |
| 286 | 286 | // allow for some default value too. |
| 287 | .Optional => return if (input) |val| encode(arena, val) else null, | |
| 287 | .optional => return if (input) |val| encode(arena, val) else null, | |
| 288 | 288 | |
| 289 | .Null => return null, | |
| 289 | .null => return null, | |
| 290 | 290 | |
| 291 | 291 | else => { |
| 292 | 292 | @compileError("Unhandled type: {s}" ++ @typeName(@TypeOf(input))); |
| ... | ... | @@ -339,7 +339,7 @@ pub const Yaml = struct { |
| 339 | 339 | |
| 340 | 340 | pub fn parse(self: *Yaml, comptime T: type) Error!T { |
| 341 | 341 | if (self.docs.items.len == 0) { |
| 342 | if (@typeInfo(T) == .Void) return {}; | |
| 342 | if (@typeInfo(T) == .void) return {}; | |
| 343 | 343 | return error.TypeMismatch; |
| 344 | 344 | } |
| 345 | 345 | |
| ... | ... | @@ -348,14 +348,14 @@ pub const Yaml = struct { |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | switch (@typeInfo(T)) { |
| 351 | .Array => |info| { | |
| 351 | .array => |info| { | |
| 352 | 352 | var parsed: T = undefined; |
| 353 | 353 | for (self.docs.items, 0..) |doc, i| { |
| 354 | 354 | parsed[i] = try self.parseValue(info.child, doc); |
| 355 | 355 | } |
| 356 | 356 | return parsed; |
| 357 | 357 | }, |
| 358 | .Pointer => |info| { | |
| 358 | .pointer => |info| { | |
| 359 | 359 | switch (info.size) { |
| 360 | 360 | .Slice => { |
| 361 | 361 | var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len); |
| ... | ... | @@ -367,35 +367,35 @@ pub const Yaml = struct { |
| 367 | 367 | else => return error.TypeMismatch, |
| 368 | 368 | } |
| 369 | 369 | }, |
| 370 | .Union => return error.Unimplemented, | |
| 370 | .@"union" => return error.Unimplemented, | |
| 371 | 371 | else => return error.TypeMismatch, |
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | fn parseValue(self: *Yaml, comptime T: type, value: Value) Error!T { |
| 376 | 376 | return switch (@typeInfo(T)) { |
| 377 | .Int => math.cast(T, try value.asInt()) orelse return error.Overflow, | |
| 378 | .Float => if (value.asFloat()) |float| { | |
| 377 | .int => math.cast(T, try value.asInt()) orelse return error.Overflow, | |
| 378 | .float => if (value.asFloat()) |float| { | |
| 379 | 379 | return math.lossyCast(T, float); |
| 380 | 380 | } else |_| { |
| 381 | 381 | return math.lossyCast(T, try value.asInt()); |
| 382 | 382 | }, |
| 383 | .Struct => self.parseStruct(T, try value.asMap()), | |
| 384 | .Union => self.parseUnion(T, value), | |
| 385 | .Array => self.parseArray(T, try value.asList()), | |
| 386 | .Pointer => if (value.asList()) |list| { | |
| 383 | .@"struct" => self.parseStruct(T, try value.asMap()), | |
| 384 | .@"union" => self.parseUnion(T, value), | |
| 385 | .array => self.parseArray(T, try value.asList()), | |
| 386 | .pointer => if (value.asList()) |list| { | |
| 387 | 387 | return self.parsePointer(T, .{ .list = list }); |
| 388 | 388 | } else |_| { |
| 389 | 389 | return self.parsePointer(T, .{ .string = try value.asString() }); |
| 390 | 390 | }, |
| 391 | .Void => error.TypeMismatch, | |
| 392 | .Optional => unreachable, | |
| 391 | .void => error.TypeMismatch, | |
| 392 | .optional => unreachable, | |
| 393 | 393 | else => error.Unimplemented, |
| 394 | 394 | }; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | fn parseUnion(self: *Yaml, comptime T: type, value: Value) Error!T { |
| 398 | const union_info = @typeInfo(T).Union; | |
| 398 | const union_info = @typeInfo(T).@"union"; | |
| 399 | 399 | |
| 400 | 400 | if (union_info.tag_type) |_| { |
| 401 | 401 | inline for (union_info.fields) |field| { |
| ... | ... | @@ -412,12 +412,12 @@ pub const Yaml = struct { |
| 412 | 412 | |
| 413 | 413 | fn parseOptional(self: *Yaml, comptime T: type, value: ?Value) Error!T { |
| 414 | 414 | const unwrapped = value orelse return null; |
| 415 | const opt_info = @typeInfo(T).Optional; | |
| 415 | const opt_info = @typeInfo(T).optional; | |
| 416 | 416 | return @as(T, try self.parseValue(opt_info.child, unwrapped)); |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | fn parseStruct(self: *Yaml, comptime T: type, map: Map) Error!T { |
| 420 | const struct_info = @typeInfo(T).Struct; | |
| 420 | const struct_info = @typeInfo(T).@"struct"; | |
| 421 | 421 | var parsed: T = undefined; |
| 422 | 422 | |
| 423 | 423 | inline for (struct_info.fields) |field| { |
| ... | ... | @@ -426,7 +426,7 @@ pub const Yaml = struct { |
| 426 | 426 | break :blk map.get(field_name); |
| 427 | 427 | }; |
| 428 | 428 | |
| 429 | if (@typeInfo(field.type) == .Optional) { | |
| 429 | if (@typeInfo(field.type) == .optional) { | |
| 430 | 430 | @field(parsed, field.name) = try self.parseOptional(field.type, value); |
| 431 | 431 | continue; |
| 432 | 432 | } |
| ... | ... | @@ -442,7 +442,7 @@ pub const Yaml = struct { |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | fn parsePointer(self: *Yaml, comptime T: type, value: Value) Error!T { |
| 445 | const ptr_info = @typeInfo(T).Pointer; | |
| 445 | const ptr_info = @typeInfo(T).pointer; | |
| 446 | 446 | const arena = self.arena.allocator(); |
| 447 | 447 | |
| 448 | 448 | switch (ptr_info.size) { |
| ... | ... | @@ -462,7 +462,7 @@ pub const Yaml = struct { |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | fn parseArray(self: *Yaml, comptime T: type, list: List) Error!T { |
| 465 | const array_info = @typeInfo(T).Array; | |
| 465 | const array_info = @typeInfo(T).array; | |
| 466 | 466 | if (array_info.len != list.len) return error.ArraySizeMismatch; |
| 467 | 467 | |
| 468 | 468 | var parsed: T = undefined; |
src/main.zig+2-2| ... | ... | @@ -130,7 +130,7 @@ var log_scopes: std.ArrayListUnmanaged([]const u8) = .{}; |
| 130 | 130 | |
| 131 | 131 | pub fn log( |
| 132 | 132 | comptime level: std.log.Level, |
| 133 | comptime scope: @TypeOf(.EnumLiteral), | |
| 133 | comptime scope: @Type(.enum_literal), | |
| 134 | 134 | comptime format: []const u8, |
| 135 | 135 | args: anytype, |
| 136 | 136 | ) void { |
| ... | ... | @@ -5315,7 +5315,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 5315 | 5315 | var any_errors = false; |
| 5316 | 5316 | while (it.next()) |hash| { |
| 5317 | 5317 | if (hash.len == 0) continue; |
| 5318 | const digest_len = @typeInfo(Package.Manifest.MultiHashHexDigest).Array.len; | |
| 5318 | const digest_len = @typeInfo(Package.Manifest.MultiHashHexDigest).array.len; | |
| 5319 | 5319 | if (hash.len != digest_len) { |
| 5320 | 5320 | std.log.err("invalid digest (length {d} instead of {d}): '{s}'", .{ |
| 5321 | 5321 | hash.len, digest_len, hash, |
src/mutable_value.zig+12-12| ... | ... | @@ -210,19 +210,19 @@ pub const MutableValue = union(enum) { |
| 210 | 210 | }, |
| 211 | 211 | }, |
| 212 | 212 | .undef => |ty_ip| switch (Type.fromInterned(ty_ip).zigTypeTag(zcu)) { |
| 213 | .Struct, .Array, .Vector => |type_tag| { | |
| 213 | .@"struct", .array, .vector => |type_tag| { | |
| 214 | 214 | const ty = Type.fromInterned(ty_ip); |
| 215 | 215 | const opt_sent = ty.sentinel(zcu); |
| 216 | if (type_tag == .Struct or opt_sent != null or !allow_repeated) { | |
| 216 | if (type_tag == .@"struct" or opt_sent != null or !allow_repeated) { | |
| 217 | 217 | const len_no_sent = ip.aggregateTypeLen(ty_ip); |
| 218 | 218 | const elems = try arena.alloc(MutableValue, @intCast(len_no_sent + @intFromBool(opt_sent != null))); |
| 219 | 219 | switch (type_tag) { |
| 220 | .Array, .Vector => { | |
| 220 | .array, .vector => { | |
| 221 | 221 | const elem_ty = ip.childType(ty_ip); |
| 222 | 222 | const undef_elem = try pt.intern(.{ .undef = elem_ty }); |
| 223 | 223 | @memset(elems[0..@intCast(len_no_sent)], .{ .interned = undef_elem }); |
| 224 | 224 | }, |
| 225 | .Struct => for (elems[0..@intCast(len_no_sent)], 0..) |*mut_elem, i| { | |
| 225 | .@"struct" => for (elems[0..@intCast(len_no_sent)], 0..) |*mut_elem, i| { | |
| 226 | 226 | const field_ty = ty.fieldType(i, zcu).toIntern(); |
| 227 | 227 | mut_elem.* = .{ .interned = try pt.intern(.{ .undef = field_ty }) }; |
| 228 | 228 | }, |
| ... | ... | @@ -244,7 +244,7 @@ pub const MutableValue = union(enum) { |
| 244 | 244 | } }; |
| 245 | 245 | } |
| 246 | 246 | }, |
| 247 | .Union => { | |
| 247 | .@"union" => { | |
| 248 | 248 | const payload = try arena.create(MutableValue); |
| 249 | 249 | const backing_ty = try Type.fromInterned(ty_ip).unionBackingType(pt); |
| 250 | 250 | payload.* = .{ .interned = try pt.intern(.{ .undef = backing_ty.toIntern() }) }; |
| ... | ... | @@ -254,7 +254,7 @@ pub const MutableValue = union(enum) { |
| 254 | 254 | .payload = payload, |
| 255 | 255 | } }; |
| 256 | 256 | }, |
| 257 | .Pointer => { | |
| 257 | .pointer => { | |
| 258 | 258 | const ptr_ty = ip.indexToKey(ty_ip).ptr_type; |
| 259 | 259 | if (ptr_ty.flags.size != .Slice) return; |
| 260 | 260 | const ptr = try arena.create(MutableValue); |
| ... | ... | @@ -375,7 +375,7 @@ pub const MutableValue = union(enum) { |
| 375 | 375 | if (field_val.eqlTrivial(r.child.*)) return; |
| 376 | 376 | // We must switch to either the `aggregate` or the `bytes` representation. |
| 377 | 377 | const len_inc_sent = ip.aggregateTypeLenIncludingSentinel(r.ty); |
| 378 | if (Type.fromInterned(r.ty).zigTypeTag(zcu) != .Struct and | |
| 378 | if (Type.fromInterned(r.ty).zigTypeTag(zcu) != .@"struct" and | |
| 379 | 379 | is_trivial_int and |
| 380 | 380 | Type.fromInterned(r.ty).childType(zcu).toIntern() == .u8_type and |
| 381 | 381 | r.child.isTrivialInt(zcu)) |
| ... | ... | @@ -402,7 +402,7 @@ pub const MutableValue = union(enum) { |
| 402 | 402 | }, |
| 403 | 403 | .aggregate => |a| { |
| 404 | 404 | a.elems[field_idx] = field_val; |
| 405 | const is_struct = Type.fromInterned(a.ty).zigTypeTag(zcu) == .Struct; | |
| 405 | const is_struct = Type.fromInterned(a.ty).zigTypeTag(zcu) == .@"struct"; | |
| 406 | 406 | // Attempt to switch to a more efficient representation. |
| 407 | 407 | const is_repeated = for (a.elems) |e| { |
| 408 | 408 | if (!e.eqlTrivial(field_val)) break false; |
| ... | ... | @@ -457,9 +457,9 @@ pub const MutableValue = union(enum) { |
| 457 | 457 | .interned => |ip_index| { |
| 458 | 458 | const ty = Type.fromInterned(pt.zcu.intern_pool.typeOf(ip_index)); |
| 459 | 459 | switch (ty.zigTypeTag(pt.zcu)) { |
| 460 | .Array, .Vector => return .{ .interned = (try Value.fromInterned(ip_index).elemValue(pt, field_idx)).toIntern() }, | |
| 461 | .Struct, .Union => return .{ .interned = (try Value.fromInterned(ip_index).fieldValue(pt, field_idx)).toIntern() }, | |
| 462 | .Pointer => { | |
| 460 | .array, .vector => return .{ .interned = (try Value.fromInterned(ip_index).elemValue(pt, field_idx)).toIntern() }, | |
| 461 | .@"struct", .@"union" => return .{ .interned = (try Value.fromInterned(ip_index).fieldValue(pt, field_idx)).toIntern() }, | |
| 462 | .pointer => { | |
| 463 | 463 | assert(ty.isSlice(pt.zcu)); |
| 464 | 464 | return switch (field_idx) { |
| 465 | 465 | Value.slice_ptr_index => .{ .interned = Value.fromInterned(ip_index).slicePtr(pt.zcu).toIntern() }, |
| ... | ... | @@ -551,7 +551,7 @@ pub const MutableValue = union(enum) { |
| 551 | 551 | /// Used for deciding when to switch aggregate representations without fully |
| 552 | 552 | /// interning many values. |
| 553 | 553 | fn eqlTrivial(a: MutableValue, b: MutableValue) bool { |
| 554 | const Tag = @typeInfo(MutableValue).Union.tag_type.?; | |
| 554 | const Tag = @typeInfo(MutableValue).@"union".tag_type.?; | |
| 555 | 555 | if (@as(Tag, a) != @as(Tag, b)) return false; |
| 556 | 556 | return switch (a) { |
| 557 | 557 | .interned => |a_ip| a_ip == b.interned, |
src/print_env.zig+1-1| ... | ... | @@ -47,7 +47,7 @@ pub fn cmdEnv(arena: Allocator, args: []const []const u8, stdout: std.fs.File.Wr |
| 47 | 47 | |
| 48 | 48 | try jws.objectField("env"); |
| 49 | 49 | try jws.beginObject(); |
| 50 | inline for (@typeInfo(std.zig.EnvVar).Enum.fields) |field| { | |
| 50 | inline for (@typeInfo(std.zig.EnvVar).@"enum".fields) |field| { | |
| 51 | 51 | try jws.objectField(field.name); |
| 52 | 52 | try jws.write(try @field(std.zig.EnvVar, field.name).get(arena)); |
| 53 | 53 | } |
src/print_value.zig+6-6| ... | ... | @@ -207,7 +207,7 @@ fn printAggregate( |
| 207 | 207 | const ip = &zcu.intern_pool; |
| 208 | 208 | const ty = Type.fromInterned(aggregate.ty); |
| 209 | 209 | switch (ty.zigTypeTag(zcu)) { |
| 210 | .Struct => if (!ty.isTuple(zcu)) { | |
| 210 | .@"struct" => if (!ty.isTuple(zcu)) { | |
| 211 | 211 | if (is_ref) try writer.writeByte('&'); |
| 212 | 212 | if (ty.structFieldCount(zcu) == 0) { |
| 213 | 213 | return writer.writeAll(".{}"); |
| ... | ... | @@ -223,7 +223,7 @@ fn printAggregate( |
| 223 | 223 | try writer.writeAll(" }"); |
| 224 | 224 | return; |
| 225 | 225 | }, |
| 226 | .Array => { | |
| 226 | .array => { | |
| 227 | 227 | switch (aggregate.storage) { |
| 228 | 228 | .bytes => |bytes| string: { |
| 229 | 229 | const len = ty.arrayLenIncludingSentinel(zcu); |
| ... | ... | @@ -253,7 +253,7 @@ fn printAggregate( |
| 253 | 253 | else => {}, |
| 254 | 254 | } |
| 255 | 255 | }, |
| 256 | .Vector => if (ty.arrayLen(zcu) == 0) { | |
| 256 | .vector => if (ty.arrayLen(zcu) == 0) { | |
| 257 | 257 | if (is_ref) try writer.writeByte('&'); |
| 258 | 258 | return writer.writeAll(".{}"); |
| 259 | 259 | }, |
| ... | ... | @@ -362,17 +362,17 @@ fn printPtrDerivation( |
| 362 | 362 | try printPtrDerivation(field.parent.*, writer, level, pt, have_sema, sema); |
| 363 | 363 | const agg_ty = (try field.parent.ptrType(pt)).childType(zcu); |
| 364 | 364 | switch (agg_ty.zigTypeTag(zcu)) { |
| 365 | .Struct => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| { | |
| 365 | .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| { | |
| 366 | 366 | try writer.print(".{i}", .{field_name.fmt(ip)}); |
| 367 | 367 | } else { |
| 368 | 368 | try writer.print("[{d}]", .{field.field_idx}); |
| 369 | 369 | }, |
| 370 | .Union => { | |
| 370 | .@"union" => { | |
| 371 | 371 | const tag_ty = agg_ty.unionTagTypeHypothetical(zcu); |
| 372 | 372 | const field_name = tag_ty.enumFieldName(field.field_idx, zcu); |
| 373 | 373 | try writer.print(".{i}", .{field_name.fmt(ip)}); |
| 374 | 374 | }, |
| 375 | .Pointer => switch (field.field_idx) { | |
| 375 | .pointer => switch (field.field_idx) { | |
| 376 | 376 | Value.slice_ptr_index => try writer.writeAll(".ptr"), |
| 377 | 377 | Value.slice_len_index => try writer.writeAll(".len"), |
| 378 | 378 | else => unreachable, |
src/print_zir.zig+3-3| ... | ... | @@ -907,7 +907,7 @@ const Writer = struct { |
| 907 | 907 | |
| 908 | 908 | fn writeFieldParentPtr(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { |
| 909 | 909 | const extra = self.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data; |
| 910 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; | |
| 910 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | |
| 911 | 911 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 912 | 912 | if (flags.align_cast) try stream.writeAll("align_cast, "); |
| 913 | 913 | if (flags.addrspace_cast) try stream.writeAll("addrspace_cast, "); |
| ... | ... | @@ -1065,7 +1065,7 @@ const Writer = struct { |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | fn writePtrCastFull(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { |
| 1068 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; | |
| 1068 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | |
| 1069 | 1069 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 1070 | 1070 | const extra = self.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 1071 | 1071 | if (flags.ptr_cast) try stream.writeAll("ptr_cast, "); |
| ... | ... | @@ -1081,7 +1081,7 @@ const Writer = struct { |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | fn writePtrCastNoDest(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { |
| 1084 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; | |
| 1084 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | |
| 1085 | 1085 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 1086 | 1086 | const extra = self.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 1087 | 1087 | if (flags.const_cast) try stream.writeAll("const_cast, "); |
src/translate_c.zig+4-4| ... | ... | @@ -161,7 +161,7 @@ pub fn translate( |
| 161 | 161 | context.pattern_list.deinit(gpa); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | inline for (@typeInfo(std.zig.c_builtins).Struct.decls) |decl| { | |
| 164 | inline for (@typeInfo(std.zig.c_builtins).@"struct".decls) |decl| { | |
| 165 | 165 | const builtin = try Tag.pub_var_simple.create(arena, .{ |
| 166 | 166 | .name = decl.name, |
| 167 | 167 | .init = try Tag.import_c_builtin.create(arena, decl.name), |
| ... | ... | @@ -1324,7 +1324,7 @@ fn makeShuffleMask(c: *Context, scope: *Scope, expr: *const clang.ShuffleVectorE |
| 1324 | 1324 | fn vectorTypeInfo(arena: mem.Allocator, vec_node: Node, field: []const u8) TransError!Node { |
| 1325 | 1325 | const typeof_call = try Tag.typeof.create(arena, vec_node); |
| 1326 | 1326 | const typeinfo_call = try Tag.typeinfo.create(arena, typeof_call); |
| 1327 | const vector_type_info = try Tag.field_access.create(arena, .{ .lhs = typeinfo_call, .field_name = "Vector" }); | |
| 1327 | const vector_type_info = try Tag.field_access.create(arena, .{ .lhs = typeinfo_call, .field_name = "vector" }); | |
| 1328 | 1328 | return Tag.field_access.create(arena, .{ .lhs = vector_type_info, .field_name = field }); |
| 1329 | 1329 | } |
| 1330 | 1330 | |
| ... | ... | @@ -2008,7 +2008,7 @@ fn transImplicitCastExpr( |
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | 2010 | fn isBuiltinDefined(name: []const u8) bool { |
| 2011 | inline for (@typeInfo(std.zig.c_builtins).Struct.decls) |decl| { | |
| 2011 | inline for (@typeInfo(std.zig.c_builtins).@"struct".decls) |decl| { | |
| 2012 | 2012 | if (std.mem.eql(u8, name, decl.name)) return true; |
| 2013 | 2013 | } |
| 2014 | 2014 | return false; |
| ... | ... | @@ -4655,7 +4655,7 @@ fn transCreateNodeAPInt(c: *Context, int: *const clang.APSInt) !Node { |
| 4655 | 4655 | |
| 4656 | 4656 | fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float }) !Node { |
| 4657 | 4657 | const fmt_s = switch (@typeInfo(@TypeOf(num))) { |
| 4658 | .Int, .ComptimeInt => "{d}", | |
| 4658 | .int, .comptime_int => "{d}", | |
| 4659 | 4659 | else => "{s}", |
| 4660 | 4660 | }; |
| 4661 | 4661 | const str = try std.fmt.allocPrint(c.arena, fmt_s, .{num}); |
test/behavior/abs.zig+1-1| ... | ... | @@ -104,7 +104,7 @@ test "@abs big int <= 128 bits" { |
| 104 | 104 | try testAbsUnsignedBigInt(); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | fn abs(comptime T: type, a: T) std.meta.Int(.unsigned, @typeInfo(T).Int.bits) { | |
| 107 | fn abs(comptime T: type, a: T) std.meta.Int(.unsigned, @typeInfo(T).int.bits) { | |
| 108 | 108 | return @abs(a); |
| 109 | 109 | } |
| 110 | 110 |
test/behavior/align.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ const assert = std.debug.assert; |
| 7 | 7 | var foo: u8 align(4) = 100; |
| 8 | 8 | |
| 9 | 9 | test "global variable alignment" { |
| 10 | comptime assert(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4); | |
| 10 | comptime assert(@typeInfo(@TypeOf(&foo)).pointer.alignment == 4); | |
| 11 | 11 | comptime assert(@TypeOf(&foo) == *align(4) u8); |
| 12 | 12 | { |
| 13 | 13 | const slice = @as(*align(4) [1]u8, &foo)[0..]; |
test/behavior/async_fn.zig+3-3| ... | ... | @@ -391,7 +391,7 @@ test "async fn with inferred error set" { |
| 391 | 391 | var frame: [1]@Frame(middle) = undefined; |
| 392 | 392 | var fn_ptr = middle; |
| 393 | 393 | _ = &fn_ptr; |
| 394 | var result: @typeInfo(@typeInfo(@TypeOf(fn_ptr)).Fn.return_type.?).ErrorUnion.error_set!void = undefined; | |
| 394 | var result: @typeInfo(@typeInfo(@TypeOf(fn_ptr)).@"fn".return_type.?).error_union.error_set!void = undefined; | |
| 395 | 395 | _ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, fn_ptr, .{}); |
| 396 | 396 | resume global_frame; |
| 397 | 397 | try std.testing.expectError(error.Fail, result); |
| ... | ... | @@ -1088,7 +1088,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" { |
| 1088 | 1088 | |
| 1089 | 1089 | fn doTheTest() !void { |
| 1090 | 1090 | var frame: [1]@Frame(middle) = undefined; |
| 1091 | var result: @typeInfo(@typeInfo(@TypeOf(middle)).Fn.return_type.?).ErrorUnion.error_set!void = undefined; | |
| 1091 | var result: @typeInfo(@typeInfo(@TypeOf(middle)).@"fn".return_type.?).error_union.error_set!void = undefined; | |
| 1092 | 1092 | _ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, middle, .{}); |
| 1093 | 1093 | resume global_frame; |
| 1094 | 1094 | try std.testing.expectError(error.Fail, result); |
| ... | ... | @@ -1166,7 +1166,7 @@ test "@TypeOf an async function call of generic fn with error union type" { |
| 1166 | 1166 | const S = struct { |
| 1167 | 1167 | fn func(comptime x: anytype) anyerror!i32 { |
| 1168 | 1168 | const T = @TypeOf(async func(x)); |
| 1169 | comptime assert(T == @typeInfo(@TypeOf(@frame())).Pointer.child); | |
| 1169 | comptime assert(T == @typeInfo(@TypeOf(@frame())).pointer.child); | |
| 1170 | 1170 | return undefined; |
| 1171 | 1171 | } |
| 1172 | 1172 | }; |
test/behavior/atomics.zig+1-1| ... | ... | @@ -414,7 +414,7 @@ fn testAtomicsWithType(comptime T: type, a: T, b: T) !void { |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | fn testAtomicsWithPackedStruct(comptime T: type, a: T, b: T) !void { |
| 417 | const BackingInt = @typeInfo(T).Struct.backing_integer.?; | |
| 417 | const BackingInt = @typeInfo(T).@"struct".backing_integer.?; | |
| 418 | 418 | var x: T = b; |
| 419 | 419 | @atomicStore(T, &x, a, .seq_cst); |
| 420 | 420 | try expect(@as(BackingInt, @bitCast(x)) == @as(BackingInt, @bitCast(a))); |
test/behavior/basic.zig+5-5| ... | ... | @@ -1193,7 +1193,7 @@ test "pointer to struct literal with runtime field is constant" { |
| 1193 | 1193 | var runtime_zero: usize = 0; |
| 1194 | 1194 | _ = &runtime_zero; |
| 1195 | 1195 | const ptr = &S{ .data = runtime_zero }; |
| 1196 | try expect(@typeInfo(@TypeOf(ptr)).Pointer.is_const); | |
| 1196 | try expect(@typeInfo(@TypeOf(ptr)).pointer.is_const); | |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | fn testSignedCmp(comptime T: type) !void { |
| ... | ... | @@ -1289,7 +1289,7 @@ test "reference to inferred local variable works as expected" { |
| 1289 | 1289 | |
| 1290 | 1290 | test "@Type returned from block" { |
| 1291 | 1291 | const T = comptime b: { |
| 1292 | break :b @Type(.{ .Int = .{ | |
| 1292 | break :b @Type(.{ .int = .{ | |
| 1293 | 1293 | .signedness = .unsigned, |
| 1294 | 1294 | .bits = 8, |
| 1295 | 1295 | } }); |
| ... | ... | @@ -1304,7 +1304,7 @@ test "comptime variable initialized with addresses of literals" { |
| 1304 | 1304 | }; |
| 1305 | 1305 | _ = &st; |
| 1306 | 1306 | |
| 1307 | inline for (@typeInfo(@TypeOf(st)).Struct.fields) |field| { | |
| 1307 | inline for (@typeInfo(@TypeOf(st)).@"struct".fields) |field| { | |
| 1308 | 1308 | _ = field; |
| 1309 | 1309 | } |
| 1310 | 1310 | } |
| ... | ... | @@ -1321,12 +1321,12 @@ test "proper value is returned from labeled block" { |
| 1321 | 1321 | const S = struct { |
| 1322 | 1322 | fn hash(v: *u32, key: anytype) void { |
| 1323 | 1323 | const Key = @TypeOf(key); |
| 1324 | if (@typeInfo(Key) == .ErrorSet) { | |
| 1324 | if (@typeInfo(Key) == .error_set) { | |
| 1325 | 1325 | v.* += 1; |
| 1326 | 1326 | return; |
| 1327 | 1327 | } |
| 1328 | 1328 | switch (@typeInfo(Key)) { |
| 1329 | .ErrorUnion => blk: { | |
| 1329 | .error_union => blk: { | |
| 1330 | 1330 | const payload = key catch |err| { |
| 1331 | 1331 | hash(v, err); |
| 1332 | 1332 | break :blk; |
test/behavior/bit_shifting.zig+3-3| ... | ... | @@ -3,7 +3,7 @@ const expect = std.testing.expect; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | 4 | |
| 5 | 5 | fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type { |
| 6 | const key_bits = @typeInfo(Key).Int.bits; | |
| 6 | const key_bits = @typeInfo(Key).int.bits; | |
| 7 | 7 | std.debug.assert(Key == std.meta.Int(.unsigned, key_bits)); |
| 8 | 8 | std.debug.assert(key_bits >= mask_bit_count); |
| 9 | 9 | const shard_key_bits = mask_bit_count; |
| ... | ... | @@ -120,11 +120,11 @@ test "Saturating Shift Left where lhs is of a computed type" { |
| 120 | 120 | |
| 121 | 121 | const S = struct { |
| 122 | 122 | fn getIntShiftType(comptime T: type) type { |
| 123 | var unsigned_shift_type = @typeInfo(std.math.Log2Int(T)).Int; | |
| 123 | var unsigned_shift_type = @typeInfo(std.math.Log2Int(T)).int; | |
| 124 | 124 | unsigned_shift_type.signedness = .signed; |
| 125 | 125 | |
| 126 | 126 | return @Type(.{ |
| 127 | .Int = unsigned_shift_type, | |
| 127 | .int = unsigned_shift_type, | |
| 128 | 128 | }); |
| 129 | 129 | } |
| 130 | 130 |
test/behavior/bitcast.zig+2-2| ... | ... | @@ -361,7 +361,7 @@ test "comptime @bitCast packed struct to int and back" { |
| 361 | 361 | vectori: @Vector(2, u8) = .{ 127, 42 }, |
| 362 | 362 | vectorf: @Vector(2, f16) = .{ 3.14, 2.71 }, |
| 363 | 363 | }; |
| 364 | const Int = @typeInfo(S).Struct.backing_integer.?; | |
| 364 | const Int = @typeInfo(S).@"struct".backing_integer.?; | |
| 365 | 365 | |
| 366 | 366 | // S -> Int |
| 367 | 367 | var s: S = .{}; |
| ... | ... | @@ -373,7 +373,7 @@ test "comptime @bitCast packed struct to int and back" { |
| 373 | 373 | _ = &i; |
| 374 | 374 | const rt_cast = @as(S, @bitCast(i)); |
| 375 | 375 | const ct_cast = comptime @as(S, @bitCast(@as(Int, 0))); |
| 376 | inline for (@typeInfo(S).Struct.fields) |field| { | |
| 376 | inline for (@typeInfo(S).@"struct".fields) |field| { | |
| 377 | 377 | try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name)); |
| 378 | 378 | } |
| 379 | 379 | } |
test/behavior/call.zig+3-3| ... | ... | @@ -374,7 +374,7 @@ test "Enum constructed by @Type passed as generic argument" { |
| 374 | 374 | try expect(@intFromEnum(a) == b); |
| 375 | 375 | } |
| 376 | 376 | }; |
| 377 | inline for (@typeInfo(S.E).Enum.fields, 0..) |_, i| { | |
| 377 | inline for (@typeInfo(S.E).@"enum".fields, 0..) |_, i| { | |
| 378 | 378 | try S.foo(@as(S.E, @enumFromInt(i)), i); |
| 379 | 379 | } |
| 380 | 380 | } |
| ... | ... | @@ -578,11 +578,11 @@ test "generic function pointer can be called" { |
| 578 | 578 | test "value returned from comptime function is comptime known" { |
| 579 | 579 | const S = struct { |
| 580 | 580 | fn fields(comptime T: type) switch (@typeInfo(T)) { |
| 581 | .Struct => []const std.builtin.Type.StructField, | |
| 581 | .@"struct" => []const std.builtin.Type.StructField, | |
| 582 | 582 | else => unreachable, |
| 583 | 583 | } { |
| 584 | 584 | return switch (@typeInfo(T)) { |
| 585 | .Struct => |info| info.fields, | |
| 585 | .@"struct" => |info| info.fields, | |
| 586 | 586 | else => unreachable, |
| 587 | 587 | }; |
| 588 | 588 | } |
test/behavior/cast.zig+44-44| ... | ... | @@ -704,20 +704,20 @@ test "peer type resolution: error set supersets" { |
| 704 | 704 | { |
| 705 | 705 | const ty = @TypeOf(a, b); |
| 706 | 706 | const error_set_info = @typeInfo(ty); |
| 707 | try expect(error_set_info == .ErrorSet); | |
| 708 | try expect(error_set_info.ErrorSet.?.len == 2); | |
| 709 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 710 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 707 | try expect(error_set_info == .error_set); | |
| 708 | try expect(error_set_info.error_set.?.len == 2); | |
| 709 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 710 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | // B superset of A |
| 714 | 714 | { |
| 715 | 715 | const ty = @TypeOf(b, a); |
| 716 | 716 | const error_set_info = @typeInfo(ty); |
| 717 | try expect(error_set_info == .ErrorSet); | |
| 718 | try expect(error_set_info.ErrorSet.?.len == 2); | |
| 719 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 720 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 717 | try expect(error_set_info == .error_set); | |
| 718 | try expect(error_set_info.error_set.?.len == 2); | |
| 719 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 720 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 721 | 721 | } |
| 722 | 722 | } |
| 723 | 723 | |
| ... | ... | @@ -732,21 +732,21 @@ test "peer type resolution: disjoint error sets" { |
| 732 | 732 | { |
| 733 | 733 | const ty = @TypeOf(a, b); |
| 734 | 734 | const error_set_info = @typeInfo(ty); |
| 735 | try expect(error_set_info == .ErrorSet); | |
| 736 | try expect(error_set_info.ErrorSet.?.len == 3); | |
| 737 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 738 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 739 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three")); | |
| 735 | try expect(error_set_info == .error_set); | |
| 736 | try expect(error_set_info.error_set.?.len == 3); | |
| 737 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 738 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 739 | try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three")); | |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | { |
| 743 | 743 | const ty = @TypeOf(b, a); |
| 744 | 744 | const error_set_info = @typeInfo(ty); |
| 745 | try expect(error_set_info == .ErrorSet); | |
| 746 | try expect(error_set_info.ErrorSet.?.len == 3); | |
| 747 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 748 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 749 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three")); | |
| 745 | try expect(error_set_info == .error_set); | |
| 746 | try expect(error_set_info.error_set.?.len == 3); | |
| 747 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 748 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 749 | try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three")); | |
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | |
| ... | ... | @@ -762,25 +762,25 @@ test "peer type resolution: error union and error set" { |
| 762 | 762 | { |
| 763 | 763 | const ty = @TypeOf(a, b); |
| 764 | 764 | const info = @typeInfo(ty); |
| 765 | try expect(info == .ErrorUnion); | |
| 765 | try expect(info == .error_union); | |
| 766 | 766 | |
| 767 | const error_set_info = @typeInfo(info.ErrorUnion.error_set); | |
| 768 | try expect(error_set_info.ErrorSet.?.len == 3); | |
| 769 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 770 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 771 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three")); | |
| 767 | const error_set_info = @typeInfo(info.error_union.error_set); | |
| 768 | try expect(error_set_info.error_set.?.len == 3); | |
| 769 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 770 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 771 | try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three")); | |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | { |
| 775 | 775 | const ty = @TypeOf(b, a); |
| 776 | 776 | const info = @typeInfo(ty); |
| 777 | try expect(info == .ErrorUnion); | |
| 777 | try expect(info == .error_union); | |
| 778 | 778 | |
| 779 | const error_set_info = @typeInfo(info.ErrorUnion.error_set); | |
| 780 | try expect(error_set_info.ErrorSet.?.len == 3); | |
| 781 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 782 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 783 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three")); | |
| 779 | const error_set_info = @typeInfo(info.error_union.error_set); | |
| 780 | try expect(error_set_info.error_set.?.len == 3); | |
| 781 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 782 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 783 | try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three")); | |
| 784 | 784 | } |
| 785 | 785 | } |
| 786 | 786 | |
| ... | ... | @@ -795,25 +795,25 @@ test "peer type resolution: error union after non-error" { |
| 795 | 795 | { |
| 796 | 796 | const ty = @TypeOf(a, b); |
| 797 | 797 | const info = @typeInfo(ty); |
| 798 | try expect(info == .ErrorUnion); | |
| 799 | try expect(info.ErrorUnion.payload == u32); | |
| 798 | try expect(info == .error_union); | |
| 799 | try expect(info.error_union.payload == u32); | |
| 800 | 800 | |
| 801 | const error_set_info = @typeInfo(info.ErrorUnion.error_set); | |
| 802 | try expect(error_set_info.ErrorSet.?.len == 2); | |
| 803 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 804 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 801 | const error_set_info = @typeInfo(info.error_union.error_set); | |
| 802 | try expect(error_set_info.error_set.?.len == 2); | |
| 803 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 804 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | { |
| 808 | 808 | const ty = @TypeOf(b, a); |
| 809 | 809 | const info = @typeInfo(ty); |
| 810 | try expect(info == .ErrorUnion); | |
| 811 | try expect(info.ErrorUnion.payload == u32); | |
| 810 | try expect(info == .error_union); | |
| 811 | try expect(info.error_union.payload == u32); | |
| 812 | 812 | |
| 813 | const error_set_info = @typeInfo(info.ErrorUnion.error_set); | |
| 814 | try expect(error_set_info.ErrorSet.?.len == 2); | |
| 815 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 816 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 813 | const error_set_info = @typeInfo(info.error_union.error_set); | |
| 814 | try expect(error_set_info.error_set.?.len == 2); | |
| 815 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 816 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | |
| ... | ... | @@ -1484,7 +1484,7 @@ test "coerce between pointers of compatible differently-named floats" { |
| 1484 | 1484 | return error.SkipZigTest; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | const F = switch (@typeInfo(c_longdouble).Float.bits) { | |
| 1487 | const F = switch (@typeInfo(c_longdouble).float.bits) { | |
| 1488 | 1488 | 16 => f16, |
| 1489 | 1489 | 32 => f32, |
| 1490 | 1490 | 64 => f64, |
| ... | ... | @@ -2151,7 +2151,7 @@ test "peer type resolution: tuples with comptime fields" { |
| 2151 | 2151 | const ti1 = @typeInfo(@TypeOf(a, b)); |
| 2152 | 2152 | const ti2 = @typeInfo(@TypeOf(b, a)); |
| 2153 | 2153 | inline for (.{ ti1, ti2 }) |ti| { |
| 2154 | const s = ti.Struct; | |
| 2154 | const s = ti.@"struct"; | |
| 2155 | 2155 | comptime assert(s.is_tuple); |
| 2156 | 2156 | comptime assert(s.fields.len == 2); |
| 2157 | 2157 | comptime assert(s.fields[0].type == u32); |
test/behavior/comptime_memory.zig+1-1| ... | ... | @@ -119,7 +119,7 @@ fn shuffle(ptr: usize, comptime From: type, comptime To: type) usize { |
| 119 | 119 | const pResult = @as(*align(1) [array_len]To, @ptrCast(&result)); |
| 120 | 120 | var i: usize = 0; |
| 121 | 121 | while (i < array_len) : (i += 1) { |
| 122 | inline for (@typeInfo(To).Struct.fields) |f| { | |
| 122 | inline for (@typeInfo(To).@"struct".fields) |f| { | |
| 123 | 123 | @field(pResult[i], f.name) = @field(pSource[i], f.name); |
| 124 | 124 | } |
| 125 | 125 | } |
test/behavior/empty_tuple_fields.zig+6-6| ... | ... | @@ -9,9 +9,9 @@ test "empty file level struct" { |
| 9 | 9 | |
| 10 | 10 | const T = @import("empty_file_level_struct.zig"); |
| 11 | 11 | const info = @typeInfo(T); |
| 12 | try std.testing.expectEqual(@as(usize, 1), info.Struct.fields.len); | |
| 13 | try std.testing.expectEqualStrings("0", info.Struct.fields[0].name); | |
| 14 | try std.testing.expect(@typeInfo(info.Struct.fields[0].type) == .Struct); | |
| 12 | try std.testing.expectEqual(@as(usize, 1), info.@"struct".fields.len); | |
| 13 | try std.testing.expectEqualStrings("0", info.@"struct".fields[0].name); | |
| 14 | try std.testing.expect(@typeInfo(info.@"struct".fields[0].type) == .@"struct"); | |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | test "empty file level union" { |
| ... | ... | @@ -22,7 +22,7 @@ test "empty file level union" { |
| 22 | 22 | |
| 23 | 23 | const T = @import("empty_file_level_union.zig"); |
| 24 | 24 | const info = @typeInfo(T); |
| 25 | try std.testing.expectEqual(@as(usize, 1), info.Struct.fields.len); | |
| 26 | try std.testing.expectEqualStrings("0", info.Struct.fields[0].name); | |
| 27 | try std.testing.expect(@typeInfo(info.Struct.fields[0].type) == .Union); | |
| 25 | try std.testing.expectEqual(@as(usize, 1), info.@"struct".fields.len); | |
| 26 | try std.testing.expectEqualStrings("0", info.@"struct".fields[0].name); | |
| 27 | try std.testing.expect(@typeInfo(info.@"struct".fields[0].type) == .@"union"); | |
| 28 | 28 | } |
test/behavior/enum.zig+8-8| ... | ... | @@ -647,12 +647,12 @@ test "non-exhaustive enum" { |
| 647 | 647 | else => true, |
| 648 | 648 | }); |
| 649 | 649 | |
| 650 | try expect(@typeInfo(E).Enum.fields.len == 2); | |
| 650 | try expect(@typeInfo(E).@"enum".fields.len == 2); | |
| 651 | 651 | e = @as(E, @enumFromInt(12)); |
| 652 | 652 | try expect(@intFromEnum(e) == 12); |
| 653 | 653 | e = @as(E, @enumFromInt(y)); |
| 654 | 654 | try expect(@intFromEnum(e) == 52); |
| 655 | try expect(@typeInfo(E).Enum.is_exhaustive == false); | |
| 655 | try expect(@typeInfo(E).@"enum".is_exhaustive == false); | |
| 656 | 656 | } |
| 657 | 657 | }; |
| 658 | 658 | try S.doTheTest(52); |
| ... | ... | @@ -671,8 +671,8 @@ test "empty non-exhaustive enum" { |
| 671 | 671 | }); |
| 672 | 672 | try expect(@intFromEnum(e) == y); |
| 673 | 673 | |
| 674 | try expect(@typeInfo(E).Enum.fields.len == 0); | |
| 675 | try expect(@typeInfo(E).Enum.is_exhaustive == false); | |
| 674 | try expect(@typeInfo(E).@"enum".fields.len == 0); | |
| 675 | try expect(@typeInfo(E).@"enum".is_exhaustive == false); | |
| 676 | 676 | } |
| 677 | 677 | }; |
| 678 | 678 | try S.doTheTest(42); |
| ... | ... | @@ -708,8 +708,8 @@ test "single field non-exhaustive enum" { |
| 708 | 708 | }); |
| 709 | 709 | |
| 710 | 710 | try expect(@intFromEnum(@as(E, @enumFromInt(y))) == y); |
| 711 | try expect(@typeInfo(E).Enum.fields.len == 1); | |
| 712 | try expect(@typeInfo(E).Enum.is_exhaustive == false); | |
| 711 | try expect(@typeInfo(E).@"enum".fields.len == 1); | |
| 712 | try expect(@typeInfo(E).@"enum".is_exhaustive == false); | |
| 713 | 713 | } |
| 714 | 714 | }; |
| 715 | 715 | try S.doTheTest(23); |
| ... | ... | @@ -1253,9 +1253,9 @@ test "Non-exhaustive enum backed by comptime_int" { |
| 1253 | 1253 | test "matching captures causes enum equivalence" { |
| 1254 | 1254 | const S = struct { |
| 1255 | 1255 | fn Nonexhaustive(comptime I: type) type { |
| 1256 | const UTag = @Type(.{ .Int = .{ | |
| 1256 | const UTag = @Type(.{ .int = .{ | |
| 1257 | 1257 | .signedness = .unsigned, |
| 1258 | .bits = @typeInfo(I).Int.bits, | |
| 1258 | .bits = @typeInfo(I).int.bits, | |
| 1259 | 1259 | } }); |
| 1260 | 1260 | return enum(UTag) { _ }; |
| 1261 | 1261 | } |
test/behavior/error.zig+8-8| ... | ... | @@ -188,9 +188,9 @@ test "error union type " { |
| 188 | 188 | fn testErrorUnionType() !void { |
| 189 | 189 | const x: anyerror!i32 = 1234; |
| 190 | 190 | if (x) |value| try expect(value == 1234) else |_| unreachable; |
| 191 | try expect(@typeInfo(@TypeOf(x)) == .ErrorUnion); | |
| 192 | try expect(@typeInfo(@typeInfo(@TypeOf(x)).ErrorUnion.error_set) == .ErrorSet); | |
| 193 | try expect(@typeInfo(@TypeOf(x)).ErrorUnion.error_set == anyerror); | |
| 191 | try expect(@typeInfo(@TypeOf(x)) == .error_union); | |
| 192 | try expect(@typeInfo(@typeInfo(@TypeOf(x)).error_union.error_set) == .error_set); | |
| 193 | try expect(@typeInfo(@TypeOf(x)).error_union.error_set == anyerror); | |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | test "error set type" { |
| ... | ... | @@ -204,7 +204,7 @@ const MyErrSet = error{ |
| 204 | 204 | }; |
| 205 | 205 | |
| 206 | 206 | fn testErrorSetType() !void { |
| 207 | try expect(@typeInfo(MyErrSet).ErrorSet.?.len == 2); | |
| 207 | try expect(@typeInfo(MyErrSet).error_set.?.len == 2); | |
| 208 | 208 | |
| 209 | 209 | const a: MyErrSet!i32 = 5678; |
| 210 | 210 | const b: MyErrSet!i32 = MyErrSet.OutOfMemory; |
| ... | ... | @@ -653,9 +653,9 @@ test "inferred error set equality" { |
| 653 | 653 | fn quux() anyerror!void {} |
| 654 | 654 | }; |
| 655 | 655 | |
| 656 | const FooError = @typeInfo(@typeInfo(@TypeOf(S.foo)).Fn.return_type.?).ErrorUnion.error_set; | |
| 657 | const BarError = @typeInfo(@typeInfo(@TypeOf(S.bar)).Fn.return_type.?).ErrorUnion.error_set; | |
| 658 | const BazError = @typeInfo(@typeInfo(@TypeOf(S.baz)).Fn.return_type.?).ErrorUnion.error_set; | |
| 656 | const FooError = @typeInfo(@typeInfo(@TypeOf(S.foo)).@"fn".return_type.?).error_union.error_set; | |
| 657 | const BarError = @typeInfo(@typeInfo(@TypeOf(S.bar)).@"fn".return_type.?).error_union.error_set; | |
| 658 | const BazError = @typeInfo(@typeInfo(@TypeOf(S.baz)).@"fn".return_type.?).error_union.error_set; | |
| 659 | 659 | |
| 660 | 660 | try expect(BarError != error{Bad}); |
| 661 | 661 | |
| ... | ... | @@ -1040,7 +1040,7 @@ test "generic type constructed from inferred error set of unresolved function" { |
| 1040 | 1040 | _ = bytes; |
| 1041 | 1041 | return 0; |
| 1042 | 1042 | } |
| 1043 | const T = std.io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write); | |
| 1043 | const T = std.io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).@"fn".return_type.?).error_union.error_set, write); | |
| 1044 | 1044 | fn writer() T { |
| 1045 | 1045 | return .{ .context = {} }; |
| 1046 | 1046 | } |
test/behavior/eval.zig+2-2| ... | ... | @@ -538,7 +538,7 @@ test "@tagName of @typeInfo" { |
| 538 | 538 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 539 | 539 | |
| 540 | 540 | const str = @tagName(@typeInfo(u8)); |
| 541 | try expect(std.mem.eql(u8, str, "Int")); | |
| 541 | try expect(std.mem.eql(u8, str, "int")); | |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | test "static eval list init" { |
| ... | ... | @@ -951,7 +951,7 @@ test "const local with comptime init through array init" { |
| 951 | 951 | |
| 952 | 952 | const S = struct { |
| 953 | 953 | fn declarations(comptime T: type) []const std.builtin.Type.Declaration { |
| 954 | return @typeInfo(T).Enum.decls; | |
| 954 | return @typeInfo(T).@"enum".decls; | |
| 955 | 955 | } |
| 956 | 956 | }; |
| 957 | 957 |
test/behavior/export_self_referential_type_info.zig+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | export const self_referential_type_info: c_int = @intFromBool(@typeInfo(@This()).Struct.is_tuple); | |
| 1 | export const self_referential_type_info: c_int = @intFromBool(@typeInfo(@This()).@"struct".is_tuple); |
test/behavior/fn.zig+5-5| ... | ... | @@ -393,7 +393,7 @@ test "ability to give comptime types and non comptime types to same parameter" { |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | fn foo(arg: anytype) i32 { |
| 396 | if (@typeInfo(@TypeOf(arg)) == .Type and arg == i32) return 20; | |
| 396 | if (@typeInfo(@TypeOf(arg)) == .type and arg == i32) return 20; | |
| 397 | 397 | return 9 + arg; |
| 398 | 398 | } |
| 399 | 399 | }; |
| ... | ... | @@ -406,8 +406,8 @@ test "function with inferred error set but returning no error" { |
| 406 | 406 | fn foo() !void {} |
| 407 | 407 | }; |
| 408 | 408 | |
| 409 | const return_ty = @typeInfo(@TypeOf(S.foo)).Fn.return_type.?; | |
| 410 | try expectEqual(0, @typeInfo(@typeInfo(return_ty).ErrorUnion.error_set).ErrorSet.?.len); | |
| 409 | const return_ty = @typeInfo(@TypeOf(S.foo)).@"fn".return_type.?; | |
| 410 | try expectEqual(0, @typeInfo(@typeInfo(return_ty).error_union.error_set).error_set.?.len); | |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | test "import passed byref to function in return type" { |
| ... | ... | @@ -567,10 +567,10 @@ test "lazy values passed to anytype parameter" { |
| 567 | 567 | |
| 568 | 568 | test "pass and return comptime-only types" { |
| 569 | 569 | const S = struct { |
| 570 | fn returnNull(comptime x: @Type(.Null)) @Type(.Null) { | |
| 570 | fn returnNull(comptime x: @Type(.null)) @Type(.null) { | |
| 571 | 571 | return x; |
| 572 | 572 | } |
| 573 | fn returnUndefined(comptime x: @Type(.Undefined)) @Type(.Undefined) { | |
| 573 | fn returnUndefined(comptime x: @Type(.undefined)) @Type(.undefined) { | |
| 574 | 574 | return x; |
| 575 | 575 | } |
| 576 | 576 | }; |
test/behavior/generics.zig+6-6| ... | ... | @@ -179,7 +179,7 @@ test "generic fn keeps non-generic parameter types" { |
| 179 | 179 | |
| 180 | 180 | const S = struct { |
| 181 | 181 | fn f(comptime T: type, s: []T) !void { |
| 182 | try expect(A != @typeInfo(@TypeOf(s)).Pointer.alignment); | |
| 182 | try expect(A != @typeInfo(@TypeOf(s)).pointer.alignment); | |
| 183 | 183 | } |
| 184 | 184 | }; |
| 185 | 185 | |
| ... | ... | @@ -258,17 +258,17 @@ test "generic function instantiation turns into comptime call" { |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { |
| 261 | .Enum => std.builtin.Type.EnumField, | |
| 261 | .@"enum" => std.builtin.Type.EnumField, | |
| 262 | 262 | else => void, |
| 263 | 263 | } { |
| 264 | return @typeInfo(T).Enum.fields[@intFromEnum(field)]; | |
| 264 | return @typeInfo(T).@"enum".fields[@intFromEnum(field)]; | |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | pub fn FieldEnum(comptime T: type) type { |
| 268 | 268 | _ = T; |
| 269 | 269 | var enumFields: [1]std.builtin.Type.EnumField = .{.{ .name = "A", .value = 0 }}; |
| 270 | 270 | return @Type(.{ |
| 271 | .Enum = .{ | |
| 271 | .@"enum" = .{ | |
| 272 | 272 | .tag_type = u0, |
| 273 | 273 | .fields = &enumFields, |
| 274 | 274 | .decls = &.{}, |
| ... | ... | @@ -363,7 +363,7 @@ test "nested generic function" { |
| 363 | 363 | |
| 364 | 364 | fn g(_: *const fn (anytype) void) void {} |
| 365 | 365 | }; |
| 366 | try expect(@typeInfo(@TypeOf(S.g)).Fn.is_generic); | |
| 366 | try expect(@typeInfo(@TypeOf(S.g)).@"fn".is_generic); | |
| 367 | 367 | try S.foo(u32, S.bar, 123); |
| 368 | 368 | } |
| 369 | 369 | |
| ... | ... | @@ -549,7 +549,7 @@ test "call generic function with from function called by the generic function" { |
| 549 | 549 | const ArgSerializer = struct { |
| 550 | 550 | fn isCommand(comptime T: type) bool { |
| 551 | 551 | const tid = @typeInfo(T); |
| 552 | return (tid == .Struct or tid == .Enum or tid == .Union) and | |
| 552 | return (tid == .@"struct" or tid == .@"enum" or tid == .@"union") and | |
| 553 | 553 | @hasDecl(T, "Redis") and @hasDecl(T.Redis, "Command"); |
| 554 | 554 | } |
| 555 | 555 | fn serializeCommand(command: anytype) void { |
test/behavior/math.zig+4-4| ... | ... | @@ -135,8 +135,8 @@ fn testOneClzVector( |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | fn expectVectorsEqual(a: anytype, b: anytype) !void { |
| 138 | const len_a = @typeInfo(@TypeOf(a)).Vector.len; | |
| 139 | const len_b = @typeInfo(@TypeOf(b)).Vector.len; | |
| 138 | const len_a = @typeInfo(@TypeOf(a)).vector.len; | |
| 139 | const len_b = @typeInfo(@TypeOf(b)).vector.len; | |
| 140 | 140 | try expect(len_a == len_b); |
| 141 | 141 | |
| 142 | 142 | var i: usize = 0; |
| ... | ... | @@ -1683,12 +1683,12 @@ test "signed zeros are represented properly" { |
| 1683 | 1683 | } |
| 1684 | 1684 | |
| 1685 | 1685 | fn testOne(comptime T: type) !void { |
| 1686 | const ST = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 1686 | const ST = std.meta.Int(.unsigned, @typeInfo(T).float.bits); | |
| 1687 | 1687 | var as_fp_val = -@as(T, 0.0); |
| 1688 | 1688 | _ = &as_fp_val; |
| 1689 | 1689 | const as_uint_val: ST = @bitCast(as_fp_val); |
| 1690 | 1690 | // Ensure the sign bit is set. |
| 1691 | try expect(as_uint_val >> (@typeInfo(T).Float.bits - 1) == 1); | |
| 1691 | try expect(as_uint_val >> (@typeInfo(T).float.bits - 1) == 1); | |
| 1692 | 1692 | } |
| 1693 | 1693 | }; |
| 1694 | 1694 |
test/behavior/packed-struct.zig+2-2| ... | ... | @@ -1186,9 +1186,9 @@ test "packed struct field pointer aligned properly" { |
| 1186 | 1186 | }; |
| 1187 | 1187 | |
| 1188 | 1188 | var f1: *align(16) Foo = @alignCast(@as(*align(1) Foo, @ptrCast(&Foo.buffer[0]))); |
| 1189 | try expect(@typeInfo(@TypeOf(f1)).Pointer.alignment == 16); | |
| 1189 | try expect(@typeInfo(@TypeOf(f1)).pointer.alignment == 16); | |
| 1190 | 1190 | try expect(@intFromPtr(f1) == @intFromPtr(&f1.a)); |
| 1191 | try expect(@typeInfo(@TypeOf(&f1.a)).Pointer.alignment == 16); | |
| 1191 | try expect(@typeInfo(@TypeOf(&f1.a)).pointer.alignment == 16); | |
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | 1194 | test "load flag from packed struct in union" { |
test/behavior/pointers.zig+18-18| ... | ... | @@ -266,8 +266,8 @@ test "allowzero pointer and slice" { |
| 266 | 266 | comptime assert(@TypeOf(slice) == []allowzero i32); |
| 267 | 267 | try expect(@intFromPtr(&slice[5]) == 20); |
| 268 | 268 | |
| 269 | comptime assert(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero); | |
| 270 | comptime assert(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero); | |
| 269 | comptime assert(@typeInfo(@TypeOf(ptr)).pointer.is_allowzero); | |
| 270 | comptime assert(@typeInfo(@TypeOf(slice)).pointer.is_allowzero); | |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | test "assign null directly to C pointer and test null equality" { |
| ... | ... | @@ -441,15 +441,15 @@ test "pointer-integer arithmetic affects the alignment" { |
| 441 | 441 | var x: usize = 1; |
| 442 | 442 | _ = .{ &ptr, &x }; |
| 443 | 443 | |
| 444 | try expect(@typeInfo(@TypeOf(ptr)).Pointer.alignment == 8); | |
| 444 | try expect(@typeInfo(@TypeOf(ptr)).pointer.alignment == 8); | |
| 445 | 445 | const ptr1 = ptr + 1; // 1 * 4 = 4 -> lcd(4,8) = 4 |
| 446 | try expect(@typeInfo(@TypeOf(ptr1)).Pointer.alignment == 4); | |
| 446 | try expect(@typeInfo(@TypeOf(ptr1)).pointer.alignment == 4); | |
| 447 | 447 | const ptr2 = ptr + 4; // 4 * 4 = 16 -> lcd(16,8) = 8 |
| 448 | try expect(@typeInfo(@TypeOf(ptr2)).Pointer.alignment == 8); | |
| 448 | try expect(@typeInfo(@TypeOf(ptr2)).pointer.alignment == 8); | |
| 449 | 449 | const ptr3 = ptr + 0; // no-op |
| 450 | try expect(@typeInfo(@TypeOf(ptr3)).Pointer.alignment == 8); | |
| 450 | try expect(@typeInfo(@TypeOf(ptr3)).pointer.alignment == 8); | |
| 451 | 451 | const ptr4 = ptr + x; // runtime-known addend |
| 452 | try expect(@typeInfo(@TypeOf(ptr4)).Pointer.alignment == 4); | |
| 452 | try expect(@typeInfo(@TypeOf(ptr4)).pointer.alignment == 4); | |
| 453 | 453 | } |
| 454 | 454 | { |
| 455 | 455 | var ptr: [*]align(8) [3]u8 = undefined; |
| ... | ... | @@ -457,13 +457,13 @@ test "pointer-integer arithmetic affects the alignment" { |
| 457 | 457 | _ = .{ &ptr, &x }; |
| 458 | 458 | |
| 459 | 459 | const ptr1 = ptr + 17; // 3 * 17 = 51 |
| 460 | try expect(@typeInfo(@TypeOf(ptr1)).Pointer.alignment == 1); | |
| 460 | try expect(@typeInfo(@TypeOf(ptr1)).pointer.alignment == 1); | |
| 461 | 461 | const ptr2 = ptr + x; // runtime-known addend |
| 462 | try expect(@typeInfo(@TypeOf(ptr2)).Pointer.alignment == 1); | |
| 462 | try expect(@typeInfo(@TypeOf(ptr2)).pointer.alignment == 1); | |
| 463 | 463 | const ptr3 = ptr + 8; // 3 * 8 = 24 -> lcd(8,24) = 8 |
| 464 | try expect(@typeInfo(@TypeOf(ptr3)).Pointer.alignment == 8); | |
| 464 | try expect(@typeInfo(@TypeOf(ptr3)).pointer.alignment == 8); | |
| 465 | 465 | const ptr4 = ptr + 4; // 3 * 4 = 12 -> lcd(8,12) = 4 |
| 466 | try expect(@typeInfo(@TypeOf(ptr4)).Pointer.alignment == 4); | |
| 466 | try expect(@typeInfo(@TypeOf(ptr4)).pointer.alignment == 4); | |
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | |
| ... | ... | @@ -560,7 +560,7 @@ test "pointer to constant decl preserves alignment" { |
| 560 | 560 | const aligned align(8) = @This(){ .a = 3, .b = 4 }; |
| 561 | 561 | }; |
| 562 | 562 | |
| 563 | const alignment = @typeInfo(@TypeOf(&S.aligned)).Pointer.alignment; | |
| 563 | const alignment = @typeInfo(@TypeOf(&S.aligned)).pointer.alignment; | |
| 564 | 564 | try std.testing.expect(alignment == 8); |
| 565 | 565 | } |
| 566 | 566 | |
| ... | ... | @@ -641,24 +641,24 @@ const Box2 = struct { |
| 641 | 641 | |
| 642 | 642 | fn mutable() !void { |
| 643 | 643 | var box0: Box0 = .{ .items = undefined }; |
| 644 | try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).Pointer.is_const == false); | |
| 644 | try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).pointer.is_const == false); | |
| 645 | 645 | |
| 646 | 646 | var box1: Box1 = .{ .items = undefined }; |
| 647 | try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).Pointer.is_const == false); | |
| 647 | try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).pointer.is_const == false); | |
| 648 | 648 | |
| 649 | 649 | var box2: Box2 = .{ .items = undefined }; |
| 650 | try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).Pointer.is_const == false); | |
| 650 | try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).pointer.is_const == false); | |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | fn constant() !void { |
| 654 | 654 | const box0: Box0 = .{ .items = undefined }; |
| 655 | try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).Pointer.is_const == true); | |
| 655 | try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).pointer.is_const == true); | |
| 656 | 656 | |
| 657 | 657 | const box1: Box1 = .{ .items = undefined }; |
| 658 | try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).Pointer.is_const == true); | |
| 658 | try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).pointer.is_const == true); | |
| 659 | 659 | |
| 660 | 660 | const box2: Box2 = .{ .items = undefined }; |
| 661 | try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).Pointer.is_const == true); | |
| 661 | try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).pointer.is_const == true); | |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | test "pointer-to-array constness for zero-size elements, var" { |
test/behavior/reflection.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ const reflection = @This(); |
| 6 | 6 | |
| 7 | 7 | test "reflection: function return type, var args, and param types" { |
| 8 | 8 | comptime { |
| 9 | const info = @typeInfo(@TypeOf(dummy)).Fn; | |
| 9 | const info = @typeInfo(@TypeOf(dummy)).@"fn"; | |
| 10 | 10 | try expect(info.return_type.? == i32); |
| 11 | 11 | try expect(!info.is_var_args); |
| 12 | 12 | try expect(info.params.len == 3); |
test/behavior/slice.zig+3-3| ... | ... | @@ -329,9 +329,9 @@ test "empty array to slice" { |
| 329 | 329 | const align_1: []align(1) u8 = empty; |
| 330 | 330 | const align_4: []align(4) u8 = empty; |
| 331 | 331 | const align_16: []align(16) u8 = empty; |
| 332 | try expect(1 == @typeInfo(@TypeOf(align_1)).Pointer.alignment); | |
| 333 | try expect(4 == @typeInfo(@TypeOf(align_4)).Pointer.alignment); | |
| 334 | try expect(16 == @typeInfo(@TypeOf(align_16)).Pointer.alignment); | |
| 332 | try expect(1 == @typeInfo(@TypeOf(align_1)).pointer.alignment); | |
| 333 | try expect(4 == @typeInfo(@TypeOf(align_4)).pointer.alignment); | |
| 334 | try expect(16 == @typeInfo(@TypeOf(align_16)).pointer.alignment); | |
| 335 | 335 | } |
| 336 | 336 | }; |
| 337 | 337 |
test/behavior/struct.zig+3-3| ... | ... | @@ -1738,7 +1738,7 @@ test "packed struct field in anonymous struct" { |
| 1738 | 1738 | try std.testing.expect(countFields(.{ .t = T{} }) == 1); |
| 1739 | 1739 | } |
| 1740 | 1740 | fn countFields(v: anytype) usize { |
| 1741 | return @typeInfo(@TypeOf(v)).Struct.fields.len; | |
| 1741 | return @typeInfo(@TypeOf(v)).@"struct".fields.len; | |
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | test "struct init with no result pointer sets field result types" { |
| ... | ... | @@ -2144,9 +2144,9 @@ test "struct containing optional pointer to array of @This()" { |
| 2144 | 2144 | test "matching captures causes struct equivalence" { |
| 2145 | 2145 | const S = struct { |
| 2146 | 2146 | fn UnsignedWrapper(comptime I: type) type { |
| 2147 | const bits = @typeInfo(I).Int.bits; | |
| 2147 | const bits = @typeInfo(I).int.bits; | |
| 2148 | 2148 | return struct { |
| 2149 | x: @Type(.{ .Int = .{ | |
| 2149 | x: @Type(.{ .int = .{ | |
| 2150 | 2150 | .signedness = .unsigned, |
| 2151 | 2151 | .bits = bits, |
| 2152 | 2152 | } }), |
test/behavior/tuple.zig+6-6| ... | ... | @@ -32,16 +32,16 @@ test "tuple multiplication" { |
| 32 | 32 | fn doTheTest() !void { |
| 33 | 33 | { |
| 34 | 34 | const t = .{} ** 4; |
| 35 | try expect(@typeInfo(@TypeOf(t)).Struct.fields.len == 0); | |
| 35 | try expect(@typeInfo(@TypeOf(t)).@"struct".fields.len == 0); | |
| 36 | 36 | } |
| 37 | 37 | { |
| 38 | 38 | const t = .{'a'} ** 4; |
| 39 | try expect(@typeInfo(@TypeOf(t)).Struct.fields.len == 4); | |
| 39 | try expect(@typeInfo(@TypeOf(t)).@"struct".fields.len == 4); | |
| 40 | 40 | inline for (t) |x| try expect(x == 'a'); |
| 41 | 41 | } |
| 42 | 42 | { |
| 43 | 43 | const t = .{ 1, 2, 3 } ** 4; |
| 44 | try expect(@typeInfo(@TypeOf(t)).Struct.fields.len == 12); | |
| 44 | try expect(@typeInfo(@TypeOf(t)).@"struct".fields.len == 12); | |
| 45 | 45 | inline for (t, 0..) |x, i| try expect(x == 1 + i % 3); |
| 46 | 46 | } |
| 47 | 47 | } |
| ... | ... | @@ -133,7 +133,7 @@ test "array-like initializer for tuple types" { |
| 133 | 133 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 134 | 134 | |
| 135 | 135 | const T = @Type(.{ |
| 136 | .Struct = .{ | |
| 136 | .@"struct" = .{ | |
| 137 | 137 | .is_tuple = true, |
| 138 | 138 | .layout = .auto, |
| 139 | 139 | .decls = &.{}, |
| ... | ... | @@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" { |
| 323 | 323 | const State = struct { |
| 324 | 324 | const Self = @This(); |
| 325 | 325 | data: @Type(.{ |
| 326 | .Struct = .{ | |
| 326 | .@"struct" = .{ | |
| 327 | 327 | .is_tuple = true, |
| 328 | 328 | .layout = .auto, |
| 329 | 329 | .decls = &.{}, |
| ... | ... | @@ -474,7 +474,7 @@ test "coerce anon tuple to tuple" { |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | test "empty tuple type" { |
| 477 | const S = @Type(.{ .Struct = .{ | |
| 477 | const S = @Type(.{ .@"struct" = .{ | |
| 478 | 478 | .layout = .auto, |
| 479 | 479 | .fields = &.{}, |
| 480 | 480 | .decls = &.{}, |
test/behavior/tuple_declarations.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ test "tuple declaration type info" { |
| 10 | 10 | |
| 11 | 11 | { |
| 12 | 12 | const T = struct { comptime u32 align(2) = 1, []const u8 }; |
| 13 | const info = @typeInfo(T).Struct; | |
| 13 | const info = @typeInfo(T).@"struct"; | |
| 14 | 14 | |
| 15 | 15 | try expect(info.layout == .auto); |
| 16 | 16 | try expect(info.backing_integer == null); |
test/behavior/type.zig+59-59| ... | ... | @@ -11,32 +11,32 @@ fn testTypes(comptime types: []const type) !void { |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | test "Type.MetaType" { |
| 14 | try testing.expect(type == @Type(.{ .Type = {} })); | |
| 14 | try testing.expect(type == @Type(.{ .type = {} })); | |
| 15 | 15 | try testTypes(&[_]type{type}); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | test "Type.Void" { |
| 19 | try testing.expect(void == @Type(.{ .Void = {} })); | |
| 19 | try testing.expect(void == @Type(.{ .void = {} })); | |
| 20 | 20 | try testTypes(&[_]type{void}); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | test "Type.Bool" { |
| 24 | try testing.expect(bool == @Type(.{ .Bool = {} })); | |
| 24 | try testing.expect(bool == @Type(.{ .bool = {} })); | |
| 25 | 25 | try testTypes(&[_]type{bool}); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | test "Type.NoReturn" { |
| 29 | try testing.expect(noreturn == @Type(.{ .NoReturn = {} })); | |
| 29 | try testing.expect(noreturn == @Type(.{ .noreturn = {} })); | |
| 30 | 30 | try testTypes(&[_]type{noreturn}); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | test "Type.Int" { |
| 34 | try testing.expect(u1 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 1 } })); | |
| 35 | try testing.expect(i1 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 1 } })); | |
| 36 | try testing.expect(u8 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 8 } })); | |
| 37 | try testing.expect(i8 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 8 } })); | |
| 38 | try testing.expect(u64 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 64 } })); | |
| 39 | try testing.expect(i64 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 64 } })); | |
| 34 | try testing.expect(u1 == @Type(.{ .int = .{ .signedness = .unsigned, .bits = 1 } })); | |
| 35 | try testing.expect(i1 == @Type(.{ .int = .{ .signedness = .signed, .bits = 1 } })); | |
| 36 | try testing.expect(u8 == @Type(.{ .int = .{ .signedness = .unsigned, .bits = 8 } })); | |
| 37 | try testing.expect(i8 == @Type(.{ .int = .{ .signedness = .signed, .bits = 8 } })); | |
| 38 | try testing.expect(u64 == @Type(.{ .int = .{ .signedness = .unsigned, .bits = 64 } })); | |
| 39 | try testing.expect(i64 == @Type(.{ .int = .{ .signedness = .signed, .bits = 64 } })); | |
| 40 | 40 | try testTypes(&[_]type{ u8, u32, i64 }); |
| 41 | 41 | } |
| 42 | 42 | |
| ... | ... | @@ -105,31 +105,31 @@ test "Type.Pointer" { |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | test "Type.Float" { |
| 108 | try testing.expect(f16 == @Type(.{ .Float = .{ .bits = 16 } })); | |
| 109 | try testing.expect(f32 == @Type(.{ .Float = .{ .bits = 32 } })); | |
| 110 | try testing.expect(f64 == @Type(.{ .Float = .{ .bits = 64 } })); | |
| 111 | try testing.expect(f80 == @Type(.{ .Float = .{ .bits = 80 } })); | |
| 112 | try testing.expect(f128 == @Type(.{ .Float = .{ .bits = 128 } })); | |
| 108 | try testing.expect(f16 == @Type(.{ .float = .{ .bits = 16 } })); | |
| 109 | try testing.expect(f32 == @Type(.{ .float = .{ .bits = 32 } })); | |
| 110 | try testing.expect(f64 == @Type(.{ .float = .{ .bits = 64 } })); | |
| 111 | try testing.expect(f80 == @Type(.{ .float = .{ .bits = 80 } })); | |
| 112 | try testing.expect(f128 == @Type(.{ .float = .{ .bits = 128 } })); | |
| 113 | 113 | try testTypes(&[_]type{ f16, f32, f64, f80, f128 }); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | test "Type.Array" { |
| 117 | 117 | try testing.expect([123]u8 == @Type(.{ |
| 118 | .Array = .{ | |
| 118 | .array = .{ | |
| 119 | 119 | .len = 123, |
| 120 | 120 | .child = u8, |
| 121 | 121 | .sentinel = null, |
| 122 | 122 | }, |
| 123 | 123 | })); |
| 124 | 124 | try testing.expect([2]u32 == @Type(.{ |
| 125 | .Array = .{ | |
| 125 | .array = .{ | |
| 126 | 126 | .len = 2, |
| 127 | 127 | .child = u32, |
| 128 | 128 | .sentinel = null, |
| 129 | 129 | }, |
| 130 | 130 | })); |
| 131 | 131 | try testing.expect([2:0]u32 == @Type(.{ |
| 132 | .Array = .{ | |
| 132 | .array = .{ | |
| 133 | 133 | .len = 2, |
| 134 | 134 | .child = u32, |
| 135 | 135 | .sentinel = &@as(u32, 0), |
| ... | ... | @@ -140,7 +140,7 @@ test "Type.Array" { |
| 140 | 140 | |
| 141 | 141 | test "@Type create slice with null sentinel" { |
| 142 | 142 | const Slice = @Type(.{ |
| 143 | .Pointer = .{ | |
| 143 | .pointer = .{ | |
| 144 | 144 | .size = .Slice, |
| 145 | 145 | .is_const = true, |
| 146 | 146 | .is_volatile = false, |
| ... | ... | @@ -205,7 +205,7 @@ test "Type.Opaque" { |
| 205 | 205 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 206 | 206 | |
| 207 | 207 | const Opaque = @Type(.{ |
| 208 | .Opaque = .{ | |
| 208 | .@"opaque" = .{ | |
| 209 | 209 | .decls = &.{}, |
| 210 | 210 | }, |
| 211 | 211 | }); |
| ... | ... | @@ -213,7 +213,7 @@ test "Type.Opaque" { |
| 213 | 213 | try testing.expectEqualSlices( |
| 214 | 214 | Type.Declaration, |
| 215 | 215 | &.{}, |
| 216 | @typeInfo(Opaque).Opaque.decls, | |
| 216 | @typeInfo(Opaque).@"opaque".decls, | |
| 217 | 217 | ); |
| 218 | 218 | } |
| 219 | 219 | |
| ... | ... | @@ -246,7 +246,7 @@ fn add(a: i32, b: i32) i32 { |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | test "Type.ErrorSet" { |
| 249 | try testing.expect(@Type(.{ .ErrorSet = null }) == anyerror); | |
| 249 | try testing.expect(@Type(.{ .error_set = null }) == anyerror); | |
| 250 | 250 | |
| 251 | 251 | // error sets don't compare equal so just check if they compile |
| 252 | 252 | inline for (.{ error{}, error{A}, error{ A, B, C } }) |T| { |
| ... | ... | @@ -262,7 +262,7 @@ test "Type.Struct" { |
| 262 | 262 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 263 | 263 | |
| 264 | 264 | const A = @Type(@typeInfo(struct { x: u8, y: u32 })); |
| 265 | const infoA = @typeInfo(A).Struct; | |
| 265 | const infoA = @typeInfo(A).@"struct"; | |
| 266 | 266 | try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout); |
| 267 | 267 | try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); |
| 268 | 268 | try testing.expectEqual(u8, infoA.fields[0].type); |
| ... | ... | @@ -280,7 +280,7 @@ test "Type.Struct" { |
| 280 | 280 | try testing.expectEqual(@as(u32, 2), a.y); |
| 281 | 281 | |
| 282 | 282 | const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 })); |
| 283 | const infoB = @typeInfo(B).Struct; | |
| 283 | const infoB = @typeInfo(B).@"struct"; | |
| 284 | 284 | try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout); |
| 285 | 285 | try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); |
| 286 | 286 | try testing.expectEqual(u8, infoB.fields[0].type); |
| ... | ... | @@ -292,7 +292,7 @@ test "Type.Struct" { |
| 292 | 292 | try testing.expectEqual(@as(bool, false), infoB.is_tuple); |
| 293 | 293 | |
| 294 | 294 | const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 })); |
| 295 | const infoC = @typeInfo(C).Struct; | |
| 295 | const infoC = @typeInfo(C).@"struct"; | |
| 296 | 296 | try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout); |
| 297 | 297 | try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); |
| 298 | 298 | try testing.expectEqual(u8, infoC.fields[0].type); |
| ... | ... | @@ -305,7 +305,7 @@ test "Type.Struct" { |
| 305 | 305 | |
| 306 | 306 | // anon structs |
| 307 | 307 | const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 }))); |
| 308 | const infoD = @typeInfo(D).Struct; | |
| 308 | const infoD = @typeInfo(D).@"struct"; | |
| 309 | 309 | try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout); |
| 310 | 310 | try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); |
| 311 | 311 | try testing.expectEqual(comptime_int, infoD.fields[0].type); |
| ... | ... | @@ -318,7 +318,7 @@ test "Type.Struct" { |
| 318 | 318 | |
| 319 | 319 | // tuples |
| 320 | 320 | const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 }))); |
| 321 | const infoE = @typeInfo(E).Struct; | |
| 321 | const infoE = @typeInfo(E).@"struct"; | |
| 322 | 322 | try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout); |
| 323 | 323 | try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); |
| 324 | 324 | try testing.expectEqual(comptime_int, infoE.fields[0].type); |
| ... | ... | @@ -331,14 +331,14 @@ test "Type.Struct" { |
| 331 | 331 | |
| 332 | 332 | // empty struct |
| 333 | 333 | const F = @Type(@typeInfo(struct {})); |
| 334 | const infoF = @typeInfo(F).Struct; | |
| 334 | const infoF = @typeInfo(F).@"struct"; | |
| 335 | 335 | try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout); |
| 336 | 336 | try testing.expect(infoF.fields.len == 0); |
| 337 | 337 | try testing.expectEqual(@as(bool, false), infoF.is_tuple); |
| 338 | 338 | |
| 339 | 339 | // empty tuple |
| 340 | 340 | const G = @Type(@typeInfo(@TypeOf(.{}))); |
| 341 | const infoG = @typeInfo(G).Struct; | |
| 341 | const infoG = @typeInfo(G).@"struct"; | |
| 342 | 342 | try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout); |
| 343 | 343 | try testing.expect(infoG.fields.len == 0); |
| 344 | 344 | try testing.expectEqual(@as(bool, true), infoG.is_tuple); |
| ... | ... | @@ -349,7 +349,7 @@ test "Type.Enum" { |
| 349 | 349 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 350 | 350 | |
| 351 | 351 | const Foo = @Type(.{ |
| 352 | .Enum = .{ | |
| 352 | .@"enum" = .{ | |
| 353 | 353 | .tag_type = u8, |
| 354 | 354 | .fields = &.{ |
| 355 | 355 | .{ .name = "a", .value = 1 }, |
| ... | ... | @@ -359,11 +359,11 @@ test "Type.Enum" { |
| 359 | 359 | .is_exhaustive = true, |
| 360 | 360 | }, |
| 361 | 361 | }); |
| 362 | try testing.expectEqual(true, @typeInfo(Foo).Enum.is_exhaustive); | |
| 362 | try testing.expectEqual(true, @typeInfo(Foo).@"enum".is_exhaustive); | |
| 363 | 363 | try testing.expectEqual(@as(u8, 1), @intFromEnum(Foo.a)); |
| 364 | 364 | try testing.expectEqual(@as(u8, 5), @intFromEnum(Foo.b)); |
| 365 | 365 | const Bar = @Type(.{ |
| 366 | .Enum = .{ | |
| 366 | .@"enum" = .{ | |
| 367 | 367 | .tag_type = u32, |
| 368 | 368 | .fields = &.{ |
| 369 | 369 | .{ .name = "a", .value = 1 }, |
| ... | ... | @@ -373,7 +373,7 @@ test "Type.Enum" { |
| 373 | 373 | .is_exhaustive = false, |
| 374 | 374 | }, |
| 375 | 375 | }); |
| 376 | try testing.expectEqual(false, @typeInfo(Bar).Enum.is_exhaustive); | |
| 376 | try testing.expectEqual(false, @typeInfo(Bar).@"enum".is_exhaustive); | |
| 377 | 377 | try testing.expectEqual(@as(u32, 1), @intFromEnum(Bar.a)); |
| 378 | 378 | try testing.expectEqual(@as(u32, 5), @intFromEnum(Bar.b)); |
| 379 | 379 | try testing.expectEqual(@as(u32, 6), @intFromEnum(@as(Bar, @enumFromInt(6)))); |
| ... | ... | @@ -385,7 +385,7 @@ test "Type.Union" { |
| 385 | 385 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 386 | 386 | |
| 387 | 387 | const Untagged = @Type(.{ |
| 388 | .Union = .{ | |
| 388 | .@"union" = .{ | |
| 389 | 389 | .layout = .@"extern", |
| 390 | 390 | .tag_type = null, |
| 391 | 391 | .fields = &.{ |
| ... | ... | @@ -401,7 +401,7 @@ test "Type.Union" { |
| 401 | 401 | try testing.expectEqual(@as(i32, 3), untagged.int); |
| 402 | 402 | |
| 403 | 403 | const PackedUntagged = @Type(.{ |
| 404 | .Union = .{ | |
| 404 | .@"union" = .{ | |
| 405 | 405 | .layout = .@"packed", |
| 406 | 406 | .tag_type = null, |
| 407 | 407 | .fields = &.{ |
| ... | ... | @@ -417,7 +417,7 @@ test "Type.Union" { |
| 417 | 417 | try testing.expectEqual(~@as(u32, 0), packed_untagged.unsigned); |
| 418 | 418 | |
| 419 | 419 | const Tag = @Type(.{ |
| 420 | .Enum = .{ | |
| 420 | .@"enum" = .{ | |
| 421 | 421 | .tag_type = u1, |
| 422 | 422 | .fields = &.{ |
| 423 | 423 | .{ .name = "signed", .value = 0 }, |
| ... | ... | @@ -428,7 +428,7 @@ test "Type.Union" { |
| 428 | 428 | }, |
| 429 | 429 | }); |
| 430 | 430 | const Tagged = @Type(.{ |
| 431 | .Union = .{ | |
| 431 | .@"union" = .{ | |
| 432 | 432 | .layout = .auto, |
| 433 | 433 | .tag_type = Tag, |
| 434 | 434 | .fields = &.{ |
| ... | ... | @@ -446,7 +446,7 @@ test "Type.Union" { |
| 446 | 446 | |
| 447 | 447 | test "Type.Union from Type.Enum" { |
| 448 | 448 | const Tag = @Type(.{ |
| 449 | .Enum = .{ | |
| 449 | .@"enum" = .{ | |
| 450 | 450 | .tag_type = u0, |
| 451 | 451 | .fields = &.{ |
| 452 | 452 | .{ .name = "working_as_expected", .value = 0 }, |
| ... | ... | @@ -456,7 +456,7 @@ test "Type.Union from Type.Enum" { |
| 456 | 456 | }, |
| 457 | 457 | }); |
| 458 | 458 | const T = @Type(.{ |
| 459 | .Union = .{ | |
| 459 | .@"union" = .{ | |
| 460 | 460 | .layout = .auto, |
| 461 | 461 | .tag_type = Tag, |
| 462 | 462 | .fields = &.{ |
| ... | ... | @@ -465,13 +465,13 @@ test "Type.Union from Type.Enum" { |
| 465 | 465 | .decls = &.{}, |
| 466 | 466 | }, |
| 467 | 467 | }); |
| 468 | _ = @typeInfo(T).Union; | |
| 468 | _ = @typeInfo(T).@"union"; | |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | test "Type.Union from regular enum" { |
| 472 | 472 | const E = enum { working_as_expected }; |
| 473 | 473 | const T = @Type(.{ |
| 474 | .Union = .{ | |
| 474 | .@"union" = .{ | |
| 475 | 475 | .layout = .auto, |
| 476 | 476 | .tag_type = E, |
| 477 | 477 | .fields = &.{ |
| ... | ... | @@ -480,13 +480,13 @@ test "Type.Union from regular enum" { |
| 480 | 480 | .decls = &.{}, |
| 481 | 481 | }, |
| 482 | 482 | }); |
| 483 | _ = @typeInfo(T).Union; | |
| 483 | _ = @typeInfo(T).@"union"; | |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | test "Type.Union from empty regular enum" { |
| 487 | 487 | const E = enum {}; |
| 488 | 488 | const U = @Type(.{ |
| 489 | .Union = .{ | |
| 489 | .@"union" = .{ | |
| 490 | 490 | .layout = .auto, |
| 491 | 491 | .tag_type = E, |
| 492 | 492 | .fields = &.{}, |
| ... | ... | @@ -498,7 +498,7 @@ test "Type.Union from empty regular enum" { |
| 498 | 498 | |
| 499 | 499 | test "Type.Union from empty Type.Enum" { |
| 500 | 500 | const E = @Type(.{ |
| 501 | .Enum = .{ | |
| 501 | .@"enum" = .{ | |
| 502 | 502 | .tag_type = u0, |
| 503 | 503 | .fields = &.{}, |
| 504 | 504 | .decls = &.{}, |
| ... | ... | @@ -506,7 +506,7 @@ test "Type.Union from empty Type.Enum" { |
| 506 | 506 | }, |
| 507 | 507 | }); |
| 508 | 508 | const U = @Type(.{ |
| 509 | .Union = .{ | |
| 509 | .@"union" = .{ | |
| 510 | 510 | .layout = .auto, |
| 511 | 511 | .tag_type = E, |
| 512 | 512 | .fields = &.{}, |
| ... | ... | @@ -525,7 +525,7 @@ test "Type.Fn" { |
| 525 | 525 | const T = fn (c_int, some_ptr) callconv(.C) void; |
| 526 | 526 | |
| 527 | 527 | { |
| 528 | const fn_info = std.builtin.Type{ .Fn = .{ | |
| 528 | const fn_info = std.builtin.Type{ .@"fn" = .{ | |
| 529 | 529 | .calling_convention = .C, |
| 530 | 530 | .is_generic = false, |
| 531 | 531 | .is_var_args = false, |
| ... | ... | @@ -551,7 +551,7 @@ test "reified struct field name from optional payload" { |
| 551 | 551 | comptime { |
| 552 | 552 | const m_name: ?[1:0]u8 = "a".*; |
| 553 | 553 | if (m_name) |*name| { |
| 554 | const T = @Type(.{ .Struct = .{ | |
| 554 | const T = @Type(.{ .@"struct" = .{ | |
| 555 | 555 | .layout = .auto, |
| 556 | 556 | .fields = &.{.{ |
| 557 | 557 | .name = name, |
| ... | ... | @@ -573,7 +573,7 @@ test "reified union uses @alignOf" { |
| 573 | 573 | const S = struct { |
| 574 | 574 | fn CreateUnion(comptime T: type) type { |
| 575 | 575 | return @Type(.{ |
| 576 | .Union = .{ | |
| 576 | .@"union" = .{ | |
| 577 | 577 | .layout = .auto, |
| 578 | 578 | .tag_type = null, |
| 579 | 579 | .fields = &[_]std.builtin.Type.UnionField{ |
| ... | ... | @@ -595,7 +595,7 @@ test "reified struct uses @alignOf" { |
| 595 | 595 | const S = struct { |
| 596 | 596 | fn NamespacedGlobals(comptime modules: anytype) type { |
| 597 | 597 | return @Type(.{ |
| 598 | .Struct = .{ | |
| 598 | .@"struct" = .{ | |
| 599 | 599 | .layout = .auto, |
| 600 | 600 | .is_tuple = false, |
| 601 | 601 | .fields = &.{ |
| ... | ... | @@ -627,7 +627,7 @@ test "reified error set initialized with field pointer" { |
| 627 | 627 | }, |
| 628 | 628 | }; |
| 629 | 629 | const Foo = @Type(.{ |
| 630 | .ErrorSet = &info.args, | |
| 630 | .error_set = &info.args, | |
| 631 | 631 | }); |
| 632 | 632 | }; |
| 633 | 633 | try testing.expect(S.Foo == error{bar}); |
| ... | ... | @@ -640,7 +640,7 @@ test "reified function type params initialized with field pointer" { |
| 640 | 640 | }, |
| 641 | 641 | }; |
| 642 | 642 | const Bar = @Type(.{ |
| 643 | .Fn = .{ | |
| 643 | .@"fn" = .{ | |
| 644 | 644 | .calling_convention = .Unspecified, |
| 645 | 645 | .is_generic = false, |
| 646 | 646 | .is_var_args = false, |
| ... | ... | @@ -649,14 +649,14 @@ test "reified function type params initialized with field pointer" { |
| 649 | 649 | }, |
| 650 | 650 | }); |
| 651 | 651 | }; |
| 652 | try testing.expect(@typeInfo(S.Bar) == .Fn); | |
| 652 | try testing.expect(@typeInfo(S.Bar) == .@"fn"); | |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | test "empty struct assigned to reified struct field" { |
| 656 | 656 | const S = struct { |
| 657 | 657 | fn NamespacedComponents(comptime modules: anytype) type { |
| 658 | 658 | return @Type(.{ |
| 659 | .Struct = .{ | |
| 659 | .@"struct" = .{ | |
| 660 | 660 | .layout = .auto, |
| 661 | 661 | .is_tuple = false, |
| 662 | 662 | .fields = &.{.{ |
| ... | ... | @@ -689,7 +689,7 @@ test "@Type should resolve its children types" { |
| 689 | 689 | const dense = enum(u2) { a, b, c, d }; |
| 690 | 690 | |
| 691 | 691 | comptime var sparse_info = @typeInfo(anyerror!sparse); |
| 692 | sparse_info.ErrorUnion.payload = dense; | |
| 692 | sparse_info.error_union.payload = dense; | |
| 693 | 693 | const B = @Type(sparse_info); |
| 694 | 694 | try testing.expectEqual(anyerror!dense, B); |
| 695 | 695 | } |
| ... | ... | @@ -718,7 +718,7 @@ test "struct field names sliced at comptime from larger string" { |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | const T = @Type(.{ |
| 721 | .Struct = .{ | |
| 721 | .@"struct" = .{ | |
| 722 | 722 | .layout = .auto, |
| 723 | 723 | .is_tuple = false, |
| 724 | 724 | .fields = fields, |
| ... | ... | @@ -726,7 +726,7 @@ test "struct field names sliced at comptime from larger string" { |
| 726 | 726 | }, |
| 727 | 727 | }); |
| 728 | 728 | |
| 729 | const gen_fields = @typeInfo(T).Struct.fields; | |
| 729 | const gen_fields = @typeInfo(T).@"struct".fields; | |
| 730 | 730 | try testing.expectEqual(3, gen_fields.len); |
| 731 | 731 | try testing.expectEqualStrings("f1", gen_fields[0].name); |
| 732 | 732 | try testing.expectEqualStrings("f2", gen_fields[1].name); |
| ... | ... | @@ -737,9 +737,9 @@ test "struct field names sliced at comptime from larger string" { |
| 737 | 737 | test "matching captures causes opaque equivalence" { |
| 738 | 738 | const S = struct { |
| 739 | 739 | fn UnsignedId(comptime I: type) type { |
| 740 | const U = @Type(.{ .Int = .{ | |
| 740 | const U = @Type(.{ .int = .{ | |
| 741 | 741 | .signedness = .unsigned, |
| 742 | .bits = @typeInfo(I).Int.bits, | |
| 742 | .bits = @typeInfo(I).int.bits, | |
| 743 | 743 | } }); |
| 744 | 744 | return opaque { |
| 745 | 745 | fn id(x: U) U { |
| ... | ... | @@ -765,7 +765,7 @@ test "reify enum where fields refers to part of array" { |
| 765 | 765 | .{ .name = "bar", .value = 1 }, |
| 766 | 766 | undefined, |
| 767 | 767 | }; |
| 768 | const E = @Type(.{ .Enum = .{ | |
| 768 | const E = @Type(.{ .@"enum" = .{ | |
| 769 | 769 | .tag_type = u8, |
| 770 | 770 | .fields = fields[0..2], |
| 771 | 771 | .decls = &.{}, |
test/behavior/type_info.zig+175-175| ... | ... | @@ -16,13 +16,13 @@ test "type info: integer, floating point type info" { |
| 16 | 16 | |
| 17 | 17 | fn testIntFloat() !void { |
| 18 | 18 | const u8_info = @typeInfo(u8); |
| 19 | try expect(u8_info == .Int); | |
| 20 | try expect(u8_info.Int.signedness == .unsigned); | |
| 21 | try expect(u8_info.Int.bits == 8); | |
| 19 | try expect(u8_info == .int); | |
| 20 | try expect(u8_info.int.signedness == .unsigned); | |
| 21 | try expect(u8_info.int.bits == 8); | |
| 22 | 22 | |
| 23 | 23 | const f64_info = @typeInfo(f64); |
| 24 | try expect(f64_info == .Float); | |
| 25 | try expect(f64_info.Float.bits == 64); | |
| 24 | try expect(f64_info == .float); | |
| 25 | try expect(f64_info.float.bits == 64); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | test "type info: optional type info" { |
| ... | ... | @@ -32,8 +32,8 @@ test "type info: optional type info" { |
| 32 | 32 | |
| 33 | 33 | fn testOptional() !void { |
| 34 | 34 | const null_info = @typeInfo(?void); |
| 35 | try expect(null_info == .Optional); | |
| 36 | try expect(null_info.Optional.child == void); | |
| 35 | try expect(null_info == .optional); | |
| 36 | try expect(null_info.optional.child == void); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | test "type info: C pointer type info" { |
| ... | ... | @@ -43,19 +43,19 @@ test "type info: C pointer type info" { |
| 43 | 43 | |
| 44 | 44 | fn testCPtr() !void { |
| 45 | 45 | const ptr_info = @typeInfo([*c]align(4) const i8); |
| 46 | try expect(ptr_info == .Pointer); | |
| 47 | try expect(ptr_info.Pointer.size == .C); | |
| 48 | try expect(ptr_info.Pointer.is_const); | |
| 49 | try expect(!ptr_info.Pointer.is_volatile); | |
| 50 | try expect(ptr_info.Pointer.alignment == 4); | |
| 51 | try expect(ptr_info.Pointer.child == i8); | |
| 46 | try expect(ptr_info == .pointer); | |
| 47 | try expect(ptr_info.pointer.size == .C); | |
| 48 | try expect(ptr_info.pointer.is_const); | |
| 49 | try expect(!ptr_info.pointer.is_volatile); | |
| 50 | try expect(ptr_info.pointer.alignment == 4); | |
| 51 | try expect(ptr_info.pointer.child == i8); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | test "type info: value is correctly copied" { |
| 55 | 55 | comptime { |
| 56 | 56 | var ptrInfo = @typeInfo([]u32); |
| 57 | ptrInfo.Pointer.size = .One; | |
| 58 | try expect(@typeInfo([]u32).Pointer.size == .Slice); | |
| 57 | ptrInfo.pointer.size = .One; | |
| 58 | try expect(@typeInfo([]u32).pointer.size == .Slice); | |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| ... | ... | @@ -65,10 +65,10 @@ test "type info: tag type, void info" { |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | fn testBasic() !void { |
| 68 | try expect(@typeInfo(Type).Union.tag_type == TypeId); | |
| 68 | try expect(@typeInfo(Type).@"union".tag_type == TypeId); | |
| 69 | 69 | const void_info = @typeInfo(void); |
| 70 | try expect(void_info == TypeId.Void); | |
| 71 | try expect(void_info.Void == {}); | |
| 70 | try expect(void_info == TypeId.void); | |
| 71 | try expect(void_info.void == {}); | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | test "type info: pointer type info" { |
| ... | ... | @@ -78,13 +78,13 @@ test "type info: pointer type info" { |
| 78 | 78 | |
| 79 | 79 | fn testPointer() !void { |
| 80 | 80 | const u32_ptr_info = @typeInfo(*u32); |
| 81 | try expect(u32_ptr_info == .Pointer); | |
| 82 | try expect(u32_ptr_info.Pointer.size == .One); | |
| 83 | try expect(u32_ptr_info.Pointer.is_const == false); | |
| 84 | try expect(u32_ptr_info.Pointer.is_volatile == false); | |
| 85 | try expect(u32_ptr_info.Pointer.alignment == @alignOf(u32)); | |
| 86 | try expect(u32_ptr_info.Pointer.child == u32); | |
| 87 | try expect(u32_ptr_info.Pointer.sentinel == null); | |
| 81 | try expect(u32_ptr_info == .pointer); | |
| 82 | try expect(u32_ptr_info.pointer.size == .One); | |
| 83 | try expect(u32_ptr_info.pointer.is_const == false); | |
| 84 | try expect(u32_ptr_info.pointer.is_volatile == false); | |
| 85 | try expect(u32_ptr_info.pointer.alignment == @alignOf(u32)); | |
| 86 | try expect(u32_ptr_info.pointer.child == u32); | |
| 87 | try expect(u32_ptr_info.pointer.sentinel == null); | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | test "type info: unknown length pointer type info" { |
| ... | ... | @@ -94,13 +94,13 @@ test "type info: unknown length pointer type info" { |
| 94 | 94 | |
| 95 | 95 | fn testUnknownLenPtr() !void { |
| 96 | 96 | const u32_ptr_info = @typeInfo([*]const volatile f64); |
| 97 | try expect(u32_ptr_info == .Pointer); | |
| 98 | try expect(u32_ptr_info.Pointer.size == .Many); | |
| 99 | try expect(u32_ptr_info.Pointer.is_const == true); | |
| 100 | try expect(u32_ptr_info.Pointer.is_volatile == true); | |
| 101 | try expect(u32_ptr_info.Pointer.sentinel == null); | |
| 102 | try expect(u32_ptr_info.Pointer.alignment == @alignOf(f64)); | |
| 103 | try expect(u32_ptr_info.Pointer.child == f64); | |
| 97 | try expect(u32_ptr_info == .pointer); | |
| 98 | try expect(u32_ptr_info.pointer.size == .Many); | |
| 99 | try expect(u32_ptr_info.pointer.is_const == true); | |
| 100 | try expect(u32_ptr_info.pointer.is_volatile == true); | |
| 101 | try expect(u32_ptr_info.pointer.sentinel == null); | |
| 102 | try expect(u32_ptr_info.pointer.alignment == @alignOf(f64)); | |
| 103 | try expect(u32_ptr_info.pointer.child == f64); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | test "type info: null terminated pointer type info" { |
| ... | ... | @@ -110,13 +110,13 @@ test "type info: null terminated pointer type info" { |
| 110 | 110 | |
| 111 | 111 | fn testNullTerminatedPtr() !void { |
| 112 | 112 | const ptr_info = @typeInfo([*:0]u8); |
| 113 | try expect(ptr_info == .Pointer); | |
| 114 | try expect(ptr_info.Pointer.size == .Many); | |
| 115 | try expect(ptr_info.Pointer.is_const == false); | |
| 116 | try expect(ptr_info.Pointer.is_volatile == false); | |
| 117 | try expect(@as(*const u8, @ptrCast(ptr_info.Pointer.sentinel.?)).* == 0); | |
| 113 | try expect(ptr_info == .pointer); | |
| 114 | try expect(ptr_info.pointer.size == .Many); | |
| 115 | try expect(ptr_info.pointer.is_const == false); | |
| 116 | try expect(ptr_info.pointer.is_volatile == false); | |
| 117 | try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0); | |
| 118 | 118 | |
| 119 | try expect(@typeInfo([:0]u8).Pointer.sentinel != null); | |
| 119 | try expect(@typeInfo([:0]u8).pointer.sentinel != null); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | test "type info: slice type info" { |
| ... | ... | @@ -126,12 +126,12 @@ test "type info: slice type info" { |
| 126 | 126 | |
| 127 | 127 | fn testSlice() !void { |
| 128 | 128 | const u32_slice_info = @typeInfo([]u32); |
| 129 | try expect(u32_slice_info == .Pointer); | |
| 130 | try expect(u32_slice_info.Pointer.size == .Slice); | |
| 131 | try expect(u32_slice_info.Pointer.is_const == false); | |
| 132 | try expect(u32_slice_info.Pointer.is_volatile == false); | |
| 133 | try expect(u32_slice_info.Pointer.alignment == 4); | |
| 134 | try expect(u32_slice_info.Pointer.child == u32); | |
| 129 | try expect(u32_slice_info == .pointer); | |
| 130 | try expect(u32_slice_info.pointer.size == .Slice); | |
| 131 | try expect(u32_slice_info.pointer.is_const == false); | |
| 132 | try expect(u32_slice_info.pointer.is_volatile == false); | |
| 133 | try expect(u32_slice_info.pointer.alignment == 4); | |
| 134 | try expect(u32_slice_info.pointer.child == u32); | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | test "type info: array type info" { |
| ... | ... | @@ -142,18 +142,18 @@ test "type info: array type info" { |
| 142 | 142 | fn testArray() !void { |
| 143 | 143 | { |
| 144 | 144 | const info = @typeInfo([42]u8); |
| 145 | try expect(info == .Array); | |
| 146 | try expect(info.Array.len == 42); | |
| 147 | try expect(info.Array.child == u8); | |
| 148 | try expect(info.Array.sentinel == null); | |
| 145 | try expect(info == .array); | |
| 146 | try expect(info.array.len == 42); | |
| 147 | try expect(info.array.child == u8); | |
| 148 | try expect(info.array.sentinel == null); | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | { |
| 152 | 152 | const info = @typeInfo([10:0]u8); |
| 153 | try expect(info.Array.len == 10); | |
| 154 | try expect(info.Array.child == u8); | |
| 155 | try expect(@as(*const u8, @ptrCast(info.Array.sentinel.?)).* == @as(u8, 0)); | |
| 156 | try expect(@sizeOf([10:0]u8) == info.Array.len + 1); | |
| 153 | try expect(info.array.len == 10); | |
| 154 | try expect(info.array.child == u8); | |
| 155 | try expect(@as(*const u8, @ptrCast(info.array.sentinel.?)).* == @as(u8, 0)); | |
| 156 | try expect(@sizeOf([10:0]u8) == info.array.len + 1); | |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| ... | ... | @@ -174,18 +174,18 @@ fn testErrorSet() !void { |
| 174 | 174 | }; |
| 175 | 175 | |
| 176 | 176 | const error_set_info = @typeInfo(TestErrorSet); |
| 177 | try expect(error_set_info == .ErrorSet); | |
| 178 | try expect(error_set_info.ErrorSet.?.len == 3); | |
| 179 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "First")); | |
| 177 | try expect(error_set_info == .error_set); | |
| 178 | try expect(error_set_info.error_set.?.len == 3); | |
| 179 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "First")); | |
| 180 | 180 | |
| 181 | 181 | const error_union_info = @typeInfo(TestErrorSet!usize); |
| 182 | try expect(error_union_info == .ErrorUnion); | |
| 183 | try expect(error_union_info.ErrorUnion.error_set == TestErrorSet); | |
| 184 | try expect(error_union_info.ErrorUnion.payload == usize); | |
| 182 | try expect(error_union_info == .error_union); | |
| 183 | try expect(error_union_info.error_union.error_set == TestErrorSet); | |
| 184 | try expect(error_union_info.error_union.payload == usize); | |
| 185 | 185 | |
| 186 | 186 | const global_info = @typeInfo(anyerror); |
| 187 | try expect(global_info == .ErrorSet); | |
| 188 | try expect(global_info.ErrorSet == null); | |
| 187 | try expect(global_info == .error_set); | |
| 188 | try expect(global_info.error_set == null); | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | test "type info: error set single value" { |
| ... | ... | @@ -196,9 +196,9 @@ test "type info: error set single value" { |
| 196 | 196 | const TestSet = error.One; |
| 197 | 197 | |
| 198 | 198 | const error_set_info = @typeInfo(@TypeOf(TestSet)); |
| 199 | try expect(error_set_info == .ErrorSet); | |
| 200 | try expect(error_set_info.ErrorSet.?.len == 1); | |
| 201 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 199 | try expect(error_set_info == .error_set); | |
| 200 | try expect(error_set_info.error_set.?.len == 1); | |
| 201 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | test "type info: error set merged" { |
| ... | ... | @@ -209,11 +209,11 @@ test "type info: error set merged" { |
| 209 | 209 | const TestSet = error{ One, Two } || error{Three}; |
| 210 | 210 | |
| 211 | 211 | const error_set_info = @typeInfo(TestSet); |
| 212 | try expect(error_set_info == .ErrorSet); | |
| 213 | try expect(error_set_info.ErrorSet.?.len == 3); | |
| 214 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One")); | |
| 215 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two")); | |
| 216 | try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three")); | |
| 212 | try expect(error_set_info == .error_set); | |
| 213 | try expect(error_set_info.error_set.?.len == 3); | |
| 214 | try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One")); | |
| 215 | try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two")); | |
| 216 | try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three")); | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | test "type info: enum info" { |
| ... | ... | @@ -234,12 +234,12 @@ fn testEnum() !void { |
| 234 | 234 | }; |
| 235 | 235 | |
| 236 | 236 | const os_info = @typeInfo(Os); |
| 237 | try expect(os_info == .Enum); | |
| 238 | try expect(os_info.Enum.fields.len == 4); | |
| 239 | try expect(mem.eql(u8, os_info.Enum.fields[1].name, "Macos")); | |
| 240 | try expect(os_info.Enum.fields[3].value == 3); | |
| 241 | try expect(os_info.Enum.tag_type == u2); | |
| 242 | try expect(os_info.Enum.decls.len == 0); | |
| 237 | try expect(os_info == .@"enum"); | |
| 238 | try expect(os_info.@"enum".fields.len == 4); | |
| 239 | try expect(mem.eql(u8, os_info.@"enum".fields[1].name, "Macos")); | |
| 240 | try expect(os_info.@"enum".fields[3].value == 3); | |
| 241 | try expect(os_info.@"enum".tag_type == u2); | |
| 242 | try expect(os_info.@"enum".decls.len == 0); | |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | test "type info: union info" { |
| ... | ... | @@ -249,12 +249,12 @@ test "type info: union info" { |
| 249 | 249 | |
| 250 | 250 | fn testUnion() !void { |
| 251 | 251 | const typeinfo_info = @typeInfo(Type); |
| 252 | try expect(typeinfo_info == .Union); | |
| 253 | try expect(typeinfo_info.Union.layout == .auto); | |
| 254 | try expect(typeinfo_info.Union.tag_type.? == TypeId); | |
| 255 | try expect(typeinfo_info.Union.fields.len == 24); | |
| 256 | try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int)); | |
| 257 | try expect(typeinfo_info.Union.decls.len == 21); | |
| 252 | try expect(typeinfo_info == .@"union"); | |
| 253 | try expect(typeinfo_info.@"union".layout == .auto); | |
| 254 | try expect(typeinfo_info.@"union".tag_type.? == TypeId); | |
| 255 | try expect(typeinfo_info.@"union".fields.len == 24); | |
| 256 | try expect(typeinfo_info.@"union".fields[4].type == @TypeOf(@typeInfo(u8).int)); | |
| 257 | try expect(typeinfo_info.@"union".decls.len == 21); | |
| 258 | 258 | |
| 259 | 259 | const TestNoTagUnion = union { |
| 260 | 260 | Foo: void, |
| ... | ... | @@ -262,22 +262,22 @@ fn testUnion() !void { |
| 262 | 262 | }; |
| 263 | 263 | |
| 264 | 264 | const notag_union_info = @typeInfo(TestNoTagUnion); |
| 265 | try expect(notag_union_info == .Union); | |
| 266 | try expect(notag_union_info.Union.tag_type == null); | |
| 267 | try expect(notag_union_info.Union.layout == .auto); | |
| 268 | try expect(notag_union_info.Union.fields.len == 2); | |
| 269 | try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void)); | |
| 270 | try expect(notag_union_info.Union.fields[1].type == u32); | |
| 271 | try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32)); | |
| 265 | try expect(notag_union_info == .@"union"); | |
| 266 | try expect(notag_union_info.@"union".tag_type == null); | |
| 267 | try expect(notag_union_info.@"union".layout == .auto); | |
| 268 | try expect(notag_union_info.@"union".fields.len == 2); | |
| 269 | try expect(notag_union_info.@"union".fields[0].alignment == @alignOf(void)); | |
| 270 | try expect(notag_union_info.@"union".fields[1].type == u32); | |
| 271 | try expect(notag_union_info.@"union".fields[1].alignment == @alignOf(u32)); | |
| 272 | 272 | |
| 273 | 273 | const TestExternUnion = extern union { |
| 274 | 274 | foo: *anyopaque, |
| 275 | 275 | }; |
| 276 | 276 | |
| 277 | 277 | const extern_union_info = @typeInfo(TestExternUnion); |
| 278 | try expect(extern_union_info.Union.layout == .@"extern"); | |
| 279 | try expect(extern_union_info.Union.tag_type == null); | |
| 280 | try expect(extern_union_info.Union.fields[0].type == *anyopaque); | |
| 278 | try expect(extern_union_info.@"union".layout == .@"extern"); | |
| 279 | try expect(extern_union_info.@"union".tag_type == null); | |
| 280 | try expect(extern_union_info.@"union".fields[0].type == *anyopaque); | |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | test "type info: struct info" { |
| ... | ... | @@ -289,11 +289,11 @@ test "type info: struct info" { |
| 289 | 289 | |
| 290 | 290 | fn testStruct() !void { |
| 291 | 291 | const unpacked_struct_info = @typeInfo(TestStruct); |
| 292 | try expect(unpacked_struct_info.Struct.is_tuple == false); | |
| 293 | try expect(unpacked_struct_info.Struct.backing_integer == null); | |
| 294 | try expect(unpacked_struct_info.Struct.fields[0].alignment == @alignOf(u32)); | |
| 295 | try expect(@as(*align(1) const u32, @ptrCast(unpacked_struct_info.Struct.fields[0].default_value.?)).* == 4); | |
| 296 | try expect(mem.eql(u8, "foobar", @as(*align(1) const *const [6:0]u8, @ptrCast(unpacked_struct_info.Struct.fields[1].default_value.?)).*)); | |
| 292 | try expect(unpacked_struct_info.@"struct".is_tuple == false); | |
| 293 | try expect(unpacked_struct_info.@"struct".backing_integer == null); | |
| 294 | try expect(unpacked_struct_info.@"struct".fields[0].alignment == @alignOf(u32)); | |
| 295 | try expect(@as(*align(1) const u32, @ptrCast(unpacked_struct_info.@"struct".fields[0].default_value.?)).* == 4); | |
| 296 | try expect(mem.eql(u8, "foobar", @as(*align(1) const *const [6:0]u8, @ptrCast(unpacked_struct_info.@"struct".fields[1].default_value.?)).*)); | |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | const TestStruct = struct { |
| ... | ... | @@ -308,17 +308,17 @@ test "type info: packed struct info" { |
| 308 | 308 | |
| 309 | 309 | fn testPackedStruct() !void { |
| 310 | 310 | const struct_info = @typeInfo(TestPackedStruct); |
| 311 | try expect(struct_info == .Struct); | |
| 312 | try expect(struct_info.Struct.is_tuple == false); | |
| 313 | try expect(struct_info.Struct.layout == .@"packed"); | |
| 314 | try expect(struct_info.Struct.backing_integer == u128); | |
| 315 | try expect(struct_info.Struct.fields.len == 4); | |
| 316 | try expect(struct_info.Struct.fields[0].alignment == 0); | |
| 317 | try expect(struct_info.Struct.fields[2].type == f32); | |
| 318 | try expect(struct_info.Struct.fields[2].default_value == null); | |
| 319 | try expect(@as(*align(1) const u32, @ptrCast(struct_info.Struct.fields[3].default_value.?)).* == 4); | |
| 320 | try expect(struct_info.Struct.fields[3].alignment == 0); | |
| 321 | try expect(struct_info.Struct.decls.len == 1); | |
| 311 | try expect(struct_info == .@"struct"); | |
| 312 | try expect(struct_info.@"struct".is_tuple == false); | |
| 313 | try expect(struct_info.@"struct".layout == .@"packed"); | |
| 314 | try expect(struct_info.@"struct".backing_integer == u128); | |
| 315 | try expect(struct_info.@"struct".fields.len == 4); | |
| 316 | try expect(struct_info.@"struct".fields[0].alignment == 0); | |
| 317 | try expect(struct_info.@"struct".fields[2].type == f32); | |
| 318 | try expect(struct_info.@"struct".fields[2].default_value == null); | |
| 319 | try expect(@as(*align(1) const u32, @ptrCast(struct_info.@"struct".fields[3].default_value.?)).* == 4); | |
| 320 | try expect(struct_info.@"struct".fields[3].alignment == 0); | |
| 321 | try expect(struct_info.@"struct".decls.len == 1); | |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | const TestPackedStruct = packed struct { |
| ... | ... | @@ -345,7 +345,7 @@ fn testOpaque() !void { |
| 345 | 345 | }; |
| 346 | 346 | |
| 347 | 347 | const foo_info = @typeInfo(Foo); |
| 348 | try expect(foo_info.Opaque.decls.len == 2); | |
| 348 | try expect(foo_info.@"opaque".decls.len == 2); | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | test "type info: function type info" { |
| ... | ... | @@ -358,36 +358,36 @@ test "type info: function type info" { |
| 358 | 358 | fn testFunction() !void { |
| 359 | 359 | const foo_fn_type = @TypeOf(typeInfoFoo); |
| 360 | 360 | const foo_fn_info = @typeInfo(foo_fn_type); |
| 361 | try expect(foo_fn_info.Fn.calling_convention == .C); | |
| 362 | try expect(!foo_fn_info.Fn.is_generic); | |
| 363 | try expect(foo_fn_info.Fn.params.len == 2); | |
| 364 | try expect(foo_fn_info.Fn.is_var_args); | |
| 365 | try expect(foo_fn_info.Fn.return_type.? == usize); | |
| 361 | try expect(foo_fn_info.@"fn".calling_convention == .C); | |
| 362 | try expect(!foo_fn_info.@"fn".is_generic); | |
| 363 | try expect(foo_fn_info.@"fn".params.len == 2); | |
| 364 | try expect(foo_fn_info.@"fn".is_var_args); | |
| 365 | try expect(foo_fn_info.@"fn".return_type.? == usize); | |
| 366 | 366 | const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo)); |
| 367 | try expect(foo_ptr_fn_info.Pointer.size == .One); | |
| 368 | try expect(foo_ptr_fn_info.Pointer.is_const); | |
| 369 | try expect(!foo_ptr_fn_info.Pointer.is_volatile); | |
| 370 | try expect(foo_ptr_fn_info.Pointer.address_space == .generic); | |
| 371 | try expect(foo_ptr_fn_info.Pointer.child == foo_fn_type); | |
| 372 | try expect(!foo_ptr_fn_info.Pointer.is_allowzero); | |
| 373 | try expect(foo_ptr_fn_info.Pointer.sentinel == null); | |
| 367 | try expect(foo_ptr_fn_info.pointer.size == .One); | |
| 368 | try expect(foo_ptr_fn_info.pointer.is_const); | |
| 369 | try expect(!foo_ptr_fn_info.pointer.is_volatile); | |
| 370 | try expect(foo_ptr_fn_info.pointer.address_space == .generic); | |
| 371 | try expect(foo_ptr_fn_info.pointer.child == foo_fn_type); | |
| 372 | try expect(!foo_ptr_fn_info.pointer.is_allowzero); | |
| 373 | try expect(foo_ptr_fn_info.pointer.sentinel == null); | |
| 374 | 374 | |
| 375 | 375 | const aligned_foo_fn_type = @TypeOf(typeInfoFooAligned); |
| 376 | 376 | const aligned_foo_fn_info = @typeInfo(aligned_foo_fn_type); |
| 377 | try expect(aligned_foo_fn_info.Fn.calling_convention == .C); | |
| 378 | try expect(!aligned_foo_fn_info.Fn.is_generic); | |
| 379 | try expect(aligned_foo_fn_info.Fn.params.len == 2); | |
| 380 | try expect(aligned_foo_fn_info.Fn.is_var_args); | |
| 381 | try expect(aligned_foo_fn_info.Fn.return_type.? == usize); | |
| 377 | try expect(aligned_foo_fn_info.@"fn".calling_convention == .C); | |
| 378 | try expect(!aligned_foo_fn_info.@"fn".is_generic); | |
| 379 | try expect(aligned_foo_fn_info.@"fn".params.len == 2); | |
| 380 | try expect(aligned_foo_fn_info.@"fn".is_var_args); | |
| 381 | try expect(aligned_foo_fn_info.@"fn".return_type.? == usize); | |
| 382 | 382 | const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned)); |
| 383 | try expect(aligned_foo_ptr_fn_info.Pointer.size == .One); | |
| 384 | try expect(aligned_foo_ptr_fn_info.Pointer.is_const); | |
| 385 | try expect(!aligned_foo_ptr_fn_info.Pointer.is_volatile); | |
| 386 | try expect(aligned_foo_ptr_fn_info.Pointer.alignment == 4); | |
| 387 | try expect(aligned_foo_ptr_fn_info.Pointer.address_space == .generic); | |
| 388 | try expect(aligned_foo_ptr_fn_info.Pointer.child == aligned_foo_fn_type); | |
| 389 | try expect(!aligned_foo_ptr_fn_info.Pointer.is_allowzero); | |
| 390 | try expect(aligned_foo_ptr_fn_info.Pointer.sentinel == null); | |
| 383 | try expect(aligned_foo_ptr_fn_info.pointer.size == .One); | |
| 384 | try expect(aligned_foo_ptr_fn_info.pointer.is_const); | |
| 385 | try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile); | |
| 386 | try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4); | |
| 387 | try expect(aligned_foo_ptr_fn_info.pointer.address_space == .generic); | |
| 388 | try expect(aligned_foo_ptr_fn_info.pointer.child == aligned_foo_fn_type); | |
| 389 | try expect(!aligned_foo_ptr_fn_info.pointer.is_allowzero); | |
| 390 | try expect(aligned_foo_ptr_fn_info.pointer.sentinel == null); | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.C) usize; |
| ... | ... | @@ -395,32 +395,32 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize |
| 395 | 395 | |
| 396 | 396 | test "type info: generic function types" { |
| 397 | 397 | const G1 = @typeInfo(@TypeOf(generic1)); |
| 398 | try expect(G1.Fn.params.len == 1); | |
| 399 | try expect(G1.Fn.params[0].is_generic == true); | |
| 400 | try expect(G1.Fn.params[0].type == null); | |
| 401 | try expect(G1.Fn.return_type == void); | |
| 398 | try expect(G1.@"fn".params.len == 1); | |
| 399 | try expect(G1.@"fn".params[0].is_generic == true); | |
| 400 | try expect(G1.@"fn".params[0].type == null); | |
| 401 | try expect(G1.@"fn".return_type == void); | |
| 402 | 402 | |
| 403 | 403 | const G2 = @typeInfo(@TypeOf(generic2)); |
| 404 | try expect(G2.Fn.params.len == 3); | |
| 405 | try expect(G2.Fn.params[0].is_generic == false); | |
| 406 | try expect(G2.Fn.params[0].type == type); | |
| 407 | try expect(G2.Fn.params[1].is_generic == true); | |
| 408 | try expect(G2.Fn.params[1].type == null); | |
| 409 | try expect(G2.Fn.params[2].is_generic == false); | |
| 410 | try expect(G2.Fn.params[2].type == u8); | |
| 411 | try expect(G2.Fn.return_type == void); | |
| 404 | try expect(G2.@"fn".params.len == 3); | |
| 405 | try expect(G2.@"fn".params[0].is_generic == false); | |
| 406 | try expect(G2.@"fn".params[0].type == type); | |
| 407 | try expect(G2.@"fn".params[1].is_generic == true); | |
| 408 | try expect(G2.@"fn".params[1].type == null); | |
| 409 | try expect(G2.@"fn".params[2].is_generic == false); | |
| 410 | try expect(G2.@"fn".params[2].type == u8); | |
| 411 | try expect(G2.@"fn".return_type == void); | |
| 412 | 412 | |
| 413 | 413 | const G3 = @typeInfo(@TypeOf(generic3)); |
| 414 | try expect(G3.Fn.params.len == 1); | |
| 415 | try expect(G3.Fn.params[0].is_generic == true); | |
| 416 | try expect(G3.Fn.params[0].type == null); | |
| 417 | try expect(G3.Fn.return_type == null); | |
| 414 | try expect(G3.@"fn".params.len == 1); | |
| 415 | try expect(G3.@"fn".params[0].is_generic == true); | |
| 416 | try expect(G3.@"fn".params[0].type == null); | |
| 417 | try expect(G3.@"fn".return_type == null); | |
| 418 | 418 | |
| 419 | 419 | const G4 = @typeInfo(@TypeOf(generic4)); |
| 420 | try expect(G4.Fn.params.len == 1); | |
| 421 | try expect(G4.Fn.params[0].is_generic == true); | |
| 422 | try expect(G4.Fn.params[0].type == null); | |
| 423 | try expect(G4.Fn.return_type == null); | |
| 420 | try expect(G4.@"fn".params.len == 1); | |
| 421 | try expect(G4.@"fn".params[0].is_generic == true); | |
| 422 | try expect(G4.@"fn".params[0].type == null); | |
| 423 | try expect(G4.@"fn".return_type == null); | |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | fn generic1(param: anytype) void { |
| ... | ... | @@ -450,9 +450,9 @@ test "type info: vectors" { |
| 450 | 450 | |
| 451 | 451 | fn testVector() !void { |
| 452 | 452 | const vec_info = @typeInfo(@Vector(4, i32)); |
| 453 | try expect(vec_info == .Vector); | |
| 454 | try expect(vec_info.Vector.len == 4); | |
| 455 | try expect(vec_info.Vector.child == i32); | |
| 453 | try expect(vec_info == .vector); | |
| 454 | try expect(vec_info.vector.len == 4); | |
| 455 | try expect(vec_info.vector.child == i32); | |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | test "type info: anyframe and anyframe->T" { |
| ... | ... | @@ -468,14 +468,14 @@ test "type info: anyframe and anyframe->T" { |
| 468 | 468 | fn testAnyFrame() !void { |
| 469 | 469 | { |
| 470 | 470 | const anyframe_info = @typeInfo(anyframe->i32); |
| 471 | try expect(anyframe_info == .AnyFrame); | |
| 472 | try expect(anyframe_info.AnyFrame.child.? == i32); | |
| 471 | try expect(anyframe_info == .@"anyframe"); | |
| 472 | try expect(anyframe_info.@"anyframe".child.? == i32); | |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | { |
| 476 | 476 | const anyframe_info = @typeInfo(anyframe); |
| 477 | try expect(anyframe_info == .AnyFrame); | |
| 478 | try expect(anyframe_info.AnyFrame.child == null); | |
| 477 | try expect(anyframe_info == .@"anyframe"); | |
| 478 | try expect(anyframe_info.@"anyframe".child == null); | |
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
| ... | ... | @@ -490,13 +490,13 @@ fn passTypeInfo(comptime info: Type) type { |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | test "type info: TypeId -> Type impl cast" { |
| 493 | _ = passTypeInfo(TypeId.Void); | |
| 494 | _ = comptime passTypeInfo(TypeId.Void); | |
| 493 | _ = passTypeInfo(TypeId.void); | |
| 494 | _ = comptime passTypeInfo(TypeId.void); | |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | test "sentinel of opaque pointer type" { |
| 498 | 498 | const c_void_info = @typeInfo(*anyopaque); |
| 499 | try expect(c_void_info.Pointer.sentinel == null); | |
| 499 | try expect(c_void_info.pointer.sentinel == null); | |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | test "@typeInfo does not force declarations into existence" { |
| ... | ... | @@ -507,7 +507,7 @@ test "@typeInfo does not force declarations into existence" { |
| 507 | 507 | @compileError("test failed"); |
| 508 | 508 | } |
| 509 | 509 | }; |
| 510 | comptime assert(@typeInfo(S).Struct.fields.len == 1); | |
| 510 | comptime assert(@typeInfo(S).@"struct".fields.len == 1); | |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | fn add(a: i32, b: i32) i32 { |
| ... | ... | @@ -521,7 +521,7 @@ test "type info for async frames" { |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | switch (@typeInfo(@Frame(add))) { |
| 524 | .Frame => |frame| { | |
| 524 | .frame => |frame| { | |
| 525 | 525 | try expect(@as(@TypeOf(add), @ptrCast(frame.function)) == add); |
| 526 | 526 | }, |
| 527 | 527 | else => unreachable, |
| ... | ... | @@ -538,7 +538,7 @@ test "Declarations are returned in declaration order" { |
| 538 | 538 | pub const d = 4; |
| 539 | 539 | pub const e = 5; |
| 540 | 540 | }; |
| 541 | const d = @typeInfo(S).Struct.decls; | |
| 541 | const d = @typeInfo(S).@"struct".decls; | |
| 542 | 542 | try expect(std.mem.eql(u8, d[0].name, "a")); |
| 543 | 543 | try expect(std.mem.eql(u8, d[1].name, "b")); |
| 544 | 544 | try expect(std.mem.eql(u8, d[2].name, "c")); |
| ... | ... | @@ -547,19 +547,19 @@ test "Declarations are returned in declaration order" { |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | test "Struct.is_tuple for anon list literal" { |
| 550 | try expect(@typeInfo(@TypeOf(.{0})).Struct.is_tuple); | |
| 550 | try expect(@typeInfo(@TypeOf(.{0})).@"struct".is_tuple); | |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | test "Struct.is_tuple for anon struct literal" { |
| 554 | 554 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 555 | 555 | |
| 556 | 556 | const info = @typeInfo(@TypeOf(.{ .a = 0 })); |
| 557 | try expect(!info.Struct.is_tuple); | |
| 558 | try expect(std.mem.eql(u8, info.Struct.fields[0].name, "a")); | |
| 557 | try expect(!info.@"struct".is_tuple); | |
| 558 | try expect(std.mem.eql(u8, info.@"struct".fields[0].name, "a")); | |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | test "StructField.is_comptime" { |
| 562 | const info = @typeInfo(struct { x: u8 = 3, comptime y: u32 = 5 }).Struct; | |
| 562 | const info = @typeInfo(struct { x: u8 = 3, comptime y: u32 = 5 }).@"struct"; | |
| 563 | 563 | try expect(!info.fields[0].is_comptime); |
| 564 | 564 | try expect(info.fields[1].is_comptime); |
| 565 | 565 | } |
| ... | ... | @@ -574,7 +574,7 @@ test "typeInfo resolves usingnamespace declarations" { |
| 574 | 574 | pub usingnamespace A; |
| 575 | 575 | }; |
| 576 | 576 | |
| 577 | const decls = @typeInfo(B).Struct.decls; | |
| 577 | const decls = @typeInfo(B).@"struct".decls; | |
| 578 | 578 | try expect(decls.len == 2); |
| 579 | 579 | try expectEqualStrings(decls[0].name, "f0"); |
| 580 | 580 | try expectEqualStrings(decls[1].name, "f1"); |
| ... | ... | @@ -582,7 +582,7 @@ test "typeInfo resolves usingnamespace declarations" { |
| 582 | 582 | |
| 583 | 583 | test "value from struct @typeInfo default_value can be loaded at comptime" { |
| 584 | 584 | comptime { |
| 585 | const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).Struct.fields[0].default_value; | |
| 585 | const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).@"struct".fields[0].default_value; | |
| 586 | 586 | try expect(@as(*const u8, @ptrCast(a)).* == 1); |
| 587 | 587 | } |
| 588 | 588 | } |
| ... | ... | @@ -603,7 +603,7 @@ test "@typeInfo decls and usingnamespace" { |
| 603 | 603 | |
| 604 | 604 | test {} |
| 605 | 605 | }; |
| 606 | const decls = @typeInfo(B).Struct.decls; | |
| 606 | const decls = @typeInfo(B).@"struct".decls; | |
| 607 | 607 | try expect(decls.len == 3); |
| 608 | 608 | try expectEqualStrings(decls[0].name, "z"); |
| 609 | 609 | try expectEqualStrings(decls[1].name, "x"); |
| ... | ... | @@ -613,7 +613,7 @@ test "@typeInfo decls and usingnamespace" { |
| 613 | 613 | test "@typeInfo decls ignore dependency loops" { |
| 614 | 614 | const S = struct { |
| 615 | 615 | pub fn Def(comptime T: type) type { |
| 616 | std.debug.assert(@typeInfo(T).Struct.decls.len == 1); | |
| 616 | std.debug.assert(@typeInfo(T).@"struct".decls.len == 1); | |
| 617 | 617 | return struct { |
| 618 | 618 | const foo = u32; |
| 619 | 619 | }; |
| ... | ... | @@ -624,7 +624,7 @@ test "@typeInfo decls ignore dependency loops" { |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | test "type info of tuple of string literal default value" { |
| 627 | const struct_field = @typeInfo(@TypeOf(.{"hi"})).Struct.fields[0]; | |
| 627 | const struct_field = @typeInfo(@TypeOf(.{"hi"})).@"struct".fields[0]; | |
| 628 | 628 | const value = @as(*align(1) const *const [2:0]u8, @ptrCast(struct_field.default_value.?)).*; |
| 629 | 629 | comptime std.debug.assert(value[0] == 'h'); |
| 630 | 630 | } |
| ... | ... | @@ -648,7 +648,7 @@ test "@typeInfo only contains pub decls" { |
| 648 | 648 | }; |
| 649 | 649 | }; |
| 650 | 650 | const ti = @typeInfo(other); |
| 651 | const decls = ti.Struct.decls; | |
| 651 | const decls = ti.@"struct".decls; | |
| 652 | 652 | |
| 653 | 653 | try std.testing.expectEqual(2, decls.len); |
| 654 | 654 | try std.testing.expectEqualStrings("Enum", decls[0].name); |
test/behavior/type_info_mul_linksection_addrspace_decls.zig+1-1| ... | ... | @@ -7,6 +7,6 @@ pub const c addrspace("space_c") = 0; |
| 7 | 7 | pub const d addrspace("space_d") = 0; |
| 8 | 8 | |
| 9 | 9 | test { |
| 10 | const decls = @typeInfo(@This()).Struct.decls; | |
| 10 | const decls = @typeInfo(@This()).@"struct".decls; | |
| 11 | 11 | try expect(decls.len == 4); |
| 12 | 12 | } |
test/behavior/typename.zig+1-1| ... | ... | @@ -110,7 +110,7 @@ test "top level decl" { |
| 110 | 110 | ); |
| 111 | 111 | // regular fn inside struct, with error |
| 112 | 112 | try expectEqualStrings( |
| 113 | "fn () @typeInfo(@typeInfo(@TypeOf(behavior.typename.B.doTest)).Fn.return_type.?).ErrorUnion.error_set!void", | |
| 113 | "fn () @typeInfo(@typeInfo(@TypeOf(behavior.typename.B.doTest)).@\"fn\".return_type.?).error_union.error_set!void", | |
| 114 | 114 | @typeName(@TypeOf(B.doTest)), |
| 115 | 115 | ); |
| 116 | 116 | // generic fn |
test/behavior/union.zig+6-6| ... | ... | @@ -479,7 +479,7 @@ test "global union with single field is correctly initialized" { |
| 479 | 479 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 480 | 480 | |
| 481 | 481 | glbl = Foo1{ |
| 482 | .f = @typeInfo(Foo1).Union.fields[0].type{ .x = 123 }, | |
| 482 | .f = @typeInfo(Foo1).@"union".fields[0].type{ .x = 123 }, | |
| 483 | 483 | }; |
| 484 | 484 | try expect(glbl.f.x == 123); |
| 485 | 485 | } |
| ... | ... | @@ -600,8 +600,8 @@ test "tagged union type" { |
| 600 | 600 | const baz = Baz.B; |
| 601 | 601 | |
| 602 | 602 | try expect(baz == Baz.B); |
| 603 | try expect(@typeInfo(TaggedFoo).Union.fields.len == 3); | |
| 604 | try expect(@typeInfo(Baz).Enum.fields.len == 4); | |
| 603 | try expect(@typeInfo(TaggedFoo).@"union".fields.len == 3); | |
| 604 | try expect(@typeInfo(Baz).@"enum".fields.len == 4); | |
| 605 | 605 | try expect(@sizeOf(TaggedFoo) == @sizeOf(FooNoVoid)); |
| 606 | 606 | try expect(@sizeOf(Baz) == 1); |
| 607 | 607 | } |
| ... | ... | @@ -2305,13 +2305,13 @@ test "create union(enum) from other union(enum)" { |
| 2305 | 2305 | test "matching captures causes union equivalence" { |
| 2306 | 2306 | const S = struct { |
| 2307 | 2307 | fn SignedUnsigned(comptime I: type) type { |
| 2308 | const bits = @typeInfo(I).Int.bits; | |
| 2308 | const bits = @typeInfo(I).int.bits; | |
| 2309 | 2309 | return union { |
| 2310 | u: @Type(.{ .Int = .{ | |
| 2310 | u: @Type(.{ .int = .{ | |
| 2311 | 2311 | .signedness = .unsigned, |
| 2312 | 2312 | .bits = bits, |
| 2313 | 2313 | } }), |
| 2314 | i: @Type(.{ .Int = .{ | |
| 2314 | i: @Type(.{ .int = .{ | |
| 2315 | 2315 | .signedness = .signed, |
| 2316 | 2316 | .bits = bits, |
| 2317 | 2317 | } }), |
test/behavior/usingnamespace.zig+1-1| ... | ... | @@ -109,7 +109,7 @@ test "container member access usingnamespace decls" { |
| 109 | 109 | |
| 110 | 110 | usingnamespace opaque {}; |
| 111 | 111 | |
| 112 | usingnamespace @Type(.{ .Struct = .{ | |
| 112 | usingnamespace @Type(.{ .@"struct" = .{ | |
| 113 | 113 | .layout = .auto, |
| 114 | 114 | .fields = &.{}, |
| 115 | 115 | .decls = &.{}, |
test/behavior/vector.zig+17-17| ... | ... | @@ -564,7 +564,7 @@ test "vector division operators" { |
| 564 | 564 | const S = struct { |
| 565 | 565 | fn doTheTestDiv(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) !void { |
| 566 | 566 | const is_signed_int = switch (@typeInfo(T)) { |
| 567 | .Int => |info| info.signedness == .signed, | |
| 567 | .int => |info| info.signedness == .signed, | |
| 568 | 568 | else => false, |
| 569 | 569 | }; |
| 570 | 570 | if (!is_signed_int) { |
| ... | ... | @@ -589,10 +589,10 @@ test "vector division operators" { |
| 589 | 589 | |
| 590 | 590 | fn doTheTestMod(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) !void { |
| 591 | 591 | const is_signed_int = switch (@typeInfo(T)) { |
| 592 | .Int => |info| info.signedness == .signed, | |
| 592 | .int => |info| info.signedness == .signed, | |
| 593 | 593 | else => false, |
| 594 | 594 | }; |
| 595 | if (!is_signed_int and @typeInfo(T) != .Float) { | |
| 595 | if (!is_signed_int and @typeInfo(T) != .float) { | |
| 596 | 596 | const r0 = x % y; |
| 597 | 597 | for (@as([4]T, r0), 0..) |v, i| { |
| 598 | 598 | try expect(x[i] % y[i] == v); |
| ... | ... | @@ -686,9 +686,9 @@ test "vector shift operators" { |
| 686 | 686 | |
| 687 | 687 | const S = struct { |
| 688 | 688 | fn doTheTestShift(x: anytype, y: anytype) !void { |
| 689 | const N = @typeInfo(@TypeOf(x)).Array.len; | |
| 690 | const TX = @typeInfo(@TypeOf(x)).Array.child; | |
| 691 | const TY = @typeInfo(@TypeOf(y)).Array.child; | |
| 689 | const N = @typeInfo(@TypeOf(x)).array.len; | |
| 690 | const TX = @typeInfo(@TypeOf(x)).array.child; | |
| 691 | const TY = @typeInfo(@TypeOf(y)).array.child; | |
| 692 | 692 | |
| 693 | 693 | const xv = @as(@Vector(N, TX), x); |
| 694 | 694 | const yv = @as(@Vector(N, TY), y); |
| ... | ... | @@ -703,9 +703,9 @@ test "vector shift operators" { |
| 703 | 703 | } |
| 704 | 704 | } |
| 705 | 705 | fn doTheTestShiftExact(x: anytype, y: anytype, dir: enum { Left, Right }) !void { |
| 706 | const N = @typeInfo(@TypeOf(x)).Array.len; | |
| 707 | const TX = @typeInfo(@TypeOf(x)).Array.child; | |
| 708 | const TY = @typeInfo(@TypeOf(y)).Array.child; | |
| 706 | const N = @typeInfo(@TypeOf(x)).array.len; | |
| 707 | const TX = @typeInfo(@TypeOf(x)).array.child; | |
| 708 | const TY = @typeInfo(@TypeOf(y)).array.child; | |
| 709 | 709 | |
| 710 | 710 | const xv = @as(@Vector(N, TX), x); |
| 711 | 711 | const yv = @as(@Vector(N, TY), y); |
| ... | ... | @@ -777,13 +777,13 @@ test "vector reduce operation" { |
| 777 | 777 | |
| 778 | 778 | const S = struct { |
| 779 | 779 | fn testReduce(comptime op: std.builtin.ReduceOp, x: anytype, expected: anytype) !void { |
| 780 | const N = @typeInfo(@TypeOf(x)).Array.len; | |
| 781 | const TX = @typeInfo(@TypeOf(x)).Array.child; | |
| 780 | const N = @typeInfo(@TypeOf(x)).array.len; | |
| 781 | const TX = @typeInfo(@TypeOf(x)).array.child; | |
| 782 | 782 | |
| 783 | 783 | const r = @reduce(op, @as(@Vector(N, TX), x)); |
| 784 | 784 | switch (@typeInfo(TX)) { |
| 785 | .Int, .Bool => try expect(expected == r), | |
| 786 | .Float => { | |
| 785 | .int, .bool => try expect(expected == r), | |
| 786 | .float => { | |
| 787 | 787 | const expected_nan = math.isNan(expected); |
| 788 | 788 | const got_nan = math.isNan(r); |
| 789 | 789 | |
| ... | ... | @@ -941,10 +941,10 @@ test "mask parameter of @shuffle is comptime scope" { |
| 941 | 941 | var v4_b = __v4hi{ 5, 6, 7, 8 }; |
| 942 | 942 | _ = .{ &v4_a, &v4_b }; |
| 943 | 943 | const shuffled: __v4hi = @shuffle(i16, v4_a, v4_b, @Vector(4, i32){ |
| 944 | std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 945 | std.zig.c_translation.shuffleVectorIndex(2, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 946 | std.zig.c_translation.shuffleVectorIndex(4, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 947 | std.zig.c_translation.shuffleVectorIndex(6, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 944 | std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).vector.len), | |
| 945 | std.zig.c_translation.shuffleVectorIndex(2, @typeInfo(@TypeOf(v4_a)).vector.len), | |
| 946 | std.zig.c_translation.shuffleVectorIndex(4, @typeInfo(@TypeOf(v4_a)).vector.len), | |
| 947 | std.zig.c_translation.shuffleVectorIndex(6, @typeInfo(@TypeOf(v4_a)).vector.len), | |
| 948 | 948 | }); |
| 949 | 949 | try expect(shuffled[0] == 1); |
| 950 | 950 | try expect(shuffled[1] == 3); |
test/c_import/macros.zig+1-1| ... | ... | @@ -222,7 +222,7 @@ test "Macro that uses remainder operator. Issue #13346" { |
| 222 | 222 | test "@typeInfo on @cImport result" { |
| 223 | 223 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 224 | 224 | |
| 225 | try expect(@typeInfo(h).Struct.decls.len > 1); | |
| 225 | try expect(@typeInfo(h).@"struct".decls.len > 1); | |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | test "Macro that uses Long type concatenation casting" { |
test/cases/compile_errors/@errorCast_with_bad_type.zig+2-2| ... | ... | @@ -23,8 +23,8 @@ pub export fn entry4() void { |
| 23 | 23 | // backend=stage2 |
| 24 | 24 | // target=x86_64-linux |
| 25 | 25 | // |
| 26 | // :4:25: error: expected error set or error union type, found 'ComptimeInt' | |
| 27 | // :8:20: error: expected error set or error union type, found 'Int' | |
| 26 | // :4:25: error: expected error set or error union type, found 'comptime_int' | |
| 27 | // :8:20: error: expected error set or error union type, found 'int' | |
| 28 | 28 | // :13:25: error: cannot cast an error union type to error set |
| 29 | 29 | // :18:29: error: payload types of error unions must match |
| 30 | 30 | // :18:29: note: destination payload is 'f32' |
test/cases/compile_errors/access_invalid_typeInfo_decl.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const A = B; |
| 2 | 2 | test "Crash" { |
| 3 | _ = @typeInfo(@This()).Struct.decls[0]; | |
| 3 | _ = @typeInfo(@This()).@"struct".decls[0]; | |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
test/cases/compile_errors/addition_with_non_numbers.zig+1-1| ... | ... | @@ -11,4 +11,4 @@ export fn entry() usize { |
| 11 | 11 | // backend=llvm |
| 12 | 12 | // target=native |
| 13 | 13 | // |
| 14 | // :4:29: error: invalid operands to binary expression: 'Struct' and 'Struct' | |
| 14 | // :4:29: error: invalid operands to binary expression: 'struct' and 'struct' |
test/cases/compile_errors/array_init_generic_fn_with_inferred_error_set.zig+2-2| ... | ... | @@ -8,5 +8,5 @@ fn my_func(comptime T: type) !T {} |
| 8 | 8 | |
| 9 | 9 | // error |
| 10 | 10 | // |
| 11 | // :2:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype' | |
| 12 | // :5:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype' | |
| 11 | // :2:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).@"fn".return_type.?).error_union.error_set!anytype' | |
| 12 | // :5:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).@"fn".return_type.?).error_union.error_set!anytype' |
test/cases/compile_errors/attempt_to_create_17_bit_float_type.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const builtin = @import("std").builtin; |
| 2 | 2 | comptime { |
| 3 | _ = @Type(.{ .Float = .{ .bits = 17 } }); | |
| 3 | _ = @Type(.{ .float = .{ .bits = 17 } }); | |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
test/cases/compile_errors/binary_OR_operator_on_error_sets.zig+1-1| ... | ... | @@ -9,4 +9,4 @@ export fn entry() void { |
| 9 | 9 | // backend=stage2 |
| 10 | 10 | // target=native |
| 11 | 11 | // |
| 12 | // :2:18: error: invalid operands to binary bitwise expression: 'ErrorSet' and 'ErrorSet' | |
| 12 | // :2:18: error: invalid operands to binary bitwise expression: 'error_set' and 'error_set' |
test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ pub export fn entry() void { |
| 6 | 6 | const Widget = union(enum) { a: u0 }; |
| 7 | 7 | |
| 8 | 8 | comptime var a = 1; |
| 9 | const info = @typeInfo(Widget).Union; | |
| 9 | const info = @typeInfo(Widget).@"union"; | |
| 10 | 10 | inline for (info.fields) |field| { |
| 11 | 11 | if (foo()) { |
| 12 | 12 | switch (field.type) { |
test/cases/compile_errors/dereference_anyopaque.zig+2-2| ... | ... | @@ -13,13 +13,13 @@ fn parse(comptime T: type, allocator: std.mem.Allocator) !void { |
| 13 | 13 | |
| 14 | 14 | fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void { |
| 15 | 15 | switch (@typeInfo(T)) { |
| 16 | .Struct => |structInfo| { | |
| 16 | .@"struct" => |structInfo| { | |
| 17 | 17 | inline for (structInfo.fields) |field| { |
| 18 | 18 | if (!field.is_comptime) |
| 19 | 19 | parseFree(field.type, undefined, allocator); |
| 20 | 20 | } |
| 21 | 21 | }, |
| 22 | .Pointer => |ptrInfo| { | |
| 22 | .pointer => |ptrInfo| { | |
| 23 | 23 | switch (ptrInfo.size) { |
| 24 | 24 | .One => { |
| 25 | 25 | parseFree(ptrInfo.child, value.*, allocator); |
test/cases/compile_errors/error_set_membership.zig+1-1| ... | ... | @@ -27,5 +27,5 @@ pub fn main() Error!void { |
| 27 | 27 | // backend=llvm |
| 28 | 28 | // target=native |
| 29 | 29 | // |
| 30 | // :23:29: error: expected type 'error{InvalidCharacter}', found '@typeInfo(@typeInfo(@TypeOf(tmp.fooey)).Fn.return_type.?).ErrorUnion.error_set' | |
| 30 | // :23:29: error: expected type 'error{InvalidCharacter}', found '@typeInfo(@typeInfo(@TypeOf(tmp.fooey)).@"fn".return_type.?).error_union.error_set' | |
| 31 | 31 | // :23:29: note: 'error.InvalidDirection' not a member of destination error set |
test/cases/compile_errors/for_loop_error_union.zig+1-1| ... | ... | @@ -10,6 +10,6 @@ export fn a() void { |
| 10 | 10 | // backend=stage2 |
| 11 | 11 | // target=native |
| 12 | 12 | // |
| 13 | // :6:11: error: type '@typeInfo(@typeInfo(@TypeOf(tmp.b)).Fn.return_type.?).ErrorUnion.error_set!u32' is not indexable and not a range | |
| 13 | // :6:11: error: type '@typeInfo(@typeInfo(@TypeOf(tmp.b)).@"fn".return_type.?).error_union.error_set!u32' is not indexable and not a range | |
| 14 | 14 | // :6:11: note: for loop operand must be a range, array, slice, tuple, or vector |
| 15 | 15 | // :6:11: note: consider using 'try', 'catch', or 'if' |
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig+3-3| ... | ... | @@ -5,7 +5,7 @@ pub export fn entry() void { |
| 5 | 5 | _ = sliceAsBytes(ohnoes); |
| 6 | 6 | _ = &ohnoes; |
| 7 | 7 | } |
| 8 | fn sliceAsBytes(slice: anytype) isPtrTo(.Array)(@TypeOf(slice)) {} | |
| 8 | fn sliceAsBytes(slice: anytype) isPtrTo(.array)(@TypeOf(slice)) {} | |
| 9 | 9 | |
| 10 | 10 | pub const TraitFn = fn (type) bool; |
| 11 | 11 | |
| ... | ... | @@ -20,8 +20,8 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | pub fn isSingleItemPtr(comptime T: type) bool { |
| 23 | if (comptime is(.Pointer)(T)) { | |
| 24 | return @typeInfo(T).Pointer.size == .One; | |
| 23 | if (comptime is(.pointer)(T)) { | |
| 24 | return @typeInfo(T).pointer.size == .One; | |
| 25 | 25 | } |
| 26 | 26 | return false; |
| 27 | 27 | } |
test/cases/compile_errors/helpful_return_type_error_message.zig+3-3| ... | ... | @@ -21,12 +21,12 @@ export fn quux() u32 { |
| 21 | 21 | // |
| 22 | 22 | // :2:18: error: expected type 'u32', found 'error{Ohno}' |
| 23 | 23 | // :1:17: note: function cannot return an error |
| 24 | // :8:5: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).Fn.return_type.?).ErrorUnion.error_set' | |
| 24 | // :8:5: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).@"fn".return_type.?).error_union.error_set' | |
| 25 | 25 | // :7:17: note: function cannot return an error |
| 26 | // :11:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).Fn.return_type.?).ErrorUnion.error_set!u32' | |
| 26 | // :11:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).@"fn".return_type.?).error_union.error_set!u32' | |
| 27 | 27 | // :11:15: note: cannot convert error union to payload type |
| 28 | 28 | // :11:15: note: consider using 'try', 'catch', or 'if' |
| 29 | 29 | // :10:17: note: function cannot return an error |
| 30 | // :15:14: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).Fn.return_type.?).ErrorUnion.error_set!u32' | |
| 30 | // :15:14: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).@"fn".return_type.?).error_union.error_set!u32' | |
| 31 | 31 | // :15:14: note: cannot convert error union to payload type |
| 32 | 32 | // :15:14: note: consider using 'try', 'catch', or 'if' |
test/cases/compile_errors/invalid_pointer_arithmetic.zig+1-1| ... | ... | @@ -45,7 +45,7 @@ comptime { |
| 45 | 45 | // :2:11: note: pointer-integer arithmetic only supports addition and subtraction |
| 46 | 46 | // :6:11: error: invalid pointer-pointer arithmetic operator |
| 47 | 47 | // :6:11: note: pointer-pointer arithmetic only supports subtraction |
| 48 | // :12:11: error: invalid operands to binary expression: 'Pointer' and 'Pointer' | |
| 48 | // :12:11: error: invalid operands to binary expression: 'pointer' and 'pointer' | |
| 49 | 49 | // :20:11: error: incompatible pointer arithmetic operands '[*]u8' and '[*]u16' |
| 50 | 50 | // :26:11: error: incompatible pointer arithmetic operands '*u8' and '*u16' |
| 51 | 51 | // :31:11: error: pointer arithmetic requires element type 'u0' to have runtime bits |
test/cases/compile_errors/invalid_pointer_with_reify_type.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ .Pointer = .{ | |
| 2 | _ = @Type(.{ .pointer = .{ | |
| 3 | 3 | .size = .One, |
| 4 | 4 | .is_const = false, |
| 5 | 5 | .is_volatile = false, |
test/cases/compile_errors/issue_15572_break_on_inline_while.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ pub const DwarfSection = enum { |
| 6 | 6 | }; |
| 7 | 7 | |
| 8 | 8 | pub fn main() void { |
| 9 | const section = inline for (@typeInfo(DwarfSection).Enum.fields) |section| { | |
| 9 | const section = inline for (@typeInfo(DwarfSection).@"enum".fields) |section| { | |
| 10 | 10 | if (std.mem.eql(u8, section.name, "eh_frame")) break section; |
| 11 | 11 | }; |
| 12 | 12 |
test/cases/compile_errors/issue_5221_invalid_struct_init_type_referenced_by_typeInfo_and_passed_into_function.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ export fn foo() void { |
| 7 | 7 | wrong_type: []u8 = "foo", |
| 8 | 8 | }; |
| 9 | 9 | |
| 10 | comptime ignore(@typeInfo(MyStruct).Struct.fields[0]); | |
| 10 | comptime ignore(@typeInfo(MyStruct).@"struct".fields[0]); | |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | // error |
test/cases/compile_errors/method_call_on_error_union.zig+1-1| ... | ... | @@ -17,5 +17,5 @@ export fn entry() void { |
| 17 | 17 | // backend=stage2 |
| 18 | 18 | // target=native |
| 19 | 19 | // |
| 20 | // :13:6: error: no field or member function named 'a' in '@typeInfo(@typeInfo(@TypeOf(tmp.X.init)).Fn.return_type.?).ErrorUnion.error_set!tmp.X' | |
| 20 | // :13:6: error: no field or member function named 'a' in '@typeInfo(@typeInfo(@TypeOf(tmp.X.init)).@"fn".return_type.?).error_union.error_set!tmp.X' | |
| 21 | 21 | // :13:6: note: consider using 'try', 'catch', or 'if' |
test/cases/compile_errors/nested_vectors.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 2 | const V1 = @Vector(4, u8); |
| 3 | const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } }); | |
| 3 | const V2 = @Type(.{ .vector = .{ .len = 4, .child = V1 } }); | |
| 4 | 4 | const v: V2 = undefined; |
| 5 | 5 | _ = v; |
| 6 | 6 | } |
test/cases/compile_errors/non-enum_tag_type_passed_to_union.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ const Foo = union(u32) { |
| 2 | 2 | A: i32, |
| 3 | 3 | }; |
| 4 | 4 | export fn entry() void { |
| 5 | const x = @typeInfo(Foo).Union.tag_type.?; | |
| 5 | const x = @typeInfo(Foo).@"union".tag_type.?; | |
| 6 | 6 | _ = x; |
| 7 | 7 | } |
| 8 | 8 |
test/cases/compile_errors/non-integer_tag_type_to_automatic_union_enum.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ const Foo = union(enum(f32)) { |
| 2 | 2 | A: i32, |
| 3 | 3 | }; |
| 4 | 4 | export fn entry() void { |
| 5 | const x = @typeInfo(Foo).Union.tag_type.?; | |
| 5 | const x = @typeInfo(Foo).@"union".tag_type.?; | |
| 6 | 6 | _ = x; |
| 7 | 7 | } |
| 8 | 8 |
test/cases/compile_errors/not_an_enum_type.zig+1-1| ... | ... | @@ -16,5 +16,5 @@ const ExpectedVarDeclOrFn = struct {}; |
| 16 | 16 | // backend=stage2 |
| 17 | 17 | // target=native |
| 18 | 18 | // |
| 19 | // :4:9: error: expected type '@typeInfo(tmp.Error).Union.tag_type.?', found 'type' | |
| 19 | // :4:9: error: expected type '@typeInfo(tmp.Error).@"union".tag_type.?', found 'type' | |
| 20 | 20 | // :8:15: note: enum declared here |
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ .Struct = .{ .layout = .@"packed", .fields = &.{ | |
| 2 | _ = @Type(.{ .@"struct" = .{ .layout = .@"packed", .fields = &.{ | |
| 3 | 3 | .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, |
| 4 | 4 | }, .decls = &.{}, .is_tuple = false } }); |
| 5 | 5 | } |
test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig+1-1| ... | ... | @@ -16,5 +16,5 @@ fn foo(x: i32) !void { |
| 16 | 16 | // backend=llvm |
| 17 | 17 | // target=native |
| 18 | 18 | // |
| 19 | // :2:34: error: ranges not allowed when switching on type '@typeInfo(@typeInfo(@TypeOf(tmp.foo)).Fn.return_type.?).ErrorUnion.error_set' | |
| 19 | // :2:34: error: ranges not allowed when switching on type '@typeInfo(@typeInfo(@TypeOf(tmp.foo)).@"fn".return_type.?).error_union.error_set' | |
| 20 | 20 | // :3:18: note: range here |
test/cases/compile_errors/regression_test_2980_base_type_u32_is_not_type_checked_properly_when_assigning_a_value_within_a_struct.zig+1-1| ... | ... | @@ -18,6 +18,6 @@ export fn entry() void { |
| 18 | 18 | // backend=stage2 |
| 19 | 19 | // target=native |
| 20 | 20 | // |
| 21 | // :12:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.get_uval)).Fn.return_type.?).ErrorUnion.error_set!u32' | |
| 21 | // :12:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.get_uval)).@"fn".return_type.?).error_union.error_set!u32' | |
| 22 | 22 | // :12:15: note: cannot convert error union to payload type |
| 23 | 23 | // :12:15: note: consider using 'try', 'catch', or 'if' |
test/cases/compile_errors/reified_enum_field_value_overflow.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | comptime { |
| 2 | const E = @Type(.{ .Enum = .{ | |
| 2 | const E = @Type(.{ .@"enum" = .{ | |
| 3 | 3 | .tag_type = u1, |
| 4 | 4 | .fields = &.{ |
| 5 | 5 | .{ .name = "f0", .value = 0 }, |
test/cases/compile_errors/reify_enum_with_duplicate_field.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 2 | _ = @Type(.{ |
| 3 | .Enum = .{ | |
| 3 | .@"enum" = .{ | |
| 4 | 4 | .tag_type = u32, |
| 5 | 5 | .fields = &.{ |
| 6 | 6 | .{ .name = "A", .value = 0 }, |
test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 2 | _ = @Type(.{ |
| 3 | .Enum = .{ | |
| 3 | .@"enum" = .{ | |
| 4 | 4 | .tag_type = u32, |
| 5 | 5 | .fields = &.{ |
| 6 | 6 | .{ .name = "A", .value = 10 }, |
test/cases/compile_errors/reify_struct.zig+5-5| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | comptime { |
| 2 | @Type(.{ .Struct = .{ | |
| 2 | @Type(.{ .@"struct" = .{ | |
| 3 | 3 | .layout = .auto, |
| 4 | 4 | .fields = &.{.{ |
| 5 | 5 | .name = "foo", |
| ... | ... | @@ -13,7 +13,7 @@ comptime { |
| 13 | 13 | } }); |
| 14 | 14 | } |
| 15 | 15 | comptime { |
| 16 | @Type(.{ .Struct = .{ | |
| 16 | @Type(.{ .@"struct" = .{ | |
| 17 | 17 | .layout = .auto, |
| 18 | 18 | .fields = &.{.{ |
| 19 | 19 | .name = "3", |
| ... | ... | @@ -27,7 +27,7 @@ comptime { |
| 27 | 27 | } }); |
| 28 | 28 | } |
| 29 | 29 | comptime { |
| 30 | @Type(.{ .Struct = .{ | |
| 30 | @Type(.{ .@"struct" = .{ | |
| 31 | 31 | .layout = .auto, |
| 32 | 32 | .fields = &.{.{ |
| 33 | 33 | .name = "0", |
| ... | ... | @@ -41,7 +41,7 @@ comptime { |
| 41 | 41 | } }); |
| 42 | 42 | } |
| 43 | 43 | comptime { |
| 44 | @Type(.{ .Struct = .{ | |
| 44 | @Type(.{ .@"struct" = .{ | |
| 45 | 45 | .layout = .@"extern", |
| 46 | 46 | .fields = &.{.{ |
| 47 | 47 | .name = "0", |
| ... | ... | @@ -55,7 +55,7 @@ comptime { |
| 55 | 55 | } }); |
| 56 | 56 | } |
| 57 | 57 | comptime { |
| 58 | @Type(.{ .Struct = .{ | |
| 58 | @Type(.{ .@"struct" = .{ | |
| 59 | 59 | .layout = .@"packed", |
| 60 | 60 | .fields = &.{.{ |
| 61 | 61 | .name = "0", |
test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Foo = @Type(.{ |
| 2 | .Fn = .{ | |
| 2 | .@"fn" = .{ | |
| 3 | 3 | .calling_convention = .Unspecified, |
| 4 | 4 | .is_generic = true, |
| 5 | 5 | .is_var_args = false, |
test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Foo = @Type(.{ |
| 2 | .Fn = .{ | |
| 2 | .@"fn" = .{ | |
| 3 | 3 | .calling_convention = .Unspecified, |
| 4 | 4 | .is_generic = false, |
| 5 | 5 | .is_var_args = true, |
test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Foo = @Type(.{ |
| 2 | .Fn = .{ | |
| 2 | .@"fn" = .{ | |
| 3 | 3 | .calling_convention = .Unspecified, |
| 4 | 4 | .is_generic = false, |
| 5 | 5 | .is_var_args = false, |
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | |
| 2 | .@"enum" = .{ | |
| 3 | 3 | .tag_type = bool, |
| 4 | 4 | .fields = &.{}, |
| 5 | 5 | .decls = &.{}, |
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | |
| 2 | .@"enum" = .{ | |
| 3 | 3 | .tag_type = undefined, |
| 4 | 4 | .fields = &.{}, |
| 5 | 5 | .decls = &.{}, |
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | |
| 2 | .@"enum" = .{ | |
| 3 | 3 | .tag_type = u2, |
| 4 | 4 | .fields = &.{ |
| 5 | 5 | .{ .name = "signed", .value = 0 }, |
| ... | ... | @@ -11,7 +11,7 @@ const Tag = @Type(.{ |
| 11 | 11 | }, |
| 12 | 12 | }); |
| 13 | 13 | const Tagged = @Type(.{ |
| 14 | .Union = .{ | |
| 14 | .@"union" = .{ | |
| 15 | 15 | .layout = .auto, |
| 16 | 16 | .tag_type = Tag, |
| 17 | 17 | .fields = &.{ |
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | |
| 2 | .@"enum" = .{ | |
| 3 | 3 | .tag_type = u1, |
| 4 | 4 | .fields = &.{ |
| 5 | 5 | .{ .name = "signed", .value = 0 }, |
| ... | ... | @@ -10,7 +10,7 @@ const Tag = @Type(.{ |
| 10 | 10 | }, |
| 11 | 11 | }); |
| 12 | 12 | const Tagged = @Type(.{ |
| 13 | .Union = .{ | |
| 13 | .@"union" = .{ | |
| 14 | 14 | .layout = .auto, |
| 15 | 15 | .tag_type = Tag, |
| 16 | 16 | .fields = &.{ |
test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | |
| 2 | .@"enum" = .{ | |
| 3 | 3 | .tag_type = u0, |
| 4 | 4 | .fields = &.{}, |
| 5 | 5 | .decls = &.{}, |
| ... | ... | @@ -7,7 +7,7 @@ const Tag = @Type(.{ |
| 7 | 7 | }, |
| 8 | 8 | }); |
| 9 | 9 | const Tagged = @Type(.{ |
| 10 | .Union = .{ | |
| 10 | .@"union" = .{ | |
| 11 | 11 | .layout = .auto, |
| 12 | 12 | .tag_type = Tag, |
| 13 | 13 | .fields = &.{ |
test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | |
| 2 | .@"enum" = .{ | |
| 3 | 3 | .tag_type = u1, |
| 4 | 4 | .fields = &.{ |
| 5 | 5 | .{ .name = "signed", .value = 0 }, |
| ... | ... | @@ -10,7 +10,7 @@ const Tag = @Type(.{ |
| 10 | 10 | }, |
| 11 | 11 | }); |
| 12 | 12 | const Tagged = @Type(.{ |
| 13 | .Union = .{ | |
| 13 | .@"union" = .{ | |
| 14 | 14 | .layout = .auto, |
| 15 | 15 | .tag_type = Tag, |
| 16 | 16 | .fields = &.{}, |
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Untagged = @Type(.{ |
| 2 | .Union = .{ | |
| 2 | .@"union" = .{ | |
| 3 | 3 | .layout = .auto, |
| 4 | 4 | .tag_type = null, |
| 5 | 5 | .fields = &.{ |
test/cases/compile_errors/reify_type_union_payload_is_undefined.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const Foo = @Type(.{ |
| 2 | .Struct = undefined, | |
| 2 | .@"struct" = undefined, | |
| 3 | 3 | }); |
| 4 | 4 | comptime { |
| 5 | 5 | _ = Foo; |
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+3-3| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | comptime { |
| 2 | 2 | _ = @Type(.{ |
| 3 | .Union = .{ | |
| 3 | .@"union" = .{ | |
| 4 | 4 | .layout = .auto, |
| 5 | 5 | .tag_type = null, |
| 6 | 6 | .fields = &.{ |
| ... | ... | @@ -12,7 +12,7 @@ comptime { |
| 12 | 12 | } |
| 13 | 13 | comptime { |
| 14 | 14 | _ = @Type(.{ |
| 15 | .Struct = .{ | |
| 15 | .@"struct" = .{ | |
| 16 | 16 | .layout = .auto, |
| 17 | 17 | .fields = &.{.{ |
| 18 | 18 | .name = "0", |
| ... | ... | @@ -28,7 +28,7 @@ comptime { |
| 28 | 28 | } |
| 29 | 29 | comptime { |
| 30 | 30 | _ = @Type(.{ |
| 31 | .Pointer = .{ | |
| 31 | .pointer = .{ | |
| 32 | 32 | .size = .Many, |
| 33 | 33 | .is_const = true, |
| 34 | 34 | .is_volatile = false, |
test/cases/compile_errors/reify_type_with_undefined.zig+3-3| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | comptime { |
| 2 | _ = @Type(.{ .Array = .{ .len = 0, .child = u8, .sentinel = undefined } }); | |
| 2 | _ = @Type(.{ .array = .{ .len = 0, .child = u8, .sentinel = undefined } }); | |
| 3 | 3 | } |
| 4 | 4 | comptime { |
| 5 | 5 | _ = @Type(.{ |
| 6 | .Struct = .{ | |
| 6 | .@"struct" = .{ | |
| 7 | 7 | .fields = undefined, |
| 8 | 8 | .decls = undefined, |
| 9 | 9 | .is_tuple = false, |
| ... | ... | @@ -15,7 +15,7 @@ comptime { |
| 15 | 15 | const std = @import("std"); |
| 16 | 16 | const fields: [1]std.builtin.Type.StructField = undefined; |
| 17 | 17 | _ = @Type(.{ |
| 18 | .Struct = .{ | |
| 18 | .@"struct" = .{ | |
| 19 | 19 | .layout = .auto, |
| 20 | 20 | .fields = &fields, |
| 21 | 21 | .decls = &.{}, |
test/cases/compile_errors/resolve_inferred_error_set_of_generic_fn.zig+2-2| ... | ... | @@ -5,8 +5,8 @@ fn foo(a: anytype) !void { |
| 5 | 5 | const Error = error{ A, B }; |
| 6 | 6 | export fn entry() void { |
| 7 | 7 | const info = @typeInfo(@TypeOf(foo)); |
| 8 | const ret_type = info.Fn.return_type.?; | |
| 9 | const error_set = @typeInfo(ret_type).ErrorUnion.error_set; | |
| 8 | const ret_type = info.@"fn".return_type.?; | |
| 9 | const error_set = @typeInfo(ret_type).error_union.error_set; | |
| 10 | 10 | _ = Error || error_set; |
| 11 | 11 | } |
| 12 | 12 |
test/cases/compile_errors/runtime_index_into_comptime_type_slice.zig+2-2| ... | ... | @@ -6,7 +6,7 @@ fn getIndex() usize { |
| 6 | 6 | } |
| 7 | 7 | export fn entry() void { |
| 8 | 8 | const index = getIndex(); |
| 9 | const field = @typeInfo(Struct).Struct.fields[index]; | |
| 9 | const field = @typeInfo(Struct).@"struct".fields[index]; | |
| 10 | 10 | _ = field; |
| 11 | 11 | } |
| 12 | 12 | |
| ... | ... | @@ -14,7 +14,7 @@ export fn entry() void { |
| 14 | 14 | // backend=stage2 |
| 15 | 15 | // target=native |
| 16 | 16 | // |
| 17 | // :9:51: error: values of type '[]const builtin.Type.StructField' must be comptime-known, but index value is runtime-known | |
| 17 | // :9:54: error: values of type '[]const builtin.Type.StructField' must be comptime-known, but index value is runtime-known | |
| 18 | 18 | // : note: struct requires comptime because of this field |
| 19 | 19 | // : note: types are not available at runtime |
| 20 | 20 | // : struct requires comptime because of this field |
test/cases/compile_errors/saturating_arithmetic_does_not_allow_floats.zig+1-1| ... | ... | @@ -6,4 +6,4 @@ export fn a() void { |
| 6 | 6 | // backend=stage2 |
| 7 | 7 | // target=native |
| 8 | 8 | // |
| 9 | // :2:23: error: invalid operands to binary expression: 'Float' and 'Float' | |
| 9 | // :2:23: error: invalid operands to binary expression: 'float' and 'float' |
test/cases/compile_errors/switch_on_error_with_non_trivial_switch_operand.zig+2-2| ... | ... | @@ -18,5 +18,5 @@ export fn entry2() void { |
| 18 | 18 | // backend=stage2 |
| 19 | 19 | // target=native |
| 20 | 20 | // |
| 21 | // :4:42: error: invalid operands to binary expression: 'ErrorSet' and 'ComptimeInt' | |
| 22 | // :12:35: error: invalid operands to binary expression: 'ErrorSet' and 'ComptimeInt' | |
| 21 | // :4:42: error: invalid operands to binary expression: 'error_set' and 'comptime_int' | |
| 22 | // :12:35: error: invalid operands to binary expression: 'error_set' and 'comptime_int' |
test/cases/compile_errors/unable_to_evaluate_comptime_expr.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ pub export fn entry2() void { |
| 16 | 16 | _ = b; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | const Int = @typeInfo(bar).Struct.backing_integer.?; | |
| 19 | const Int = @typeInfo(bar).@"struct".backing_integer.?; | |
| 20 | 20 | |
| 21 | 21 | const foo = enum(Int) { |
| 22 | 22 | c = @bitCast(bar{ |
test/cases/compile_errors/union_fields_are_resolved_before_tag_type_is_needed.zig+1-1| ... | ... | @@ -12,5 +12,5 @@ pub export fn entry() void { |
| 12 | 12 | // backend=stage2 |
| 13 | 13 | // target=native |
| 14 | 14 | // |
| 15 | // :8:8: error: no field or member function named 'f' in '@typeInfo(tmp.T).Union.tag_type.?' | |
| 15 | // :8:8: error: no field or member function named 'f' in '@typeInfo(tmp.T).@"union".tag_type.?' | |
| 16 | 16 | // :1:11: note: enum declared here |
test/cases/compile_errors/union_noreturn_field_initialized.zig+2-2| ... | ... | @@ -23,7 +23,7 @@ pub export fn entry3() void { |
| 23 | 23 | a: noreturn, |
| 24 | 24 | b: void, |
| 25 | 25 | }; |
| 26 | var e = @typeInfo(U).Union.tag_type.?.a; | |
| 26 | var e = @typeInfo(U).@"union".tag_type.?.a; | |
| 27 | 27 | var u: U = undefined; |
| 28 | 28 | u = (&e).*; |
| 29 | 29 | } |
| ... | ... | @@ -38,6 +38,6 @@ pub export fn entry3() void { |
| 38 | 38 | // :19:10: error: cannot initialize 'noreturn' field of union |
| 39 | 39 | // :16:9: note: field 'a' declared here |
| 40 | 40 | // :15:15: note: union declared here |
| 41 | // :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).Union.tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field | |
| 41 | // :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).@"union".tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field | |
| 42 | 42 | // :23:9: note: 'noreturn' field here |
| 43 | 43 | // :22:15: note: union declared here |
test/cases/fn_typeinfo_passed_to_comptime_fn.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 { |
| 9 | 9 | return 8; |
| 10 | 10 | } |
| 11 | 11 | fn foo(comptime info: std.builtin.Type) !void { |
| 12 | try std.testing.expect(info.Fn.params[0].type.? == ?*c_int); | |
| 12 | try std.testing.expect(info.@"fn".params[0].type.? == ?*c_int); | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // run |
test/cases/safety/@tagName on corrupted union value.zig	+1-1| ... | ... | @@ -16,7 +16,7 @@ const U = union(enum(u32)) { |
| 16 | 16 | pub fn main() !void { |
| 17 | 17 | var u: U = undefined; |
| 18 | 18 | @memset(@as([*]u8, @ptrCast(&u))[0..@sizeOf(U)], 0x55); |
| 19 | const t: @typeInfo(U).Union.tag_type.? = u; | |
| 19 | const t: @typeInfo(U).@"union".tag_type.? = u; | |
| 20 | 20 | const n = @tagName(t); |
| 21 | 21 | _ = n; |
| 22 | 22 | return error.TestFailed; |
test/link/build.zig+1-1| ... | ... | @@ -23,7 +23,7 @@ pub fn build(b: *std.Build) void { |
| 23 | 23 | const dep_name, const dep_hash = available_dep; |
| 24 | 24 | |
| 25 | 25 | const all_pkgs = @import("root").dependencies.packages; |
| 26 | inline for (@typeInfo(all_pkgs).Struct.decls) |decl| { | |
| 26 | inline for (@typeInfo(all_pkgs).@"struct".decls) |decl| { | |
| 27 | 27 | const pkg_hash = decl.name; |
| 28 | 28 | if (std.mem.eql(u8, dep_hash, pkg_hash)) { |
| 29 | 29 | const pkg = @field(all_pkgs, pkg_hash); |
test/src/Cases.zig+4-4| ... | ... | @@ -1188,12 +1188,12 @@ const TestManifest = struct { |
| 1188 | 1188 | }.parse; |
| 1189 | 1189 | |
| 1190 | 1190 | switch (@typeInfo(T)) { |
| 1191 | .Int => return struct { | |
| 1191 | .int => return struct { | |
| 1192 | 1192 | fn parse(str: []const u8) anyerror!T { |
| 1193 | 1193 | return try std.fmt.parseInt(T, str, 0); |
| 1194 | 1194 | } |
| 1195 | 1195 | }.parse, |
| 1196 | .Bool => return struct { | |
| 1196 | .bool => return struct { | |
| 1197 | 1197 | fn parse(str: []const u8) anyerror!T { |
| 1198 | 1198 | if (std.mem.eql(u8, str, "true")) return true; |
| 1199 | 1199 | if (std.mem.eql(u8, str, "false")) return false; |
| ... | ... | @@ -1201,7 +1201,7 @@ const TestManifest = struct { |
| 1201 | 1201 | return error.InvalidBool; |
| 1202 | 1202 | } |
| 1203 | 1203 | }.parse, |
| 1204 | .Enum => return struct { | |
| 1204 | .@"enum" => return struct { | |
| 1205 | 1205 | fn parse(str: []const u8) anyerror!T { |
| 1206 | 1206 | return std.meta.stringToEnum(T, str) orelse { |
| 1207 | 1207 | std.log.err("unknown enum variant for {s}: {s}", .{ @typeName(T), str }); |
| ... | ... | @@ -1209,7 +1209,7 @@ const TestManifest = struct { |
| 1209 | 1209 | }; |
| 1210 | 1210 | } |
| 1211 | 1211 | }.parse, |
| 1212 | .Struct => @compileError("no default parser for " ++ @typeName(T)), | |
| 1212 | .@"struct" => @compileError("no default parser for " ++ @typeName(T)), | |
| 1213 | 1213 | else => @compileError("no default parser for " ++ @typeName(T)), |
| 1214 | 1214 | } |
| 1215 | 1215 | } |
test/standalone/build.zig+1-1| ... | ... | @@ -60,7 +60,7 @@ pub fn build(b: *std.Build) void { |
| 60 | 60 | if (std.mem.eql(u8, dep_name, "simple")) continue; |
| 61 | 61 | |
| 62 | 62 | const all_pkgs = @import("root").dependencies.packages; |
| 63 | inline for (@typeInfo(all_pkgs).Struct.decls) |decl| { | |
| 63 | inline for (@typeInfo(all_pkgs).@"struct".decls) |decl| { | |
| 64 | 64 | const pkg_hash = decl.name; |
| 65 | 65 | if (std.mem.eql(u8, dep_hash, pkg_hash)) { |
| 66 | 66 | const pkg = @field(all_pkgs, pkg_hash); |
test/standalone/simple/issue_7030.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ pub const std_options = .{ |
| 6 | 6 | |
| 7 | 7 | pub fn log( |
| 8 | 8 | comptime message_level: std.log.Level, |
| 9 | comptime scope: @Type(.EnumLiteral), | |
| 9 | comptime scope: @Type(.enum_literal), | |
| 10 | 10 | comptime format: []const u8, |
| 11 | 11 | args: anytype, |
| 12 | 12 | ) void { |
test/standalone/simple/std_enums_big_enums.zig+12-14| ... | ... | @@ -3,21 +3,19 @@ const std = @import("std"); |
| 3 | 3 | // big enums should not hit the eval branch quota |
| 4 | 4 | pub fn main() void { |
| 5 | 5 | const big = struct { |
| 6 | const Big = @Type(@as(std.builtin.Type, .{ | |
| 7 | .Enum = .{ | |
| 8 | .tag_type = u16, | |
| 9 | .fields = make_fields: { | |
| 10 | var fields: [1001]std.builtin.Type.EnumField = undefined; | |
| 11 | for (&fields, 0..) |*field, i| { | |
| 12 | field.* = .{ .name = std.fmt.comptimePrint("field_{d}", .{i}), .value = i }; | |
| 13 | } | |
| 14 | fields[1000] = .{ .name = "field_9999", .value = 9999 }; | |
| 15 | break :make_fields &fields; | |
| 16 | }, | |
| 17 | .decls = &.{}, | |
| 18 | .is_exhaustive = true, | |
| 6 | const Big = @Type(.{ .@"enum" = .{ | |
| 7 | .tag_type = u16, | |
| 8 | .fields = make_fields: { | |
| 9 | var fields: [1001]std.builtin.Type.EnumField = undefined; | |
| 10 | for (&fields, 0..) |*field, i| { | |
| 11 | field.* = .{ .name = std.fmt.comptimePrint("field_{d}", .{i}), .value = i }; | |
| 12 | } | |
| 13 | fields[1000] = .{ .name = "field_9999", .value = 9999 }; | |
| 14 | break :make_fields &fields; | |
| 19 | 15 | }, |
| 20 | })); | |
| 16 | .decls = &.{}, | |
| 17 | .is_exhaustive = true, | |
| 18 | } }); | |
| 21 | 19 | }; |
| 22 | 20 | |
| 23 | 21 | var set = std.enums.EnumSet(big.Big).init(.{}); |
tools/generate_c_size_and_align_checks.zig+1-1| ... | ... | @@ -43,7 +43,7 @@ pub fn main() !void { |
| 43 | 43 | const target = try std.zig.system.resolveTargetQuery(query); |
| 44 | 44 | |
| 45 | 45 | const stdout = std.io.getStdOut().writer(); |
| 46 | inline for (@typeInfo(std.Target.CType).Enum.fields) |field| { | |
| 46 | inline for (@typeInfo(std.Target.CType).@"enum".fields) |field| { | |
| 47 | 47 | const c_type: std.Target.CType = @enumFromInt(field.value); |
| 48 | 48 | try stdout.print("_Static_assert(sizeof({0s}) == {1d}, \"sizeof({0s}) == {1d}\");\n", .{ |
| 49 | 49 | cName(c_type), |
tools/lldb_pretty_printers.py+1-1| ... | ... | @@ -602,7 +602,7 @@ type_tag_handlers = { |
| 602 | 602 | 'error_set': lambda payload: type_tag_handlers['error_set_merged'](payload.GetChildMemberWithName('names')), |
| 603 | 603 | 'error_set_single': lambda payload: 'error{%s}' % zig_String_AsIdentifier(payload, zig_IsFieldName), |
| 604 | 604 | 'error_set_merged': lambda payload: 'error{%s}' % ','.join(zig_String_AsIdentifier(child.GetChildMemberWithName('key'), zig_IsFieldName) for child in payload.GetChildMemberWithName('entries').children), |
| 605 | 'error_set_inferred': lambda payload: '@typeInfo(@typeInfo(@TypeOf(%s)).Fn.return_type.?).ErrorUnion.error_set' % OwnerDecl_RenderFullyQualifiedName(payload.GetChildMemberWithName('func')), | |
| 605 | 'error_set_inferred': lambda payload: '@typeInfo(@typeInfo(@TypeOf(%s)).@"fn".return_type.?).error_union.error_set' % OwnerDecl_RenderFullyQualifiedName(payload.GetChildMemberWithName('func')), | |
| 606 | 606 | |
| 607 | 607 | 'enum_full': OwnerDecl_RenderFullyQualifiedName, |
| 608 | 608 | 'enum_nonexhaustive': OwnerDecl_RenderFullyQualifiedName, |
tools/update_clang_options.zig+1-1| ... | ... | @@ -616,7 +616,7 @@ pub fn main() anyerror!void { |
| 616 | 616 | |
| 617 | 617 | var llvm_to_zig_cpu_features = std.StringHashMap([]const u8).init(allocator); |
| 618 | 618 | |
| 619 | inline for (@typeInfo(cpu_targets).Struct.decls) |decl| { | |
| 619 | inline for (@typeInfo(cpu_targets).@"struct".decls) |decl| { | |
| 620 | 620 | const Feature = @field(cpu_targets, decl.name).Feature; |
| 621 | 621 | const all_features = @field(cpu_targets, decl.name).all_features; |
| 622 | 622 |
tools/update_cpu_features.zig+2-2| ... | ... | @@ -1348,7 +1348,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1348 | 1348 | try w.print(" @setEvalBranchQuota({d});\n", .{branch_quota}); |
| 1349 | 1349 | } |
| 1350 | 1350 | try w.writeAll( |
| 1351 | \\ const len = @typeInfo(Feature).Enum.fields.len; | |
| 1351 | \\ const len = @typeInfo(Feature).@"enum".fields.len; | |
| 1352 | 1352 | \\ std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 1353 | 1353 | \\ var result: [len]CpuFeature = undefined; |
| 1354 | 1354 | \\ |
| ... | ... | @@ -1417,7 +1417,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1417 | 1417 | \\ const ti = @typeInfo(Feature); |
| 1418 | 1418 | \\ for (&result, 0..) |*elem, i| { |
| 1419 | 1419 | \\ elem.index = i; |
| 1420 | \\ elem.name = ti.Enum.fields[i].name; | |
| 1420 | \\ elem.name = ti.@"enum".fields[i].name; | |
| 1421 | 1421 | \\ } |
| 1422 | 1422 | \\ break :blk result; |
| 1423 | 1423 | \\}; |
tools/update_spirv_features.zig+2-2| ... | ... | @@ -129,7 +129,7 @@ pub fn main() !void { |
| 129 | 129 | \\ |
| 130 | 130 | \\pub const all_features = blk: { |
| 131 | 131 | \\ @setEvalBranchQuota(2000); |
| 132 | \\ const len = @typeInfo(Feature).Enum.fields.len; | |
| 132 | \\ const len = @typeInfo(Feature).@"enum".fields.len; | |
| 133 | 133 | \\ std.debug.assert(len <= CpuFeature.Set.needed_bit_count); |
| 134 | 134 | \\ var result: [len]CpuFeature = undefined; |
| 135 | 135 | \\ |
| ... | ... | @@ -210,7 +210,7 @@ pub fn main() !void { |
| 210 | 210 | \\ const ti = @typeInfo(Feature); |
| 211 | 211 | \\ for (&result, 0..) |*elem, i| { |
| 212 | 212 | \\ elem.index = i; |
| 213 | \\ elem.name = ti.Enum.fields[i].name; | |
| 213 | \\ elem.name = ti.@"enum".fields[i].name; | |
| 214 | 214 | \\ } |
| 215 | 215 | \\ break :blk result; |
| 216 | 216 | \\}; |