From 844fd0c5c95498a7031e27ad3bb50094ecc56628 Mon Sep 17 00:00:00 2001 From: Andrew Dirksen Date: Tue, 20 Nov 2018 10:30:56 -0800 Subject: [PATCH] remove unnessesary argument from start_execution --- src/func.rs | 5 ++--- src/runner.rs | 8 ++++---- src/tests/host.rs | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/func.rs b/src/func.rs index bf36b49..31270fc 100644 --- a/src/func.rs +++ b/src/func.rs @@ -138,7 +138,7 @@ impl FuncInstance { check_function_args(func.signature(), &args)?; match *func.as_internal() { FuncInstanceInternal::Internal { .. } => { - interpreter.start_execution(externals, func, args, func.signature().return_type()) + interpreter.start_execution(externals, func, args) } FuncInstanceInternal::Host { ref host_func_index, .. @@ -268,14 +268,13 @@ impl FuncInvocation { externals: &'externals mut E, func: &FuncRef, args: &[RuntimeValue], - return_type: Option, ) -> Result, ResumableError> { match self.kind { FuncInvocationKind::Internal(ref mut interpreter) => { if interpreter.state() != &InterpreterState::Initialized { return Err(ResumableError::AlreadyStarted); } - Ok(interpreter.start_execution(externals, func, args, return_type)?) + Ok(interpreter.start_execution(externals, func, args)?) } FuncInvocationKind::Host { ref mut finished, diff --git a/src/runner.rs b/src/runner.rs index 6f0bb05..ef37582 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -204,10 +204,7 @@ impl Interpreter { externals: &mut E, func: &FuncRef, args: &[RuntimeValue], - return_type: Option, ) -> Result, Trap> { - debug_assert_eq!(func.signature().return_type(), return_type); - // Ensure that the VM has not been executed. This is checked in `FuncInvocation::start_execution`. assert!(self.state == InterpreterState::Initialized); @@ -224,7 +221,10 @@ impl Interpreter { self.state = InterpreterState::Started; self.run_interpreter_loop(externals)?; - let opt_return_value = return_type.map(|vt| self.value_stack.pop().with_type(vt)); + let opt_return_value = func + .signature() + .return_type() + .map(|vt| self.value_stack.pop().with_type(vt)); // Ensure that stack is empty after the execution. This is guaranteed by the validation properties. assert!(self.value_stack.len() == 0); diff --git a/src/tests/host.rs b/src/tests/host.rs index 3bc5b13..8a93e3f 100644 --- a/src/tests/host.rs +++ b/src/tests/host.rs @@ -267,7 +267,7 @@ fn resume_call_host_func() { let return_type = func_instance.signature().return_type(); let mut invocation = FuncInstance::invoke_resumable(&func_instance); - let result = invocation.start_execution(&mut env, func_instance, &[], return_type); + let result = invocation.start_execution(&mut env, func_instance, &[]); match result { Err(ResumableError::Trap(_)) => {} _ => panic!(),