select: int condition on stack top
This commit is contained in:
parent
ee7ef764de
commit
508c918522
|
@ -470,11 +470,10 @@ impl<'a, E: Externals> Interpreter<'a, E> {
|
||||||
.value_stack_mut()
|
.value_stack_mut()
|
||||||
.pop_triple()
|
.pop_triple()
|
||||||
.and_then(|(left, mid, right)| {
|
.and_then(|(left, mid, right)| {
|
||||||
let right: Result<_, Error> = right.try_into();
|
let condition = right
|
||||||
match (left, mid, right) {
|
.try_into()
|
||||||
(left, mid, Ok(condition)) => Ok((left, mid, condition)),
|
.expect("Due to validation stack top should be int");
|
||||||
_ => Err(Error::Stack("expected to get int value from stack".into()))
|
Ok((left, mid, condition))
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.map(|(left, mid, condition)| if condition { left } else { mid })
|
.map(|(left, mid, condition)| if condition { left } else { mid })
|
||||||
.map(|val| context.value_stack_mut().push(val))
|
.map(|val| context.value_stack_mut().push(val))
|
||||||
|
|
Loading…
Reference in New Issue