fix build and address comments
This commit is contained in:
parent
4eb8608c1e
commit
d340b99016
|
@ -13,8 +13,8 @@ use wasmi::{
|
||||||
GlobalInstance, GlobalRef, ImportResolver, ImportsBuilder,
|
GlobalInstance, GlobalRef, ImportResolver, ImportsBuilder,
|
||||||
MemoryInstance, MemoryRef, ModuleImportResolver, ModuleInstance,
|
MemoryInstance, MemoryRef, ModuleImportResolver, ModuleInstance,
|
||||||
ModuleRef, RuntimeValue, TableInstance, TableRef, ValueType,
|
ModuleRef, RuntimeValue, TableInstance, TableRef, ValueType,
|
||||||
load_from_buffer, LoadedModule, Signature, MemoryDescriptor,
|
load_from_buffer, LoadedModule, Signature, MemoryDescriptor,
|
||||||
TableDescriptor, GlobalDescriptor, FuncInstance,
|
TableDescriptor, GlobalDescriptor, FuncInstance, RuntimeArgs,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -57,7 +57,7 @@ impl Externals for SpecModule {
|
||||||
fn invoke_index(
|
fn invoke_index(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: usize,
|
index: usize,
|
||||||
args: &[RuntimeValue],
|
args: RuntimeArgs,
|
||||||
) -> Result<Option<RuntimeValue>, InterpreterError> {
|
) -> Result<Option<RuntimeValue>, InterpreterError> {
|
||||||
match index {
|
match index {
|
||||||
PRINT_FUNC_INDEX => {
|
PRINT_FUNC_INDEX => {
|
||||||
|
|
|
@ -3,6 +3,7 @@ use value::{RuntimeValue, TryInto};
|
||||||
use Error;
|
use Error;
|
||||||
|
|
||||||
/// Safe wrapper for list of arguments
|
/// Safe wrapper for list of arguments
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct RuntimeArgs<'a>(&'a [RuntimeValue]);
|
pub struct RuntimeArgs<'a>(&'a [RuntimeValue]);
|
||||||
|
|
||||||
impl<'a> From<&'a [RuntimeValue]> for RuntimeArgs<'a> {
|
impl<'a> From<&'a [RuntimeValue]> for RuntimeArgs<'a> {
|
||||||
|
@ -94,4 +95,9 @@ mod tests {
|
||||||
assert_eq!(val, 0);
|
assert_eq!(val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn i64_invalid_arg_cast() {
|
||||||
|
let args: RuntimeArgs = (&[RuntimeValue::I64(90534534545322)][..]).into();
|
||||||
|
assert!(args.nth::<i32>(0).is_err());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
use {
|
use {
|
||||||
Error, Signature, Externals, FuncInstance, FuncRef, HostError, ImportsBuilder,
|
Error, Signature, Externals, FuncInstance, FuncRef, HostError, ImportsBuilder,
|
||||||
MemoryInstance, MemoryRef, TableInstance, TableRef, ModuleImportResolver, ModuleInstance, ModuleRef,
|
MemoryInstance, MemoryRef, TableInstance, TableRef, ModuleImportResolver, ModuleInstance, ModuleRef,
|
||||||
RuntimeValue, TryInto, LoadedModule, load_from_buffer, TableDescriptor, MemoryDescriptor,
|
RuntimeValue, RuntimeArgs, LoadedModule, load_from_buffer, TableDescriptor, MemoryDescriptor,
|
||||||
RuntimeArgs,
|
|
||||||
};
|
};
|
||||||
use types::ValueType;
|
use types::ValueType;
|
||||||
use wabt::wat2wasm;
|
use wabt::wat2wasm;
|
||||||
|
|
Loading…
Reference in New Issue