(
&mut self,
body: &[ast::Stmt],
symbol_table: SymbolTable,
)
| 1944 | } |
| 1945 | |
| 1946 | fn compile_block_expr( |
| 1947 | &mut self, |
| 1948 | body: &[ast::Stmt], |
| 1949 | symbol_table: SymbolTable, |
| 1950 | ) -> CompileResult<()> { |
| 1951 | self.symbol_table_stack.push(symbol_table); |
| 1952 | self.emit_resume_for_scope(CompilerScope::Module, 1); |
| 1953 | |
| 1954 | self.compile_statements(body)?; |
| 1955 | |
| 1956 | if let Some(last_statement) = body.last() { |
| 1957 | match last_statement { |
| 1958 | ast::Stmt::Expr(_) => { |
| 1959 | self.current_block().instructions.pop(); // pop Instruction::PopTop |
| 1960 | } |
| 1961 | ast::Stmt::FunctionDef(_) | ast::Stmt::ClassDef(_) => { |
| 1962 | let pop_instructions = self.current_block().instructions.pop(); |
| 1963 | let store_inst = compiler_unwrap_option(self, pop_instructions); // pop Instruction::Store |
| 1964 | emit!(self, Instruction::Copy { i: 1 }); |
| 1965 | self.current_block().instructions.push(store_inst); |
| 1966 | } |
| 1967 | _ => self.emit_load_const(ConstantData::None), |
| 1968 | } |
| 1969 | } |
| 1970 | self.emit_return_value(); |
| 1971 | |
| 1972 | Ok(()) |
| 1973 | } |
| 1974 | |
| 1975 | // Compile statement in eval mode: |
| 1976 | fn compile_eval( |
no test coverage detected