Removing heap allocations, Porting to Unix

This commit is contained in:
Krzosa Karol
2022-10-09 10:34:23 +02:00
parent aa2b4d90e4
commit b22e1ac0db
13 changed files with 260 additions and 269 deletions

View File

@@ -236,7 +236,7 @@ How does current declaration order resolver works:
struct Ast_Scope: Ast{
String debug_name; // Dont use
List<Ast_Scope *> implicit_imports;
Array<Ast_Decl *> decls;
List<Ast_Decl *> decls;
Array<Ast *> stmts;
U32 visit_id;
@@ -301,7 +301,7 @@ struct Ast_Decl: Ast{
#define ast_new(T,kind,pos,flags) (T *)_ast_new(sizeof(T), kind, pos, flags)
function Ast *
_ast_new(SizeU size, Ast_Kind kind, Token *pos, Ast_Flag flags = 0){
_ast_new(size_t size, Ast_Kind kind, Token *pos, Ast_Flag flags = 0){
Ast *result = (Ast *)exp_alloc(pctx->perm, size, AF_ZeroMemory);
result->flags = flags;
result->kind = kind;
@@ -471,7 +471,6 @@ ast_array(Token *pos, Ast_Expr *expr){
function Ast_Scope *
begin_decl_scope(Allocator *scratch, Token *pos){
AST_NEW(Scope, SCOPE, pos, AST_DECL);
result->decls = {scratch};
result->file = pctx->currently_parsed_file;
result->module = pctx->currently_parsed_file->module;
result->scope_id = pctx->scope_ids++;
@@ -483,7 +482,6 @@ begin_decl_scope(Allocator *scratch, Token *pos){
function void
finalize_decl_scope(Ast_Scope *scope){
scope->decls = scope->decls.tight_copy(pctx->perm);
pctx->currently_parsed_scope = scope->parent_scope;
}
@@ -491,7 +489,6 @@ function Ast_Scope *
begin_stmt_scope(Allocator *scratch, Token *pos){
AST_NEW(Scope, SCOPE, pos, AST_STMT);
result->stmts = {scratch};
result->decls = {pctx->heap};
result->file = pctx->currently_parsed_file;
result->module = pctx->currently_parsed_file->module;
result->scope_id = pctx->scope_ids++;
@@ -559,7 +556,6 @@ ast_type(Token *pos, Intern_String name, Ast_Type *type){
function Ast_Scope *
ast_decl_scope(Token *pos, Allocator *allocator, Ast_File *file){
AST_NEW(Scope, SCOPE, pos, AST_DECL);
result->decls = {allocator};
result->file = file;
result->scope_id = pctx->scope_ids++;