Package is Decl

This commit is contained in:
Krzosa Karol
2022-06-12 19:54:37 +02:00
parent 31c2c00452
commit cdaf85438e
4 changed files with 29 additions and 24 deletions

13
ast.cpp
View File

@@ -221,9 +221,7 @@ struct Ast_File{
Array<Ast_Decl *> decls;
};
struct Ast_Package : Ast_Scope{
Intern_String name;
};
struct Ast_Package : Ast_Decl{};
//-----------------------------------------------------------------------------
// AST Constructors beginning with expressions
@@ -475,11 +473,18 @@ ast_type(Token *pos, Intern_String name, Ast_Type *type){
return result;
}
function Ast_Scope *
ast_decl_scope(Token *pos, Allocator *allocator){
AST_NEW(Scope, SCOPE, pos, AST_DECL);
result->decls = {allocator};
return result;
}
function Ast_Package *
ast_package(Token *pos, Allocator *allocator, Intern_String name){
AST_NEW(Package, PACKAGE, pos, 0);
result->kind = AST_PACKAGE;
result->decls = {allocator};
result->scope = ast_decl_scope(pos, allocator);
result->name = name;
return result;
}