Preparing to add a module folder
This commit is contained in:
@@ -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);
|
String main_module = string_fmt(ctx->perm, "%Q/modules", ctx->exe_folder);
|
||||||
ctx->module_folders.add(main_module);
|
ctx->module_folders.add(main_module);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
21
parsing.cpp
21
parsing.cpp
@@ -712,14 +712,27 @@ add_implicit_import(Ast_Scope *scope, Ast_Scope *add){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum{
|
function String
|
||||||
GLOBAL_IMPLICIT_LOAD = 1
|
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 *
|
function Ast_File *
|
||||||
register_ast_file(Token *pos, Intern_String filename, Ast_Module *module, B32 global_implicit_load){
|
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;
|
Ast_File *file = 0;
|
||||||
String absolute_path = os_get_absolute_path(pctx->perm, filename.s);
|
|
||||||
|
|
||||||
For(pctx->files){
|
For(pctx->files){
|
||||||
if(string_compare(it->absolute_path, absolute_path)){
|
if(string_compare(it->absolute_path, absolute_path)){
|
||||||
|
|||||||
Reference in New Issue
Block a user