More order independent globals
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user