More order independent globals

This commit is contained in:
Krzosa Karol
2022-05-29 22:07:08 +02:00
parent 2ad3131dba
commit 4434ad1fb5
6 changed files with 39 additions and 11 deletions

View File

@@ -269,6 +269,7 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *const_sym){
result.is_const = true;
}
else if(sym->kind == SYM_CONST || sym->kind == SYM_VAR){
type_complete(sym->type);
result.type = sym->type;
result.is_const = sym->kind == SYM_CONST ? true : false;
result.value = sym->value;
@@ -543,6 +544,9 @@ function void
resolve_package(Ast_Package *package){
For(package->decls){
resolve_name(it[0]->pos, it[0]->name);
if(ast_is_struct(it[0])){
type_complete(const_get_struct(it[0])->type);
}
}
}
@@ -567,10 +571,12 @@ parse_file(){
Sym *sym = sym_new(SYM_VAR, decl->name, decl);
if(decl->kind == AST_CONST) {
sym->kind = SYM_CONST;
auto constant = (Ast_Const *)decl;
if(constant->value->kind == AST_STRUCT){
sym->type = type_incomplete(sym);
sym->state = SYM_RESOLVED;
Ast_Struct *s = const_try_getting_struct(decl);
if(s){
s->type = type_incomplete(sym);
sym->type_val = s->type;
sym->type = type_type;
sym->state = SYM_RESOLVED;
}
}
else assert(decl->kind == AST_VAR);