mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-04-25 15:22:17 +00:00
Clean
This commit is contained in:
parent
ea980415f6
commit
ea6275cc9d
@ -15,9 +15,8 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Intrepreter initialization.
|
// Intrepreter initialization.
|
||||||
// parity_wasm::DefaultProgramInstance parametrize ProgramInstance with a pre-defined "DummyUserError"
|
// It also initializes a default "env" module.
|
||||||
// Initializes a default "env" module also.
|
let program = parity_wasm::ProgramInstance::with_env_params(
|
||||||
let program = parity_wasm::DefaultProgramInstance::with_env_params(
|
|
||||||
interpreter::EnvParams {
|
interpreter::EnvParams {
|
||||||
total_stack: 128*1024,
|
total_stack: 128*1024,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -16,9 +16,8 @@ fn main() {
|
|||||||
let (_, program_args) = args.split_at(3);
|
let (_, program_args) = args.split_at(3);
|
||||||
|
|
||||||
// Intrepreter initialization.
|
// Intrepreter initialization.
|
||||||
// parity_wasm::DefaultProgramInstance parametrize ProgramInstance with a pre-defined "DummyUserError"
|
// It also initializes a default "env" module.
|
||||||
// Initializes a default "env" module also.
|
let program = parity_wasm::ProgramInstance::with_env_params(
|
||||||
let program = parity_wasm::DefaultProgramInstance::with_env_params(
|
|
||||||
interpreter::EnvParams {
|
interpreter::EnvParams {
|
||||||
total_stack: 128*1024,
|
total_stack: 128*1024,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -11,10 +11,9 @@ use test;
|
|||||||
use parity_wasm::{self, elements, builder};
|
use parity_wasm::{self, elements, builder};
|
||||||
use parity_wasm::interpreter::{
|
use parity_wasm::interpreter::{
|
||||||
RuntimeValue,
|
RuntimeValue,
|
||||||
DefaultProgramInstance, DefaultModuleInstance,
|
ProgramInstance, ModuleInstance,
|
||||||
ItemIndex, ExportEntryType,
|
ItemIndex, ExportEntryType,
|
||||||
Error as InterpreterError,
|
Error as InterpreterError,
|
||||||
DummyError as DummyInterpreterError,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn spec_test_module() -> elements::Module {
|
fn spec_test_module() -> elements::Module {
|
||||||
@ -42,7 +41,7 @@ fn spec_test_module() -> elements::Module {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_module(base_dir: &str, path: &str, name: &Option<String>, program: &DefaultProgramInstance) -> Arc<DefaultModuleInstance> {
|
fn load_module(base_dir: &str, path: &str, name: &Option<String>, program: &ProgramInstance) -> Arc<ModuleInstance> {
|
||||||
let module = try_deserialize(base_dir, path).expect(&format!("Wasm file {} failed to load", path));
|
let module = try_deserialize(base_dir, path).expect(&format!("Wasm file {} failed to load", path));
|
||||||
|
|
||||||
program.add_module("spectest", spec_test_module(), None).expect("Failed adding 'spectest' module");
|
program.add_module("spectest", spec_test_module(), None).expect("Failed adding 'spectest' module");
|
||||||
@ -58,9 +57,9 @@ fn try_deserialize(base_dir: &str, module_path: &str) -> Result<elements::Module
|
|||||||
parity_wasm::deserialize_file(&wasm_path)
|
parity_wasm::deserialize_file(&wasm_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_load(base_dir: &str, module_path: &str) -> Result<(), DummyInterpreterError> {
|
fn try_load(base_dir: &str, module_path: &str) -> Result<(), InterpreterError> {
|
||||||
let module = try_deserialize(base_dir, module_path).map_err(|e| parity_wasm::interpreter::Error::Program(format!("{:?}", e)))?;
|
let module = try_deserialize(base_dir, module_path).map_err(|e| parity_wasm::interpreter::Error::Program(format!("{:?}", e)))?;
|
||||||
let program = DefaultProgramInstance::new().expect("Failed creating program");
|
let program = ProgramInstance::new().expect("Failed creating program");
|
||||||
program.add_module("try_load", module, None).map(|_| ())
|
program.add_module("try_load", module, None).map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +89,8 @@ fn runtime_values(test_vals: &[test::RuntimeValue]) -> Vec<parity_wasm::RuntimeV
|
|||||||
test_vals.iter().map(runtime_value).collect::<Vec<parity_wasm::RuntimeValue>>()
|
test_vals.iter().map(runtime_value).collect::<Vec<parity_wasm::RuntimeValue>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_action(program: &DefaultProgramInstance, action: &test::Action)
|
fn run_action(program: &ProgramInstance, action: &test::Action)
|
||||||
-> Result<Option<parity_wasm::RuntimeValue>, DummyInterpreterError>
|
-> Result<Option<parity_wasm::RuntimeValue>, InterpreterError>
|
||||||
{
|
{
|
||||||
match *action {
|
match *action {
|
||||||
test::Action::Invoke { ref module, ref field, ref args } => {
|
test::Action::Invoke { ref module, ref field, ref args } => {
|
||||||
@ -149,7 +148,7 @@ pub fn run_wast2wasm(name: &str) -> FixtureParams {
|
|||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,14 +165,14 @@ pub fn spec(name: &str) {
|
|||||||
|
|
||||||
let fixture = run_wast2wasm(name);
|
let fixture = run_wast2wasm(name);
|
||||||
if fixture.failing {
|
if fixture.failing {
|
||||||
panic!("wasm2wast terminated abnormally, expected to success");
|
panic!("wasm2wast terminated abnormally, expected to success");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut f = File::open(&fixture.json)
|
let mut f = File::open(&fixture.json)
|
||||||
.expect(&format!("Failed to load json file {}", &fixture.json));
|
.expect(&format!("Failed to load json file {}", &fixture.json));
|
||||||
let spec: test::Spec = serde_json::from_reader(&mut f).expect("Failed to deserialize JSON file");
|
let spec: test::Spec = serde_json::from_reader(&mut f).expect("Failed to deserialize JSON file");
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().expect("Failed creating program");
|
let program = ProgramInstance::new().expect("Failed creating program");
|
||||||
let mut last_module = None;
|
let mut last_module = None;
|
||||||
for command in &spec.commands {
|
for command in &spec.commands {
|
||||||
println!("command {:?}", command);
|
println!("command {:?}", command);
|
||||||
@ -241,7 +240,7 @@ pub fn spec(name: &str) {
|
|||||||
panic!("Expected action to result in a trap, got result: {:?}", result);
|
panic!("Expected action to result in a trap, got result: {:?}", result);
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("assert_trap at line {} - success ({:?})", line, e);
|
println!("assert_trap at line {} - success ({:?})", line, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -204,7 +204,7 @@ fn calculate_memory_size(old_size: u32, additional_pages: u32, maximum_size: u32
|
|||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::MemoryInstance;
|
use super::MemoryInstance;
|
||||||
use interpreter::{Error, DummyUserError};
|
use interpreter::Error;
|
||||||
use elements::MemoryType;
|
use elements::MemoryType;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -5,27 +5,30 @@ use std::any::TypeId;
|
|||||||
/// Custom user error.
|
/// Custom user error.
|
||||||
pub trait UserError: 'static + ::std::fmt::Display + ::std::fmt::Debug {
|
pub trait UserError: 'static + ::std::fmt::Display + ::std::fmt::Debug {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn __private_get_type_id__(&self) -> TypeId {
|
fn __private_get_type_id__(&self) -> TypeId {
|
||||||
TypeId::of::<Self>()
|
TypeId::of::<Self>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserError {
|
impl UserError {
|
||||||
|
/// Attempt to downcast this `UserError` to a concrete type by reference.
|
||||||
pub fn downcast_ref<T: UserError>(&self) -> Option<&T> {
|
pub fn downcast_ref<T: UserError>(&self) -> Option<&T> {
|
||||||
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
||||||
unsafe { Some(&*(self as *const UserError as *const T)) }
|
unsafe { Some(&*(self as *const UserError as *const T)) }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attempt to downcast this `UserError` to a concrete type by mutable
|
||||||
|
/// reference.
|
||||||
pub fn downcast_mut<T: UserError>(&mut self) -> Option<&mut T> {
|
pub fn downcast_mut<T: UserError>(&mut self) -> Option<&mut T> {
|
||||||
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
||||||
unsafe { Some(&mut *(self as *mut UserError as *mut T)) }
|
unsafe { Some(&mut *(self as *mut UserError as *mut T)) }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Internal interpreter error.
|
/// Internal interpreter error.
|
||||||
@ -111,16 +114,6 @@ impl ::std::fmt::Display for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dummy user error.
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
|
||||||
pub struct DummyUserError;
|
|
||||||
|
|
||||||
impl UserError for DummyUserError {}
|
|
||||||
|
|
||||||
impl ::std::fmt::Display for DummyUserError {
|
|
||||||
fn fmt(&self, _f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { Ok(()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<U> From<U> for Error where U: UserError + Sized {
|
impl<U> From<U> for Error where U: UserError + Sized {
|
||||||
fn from(e: U) -> Self {
|
fn from(e: U) -> Self {
|
||||||
Error::User(Box::new(e))
|
Error::User(Box::new(e))
|
||||||
@ -152,22 +145,3 @@ pub use self::value::RuntimeValue;
|
|||||||
pub use self::variable::{VariableInstance, VariableType, ExternalVariableValue};
|
pub use self::variable::{VariableInstance, VariableType, ExternalVariableValue};
|
||||||
pub use self::env_native::{env_native_module, UserDefinedElements, UserFunctionExecutor, UserFunctionDescriptor};
|
pub use self::env_native::{env_native_module, UserDefinedElements, UserFunctionExecutor, UserFunctionDescriptor};
|
||||||
pub use self::env::EnvParams;
|
pub use self::env::EnvParams;
|
||||||
|
|
||||||
/// Default type of Error if you do not need any custom user errors.
|
|
||||||
#[deprecated]
|
|
||||||
pub type DummyError = Error;
|
|
||||||
|
|
||||||
/// Default type of ProgramInstance if you do not need any custom user errors.
|
|
||||||
/// To work with custom user errors or interpreter internals, use CustomProgramInstance.
|
|
||||||
#[deprecated]
|
|
||||||
pub type DefaultProgramInstance = self::program::ProgramInstance;
|
|
||||||
|
|
||||||
/// Default type of ModuleInstance if you do not need any custom user errors.
|
|
||||||
/// To work with custom user errors or interpreter internals, use CustomModuleInstance.
|
|
||||||
#[deprecated]
|
|
||||||
pub type DefaultModuleInstance = self::module::ModuleInstance;
|
|
||||||
|
|
||||||
/// Default type of ModuleInstanceInterface if you do not need any custom user errors.
|
|
||||||
/// To work with custom user errors or interpreter internals, use CustomModuleInstanceInterface.
|
|
||||||
#[deprecated]
|
|
||||||
pub type DefaultModuleInstanceInterface = self::module::ModuleInstanceInterface;
|
|
||||||
|
@ -6,10 +6,10 @@ use std::collections::HashMap;
|
|||||||
use builder::module;
|
use builder::module;
|
||||||
use elements::{ExportEntry, Internal, ImportEntry, External, GlobalEntry, GlobalType,
|
use elements::{ExportEntry, Internal, ImportEntry, External, GlobalEntry, GlobalType,
|
||||||
InitExpr, ValueType, BlockType, Opcodes, Opcode, FunctionType, TableType, MemoryType};
|
InitExpr, ValueType, BlockType, Opcodes, Opcode, FunctionType, TableType, MemoryType};
|
||||||
use interpreter::{Error, UserError, ProgramInstance, DefaultProgramInstance, DefaultModuleInstance};
|
use interpreter::{Error, UserError, ProgramInstance};
|
||||||
use interpreter::env_native::{env_native_module, UserDefinedElements, UserFunctionExecutor, UserFunctionDescriptor};
|
use interpreter::env_native::{env_native_module, UserDefinedElements, UserFunctionExecutor, UserFunctionDescriptor};
|
||||||
use interpreter::memory::MemoryInstance;
|
use interpreter::memory::MemoryInstance;
|
||||||
use interpreter::module::{ModuleInstanceInterface, CallerContext, ItemIndex, ExecutionParams, ExportEntryType, FunctionSignature};
|
use interpreter::module::{ModuleInstance, ModuleInstanceInterface, CallerContext, ItemIndex, ExecutionParams, ExportEntryType, FunctionSignature};
|
||||||
use interpreter::validator::{FunctionValidationContext, Validator};
|
use interpreter::validator::{FunctionValidationContext, Validator};
|
||||||
use interpreter::value::{RuntimeValue, TryInto};
|
use interpreter::value::{RuntimeValue, TryInto};
|
||||||
use interpreter::variable::{VariableInstance, ExternalVariableValue, VariableType};
|
use interpreter::variable::{VariableInstance, ExternalVariableValue, VariableType};
|
||||||
@ -40,7 +40,7 @@ fn import_function() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let external_module = program.add_module("external_module", module1, None).unwrap();
|
let external_module = program.add_module("external_module", module1, None).unwrap();
|
||||||
let main_module = program.add_module("main", module2, None).unwrap();
|
let main_module = program.add_module("main", module2, None).unwrap();
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ fn wrong_import() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let _side_module_instance = program.add_module("side_module", side_module, None).unwrap();
|
let _side_module_instance = program.add_module("side_module", side_module, None).unwrap();
|
||||||
assert!(program.add_module("main", module, None).is_err());
|
assert!(program.add_module("main", module, None).is_err());
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ fn global_get_set() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(50));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(50));
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(58));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(58));
|
||||||
@ -428,7 +428,7 @@ fn native_custom_error() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn import_env_mutable_global() {
|
fn import_env_mutable_global() {
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
|
|
||||||
let module = module()
|
let module = module()
|
||||||
.with_import(ImportEntry::new("env".into(), "STACKTOP".into(), External::Global(GlobalType::new(ValueType::I32, false))))
|
.with_import(ImportEntry::new("env".into(), "STACKTOP".into(), External::Global(GlobalType::new(ValueType::I32, false))))
|
||||||
@ -473,7 +473,7 @@ fn env_native_export_entry_type_check() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn if_else_with_return_type_validation() {
|
fn if_else_with_return_type_validation() {
|
||||||
let module_instance = DefaultModuleInstance::new(Weak::default(), "test".into(), module().build()).unwrap();
|
let module_instance = ModuleInstance::new(Weak::default(), "test".into(), module().build()).unwrap();
|
||||||
let mut context = FunctionValidationContext::new(&module_instance, None, &[], 1024, 1024, FunctionSignature::Module(&FunctionType::default()));
|
let mut context = FunctionValidationContext::new(&module_instance, None, &[], 1024, 1024, FunctionSignature::Module(&FunctionType::default()));
|
||||||
|
|
||||||
Validator::validate_function(&mut context, BlockType::NoResult, &[
|
Validator::validate_function(&mut context, BlockType::NoResult, &[
|
||||||
@ -498,7 +498,7 @@ fn memory_import_limits_initial() {
|
|||||||
.with_export(ExportEntry::new("memory".into(), Internal::Memory(0)))
|
.with_export(ExportEntry::new("memory".into(), Internal::Memory(0)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
program.add_module("core", core_module, None).unwrap();
|
program.add_module("core", core_module, None).unwrap();
|
||||||
|
|
||||||
let test_cases = vec![
|
let test_cases = vec![
|
||||||
@ -535,7 +535,7 @@ fn memory_import_limits_maximum() {
|
|||||||
(None, None, MaximumError::Ok),
|
(None, None, MaximumError::Ok),
|
||||||
];
|
];
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
for test_case in test_cases {
|
for test_case in test_cases {
|
||||||
let (core_maximum, client_maximum, expected_err) = test_case;
|
let (core_maximum, client_maximum, expected_err) = test_case;
|
||||||
let core_module = module()
|
let core_module = module()
|
||||||
@ -566,7 +566,7 @@ fn table_import_limits_initial() {
|
|||||||
.with_export(ExportEntry::new("table".into(), Internal::Table(0)))
|
.with_export(ExportEntry::new("table".into(), Internal::Table(0)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
program.add_module("core", core_module, None).unwrap();
|
program.add_module("core", core_module, None).unwrap();
|
||||||
|
|
||||||
let test_cases = vec![
|
let test_cases = vec![
|
||||||
@ -603,7 +603,7 @@ fn table_import_limits_maximum() {
|
|||||||
(None, None, MaximumError::Ok),
|
(None, None, MaximumError::Ok),
|
||||||
];
|
];
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
for test_case in test_cases {
|
for test_case in test_cases {
|
||||||
let (core_maximum, client_maximum, expected_err) = test_case;
|
let (core_maximum, client_maximum, expected_err) = test_case;
|
||||||
let core_module = module()
|
let core_module = module()
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use builder::module;
|
use builder::module;
|
||||||
use elements::{ValueType, Opcodes, Opcode, BlockType, Local};
|
use elements::{ValueType, Opcodes, Opcode, BlockType, Local};
|
||||||
use interpreter::{Error, DummyError, DefaultProgramInstance, DefaultModuleInstanceInterface, ModuleInstanceInterface, ItemIndex};
|
use interpreter::{Error, ProgramInstance, ModuleInstanceInterface, ItemIndex};
|
||||||
use interpreter::value::{RuntimeValue, TryInto};
|
use interpreter::value::{RuntimeValue, TryInto};
|
||||||
|
|
||||||
fn make_function_i32(body: Opcodes) -> (DefaultProgramInstance, Arc<DefaultModuleInstanceInterface>) {
|
fn make_function_i32(body: Opcodes) -> (ProgramInstance, Arc<ModuleInstanceInterface>) {
|
||||||
let module = module()
|
let module = module()
|
||||||
.function()
|
.function()
|
||||||
.signature().param().i32().return_type().i32().build()
|
.signature().param().i32().return_type().i32().build()
|
||||||
@ -17,12 +17,12 @@ fn make_function_i32(body: Opcodes) -> (DefaultProgramInstance, Arc<DefaultModul
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
(program, module)
|
(program, module)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_function_i32(module: &Arc<DefaultModuleInstanceInterface>, arg: i32) -> Result<i32, DummyError> {
|
fn run_function_i32(module: &Arc<ModuleInstanceInterface>, arg: i32) -> Result<i32, Error> {
|
||||||
module
|
module
|
||||||
.execute_index(0, vec![RuntimeValue::I32(arg)].into())
|
.execute_index(0, vec![RuntimeValue::I32(arg)].into())
|
||||||
.and_then(|r| r.unwrap().try_into())
|
.and_then(|r| r.unwrap().try_into())
|
||||||
@ -461,7 +461,7 @@ fn return_void() {
|
|||||||
.body().with_opcodes(body).build()
|
.body().with_opcodes(body).build()
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
|
|
||||||
module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap();
|
module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap();
|
||||||
@ -520,7 +520,7 @@ fn call_1() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(10));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(10));
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ fn call_2() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3628800));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3628800));
|
||||||
}
|
}
|
||||||
@ -612,7 +612,7 @@ fn call_zero_args() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(43));
|
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(43));
|
||||||
}
|
}
|
||||||
@ -658,7 +658,7 @@ fn callindirect_1() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -731,7 +731,7 @@ fn callindirect_2() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(14));
|
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(14));
|
||||||
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(6));
|
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(6));
|
||||||
@ -813,7 +813,7 @@ fn select() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(2));
|
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(2));
|
||||||
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -966,7 +966,7 @@ fn binary_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(16));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(16));
|
||||||
@ -1126,7 +1126,7 @@ fn binary_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(16));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(16));
|
||||||
@ -1216,7 +1216,7 @@ fn binary_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(5.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(5.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-9995.500000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-9995.500000));
|
||||||
@ -1298,7 +1298,7 @@ fn binary_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1111111110.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1111111110.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(123400000000000007812762268812638756607430593436581896388608.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(123400000000000007812762268812638756607430593436581896388608.000000));
|
||||||
@ -1351,7 +1351,7 @@ fn cast() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4.5));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4.5));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1067450368)); // 3227516928
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1067450368)); // 3227516928
|
||||||
@ -1617,7 +1617,7 @@ fn compare_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -1907,7 +1907,7 @@ fn compare_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -2091,7 +2091,7 @@ fn compare_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -2263,7 +2263,7 @@ fn compare_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -2331,7 +2331,7 @@ fn convert_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1)); // 4294967295
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1)); // 4294967295
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-100)); // 4294967196
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-100)); // 4294967196
|
||||||
@ -2404,7 +2404,7 @@ fn convert_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4294967295));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4294967295));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1)); // 18446744073709551615
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1)); // 18446744073709551615
|
||||||
@ -2462,7 +2462,7 @@ fn convert_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-1.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-1.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4294967296.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4294967296.000000));
|
||||||
@ -2519,7 +2519,7 @@ fn convert_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-1.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-1.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(4294967295.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(4294967295.000000));
|
||||||
@ -2579,7 +2579,7 @@ fn load_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
||||||
@ -2655,7 +2655,7 @@ fn load_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
||||||
@ -2685,7 +2685,7 @@ fn load_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(25.750000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(25.750000));
|
||||||
}
|
}
|
||||||
@ -2709,7 +2709,7 @@ fn load_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1023.875000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1023.875000));
|
||||||
}
|
}
|
||||||
@ -2766,7 +2766,7 @@ fn store_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-16909061));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-16909061));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-859059511));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-859059511));
|
||||||
@ -2836,7 +2836,7 @@ fn store_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4278058235));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4278058235));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3435907785));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3435907785));
|
||||||
@ -2864,7 +2864,7 @@ fn store_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1069547520));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1069547520));
|
||||||
}
|
}
|
||||||
@ -2889,7 +2889,7 @@ fn store_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1064352256));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1064352256));
|
||||||
}
|
}
|
||||||
@ -2940,7 +2940,7 @@ fn unary_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -2995,7 +2995,7 @@ fn unary_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -3094,7 +3094,7 @@ fn unary_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-100.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-100.000000));
|
||||||
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(100.000000));
|
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(100.000000));
|
||||||
@ -3197,7 +3197,7 @@ fn unary_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().unwrap();
|
let program = ProgramInstance::new().unwrap();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-100.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-100.000000));
|
||||||
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(100.000000));
|
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(100.000000));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use elements::deserialize_file;
|
use elements::deserialize_file;
|
||||||
use elements::Module;
|
use elements::Module;
|
||||||
use interpreter::{ExecutionParams, DefaultProgramInstance};
|
use interpreter::{ExecutionParams, ProgramInstance};
|
||||||
use interpreter::value::RuntimeValue;
|
use interpreter::value::RuntimeValue;
|
||||||
use interpreter::module::{ModuleInstanceInterface, ItemIndex};
|
use interpreter::module::{ModuleInstanceInterface, ItemIndex};
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ fn interpreter_inc_i32() {
|
|||||||
// The WASM file containing the module and function
|
// The WASM file containing the module and function
|
||||||
const WASM_FILE: &str = &"res/cases/v1/inc_i32.wasm";
|
const WASM_FILE: &str = &"res/cases/v1/inc_i32.wasm";
|
||||||
|
|
||||||
let program = DefaultProgramInstance::new().expect("Failed to instanciate program");
|
let program = ProgramInstance::new().expect("Failed to instanciate program");
|
||||||
|
|
||||||
let module: Module =
|
let module: Module =
|
||||||
deserialize_file(WASM_FILE).expect("Failed to deserialize module from buffer");
|
deserialize_file(WASM_FILE).expect("Failed to deserialize module from buffer");
|
||||||
@ -43,7 +43,7 @@ fn interpreter_accumulate_u8() {
|
|||||||
const BUF: &[u8] = &[9,8,7,6,5,4,3,2,1];
|
const BUF: &[u8] = &[9,8,7,6,5,4,3,2,1];
|
||||||
|
|
||||||
// Declare the memory limits of the runtime-environment
|
// Declare the memory limits of the runtime-environment
|
||||||
let program = DefaultProgramInstance::new().expect("Failed to instanciate program");
|
let program = ProgramInstance::new().expect("Failed to instanciate program");
|
||||||
|
|
||||||
// Load the module-structure from wasm-file and add to program
|
// Load the module-structure from wasm-file and add to program
|
||||||
let module: Module =
|
let module: Module =
|
||||||
|
@ -22,10 +22,7 @@ pub use elements::{
|
|||||||
|
|
||||||
pub use interpreter::{
|
pub use interpreter::{
|
||||||
ProgramInstance,
|
ProgramInstance,
|
||||||
DefaultProgramInstance,
|
|
||||||
ModuleInstance,
|
ModuleInstance,
|
||||||
DefaultModuleInstance,
|
|
||||||
ModuleInstanceInterface,
|
ModuleInstanceInterface,
|
||||||
DefaultModuleInstanceInterface,
|
|
||||||
RuntimeValue,
|
RuntimeValue,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user