Skip to content

Commit

Permalink
fix NameResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Jul 18, 2024
1 parent 1b5a1b5 commit 9bb9ed5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions assembly/src/assembler/module_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ impl WrapperModule {
}
}

pub fn unwrap_ast(&self) -> Arc<Module> {
pub fn unwrap_ast(&self) -> &Arc<Module> {
match self {
WrapperModule::Ast(module) => module.clone(),
WrapperModule::Ast(module) => module,
WrapperModule::Exports(_) => {
panic!("expected module to be in AST representation, but was compiled")
}
Expand Down Expand Up @@ -558,7 +558,7 @@ impl ModuleGraph {
/// Fetch a [WrapperProcedure] by [GlobalProcedureIndex], or `None` if index is invalid.
pub fn get_procedure(&self, id: GlobalProcedureIndex) -> Option<WrapperProcedure> {
match &self.modules[id.module.as_usize()] {
WrapperModule::Ast(m) => m.get(id.index).map(|export| WrapperProcedure::Ast(export)),
WrapperModule::Ast(m) => m.get(id.index).map(WrapperProcedure::Ast),
WrapperModule::Exports(m) => m
.procedures
.get(id.index.as_usize())
Expand Down
9 changes: 5 additions & 4 deletions assembly/src/assembler/module_graph/name_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'a> NameResolver<'a> {
.get_name(gid.index)
.clone()
} else {
self.graph[gid].name().clone()
self.graph.get_procedure_unsafe(gid).name().clone()
};
Ok(ResolvedTarget::Resolved {
gid,
Expand Down Expand Up @@ -210,6 +210,7 @@ impl<'a> NameResolver<'a> {
.resolve_import(name)
} else {
self.graph[caller.module]
.unwrap_ast()
.resolve_import(name)
.map(|import| Span::new(import.span(), import.path()))
}
Expand Down Expand Up @@ -255,7 +256,7 @@ impl<'a> NameResolver<'a> {
.get_name(gid.index)
.clone()
} else {
self.graph[gid].name().clone()
self.graph.get_procedure_unsafe(gid).name().clone()
};
Ok(ResolvedTarget::Resolved {
gid,
Expand Down Expand Up @@ -315,7 +316,7 @@ impl<'a> NameResolver<'a> {
if module_index >= pending_offset {
self.pending[module_index - pending_offset].resolver.resolve(callee)
} else {
self.graph[module].resolve(callee)
self.graph[module].unwrap_ast().resolve(callee)
}
}

Expand Down Expand Up @@ -487,7 +488,7 @@ impl<'a> NameResolver<'a> {
if module_index >= pending_offset {
self.pending[module_index - pending_offset].source_file.clone()
} else {
self.graph[module].source_file()
self.graph[module].unwrap_ast().source_file()
}
}

Expand Down

0 comments on commit 9bb9ed5

Please sign in to comment.