Enum ExternalName
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§
§impl ExternalName
impl ExternalName
pub fn testcase<T>(v: T) -> ExternalName
pub fn testcase<T>(v: T) -> ExternalName
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");
pub fn user(func_ref: UserExternalNameRef) -> ExternalName
pub fn user(func_ref: UserExternalNameRef) -> ExternalName
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");
Trait Implementations§
§impl Clone for ExternalName
impl Clone for ExternalName
§fn clone(&self) -> ExternalName
fn clone(&self) -> ExternalName
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ExternalName
impl Debug for ExternalName
§impl Default for ExternalName
impl Default for ExternalName
§fn default() -> ExternalName
fn default() -> ExternalName
§impl<'de> Deserialize<'de> for ExternalName
impl<'de> Deserialize<'de> for ExternalName
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExternalName, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExternalName, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl FromStr for ExternalName
impl FromStr for ExternalName
§impl Hash for ExternalName
impl Hash for ExternalName
§impl PartialEq for ExternalName
impl PartialEq for ExternalName
§impl Serialize for ExternalName
impl Serialize for ExternalName
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for ExternalName
impl StructuralPartialEq for ExternalName
Auto Trait Implementations§
impl Freeze for ExternalName
impl RefUnwindSafe for ExternalName
impl Send for ExternalName
impl Sync for ExternalName
impl Unpin for ExternalName
impl UnwindSafe for ExternalName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.