Enum cranelift_codegen::ir::ExternalName
source · [−]pub enum ExternalName {
User(UserExternalNameRef),
TestCase(TestcaseName),
LibCall(LibCall),
KnownSymbol(KnownSymbol),
}
Expand description
The name of an external is either a reference to a user-defined symbol table, or a short sequence of ascii bytes so that test cases do not have to keep track of a symbol table.
External names are primarily used as keys by code using Cranelift to map
from a cranelift_codegen::ir::FuncRef
or similar to additional associated
data.
External names can also serve as a primitive testing and debugging tool.
In particular, many .clif
test files use function names to identify
functions.
Variants
User(UserExternalNameRef)
A reference to a name in a user-defined symbol table.
TestCase(TestcaseName)
A test case function name of up to a hardcoded amount of ascii characters. This is not intended to be used outside test cases.
LibCall(LibCall)
A well-known runtime library function.
KnownSymbol(KnownSymbol)
A well-known symbol.
Implementations
sourceimpl ExternalName
impl ExternalName
sourcepub fn testcase<T: AsRef<[u8]>>(v: T) -> Self
pub fn testcase<T: AsRef<[u8]>>(v: T) -> Self
Creates a new external name from a sequence of bytes. Caller is expected
to guarantee bytes are only ascii alphanumeric or _
.
Examples
// Create `ExternalName` from a string.
let name = ExternalName::testcase("hello");
assert_eq!(name.display(None).to_string(), "%hello");
sourcepub fn user(func_ref: UserExternalNameRef) -> Self
pub fn user(func_ref: UserExternalNameRef) -> Self
Create a new external name from a user-defined external function reference.
Examples
let user_func_ref: UserExternalNameRef = Default::default(); // usually obtained with `Function::declare_imported_user_function()`
let name = ExternalName::user(user_func_ref);
assert_eq!(name.display(None).to_string(), "userextname0");
sourcepub fn display<'a>(
&'a self,
params: Option<&'a FunctionParameters>
) -> DisplayableExternalName<'a>
pub fn display<'a>(
&'a self,
params: Option<&'a FunctionParameters>
) -> DisplayableExternalName<'a>
Returns a display for the current ExternalName
, with extra context to prettify the
output.
Trait Implementations
sourceimpl Clone for ExternalName
impl Clone for ExternalName
sourcefn clone(&self) -> ExternalName
fn clone(&self) -> ExternalName
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ExternalName
impl Debug for ExternalName
sourceimpl Default for ExternalName
impl Default for ExternalName
sourceimpl FromStr for ExternalName
impl FromStr for ExternalName
sourceimpl Hash for ExternalName
impl Hash for ExternalName
sourceimpl PartialEq<ExternalName> for ExternalName
impl PartialEq<ExternalName> for ExternalName
sourcefn eq(&self, other: &ExternalName) -> bool
fn eq(&self, other: &ExternalName) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ExternalName) -> bool
fn ne(&self, other: &ExternalName) -> bool
This method tests for !=
.
impl Eq for ExternalName
impl StructuralEq for ExternalName
impl StructuralPartialEq for ExternalName
Auto Trait Implementations
impl RefUnwindSafe for ExternalName
impl Send for ExternalName
impl Sync for ExternalName
impl Unpin for ExternalName
impl UnwindSafe for ExternalName
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more