Skip to content

Commit

Permalink
fix: query ModuleImportInfo::aliases with module id alias
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed May 6, 2024
1 parent 5f621db commit 820cd76
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 202 deletions.
2 changes: 1 addition & 1 deletion frontend-wasm/src/miden_abi/stdlib/crypto/hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ pub(crate) fn signatures() -> ModuleFunctionTypeMap {
[Felt, Felt, Felt, Felt, Felt, Felt, Felt, Felt],
),
);
m.insert("miden:prelude/std_crypto_hashes", crypto);
m.insert("std::crypto_hashes", crypto);
m
}
15 changes: 10 additions & 5 deletions hir/src/asm/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ impl ModuleImportInfo {
let module_id = id.module;
match self.modules.entry(module_id) {
Entry::Vacant(entry) => {
let alias = match module_id.as_str().rsplit_once("::") {
None => module_id.as_symbol(),
Some((_, alias)) => Symbol::intern(alias),
};
let alias = module_id_alias(module_id);
let span = module_id.span();
let alias_id = if self.aliases.contains_key(&alias) {
// The alias is already used by another module, we must
Expand Down Expand Up @@ -69,7 +66,8 @@ impl ModuleImportInfo {
self.functions.entry(alias_id).or_default().insert(id);
}
Entry::Occupied(_) => {
let alias = self.aliases[&module_id];
let module_id_alias = module_id_alias(module_id);
let alias = self.aliases[&module_id_alias];
let functions = self.functions.entry(alias).or_default();
functions.insert(id);
}
Expand Down Expand Up @@ -137,6 +135,13 @@ impl ModuleImportInfo {
}
}

fn module_id_alias(module_id: Ident) -> Symbol {
match module_id.as_str().rsplit_once("::") {
None => module_id.as_symbol(),
Some((_, alias)) => Symbol::intern(alias),
}
}

/// This represents an import statement in Miden Assembly
#[derive(Debug, Copy, Clone, Spanned)]
pub struct MasmImport {
Expand Down
Loading

0 comments on commit 820cd76

Please sign in to comment.