Add intrinsic_name
to get plain intrinsic name
This commit is contained in:
parent
74acabe9b0
commit
68fc92242f
4 changed files with 35 additions and 1 deletions
|
@ -183,6 +183,7 @@ pub trait Context {
|
|||
fn vtable_allocation(&self, global_alloc: &GlobalAlloc) -> Option<AllocId>;
|
||||
fn krate(&self, def_id: DefId) -> Crate;
|
||||
fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol;
|
||||
fn intrinsic_name(&self, def: InstanceDef) -> Symbol;
|
||||
|
||||
/// Return information about the target machine.
|
||||
fn target_info(&self) -> MachineInfo;
|
||||
|
|
|
@ -90,6 +90,17 @@ impl Instance {
|
|||
with(|context| context.instance_name(self.def, true))
|
||||
}
|
||||
|
||||
/// Retrieve the plain intrinsic name of an instance if it's an intrinsic.
|
||||
///
|
||||
/// The plain name does not include type arguments (as `trimmed_name` does),
|
||||
/// which is more convenient to match with intrinsic symbols.
|
||||
pub fn intrinsic_name(&self) -> Option<Symbol> {
|
||||
match self.kind {
|
||||
InstanceKind::Intrinsic => Some(with(|context| context.intrinsic_name(self.def))),
|
||||
InstanceKind::Item | InstanceKind::Virtual { .. } | InstanceKind::Shim => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve an instance starting from a function definition and generic arguments.
|
||||
pub fn resolve(def: FnDef, args: &GenericArgs) -> Result<Instance, crate::Error> {
|
||||
with(|context| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue