mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
stage1: rename TypeInfo.FnArg to Fn.Param
This commit is contained in:
parent
e5c30eef1f
commit
f8154905e7
3 changed files with 18 additions and 17 deletions
|
|
@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) {
|
||||||
decls: []const Declaration,
|
decls: []const Declaration,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This data structure is used by the Zig language code generation and
|
/// TODO deprecated use Fn.Param
|
||||||
/// therefore must be kept in sync with the compiler implementation.
|
pub const FnArg = Fn.Param;
|
||||||
/// TODO rename to Param and put inside `Fn`.
|
|
||||||
pub const FnArg = struct {
|
|
||||||
is_generic: bool,
|
|
||||||
is_noalias: bool,
|
|
||||||
arg_type: ?type,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// This data structure is used by the Zig language code generation and
|
/// This data structure is used by the Zig language code generation and
|
||||||
/// therefore must be kept in sync with the compiler implementation.
|
/// therefore must be kept in sync with the compiler implementation.
|
||||||
|
|
@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) {
|
||||||
is_generic: bool,
|
is_generic: bool,
|
||||||
is_var_args: bool,
|
is_var_args: bool,
|
||||||
return_type: ?type,
|
return_type: ?type,
|
||||||
args: []const FnArg,
|
args: []const Param,
|
||||||
|
|
||||||
|
/// This data structure is used by the Zig language code generation and
|
||||||
|
/// therefore must be kept in sync with the compiler implementation.
|
||||||
|
pub const Param = struct {
|
||||||
|
is_generic: bool,
|
||||||
|
is_noalias: bool,
|
||||||
|
arg_type: ?type,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This data structure is used by the Zig language code generation and
|
/// This data structure is used by the Zig language code generation and
|
||||||
|
|
|
||||||
|
|
@ -18750,8 +18750,8 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
|
||||||
return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
|
return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
|
||||||
fields[4]->data.x_optional = return_type;
|
fields[4]->data.x_optional = return_type;
|
||||||
}
|
}
|
||||||
// args: []TypeInfo.FnArg
|
// args: []TypeInfo.Fn.Param
|
||||||
ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
|
ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "Param", result->type);
|
||||||
if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {
|
if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {
|
||||||
zig_unreachable();
|
zig_unreachable();
|
||||||
}
|
}
|
||||||
|
|
@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
|
||||||
assert(args_arr->data.x_array.special == ConstArraySpecialNone);
|
assert(args_arr->data.x_array.special == ConstArraySpecialNone);
|
||||||
for (size_t i = 0; i < args_len; i++) {
|
for (size_t i = 0; i < args_len; i++) {
|
||||||
ZigValue *arg_value = &args_arr->data.x_array.data.s_none.elements[i];
|
ZigValue *arg_value = &args_arr->data.x_array.data.s_none.elements[i];
|
||||||
assert(arg_value->type == ir_type_info_get_type(ira, "FnArg", nullptr));
|
|
||||||
FnTypeParamInfo *info = &fn_type_id.param_info[i];
|
FnTypeParamInfo *info = &fn_type_id.param_info[i];
|
||||||
Error err;
|
Error err;
|
||||||
bool is_generic;
|
bool is_generic;
|
||||||
if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))
|
if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))
|
||||||
return ira->codegen->invalid_inst_gen->value->type;
|
return ira->codegen->invalid_inst_gen->value->type;
|
||||||
if (is_generic) {
|
if (is_generic) {
|
||||||
ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.is_generic must be false for @Type"));
|
ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.is_generic must be false for @Type"));
|
||||||
return ira->codegen->invalid_inst_gen->value->type;
|
return ira->codegen->invalid_inst_gen->value->type;
|
||||||
}
|
}
|
||||||
if ((err = get_const_field_bool(ira, source_node, arg_value, "is_noalias", 1, &info->is_noalias)))
|
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_
|
||||||
ZigType *type = get_const_field_meta_type_optional(
|
ZigType *type = get_const_field_meta_type_optional(
|
||||||
ira, source_node, arg_value, "arg_type", 2);
|
ira, source_node, arg_value, "arg_type", 2);
|
||||||
if (type == nullptr) {
|
if (type == nullptr) {
|
||||||
ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.arg_type must be non-null for @Type"));
|
ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.arg_type must be non-null for @Type"));
|
||||||
return ira->codegen->invalid_inst_gen->value->type;
|
return ira->codegen->invalid_inst_gen->value->type;
|
||||||
}
|
}
|
||||||
info->type = type;
|
info->type = type;
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||||
\\ .is_generic = true,
|
\\ .is_generic = true,
|
||||||
\\ .is_var_args = false,
|
\\ .is_var_args = false,
|
||||||
\\ .return_type = u0,
|
\\ .return_type = u0,
|
||||||
\\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
|
\\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
|
||||||
\\ },
|
\\ },
|
||||||
\\});
|
\\});
|
||||||
\\comptime { _ = Foo; }
|
\\comptime { _ = Foo; }
|
||||||
|
|
@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||||
\\ .is_generic = false,
|
\\ .is_generic = false,
|
||||||
\\ .is_var_args = true,
|
\\ .is_var_args = true,
|
||||||
\\ .return_type = u0,
|
\\ .return_type = u0,
|
||||||
\\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
|
\\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
|
||||||
\\ },
|
\\ },
|
||||||
\\});
|
\\});
|
||||||
\\comptime { _ = Foo; }
|
\\comptime { _ = Foo; }
|
||||||
|
|
@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||||
\\ .is_generic = false,
|
\\ .is_generic = false,
|
||||||
\\ .is_var_args = false,
|
\\ .is_var_args = false,
|
||||||
\\ .return_type = null,
|
\\ .return_type = null,
|
||||||
\\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
|
\\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
|
||||||
\\ },
|
\\ },
|
||||||
\\});
|
\\});
|
||||||
\\comptime { _ = Foo; }
|
\\comptime { _ = Foo; }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue