mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-19 19:15:43 +00:00
Add Free enum variant to the symbol scope to be able to distuingish between true local and free variables.
This commit is contained in:
parent
9b1771b483
commit
39c095d12c
2 changed files with 15 additions and 15 deletions
|
@ -282,8 +282,8 @@ impl<O: OutputStream> Compiler<O> {
|
|||
match symbol.scope {
|
||||
SymbolScope::Global => bytecode::NameScope::Global,
|
||||
SymbolScope::Nonlocal => bytecode::NameScope::NonLocal,
|
||||
SymbolScope::Unknown => bytecode::NameScope::Local,
|
||||
SymbolScope::Local => bytecode::NameScope::Local,
|
||||
SymbolScope::Unknown => bytecode::NameScope::Free,
|
||||
SymbolScope::Local => bytecode::NameScope::Free,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ impl<O: OutputStream> Compiler<O> {
|
|||
self.compile_jump_if(test, true, end_label)?;
|
||||
self.emit(Instruction::LoadName {
|
||||
name: String::from("AssertionError"),
|
||||
scope: bytecode::NameScope::Local,
|
||||
scope: bytecode::NameScope::Global,
|
||||
});
|
||||
match msg {
|
||||
Some(e) => {
|
||||
|
@ -736,7 +736,7 @@ impl<O: OutputStream> Compiler<O> {
|
|||
// Check exception type:
|
||||
self.emit(Instruction::LoadName {
|
||||
name: String::from("isinstance"),
|
||||
scope: bytecode::NameScope::Local,
|
||||
scope: bytecode::NameScope::Global,
|
||||
});
|
||||
self.emit(Instruction::Rotate { amount: 2 });
|
||||
self.compile_expression(exc_type)?;
|
||||
|
@ -931,11 +931,11 @@ impl<O: OutputStream> Compiler<O> {
|
|||
|
||||
self.emit(Instruction::LoadName {
|
||||
name: "__name__".to_string(),
|
||||
scope: bytecode::NameScope::Local,
|
||||
scope: bytecode::NameScope::Free,
|
||||
});
|
||||
self.emit(Instruction::StoreName {
|
||||
name: "__module__".to_string(),
|
||||
scope: bytecode::NameScope::Local,
|
||||
scope: bytecode::NameScope::Free,
|
||||
});
|
||||
self.compile_statements(new_body)?;
|
||||
self.emit(Instruction::LoadConst {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue