Don't require check_signature.

This commit is contained in:
Sergey Pepyakin 2018-01-15 14:49:28 +03:00
parent 43d446b04c
commit e9d05f3bc5
4 changed files with 2 additions and 30 deletions

View File

@ -180,18 +180,6 @@ impl<'a> Externals for Runtime<'a> {
_ => panic!("unknown function index")
}
}
fn check_signature(&self, index: usize, sig: &FunctionType) -> bool {
match index {
SET_FUNC_INDEX => {
sig.params() == &[ValueType::I32] && sig.return_type() == None
}
GET_FUNC_INDEX => {
sig.params() == &[ValueType::I32] && sig.return_type() == Some(ValueType::I32)
}
_ => panic!("unknown function index")
}
}
}
struct RuntimeModuleImportResolver;

View File

@ -81,13 +81,6 @@ impl Externals for SpecModule {
_ => panic!("SpecModule doesn't provide function at index {}", index),
}
}
fn check_signature(&self, index: usize, _signature: &FunctionType) -> bool {
match index {
PRINT_FUNC_INDEX => true,
_ => false,
}
}
}
impl ModuleImportResolver for SpecModule {

View File

@ -1,5 +1,4 @@
use std::any::TypeId;
use elements::FunctionType;
use interpreter::value::RuntimeValue;
use interpreter::Error;
@ -38,8 +37,6 @@ pub trait Externals {
index: usize,
args: &[RuntimeValue],
) -> Result<Option<RuntimeValue>, Error>;
fn check_signature(&self, index: usize, signature: &FunctionType) -> bool;
}
pub struct NopExternals;
@ -52,8 +49,4 @@ impl Externals for NopExternals {
) -> Result<Option<RuntimeValue>, Error> {
Err(Error::Trap("invoke index on no-op externals".into()))
}
fn check_signature(&self, _index: usize, _signature: &FunctionType) -> bool {
false
}
}

View File

@ -141,7 +141,9 @@ impl Externals for TestHost {
_ => panic!("env doesn't provide function at index {}", index),
}
}
}
impl TestHost {
fn check_signature(&self, index: usize, func_type: &FunctionType) -> bool {
if index == RECURSE_FUNC_INDEX {
// This function requires special handling because it is polymorphic.
@ -477,10 +479,6 @@ fn defer_providing_externals() {
_ => panic!("env module doesn't provide function at index {}", index),
}
}
fn check_signature(&self, _index: usize, func_type: &FunctionType) -> bool {
func_type.params() == &[ValueType::I32] && func_type.return_type() == None
}
}
let module = parse_wat(