From 9dd258c2bbcbd73efa7a20d5d1e97f0ca7fafd7b Mon Sep 17 00:00:00 2001 From: Andrew Dirksen Date: Mon, 19 Nov 2018 14:02:08 -0800 Subject: [PATCH] invoke_resumable does not need to take &args anymore --- src/func.rs | 27 ++++++++++----------------- src/tests/host.rs | 2 +- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/func.rs b/src/func.rs index ace42f8..8a274c1 100644 --- a/src/func.rs +++ b/src/func.rs @@ -184,26 +184,24 @@ impl FuncInstance { /// [`Trap`]: #enum.Trap.html /// [`start_execution`]: struct.FuncInvocation.html#method.start_execution /// [`resume_execution`]: struct.FuncInvocation.html#method.resume_execution - pub fn invoke_resumable<'args>(func: &FuncRef, args: &'args [RuntimeValue]) -> Result, Trap> { - check_function_args(func.signature(), &args)?; + pub fn invoke_resumable(func: &FuncRef) -> FuncInvocation { match *func.as_internal() { FuncInstanceInternal::Internal { .. } => { let value_stack = StackWithLimit::with_size(StackSize::from_element_count(DEFAULT_VALUE_STACK_LIMIT)); let call_stack = StackWithLimit::with_size(StackSize::from_element_count(DEFAULT_CALL_STACK_LIMIT)); let interpreter = Interpreter::new(value_stack, call_stack); - Ok(FuncInvocation { + FuncInvocation { kind: FuncInvocationKind::Internal(interpreter), - }) + } } FuncInstanceInternal::Host { ref host_func_index, .. - } => Ok(FuncInvocation { + } => FuncInvocation { kind: FuncInvocationKind::Host { - args, host_func_index: *host_func_index, finished: false, }, - }), + }, } } } @@ -239,20 +237,16 @@ impl From for ResumableError { } /// A resumable invocation handle. This struct is returned by `FuncInstance::invoke_resumable`. -pub struct FuncInvocation<'args> { - kind: FuncInvocationKind<'args>, +pub struct FuncInvocation { + kind: FuncInvocationKind, } -enum FuncInvocationKind<'args> { +enum FuncInvocationKind { Internal(Interpreter), - Host { - args: &'args [RuntimeValue], - host_func_index: usize, - finished: bool, - }, + Host { host_func_index: usize, finished: bool }, } -impl<'args> FuncInvocation<'args> { +impl FuncInvocation { /// Whether this invocation is currently resumable. pub fn is_resumable(&self) -> bool { match &self.kind { @@ -288,7 +282,6 @@ impl<'args> FuncInvocation<'args> { Ok(interpreter.start_execution(externals, func, args, return_type)?) } FuncInvocationKind::Host { - ref args, ref mut finished, ref host_func_index, } => { diff --git a/src/tests/host.rs b/src/tests/host.rs index 3f09ade..3bc5b13 100644 --- a/src/tests/host.rs +++ b/src/tests/host.rs @@ -266,7 +266,7 @@ fn resume_call_host_func() { let func_instance = export.as_func().unwrap(); let return_type = func_instance.signature().return_type(); - let mut invocation = FuncInstance::invoke_resumable(&func_instance, &[]).unwrap(); + let mut invocation = FuncInstance::invoke_resumable(&func_instance); let result = invocation.start_execution(&mut env, func_instance, &[], return_type); match result { Err(ResumableError::Trap(_)) => {}