Getting absolute paths, Ast_Files now compare absolute paths

This commit is contained in:
Krzosa Karol
2022-06-27 09:39:24 +02:00
parent 02ec291ad0
commit 3af20536fc
4 changed files with 28 additions and 16 deletions

View File

@@ -719,10 +719,12 @@ enum{
function Ast_File *
register_ast_file(Token *pos, Intern_String filename, Ast_Module *module, B32 global_implicit_load){
Ast_File *file = 0;
String absolute_path = os_get_absolute_path(pctx->perm, filename.s);
For(pctx->files){
if(it->filename == filename){
if(string_compare(it->absolute_path, absolute_path)){
if(module == it->module){
log_info("%Q :: Returning registered file: %Q\n", module->name, filename);
log_info("%Q :: Returning registered file: %Q\n", module->name, absolute_path);
file = it;
break;
}
@@ -735,16 +737,17 @@ register_ast_file(Token *pos, Intern_String filename, Ast_Module *module, B32 gl
if(!file){
log_info("%Q :: Registering file: %Q\n", module->name, filename);
AST_NEW(File, FILE, 0, 0);
file = result;
file->filename = filename;
file->module = module;
file->parent_scope = 0;
file->file = file; // @warning: self referential!
file->decls = {pctx->heap};
file = result;
file->absolute_path = absolute_path;
file->filename = filename;
file->module = module;
file->parent_scope = 0;
file->file = file; // @warning: self referential!
file->decls = {pctx->heap};
file->implicit_imports = {pctx->heap};
file->pos = pos;
file->module->all_loaded_files.add(file);
pctx->files.add(file);
file->pos = pos;
}
if(global_implicit_load) {