Module relative folders working

This commit is contained in:
Krzosa Karol
2022-06-27 10:24:58 +02:00
parent 6644a2c5ae
commit 15d452cae3
8 changed files with 42 additions and 21 deletions

View File

@@ -712,26 +712,11 @@ add_implicit_import(Ast_Scope *scope, Ast_Scope *add){
}
}
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);
String absolute_path = string_fmt(pctx->perm, "%Q/%Q", module->base_folder, filename);
Ast_File *file = 0;
For(pctx->files){
@@ -777,7 +762,7 @@ parse_load(B32 global_implicit_load){
return result;
}
function Ast_Module *add_module(Token *pos, Intern_String filename);
function Ast_Module *add_module(Token *pos, Intern_String filename, B32 command_line_module = false);
function Ast_Module *
parse_import(B32 global_implicit_import){
Token *file = token_expect(TK_StringLit);