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

Function compile_program

crates/codegen/src/compile.rs:265–277  ·  view source on GitHub ↗

Compile a standard Python program to bytecode

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

Source from the content-addressed store, hash-verified

263
264/// Compile a standard Python program to bytecode
265pub fn compile_program(
266 ast: &ast::ModModule,
267 source_file: SourceFile,
268 opts: CompileOpts,
269) -> CompileResult<CodeObject> {
270 let symbol_table = SymbolTable::scan_program(ast, source_file.clone())
271 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))?;
272 let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned());
273 compiler.compile_program(ast, symbol_table)?;
274 let code = compiler.exit_scope();
275 trace!("Compilation completed: {code:?}");
276 Ok(code)
277}
278
279/// Compile a Python program to bytecode for the context of a REPL
280pub fn compile_program_single(

Callers 1

compile_topFunction · 0.85

Calls 7

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

Tested by

no test coverage detected