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

Method enter_scope

crates/codegen/src/symboltable.rs:1019–1044  ·  view source on GitHub ↗
(&mut self, name: &str, typ: CompilerScope, line_number: u32)

Source from the content-addressed store, hash-verified

1017 }
1018
1019 fn enter_scope(&mut self, name: &str, typ: CompilerScope, line_number: u32) {
1020 let is_nested = self
1021 .tables
1022 .last()
1023 .map(|table| {
1024 table.is_nested
1025 || matches!(
1026 table.typ,
1027 CompilerScope::Function | CompilerScope::AsyncFunction
1028 )
1029 })
1030 .unwrap_or(false);
1031 // Inherit mangled_names from parent for non-class scopes
1032 let inherited_mangled_names = self
1033 .tables
1034 .last()
1035 .and_then(|t| t.mangled_names.clone())
1036 .filter(|_| typ != CompilerScope::Class);
1037 let mut table = SymbolTable::new(name.to_owned(), typ, line_number, is_nested);
1038 table.future_annotations = self.future_annotations;
1039 table.mangled_names = inherited_mangled_names;
1040 self.tables.push(table);
1041 // Save parent's varnames and start fresh for the new scope
1042 self.varnames_stack
1043 .push(core::mem::take(&mut self.current_varnames));
1044 }
1045
1046 fn enter_type_param_block(
1047 &mut self,

Callers 7

newMethod · 0.45
scan_statementMethod · 0.45
scan_expressionMethod · 0.45
scan_comprehensionMethod · 0.45

Calls 8

newFunction · 0.85
takeFunction · 0.85
mapMethod · 0.45
lastMethod · 0.45
filterMethod · 0.45
cloneMethod · 0.45
to_ownedMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected