Actually substitute token array. init_language_core.

Seems like perf improved
This commit is contained in:
Krzosa Karol
2023-02-10 09:49:46 +01:00
parent 6f8a7ba6c8
commit dd6dc60d8b
2 changed files with 12 additions and 7 deletions

View File

@@ -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<Token>(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();

View File

@@ -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;
}