mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-12 14:21:25 -07:00
Save before Demo 001
This commit is contained in:
@@ -190,6 +190,21 @@ struct Checker {
|
||||
|
||||
gb_global Scope *universal_scope = NULL;
|
||||
|
||||
struct CycleChecker {
|
||||
gbArray(Entity *) path; // Entity_TypeName
|
||||
};
|
||||
|
||||
CycleChecker *cycle_checker_add(CycleChecker *cc, Entity *e) {
|
||||
GB_ASSERT(cc != NULL);
|
||||
if (cc->path == NULL) {
|
||||
gb_array_init(cc->path, gb_heap_allocator());
|
||||
}
|
||||
GB_ASSERT(e != NULL && e->kind == Entity_TypeName);
|
||||
gb_array_append(cc->path, e);
|
||||
return cc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Scope *make_scope(Scope *parent, gbAllocator allocator) {
|
||||
Scope *s = gb_alloc_item(allocator, Scope);
|
||||
@@ -561,6 +576,30 @@ void add_curr_ast_file(Checker *c, AstFile *file) {
|
||||
|
||||
|
||||
|
||||
struct CycleCheck {
|
||||
gbArray(Entity *) path; // HACK(bill): Memory Leak
|
||||
};
|
||||
|
||||
void cycle_check_add(CycleCheck *cc, Entity *entity) {
|
||||
if (cc == NULL)
|
||||
return;
|
||||
if (cc->path == NULL) {
|
||||
gb_array_init(cc->path, gb_heap_allocator());
|
||||
}
|
||||
GB_ASSERT(entity->kind == Entity_TypeName);
|
||||
gb_array_append(cc->path, entity);
|
||||
}
|
||||
|
||||
void check_type_name_cycles(Checker *c, CycleCheck *cc, Entity *e) {
|
||||
GB_ASSERT(e->kind == Entity_TypeName);
|
||||
Type *t = e->type;
|
||||
// if (t->kind == Type_Named) {
|
||||
// if (t->Named.type_name == e) {
|
||||
// gb_printf("Illegal cycle %.*s!!!\n", LIT(e->token.string));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void check_parsed_files(Checker *c) {
|
||||
// Collect Entities
|
||||
|
||||
Reference in New Issue
Block a user