Added conditional compilation and Const namespace with OS name
This commit is contained in:
@@ -768,10 +768,23 @@ register_ast_file(Token *pos, String absolute_file_path, Ast_Module *module, B32
|
||||
return file;
|
||||
}
|
||||
|
||||
function Intern_String
|
||||
preprocess_filename(Token *token_filename){
|
||||
Scratch scratch;
|
||||
String filename = token_filename->intern_val.s;
|
||||
Array<String_Replace> replace = {scratch};
|
||||
replace.add({"$OS"_s, OS_NAME});
|
||||
replace.add({"$os"_s, OS_NAME_LOWER});
|
||||
String result0 = string_replace(scratch, filename, replace);
|
||||
Intern_String result = pctx->intern(result0);
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_File *
|
||||
parse_load(B32 global_implicit_load){
|
||||
Token *file = token_expect(TK_StringLit);
|
||||
String absolute_path = string_fmt(pctx->perm, "%Q/%Q", pctx->currently_parsed_file->module->absolute_base_folder, file->intern_val);
|
||||
Intern_String filename = preprocess_filename(file);
|
||||
String absolute_path = string_fmt(pctx->perm, "%Q/%Q", pctx->currently_parsed_file->module->absolute_base_folder, filename);
|
||||
Ast_File *result = register_ast_file(file, absolute_path, pctx->currently_parsed_file->module, global_implicit_load);
|
||||
return result;
|
||||
}
|
||||
@@ -780,7 +793,8 @@ function Ast_Module *add_module(Token *pos, Intern_String filename, B32 command_
|
||||
function Ast_Module *
|
||||
parse_import(B32 global_implicit_import){
|
||||
Token *file = token_expect(TK_StringLit);
|
||||
Ast_Module *result = add_module(file, file->intern_val);
|
||||
Intern_String filename = preprocess_filename(file);
|
||||
Ast_Module *result = add_module(file, filename);
|
||||
if(global_implicit_import){
|
||||
add_implicit_import(pctx->currently_parsed_file->module, result);
|
||||
}
|
||||
@@ -823,7 +837,7 @@ parse_decl(B32 is_global){
|
||||
|
||||
else if(token_match_pound(pctx->intern("import"_s))){
|
||||
Ast_Module *module = parse_import(false);
|
||||
result = ast_module_namespace(tname, module, tname->intern_val);
|
||||
result = ast_namespace(tname, module, tname->intern_val);
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
Reference in New Issue
Block a user