More work on order independent bindings, A bit more cleanup, Delete some of the null code, no longer valid c code

This commit is contained in:
Krzosa Karol
2022-05-29 21:38:29 +02:00
parent b6ea62fd67
commit 2ad3131dba
5 changed files with 250 additions and 214 deletions

View File

@@ -226,7 +226,11 @@ struct Ast_Var: Ast_Named{
};
struct Ast_Const: Ast_Named{
Ast_Expr *value;
union{
Ast *ast;
Ast_Expr *value;
Ast_Struct *agg;
};
};
struct Ast_Package:Ast{
@@ -460,3 +464,21 @@ ast_package(Token *pos, String name, Array<Ast_Named *> decls){
For(result->decls) it[0]->parent = result;
return result;
}
//-----------------------------------------------------------------------------
// Utillities
//-----------------------------------------------------------------------------
function Ast_Struct *
const_get_struct(Ast *ast){
assert(ast->kind == AST_CONST);
Ast_Const *constant = (Ast_Const *)ast;
assert(constant->value->kind == AST_STRUCT);
return (Ast_Struct *)constant->value;
}
function Intern_String
ast_get_name(Ast *ast){
assert(is_flag_set(ast->flags, AST_BINDING));
auto constant = (Ast_Named *)ast;
return constant->name;
}