Organization cleanup, stage arena to Scratch_Arena
This commit is contained in:
@@ -6,13 +6,13 @@ core_init_compiler(Core_Ctx *ctx, Allocator *allocator) {
|
||||
ctx->perm_push_only = make_push_arena(allocator);
|
||||
ctx->perm = &ctx->perm_push_only;
|
||||
ctx->scratch = allocate_scratch_arena(ctx->perm, mib(1));
|
||||
ctx->stage_arena = allocate_scratch_arena(ctx->perm, mib(1));
|
||||
ctx->heap = allocator;
|
||||
ctx->type_map = map_make(ctx->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>(ctx->heap, 4096 * 4);
|
||||
ctx->interns = intern_table_make(ctx->perm, ctx->heap, 2048);
|
||||
@@ -98,7 +98,6 @@ core_init_compiler(Core_Ctx *ctx, Allocator *allocator) {
|
||||
CORE_Static void
|
||||
core_bootstrap_compiler(Allocator *allocator) {
|
||||
Core_Ctx *ctx = allocate_struct(allocator, Core_Ctx);
|
||||
assert((uintptr_t)allocator->allocate == (uintptr_t)arena_push_size);
|
||||
core_init_compiler(ctx, allocator);
|
||||
}
|
||||
|
||||
@@ -215,9 +214,9 @@ resolve_everything_in_module(Ast_Module *module) {
|
||||
}
|
||||
|
||||
CORE_Static String
|
||||
compile_file_to_string(Arena *arena, String filename) {
|
||||
compile_file_to_string(Allocator *allocator, String filename) {
|
||||
F64 total_time = os_time();
|
||||
core_bootstrap_compiler(arena);
|
||||
core_bootstrap_compiler(allocator);
|
||||
pctx->total_time = total_time;
|
||||
{
|
||||
Ast_Module *module = add_module(0, pctx->intern("Language.core"_s));
|
||||
@@ -280,7 +279,8 @@ compile_file_to_string(Arena *arena, String filename) {
|
||||
assert(module);
|
||||
resolve_everything_in_module(module);
|
||||
|
||||
arena_clear(&pctx->stage_arena);
|
||||
|
||||
pctx->stage_arena->len = 0;
|
||||
String result = compile_to_c_code();
|
||||
return result;
|
||||
}
|
||||
@@ -292,8 +292,8 @@ const U32 COMPILE_AND_RUN = 0x4;
|
||||
const U32 COMPILE_TESTING = 0x8;
|
||||
|
||||
CORE_Static void
|
||||
compile_file(Arena *arena, String filename, U32 compile_flags = COMPILE_NULL) {
|
||||
String result = compile_file_to_string(arena, filename);
|
||||
compile_file(Allocator *allocator, String filename, U32 compile_flags = COMPILE_NULL) {
|
||||
String result = compile_file_to_string(allocator, filename);
|
||||
if (is_flag_set(compile_flags, COMPILE_AND_RUN)) {
|
||||
log_info_no_nl("%Q - ", filename);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user