mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-01 09:31:32 +00:00
Fix wasmer binary
This commit is contained in:
@ -164,14 +164,27 @@ pub enum Backend {
|
||||
}
|
||||
|
||||
impl Backend {
|
||||
/// Get a list of the currently enabled (via feature flag) backends.
|
||||
pub fn variants() -> &'static [&'static str] {
|
||||
&[
|
||||
#[cfg(feature = "singlepass")]
|
||||
"singlepass",
|
||||
#[cfg(feature = "cranelift")]
|
||||
"cranelift",
|
||||
#[cfg(feature = "llvm")]
|
||||
"llvm",
|
||||
"auto",
|
||||
]
|
||||
}
|
||||
|
||||
/// Stable string representation of the backend.
|
||||
/// It can be used as part of a cache key, for example.
|
||||
pub fn to_string(&self) -> &'static str {
|
||||
match self {
|
||||
#[cfg(feature = "cranelift")]
|
||||
Backend::Cranelift => "cranelift",
|
||||
#[cfg(feature = "singlepass")]
|
||||
Backend::Singlepass => "singlepass",
|
||||
#[cfg(feature = "cranelift")]
|
||||
Backend::Cranelift => "cranelift",
|
||||
#[cfg(feature = "llvm")]
|
||||
Backend::LLVM => "llvm",
|
||||
Backend::Auto => "auto",
|
||||
@ -192,6 +205,22 @@ impl Default for Backend {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Backend {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Backend, String> {
|
||||
match s.to_lowercase().as_str() {
|
||||
#[cfg(feature = "singlepass")]
|
||||
"singlepass" => Ok(Backend::Singlepass),
|
||||
#[cfg(feature = "cranelift")]
|
||||
"cranelift" => Ok(Backend::Cranelift),
|
||||
#[cfg(feature = "llvm")]
|
||||
"llvm" => Ok(Backend::LLVM),
|
||||
"auto" => Ok(Backend::Auto),
|
||||
_ => Err(format!("The backend {} doesn't exist", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Compile WebAssembly binary code into a [`Module`].
|
||||
/// This function is useful if it is necessary to
|
||||
/// compile a module before it can be instantiated
|
||||
|
Reference in New Issue
Block a user