mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
JumpIf - evaluate truthyness of argument.
This commit is contained in:
1 parent
3ff5f16a43
commit
e9b9725860
1 file changed
+8
-13
+8
-13
@@ -12,6 +12,7 @@ use super::builtins;
|
||||
use super::bytecode;
|
||||
use super::frame::{copy_code, Block, Frame};
|
||||
use super::import::import;
|
||||
use super::objbool;
|
||||
use super::objlist;
|
||||
use super::objobject;
|
||||
use super::objstr;
|
||||
@@ -746,21 +747,15 @@ impl VirtualMachine {
|
||||
}
|
||||
bytecode::Instruction::JumpIf { target } => {
|
||||
let obj = self.pop_value();
|
||||
// TODO: determine if this value is True-ish:
|
||||
//if *v == NativeType::Boolean(true) {
|
||||
// curr_frame.lasti = curr_frame.labels.get(target).unwrap().clone();
|
||||
//}
|
||||
let x = obj.borrow();
|
||||
let result: bool = match x.kind {
|
||||
PyObjectKind::Boolean { ref value } => *value,
|
||||
_ => {
|
||||
panic!("Not impl {:?}", x);
|
||||
match objbool::boolval(self, obj) {
|
||||
Ok(value) => {
|
||||
if value {
|
||||
self.jump(target);
|
||||
}
|
||||
None
|
||||
}
|
||||
};
|
||||
if result {
|
||||
self.jump(target);
|
||||
Err(value) => Some(Err(value)),
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
bytecode::Instruction::Raise { argc } => {
|
||||
|
||||
Reference in new issue
Block a user