diff --git a/doc/langref.md b/doc/langref.md index 122c62a23d..c202925ae3 100644 --- a/doc/langref.md +++ b/doc/langref.md @@ -584,7 +584,7 @@ to stderr, and then a newline at the end. This function can be used to do "printf debugging" on compile-time executing code. -### @intType(comptime is_signed: bool, comptime bit_count: u8) -> type +### @IntType(comptime is_signed: bool, comptime bit_count: u8) -> type This function returns an integer type with the given signness and bit count. diff --git a/src/codegen.cpp b/src/codegen.cpp index 38e0b37250..7222cd3fc8 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -4500,7 +4500,7 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdTruncate, "truncate", 2); create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1); create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX); - create_builtin_fn(g, BuiltinFnIdIntType, "intType", 2); + create_builtin_fn(g, BuiltinFnIdIntType, "IntType", 2); create_builtin_fn(g, BuiltinFnIdSetDebugSafety, "setDebugSafety", 2); create_builtin_fn(g, BuiltinFnIdSetGlobalAlign, "setGlobalAlign", 2); create_builtin_fn(g, BuiltinFnIdSetGlobalSection, "setGlobalSection", 2); diff --git a/src/ir_print.cpp b/src/ir_print.cpp index e16e795c4d..7670dfa09e 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -602,7 +602,7 @@ static void ir_print_truncate(IrPrint *irp, IrInstructionTruncate *instruction) } static void ir_print_int_type(IrPrint *irp, IrInstructionIntType *instruction) { - fprintf(irp->f, "@intType("); + fprintf(irp->f, "@IntType("); ir_print_other_instruction(irp, instruction->is_signed); fprintf(irp->f, ", "); ir_print_other_instruction(irp, instruction->bit_count); diff --git a/std/fmt.zig b/std/fmt.zig index 19c6e16cf1..5c7bd077c3 100644 --- a/std/fmt.zig +++ b/std/fmt.zig @@ -222,7 +222,7 @@ pub fn formatInt(value: var, base: u8, uppercase: bool, width: usize, fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize, context: var, output: fn(@typeOf(context), []const u8)->bool) -> bool { - const uint = @intType(false, @typeOf(value).bit_count); + const uint = @IntType(false, @typeOf(value).bit_count); if (value < 0) { const minus_sign: u8 = '-'; if (!output(context, (&minus_sign)[0...1])) diff --git a/std/math.zig b/std/math.zig index c526ba4505..c51e45ca4f 100644 --- a/std/math.zig +++ b/std/math.zig @@ -62,7 +62,7 @@ pub fn abs(x: var) -> @typeOf(x) { } fn getReturnTypeForAbs(comptime T: type) -> type { if (@isInteger(T)) { - return @intType(false, T.bit_count); + return @IntType(false, T.bit_count); } else { return T; } diff --git a/std/mem.zig b/std/mem.zig index 7c9cf5db8a..e5b05071e9 100644 --- a/std/mem.zig +++ b/std/mem.zig @@ -167,7 +167,7 @@ pub fn readInt(bytes: []const u8, comptime T: type, big_endian: bool) -> T { /// to fill the entire buffer provided. /// value must be an integer. pub fn writeInt(buf: []u8, value: var, big_endian: bool) { - const uint = @intType(false, @typeOf(value).bit_count); + const uint = @IntType(false, @typeOf(value).bit_count); var bits = @truncate(uint, value); if (big_endian) { var index: usize = buf.len; diff --git a/std/os/child_process.zig b/std/os/child_process.zig index f3d9a112e3..7dd02635d8 100644 --- a/std/os/child_process.zig +++ b/std/os/child_process.zig @@ -229,7 +229,7 @@ fn forkChildErrReport(fd: i32, err: error) -> noreturn { posix.exit(1); } -const ErrInt = @intType(false, @sizeOf(error) * 8); +const ErrInt = @IntType(false, @sizeOf(error) * 8); fn writeIntFd(fd: i32, value: ErrInt) -> %void { var bytes: [@sizeOf(ErrInt)]u8 = undefined; mem.writeInt(bytes[0...], value, true); diff --git a/std/rand.zig b/std/rand.zig index dab451b725..35f9ac9423 100644 --- a/std/rand.zig +++ b/std/rand.zig @@ -84,7 +84,7 @@ pub const Rand = struct { // const mask = ((1 << @float_mantissa_bit_count(T)) - 1); // const rand_bits = r.rng.scalar(int) & mask; // return @float_compose(T, false, 0, rand_bits) - 1.0 - const int_type = @intType(false, @sizeOf(T) * 8); + const int_type = @IntType(false, @sizeOf(T) * 8); const precision = if (T == f32) { 16777216 } else if (T == f64) { diff --git a/test/cases/math.zig b/test/cases/math.zig index 3d5af7dca5..c5636350ab 100644 --- a/test/cases/math.zig +++ b/test/cases/math.zig @@ -152,7 +152,7 @@ fn testBinaryNot(x: u16) { } test "smallIntAddition" { - var x: @intType(false, 2) = 0; + var x: @IntType(false, 2) = 0; assert(x == 0); x += 1; diff --git a/test/cases/misc.zig b/test/cases/misc.zig index 6a1881fb70..4bcd59e1f5 100644 --- a/test/cases/misc.zig +++ b/test/cases/misc.zig @@ -19,16 +19,16 @@ test "callDisabledExternFn" { disabledExternFn(); } -test "intTypeBuiltin" { - assert(@intType(true, 8) == i8); - assert(@intType(true, 16) == i16); - assert(@intType(true, 32) == i32); - assert(@intType(true, 64) == i64); +test "@IntType builtin" { + assert(@IntType(true, 8) == i8); + assert(@IntType(true, 16) == i16); + assert(@IntType(true, 32) == i32); + assert(@IntType(true, 64) == i64); - assert(@intType(false, 8) == u8); - assert(@intType(false, 16) == u16); - assert(@intType(false, 32) == u32); - assert(@intType(false, 64) == u64); + assert(@IntType(false, 8) == u8); + assert(@IntType(false, 16) == u16); + assert(@IntType(false, 32) == u32); + assert(@IntType(false, 64) == u64); assert(i8.bit_count == 8); assert(i16.bit_count == 16); @@ -48,10 +48,10 @@ test "intTypeBuiltin" { assert(!usize.is_signed); } -const u1 = @intType(false, 1); -const u63 = @intType(false, 63); -const i1 = @intType(true, 1); -const i63 = @intType(true, 63); +const u1 = @IntType(false, 1); +const u63 = @IntType(false, 63); +const i1 = @IntType(true, 1); +const i63 = @IntType(true, 63); test "minValueAndMaxValue" { assert(@maxValue(u1) == 1); diff --git a/test/cases/struct.zig b/test/cases/struct.zig index 96e7e7e49f..99039df654 100644 --- a/test/cases/struct.zig +++ b/test/cases/struct.zig @@ -201,8 +201,8 @@ test "packedStruct" { } -const u2 = @intType(false, 2); -const u3 = @intType(false, 3); +const u2 = @IntType(false, 2); +const u3 = @IntType(false, 3); const BitField1 = packed struct { a: u3, @@ -243,7 +243,7 @@ fn getC(data: &const BitField1) -> u2 { return data.c; } -const u24 = @intType(false, 24); +const u24 = @IntType(false, 24); const Foo24Bits = packed struct { field: u24, }; @@ -374,7 +374,7 @@ test "runtime struct initialization of bitfield" { assert(s2.y == u4(x2)); } -const u4 = @intType(false, 4); +const u4 = @IntType(false, 4); var x1 = u4(1); var x2 = u8(2); diff --git a/test/run_tests.cpp b/test/run_tests.cpp index c509966347..f928b05e87 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1736,8 +1736,8 @@ fn bar(a: i32, b: []const u8) { ".tmp_source.zig:3:17: note: called from here"); add_compile_fail_case("casting bit offset pointer to regular pointer", R"SOURCE( -const u2 = @intType(false, 2); -const u3 = @intType(false, 3); +const u2 = @IntType(false, 2); +const u3 = @IntType(false, 3); const BitField = packed struct { a: u3, @@ -1869,7 +1869,7 @@ export fn entry(a: &i32) -> usize { add_compile_fail_case("too many error values to cast to small integer", R"SOURCE( error A; error B; error C; error D; error E; error F; error G; error H; -const u2 = @intType(false, 2); +const u2 = @IntType(false, 2); fn foo(e: error) -> u2 { return u2(e); }