diff --git a/compiler.h b/compiler.h index 5286ec3..75b43ee 100644 --- a/compiler.h +++ b/compiler.h @@ -274,7 +274,4 @@ parse_init(Parse_Ctx *ctx, Allocator *perm_allocator, Allocator *heap_allocator) String main_module = string_fmt(ctx->perm, "%Q/modules", ctx->exe_folder); ctx->module_folders.add(main_module); - - - } \ No newline at end of file diff --git a/parsing.cpp b/parsing.cpp index 5b3c9e7..942d210 100644 --- a/parsing.cpp +++ b/parsing.cpp @@ -712,14 +712,27 @@ add_implicit_import(Ast_Scope *scope, Ast_Scope *add){ } } -enum{ - GLOBAL_IMPLICIT_LOAD = 1 -}; +function String +find_module(Intern_String filename){ + Scratch scratch; + For(pctx->module_folders){ + String path = string_fmt(scratch, "%Q/%Q", it, filename); + if(os_does_file_exist(path)){ + String result = string_copy(pctx->perm, path); + return result; + } + } + + return {}; +} + +enum{ GLOBAL_IMPLICIT_LOAD = 1 }; function Ast_File * register_ast_file(Token *pos, Intern_String filename, Ast_Module *module, B32 global_implicit_load){ + String absolute_path = find_module(filename); + if(absolute_path.len == 0) absolute_path = os_get_absolute_path(pctx->perm, filename.s); Ast_File *file = 0; - String absolute_path = os_get_absolute_path(pctx->perm, filename.s); For(pctx->files){ if(string_compare(it->absolute_path, absolute_path)){