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

Method push_symbol_table

crates/codegen/src/compile.rs:812–835  ·  view source on GitHub ↗

Push the next symbol table on to the stack

(&mut self)

Source from the content-addressed store, hash-verified

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

Callers 5

push_outputMethod · 0.80
compile_statementMethod · 0.80
compile_class_bodyMethod · 0.80

Calls 6

current_symbol_tableMethod · 0.80
ErrClass · 0.50
lenMethod · 0.45
cloneMethod · 0.45
errorMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected