This commit is contained in:
elfein 2021-11-11 00:54:09 -08:00
parent ae7719371f
commit 6459eb61e2
2 changed files with 4 additions and 4 deletions

View file

@ -12,7 +12,7 @@ pub const KILL: usize = 0;
struct HostFunctions;
impl HostFunctions {
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
let (params, ret_ty): (&[ValueType], Option<ValueType>) = match index {
let (params, ret_ty): (&[ValueType], Option<ValueType>) = match index.into() {
SysCall::KILL => (&[ValueType::I32, ValueType::I32], Some(ValueType::I32)),
_ => return false,
};
@ -26,7 +26,7 @@ impl Externals for HostFunctions {
index: usize,
args: RuntimeArgs,
) -> Result<Option<RuntimeValue>, Trap> {
match index {
match index.into() {
SysCall::KILL => {
let a: u32 = args.nth_checked(0)?;
let b: u32 = args.nth_checked(1)?;
@ -41,7 +41,7 @@ impl Externals for HostFunctions {
impl ModuleImportResolver for HostFunctions {
fn resolve_func(&self, field_name: &str, signature: &Signature) -> Result<FuncRef, Error> {
let index = match field_name {
"add" => SysCall::KILL,
"add" => SysCall::KILL as usize,
_ => {
return Err(Error::Instantiation(format!(
"Export {} not found",

View file

@ -33,7 +33,7 @@ pub enum SysCall {
// Security Syscalls
ENCRYPT = 50,
EMPTY = usize::MAX,
EMPTY = u32::MAX as usize,
}
impl From<usize> for SysCall {