Restructuring
This commit is contained in:
@@ -6,6 +6,72 @@ global F64 total_time;
|
||||
global F64 init_ctx_time_begin;
|
||||
global F64 init_ctx_time_end;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructors
|
||||
//-----------------------------------------------------------------------------
|
||||
function void
|
||||
lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){
|
||||
l->arena = token_string_arena;
|
||||
l->tokens = array_make<Token>(token_string_arena, 1024*2);
|
||||
l->interns= intern_table_make(token_string_arena, map_allocator, 1024);
|
||||
|
||||
keyword_struct= l->intern("struct"_s);
|
||||
keyword_union = l->intern("union"_s);
|
||||
keyword_true = l->intern("true"_s);
|
||||
keyword_default = l->intern("default"_s);
|
||||
keyword_break = l->intern("break"_s);
|
||||
keyword_false = l->intern("false"_s);
|
||||
keyword_return = l->intern("return"_s);
|
||||
keyword_switch = l->intern("switch"_s);
|
||||
keyword_assert = l->intern("Assert"_s);
|
||||
keyword_if = l->intern("if"_s);
|
||||
keyword_elif = l->intern("elif"_s);
|
||||
keyword_pass = l->intern("pass"_s);
|
||||
keyword_else = l->intern("else"_s);
|
||||
keyword_for = l->intern("for"_s);
|
||||
keyword_enum = intern_string(&l->interns, "enum"_s);
|
||||
l->interns.first_keyword = keyword_struct.str;
|
||||
l->interns.last_keyword = keyword_enum.str;
|
||||
|
||||
intern_sizeof = l->intern("SizeOf"_s);
|
||||
intern_lengthof = l->intern("Length"_s);
|
||||
intern_alignof = l->intern("AlignOf"_s);
|
||||
intern_foreign = intern_string(&l->interns, "foreign"_s);
|
||||
intern_strict = intern_string(&l->interns, "strict"_s);
|
||||
intern_void = intern_string(&l->interns, "void"_s);
|
||||
intern_flag = intern_string(&l->interns, "flag"_s);
|
||||
intern_it = intern_string(&l->interns, "it"_s);
|
||||
}
|
||||
|
||||
function void
|
||||
parse_init(Parse_Ctx *ctx, Allocator *perm_allocator, Allocator *heap_allocator){
|
||||
pctx = ctx;
|
||||
ctx->perm = perm_allocator;
|
||||
ctx->heap = heap_allocator;
|
||||
ctx->gen = {ctx->heap};
|
||||
ctx->ordered_decls = {ctx->heap};
|
||||
ctx->type_map = {ctx->heap};
|
||||
ctx->modules = {ctx->heap};
|
||||
ctx->all_types = {ctx->heap};
|
||||
ctx->helper_builder= {ctx->heap};
|
||||
ctx->files = {ctx->heap};
|
||||
ctx->scope_ids = 1;
|
||||
bigint_allocator = ctx->perm;
|
||||
arena_init(&ctx->stage_arena, "Compiler stage arena"_s);
|
||||
|
||||
lex_init(ctx->perm, ctx->heap, ctx);
|
||||
init_type();
|
||||
|
||||
// Init paths
|
||||
ctx->exe_folder = os_get_exe_dir(ctx->perm);
|
||||
ctx->working_folder = os_get_working_dir(ctx->perm);
|
||||
|
||||
ctx->module_folders = {ctx->heap};
|
||||
String main_module = string_fmt(ctx->perm, "%Q/modules", ctx->exe_folder);
|
||||
ctx->module_folders.add(main_module);
|
||||
}
|
||||
|
||||
|
||||
function void
|
||||
begin_compilation(){
|
||||
init_ctx_time_begin = os_time();
|
||||
@@ -155,8 +221,6 @@ resolve_everything_in_module(Ast_Module *module){
|
||||
resolving_time_end = os_time();
|
||||
}
|
||||
|
||||
function String compile_to_c_code();
|
||||
|
||||
function String
|
||||
compile_file_to_string(String filename){
|
||||
total_time = os_time();
|
||||
|
||||
Reference in New Issue
Block a user