Small allocator changes, fix crash

This commit is contained in:
Krzosa Karol
2022-12-31 21:05:13 +01:00
parent d75c54f61f
commit d5179bb596
2 changed files with 15 additions and 9 deletions

View File

@@ -1,19 +1,19 @@
CORE_Static void
core_init_compiler(Parse_Ctx *ctx, Allocator *allocator) {
core_init_compiler(Parse_Ctx *ctx, Arena *perm, Allocator *heap) {
ctx->init_ctx_time_begin = os_time();
pctx = ctx;
Allocator *heap_allocator = allocator;
ctx->perm = (Arena *)allocator;
ctx->type_map = map_make(heap_allocator, 2048);
ctx->perm = perm;
ctx->heap = heap;
ctx->type_map = map_make(heap, 2048);
ctx->gen = {ctx->perm};
ctx->helper_builder = {ctx->perm};
ctx->scope_ids = 1;
bigint_allocator = ctx->perm;
arena_init(&ctx->stage_arena, "Compiler stage arena"_s);
ctx->tokens = array_make<Token>(heap_allocator, 4096 * 4);
ctx->interns = intern_table_make(ctx->perm, heap_allocator, 2048);
ctx->tokens = array_make<Token>(heap, 4096 * 4);
ctx->interns = intern_table_make(ctx->perm, heap, 2048);
/*#import meta
for i in meta.keywords:
@@ -96,7 +96,9 @@ core_init_compiler(Parse_Ctx *ctx, Allocator *allocator) {
CORE_Static void
core_bootstrap_compiler(Allocator *allocator) {
Parse_Ctx *ctx = allocate_struct(allocator, Parse_Ctx);
core_init_compiler(ctx, allocator);
assert((uintptr_t)allocator->allocate == (uintptr_t)arena_push_size);
core_init_compiler(ctx, (Arena *)allocator, allocator);
}
CORE_Static void
@@ -212,8 +214,9 @@ resolve_everything_in_module(Ast_Module *module) {
CORE_Static String
compile_file_to_string(Arena *arena, String filename) {
pctx->total_time = os_time();
F64 total_time = os_time();
core_bootstrap_compiler(arena);
pctx->total_time = total_time;
{
Ast_Module *module = add_module(0, pctx->intern("Language.core"_s));
{