MCPcopy Index your code
hub / github.com/RustPython/RustPython / eval

Function eval

crates/vm/src/eval.rs:3–11  ·  view source on GitHub ↗
(vm: &VirtualMachine, source: &str, scope: Scope, source_path: &str)

Source from the content-addressed store, hash-verified

1use crate::{PyResult, VirtualMachine, compiler, scope::Scope};
2
3pub 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)]
14mod tests {

Callers 15

test_print_42Function · 0.70
attr_matchesMethod · 0.50
wrap_valueFunction · 0.50
helpMethod · 0.50
evaluateMethod · 0.50
get_annotationsFunction · 0.50
do_breakMethod · 0.50
_getvalMethod · 0.50
_getval_exceptMethod · 0.50
runevalMethod · 0.50
effectiveFunction · 0.50
namedtupleFunction · 0.50

Calls 6

run_code_objMethod · 0.80
new_syntax_errorMethod · 0.80
ErrClass · 0.50
SomeClass · 0.50
compileMethod · 0.45
to_ownedMethod · 0.45