pub struct SymbolTable {Show 17 fields
pub name: String,
pub typ: CompilerScope,
pub line_number: u32,
pub is_nested: bool,
pub symbols: IndexMap<String, Symbol, RandomState>,
pub sub_tables: Vec<SymbolTable>,
pub next_sub_table: usize,
pub varnames: Vec<String>,
pub needs_class_closure: bool,
pub needs_classdict: bool,
pub can_see_class_scope: bool,
pub is_generator: bool,
pub comp_inlined: bool,
pub annotation_block: Option<Box<SymbolTable>>,
pub has_conditional_annotations: bool,
pub future_annotations: bool,
pub mangled_names: Option<IndexSet<String, RandomState>>,
}Expand description
Captures all symbols in the current scope, and has a list of sub-scopes in this scope.
Fields§
§name: StringThe name of this symbol table. Often the name of the class or function.
typ: CompilerScopeThe type of symbol table
line_number: u32The line number in the source code where this symboltable begins.
is_nested: bool§symbols: IndexMap<String, Symbol, RandomState>A set of symbols present on this scope level.
sub_tables: Vec<SymbolTable>A list of sub-scopes in the order as found in the AST nodes.
next_sub_table: usizeCursor pointing to the next sub-table to consume during compilation.
varnames: Vec<String>Variable names in definition order (parameters first, then locals)
needs_class_closure: boolWhether this class scope needs an implicit class cell
needs_classdict: boolWhether this class scope needs an implicit classdict cell
can_see_class_scope: boolWhether this type param scope can see the parent class scope
is_generator: boolWhether this scope contains yield/yield from (is a generator function)
comp_inlined: boolWhether this comprehension scope should be inlined (PEP 709) True for list/set/dict comprehensions in non-generator expressions
annotation_block: Option<Box<SymbolTable>>PEP 649: Reference to annotation scope for this block
Annotations are compiled as a separate __annotate__ function
has_conditional_annotations: boolPEP 649: Whether this scope has conditional annotations (annotations inside if/for/while/etc. blocks or at module level)
future_annotations: boolWhether from __future__ import annotations is active
mangled_names: Option<IndexSet<String, RandomState>>Names of type parameters that should still be mangled in type param scopes. When Some, only names in this set are mangled; other names are left unmangled. Set on type param blocks for generic classes; inherited by non-class child scopes.
Implementations§
Source§impl SymbolTable
impl SymbolTable
pub fn scan_program( program: &ModModule, source_file: SourceFile, ) -> Result<SymbolTable, SymbolTableError>
pub fn scan_expr( expr: &ModExpression, source_file: SourceFile, ) -> Result<SymbolTable, SymbolTableError>
pub fn lookup(&self, name: &str) -> Option<&Symbol>
Trait Implementations§
Source§impl Clone for SymbolTable
impl Clone for SymbolTable
Source§fn clone(&self) -> SymbolTable
fn clone(&self) -> SymbolTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SymbolTable
impl RefUnwindSafe for SymbolTable
impl Send for SymbolTable
impl Sync for SymbolTable
impl Unpin for SymbolTable
impl UnsafeUnpin for SymbolTable
impl UnwindSafe for SymbolTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more