Compile a Python program to bytecode for the context of a REPL
(
ast: &ast::ModModule,
source_file: SourceFile,
opts: CompileOpts,
)
| 278 | |
| 279 | /// Compile a Python program to bytecode for the context of a REPL |
| 280 | pub 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 | |
| 294 | pub fn compile_block_expression( |
| 295 | ast: &ast::ModModule, |
no test coverage detected