authorgravatar for sahnvour@pm.meSahnvour <sahnvour@pm.me> 2019-03-02 18:12:56+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-02 14:27:37-05:00
log4bac22e88898158fc49e69db5bbe26a324797d68
tree82c9845d2f113594f359339548bf949823413711
parent67b4de33d2729fdb21337e5a0e05f6273bce23ba

all integers returned by @typeInfo are now comptime_int


4 files changed, 25 insertions(+), 25 deletions(-)

doc/langref.html.in+7-7
......@@ -6827,18 +6827,18 @@ pub const TypeInfo = union(TypeId) {
68276827
68286828 pub const Int = struct {
68296829 is_signed: bool,
6830 bits: u8,
6830 bits: comptime_int,
68316831 };
68326832
68336833 pub const Float = struct {
6834 bits: u8,
6834 bits: comptime_int,
68356835 };
68366836
68376837 pub const Pointer = struct {
68386838 size: Size,
68396839 is_const: bool,
68406840 is_volatile: bool,
6841 alignment: u32,
6841 alignment: comptime_int,
68426842 child: type,
68436843
68446844 pub const Size = enum {
......@@ -6849,7 +6849,7 @@ pub const TypeInfo = union(TypeId) {
68496849 };
68506850
68516851 pub const Array = struct {
6852 len: usize,
6852 len: comptime_int,
68536853 child: type,
68546854 };
68556855
......@@ -6861,7 +6861,7 @@ pub const TypeInfo = union(TypeId) {
68616861
68626862 pub const StructField = struct {
68636863 name: []const u8,
6864 offset: ?usize,
6864 offset: ?comptime_int,
68656865 field_type: type,
68666866 };
68676867
......@@ -6882,7 +6882,7 @@ pub const TypeInfo = union(TypeId) {
68826882
68836883 pub const Error = struct {
68846884 name: []const u8,
6885 value: usize,
6885 value: comptime_int,
68866886 };
68876887
68886888 pub const ErrorSet = struct {
......@@ -6891,7 +6891,7 @@ pub const TypeInfo = union(TypeId) {
68916891
68926892 pub const EnumField = struct {
68936893 name: []const u8,
6894 value: usize,
6894 value: comptime_int,
68956895 };
68966896
68976897 pub const Enum = struct {
src/codegen.cpp+8-8
......@@ -7492,18 +7492,18 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
74927492 "\n\n"
74937493 " pub const Int = struct {\n"
74947494 " is_signed: bool,\n"
7495 " bits: u8,\n"
7495 " bits: comptime_int,\n"
74967496 " };\n"
74977497 "\n"
74987498 " pub const Float = struct {\n"
7499 " bits: u8,\n"
7499 " bits: comptime_int,\n"
75007500 " };\n"
75017501 "\n"
75027502 " pub const Pointer = struct {\n"
75037503 " size: Size,\n"
75047504 " is_const: bool,\n"
75057505 " is_volatile: bool,\n"
7506 " alignment: u32,\n"
7506 " alignment: comptime_int,\n"
75077507 " child: type,\n"
75087508 "\n"
75097509 " pub const Size = enum {\n"
......@@ -7515,7 +7515,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
75157515 " };\n"
75167516 "\n"
75177517 " pub const Array = struct {\n"
7518 " len: usize,\n"
7518 " len: comptime_int,\n"
75197519 " child: type,\n"
75207520 " };\n"
75217521 "\n"
......@@ -7527,7 +7527,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
75277527 "\n"
75287528 " pub const StructField = struct {\n"
75297529 " name: []const u8,\n"
7530 " offset: ?usize,\n"
7530 " offset: ?comptime_int,\n"
75317531 " field_type: type,\n"
75327532 " };\n"
75337533 "\n"
......@@ -7548,7 +7548,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
75487548 "\n"
75497549 " pub const Error = struct {\n"
75507550 " name: []const u8,\n"
7551 " value: usize,\n"
7551 " value: comptime_int,\n"
75527552 " };\n"
75537553 "\n"
75547554 " pub const ErrorSet = struct {\n"
......@@ -7557,7 +7557,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
75577557 "\n"
75587558 " pub const EnumField = struct {\n"
75597559 " name: []const u8,\n"
7560 " value: usize,\n"
7560 " value: comptime_int,\n"
75617561 " };\n"
75627562 "\n"
75637563 " pub const Enum = struct {\n"
......@@ -7609,7 +7609,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
76097609 " };\n"
76107610 "\n"
76117611 " pub const Vector = struct {\n"
7612 " len: u32,\n"
7612 " len: comptime_int,\n"
76137613 " child: type,\n"
76147614 " };\n"
76157615 "\n"
src/ir.cpp+8-8
......@@ -17997,7 +17997,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty
1799717997 // alignment: u32
1799817998 ensure_field_index(result->type, "alignment", 3);
1799917999 fields[3].special = ConstValSpecialStatic;
18000 fields[3].type = get_int_type(ira->codegen, false, 29);
18000 fields[3].type = ira->codegen->builtin_types.entry_num_lit_int;
1800118001 bigint_init_unsigned(&fields[3].data.x_bigint, get_ptr_align(ira->codegen, attrs_type));
1800218002 // child: type
1800318003 ensure_field_index(result->type, "child", 4);
......@@ -18016,7 +18016,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val,
1801618016
1801718017 ConstExprValue *inner_fields = create_const_vals(2);
1801818018 inner_fields[1].special = ConstValSpecialStatic;
18019 inner_fields[1].type = ira->codegen->builtin_types.entry_usize;
18019 inner_fields[1].type = ira->codegen->builtin_types.entry_num_lit_int;
1802018020
1802118021 ConstExprValue *name = create_const_str_lit(ira->codegen, enum_field->name);
1802218022 init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(enum_field->name), true);
......@@ -18080,7 +18080,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
1808018080 // bits: u8
1808118081 ensure_field_index(result->type, "bits", 1);
1808218082 fields[1].special = ConstValSpecialStatic;
18083 fields[1].type = ira->codegen->builtin_types.entry_u8;
18083 fields[1].type = ira->codegen->builtin_types.entry_num_lit_int;
1808418084 bigint_init_unsigned(&fields[1].data.x_bigint, type_entry->data.integral.bit_count);
1808518085
1808618086 break;
......@@ -18097,7 +18097,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
1809718097 // bits: u8
1809818098 ensure_field_index(result->type, "bits", 0);
1809918099 fields[0].special = ConstValSpecialStatic;
18100 fields[0].type = ira->codegen->builtin_types.entry_u8;
18100 fields[0].type = ira->codegen->builtin_types.entry_num_lit_int;
1810118101 bigint_init_unsigned(&fields->data.x_bigint, type_entry->data.floating.bit_count);
1810218102
1810318103 break;
......@@ -18121,7 +18121,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
1812118121 // len: usize
1812218122 ensure_field_index(result->type, "len", 0);
1812318123 fields[0].special = ConstValSpecialStatic;
18124 fields[0].type = ira->codegen->builtin_types.entry_usize;
18124 fields[0].type = ira->codegen->builtin_types.entry_num_lit_int;
1812518125 bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.array.len);
1812618126 // child: type
1812718127 ensure_field_index(result->type, "child", 1);
......@@ -18142,7 +18142,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
1814218142 // len: usize
1814318143 ensure_field_index(result->type, "len", 0);
1814418144 fields[0].special = ConstValSpecialStatic;
18145 fields[0].type = ira->codegen->builtin_types.entry_u32;
18145 fields[0].type = ira->codegen->builtin_types.entry_num_lit_int;
1814618146 bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.vector.len);
1814718147 // child: type
1814818148 ensure_field_index(result->type, "child", 1);
......@@ -18286,7 +18286,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
1828618286
1828718287 ConstExprValue *inner_fields = create_const_vals(2);
1828818288 inner_fields[1].special = ConstValSpecialStatic;
18289 inner_fields[1].type = ira->codegen->builtin_types.entry_usize;
18289 inner_fields[1].type = ira->codegen->builtin_types.entry_num_lit_int;
1829018290
1829118291 ConstExprValue *name = nullptr;
1829218292 if (error->cached_error_name_val != nullptr)
......@@ -18458,7 +18458,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
1845818458
1845918459 ConstExprValue *inner_fields = create_const_vals(3);
1846018460 inner_fields[1].special = ConstValSpecialStatic;
18461 inner_fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_usize);
18461 inner_fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int);
1846218462
1846318463 if (!type_has_bits(struct_field->type_entry)) {
1846418464 inner_fields[1].data.x_optional = nullptr;
std/math/index.zig+2-2
......@@ -738,14 +738,14 @@ test "math.f64_min" {
738738
739739pub fn maxInt(comptime T: type) comptime_int {
740740 const info = @typeInfo(T);
741 const bit_count = comptime_int(info.Int.bits); // TODO #1683
741 const bit_count = info.Int.bits;
742742 if (bit_count == 0) return 0;
743743 return (1 << (bit_count - @boolToInt(info.Int.is_signed))) - 1;
744744}
745745
746746pub fn minInt(comptime T: type) comptime_int {
747747 const info = @typeInfo(T);
748 const bit_count = comptime_int(info.Int.bits); // TODO #1683
748 const bit_count = info.Int.bits;
749749 if (!info.Int.is_signed) return 0;
750750 if (bit_count == 0) return 0;
751751 return -(1 << (bit_count - 1));