fixed: wrong file in imported AST

This commit is contained in:
Sven Vogel 2024-06-13 00:15:36 +02:00
parent b23ce945ea
commit 657efa3ebe
3 changed files with 5 additions and 5 deletions

View File

@ -200,7 +200,6 @@ static int compile_module_with_dependencies(ModuleFileStack *unit, ModuleFile* f
AST_NODE_PTR child = AST_get_node(root_module, i);
if (child->kind == AST_Import) {
AST_NODE_PTR imported_module = AST_new_node(empty_location(), AST_Module, NULL);
const char* path = get_absolute_import_path(target, child->value);
if (path == NULL) {
@ -208,6 +207,7 @@ static int compile_module_with_dependencies(ModuleFileStack *unit, ModuleFile* f
}
ModuleFile *imported_file = push_file(unit, path);
AST_NODE_PTR imported_module = AST_new_node(empty_location(imported_file), AST_Module, NULL);
if (compile_file_to_ast(imported_module, imported_file) == EXIT_SUCCESS) {
AST_merge_modules(root_module, i + 1, imported_module);
@ -232,7 +232,7 @@ static void build_target(ModuleFileStack *unit, const TargetConfig *target) {
print_message(Info, "Building target: %s", target->name);
ModuleFile *file = push_file(unit, target->root_module);
AST_NODE_PTR root_module = AST_new_node(empty_location(), AST_Module, NULL);
AST_NODE_PTR root_module = AST_new_node(empty_location(file), AST_Module, NULL);
if (compile_module_with_dependencies(unit, file, target, root_module) == EXIT_SUCCESS) {
if (root_module != NULL) {

View File

@ -208,14 +208,14 @@ TokenLocation new_location(unsigned long int line_start, unsigned long int col_s
return location;
}
TokenLocation empty_location(void) {
TokenLocation empty_location(ModuleFile* file) {
TokenLocation location;
location.line_start = 0;
location.line_end = 0;
location.col_start = 0;
location.col_end = 0;
location.file = NULL;
location.file = file;
return location;
}

View File

@ -82,7 +82,7 @@ TokenLocation new_location(unsigned long int line_start, unsigned long int col_s
* @brief Create a new empty location with all of its contents set to zero
* @return
*/
TokenLocation empty_location(void);
TokenLocation empty_location(ModuleFile* file);
/**
* @brief Prints some diagnostic message to stdout.