Save before Demo 001

This commit is contained in:
Ginger Bill
2016-08-25 19:52:51 +01:00
parent f93cf3827b
commit 3a189b9c1c
7 changed files with 140 additions and 142 deletions
+39
View File
@@ -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