mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Add sanity checks to checker
This commit is contained in:
@@ -1171,9 +1171,6 @@ end:;
|
|||||||
// NOTE(bill): Add it to the list of checked entities
|
// NOTE(bill): Add it to the list of checked entities
|
||||||
if (e->flags & EntityFlag_Lazy) {
|
if (e->flags & EntityFlag_Lazy) {
|
||||||
array_add(&ctx->info->entities, e);
|
array_add(&ctx->info->entities, e);
|
||||||
}
|
|
||||||
|
|
||||||
if (e->flags & EntityFlag_Lazy) {
|
|
||||||
mutex_unlock(&ctx->info->lazy_mutex);
|
mutex_unlock(&ctx->info->lazy_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-13
@@ -5014,22 +5014,22 @@ void check_unique_package_names(Checker *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void check_add_entities_from_queues(Checker *c) {
|
void check_add_entities_from_queues(Checker *c) {
|
||||||
{
|
isize cap = c->info.entities.count + c->info.entity_queue.count.load(std::memory_order_relaxed);
|
||||||
isize cap = c->info.entities.count + c->info.entity_queue.count.load(std::memory_order_relaxed);
|
array_reserve(&c->info.entities, cap);
|
||||||
array_reserve(&c->info.entities, cap);
|
for (Entity *e; mpmc_dequeue(&c->info.entity_queue, &e); /**/) {
|
||||||
for (Entity *e; mpmc_dequeue(&c->info.entity_queue, &e); /**/) {
|
array_add(&c->info.entities, e);
|
||||||
array_add(&c->info.entities, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
isize cap = c->info.definitions.count + c->info.definition_queue.count.load(std::memory_order_relaxed);
|
|
||||||
array_reserve(&c->info.definitions, cap);
|
|
||||||
for (Entity *e; mpmc_dequeue(&c->info.definition_queue, &e); /**/) {
|
|
||||||
array_add(&c->info.definitions, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void check_add_definitions_from_queues(Checker *c) {
|
||||||
|
isize cap = c->info.definitions.count + c->info.definition_queue.count.load(std::memory_order_relaxed);
|
||||||
|
array_reserve(&c->info.definitions, cap);
|
||||||
|
for (Entity *e; mpmc_dequeue(&c->info.definition_queue, &e); /**/) {
|
||||||
|
array_add(&c->info.definitions, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void check_parsed_files(Checker *c) {
|
void check_parsed_files(Checker *c) {
|
||||||
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||||
@@ -5071,6 +5071,7 @@ void check_parsed_files(Checker *c) {
|
|||||||
|
|
||||||
TIME_SECTION("add entities from packages");
|
TIME_SECTION("add entities from packages");
|
||||||
check_add_entities_from_queues(c);
|
check_add_entities_from_queues(c);
|
||||||
|
check_add_definitions_from_queues(c);
|
||||||
|
|
||||||
TIME_SECTION("check all global entities");
|
TIME_SECTION("check all global entities");
|
||||||
check_all_global_entities(c);
|
check_all_global_entities(c);
|
||||||
@@ -5090,6 +5091,7 @@ void check_parsed_files(Checker *c) {
|
|||||||
|
|
||||||
TIME_SECTION("add entities from procedure bodies");
|
TIME_SECTION("add entities from procedure bodies");
|
||||||
check_add_entities_from_queues(c);
|
check_add_entities_from_queues(c);
|
||||||
|
check_add_definitions_from_queues(c);
|
||||||
|
|
||||||
TIME_SECTION("check scope usage");
|
TIME_SECTION("check scope usage");
|
||||||
for_array(i, c->info.files.entries) {
|
for_array(i, c->info.files.entries) {
|
||||||
@@ -5132,6 +5134,8 @@ void check_parsed_files(Checker *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TIME_SECTION("check for type cycles and inline cycles");
|
TIME_SECTION("check for type cycles and inline cycles");
|
||||||
|
check_add_definitions_from_queues(c);
|
||||||
|
|
||||||
// NOTE(bill): Check for illegal cyclic type declarations
|
// NOTE(bill): Check for illegal cyclic type declarations
|
||||||
for_array(i, c->info.definitions) {
|
for_array(i, c->info.definitions) {
|
||||||
Entity *e = c->info.definitions[i];
|
Entity *e = c->info.definitions[i];
|
||||||
@@ -5190,6 +5194,11 @@ void check_parsed_files(Checker *c) {
|
|||||||
TIME_SECTION("check unique package names");
|
TIME_SECTION("check unique package names");
|
||||||
check_unique_package_names(c);
|
check_unique_package_names(c);
|
||||||
|
|
||||||
|
|
||||||
|
TIME_SECTION("sanity checks");
|
||||||
|
GB_ASSERT(c->info.entity_queue.count.load(std::memory_order_relaxed) == 0);
|
||||||
|
GB_ASSERT(c->info.definition_queue.count.load(std::memory_order_relaxed) == 0);
|
||||||
|
|
||||||
TIME_SECTION("type check finish");
|
TIME_SECTION("type check finish");
|
||||||
|
|
||||||
#undef TIME_SECTION
|
#undef TIME_SECTION
|
||||||
|
|||||||
Reference in New Issue
Block a user