From dd6dc60d8bec7e630f7d90fcb6e0d5b6e7559075 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 10 Feb 2023 09:49:46 +0100 Subject: [PATCH] Actually substitute token array. init_language_core. Seems like perf improved --- core_compiler.cpp | 18 +++++++++++------- core_lexing.cpp | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core_compiler.cpp b/core_compiler.cpp index 66cb38a..e726663 100644 --- a/core_compiler.cpp +++ b/core_compiler.cpp @@ -23,7 +23,6 @@ static void core_init_compiler(Core_Ctx *ctx, Allocator *allocator) { ctx->scope_ids = 1; bigint_allocator = ctx->perm; - ctx->tokens = array_make(ctx->heap, 4096 * 4); ctx->interns = intern_table_make(ctx->perm, ctx->heap, 2048); /*#import meta @@ -281,12 +280,8 @@ resolve_everything_in_module(Ast_Module *module) { pctx->time.typechecking = os_time() - pctx->time.typechecking; } -CORE_Static String -compile_file_to_string(Allocator *allocator, String filename) { - F64 total_time = os_time(); - core_bootstrap_compiler(allocator); - pctx->time.total = total_time; - pctx->time.start = total_time; +CORE_Static void +init_language_core() { { Ast_Module *module = add_module(0, pctx->intern("Language.core"_s), false, true); get(&module->all_loaded_files, 0)->filecontent = @@ -412,6 +407,15 @@ GetTypeInfo :: (type: Type): *Type_Info assert(string_decl->type == pctx->type_type); pctx->type_string = string_decl->type_val; } +} + +CORE_Static String +compile_file_to_string(Allocator *allocator, String filename) { + F64 total_time = os_time(); + core_bootstrap_compiler(allocator); + pctx->time.total = total_time; + pctx->time.start = total_time; + init_language_core(); Ast_Module *module = add_module(0, pctx->intern(filename), true); parse_all_modules(); diff --git a/core_lexing.cpp b/core_lexing.cpp index faf0bd4..f1c1c5c 100644 --- a/core_lexing.cpp +++ b/core_lexing.cpp @@ -209,6 +209,7 @@ lex_add_token(Core_Ctx *ctx, Token *token) { Token *top = (Token *)arena_push_size(ctx->stage_arena, sizeof(Token)); *top = *token; ctx->tokens.len += 1; + ctx->tokens.cap += 1; ctx->tokens.data = (Token *)ctx->stage_arena->memory.data; }