Skip to content

Commit

Permalink
Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pepyakin committed Jun 25, 2018
1 parent fad1470 commit 0b5d765
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 8 additions & 12 deletions src/runner.rs
Expand Up @@ -392,15 +392,15 @@ impl<'a, E: Externals> Interpreter<'a, E> {
}

fn run_br_table(&mut self, table: &[isa::Target]) -> Result<InstructionOutcome, TrapKind> {
let index: u32 = self.value_stack
.pop_as();
let index: u32 = self.value_stack.pop_as();

let dst =
if (index as usize) < table.len() - 1 {
let dst = if (index as usize) < table.len() - 1 {
table[index as usize].clone()
} else {
let len = table.len();
table[len - 1].clone()
table
.last()
.expect("Due to validation there should be at least one label")
.clone()
};
Ok(InstructionOutcome::Branch(dst))
}
Expand All @@ -426,9 +426,7 @@ impl<'a, E: Externals> Interpreter<'a, E> {
context: &mut FunctionContext,
signature_idx: u32,
) -> Result<InstructionOutcome, TrapKind> {
let table_func_idx: u32 = self
.value_stack
.pop_as();
let table_func_idx: u32 = self.value_stack.pop_as();
let table = context
.module()
.table_by_index(DEFAULT_TABLE_INDEX)
Expand All @@ -453,9 +451,7 @@ impl<'a, E: Externals> Interpreter<'a, E> {
}

fn run_drop(&mut self) -> Result<InstructionOutcome, TrapKind> {
let _ = self
.value_stack
.pop();
let _ = self.value_stack.pop();
Ok(InstructionOutcome::RunNextInstruction)
}

Expand Down
2 changes: 1 addition & 1 deletion src/validation/func.rs
Expand Up @@ -434,7 +434,7 @@ impl FunctionReader {
let drop_keep = drop_keep_return(
&context.locals,
&context.value_stack,
&context.frame_stack
&context.frame_stack,
);
context.sink.emit(isa::Instruction::Return(drop_keep));

Expand Down

0 comments on commit 0b5d765

Please sign in to comment.