authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-22 13:22:40+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-23 09:44:36+02:00
logf8154905e7798aa0e884aa55e9336531f8c2daba
tree0e8f521c21031f09aa3dfca291af08a01f858da9
parente5c30eef1f338ed65325ddbfd4d631baef0d9b81

stage1: rename TypeInfo.FnArg to Fn.Param


3 files changed, 18 insertions(+), 17 deletions(-)

lib/std/builtin.zig+11-9
...@@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) {...@@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) {
346 decls: []const Declaration,346 decls: []const Declaration,
347 };347 };
348348
349 /// This data structure is used by the Zig language code generation and349 /// TODO deprecated use Fn.Param
350 /// therefore must be kept in sync with the compiler implementation.350 pub const FnArg = Fn.Param;
351 /// TODO rename to Param and put inside `Fn`.
352 pub const FnArg = struct {
353 is_generic: bool,
354 is_noalias: bool,
355 arg_type: ?type,
356 };
357351
358 /// This data structure is used by the Zig language code generation and352 /// This data structure is used by the Zig language code generation and
359 /// therefore must be kept in sync with the compiler implementation.353 /// therefore must be kept in sync with the compiler implementation.
...@@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) {...@@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) {
363 is_generic: bool,357 is_generic: bool,
364 is_var_args: bool,358 is_var_args: bool,
365 return_type: ?type,359 return_type: ?type,
366 args: []const FnArg,360 args: []const Param,
361
362 /// This data structure is used by the Zig language code generation and
363 /// therefore must be kept in sync with the compiler implementation.
364 pub const Param = struct {
365 is_generic: bool,
366 is_noalias: bool,
367 arg_type: ?type,
368 };
367 };369 };
368370
369 /// This data structure is used by the Zig language code generation and371 /// This data structure is used by the Zig language code generation and
src/stage1/ir.cpp+4-5
...@@ -18750,8 +18750,8 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour...@@ -18750,8 +18750,8 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
18750 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;18750 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
18751 fields[4]->data.x_optional = return_type;18751 fields[4]->data.x_optional = return_type;
18752 }18752 }
18753 // args: []TypeInfo.FnArg18753 // args: []TypeInfo.Fn.Param
18754 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);18754 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "Param", result->type);
18755 if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {18755 if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {
18756 zig_unreachable();18756 zig_unreachable();
18757 }18757 }
...@@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_...@@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
19614 assert(args_arr->data.x_array.special == ConstArraySpecialNone);19614 assert(args_arr->data.x_array.special == ConstArraySpecialNone);
19615 for (size_t i = 0; i < args_len; i++) {19615 for (size_t i = 0; i < args_len; i++) {
19616 ZigValue *arg_value = &args_arr->data.x_array.data.s_none.elements[i];19616 ZigValue *arg_value = &args_arr->data.x_array.data.s_none.elements[i];
19617 assert(arg_value->type == ir_type_info_get_type(ira, "FnArg", nullptr));
19618 FnTypeParamInfo *info = &fn_type_id.param_info[i];19617 FnTypeParamInfo *info = &fn_type_id.param_info[i];
19619 Error err;19618 Error err;
19620 bool is_generic;19619 bool is_generic;
19621 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))19620 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))
19622 return ira->codegen->invalid_inst_gen->value->type;19621 return ira->codegen->invalid_inst_gen->value->type;
19623 if (is_generic) {19622 if (is_generic) {
19624 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.is_generic must be false for @Type"));19623 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.is_generic must be false for @Type"));
19625 return ira->codegen->invalid_inst_gen->value->type;19624 return ira->codegen->invalid_inst_gen->value->type;
19626 }19625 }
19627 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_noalias", 1, &info->is_noalias)))19626 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_noalias", 1, &info->is_noalias)))
...@@ -19629,7 +19628,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_...@@ -19629,7 +19628,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
19629 ZigType *type = get_const_field_meta_type_optional(19628 ZigType *type = get_const_field_meta_type_optional(
19630 ira, source_node, arg_value, "arg_type", 2);19629 ira, source_node, arg_value, "arg_type", 2);
19631 if (type == nullptr) {19630 if (type == nullptr) {
19632 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.arg_type must be non-null for @Type"));19631 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.arg_type must be non-null for @Type"));
19633 return ira->codegen->invalid_inst_gen->value->type;19632 return ira->codegen->invalid_inst_gen->value->type;
19634 }19633 }
19635 info->type = type;19634 info->type = type;
test/compile_errors.zig+3-3
...@@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void {
450 \\ .is_generic = true,450 \\ .is_generic = true,
451 \\ .is_var_args = false,451 \\ .is_var_args = false,
452 \\ .return_type = u0,452 \\ .return_type = u0,
453 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},453 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
454 \\ },454 \\ },
455 \\});455 \\});
456 \\comptime { _ = Foo; }456 \\comptime { _ = Foo; }
...@@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void {
466 \\ .is_generic = false,466 \\ .is_generic = false,
467 \\ .is_var_args = true,467 \\ .is_var_args = true,
468 \\ .return_type = u0,468 \\ .return_type = u0,
469 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},469 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
470 \\ },470 \\ },
471 \\});471 \\});
472 \\comptime { _ = Foo; }472 \\comptime { _ = Foo; }
...@@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void {
482 \\ .is_generic = false,482 \\ .is_generic = false,
483 \\ .is_var_args = false,483 \\ .is_var_args = false,
484 \\ .return_type = null,484 \\ .return_type = null,
485 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},485 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
486 \\ },486 \\ },
487 \\});487 \\});
488 \\comptime { _ = Foo; }488 \\comptime { _ = Foo; }