show match

This commit is contained in:
NikVolf 2019-04-18 19:35:41 +03:00
parent e8cc132972
commit 29c771cf70
2 changed files with 17 additions and 7 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
**/*.rs.bk
Cargo.lock
spec/target
.idea

View File

@ -1012,14 +1012,23 @@ fn compute_drop_keep(
start_value_stack_height,
)));
}
if (actual_value_stack_height as u32 - start_value_stack_height as u32) < keep as u32 {
return Err(Error(format!(
"Stack underflow detected: asked to keep {:?} values, but there are only {}",
keep,
actual_value_stack_height as u32 - start_value_stack_height as u32,
)));
match keep {
isa::Keep::Single => {
if actual_value_stack_height < start_value_stack_height + 1 {
return Err(Error(format!(
"Stack underflow detected: asked to keep {:?} values, but there are only {}",
keep,
actual_value_stack_height as u32 - start_value_stack_height as u32,
)));
}
(actual_value_stack_height - start_value_stack_height - 1) as u32
},
isa::Keep::None => {
(actual_value_stack_height - start_value_stack_height) as u32
}
}
(actual_value_stack_height as u32 - start_value_stack_height as u32) - keep as u32
};
Ok(isa::DropKeep { drop, keep })