diff options
| author | Ginger Bill <bill@gingerbill.org> | 2016-08-25 19:52:51 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2016-08-25 19:52:51 +0100 |
| commit | 3a189b9c1ca273105ba030322e151efd85825482 (patch) | |
| tree | 126679aa7ec0bffb6752045419087416be3588bf /src/checker/checker.cpp | |
| parent | f93cf3827ba5cde4f054db99b9815cb2a18ba861 (diff) | |
Save before Demo 001
Diffstat (limited to 'src/checker/checker.cpp')
| -rw-r--r-- | src/checker/checker.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/checker/checker.cpp b/src/checker/checker.cpp index fb2b9139e..8390442ae 100644 --- a/src/checker/checker.cpp +++ b/src/checker/checker.cpp @@ -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 |