(vm: &VirtualMachine, source: &str, scope: Scope, source_path: &str)
| 1 | use crate::{PyResult, VirtualMachine, compiler, scope::Scope}; |
| 2 | |
| 3 | pub fn eval(vm: &VirtualMachine, source: &str, scope: Scope, source_path: &str) -> PyResult { |
| 4 | match vm.compile(source, compiler::Mode::Eval, source_path.to_owned()) { |
| 5 | Ok(bytecode) => { |
| 6 | debug!("Code object: {bytecode:?}"); |
| 7 | vm.run_code_obj(bytecode, scope) |
| 8 | } |
| 9 | Err(err) => Err(vm.new_syntax_error(&err, Some(source))), |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | #[cfg(test)] |
| 14 | mod tests { |