authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-18 00:05:09-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-18 00:05:09-04:00
log407916cd2f3f4931de29fd87b8c9ae3faeba8452
tree5ee194f80ce127d81e220869cd56bb53c1c04f17
parentdef4fbc9ab704b1add5c3af40692b3d26594e58e

rename `@intType` to `@IntType` to follow convention

closes #327

12 files changed, 29 insertions(+), 29 deletions(-)

doc/langref.md+1-1
...@@ -584,7 +584,7 @@ to stderr, and then a newline at the end....@@ -584,7 +584,7 @@ to stderr, and then a newline at the end.
584This function can be used to do "printf debugging" on compile-time executing584This function can be used to do "printf debugging" on compile-time executing
585code.585code.
586586
587### @intType(comptime is_signed: bool, comptime bit_count: u8) -> type587### @IntType(comptime is_signed: bool, comptime bit_count: u8) -> type
588588
589This function returns an integer type with the given signness and bit count.589This function returns an integer type with the given signness and bit count.
590590
src/codegen.cpp+1-1
...@@ -4500,7 +4500,7 @@ static void define_builtin_fns(CodeGen *g) {...@@ -4500,7 +4500,7 @@ static void define_builtin_fns(CodeGen *g) {
4500 create_builtin_fn(g, BuiltinFnIdTruncate, "truncate", 2);4500 create_builtin_fn(g, BuiltinFnIdTruncate, "truncate", 2);
4501 create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1);4501 create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1);
4502 create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX);4502 create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX);
4503 create_builtin_fn(g, BuiltinFnIdIntType, "intType", 2);4503 create_builtin_fn(g, BuiltinFnIdIntType, "IntType", 2);
4504 create_builtin_fn(g, BuiltinFnIdSetDebugSafety, "setDebugSafety", 2);4504 create_builtin_fn(g, BuiltinFnIdSetDebugSafety, "setDebugSafety", 2);
4505 create_builtin_fn(g, BuiltinFnIdSetGlobalAlign, "setGlobalAlign", 2);4505 create_builtin_fn(g, BuiltinFnIdSetGlobalAlign, "setGlobalAlign", 2);
4506 create_builtin_fn(g, BuiltinFnIdSetGlobalSection, "setGlobalSection", 2);4506 create_builtin_fn(g, BuiltinFnIdSetGlobalSection, "setGlobalSection", 2);
src/ir_print.cpp+1-1
...@@ -602,7 +602,7 @@ static void ir_print_truncate(IrPrint *irp, IrInstructionTruncate *instruction)...@@ -602,7 +602,7 @@ static void ir_print_truncate(IrPrint *irp, IrInstructionTruncate *instruction)
602}602}
603603
604static void ir_print_int_type(IrPrint *irp, IrInstructionIntType *instruction) {604static void ir_print_int_type(IrPrint *irp, IrInstructionIntType *instruction) {
605 fprintf(irp->f, "@intType(");605 fprintf(irp->f, "@IntType(");
606 ir_print_other_instruction(irp, instruction->is_signed);606 ir_print_other_instruction(irp, instruction->is_signed);
607 fprintf(irp->f, ", ");607 fprintf(irp->f, ", ");
608 ir_print_other_instruction(irp, instruction->bit_count);608 ir_print_other_instruction(irp, instruction->bit_count);
std/fmt.zig+1-1
...@@ -222,7 +222,7 @@ pub fn formatInt(value: var, base: u8, uppercase: bool, width: usize,...@@ -222,7 +222,7 @@ pub fn formatInt(value: var, base: u8, uppercase: bool, width: usize,
222fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize,222fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize,
223 context: var, output: fn(@typeOf(context), []const u8)->bool) -> bool223 context: var, output: fn(@typeOf(context), []const u8)->bool) -> bool
224{224{
225 const uint = @intType(false, @typeOf(value).bit_count);225 const uint = @IntType(false, @typeOf(value).bit_count);
226 if (value < 0) {226 if (value < 0) {
227 const minus_sign: u8 = '-';227 const minus_sign: u8 = '-';
228 if (!output(context, (&minus_sign)[0...1]))228 if (!output(context, (&minus_sign)[0...1]))
std/math.zig+1-1
...@@ -62,7 +62,7 @@ pub fn abs(x: var) -> @typeOf(x) {...@@ -62,7 +62,7 @@ pub fn abs(x: var) -> @typeOf(x) {
62}62}
63fn getReturnTypeForAbs(comptime T: type) -> type {63fn getReturnTypeForAbs(comptime T: type) -> type {
64 if (@isInteger(T)) {64 if (@isInteger(T)) {
65 return @intType(false, T.bit_count);65 return @IntType(false, T.bit_count);
66 } else {66 } else {
67 return T;67 return T;
68 }68 }
std/mem.zig+1-1
...@@ -167,7 +167,7 @@ pub fn readInt(bytes: []const u8, comptime T: type, big_endian: bool) -> T {...@@ -167,7 +167,7 @@ pub fn readInt(bytes: []const u8, comptime T: type, big_endian: bool) -> T {
167/// to fill the entire buffer provided.167/// to fill the entire buffer provided.
168/// value must be an integer.168/// value must be an integer.
169pub fn writeInt(buf: []u8, value: var, big_endian: bool) {169pub fn writeInt(buf: []u8, value: var, big_endian: bool) {
170 const uint = @intType(false, @typeOf(value).bit_count);170 const uint = @IntType(false, @typeOf(value).bit_count);
171 var bits = @truncate(uint, value);171 var bits = @truncate(uint, value);
172 if (big_endian) {172 if (big_endian) {
173 var index: usize = buf.len;173 var index: usize = buf.len;
std/os/child_process.zig+1-1
...@@ -229,7 +229,7 @@ fn forkChildErrReport(fd: i32, err: error) -> noreturn {...@@ -229,7 +229,7 @@ fn forkChildErrReport(fd: i32, err: error) -> noreturn {
229 posix.exit(1);229 posix.exit(1);
230}230}
231231
232const ErrInt = @intType(false, @sizeOf(error) * 8);232const ErrInt = @IntType(false, @sizeOf(error) * 8);
233fn writeIntFd(fd: i32, value: ErrInt) -> %void {233fn writeIntFd(fd: i32, value: ErrInt) -> %void {
234 var bytes: [@sizeOf(ErrInt)]u8 = undefined;234 var bytes: [@sizeOf(ErrInt)]u8 = undefined;
235 mem.writeInt(bytes[0...], value, true);235 mem.writeInt(bytes[0...], value, true);
std/rand.zig+1-1
...@@ -84,7 +84,7 @@ pub const Rand = struct {...@@ -84,7 +84,7 @@ pub const Rand = struct {
84 // const mask = ((1 << @float_mantissa_bit_count(T)) - 1);84 // const mask = ((1 << @float_mantissa_bit_count(T)) - 1);
85 // const rand_bits = r.rng.scalar(int) & mask;85 // const rand_bits = r.rng.scalar(int) & mask;
86 // return @float_compose(T, false, 0, rand_bits) - 1.086 // return @float_compose(T, false, 0, rand_bits) - 1.0
87 const int_type = @intType(false, @sizeOf(T) * 8);87 const int_type = @IntType(false, @sizeOf(T) * 8);
88 const precision = if (T == f32) {88 const precision = if (T == f32) {
89 1677721689 16777216
90 } else if (T == f64) {90 } else if (T == f64) {
test/cases/math.zig+1-1
...@@ -152,7 +152,7 @@ fn testBinaryNot(x: u16) {...@@ -152,7 +152,7 @@ fn testBinaryNot(x: u16) {
152}152}
153153
154test "smallIntAddition" {154test "smallIntAddition" {
155 var x: @intType(false, 2) = 0;155 var x: @IntType(false, 2) = 0;
156 assert(x == 0);156 assert(x == 0);
157157
158 x += 1;158 x += 1;
test/cases/misc.zig+13-13
...@@ -19,16 +19,16 @@ test "callDisabledExternFn" {...@@ -19,16 +19,16 @@ test "callDisabledExternFn" {
19 disabledExternFn();19 disabledExternFn();
20}20}
2121
22test "intTypeBuiltin" {22test "@IntType builtin" {
23 assert(@intType(true, 8) == i8);23 assert(@IntType(true, 8) == i8);
24 assert(@intType(true, 16) == i16);24 assert(@IntType(true, 16) == i16);
25 assert(@intType(true, 32) == i32);25 assert(@IntType(true, 32) == i32);
26 assert(@intType(true, 64) == i64);26 assert(@IntType(true, 64) == i64);
2727
28 assert(@intType(false, 8) == u8);28 assert(@IntType(false, 8) == u8);
29 assert(@intType(false, 16) == u16);29 assert(@IntType(false, 16) == u16);
30 assert(@intType(false, 32) == u32);30 assert(@IntType(false, 32) == u32);
31 assert(@intType(false, 64) == u64);31 assert(@IntType(false, 64) == u64);
3232
33 assert(i8.bit_count == 8);33 assert(i8.bit_count == 8);
34 assert(i16.bit_count == 16);34 assert(i16.bit_count == 16);
...@@ -48,10 +48,10 @@ test "intTypeBuiltin" {...@@ -48,10 +48,10 @@ test "intTypeBuiltin" {
48 assert(!usize.is_signed);48 assert(!usize.is_signed);
49}49}
5050
51const u1 = @intType(false, 1);51const u1 = @IntType(false, 1);
52const u63 = @intType(false, 63);52const u63 = @IntType(false, 63);
53const i1 = @intType(true, 1);53const i1 = @IntType(true, 1);
54const i63 = @intType(true, 63);54const i63 = @IntType(true, 63);
5555
56test "minValueAndMaxValue" {56test "minValueAndMaxValue" {
57 assert(@maxValue(u1) == 1);57 assert(@maxValue(u1) == 1);
test/cases/struct.zig+4-4
...@@ -201,8 +201,8 @@ test "packedStruct" {...@@ -201,8 +201,8 @@ test "packedStruct" {
201}201}
202202
203203
204const u2 = @intType(false, 2);204const u2 = @IntType(false, 2);
205const u3 = @intType(false, 3);205const u3 = @IntType(false, 3);
206206
207const BitField1 = packed struct {207const BitField1 = packed struct {
208 a: u3,208 a: u3,
...@@ -243,7 +243,7 @@ fn getC(data: &const BitField1) -> u2 {...@@ -243,7 +243,7 @@ fn getC(data: &const BitField1) -> u2 {
243 return data.c;243 return data.c;
244}244}
245245
246const u24 = @intType(false, 24);246const u24 = @IntType(false, 24);
247const Foo24Bits = packed struct {247const Foo24Bits = packed struct {
248 field: u24,248 field: u24,
249};249};
...@@ -374,7 +374,7 @@ test "runtime struct initialization of bitfield" {...@@ -374,7 +374,7 @@ test "runtime struct initialization of bitfield" {
374 assert(s2.y == u4(x2));374 assert(s2.y == u4(x2));
375}375}
376376
377const u4 = @intType(false, 4);377const u4 = @IntType(false, 4);
378378
379var x1 = u4(1);379var x1 = u4(1);
380var x2 = u8(2);380var x2 = u8(2);
test/run_tests.cpp+3-3
...@@ -1736,8 +1736,8 @@ fn bar(a: i32, b: []const u8) {...@@ -1736,8 +1736,8 @@ fn bar(a: i32, b: []const u8) {
1736 ".tmp_source.zig:3:17: note: called from here");1736 ".tmp_source.zig:3:17: note: called from here");
17371737
1738 add_compile_fail_case("casting bit offset pointer to regular pointer", R"SOURCE(1738 add_compile_fail_case("casting bit offset pointer to regular pointer", R"SOURCE(
1739const u2 = @intType(false, 2);1739const u2 = @IntType(false, 2);
1740const u3 = @intType(false, 3);1740const u3 = @IntType(false, 3);
17411741
1742const BitField = packed struct {1742const BitField = packed struct {
1743 a: u3,1743 a: u3,
...@@ -1869,7 +1869,7 @@ export fn entry(a: &i32) -> usize {...@@ -1869,7 +1869,7 @@ export fn entry(a: &i32) -> usize {
18691869
1870 add_compile_fail_case("too many error values to cast to small integer", R"SOURCE(1870 add_compile_fail_case("too many error values to cast to small integer", R"SOURCE(
1871error A; error B; error C; error D; error E; error F; error G; error H;1871error A; error B; error C; error D; error E; error F; error G; error H;
1872const u2 = @intType(false, 2);1872const u2 = @IntType(false, 2);
1873fn foo(e: error) -> u2 {1873fn foo(e: error) -> u2 {
1874 return u2(e);1874 return u2(e);
1875}1875}