mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Fix min type info for polymorphic procedures and named types
This commit is contained in:
+2
-2
@@ -69,8 +69,8 @@ quick_sort_proc :: proc(array: $A/[]$T, f: proc(T, T) -> int) {
|
|||||||
j -= 1;
|
j -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
quick_sort(a[0..i], f);
|
quick_sort_proc(a[0..i], f);
|
||||||
quick_sort(a[i..n], f);
|
quick_sort_proc(a[i..n], f);
|
||||||
}
|
}
|
||||||
|
|
||||||
quick_sort :: proc(array: $A/[]$T) {
|
quick_sort :: proc(array: $A/[]$T) {
|
||||||
|
|||||||
@@ -4709,6 +4709,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
||||||
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
||||||
add_entity_use(c, ident, entity_to_use);
|
add_entity_use(c, ident, entity_to_use);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -4719,10 +4720,12 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity *e = entity_of_ident(ident);
|
Entity *e = entity_of_ident(ident);
|
||||||
|
|
||||||
CallArgumentData data = {};
|
CallArgumentData data = {};
|
||||||
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
|
||||||
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
|
||||||
add_entity_use(c, ident, entity_to_use);
|
add_entity_use(c, ident, entity_to_use);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -903,7 +903,7 @@ void add_entity_use(CheckerContext *c, AstNode *identifier, Entity *entity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
entity->flags |= EntityFlag_Used;
|
entity->flags |= EntityFlag_Used;
|
||||||
add_declaration_dependency(c, entity); // TODO(bill): Should this be here?
|
add_declaration_dependency(c, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -958,10 +958,11 @@ void add_type_info_type(CheckerContext *c, Type *t) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_type_info_dependency(c->decl, t);
|
||||||
|
|
||||||
auto found = map_get(&c->info->type_info_map, hash_type(t));
|
auto found = map_get(&c->info->type_info_map, hash_type(t));
|
||||||
if (found != nullptr) {
|
if (found != nullptr) {
|
||||||
// Types have already been added
|
// Types have already been added
|
||||||
add_type_info_dependency(c->decl, t);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -987,7 +988,6 @@ void add_type_info_type(CheckerContext *c, Type *t) {
|
|||||||
|
|
||||||
if (prev) {
|
if (prev) {
|
||||||
// NOTE(bill): If a previous one exists already, no need to continue
|
// NOTE(bill): If a previous one exists already, no need to continue
|
||||||
add_type_info_dependency(c->decl, t);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1356,7 +1356,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
|
|||||||
Entity *e = c->info.definitions[i];
|
Entity *e = c->info.definitions[i];
|
||||||
// if (e->scope->is_global && !is_type_poly_proc(e->type)) { // TODO(bill): is the check enough?
|
// if (e->scope->is_global && !is_type_poly_proc(e->type)) { // TODO(bill): is the check enough?
|
||||||
if (e->scope == universal_scope) { // TODO(bill): is the check enough?
|
if (e->scope == universal_scope) { // TODO(bill): is the check enough?
|
||||||
if (e->type == nullptr || !is_type_poly_proc(e->type)) {
|
if (e->type == nullptr) {
|
||||||
add_dependency_to_set(c, e);
|
add_dependency_to_set(c, e);
|
||||||
}
|
}
|
||||||
} else if (e->kind == Entity_Procedure && e->Procedure.is_export) {
|
} else if (e->kind == Entity_Procedure && e->Procedure.is_export) {
|
||||||
@@ -3141,6 +3141,7 @@ void check_proc_info(Checker *c, ProcedureInfo pi) {
|
|||||||
CheckerContext ctx = make_checker_context(c);
|
CheckerContext ctx = make_checker_context(c);
|
||||||
defer (destroy_checker_context(&ctx));
|
defer (destroy_checker_context(&ctx));
|
||||||
add_curr_ast_file(&ctx, pi.file);
|
add_curr_ast_file(&ctx, pi.file);
|
||||||
|
ctx.decl = pi.decl;
|
||||||
|
|
||||||
TypeProc *pt = &pi.type->Proc;
|
TypeProc *pt = &pi.type->Proc;
|
||||||
String name = pi.token.string;
|
String name = pi.token.string;
|
||||||
@@ -3148,7 +3149,6 @@ void check_proc_info(Checker *c, ProcedureInfo pi) {
|
|||||||
GB_ASSERT_MSG(pt->is_poly_specialized, "%.*s", LIT(name));
|
GB_ASSERT_MSG(pt->is_poly_specialized, "%.*s", LIT(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool bounds_check = (pi.tags & ProcTag_bounds_check) != 0;
|
bool bounds_check = (pi.tags & ProcTag_bounds_check) != 0;
|
||||||
bool no_bounds_check = (pi.tags & ProcTag_no_bounds_check) != 0;
|
bool no_bounds_check = (pi.tags & ProcTag_no_bounds_check) != 0;
|
||||||
|
|
||||||
|
|||||||
+1
-12
@@ -3592,7 +3592,6 @@ gb_global i32 ir_global_type_info_member_names_index = 0;
|
|||||||
gb_global i32 ir_global_type_info_member_offsets_index = 0;
|
gb_global i32 ir_global_type_info_member_offsets_index = 0;
|
||||||
gb_global i32 ir_global_type_info_member_usings_index = 0;
|
gb_global i32 ir_global_type_info_member_usings_index = 0;
|
||||||
|
|
||||||
#if 1
|
|
||||||
isize ir_type_info_count(CheckerInfo *info) {
|
isize ir_type_info_count(CheckerInfo *info) {
|
||||||
return info->minimum_dependency_type_info_set.entries.count+1;
|
return info->minimum_dependency_type_info_set.entries.count+1;
|
||||||
}
|
}
|
||||||
@@ -3610,16 +3609,6 @@ isize ir_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=tr
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
isize ir_type_info_count(CheckerInfo *info) {
|
|
||||||
return info->type_info_types.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
isize ir_type_info_index(CheckerInfo *info, Type *type) {
|
|
||||||
isize index = type_info_index(info, type);
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
irValue *ir_type_info(irProcedure *proc, Type *type) {
|
irValue *ir_type_info(irProcedure *proc, Type *type) {
|
||||||
CheckerInfo *info = proc->module->info;
|
CheckerInfo *info = proc->module->info;
|
||||||
@@ -6205,7 +6194,7 @@ void ir_build_constant_value_decl(irProcedure *proc, AstNodeValueDecl *vd) {
|
|||||||
if (e->kind == Entity_TypeName) {
|
if (e->kind == Entity_TypeName) {
|
||||||
bool polymorphic_struct = false;
|
bool polymorphic_struct = false;
|
||||||
if (e->type != nullptr && e->kind == Entity_TypeName) {
|
if (e->type != nullptr && e->kind == Entity_TypeName) {
|
||||||
Type *bt = base_type(e->type);
|
Type *bt = base_type(e->type);
|
||||||
if (bt->kind == Type_Struct) {
|
if (bt->kind == Type_Struct) {
|
||||||
polymorphic_struct = bt->Struct.is_polymorphic;
|
polymorphic_struct = bt->Struct.is_polymorphic;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user