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:
24
new_ast.cpp
24
new_ast.cpp
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user