| author | |
| committer | |
| log | 538d9a5dd8e0eca02d363bbd5f749405e003f1c6 |
| tree | d8ac99c166bbf72605c4d0ac3413c13d2c52b3bd |
| parent | 3458fb891d8c7072a9bff6a32db9f3105ab72aa4 |
| signature |
45 files changed, 125 insertions(+), 193 deletions(-)
doc/langref.html.in+3-26| ... | ... | @@ -550,7 +550,7 @@ pub fn main() void { |
| 550 | 550 | {#syntax#}i7{#endsyntax#} refers to a signed 7-bit integer. The maximum allowed bit-width of an |
| 551 | 551 | integer type is {#syntax#}65535{#endsyntax#}. |
| 552 | 552 | </p> |
| 553 | {#see_also|Integers|Floats|void|Errors|@IntType#} | |
| 553 | {#see_also|Integers|Floats|void|Errors|@Type#} | |
| 554 | 554 | {#header_close#} |
| 555 | 555 | {#header_open|Primitive Values#} |
| 556 | 556 | <div class="table-wrapper"> |
| ... | ... | @@ -6667,18 +6667,6 @@ comptime { |
| 6667 | 6667 | </p> |
| 6668 | 6668 | {#see_also|Alignment#} |
| 6669 | 6669 | {#header_close#} |
| 6670 | {#header_open|@ArgType#} | |
| 6671 | <pre>{#syntax#}@ArgType(comptime T: type, comptime n: usize) type{#endsyntax#}</pre> | |
| 6672 | <p> | |
| 6673 | This builtin function takes a function type and returns the type of the parameter at index {#syntax#}n{#endsyntax#}. | |
| 6674 | </p> | |
| 6675 | <p> | |
| 6676 | {#syntax#}T{#endsyntax#} must be a function type. | |
| 6677 | </p> | |
| 6678 | <p> | |
| 6679 | Note: This function is deprecated. Use {#link|@typeInfo#} instead. | |
| 6680 | </p> | |
| 6681 | {#header_close#} | |
| 6682 | 6670 | |
| 6683 | 6671 | {#header_open|@as#} |
| 6684 | 6672 | <pre>{#syntax#}@as(comptime T: type, expression) T{#endsyntax#}</pre> |
| ... | ... | @@ -7337,7 +7325,7 @@ test "main" { |
| 7337 | 7325 | {#header_close#} |
| 7338 | 7326 | |
| 7339 | 7327 | {#header_open|@errorToInt#} |
| 7340 | <pre>{#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre> | |
| 7328 | <pre>{#syntax#}@errorToInt(err: var) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre> | |
| 7341 | 7329 | <p> |
| 7342 | 7330 | Supports the following types: |
| 7343 | 7331 | </p> |
| ... | ... | @@ -7631,7 +7619,7 @@ test "@hasDecl" { |
| 7631 | 7619 | {#header_close#} |
| 7632 | 7620 | |
| 7633 | 7621 | {#header_open|@intToError#} |
| 7634 | <pre>{#syntax#}@intToError(value: @IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre> | |
| 7622 | <pre>{#syntax#}@intToError(value: std.meta.IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre> | |
| 7635 | 7623 | <p> |
| 7636 | 7624 | Converts from the integer representation of an error into {#link|The Global Error Set#} type. |
| 7637 | 7625 | </p> |
| ... | ... | @@ -7664,17 +7652,6 @@ test "@hasDecl" { |
| 7664 | 7652 | </p> |
| 7665 | 7653 | {#header_close#} |
| 7666 | 7654 | |
| 7667 | {#header_open|@IntType#} | |
| 7668 | <pre>{#syntax#}@IntType(comptime is_signed: bool, comptime bit_count: u16) type{#endsyntax#}</pre> | |
| 7669 | <p> | |
| 7670 | This function returns an integer type with the given signness and bit count. The maximum | |
| 7671 | bit count for an integer type is {#syntax#}65535{#endsyntax#}. | |
| 7672 | </p> | |
| 7673 | <p> | |
| 7674 | Deprecated. Use {#link|@Type#}. | |
| 7675 | </p> | |
| 7676 | {#header_close#} | |
| 7677 | ||
| 7678 | 7655 | {#header_open|@memcpy#} |
| 7679 | 7656 | <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre> |
| 7680 | 7657 | <p> |
lib/std/child_process.zig+1-1| ... | ... | @@ -851,7 +851,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn { |
| 851 | 851 | os.exit(1); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | const ErrInt = @IntType(false, @sizeOf(anyerror) * 8); | |
| 854 | const ErrInt = std.meta.IntType(false, @sizeOf(anyerror) * 8); | |
| 855 | 855 | |
| 856 | 856 | fn writeIntFd(fd: i32, value: ErrInt) !void { |
| 857 | 857 | const file = File{ |
lib/std/debug/leb128.zig+6-6| ... | ... | @@ -2,7 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const testing = std.testing; |
| 3 | 3 | |
| 4 | 4 | pub fn readULEB128(comptime T: type, in_stream: var) !T { |
| 5 | const ShiftT = @IntType(false, std.math.log2(T.bit_count)); | |
| 5 | const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); | |
| 6 | 6 | |
| 7 | 7 | var result: T = 0; |
| 8 | 8 | var shift: usize = 0; |
| ... | ... | @@ -27,7 +27,7 @@ pub fn readULEB128(comptime T: type, in_stream: var) !T { |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T { |
| 30 | const ShiftT = @IntType(false, std.math.log2(T.bit_count)); | |
| 30 | const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); | |
| 31 | 31 | |
| 32 | 32 | var result: T = 0; |
| 33 | 33 | var shift: usize = 0; |
| ... | ... | @@ -55,8 +55,8 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T { |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | pub fn readILEB128(comptime T: type, in_stream: var) !T { |
| 58 | const UT = @IntType(false, T.bit_count); | |
| 59 | const ShiftT = @IntType(false, std.math.log2(T.bit_count)); | |
| 58 | const UT = std.meta.IntType(false, T.bit_count); | |
| 59 | const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); | |
| 60 | 60 | |
| 61 | 61 | var result: UT = 0; |
| 62 | 62 | var shift: usize = 0; |
| ... | ... | @@ -87,8 +87,8 @@ pub fn readILEB128(comptime T: type, in_stream: var) !T { |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | pub fn readILEB128Mem(comptime T: type, ptr: *[*]const u8) !T { |
| 90 | const UT = @IntType(false, T.bit_count); | |
| 91 | const ShiftT = @IntType(false, std.math.log2(T.bit_count)); | |
| 90 | const UT = std.meta.IntType(false, T.bit_count); | |
| 91 | const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); | |
| 92 | 92 | |
| 93 | 93 | var result: UT = 0; |
| 94 | 94 | var shift: usize = 0; |
lib/std/fmt.zig+3-3| ... | ... | @@ -82,7 +82,7 @@ pub fn format( |
| 82 | 82 | comptime fmt: []const u8, |
| 83 | 83 | args: var, |
| 84 | 84 | ) Errors!void { |
| 85 | const ArgSetType = @IntType(false, 32); | |
| 85 | const ArgSetType = u32; | |
| 86 | 86 | if (@typeInfo(@TypeOf(args)) != .Struct) { |
| 87 | 87 | @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args))); |
| 88 | 88 | } |
| ... | ... | @@ -944,7 +944,7 @@ fn formatIntSigned( |
| 944 | 944 | .fill = options.fill, |
| 945 | 945 | }; |
| 946 | 946 | |
| 947 | const uint = @IntType(false, @TypeOf(value).bit_count); | |
| 947 | const uint = std.meta.IntType(false, @TypeOf(value).bit_count); | |
| 948 | 948 | if (value < 0) { |
| 949 | 949 | const minus_sign: u8 = '-'; |
| 950 | 950 | try output(context, @as(*const [1]u8, &minus_sign)[0..]); |
| ... | ... | @@ -972,7 +972,7 @@ fn formatIntUnsigned( |
| 972 | 972 | assert(base >= 2); |
| 973 | 973 | var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined; |
| 974 | 974 | const min_int_bits = comptime math.max(@TypeOf(value).bit_count, @TypeOf(base).bit_count); |
| 975 | const MinInt = @IntType(@TypeOf(value).is_signed, min_int_bits); | |
| 975 | const MinInt = std.meta.IntType(@TypeOf(value).is_signed, min_int_bits); | |
| 976 | 976 | var a: MinInt = value; |
| 977 | 977 | var index: usize = buf.len; |
| 978 | 978 |
lib/std/fmt/parse_float.zig+1-1| ... | ... | @@ -393,7 +393,7 @@ test "fmt.parseFloat" { |
| 393 | 393 | const epsilon = 1e-7; |
| 394 | 394 | |
| 395 | 395 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { |
| 396 | const Z = @IntType(false, T.bit_count); | |
| 396 | const Z = std.meta.IntType(false, T.bit_count); | |
| 397 | 397 | |
| 398 | 398 | testing.expectError(error.InvalidCharacter, parseFloat(T, "")); |
| 399 | 399 | testing.expectError(error.InvalidCharacter, parseFloat(T, " 1")); |
lib/std/hash/auto_hash.zig+1-1| ... | ... | @@ -93,7 +93,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void { |
| 93 | 93 | // TODO Check if the situation is better after #561 is resolved. |
| 94 | 94 | .Int => @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}), |
| 95 | 95 | |
| 96 | .Float => |info| hash(hasher, @bitCast(@IntType(false, info.bits), key), strat), | |
| 96 | .Float => |info| hash(hasher, @bitCast(std.meta.IntType(false, info.bits), key), strat), | |
| 97 | 97 | |
| 98 | 98 | .Bool => hash(hasher, @boolToInt(key), strat), |
| 99 | 99 | .Enum => hash(hasher, @enumToInt(key), strat), |
lib/std/hash/wyhash.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ const primes = [_]u64{ |
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | fn read_bytes(comptime bytes: u8, data: []const u8) u64 { |
| 13 | const T = @IntType(false, 8 * bytes); | |
| 13 | const T = std.meta.IntType(false, 8 * bytes); | |
| 14 | 14 | return mem.readIntSliceLittle(T, data[0..bytes]); |
| 15 | 15 | } |
| 16 | 16 |
lib/std/heap.zig+1-1| ... | ... | @@ -1015,7 +1015,7 @@ fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!vo |
| 1015 | 1015 | // very near usize? |
| 1016 | 1016 | if (mem.page_size << 2 > maxInt(usize)) return; |
| 1017 | 1017 | |
| 1018 | const USizeShift = @IntType(false, std.math.log2(usize.bit_count)); | |
| 1018 | const USizeShift = std.meta.IntType(false, std.math.log2(usize.bit_count)); | |
| 1019 | 1019 | const large_align = @as(u29, mem.page_size << 2); |
| 1020 | 1020 | |
| 1021 | 1021 | var align_mask: usize = undefined; |
lib/std/io.zig+5-5| ... | ... | @@ -337,7 +337,7 @@ pub fn BitInStream(endian: builtin.Endian, comptime Error: type) type { |
| 337 | 337 | assert(u_bit_count >= bits); |
| 338 | 338 | break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count; |
| 339 | 339 | }; |
| 340 | const Buf = @IntType(false, buf_bit_count); | |
| 340 | const Buf = std.meta.IntType(false, buf_bit_count); | |
| 341 | 341 | const BufShift = math.Log2Int(Buf); |
| 342 | 342 | |
| 343 | 343 | out_bits.* = @as(usize, 0); |
| ... | ... | @@ -659,7 +659,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime Error: type) type { |
| 659 | 659 | assert(u_bit_count >= bits); |
| 660 | 660 | break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count; |
| 661 | 661 | }; |
| 662 | const Buf = @IntType(false, buf_bit_count); | |
| 662 | const Buf = std.meta.IntType(false, buf_bit_count); | |
| 663 | 663 | const BufShift = math.Log2Int(Buf); |
| 664 | 664 | |
| 665 | 665 | const buf_value = @intCast(Buf, value); |
| ... | ... | @@ -836,7 +836,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, |
| 836 | 836 | const u8_bit_count = 8; |
| 837 | 837 | const t_bit_count = comptime meta.bitCount(T); |
| 838 | 838 | |
| 839 | const U = @IntType(false, t_bit_count); | |
| 839 | const U = std.meta.IntType(false, t_bit_count); | |
| 840 | 840 | const Log2U = math.Log2Int(U); |
| 841 | 841 | const int_size = (U.bit_count + 7) / 8; |
| 842 | 842 | |
| ... | ... | @@ -851,7 +851,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, |
| 851 | 851 | |
| 852 | 852 | if (int_size == 1) { |
| 853 | 853 | if (t_bit_count == 8) return @bitCast(T, buffer[0]); |
| 854 | const PossiblySignedByte = @IntType(T.is_signed, 8); | |
| 854 | const PossiblySignedByte = std.meta.IntType(T.is_signed, 8); | |
| 855 | 855 | return @truncate(T, @bitCast(PossiblySignedByte, buffer[0])); |
| 856 | 856 | } |
| 857 | 857 | |
| ... | ... | @@ -1014,7 +1014,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co |
| 1014 | 1014 | const t_bit_count = comptime meta.bitCount(T); |
| 1015 | 1015 | const u8_bit_count = comptime meta.bitCount(u8); |
| 1016 | 1016 | |
| 1017 | const U = @IntType(false, t_bit_count); | |
| 1017 | const U = std.meta.IntType(false, t_bit_count); | |
| 1018 | 1018 | const Log2U = math.Log2Int(U); |
| 1019 | 1019 | const int_size = (U.bit_count + 7) / 8; |
| 1020 | 1020 |
lib/std/io/test.zig+5-4| ... | ... | @@ -318,6 +318,7 @@ test "BitStreams with File Stream" { |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: io.Packing) !void { |
| 321 | @setEvalBranchQuota(1500); | |
| 321 | 322 | //@NOTE: if this test is taking too long, reduce the maximum tested bitsize |
| 322 | 323 | const max_test_bitsize = 128; |
| 323 | 324 | |
| ... | ... | @@ -341,8 +342,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi |
| 341 | 342 | |
| 342 | 343 | comptime var i = 0; |
| 343 | 344 | inline while (i <= max_test_bitsize) : (i += 1) { |
| 344 | const U = @IntType(false, i); | |
| 345 | const S = @IntType(true, i); | |
| 345 | const U = std.meta.IntType(false, i); | |
| 346 | const S = std.meta.IntType(true, i); | |
| 346 | 347 | try serializer.serializeInt(@as(U, i)); |
| 347 | 348 | if (i != 0) try serializer.serializeInt(@as(S, -1)) else try serializer.serialize(@as(S, 0)); |
| 348 | 349 | } |
| ... | ... | @@ -350,8 +351,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi |
| 350 | 351 | |
| 351 | 352 | i = 0; |
| 352 | 353 | inline while (i <= max_test_bitsize) : (i += 1) { |
| 353 | const U = @IntType(false, i); | |
| 354 | const S = @IntType(true, i); | |
| 354 | const U = std.meta.IntType(false, i); | |
| 355 | const S = std.meta.IntType(true, i); | |
| 355 | 356 | const x = try deserializer.deserializeInt(U); |
| 356 | 357 | const y = try deserializer.deserializeInt(S); |
| 357 | 358 | expect(x == @as(U, i)); |
lib/std/math.zig+11-11| ... | ... | @@ -444,7 +444,7 @@ pub fn Log2Int(comptime T: type) type { |
| 444 | 444 | count += 1; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | return @IntType(false, count); | |
| 447 | return std.meta.IntType(false, count); | |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type { |
| ... | ... | @@ -460,7 +460,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t |
| 460 | 460 | if (is_signed) { |
| 461 | 461 | magnitude_bits += 1; |
| 462 | 462 | } |
| 463 | return @IntType(is_signed, magnitude_bits); | |
| 463 | return std.meta.IntType(is_signed, magnitude_bits); | |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | test "math.IntFittingRange" { |
| ... | ... | @@ -674,13 +674,13 @@ pub fn absCast(x: var) t: { |
| 674 | 674 | if (@TypeOf(x) == comptime_int) { |
| 675 | 675 | break :t comptime_int; |
| 676 | 676 | } else { |
| 677 | break :t @IntType(false, @TypeOf(x).bit_count); | |
| 677 | break :t std.meta.IntType(false, @TypeOf(x).bit_count); | |
| 678 | 678 | } |
| 679 | 679 | } { |
| 680 | 680 | if (@TypeOf(x) == comptime_int) { |
| 681 | 681 | return if (x < 0) -x else x; |
| 682 | 682 | } |
| 683 | const uint = @IntType(false, @TypeOf(x).bit_count); | |
| 683 | const uint = std.meta.IntType(false, @TypeOf(x).bit_count); | |
| 684 | 684 | if (x >= 0) return @intCast(uint, x); |
| 685 | 685 | |
| 686 | 686 | return @intCast(uint, -(x + 1)) + 1; |
| ... | ... | @@ -701,10 +701,10 @@ test "math.absCast" { |
| 701 | 701 | |
| 702 | 702 | /// Returns the negation of the integer parameter. |
| 703 | 703 | /// Result is a signed integer. |
| 704 | pub fn negateCast(x: var) !@IntType(true, @TypeOf(x).bit_count) { | |
| 704 | pub fn negateCast(x: var) !std.meta.IntType(true, @TypeOf(x).bit_count) { | |
| 705 | 705 | if (@TypeOf(x).is_signed) return negate(x); |
| 706 | 706 | |
| 707 | const int = @IntType(true, @TypeOf(x).bit_count); | |
| 707 | const int = std.meta.IntType(true, @TypeOf(x).bit_count); | |
| 708 | 708 | if (x > -minInt(int)) return error.Overflow; |
| 709 | 709 | |
| 710 | 710 | if (x == -minInt(int)) return minInt(int); |
| ... | ... | @@ -790,11 +790,11 @@ fn testFloorPowerOfTwo() void { |
| 790 | 790 | /// Returns the next power of two (if the value is not already a power of two). |
| 791 | 791 | /// Only unsigned integers can be used. Zero is not an allowed input. |
| 792 | 792 | /// Result is a type with 1 more bit than the input type. |
| 793 | pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @IntType(T.is_signed, T.bit_count + 1) { | |
| 793 | pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.IntType(T.is_signed, T.bit_count + 1) { | |
| 794 | 794 | comptime assert(@typeInfo(T) == .Int); |
| 795 | 795 | comptime assert(!T.is_signed); |
| 796 | 796 | assert(value != 0); |
| 797 | comptime const PromotedType = @IntType(T.is_signed, T.bit_count + 1); | |
| 797 | comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1); | |
| 798 | 798 | comptime const shiftType = std.math.Log2Int(PromotedType); |
| 799 | 799 | return @as(PromotedType, 1) << @intCast(shiftType, T.bit_count - @clz(T, value - 1)); |
| 800 | 800 | } |
| ... | ... | @@ -805,7 +805,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @IntType(T.is_signed, T |
| 805 | 805 | pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) { |
| 806 | 806 | comptime assert(@typeInfo(T) == .Int); |
| 807 | 807 | comptime assert(!T.is_signed); |
| 808 | comptime const PromotedType = @IntType(T.is_signed, T.bit_count + 1); | |
| 808 | comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1); | |
| 809 | 809 | comptime const overflowBit = @as(PromotedType, 1) << T.bit_count; |
| 810 | 810 | var x = ceilPowerOfTwoPromote(T, value); |
| 811 | 811 | if (overflowBit & x != 0) { |
| ... | ... | @@ -947,8 +947,8 @@ test "max value type" { |
| 947 | 947 | testing.expect(x == 2147483647); |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | pub fn mulWide(comptime T: type, a: T, b: T) @IntType(T.is_signed, T.bit_count * 2) { | |
| 951 | const ResultInt = @IntType(T.is_signed, T.bit_count * 2); | |
| 950 | pub fn mulWide(comptime T: type, a: T, b: T) std.meta.IntType(T.is_signed, T.bit_count * 2) { | |
| 951 | const ResultInt = std.meta.IntType(T.is_signed, T.bit_count * 2); | |
| 952 | 952 | return @as(ResultInt, a) * @as(ResultInt, b); |
| 953 | 953 | } |
| 954 | 954 |
lib/std/math/big/int.zig+3-3| ... | ... | @@ -9,7 +9,7 @@ const maxInt = std.math.maxInt; |
| 9 | 9 | const minInt = std.math.minInt; |
| 10 | 10 | |
| 11 | 11 | pub const Limb = usize; |
| 12 | pub const DoubleLimb = @IntType(false, 2 * Limb.bit_count); | |
| 12 | pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count); | |
| 13 | 13 | pub const Log2Limb = math.Log2Int(Limb); |
| 14 | 14 | |
| 15 | 15 | comptime { |
| ... | ... | @@ -268,7 +268,7 @@ pub const Int = struct { |
| 268 | 268 | |
| 269 | 269 | switch (@typeInfo(T)) { |
| 270 | 270 | .Int => |info| { |
| 271 | const UT = if (T.is_signed) @IntType(false, T.bit_count - 1) else T; | |
| 271 | const UT = if (T.is_signed) std.meta.IntType(false, T.bit_count - 1) else T; | |
| 272 | 272 | |
| 273 | 273 | try self.ensureCapacity(@sizeOf(UT) / @sizeOf(Limb)); |
| 274 | 274 | self.metadata = 0; |
| ... | ... | @@ -331,7 +331,7 @@ pub const Int = struct { |
| 331 | 331 | pub fn to(self: Int, comptime T: type) ConvertError!T { |
| 332 | 332 | switch (@typeInfo(T)) { |
| 333 | 333 | .Int => { |
| 334 | const UT = @IntType(false, T.bit_count); | |
| 334 | const UT = std.meta.IntType(false, T.bit_count); | |
| 335 | 335 | |
| 336 | 336 | if (self.bitCountTwosComp() > T.bit_count) { |
| 337 | 337 | return error.TargetTooSmall; |
lib/std/math/big/rational.zig+3-3| ... | ... | @@ -128,7 +128,7 @@ pub const Rational = struct { |
| 128 | 128 | // Translated from golang.go/src/math/big/rat.go. |
| 129 | 129 | debug.assert(@typeInfo(T) == .Float); |
| 130 | 130 | |
| 131 | const UnsignedIntType = @IntType(false, T.bit_count); | |
| 131 | const UnsignedIntType = std.meta.IntType(false, T.bit_count); | |
| 132 | 132 | const f_bits = @bitCast(UnsignedIntType, f); |
| 133 | 133 | |
| 134 | 134 | const exponent_bits = math.floatExponentBits(T); |
| ... | ... | @@ -187,7 +187,7 @@ pub const Rational = struct { |
| 187 | 187 | debug.assert(@typeInfo(T) == .Float); |
| 188 | 188 | |
| 189 | 189 | const fsize = T.bit_count; |
| 190 | const BitReprType = @IntType(false, T.bit_count); | |
| 190 | const BitReprType = std.meta.IntType(false, T.bit_count); | |
| 191 | 191 | |
| 192 | 192 | const msize = math.floatMantissaBits(T); |
| 193 | 193 | const msize1 = msize + 1; |
| ... | ... | @@ -462,7 +462,7 @@ pub const Rational = struct { |
| 462 | 462 | } |
| 463 | 463 | }; |
| 464 | 464 | |
| 465 | const SignedDoubleLimb = @IntType(true, DoubleLimb.bit_count); | |
| 465 | const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count); | |
| 466 | 466 | |
| 467 | 467 | fn gcd(rma: *Int, x: Int, y: Int) !void { |
| 468 | 468 | rma.assertWritable(); |
lib/std/math/cos.zig+1-1| ... | ... | @@ -44,7 +44,7 @@ const pi4c = 2.69515142907905952645E-15; |
| 44 | 44 | const m4pi = 1.273239544735162542821171882678754627704620361328125; |
| 45 | 45 | |
| 46 | 46 | fn cos_(comptime T: type, x_: T) T { |
| 47 | const I = @IntType(true, T.bit_count); | |
| 47 | const I = std.meta.IntType(true, T.bit_count); | |
| 48 | 48 | |
| 49 | 49 | var x = x_; |
| 50 | 50 | if (math.isNan(x) or math.isInf(x)) { |
lib/std/math/pow.zig+1-1| ... | ... | @@ -145,7 +145,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { |
| 145 | 145 | var xe = r2.exponent; |
| 146 | 146 | var x1 = r2.significand; |
| 147 | 147 | |
| 148 | var i = @floatToInt(@IntType(true, T.bit_count), yi); | |
| 148 | var i = @floatToInt(std.meta.IntType(true, T.bit_count), yi); | |
| 149 | 149 | while (i != 0) : (i >>= 1) { |
| 150 | 150 | const overflow_shift = math.floatExponentBits(T) + 1; |
| 151 | 151 | if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) { |
lib/std/math/sin.zig+1-1| ... | ... | @@ -45,7 +45,7 @@ const pi4c = 2.69515142907905952645E-15; |
| 45 | 45 | const m4pi = 1.273239544735162542821171882678754627704620361328125; |
| 46 | 46 | |
| 47 | 47 | fn sin_(comptime T: type, x_: T) T { |
| 48 | const I = @IntType(true, T.bit_count); | |
| 48 | const I = std.meta.IntType(true, T.bit_count); | |
| 49 | 49 | |
| 50 | 50 | var x = x_; |
| 51 | 51 | if (x == 0 or math.isNan(x)) { |
lib/std/math/sqrt.zig+3-3| ... | ... | @@ -31,7 +31,7 @@ pub fn sqrt(x: var) Sqrt(@TypeOf(x)) { |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | fn sqrt_int(comptime T: type, value: T) @IntType(false, T.bit_count / 2) { | |
| 34 | fn sqrt_int(comptime T: type, value: T) std.meta.IntType(false, T.bit_count / 2) { | |
| 35 | 35 | var op = value; |
| 36 | 36 | var res: T = 0; |
| 37 | 37 | var one: T = 1 << (T.bit_count - 2); |
| ... | ... | @@ -50,7 +50,7 @@ fn sqrt_int(comptime T: type, value: T) @IntType(false, T.bit_count / 2) { |
| 50 | 50 | one >>= 2; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | const ResultType = @IntType(false, T.bit_count / 2); | |
| 53 | const ResultType = std.meta.IntType(false, T.bit_count / 2); | |
| 54 | 54 | return @intCast(ResultType, res); |
| 55 | 55 | } |
| 56 | 56 | |
| ... | ... | @@ -66,7 +66,7 @@ test "math.sqrt_int" { |
| 66 | 66 | /// Returns the return type `sqrt` will return given an operand of type `T`. |
| 67 | 67 | pub fn Sqrt(comptime T: type) type { |
| 68 | 68 | return switch (@typeInfo(T)) { |
| 69 | .Int => |int| @IntType(false, int.bits / 2), | |
| 69 | .Int => |int| std.meta.IntType(false, int.bits / 2), | |
| 70 | 70 | else => T, |
| 71 | 71 | }; |
| 72 | 72 | } |
lib/std/math/tan.zig+1-1| ... | ... | @@ -38,7 +38,7 @@ const pi4c = 2.69515142907905952645E-15; |
| 38 | 38 | const m4pi = 1.273239544735162542821171882678754627704620361328125; |
| 39 | 39 | |
| 40 | 40 | fn tan_(comptime T: type, x_: T) T { |
| 41 | const I = @IntType(true, T.bit_count); | |
| 41 | const I = std.meta.IntType(true, T.bit_count); | |
| 42 | 42 | |
| 43 | 43 | var x = x_; |
| 44 | 44 | if (x == 0 or math.isNan(x)) { |
lib/std/mem.zig+2-2| ... | ... | @@ -708,7 +708,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void { |
| 708 | 708 | assert(buffer.len >= @divExact(T.bit_count, 8)); |
| 709 | 709 | |
| 710 | 710 | // TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough |
| 711 | const uint = @IntType(false, T.bit_count); | |
| 711 | const uint = std.meta.IntType(false, T.bit_count); | |
| 712 | 712 | var bits = @truncate(uint, value); |
| 713 | 713 | for (buffer) |*b| { |
| 714 | 714 | b.* = @truncate(u8, bits); |
| ... | ... | @@ -725,7 +725,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void { |
| 725 | 725 | assert(buffer.len >= @divExact(T.bit_count, 8)); |
| 726 | 726 | |
| 727 | 727 | // TODO I want to call writeIntBig here but comptime eval facilities aren't good enough |
| 728 | const uint = @IntType(false, T.bit_count); | |
| 728 | const uint = std.meta.IntType(false, T.bit_count); | |
| 729 | 729 | var bits = @truncate(uint, value); |
| 730 | 730 | var index: usize = buffer.len; |
| 731 | 731 | while (index != 0) { |
lib/std/meta.zig+9| ... | ... | @@ -580,3 +580,12 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De |
| 580 | 580 | return &array; |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | ||
| 584 | pub fn IntType(comptime is_signed: bool, comptime bit_count: u16) type { | |
| 585 | return @Type(TypeInfo{ | |
| 586 | .Int = .{ | |
| 587 | .is_signed = is_signed, | |
| 588 | .bits = bit_count, | |
| 589 | }, | |
| 590 | }); | |
| 591 | } |
lib/std/os.zig+1-1| ... | ... | @@ -3349,7 +3349,7 @@ pub fn res_mkquery( |
| 3349 | 3349 | // Make a reasonably unpredictable id |
| 3350 | 3350 | var ts: timespec = undefined; |
| 3351 | 3351 | clock_gettime(CLOCK_REALTIME, &ts) catch {}; |
| 3352 | const UInt = @IntType(false, @TypeOf(ts.tv_nsec).bit_count); | |
| 3352 | const UInt = std.meta.IntType(false, @TypeOf(ts.tv_nsec).bit_count); | |
| 3353 | 3353 | const unsec = @bitCast(UInt, ts.tv_nsec); |
| 3354 | 3354 | const id = @truncate(u32, unsec + unsec / 65536); |
| 3355 | 3355 | q[0] = @truncate(u8, id / 256); |
lib/std/os/bits/linux.zig+1-1| ... | ... | @@ -1004,7 +1004,7 @@ pub const dl_phdr_info = extern struct { |
| 1004 | 1004 | |
| 1005 | 1005 | pub const CPU_SETSIZE = 128; |
| 1006 | 1006 | pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; |
| 1007 | pub const cpu_count_t = @IntType(false, std.math.log2(CPU_SETSIZE * 8)); | |
| 1007 | pub const cpu_count_t = std.meta.IntType(false, std.math.log2(CPU_SETSIZE * 8)); | |
| 1008 | 1008 | |
| 1009 | 1009 | pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { |
| 1010 | 1010 | var sum: cpu_count_t = 0; |
lib/std/packed_int_array.zig+6-6| ... | ... | @@ -34,13 +34,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type { |
| 34 | 34 | |
| 35 | 35 | //we bitcast the desired Int type to an unsigned version of itself |
| 36 | 36 | // to avoid issues with shifting signed ints. |
| 37 | const UnInt = @IntType(false, int_bits); | |
| 37 | const UnInt = std.meta.IntType(false, int_bits); | |
| 38 | 38 | |
| 39 | 39 | //The maximum container int type |
| 40 | const MinIo = @IntType(false, min_io_bits); | |
| 40 | const MinIo = std.meta.IntType(false, min_io_bits); | |
| 41 | 41 | |
| 42 | 42 | //The minimum container int type |
| 43 | const MaxIo = @IntType(false, max_io_bits); | |
| 43 | const MaxIo = std.meta.IntType(false, max_io_bits); | |
| 44 | 44 | |
| 45 | 45 | return struct { |
| 46 | 46 | pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int { |
| ... | ... | @@ -322,7 +322,7 @@ test "PackedIntArray" { |
| 322 | 322 | inline while (bits <= 256) : (bits += 1) { |
| 323 | 323 | //alternate unsigned and signed |
| 324 | 324 | const even = bits % 2 == 0; |
| 325 | const I = @IntType(even, bits); | |
| 325 | const I = std.meta.IntType(even, bits); | |
| 326 | 326 | |
| 327 | 327 | const PackedArray = PackedIntArray(I, int_count); |
| 328 | 328 | const expected_bytes = ((bits * int_count) + 7) / 8; |
| ... | ... | @@ -369,7 +369,7 @@ test "PackedIntSlice" { |
| 369 | 369 | inline while (bits <= 256) : (bits += 1) { |
| 370 | 370 | //alternate unsigned and signed |
| 371 | 371 | const even = bits % 2 == 0; |
| 372 | const I = @IntType(even, bits); | |
| 372 | const I = std.meta.IntType(even, bits); | |
| 373 | 373 | const P = PackedIntSlice(I); |
| 374 | 374 | |
| 375 | 375 | var data = P.init(&buffer, int_count); |
| ... | ... | @@ -399,7 +399,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" { |
| 399 | 399 | |
| 400 | 400 | comptime var bits = 0; |
| 401 | 401 | inline while (bits <= max_bits) : (bits += 1) { |
| 402 | const Int = @IntType(false, bits); | |
| 402 | const Int = std.meta.IntType(false, bits); | |
| 403 | 403 | |
| 404 | 404 | const PackedArray = PackedIntArray(Int, int_count); |
| 405 | 405 | var packed_array = @as(PackedArray, undefined); |
lib/std/rand.zig+10-10| ... | ... | @@ -45,8 +45,8 @@ pub const Random = struct { |
| 45 | 45 | /// Returns a random int `i` such that `0 <= i <= maxInt(T)`. |
| 46 | 46 | /// `i` is evenly distributed. |
| 47 | 47 | pub fn int(r: *Random, comptime T: type) T { |
| 48 | const UnsignedT = @IntType(false, T.bit_count); | |
| 49 | const ByteAlignedT = @IntType(false, @divTrunc(T.bit_count + 7, 8) * 8); | |
| 48 | const UnsignedT = std.meta.IntType(false, T.bit_count); | |
| 49 | const ByteAlignedT = std.meta.IntType(false, @divTrunc(T.bit_count + 7, 8) * 8); | |
| 50 | 50 | |
| 51 | 51 | var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined; |
| 52 | 52 | r.bytes(rand_bytes[0..]); |
| ... | ... | @@ -85,9 +85,9 @@ pub const Random = struct { |
| 85 | 85 | comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation! |
| 86 | 86 | assert(0 < less_than); |
| 87 | 87 | // Small is typically u32 |
| 88 | const Small = @IntType(false, @divTrunc(T.bit_count + 31, 32) * 32); | |
| 88 | const Small = std.meta.IntType(false, @divTrunc(T.bit_count + 31, 32) * 32); | |
| 89 | 89 | // Large is typically u64 |
| 90 | const Large = @IntType(false, Small.bit_count * 2); | |
| 90 | const Large = std.meta.IntType(false, Small.bit_count * 2); | |
| 91 | 91 | |
| 92 | 92 | // adapted from: |
| 93 | 93 | // http://www.pcg-random.org/posts/bounded-rands.html |
| ... | ... | @@ -99,7 +99,7 @@ pub const Random = struct { |
| 99 | 99 | // TODO: workaround for https://github.com/ziglang/zig/issues/1770 |
| 100 | 100 | // should be: |
| 101 | 101 | // var t: Small = -%less_than; |
| 102 | var t: Small = @bitCast(Small, -%@bitCast(@IntType(true, Small.bit_count), @as(Small, less_than))); | |
| 102 | var t: Small = @bitCast(Small, -%@bitCast(std.meta.IntType(true, Small.bit_count), @as(Small, less_than))); | |
| 103 | 103 | |
| 104 | 104 | if (t >= less_than) { |
| 105 | 105 | t -= less_than; |
| ... | ... | @@ -145,7 +145,7 @@ pub const Random = struct { |
| 145 | 145 | assert(at_least < less_than); |
| 146 | 146 | if (T.is_signed) { |
| 147 | 147 | // Two's complement makes this math pretty easy. |
| 148 | const UnsignedT = @IntType(false, T.bit_count); | |
| 148 | const UnsignedT = std.meta.IntType(false, T.bit_count); | |
| 149 | 149 | const lo = @bitCast(UnsignedT, at_least); |
| 150 | 150 | const hi = @bitCast(UnsignedT, less_than); |
| 151 | 151 | const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo); |
| ... | ... | @@ -163,7 +163,7 @@ pub const Random = struct { |
| 163 | 163 | assert(at_least < less_than); |
| 164 | 164 | if (T.is_signed) { |
| 165 | 165 | // Two's complement makes this math pretty easy. |
| 166 | const UnsignedT = @IntType(false, T.bit_count); | |
| 166 | const UnsignedT = std.meta.IntType(false, T.bit_count); | |
| 167 | 167 | const lo = @bitCast(UnsignedT, at_least); |
| 168 | 168 | const hi = @bitCast(UnsignedT, less_than); |
| 169 | 169 | const result = lo +% r.uintLessThan(UnsignedT, hi -% lo); |
| ... | ... | @@ -180,7 +180,7 @@ pub const Random = struct { |
| 180 | 180 | assert(at_least <= at_most); |
| 181 | 181 | if (T.is_signed) { |
| 182 | 182 | // Two's complement makes this math pretty easy. |
| 183 | const UnsignedT = @IntType(false, T.bit_count); | |
| 183 | const UnsignedT = std.meta.IntType(false, T.bit_count); | |
| 184 | 184 | const lo = @bitCast(UnsignedT, at_least); |
| 185 | 185 | const hi = @bitCast(UnsignedT, at_most); |
| 186 | 186 | const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo); |
| ... | ... | @@ -198,7 +198,7 @@ pub const Random = struct { |
| 198 | 198 | assert(at_least <= at_most); |
| 199 | 199 | if (T.is_signed) { |
| 200 | 200 | // Two's complement makes this math pretty easy. |
| 201 | const UnsignedT = @IntType(false, T.bit_count); | |
| 201 | const UnsignedT = std.meta.IntType(false, T.bit_count); | |
| 202 | 202 | const lo = @bitCast(UnsignedT, at_least); |
| 203 | 203 | const hi = @bitCast(UnsignedT, at_most); |
| 204 | 204 | const result = lo +% r.uintAtMost(UnsignedT, hi -% lo); |
| ... | ... | @@ -281,7 +281,7 @@ pub const Random = struct { |
| 281 | 281 | /// This function introduces a minor bias. |
| 282 | 282 | pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { |
| 283 | 283 | comptime assert(T.is_signed == false); |
| 284 | const T2 = @IntType(false, T.bit_count * 2); | |
| 284 | const T2 = std.meta.IntType(false, T.bit_count * 2); | |
| 285 | 285 | |
| 286 | 286 | // adapted from: |
| 287 | 287 | // http://www.pcg-random.org/posts/bounded-rands.html |
lib/std/special/c.zig+1-1| ... | ... | @@ -511,7 +511,7 @@ export fn roundf(a: f32) f32 { |
| 511 | 511 | fn generic_fmod(comptime T: type, x: T, y: T) T { |
| 512 | 512 | @setRuntimeSafety(false); |
| 513 | 513 | |
| 514 | const uint = @IntType(false, T.bit_count); | |
| 514 | const uint = std.meta.IntType(false, T.bit_count); | |
| 515 | 515 | const log2uint = math.Log2Int(uint); |
| 516 | 516 | const digits = if (T == f32) 23 else 52; |
| 517 | 517 | const exp_bits = if (T == f32) 9 else 12; |
lib/std/special/compiler_rt/addXf3.zig+7-7| ... | ... | @@ -54,21 +54,21 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 { |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 |
| 57 | fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 { | |
| 58 | const Z = @IntType(false, T.bit_count); | |
| 59 | const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); | |
| 57 | fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { | |
| 58 | const Z = std.meta.IntType(false, T.bit_count); | |
| 59 | const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); | |
| 60 | 60 | const significandBits = std.math.floatMantissaBits(T); |
| 61 | 61 | const implicitBit = @as(Z, 1) << significandBits; |
| 62 | 62 | |
| 63 | const shift = @clz(@IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit); | |
| 63 | const shift = @clz(std.meta.IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit); | |
| 64 | 64 | significand.* <<= @intCast(S, shift); |
| 65 | 65 | return 1 - shift; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 |
| 69 | 69 | fn addXf3(comptime T: type, a: T, b: T) T { |
| 70 | const Z = @IntType(false, T.bit_count); | |
| 71 | const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); | |
| 70 | const Z = std.meta.IntType(false, T.bit_count); | |
| 71 | const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); | |
| 72 | 72 | |
| 73 | 73 | const typeWidth = T.bit_count; |
| 74 | 74 | const significandBits = std.math.floatMantissaBits(T); |
| ... | ... | @@ -182,7 +182,7 @@ fn addXf3(comptime T: type, a: T, b: T) T { |
| 182 | 182 | // If partial cancellation occured, we need to left-shift the result |
| 183 | 183 | // and adjust the exponent: |
| 184 | 184 | if (aSignificand < implicitBit << 3) { |
| 185 | const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(@IntType(false, T.bit_count), implicitBit << 3)); | |
| 185 | const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.IntType(false, T.bit_count), implicitBit << 3)); | |
| 186 | 186 | aSignificand <<= @intCast(S, shift); |
| 187 | 187 | aExponent -= shift; |
| 188 | 188 | } |
lib/std/special/compiler_rt/compareXf2.zig+3-3| ... | ... | @@ -22,8 +22,8 @@ const GE = extern enum(i32) { |
| 22 | 22 | pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT { |
| 23 | 23 | @setRuntimeSafety(builtin.is_test); |
| 24 | 24 | |
| 25 | const srep_t = @IntType(true, T.bit_count); | |
| 26 | const rep_t = @IntType(false, T.bit_count); | |
| 25 | const srep_t = std.meta.IntType(true, T.bit_count); | |
| 26 | const rep_t = std.meta.IntType(false, T.bit_count); | |
| 27 | 27 | |
| 28 | 28 | const significandBits = std.math.floatMantissaBits(T); |
| 29 | 29 | const exponentBits = std.math.floatExponentBits(T); |
| ... | ... | @@ -68,7 +68,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT { |
| 68 | 68 | pub fn unordcmp(comptime T: type, a: T, b: T) i32 { |
| 69 | 69 | @setRuntimeSafety(builtin.is_test); |
| 70 | 70 | |
| 71 | const rep_t = @IntType(false, T.bit_count); | |
| 71 | const rep_t = std.meta.IntType(false, T.bit_count); | |
| 72 | 72 | |
| 73 | 73 | const significandBits = std.math.floatMantissaBits(T); |
| 74 | 74 | const exponentBits = std.math.floatExponentBits(T); |
lib/std/special/compiler_rt/divdf3.zig+4-4| ... | ... | @@ -7,8 +7,8 @@ const builtin = @import("builtin"); |
| 7 | 7 | |
| 8 | 8 | pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { |
| 9 | 9 | @setRuntimeSafety(builtin.is_test); |
| 10 | const Z = @IntType(false, f64.bit_count); | |
| 11 | const SignedZ = @IntType(true, f64.bit_count); | |
| 10 | const Z = std.meta.IntType(false, f64.bit_count); | |
| 11 | const SignedZ = std.meta.IntType(true, f64.bit_count); | |
| 12 | 12 | |
| 13 | 13 | const typeWidth = f64.bit_count; |
| 14 | 14 | const significandBits = std.math.floatMantissaBits(f64); |
| ... | ... | @@ -312,9 +312,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 { | |
| 315 | fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { | |
| 316 | 316 | @setRuntimeSafety(builtin.is_test); |
| 317 | const Z = @IntType(false, T.bit_count); | |
| 317 | const Z = std.meta.IntType(false, T.bit_count); | |
| 318 | 318 | const significandBits = std.math.floatMantissaBits(T); |
| 319 | 319 | const implicitBit = @as(Z, 1) << significandBits; |
| 320 | 320 |
lib/std/special/compiler_rt/divsf3.zig+3-3| ... | ... | @@ -7,7 +7,7 @@ const builtin = @import("builtin"); |
| 7 | 7 | |
| 8 | 8 | pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 9 | 9 | @setRuntimeSafety(builtin.is_test); |
| 10 | const Z = @IntType(false, f32.bit_count); | |
| 10 | const Z = std.meta.IntType(false, f32.bit_count); | |
| 11 | 11 | |
| 12 | 12 | const typeWidth = f32.bit_count; |
| 13 | 13 | const significandBits = std.math.floatMantissaBits(f32); |
| ... | ... | @@ -185,9 +185,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 { | |
| 188 | fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { | |
| 189 | 189 | @setRuntimeSafety(builtin.is_test); |
| 190 | const Z = @IntType(false, T.bit_count); | |
| 190 | const Z = std.meta.IntType(false, T.bit_count); | |
| 191 | 191 | const significandBits = std.math.floatMantissaBits(T); |
| 192 | 192 | const implicitBit = @as(Z, 1) << significandBits; |
| 193 | 193 |
lib/std/special/compiler_rt/extendXfYf2.zig+3-3| ... | ... | @@ -30,11 +30,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 { |
| 30 | 30 | |
| 31 | 31 | const CHAR_BIT = 8; |
| 32 | 32 | |
| 33 | fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t { | |
| 33 | fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.IntType(false, @typeInfo(src_t).Float.bits)) dst_t { | |
| 34 | 34 | @setRuntimeSafety(builtin.is_test); |
| 35 | 35 | |
| 36 | const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits); | |
| 37 | const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits); | |
| 36 | const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits); | |
| 37 | const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits); | |
| 38 | 38 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 39 | 39 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 40 | 40 | const SrcShift = std.math.Log2Int(src_rep_t); |
lib/std/special/compiler_rt/fixint.zig+1-1| ... | ... | @@ -45,7 +45,7 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t { |
| 45 | 45 | if (exponent < 0) return 0; |
| 46 | 46 | |
| 47 | 47 | // The unsigned result needs to be large enough to handle an fixint_t or rep_t |
| 48 | const fixuint_t = @IntType(false, fixint_t.bit_count); | |
| 48 | const fixuint_t = std.meta.IntType(false, fixint_t.bit_count); | |
| 49 | 49 | const UintResultType = if (fixint_t.bit_count > rep_t.bit_count) fixuint_t else rep_t; |
| 50 | 50 | var uint_result: UintResultType = undefined; |
| 51 | 51 |
lib/std/special/compiler_rt/fixuint.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t |
| 10 | 10 | f128 => u128, |
| 11 | 11 | else => unreachable, |
| 12 | 12 | }; |
| 13 | const srep_t = @IntType(true, rep_t.bit_count); | |
| 13 | const srep_t = @import("std").meta.IntType(true, rep_t.bit_count); | |
| 14 | 14 | const significandBits = switch (fp_t) { |
| 15 | 15 | f32 => 23, |
| 16 | 16 | f64 => 52, |
lib/std/special/compiler_rt/floatsiXf.zig+2-2| ... | ... | @@ -5,8 +5,8 @@ const maxInt = std.math.maxInt; |
| 5 | 5 | fn floatsiXf(comptime T: type, a: i32) T { |
| 6 | 6 | @setRuntimeSafety(builtin.is_test); |
| 7 | 7 | |
| 8 | const Z = @IntType(false, T.bit_count); | |
| 9 | const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); | |
| 8 | const Z = std.meta.IntType(false, T.bit_count); | |
| 9 | const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); | |
| 10 | 10 | |
| 11 | 11 | if (a == 0) { |
| 12 | 12 | return @as(T, 0.0); |
lib/std/special/compiler_rt/mulXf3.zig+3-3| ... | ... | @@ -28,7 +28,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 { |
| 28 | 28 | |
| 29 | 29 | fn mulXf3(comptime T: type, a: T, b: T) T { |
| 30 | 30 | @setRuntimeSafety(builtin.is_test); |
| 31 | const Z = @IntType(false, T.bit_count); | |
| 31 | const Z = std.meta.IntType(false, T.bit_count); | |
| 32 | 32 | |
| 33 | 33 | const typeWidth = T.bit_count; |
| 34 | 34 | const significandBits = std.math.floatMantissaBits(T); |
| ... | ... | @@ -264,9 +264,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { |
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 { | |
| 267 | fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { | |
| 268 | 268 | @setRuntimeSafety(builtin.is_test); |
| 269 | const Z = @IntType(false, T.bit_count); | |
| 269 | const Z = std.meta.IntType(false, T.bit_count); | |
| 270 | 270 | const significandBits = std.math.floatMantissaBits(T); |
| 271 | 271 | const implicitBit = @as(Z, 1) << significandBits; |
| 272 | 272 |
lib/std/special/compiler_rt/negXf2.zig+1-1| ... | ... | @@ -19,7 +19,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 { |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | fn negXf2(comptime T: type, a: T) T { |
| 22 | const Z = @IntType(false, T.bit_count); | |
| 22 | const Z = std.meta.IntType(false, T.bit_count); | |
| 23 | 23 | |
| 24 | 24 | const typeWidth = T.bit_count; |
| 25 | 25 | const significandBits = std.math.floatMantissaBits(T); |
lib/std/special/compiler_rt/truncXfYf2.zig+2-2| ... | ... | @@ -36,8 +36,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 { |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | inline fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t { |
| 39 | const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits); | |
| 40 | const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits); | |
| 39 | const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits); | |
| 40 | const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits); | |
| 41 | 41 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 42 | 42 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 43 | 43 | const SrcShift = std.math.Log2Int(src_rep_t); |
lib/std/special/compiler_rt/udivmod.zig+2-2| ... | ... | @@ -10,8 +10,8 @@ const high = 1 - low; |
| 10 | 10 | pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt { |
| 11 | 11 | @setRuntimeSafety(is_test); |
| 12 | 12 | |
| 13 | const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2)); | |
| 14 | const SignedDoubleInt = @IntType(true, DoubleInt.bit_count); | |
| 13 | const SingleInt = @import("std").meta.IntType(false, @divExact(DoubleInt.bit_count, 2)); | |
| 14 | const SignedDoubleInt = @import("std").meta.IntType(true, DoubleInt.bit_count); | |
| 15 | 15 | const Log2SingleInt = @import("std").math.Log2Int(SingleInt); |
| 16 | 16 | |
| 17 | 17 | const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421 |
lib/std/target.zig+1-1| ... | ... | @@ -222,7 +222,7 @@ pub const Target = union(enum) { |
| 222 | 222 | pub const needed_bit_count = 154; |
| 223 | 223 | pub const byte_count = (needed_bit_count + 7) / 8; |
| 224 | 224 | pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize); |
| 225 | pub const Index = std.math.Log2Int(@IntType(false, usize_count * @bitSizeOf(usize))); | |
| 225 | pub const Index = std.math.Log2Int(std.meta.IntType(false, usize_count * @bitSizeOf(usize))); | |
| 226 | 226 | pub const ShiftInt = std.math.Log2Int(usize); |
| 227 | 227 | |
| 228 | 228 | pub const empty = Set{ .ints = [1]usize{0} ** usize_count }; |
lib/std/thread.zig+1-1| ... | ... | @@ -148,7 +148,7 @@ pub const Thread = struct { |
| 148 | 148 | const default_stack_size = 16 * 1024 * 1024; |
| 149 | 149 | |
| 150 | 150 | const Context = @TypeOf(context); |
| 151 | comptime assert(@ArgType(@TypeOf(startFn), 0) == Context); | |
| 151 | comptime assert(@typeInfo(@TypeOf(startFn)).Fn.args[0].arg_type.? == Context); | |
| 152 | 152 | |
| 153 | 153 | if (builtin.os == builtin.Os.windows) { |
| 154 | 154 | const WinThread = struct { |
src-self-hosted/type.zig+1-1| ... | ... | @@ -1042,7 +1042,7 @@ fn hashAny(x: var, comptime seed: u64) u32 { |
| 1042 | 1042 | switch (@typeInfo(@TypeOf(x))) { |
| 1043 | 1043 | .Int => |info| { |
| 1044 | 1044 | comptime var rng = comptime std.rand.DefaultPrng.init(seed); |
| 1045 | const unsigned_x = @bitCast(@IntType(false, info.bits), x); | |
| 1045 | const unsigned_x = @bitCast(std.meta.IntType(false, info.bits), x); | |
| 1046 | 1046 | if (info.bits <= 32) { |
| 1047 | 1047 | return @as(u32, unsigned_x) *% comptime rng.random.scalar(u32); |
| 1048 | 1048 | } else { |
test/compile_errors.zig+3-29| ... | ... | @@ -1657,7 +1657,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1657 | 1657 | \\ var ptr: [*c]u8 = (1 << 64) + 1; |
| 1658 | 1658 | \\} |
| 1659 | 1659 | \\export fn b() void { |
| 1660 | \\ var x: @IntType(false, 65) = 0x1234; | |
| 1660 | \\ var x: u65 = 0x1234; | |
| 1661 | 1661 | \\ var ptr: [*c]u8 = x; |
| 1662 | 1662 | \\} |
| 1663 | 1663 | , &[_][]const u8{ |
| ... | ... | @@ -1896,7 +1896,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1896 | 1896 | |
| 1897 | 1897 | cases.add("exceeded maximum bit width of integer", |
| 1898 | 1898 | \\export fn entry1() void { |
| 1899 | \\ const T = @IntType(false, 65536); | |
| 1899 | \\ const T = u65536; | |
| 1900 | 1900 | \\} |
| 1901 | 1901 | \\export fn entry2() void { |
| 1902 | 1902 | \\ var x: i65536 = 1; |
| ... | ... | @@ -5598,7 +5598,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5598 | 5598 | }); |
| 5599 | 5599 | |
| 5600 | 5600 | cases.add("globally shadowing a primitive type", |
| 5601 | \\const u16 = @intType(false, 8); | |
| 5601 | \\const u16 = u8; | |
| 5602 | 5602 | \\export fn entry() void { |
| 5603 | 5603 | \\ const a: u16 = 300; |
| 5604 | 5604 | \\} |
| ... | ... | @@ -5939,23 +5939,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5939 | 5939 | "tmp.zig:2:1: error: invalid character: '\\t'", |
| 5940 | 5940 | }); |
| 5941 | 5941 | |
| 5942 | cases.add("@ArgType given non function parameter", | |
| 5943 | \\comptime { | |
| 5944 | \\ _ = @ArgType(i32, 3); | |
| 5945 | \\} | |
| 5946 | , &[_][]const u8{ | |
| 5947 | "tmp.zig:2:18: error: expected function, found 'i32'", | |
| 5948 | }); | |
| 5949 | ||
| 5950 | cases.add("@ArgType arg index out of bounds", | |
| 5951 | \\comptime { | |
| 5952 | \\ _ = @ArgType(@TypeOf(add), 2); | |
| 5953 | \\} | |
| 5954 | \\fn add(a: i32, b: i32) i32 { return a + b; } | |
| 5955 | , &[_][]const u8{ | |
| 5956 | "tmp.zig:2:32: error: arg index 2 out of bounds; 'fn(i32, i32) i32' has 2 arguments", | |
| 5957 | }); | |
| 5958 | ||
| 5959 | 5942 | cases.add("calling var args extern function, passing array instead of pointer", |
| 5960 | 5943 | \\export fn entry() void { |
| 5961 | 5944 | \\ foo("hello".*,); |
| ... | ... | @@ -6379,15 +6362,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6379 | 6362 | "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic", |
| 6380 | 6363 | }); |
| 6381 | 6364 | |
| 6382 | cases.add("getting @ArgType of generic function", | |
| 6383 | \\fn generic(a: var) void {} | |
| 6384 | \\comptime { | |
| 6385 | \\ _ = @ArgType(@TypeOf(generic), 0); | |
| 6386 | \\} | |
| 6387 | , &[_][]const u8{ | |
| 6388 | "tmp.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var) var' is generic", | |
| 6389 | }); | |
| 6390 | ||
| 6391 | 6365 | cases.add("unsupported modifier at start of asm output constraint", |
| 6392 | 6366 | \\export fn foo() void { |
| 6393 | 6367 | \\ var bar: u32 = 3; |
test/stage1/behavior/bit_shifting.zig+2-2| ... | ... | @@ -2,9 +2,9 @@ const std = @import("std"); |
| 2 | 2 | const expect = std.testing.expect; |
| 3 | 3 | |
| 4 | 4 | fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type { |
| 5 | expect(Key == @IntType(false, Key.bit_count)); | |
| 5 | expect(Key == std.meta.IntType(false, Key.bit_count)); | |
| 6 | 6 | expect(Key.bit_count >= mask_bit_count); |
| 7 | const ShardKey = @IntType(false, mask_bit_count); | |
| 7 | const ShardKey = std.meta.IntType(false, mask_bit_count); | |
| 8 | 8 | const shift_amount = Key.bit_count - ShardKey.bit_count; |
| 9 | 9 | return struct { |
| 10 | 10 | const Self = @This(); |
test/stage1/behavior/math.zig+1-1| ... | ... | @@ -270,7 +270,7 @@ fn testBinaryNot(x: u16) void { |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | test "small int addition" { |
| 273 | var x: @IntType(false, 2) = 0; | |
| 273 | var x: u2 = 0; | |
| 274 | 274 | expect(x == 0); |
| 275 | 275 | |
| 276 | 276 | x += 1; |
test/stage1/behavior/misc.zig-29| ... | ... | @@ -24,35 +24,6 @@ test "call disabled extern fn" { |
| 24 | 24 | disabledExternFn(); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | test "@IntType builtin" { | |
| 28 | expect(@IntType(true, 8) == i8); | |
| 29 | expect(@IntType(true, 16) == i16); | |
| 30 | expect(@IntType(true, 32) == i32); | |
| 31 | expect(@IntType(true, 64) == i64); | |
| 32 | ||
| 33 | expect(@IntType(false, 8) == u8); | |
| 34 | expect(@IntType(false, 16) == u16); | |
| 35 | expect(@IntType(false, 32) == u32); | |
| 36 | expect(@IntType(false, 64) == u64); | |
| 37 | ||
| 38 | expect(i8.bit_count == 8); | |
| 39 | expect(i16.bit_count == 16); | |
| 40 | expect(i32.bit_count == 32); | |
| 41 | expect(i64.bit_count == 64); | |
| 42 | ||
| 43 | expect(i8.is_signed); | |
| 44 | expect(i16.is_signed); | |
| 45 | expect(i32.is_signed); | |
| 46 | expect(i64.is_signed); | |
| 47 | expect(isize.is_signed); | |
| 48 | ||
| 49 | expect(!u8.is_signed); | |
| 50 | expect(!u16.is_signed); | |
| 51 | expect(!u32.is_signed); | |
| 52 | expect(!u64.is_signed); | |
| 53 | expect(!usize.is_signed); | |
| 54 | } | |
| 55 | ||
| 56 | 27 | test "floating point primitive bit counts" { |
| 57 | 28 | expect(f16.bit_count == 16); |
| 58 | 29 | expect(f32.bit_count == 32); |
test/stage1/behavior/reflection.zig+3-3| ... | ... | @@ -16,9 +16,9 @@ test "reflection: function return type, var args, and param types" { |
| 16 | 16 | expect(@TypeOf(dummy).ReturnType == i32); |
| 17 | 17 | expect(!@TypeOf(dummy).is_var_args); |
| 18 | 18 | expect(@TypeOf(dummy).arg_count == 3); |
| 19 | expect(@ArgType(@TypeOf(dummy), 0) == bool); | |
| 20 | expect(@ArgType(@TypeOf(dummy), 1) == i32); | |
| 21 | expect(@ArgType(@TypeOf(dummy), 2) == f32); | |
| 19 | expect(@typeInfo(@TypeOf(dummy)).Fn.args[0].arg_type.? == bool); | |
| 20 | expect(@typeInfo(@TypeOf(dummy)).Fn.args[1].arg_type.? == i32); | |
| 21 | expect(@typeInfo(@TypeOf(dummy)).Fn.args[2].arg_type.? == f32); | |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 |