get_local can't fail.

This commit is contained in:
Sergey Pepyakin 2018-01-29 16:52:11 +03:00
parent e529e3208b
commit 4821368c52
1 changed files with 6 additions and 6 deletions

View File

@ -486,9 +486,9 @@ impl<'a, E: Externals> Interpreter<'a, E> {
} }
fn run_get_local(&mut self, context: &mut FunctionContext, index: u32) -> Result<InstructionOutcome, Error> { fn run_get_local(&mut self, context: &mut FunctionContext, index: u32) -> Result<InstructionOutcome, Error> {
context.get_local(index as usize) let value = context.get_local(index as usize);
.map(|value| context.value_stack_mut().push(value)) context.value_stack_mut().push(value)?;
.map(|_| InstructionOutcome::RunNextInstruction) Ok(InstructionOutcome::RunNextInstruction)
} }
fn run_set_local(&mut self, context: &mut FunctionContext, index: u32) -> Result<InstructionOutcome, Error> { fn run_set_local(&mut self, context: &mut FunctionContext, index: u32) -> Result<InstructionOutcome, Error> {
@ -1071,10 +1071,10 @@ impl FunctionContext {
Ok(InstructionOutcome::RunNextInstruction) Ok(InstructionOutcome::RunNextInstruction)
} }
pub fn get_local(&mut self, index: usize) -> Result<RuntimeValue, Error> { pub fn get_local(&mut self, index: usize) -> RuntimeValue {
Ok(self.locals.get(index) self.locals.get(index)
.cloned() .cloned()
.expect("Due to validation local should exists")) .expect("Due to validation local should exists")
} }
pub fn value_stack(&self) -> &StackWithLimit<RuntimeValue> { pub fn value_stack(&self) -> &StackWithLimit<RuntimeValue> {