Compile a standard Python program to bytecode
(
ast: &ast::ModModule,
source_file: SourceFile,
opts: CompileOpts,
)
| 263 | |
| 264 | /// Compile a standard Python program to bytecode |
| 265 | pub 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 |
| 280 | pub fn compile_program_single( |
no test coverage detected