fix: module name contains file extension
This commit is contained in:
parent
55cd8cac40
commit
3092173d72
|
@ -242,7 +242,7 @@ static int compile_module_with_dependencies(ModuleFileStack* unit,
|
|||
module_ref->module_path = mem_new_g_array(MemoryNamespaceOpt, sizeof(char*));
|
||||
}
|
||||
|
||||
module_ref_push(module_ref, g_filename_display_basename(file->path));
|
||||
module_ref_push(module_ref, module_from_basename(file->path));
|
||||
|
||||
GHashTable* imports =
|
||||
mem_new_g_hash_table(MemoryNamespaceAst, g_str_hash, g_str_equal);
|
||||
|
@ -370,7 +370,7 @@ static int compile_module_with_dependencies(ModuleFileStack* unit,
|
|||
continue;
|
||||
}
|
||||
|
||||
module_ref_push(module_ref, g_filename_display_basename(path));
|
||||
module_ref_push(module_ref, module_from_basename(path));
|
||||
|
||||
ModuleFile* imported_file = push_file(unit, path);
|
||||
AST_NODE_PTR imported_module =
|
||||
|
|
|
@ -58,6 +58,17 @@ ModuleFile* push_file(ModuleFileStack* stack, const char* path) {
|
|||
return new_file;
|
||||
}
|
||||
|
||||
char* module_from_basename(char* path) {
|
||||
char* basename = g_path_get_basename(path);
|
||||
char* dot = strrchr(basename, '.');
|
||||
|
||||
if (dot != NULL) {
|
||||
*dot = '\0';
|
||||
}
|
||||
|
||||
return basename;
|
||||
}
|
||||
|
||||
void delete_files(ModuleFileStack* stack) {
|
||||
for (size_t i = 0; i < stack->files->len; i++) {
|
||||
const ModuleFile* file = g_array_index(stack->files, ModuleFile*, i);
|
||||
|
|
|
@ -42,6 +42,8 @@ typedef struct TokenLocation_t {
|
|||
ModuleRef* module_ref;
|
||||
} TokenLocation;
|
||||
|
||||
char* module_from_basename(char* path);
|
||||
|
||||
/**
|
||||
* @brief Create a new, empty file stack.
|
||||
* @return
|
||||
|
|
Loading…
Reference in New Issue