mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix #1267
This commit is contained in:
+2
-1
@@ -6085,7 +6085,8 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(bill): Add type info the parameters
|
// NOTE(bill): Add type info the parameters
|
||||||
add_type_info_type(c, o->type);
|
// TODO(bill, 2022-01-23): why was this line added in the first place? I'm commenting it out for the time being
|
||||||
|
// add_type_info_type(c, o->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
+18
-6
@@ -688,12 +688,17 @@ void add_dependency(CheckerInfo *info, DeclInfo *d, Entity *e) {
|
|||||||
ptr_set_add(&d->deps, e);
|
ptr_set_add(&d->deps, e);
|
||||||
mutex_unlock(&info->deps_mutex);
|
mutex_unlock(&info->deps_mutex);
|
||||||
}
|
}
|
||||||
void add_type_info_dependency(DeclInfo *d, Type *type) {
|
void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type, bool require_mutex) {
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// NOTE(bill): no mutex is required here because the only procedure calling it is wrapped in a mutex already
|
if (require_mutex) {
|
||||||
|
mutex_lock(&info->deps_mutex);
|
||||||
|
}
|
||||||
ptr_set_add(&d->type_info_deps, type);
|
ptr_set_add(&d->type_info_deps, type);
|
||||||
|
if (require_mutex) {
|
||||||
|
mutex_unlock(&info->deps_mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AstPackage *get_core_package(CheckerInfo *info, String name) {
|
AstPackage *get_core_package(CheckerInfo *info, String name) {
|
||||||
@@ -1589,7 +1594,7 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_type_info_dependency(c->decl, t);
|
add_type_info_dependency(c->info, c->decl, t, false);
|
||||||
|
|
||||||
auto found = map_get(&c->info->type_info_map, t);
|
auto found = map_get(&c->info->type_info_map, t);
|
||||||
if (found != nullptr) {
|
if (found != nullptr) {
|
||||||
@@ -1613,6 +1618,9 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) {
|
|||||||
// NOTE(bill): map entries grow linearly and in order
|
// NOTE(bill): map entries grow linearly and in order
|
||||||
ti_index = c->info->type_info_types.count;
|
ti_index = c->info->type_info_types.count;
|
||||||
array_add(&c->info->type_info_types, t);
|
array_add(&c->info->type_info_types, t);
|
||||||
|
if (t->kind == Type_Named && t->Named.name == "A") {
|
||||||
|
gb_printf_err("HERE!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
map_set(&c->checker->info.type_info_map, t, ti_index);
|
map_set(&c->checker->info.type_info_map, t, ti_index);
|
||||||
|
|
||||||
@@ -1718,6 +1726,7 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) {
|
|||||||
} else {
|
} else {
|
||||||
add_type_info_type_internal(c, t_type_info_ptr);
|
add_type_info_type_internal(c, t_type_info_ptr);
|
||||||
}
|
}
|
||||||
|
add_type_info_type_internal(c, bt->Union.polymorphic_params);
|
||||||
for_array(i, bt->Union.variants) {
|
for_array(i, bt->Union.variants) {
|
||||||
add_type_info_type_internal(c, bt->Union.variants[i]);
|
add_type_info_type_internal(c, bt->Union.variants[i]);
|
||||||
}
|
}
|
||||||
@@ -1741,6 +1750,7 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
add_type_info_type_internal(c, bt->Struct.polymorphic_params);
|
||||||
for_array(i, bt->Struct.fields) {
|
for_array(i, bt->Struct.fields) {
|
||||||
Entity *f = bt->Struct.fields[i];
|
Entity *f = bt->Struct.fields[i];
|
||||||
add_type_info_type_internal(c, f->type);
|
add_type_info_type_internal(c, f->type);
|
||||||
@@ -1934,6 +1944,7 @@ void add_min_dep_type_info(Checker *c, Type *t) {
|
|||||||
} else {
|
} else {
|
||||||
add_min_dep_type_info(c, t_type_info_ptr);
|
add_min_dep_type_info(c, t_type_info_ptr);
|
||||||
}
|
}
|
||||||
|
add_min_dep_type_info(c, bt->Union.polymorphic_params);
|
||||||
for_array(i, bt->Union.variants) {
|
for_array(i, bt->Union.variants) {
|
||||||
add_min_dep_type_info(c, bt->Union.variants[i]);
|
add_min_dep_type_info(c, bt->Union.variants[i]);
|
||||||
}
|
}
|
||||||
@@ -1957,6 +1968,7 @@ void add_min_dep_type_info(Checker *c, Type *t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
add_min_dep_type_info(c, bt->Struct.polymorphic_params);
|
||||||
for_array(i, bt->Struct.fields) {
|
for_array(i, bt->Struct.fields) {
|
||||||
Entity *f = bt->Struct.fields[i];
|
Entity *f = bt->Struct.fields[i];
|
||||||
add_min_dep_type_info(c, f->type);
|
add_min_dep_type_info(c, f->type);
|
||||||
@@ -5473,9 +5485,6 @@ void check_parsed_files(Checker *c) {
|
|||||||
TIME_SECTION("calculate global init order");
|
TIME_SECTION("calculate global init order");
|
||||||
calculate_global_init_order(c);
|
calculate_global_init_order(c);
|
||||||
|
|
||||||
TIME_SECTION("generate minimum dependency set");
|
|
||||||
generate_minimum_dependency_set(c, c->info.entry_point);
|
|
||||||
|
|
||||||
TIME_SECTION("check test procedures");
|
TIME_SECTION("check test procedures");
|
||||||
check_test_procedures(c);
|
check_test_procedures(c);
|
||||||
|
|
||||||
@@ -5486,6 +5495,9 @@ void check_parsed_files(Checker *c) {
|
|||||||
add_type_info_for_type_definitions(c);
|
add_type_info_for_type_definitions(c);
|
||||||
check_merge_queues_into_arrays(c);
|
check_merge_queues_into_arrays(c);
|
||||||
|
|
||||||
|
TIME_SECTION("generate minimum dependency set");
|
||||||
|
generate_minimum_dependency_set(c, c->info.entry_point);
|
||||||
|
|
||||||
TIME_SECTION("check entry point");
|
TIME_SECTION("check entry point");
|
||||||
if (build_context.build_mode == BuildMode_Executable && !build_context.no_entry_point && build_context.command_kind != Command_test) {
|
if (build_context.build_mode == BuildMode_Executable && !build_context.no_entry_point && build_context.command_kind != Command_test) {
|
||||||
Scope *s = c->info.init_scope;
|
Scope *s = c->info.init_scope;
|
||||||
|
|||||||
@@ -403,6 +403,7 @@ void compiler_error(char const *fmt, ...) {
|
|||||||
gb_printf_err("Internal Compiler Error: %s\n",
|
gb_printf_err("Internal Compiler Error: %s\n",
|
||||||
gb_bprintf_va(fmt, va));
|
gb_bprintf_va(fmt, va));
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
GB_DEBUG_TRAP();
|
||||||
gb_exit(1);
|
gb_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=true) {
|
isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=true) {
|
||||||
isize index = type_info_index(info, type, false);
|
auto *set = &info->minimum_dependency_type_info_set;
|
||||||
|
isize index = type_info_index(info, type, err_on_not_found);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
auto *set = &info->minimum_dependency_type_info_set;
|
isize i = ptr_entry_index(set, index);
|
||||||
for_array(i, set->entries) {
|
if (i >= 0) {
|
||||||
if (set->entries[i].ptr == index) {
|
return i+1;
|
||||||
return i+1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (err_on_not_found) {
|
if (err_on_not_found) {
|
||||||
|
|||||||
@@ -138,6 +138,15 @@ gb_inline bool ptr_set_exists(PtrSet<T> *s, T ptr) {
|
|||||||
return index != MAP_SENTINEL;
|
return index != MAP_SENTINEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
gb_inline isize ptr_entry_index(PtrSet<T> *s, T ptr) {
|
||||||
|
isize index = ptr_set__find(s, ptr).entry_index;
|
||||||
|
if (index != MAP_SENTINEL) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true if it already exists
|
// Returns true if it already exists
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T ptr_set_add(PtrSet<T> *s, T ptr) {
|
T ptr_set_add(PtrSet<T> *s, T ptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user