Push the next symbol table on to the stack
(&mut self)
| 810 | |
| 811 | /// Push the next symbol table on to the stack |
| 812 | fn push_symbol_table(&mut self) -> CompileResult<&SymbolTable> { |
| 813 | // Look up the next table contained in the scope of the current table |
| 814 | let current_table = self |
| 815 | .symbol_table_stack |
| 816 | .last_mut() |
| 817 | .expect("no current symbol table"); |
| 818 | |
| 819 | if current_table.next_sub_table >= current_table.sub_tables.len() { |
| 820 | let name = current_table.name.clone(); |
| 821 | let typ = current_table.typ; |
| 822 | return Err(self.error(CodegenErrorType::SyntaxError(format!( |
| 823 | "no symbol table available in {} (type: {:?})", |
| 824 | name, typ |
| 825 | )))); |
| 826 | } |
| 827 | |
| 828 | let idx = current_table.next_sub_table; |
| 829 | current_table.next_sub_table += 1; |
| 830 | let table = current_table.sub_tables[idx].clone(); |
| 831 | |
| 832 | // Push the next table onto the stack |
| 833 | self.symbol_table_stack.push(table); |
| 834 | Ok(self.current_symbol_table()) |
| 835 | } |
| 836 | |
| 837 | /// Push the annotation symbol table from the next sub_table's annotation_block |
| 838 | /// The annotation_block is stored in the function's scope, which is the next sub_table |
no test coverage detected