fix: path handling bug

This commit is contained in:
Shunsuke Shibayama 2024-01-21 02:26:58 +09:00
parent 74d304a1b7
commit cfc2214bfb
8 changed files with 26 additions and 21 deletions

View file

@ -2968,7 +2968,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
let mut builder = GenericHIRBuilder::<A>::new_submodule(mod_ctx, &mod_name);
builder.lowerer.module.context.cfg.input = inline.input.clone();
builder.cfg_mut().input = inline.input.clone();
let mode = if path.to_string_lossy().ends_with("d.er") {
let mode = if path.to_string_lossy().ends_with(".d.er") {
"declare"
} else {
"exec"
@ -2985,7 +2985,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
}
};
let ctx = builder.pop_mod_ctx().unwrap();
let cache = if path.to_string_lossy().ends_with("d.er") {
let cache = if path.to_string_lossy().ends_with(".d.er") {
&self.module.context.shared().py_mod_cache
} else {
&self.module.context.shared().mod_cache

View file

@ -97,7 +97,7 @@ impl SharedCompilerResource {
}
pub fn insert_module(&self, path: NormalizedPathBuf, entry: ModuleEntry) {
if path.to_string_lossy().ends_with("d.er") {
if path.to_string_lossy().ends_with(".d.er") {
self.py_mod_cache.insert(path, entry);
} else {
self.mod_cache.insert(path, entry);
@ -105,7 +105,7 @@ impl SharedCompilerResource {
}
pub fn remove_module(&self, path: &std::path::Path) -> Option<ModuleEntry> {
if path.to_string_lossy().ends_with("d.er") {
if path.to_string_lossy().ends_with(".d.er") {
self.py_mod_cache.remove(path)
} else {
self.mod_cache.remove(path)
@ -113,7 +113,7 @@ impl SharedCompilerResource {
}
pub fn get_module(&self, path: &std::path::Path) -> Option<MappedRwLockReadGuard<ModuleEntry>> {
if path.to_string_lossy().ends_with("d.er") {
if path.to_string_lossy().ends_with(".d.er") {
self.py_mod_cache.get(path)
} else {
self.mod_cache.get(path)
@ -121,7 +121,7 @@ impl SharedCompilerResource {
}
pub fn raw_ref_ctx(&self, path: &std::path::Path) -> Option<&ModuleContext> {
if path.to_string_lossy().ends_with("d.er") {
if path.to_string_lossy().ends_with(".d.er") {
self.py_mod_cache.raw_ref_ctx(path)
} else {
self.mod_cache.raw_ref_ctx(path)