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

Function compile_program_single

crates/codegen/src/compile.rs:280–292  ·  view source on GitHub ↗

Compile a Python program to bytecode for the context of a REPL

(
    ast: &ast::ModModule,
    source_file: SourceFile,
    opts: CompileOpts,
)

Source from the content-addressed store, hash-verified

278
279/// Compile a Python program to bytecode for the context of a REPL
280pub fn compile_program_single(
281 ast: &ast::ModModule,
282 source_file: SourceFile,
283 opts: CompileOpts,
284) -> CompileResult<CodeObject> {
285 let symbol_table = SymbolTable::scan_program(ast, source_file.clone())
286 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))?;
287 let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned());
288 compiler.compile_program_single(&ast.body, symbol_table)?;
289 let code = compiler.exit_scope();
290 trace!("Compilation completed: {code:?}");
291 Ok(code)
292}
293
294pub fn compile_block_expression(
295 ast: &ast::ModModule,

Callers 1

compile_topFunction · 0.85

Calls 7

newFunction · 0.85
into_codegen_errorMethod · 0.80
exit_scopeMethod · 0.80
cloneMethod · 0.45
to_ownedMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected