Cleanup, There is no decl anymore, Ast_Named
This commit is contained in:
57
new_ast.cpp
57
new_ast.cpp
@@ -113,6 +113,7 @@ struct Ast{
|
||||
bool is_stmt: 1;
|
||||
bool is_expr: 1;
|
||||
bool is_decl: 1;
|
||||
bool is_named: 1;
|
||||
};
|
||||
|
||||
struct Ast_Resolved_Type;
|
||||
@@ -209,19 +210,24 @@ struct Ast_Typespec:Ast{
|
||||
};
|
||||
};
|
||||
|
||||
struct Ast_Decl:Ast{
|
||||
struct Ast_Named:Ast{
|
||||
Intern_String name;
|
||||
union{
|
||||
struct{
|
||||
Ast_Typespec *typespec;
|
||||
Ast_Expr *expr;
|
||||
}var;
|
||||
};
|
||||
};
|
||||
|
||||
struct Ast_Var: Ast_Named{
|
||||
Intern_String name;
|
||||
Ast_Typespec *typespec;
|
||||
Ast_Expr *expr;
|
||||
};
|
||||
|
||||
struct Ast_Const: Ast_Named{
|
||||
Intern_String name;
|
||||
Ast_Expr *expr;
|
||||
};
|
||||
|
||||
struct Ast_Package:Ast{
|
||||
Intern_String name;
|
||||
Array<Ast_Decl *> decls;
|
||||
Array<Ast_Named *> decls;
|
||||
};
|
||||
|
||||
function Ast_Typespec *ast_typespec_name(Token *pos, Intern_String name);
|
||||
@@ -398,31 +404,26 @@ ast_typespec_lambda(Token *pos, Ast_Lambda *lambda){
|
||||
//-----------------------------------------------------------------------------
|
||||
// Declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
function Ast_Decl *
|
||||
ast_decl_func(Token *pos, Intern_String name){
|
||||
AST_NEW(Decl, AST_LAMBDA, pos);
|
||||
|
||||
function Ast_Var *
|
||||
ast_var(Token *pos, Ast_Typespec *typespec, Intern_String name, Ast_Expr *expr){
|
||||
AST_NEW(Var, AST_VAR, pos);
|
||||
result->expr = expr;
|
||||
result->typespec = typespec;
|
||||
result->name = name;
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Const *
|
||||
ast_const(Token *pos, Intern_String name, Ast_Expr *expr){
|
||||
AST_NEW(Const, AST_CONST, pos);
|
||||
result->expr = expr;
|
||||
result->name = name;
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Decl *
|
||||
ast_decl_var(Token *pos, Ast_Typespec *typespec, Intern_String name, Ast_Expr *expr){
|
||||
AST_NEW(Decl, AST_VAR, pos);
|
||||
result->var.expr = expr;
|
||||
result->var.typespec = typespec;
|
||||
result->name = name;
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Decl *
|
||||
ast_decl_const(Token *pos, Intern_String name, Ast_Expr *expr){
|
||||
Ast_Decl *result = ast_decl_var(pos, 0, name, expr);
|
||||
result->kind = AST_CONST;
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Package *
|
||||
ast_package(Token *pos, String name, Array<Ast_Decl *> decls){
|
||||
ast_package(Token *pos, String name, Array<Ast_Named *> decls){
|
||||
AST_NEW(Package, AST_PACKAGE, pos);
|
||||
result->decls = decls.tight_copy(pctx->perm);
|
||||
result->name = intern_string(&pctx->interns, name);
|
||||
|
||||
Reference in New Issue
Block a user