Add PrintExpr instruction to vm.

This commit is contained in:
Adam Kelly
2018-08-04 20:44:30 +01:00
parent a9afa76438
commit 0d645bf1a9
2 changed files with 12 additions and 0 deletions

View File

@@ -63,6 +63,7 @@ pub enum Instruction {
BuildList { size: usize },
BuildMap { size: usize },
BuildSlice { size: usize },
PrintExpr,
}
#[derive(Debug, Clone)]

View File

@@ -736,6 +736,17 @@ impl VirtualMachine {
}
None
}
bytecode::Instruction::PrintExpr => {
let expr = self.pop_value();
match expr.borrow().kind {
PyObjectKind::None =>
(),
_ => {
builtins::builtin_print(self, PyFuncArgs { args: vec![expr.clone()] });
}
}
None
}
_ => panic!("NOT IMPL {:?}", instruction),
}
}