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§

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");

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");

Returns a display for the current ExternalName, with extra context to prettify the output.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.