fix build and address comments

This commit is contained in:
NikVolf 2018-01-23 14:42:20 +03:00
parent 4eb8608c1e
commit d340b99016
3 changed files with 10 additions and 5 deletions

View File

@ -14,7 +14,7 @@ use wasmi::{
MemoryInstance, MemoryRef, ModuleImportResolver, ModuleInstance,
ModuleRef, RuntimeValue, TableInstance, TableRef, ValueType,
load_from_buffer, LoadedModule, Signature, MemoryDescriptor,
TableDescriptor, GlobalDescriptor, FuncInstance,
TableDescriptor, GlobalDescriptor, FuncInstance, RuntimeArgs,
};
#[derive(Debug)]
@ -57,7 +57,7 @@ impl Externals for SpecModule {
fn invoke_index(
&mut self,
index: usize,
args: &[RuntimeValue],
args: RuntimeArgs,
) -> Result<Option<RuntimeValue>, InterpreterError> {
match index {
PRINT_FUNC_INDEX => {

View File

@ -3,6 +3,7 @@ use value::{RuntimeValue, TryInto};
use Error;
/// Safe wrapper for list of arguments
#[derive(Debug)]
pub struct RuntimeArgs<'a>(&'a [RuntimeValue]);
impl<'a> From<&'a [RuntimeValue]> for RuntimeArgs<'a> {
@ -94,4 +95,9 @@ mod tests {
assert_eq!(val, 0);
}
#[test]
fn i64_invalid_arg_cast() {
let args: RuntimeArgs = (&[RuntimeValue::I64(90534534545322)][..]).into();
assert!(args.nth::<i32>(0).is_err());
}
}

View File

@ -1,8 +1,7 @@
use {
Error, Signature, Externals, FuncInstance, FuncRef, HostError, ImportsBuilder,
MemoryInstance, MemoryRef, TableInstance, TableRef, ModuleImportResolver, ModuleInstance, ModuleRef,
RuntimeValue, TryInto, LoadedModule, load_from_buffer, TableDescriptor, MemoryDescriptor,
RuntimeArgs,
RuntimeValue, RuntimeArgs, LoadedModule, load_from_buffer, TableDescriptor, MemoryDescriptor,
};
use types::ValueType;
use wabt::wat2wasm;