Moving more code to list
This commit is contained in:
@@ -82,15 +82,11 @@ function void
|
||||
parse_init(Parse_Ctx *ctx, Arena *perm_allocator, Allocator *heap_allocator){
|
||||
pctx = ctx;
|
||||
ctx->perm = perm_allocator;
|
||||
ctx->perm_arena = 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);
|
||||
@@ -102,9 +98,8 @@ parse_init(Parse_Ctx *ctx, Arena *perm_allocator, Allocator *heap_allocator){
|
||||
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);
|
||||
add(ctx->perm, &ctx->module_folders, main_module);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,8 +157,9 @@ global F64 parsing_time_end;
|
||||
function void
|
||||
parse_all_modules(){
|
||||
parsing_time_begin = os_time();
|
||||
for(S64 i = 0; i < pctx->modules.len; i++){
|
||||
Ast_Module *module = pctx->modules[i];
|
||||
|
||||
Iter_Named(&pctx->modules, mod_it){
|
||||
Ast_Module *module = mod_it.item[0];
|
||||
if(module->state != MODULE_REGISTERED) continue;
|
||||
|
||||
Iter(&module->all_loaded_files){
|
||||
@@ -200,8 +196,8 @@ add_module(Token *pos, Intern_String filename, B32 command_line_module){
|
||||
// Find in module folder
|
||||
//
|
||||
else{
|
||||
For(pctx->module_folders){
|
||||
String path = string_fmt(scratch, "%Q/%Q", it, filename);
|
||||
Iter(&pctx->module_folders){
|
||||
String path = string_fmt(scratch, "%Q/%Q", it.item[0], filename);
|
||||
if(os_does_file_exist(path)){
|
||||
absolute_file_path = path;
|
||||
absolute_base_folder = string_chop_last_slash(path);
|
||||
@@ -214,10 +210,10 @@ add_module(Token *pos, Intern_String filename, B32 command_line_module){
|
||||
compiler_error(pos, "Couldn't find the module with name %Q", filename);
|
||||
}
|
||||
|
||||
For(pctx->modules){
|
||||
if(string_compare(it->absolute_file_path, absolute_file_path)){
|
||||
Iter(&pctx->modules){
|
||||
if(string_compare(it.item[0]->absolute_file_path, absolute_file_path)){
|
||||
log_trace("Returning registered module: %Q\n", absolute_file_path);
|
||||
return it;
|
||||
return it.item[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +230,7 @@ add_module(Token *pos, Intern_String filename, B32 command_line_module){
|
||||
result->scope_id = pctx->scope_ids++;
|
||||
|
||||
register_ast_file(pos, result->absolute_file_path, result, GLOBAL_IMPLICIT_LOAD);
|
||||
pctx->modules.add(result);
|
||||
add(pctx->perm, &pctx->modules, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -267,7 +263,7 @@ compile_file_to_string(String filename){
|
||||
resolve_everything_in_module(module);
|
||||
// @note: language stuff needs to be declared before type_info data
|
||||
// so we mark where it ends
|
||||
pctx->base_language_ordered_decl_len = pctx->ordered_decls.len;
|
||||
pctx->base_language_ordered_decl_len = length(&pctx->ordered_decls);
|
||||
Ast_Decl *any_decl = search_for_single_decl(module, pctx->intern("Any"_s));
|
||||
assert(any_decl->type == type_type);
|
||||
type_any = any_decl->type_val;
|
||||
|
||||
Reference in New Issue
Block a user