Introducing List and changes in base

This commit is contained in:
Krzosa Karol
2022-09-30 09:40:56 +02:00
parent 5e149dfca3
commit cf619c2ea3
7 changed files with 299 additions and 354 deletions

View File

@@ -79,9 +79,10 @@ l->last_op = op_post_increment;
}
function void
parse_init(Parse_Ctx *ctx, Allocator *perm_allocator, Allocator *heap_allocator){
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};
@@ -165,9 +166,8 @@ parse_all_modules(){
Ast_Module *module = pctx->modules[i];
if(module->state != MODULE_REGISTERED) continue;
for(S64 j = 0; j < module->all_loaded_files.len; j++){
Ast_File *file = module->all_loaded_files.data[j];
parse_file(file);
Iter(&module->all_loaded_files){
parse_file(*it.item);
}
if(module != pctx->language_base_module)
@@ -216,23 +216,22 @@ add_module(Token *pos, Intern_String filename, B32 command_line_module){
For(pctx->modules){
if(string_compare(it->absolute_file_path, absolute_file_path)){
// log_info("Returning registered module: %Q\n", absolute_file_path);
log_trace("Returning registered module: %Q\n", absolute_file_path);
return it;
}
}
Ast_Module *result = ast_new(Ast_Module, AST_MODULE, pos, 0);
result->absolute_file_path = string_copy(pctx->perm, absolute_file_path);
log_trace("Adding module: %Q\n", filename);
Ast_Module *result = ast_new(Ast_Module, AST_MODULE, pos, 0);
result->absolute_file_path = string_copy(pctx->perm, absolute_file_path);
result->absolute_base_folder = string_copy(pctx->perm, absolute_base_folder);
result->debug_name = string_skip_to_last_slash(result->absolute_file_path);
// log_info("Adding module: %Q\n", filename);
result->module = result; // @warning: self referential
result->file = result; // @warning: self referential
result->all_loaded_files = {pctx->heap};
result->implicit_imports = {pctx->heap};
result->decls = {pctx->heap};
result->parent_scope = 0;
result->scope_id = pctx->scope_ids++;
result->debug_name = string_skip_to_last_slash(result->absolute_file_path);
result->module = result; // @warning: self referential
result->file = result; // @warning: self referential
result->implicit_imports = {pctx->heap};
result->decls = {pctx->heap};
result->parent_scope = 0;
result->scope_id = pctx->scope_ids++;
register_ast_file(pos, result->absolute_file_path, result, GLOBAL_IMPLICIT_LOAD);
pctx->modules.add(result);
@@ -243,10 +242,9 @@ function void
resolve_everything_in_module(Ast_Module *module){
if(module->state == MODULE_RESOLVED) return;
resolving_time_begin = os_time();
for(S64 i = 0; i < module->all_loaded_files.len; i++){
Ast_File *file = module->all_loaded_files[i];
For(file->decls){
resolve_name(file, it->pos, it->name);
Iter_Named(&module->all_loaded_files, file){
For(file.item[0]->decls){
resolve_name(file.item[0], it->pos, it->name);
if(it->kind == AST_STRUCT){
type_complete(it->type_val);
}