authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-04-29 11:01:19+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-04-29 11:01:19+03:00
log15141d865abda09c09d8f6e3385f127527c5232e
tree519115799840c1abe4be6aa708a3ca5079fbd817
parent5929e5ca0ebde636dd69d52d648df8cff59e6d96
parent350b2adacda217014dc511ccc4cd73f22ddaac22
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #5210 from tadeokondrak/IntType-to-Int

std.meta.IntType -> std.meta.Int

41 files changed, 111 insertions(+), 108 deletions(-)

lib/std/child_process.zig+1-1
......@@ -830,7 +830,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
830830 os.exit(1);
831831}
832832
833const ErrInt = std.meta.IntType(false, @sizeOf(anyerror) * 8);
833const ErrInt = std.meta.Int(false, @sizeOf(anyerror) * 8);
834834
835835fn writeIntFd(fd: i32, value: ErrInt) !void {
836836 const file = File{
lib/std/debug/leb128.zig+6-6
......@@ -2,7 +2,7 @@ const std = @import("std");
22const testing = std.testing;
33
44pub fn readULEB128(comptime T: type, in_stream: var) !T {
5 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
5 const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count));
66
77 var result: T = 0;
88 var shift: usize = 0;
......@@ -27,7 +27,7 @@ pub fn readULEB128(comptime T: type, in_stream: var) !T {
2727}
2828
2929pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
30 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
30 const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count));
3131
3232 var result: T = 0;
3333 var shift: usize = 0;
......@@ -55,8 +55,8 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
5555}
5656
5757pub fn readILEB128(comptime T: type, in_stream: var) !T {
58 const UT = std.meta.IntType(false, T.bit_count);
59 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
58 const UT = std.meta.Int(false, T.bit_count);
59 const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count));
6060
6161 var result: UT = 0;
6262 var shift: usize = 0;
......@@ -87,8 +87,8 @@ pub fn readILEB128(comptime T: type, in_stream: var) !T {
8787}
8888
8989pub fn readILEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
90 const UT = std.meta.IntType(false, T.bit_count);
91 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
90 const UT = std.meta.Int(false, T.bit_count);
91 const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count));
9292
9393 var result: UT = 0;
9494 var shift: usize = 0;
lib/std/fmt.zig+2-2
......@@ -906,7 +906,7 @@ fn formatIntSigned(
906906 .fill = options.fill,
907907 };
908908 const bit_count = @typeInfo(@TypeOf(value)).Int.bits;
909 const Uint = std.meta.IntType(false, bit_count);
909 const Uint = std.meta.Int(false, bit_count);
910910 if (value < 0) {
911911 try out_stream.writeAll("-");
912912 const new_value = math.absCast(value);
......@@ -930,7 +930,7 @@ fn formatIntUnsigned(
930930 assert(base >= 2);
931931 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;
932932 const min_int_bits = comptime math.max(@TypeOf(value).bit_count, @TypeOf(base).bit_count);
933 const MinInt = std.meta.IntType(@TypeOf(value).is_signed, min_int_bits);
933 const MinInt = std.meta.Int(@TypeOf(value).is_signed, min_int_bits);
934934 var a: MinInt = value;
935935 var index: usize = buf.len;
936936
lib/std/fmt/parse_float.zig+1-1
......@@ -367,7 +367,7 @@ test "fmt.parseFloat" {
367367 const epsilon = 1e-7;
368368
369369 inline for ([_]type{ f16, f32, f64, f128 }) |T| {
370 const Z = std.meta.IntType(false, T.bit_count);
370 const Z = std.meta.Int(false, T.bit_count);
371371
372372 testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
373373 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 {
9393 // TODO Check if the situation is better after #561 is resolved.
9494 .Int => @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}),
9595
96 .Float => |info| hash(hasher, @bitCast(std.meta.IntType(false, info.bits), key), strat),
96 .Float => |info| hash(hasher, @bitCast(std.meta.Int(false, info.bits), key), strat),
9797
9898 .Bool => hash(hasher, @boolToInt(key), strat),
9999 .Enum => hash(hasher, @enumToInt(key), strat),
lib/std/hash/wyhash.zig+1-1
......@@ -10,7 +10,7 @@ const primes = [_]u64{
1010};
1111
1212fn read_bytes(comptime bytes: u8, data: []const u8) u64 {
13 const T = std.meta.IntType(false, 8 * bytes);
13 const T = std.meta.Int(false, 8 * bytes);
1414 return mem.readIntLittle(T, data[0..bytes]);
1515}
1616
lib/std/heap.zig+1-1
......@@ -1015,7 +1015,7 @@ fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!vo
10151015 // very near usize?
10161016 if (mem.page_size << 2 > maxInt(usize)) return;
10171017
1018 const USizeShift = std.meta.IntType(false, std.math.log2(usize.bit_count));
1018 const USizeShift = std.meta.Int(false, std.math.log2(usize.bit_count));
10191019 const large_align = @as(u29, mem.page_size << 2);
10201020
10211021 var align_mask: usize = undefined;
lib/std/io/bit_in_stream.zig+1-1
......@@ -53,7 +53,7 @@ pub fn BitInStream(endian: builtin.Endian, comptime InStreamType: type) type {
5353 assert(u_bit_count >= bits);
5454 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
5555 };
56 const Buf = std.meta.IntType(false, buf_bit_count);
56 const Buf = std.meta.Int(false, buf_bit_count);
5757 const BufShift = math.Log2Int(Buf);
5858
5959 out_bits.* = @as(usize, 0);
lib/std/io/bit_out_stream.zig+1-1
......@@ -45,7 +45,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime OutStreamType: type) type {
4545 assert(u_bit_count >= bits);
4646 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
4747 };
48 const Buf = std.meta.IntType(false, buf_bit_count);
48 const Buf = std.meta.Int(false, buf_bit_count);
4949 const BufShift = math.Log2Int(Buf);
5050
5151 const buf_value = @intCast(Buf, value);
lib/std/io/serialization.zig+7-7
......@@ -51,7 +51,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
5151 const u8_bit_count = 8;
5252 const t_bit_count = comptime meta.bitCount(T);
5353
54 const U = std.meta.IntType(false, t_bit_count);
54 const U = std.meta.Int(false, t_bit_count);
5555 const Log2U = math.Log2Int(U);
5656 const int_size = (U.bit_count + 7) / 8;
5757
......@@ -66,7 +66,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
6666
6767 if (int_size == 1) {
6868 if (t_bit_count == 8) return @bitCast(T, buffer[0]);
69 const PossiblySignedByte = std.meta.IntType(T.is_signed, 8);
69 const PossiblySignedByte = std.meta.Int(T.is_signed, 8);
7070 return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));
7171 }
7272
......@@ -236,7 +236,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
236236 const t_bit_count = comptime meta.bitCount(T);
237237 const u8_bit_count = comptime meta.bitCount(u8);
238238
239 const U = std.meta.IntType(false, t_bit_count);
239 const U = std.meta.Int(false, t_bit_count);
240240 const Log2U = math.Log2Int(U);
241241 const int_size = (U.bit_count + 7) / 8;
242242
......@@ -372,8 +372,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
372372
373373 comptime var i = 0;
374374 inline while (i <= max_test_bitsize) : (i += 1) {
375 const U = std.meta.IntType(false, i);
376 const S = std.meta.IntType(true, i);
375 const U = std.meta.Int(false, i);
376 const S = std.meta.Int(true, i);
377377 try _serializer.serializeInt(@as(U, i));
378378 if (i != 0) try _serializer.serializeInt(@as(S, -1)) else try _serializer.serialize(@as(S, 0));
379379 }
......@@ -381,8 +381,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
381381
382382 i = 0;
383383 inline while (i <= max_test_bitsize) : (i += 1) {
384 const U = std.meta.IntType(false, i);
385 const S = std.meta.IntType(true, i);
384 const U = std.meta.Int(false, i);
385 const S = std.meta.Int(true, i);
386386 const x = try _deserializer.deserializeInt(U);
387387 const y = try _deserializer.deserializeInt(S);
388388 testing.expect(x == @as(U, i));
lib/std/math.zig+11-11
......@@ -458,7 +458,7 @@ pub fn Log2Int(comptime T: type) type {
458458 count += 1;
459459 }
460460
461 return std.meta.IntType(false, count);
461 return std.meta.Int(false, count);
462462}
463463
464464pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type {
......@@ -474,7 +474,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
474474 if (is_signed) {
475475 magnitude_bits += 1;
476476 }
477 return std.meta.IntType(is_signed, magnitude_bits);
477 return std.meta.Int(is_signed, magnitude_bits);
478478}
479479
480480test "math.IntFittingRange" {
......@@ -686,7 +686,7 @@ fn testRem() void {
686686/// Result is an unsigned integer.
687687pub fn absCast(x: var) switch (@typeInfo(@TypeOf(x))) {
688688 .ComptimeInt => comptime_int,
689 .Int => |intInfo| std.meta.IntType(false, intInfo.bits),
689 .Int => |intInfo| std.meta.Int(false, intInfo.bits),
690690 else => @compileError("absCast only accepts integers"),
691691} {
692692 switch (@typeInfo(@TypeOf(x))) {
......@@ -698,7 +698,7 @@ pub fn absCast(x: var) switch (@typeInfo(@TypeOf(x))) {
698698 }
699699 },
700700 .Int => |intInfo| {
701 const Uint = std.meta.IntType(false, intInfo.bits);
701 const Uint = std.meta.Int(false, intInfo.bits);
702702 if (x < 0) {
703703 return ~@bitCast(Uint, x +% -1);
704704 } else {
......@@ -719,10 +719,10 @@ test "math.absCast" {
719719
720720/// Returns the negation of the integer parameter.
721721/// Result is a signed integer.
722pub fn negateCast(x: var) !std.meta.IntType(true, @TypeOf(x).bit_count) {
722pub fn negateCast(x: var) !std.meta.Int(true, @TypeOf(x).bit_count) {
723723 if (@TypeOf(x).is_signed) return negate(x);
724724
725 const int = std.meta.IntType(true, @TypeOf(x).bit_count);
725 const int = std.meta.Int(true, @TypeOf(x).bit_count);
726726 if (x > -minInt(int)) return error.Overflow;
727727
728728 if (x == -minInt(int)) return minInt(int);
......@@ -808,11 +808,11 @@ fn testFloorPowerOfTwo() void {
808808/// Returns the next power of two (if the value is not already a power of two).
809809/// Only unsigned integers can be used. Zero is not an allowed input.
810810/// Result is a type with 1 more bit than the input type.
811pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.IntType(T.is_signed, T.bit_count + 1) {
811pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(T.is_signed, T.bit_count + 1) {
812812 comptime assert(@typeInfo(T) == .Int);
813813 comptime assert(!T.is_signed);
814814 assert(value != 0);
815 comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1);
815 comptime const PromotedType = std.meta.Int(T.is_signed, T.bit_count + 1);
816816 comptime const shiftType = std.math.Log2Int(PromotedType);
817817 return @as(PromotedType, 1) << @intCast(shiftType, T.bit_count - @clz(T, value - 1));
818818}
......@@ -823,7 +823,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.IntType(T.is_s
823823pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
824824 comptime assert(@typeInfo(T) == .Int);
825825 comptime assert(!T.is_signed);
826 comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1);
826 comptime const PromotedType = std.meta.Int(T.is_signed, T.bit_count + 1);
827827 comptime const overflowBit = @as(PromotedType, 1) << T.bit_count;
828828 var x = ceilPowerOfTwoPromote(T, value);
829829 if (overflowBit & x != 0) {
......@@ -965,8 +965,8 @@ test "max value type" {
965965 testing.expect(x == 2147483647);
966966}
967967
968pub fn mulWide(comptime T: type, a: T, b: T) std.meta.IntType(T.is_signed, T.bit_count * 2) {
969 const ResultInt = std.meta.IntType(T.is_signed, T.bit_count * 2);
968pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(T.is_signed, T.bit_count * 2) {
969 const ResultInt = std.meta.Int(T.is_signed, T.bit_count * 2);
970970 return @as(ResultInt, a) * @as(ResultInt, b);
971971}
972972
lib/std/math/big/int.zig+4-4
......@@ -9,8 +9,8 @@ const maxInt = std.math.maxInt;
99const minInt = std.math.minInt;
1010
1111pub const Limb = usize;
12pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count);
13pub const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count);
12pub const DoubleLimb = std.meta.Int(false, 2 * Limb.bit_count);
13pub const SignedDoubleLimb = std.meta.Int(true, DoubleLimb.bit_count);
1414pub const Log2Limb = math.Log2Int(Limb);
1515
1616comptime {
......@@ -272,7 +272,7 @@ pub const Int = struct {
272272
273273 switch (@typeInfo(T)) {
274274 .Int => |info| {
275 const UT = if (T.is_signed) std.meta.IntType(false, T.bit_count - 1) else T;
275 const UT = if (T.is_signed) std.meta.Int(false, T.bit_count - 1) else T;
276276
277277 try self.ensureCapacity(@sizeOf(UT) / @sizeOf(Limb));
278278 self.metadata = 0;
......@@ -335,7 +335,7 @@ pub const Int = struct {
335335 pub fn to(self: Int, comptime T: type) ConvertError!T {
336336 switch (@typeInfo(T)) {
337337 .Int => {
338 const UT = std.meta.IntType(false, T.bit_count);
338 const UT = std.meta.Int(false, T.bit_count);
339339
340340 if (self.bitCountTwosComp() > T.bit_count) {
341341 return error.TargetTooSmall;
lib/std/math/big/rational.zig+3-3
......@@ -127,8 +127,8 @@ pub const Rational = struct {
127127 // Translated from golang.go/src/math/big/rat.go.
128128 debug.assert(@typeInfo(T) == .Float);
129129
130 const UnsignedIntType = std.meta.IntType(false, T.bit_count);
131 const f_bits = @bitCast(UnsignedIntType, f);
130 const UnsignedInt = std.meta.Int(false, T.bit_count);
131 const f_bits = @bitCast(UnsignedInt, f);
132132
133133 const exponent_bits = math.floatExponentBits(T);
134134 const exponent_bias = (1 << (exponent_bits - 1)) - 1;
......@@ -186,7 +186,7 @@ pub const Rational = struct {
186186 debug.assert(@typeInfo(T) == .Float);
187187
188188 const fsize = T.bit_count;
189 const BitReprType = std.meta.IntType(false, T.bit_count);
189 const BitReprType = std.meta.Int(false, T.bit_count);
190190
191191 const msize = math.floatMantissaBits(T);
192192 const msize1 = msize + 1;
lib/std/math/cos.zig+1-1
......@@ -44,7 +44,7 @@ const pi4c = 2.69515142907905952645E-15;
4444const m4pi = 1.273239544735162542821171882678754627704620361328125;
4545
4646fn cos_(comptime T: type, x_: T) T {
47 const I = std.meta.IntType(true, T.bit_count);
47 const I = std.meta.Int(true, T.bit_count);
4848
4949 var x = x_;
5050 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 {
145145 var xe = r2.exponent;
146146 var x1 = r2.significand;
147147
148 var i = @floatToInt(std.meta.IntType(true, T.bit_count), yi);
148 var i = @floatToInt(std.meta.Int(true, T.bit_count), yi);
149149 while (i != 0) : (i >>= 1) {
150150 const overflow_shift = math.floatExponentBits(T) + 1;
151151 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;
4545const m4pi = 1.273239544735162542821171882678754627704620361328125;
4646
4747fn sin_(comptime T: type, x_: T) T {
48 const I = std.meta.IntType(true, T.bit_count);
48 const I = std.meta.Int(true, T.bit_count);
4949
5050 var x = x_;
5151 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)) {
3131 }
3232}
3333
34fn sqrt_int(comptime T: type, value: T) std.meta.IntType(false, T.bit_count / 2) {
34fn sqrt_int(comptime T: type, value: T) std.meta.Int(false, T.bit_count / 2) {
3535 var op = value;
3636 var res: T = 0;
3737 var one: T = 1 << (T.bit_count - 2);
......@@ -50,7 +50,7 @@ fn sqrt_int(comptime T: type, value: T) std.meta.IntType(false, T.bit_count / 2)
5050 one >>= 2;
5151 }
5252
53 const ResultType = std.meta.IntType(false, T.bit_count / 2);
53 const ResultType = std.meta.Int(false, T.bit_count / 2);
5454 return @intCast(ResultType, res);
5555}
5656
......@@ -66,7 +66,7 @@ test "math.sqrt_int" {
6666/// Returns the return type `sqrt` will return given an operand of type `T`.
6767pub fn Sqrt(comptime T: type) type {
6868 return switch (@typeInfo(T)) {
69 .Int => |int| std.meta.IntType(false, int.bits / 2),
69 .Int => |int| std.meta.Int(false, int.bits / 2),
7070 else => T,
7171 };
7272}
lib/std/math/tan.zig+1-1
......@@ -38,7 +38,7 @@ const pi4c = 2.69515142907905952645E-15;
3838const m4pi = 1.273239544735162542821171882678754627704620361328125;
3939
4040fn tan_(comptime T: type, x_: T) T {
41 const I = std.meta.IntType(true, T.bit_count);
41 const I = std.meta.Int(true, T.bit_count);
4242
4343 var x = x_;
4444 if (x == 0 or math.isNan(x)) {
lib/std/mem.zig+2-2
......@@ -1065,7 +1065,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
10651065 return set(u8, buffer, 0);
10661066
10671067 // TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough
1068 const uint = std.meta.IntType(false, T.bit_count);
1068 const uint = std.meta.Int(false, T.bit_count);
10691069 var bits = @truncate(uint, value);
10701070 for (buffer) |*b| {
10711071 b.* = @truncate(u8, bits);
......@@ -1085,7 +1085,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {
10851085 return set(u8, buffer, 0);
10861086
10871087 // TODO I want to call writeIntBig here but comptime eval facilities aren't good enough
1088 const uint = std.meta.IntType(false, T.bit_count);
1088 const uint = std.meta.Int(false, T.bit_count);
10891089 var bits = @truncate(uint, value);
10901090 var index: usize = buffer.len;
10911091 while (index != 0) {
lib/std/meta.zig+4-1
......@@ -642,7 +642,10 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
642642 }
643643}
644644
645pub fn IntType(comptime is_signed: bool, comptime bit_count: u16) type {
645/// Deprecated: use Int
646pub const IntType = Int;
647
648pub fn Int(comptime is_signed: bool, comptime bit_count: u16) type {
646649 return @Type(TypeInfo{
647650 .Int = .{
648651 .is_signed = is_signed,
lib/std/os.zig+1-1
......@@ -3681,7 +3681,7 @@ pub fn res_mkquery(
36813681 // Make a reasonably unpredictable id
36823682 var ts: timespec = undefined;
36833683 clock_gettime(CLOCK_REALTIME, &ts) catch {};
3684 const UInt = std.meta.IntType(false, @TypeOf(ts.tv_nsec).bit_count);
3684 const UInt = std.meta.Int(false, @TypeOf(ts.tv_nsec).bit_count);
36853685 const unsec = @bitCast(UInt, ts.tv_nsec);
36863686 const id = @truncate(u32, unsec + unsec / 65536);
36873687 q[0] = @truncate(u8, id / 256);
lib/std/os/bits/linux.zig+1-1
......@@ -1037,7 +1037,7 @@ pub const dl_phdr_info = extern struct {
10371037
10381038pub const CPU_SETSIZE = 128;
10391039pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
1040pub const cpu_count_t = std.meta.IntType(false, std.math.log2(CPU_SETSIZE * 8));
1040pub const cpu_count_t = std.meta.Int(false, std.math.log2(CPU_SETSIZE * 8));
10411041
10421042pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
10431043 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 {
3434
3535 //we bitcast the desired Int type to an unsigned version of itself
3636 // to avoid issues with shifting signed ints.
37 const UnInt = std.meta.IntType(false, int_bits);
37 const UnInt = std.meta.Int(false, int_bits);
3838
3939 //The maximum container int type
40 const MinIo = std.meta.IntType(false, min_io_bits);
40 const MinIo = std.meta.Int(false, min_io_bits);
4141
4242 //The minimum container int type
43 const MaxIo = std.meta.IntType(false, max_io_bits);
43 const MaxIo = std.meta.Int(false, max_io_bits);
4444
4545 return struct {
4646 pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {
......@@ -322,7 +322,7 @@ test "PackedIntArray" {
322322 inline while (bits <= 256) : (bits += 1) {
323323 //alternate unsigned and signed
324324 const even = bits % 2 == 0;
325 const I = std.meta.IntType(even, bits);
325 const I = std.meta.Int(even, bits);
326326
327327 const PackedArray = PackedIntArray(I, int_count);
328328 const expected_bytes = ((bits * int_count) + 7) / 8;
......@@ -369,7 +369,7 @@ test "PackedIntSlice" {
369369 inline while (bits <= 256) : (bits += 1) {
370370 //alternate unsigned and signed
371371 const even = bits % 2 == 0;
372 const I = std.meta.IntType(even, bits);
372 const I = std.meta.Int(even, bits);
373373 const P = PackedIntSlice(I);
374374
375375 var data = P.init(&buffer, int_count);
......@@ -399,7 +399,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {
399399
400400 comptime var bits = 0;
401401 inline while (bits <= max_bits) : (bits += 1) {
402 const Int = std.meta.IntType(false, bits);
402 const Int = std.meta.Int(false, bits);
403403
404404 const PackedArray = PackedIntArray(Int, int_count);
405405 var packed_array = @as(PackedArray, undefined);
lib/std/rand.zig+10-10
......@@ -45,8 +45,8 @@ pub const Random = struct {
4545 /// Returns a random int `i` such that `0 <= i <= maxInt(T)`.
4646 /// `i` is evenly distributed.
4747 pub fn int(r: *Random, comptime T: type) T {
48 const UnsignedT = std.meta.IntType(false, T.bit_count);
49 const ByteAlignedT = std.meta.IntType(false, @divTrunc(T.bit_count + 7, 8) * 8);
48 const UnsignedT = std.meta.Int(false, T.bit_count);
49 const ByteAlignedT = std.meta.Int(false, @divTrunc(T.bit_count + 7, 8) * 8);
5050
5151 var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;
5252 r.bytes(rand_bytes[0..]);
......@@ -85,9 +85,9 @@ pub const Random = struct {
8585 comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation!
8686 assert(0 < less_than);
8787 // Small is typically u32
88 const Small = std.meta.IntType(false, @divTrunc(T.bit_count + 31, 32) * 32);
88 const Small = std.meta.Int(false, @divTrunc(T.bit_count + 31, 32) * 32);
8989 // Large is typically u64
90 const Large = std.meta.IntType(false, Small.bit_count * 2);
90 const Large = std.meta.Int(false, Small.bit_count * 2);
9191
9292 // adapted from:
9393 // http://www.pcg-random.org/posts/bounded-rands.html
......@@ -99,7 +99,7 @@ pub const Random = struct {
9999 // TODO: workaround for https://github.com/ziglang/zig/issues/1770
100100 // should be:
101101 // var t: Small = -%less_than;
102 var t: Small = @bitCast(Small, -%@bitCast(std.meta.IntType(true, Small.bit_count), @as(Small, less_than)));
102 var t: Small = @bitCast(Small, -%@bitCast(std.meta.Int(true, Small.bit_count), @as(Small, less_than)));
103103
104104 if (t >= less_than) {
105105 t -= less_than;
......@@ -145,7 +145,7 @@ pub const Random = struct {
145145 assert(at_least < less_than);
146146 if (T.is_signed) {
147147 // Two's complement makes this math pretty easy.
148 const UnsignedT = std.meta.IntType(false, T.bit_count);
148 const UnsignedT = std.meta.Int(false, T.bit_count);
149149 const lo = @bitCast(UnsignedT, at_least);
150150 const hi = @bitCast(UnsignedT, less_than);
151151 const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);
......@@ -163,7 +163,7 @@ pub const Random = struct {
163163 assert(at_least < less_than);
164164 if (T.is_signed) {
165165 // Two's complement makes this math pretty easy.
166 const UnsignedT = std.meta.IntType(false, T.bit_count);
166 const UnsignedT = std.meta.Int(false, T.bit_count);
167167 const lo = @bitCast(UnsignedT, at_least);
168168 const hi = @bitCast(UnsignedT, less_than);
169169 const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);
......@@ -180,7 +180,7 @@ pub const Random = struct {
180180 assert(at_least <= at_most);
181181 if (T.is_signed) {
182182 // Two's complement makes this math pretty easy.
183 const UnsignedT = std.meta.IntType(false, T.bit_count);
183 const UnsignedT = std.meta.Int(false, T.bit_count);
184184 const lo = @bitCast(UnsignedT, at_least);
185185 const hi = @bitCast(UnsignedT, at_most);
186186 const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);
......@@ -198,7 +198,7 @@ pub const Random = struct {
198198 assert(at_least <= at_most);
199199 if (T.is_signed) {
200200 // Two's complement makes this math pretty easy.
201 const UnsignedT = std.meta.IntType(false, T.bit_count);
201 const UnsignedT = std.meta.Int(false, T.bit_count);
202202 const lo = @bitCast(UnsignedT, at_least);
203203 const hi = @bitCast(UnsignedT, at_most);
204204 const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);
......@@ -275,7 +275,7 @@ pub const Random = struct {
275275/// This function introduces a minor bias.
276276pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
277277 comptime assert(T.is_signed == false);
278 const T2 = std.meta.IntType(false, T.bit_count * 2);
278 const T2 = std.meta.Int(false, T.bit_count * 2);
279279
280280 // adapted from:
281281 // 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 {
511511fn generic_fmod(comptime T: type, x: T, y: T) T {
512512 @setRuntimeSafety(false);
513513
514 const uint = std.meta.IntType(false, T.bit_count);
514 const uint = std.meta.Int(false, T.bit_count);
515515 const log2uint = math.Log2Int(uint);
516516 const digits = if (T == f32) 23 else 52;
517517 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 {
5454}
5555
5656// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
57fn 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));
57fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 {
58 const Z = std.meta.Int(false, T.bit_count);
59 const S = std.meta.Int(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
6060 const significandBits = std.math.floatMantissaBits(T);
6161 const implicitBit = @as(Z, 1) << significandBits;
6262
63 const shift = @clz(std.meta.IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit);
63 const shift = @clz(std.meta.Int(false, T.bit_count), significand.*) - @clz(Z, implicitBit);
6464 significand.* <<= @intCast(S, shift);
6565 return 1 - shift;
6666}
6767
6868// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
6969fn addXf3(comptime T: type, a: T, b: T) T {
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));
70 const Z = std.meta.Int(false, T.bit_count);
71 const S = std.meta.Int(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
7272
7373 const typeWidth = T.bit_count;
7474 const significandBits = std.math.floatMantissaBits(T);
......@@ -182,7 +182,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {
182182 // If partial cancellation occured, we need to left-shift the result
183183 // and adjust the exponent:
184184 if (aSignificand < implicitBit << 3) {
185 const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.IntType(false, T.bit_count), implicitBit << 3));
185 const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.Int(false, T.bit_count), implicitBit << 3));
186186 aSignificand <<= @intCast(S, shift);
187187 aExponent -= shift;
188188 }
lib/std/special/compiler_rt/compareXf2.zig+3-3
......@@ -22,8 +22,8 @@ const GE = extern enum(i32) {
2222pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
2323 @setRuntimeSafety(builtin.is_test);
2424
25 const srep_t = std.meta.IntType(true, T.bit_count);
26 const rep_t = std.meta.IntType(false, T.bit_count);
25 const srep_t = std.meta.Int(true, T.bit_count);
26 const rep_t = std.meta.Int(false, T.bit_count);
2727
2828 const significandBits = std.math.floatMantissaBits(T);
2929 const exponentBits = std.math.floatExponentBits(T);
......@@ -68,7 +68,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
6868pub fn unordcmp(comptime T: type, a: T, b: T) i32 {
6969 @setRuntimeSafety(builtin.is_test);
7070
71 const rep_t = std.meta.IntType(false, T.bit_count);
71 const rep_t = std.meta.Int(false, T.bit_count);
7272
7373 const significandBits = std.math.floatMantissaBits(T);
7474 const exponentBits = std.math.floatExponentBits(T);
lib/std/special/compiler_rt/divdf3.zig+4-4
......@@ -7,8 +7,8 @@ const builtin = @import("builtin");
77
88pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
99 @setRuntimeSafety(builtin.is_test);
10 const Z = std.meta.IntType(false, f64.bit_count);
11 const SignedZ = std.meta.IntType(true, f64.bit_count);
10 const Z = std.meta.Int(false, f64.bit_count);
11 const SignedZ = std.meta.Int(true, f64.bit_count);
1212
1313 const typeWidth = f64.bit_count;
1414 const significandBits = std.math.floatMantissaBits(f64);
......@@ -312,9 +312,9 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
312312 }
313313}
314314
315pub fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
315pub fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 {
316316 @setRuntimeSafety(builtin.is_test);
317 const Z = std.meta.IntType(false, T.bit_count);
317 const Z = std.meta.Int(false, T.bit_count);
318318 const significandBits = std.math.floatMantissaBits(T);
319319 const implicitBit = @as(Z, 1) << significandBits;
320320
lib/std/special/compiler_rt/divsf3.zig+3-3
......@@ -7,7 +7,7 @@ const builtin = @import("builtin");
77
88pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
99 @setRuntimeSafety(builtin.is_test);
10 const Z = std.meta.IntType(false, f32.bit_count);
10 const Z = std.meta.Int(false, f32.bit_count);
1111
1212 const typeWidth = f32.bit_count;
1313 const significandBits = std.math.floatMantissaBits(f32);
......@@ -185,9 +185,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
185185 }
186186}
187187
188fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
188fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 {
189189 @setRuntimeSafety(builtin.is_test);
190 const Z = std.meta.IntType(false, T.bit_count);
190 const Z = std.meta.Int(false, T.bit_count);
191191 const significandBits = std.math.floatMantissaBits(T);
192192 const implicitBit = @as(Z, 1) << significandBits;
193193
lib/std/special/compiler_rt/divtf3.zig+2-2
......@@ -6,8 +6,8 @@ const wideMultiply = @import("divdf3.zig").wideMultiply;
66
77pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
88 @setRuntimeSafety(builtin.is_test);
9 const Z = std.meta.IntType(false, f128.bit_count);
10 const SignedZ = std.meta.IntType(true, f128.bit_count);
9 const Z = std.meta.Int(false, f128.bit_count);
10 const SignedZ = std.meta.Int(true, f128.bit_count);
1111
1212 const typeWidth = f128.bit_count;
1313 const significandBits = std.math.floatMantissaBits(f128);
lib/std/special/compiler_rt/extendXfYf2.zig+3-3
......@@ -30,11 +30,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 {
3030
3131const CHAR_BIT = 8;
3232
33fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
33fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(false, @typeInfo(src_t).Float.bits)) dst_t {
3434 @setRuntimeSafety(builtin.is_test);
3535
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);
36 const src_rep_t = std.meta.Int(false, @typeInfo(src_t).Float.bits);
37 const dst_rep_t = std.meta.Int(false, @typeInfo(dst_t).Float.bits);
3838 const srcSigBits = std.math.floatMantissaBits(src_t);
3939 const dstSigBits = std.math.floatMantissaBits(dst_t);
4040 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 {
4545 if (exponent < 0) return 0;
4646
4747 // The unsigned result needs to be large enough to handle an fixint_t or rep_t
48 const fixuint_t = std.meta.IntType(false, fixint_t.bit_count);
48 const fixuint_t = std.meta.Int(false, fixint_t.bit_count);
4949 const UintResultType = if (fixint_t.bit_count > rep_t.bit_count) fixuint_t else rep_t;
5050 var uint_result: UintResultType = undefined;
5151
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
1010 f128 => u128,
1111 else => unreachable,
1212 };
13 const srep_t = @import("std").meta.IntType(true, rep_t.bit_count);
13 const srep_t = @import("std").meta.Int(true, rep_t.bit_count);
1414 const significandBits = switch (fp_t) {
1515 f32 => 23,
1616 f64 => 52,
lib/std/special/compiler_rt/floatsiXf.zig+2-2
......@@ -5,8 +5,8 @@ const maxInt = std.math.maxInt;
55fn floatsiXf(comptime T: type, a: i32) T {
66 @setRuntimeSafety(builtin.is_test);
77
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));
8 const Z = std.meta.Int(false, T.bit_count);
9 const S = std.meta.Int(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
1010
1111 if (a == 0) {
1212 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 {
2828
2929fn mulXf3(comptime T: type, a: T, b: T) T {
3030 @setRuntimeSafety(builtin.is_test);
31 const Z = std.meta.IntType(false, T.bit_count);
31 const Z = std.meta.Int(false, T.bit_count);
3232
3333 const typeWidth = T.bit_count;
3434 const significandBits = std.math.floatMantissaBits(T);
......@@ -264,9 +264,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
264264 }
265265}
266266
267fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
267fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 {
268268 @setRuntimeSafety(builtin.is_test);
269 const Z = std.meta.IntType(false, T.bit_count);
269 const Z = std.meta.Int(false, T.bit_count);
270270 const significandBits = std.math.floatMantissaBits(T);
271271 const implicitBit = @as(Z, 1) << significandBits;
272272
lib/std/special/compiler_rt/negXf2.zig+1-1
......@@ -19,7 +19,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 {
1919}
2020
2121fn negXf2(comptime T: type, a: T) T {
22 const Z = std.meta.IntType(false, T.bit_count);
22 const Z = std.meta.Int(false, T.bit_count);
2323
2424 const typeWidth = T.bit_count;
2525 const significandBits = std.math.floatMantissaBits(T);
lib/std/special/compiler_rt/shift.zig+2-2
......@@ -4,8 +4,8 @@ const Log2Int = std.math.Log2Int;
44
55fn Dwords(comptime T: type, comptime signed_half: bool) type {
66 return extern union {
7 pub const HalfTU = std.meta.IntType(false, @divExact(T.bit_count, 2));
8 pub const HalfTS = std.meta.IntType(true, @divExact(T.bit_count, 2));
7 pub const HalfTU = std.meta.Int(false, @divExact(T.bit_count, 2));
8 pub const HalfTS = std.meta.Int(true, @divExact(T.bit_count, 2));
99 pub const HalfT = if (signed_half) HalfTS else HalfTU;
1010
1111 all: T,
lib/std/special/compiler_rt/truncXfYf2.zig+2-2
......@@ -36,8 +36,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
3636}
3737
3838fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
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);
39 const src_rep_t = std.meta.Int(false, @typeInfo(src_t).Float.bits);
40 const dst_rep_t = std.meta.Int(false, @typeInfo(dst_t).Float.bits);
4141 const srcSigBits = std.math.floatMantissaBits(src_t);
4242 const dstSigBits = std.math.floatMantissaBits(dst_t);
4343 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;
1010pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt {
1111 @setRuntimeSafety(is_test);
1212
13 const SingleInt = @import("std").meta.IntType(false, @divExact(DoubleInt.bit_count, 2));
14 const SignedDoubleInt = @import("std").meta.IntType(true, DoubleInt.bit_count);
13 const SingleInt = @import("std").meta.Int(false, @divExact(DoubleInt.bit_count, 2));
14 const SignedDoubleInt = @import("std").meta.Int(true, DoubleInt.bit_count);
1515 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
1616
1717 const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421
lib/std/target.zig+1-1
......@@ -459,7 +459,7 @@ pub const Target = struct {
459459 pub const needed_bit_count = 155;
460460 pub const byte_count = (needed_bit_count + 7) / 8;
461461 pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);
462 pub const Index = std.math.Log2Int(std.meta.IntType(false, usize_count * @bitSizeOf(usize)));
462 pub const Index = std.math.Log2Int(std.meta.Int(false, usize_count * @bitSizeOf(usize)));
463463 pub const ShiftInt = std.math.Log2Int(usize);
464464
465465 pub const empty = Set{ .ints = [1]usize{0} ** usize_count };
test/stage1/behavior/bit_shifting.zig+2-2
......@@ -2,9 +2,9 @@ const std = @import("std");
22const expect = std.testing.expect;
33
44fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {
5 expect(Key == std.meta.IntType(false, Key.bit_count));
5 expect(Key == std.meta.Int(false, Key.bit_count));
66 expect(Key.bit_count >= mask_bit_count);
7 const ShardKey = std.meta.IntType(false, mask_bit_count);
7 const ShardKey = std.meta.Int(false, mask_bit_count);
88 const shift_amount = Key.bit_count - ShardKey.bit_count;
99 return struct {
1010 const Self = @This();