mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-16 09:35:19 +00:00
parent
05fcfa8aa1
commit
ae122c6478
3 changed files with 5 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
||||||
//! Take an AST and transform it into bytecode
|
//! Take an AST and transform it into bytecode
|
||||||
//!
|
//!
|
||||||
//! Inspirational code:
|
//! Inspirational code:
|
||||||
//! https://github.com/python/cpython/blob/master/Python/compile.c
|
//! https://github.com/python/cpython/blob/main/Python/compile.c
|
||||||
//! https://github.com/micropython/micropython/blob/master/py/compile.c
|
//! https://github.com/micropython/micropython/blob/master/py/compile.c
|
||||||
|
|
||||||
use crate::ir::{self, CodeInfo};
|
use crate::ir::{self, CodeInfo};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//! Compile a Python AST or source code into bytecode consumable by RustPython.
|
//! Compile a Python AST or source code into bytecode consumable by RustPython.
|
||||||
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/master/logo.png")]
|
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")]
|
||||||
#![doc(html_root_url = "https://docs.rs/rustpython-compiler/")]
|
#![doc(html_root_url = "https://docs.rs/rustpython-compiler/")]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -4,7 +4,7 @@ This ensures that global and nonlocal keywords are picked up.
|
||||||
Then the compiler can use the symbol table to generate proper
|
Then the compiler can use the symbol table to generate proper
|
||||||
load and store instructions for names.
|
load and store instructions for names.
|
||||||
|
|
||||||
Inspirational file: https://github.com/python/cpython/blob/master/Python/symtable.c
|
Inspirational file: https://github.com/python/cpython/blob/main/Python/symtable.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::error::{CompileError, CompileErrorType};
|
use crate::error::{CompileError, CompileErrorType};
|
||||||
|
@ -196,7 +196,7 @@ impl std::fmt::Debug for SymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform some sort of analysis on nonlocals, globals etc..
|
/* Perform some sort of analysis on nonlocals, globals etc..
|
||||||
See also: https://github.com/python/cpython/blob/master/Python/symtable.c#L410
|
See also: https://github.com/python/cpython/blob/main/Python/symtable.c#L410
|
||||||
*/
|
*/
|
||||||
fn analyze_symbol_table(symbol_table: &mut SymbolTable) -> SymbolTableResult {
|
fn analyze_symbol_table(symbol_table: &mut SymbolTable) -> SymbolTableResult {
|
||||||
let mut analyzer = SymbolTableAnalyzer::default();
|
let mut analyzer = SymbolTableAnalyzer::default();
|
||||||
|
@ -760,7 +760,7 @@ impl SymbolTableBuilder {
|
||||||
value,
|
value,
|
||||||
simple,
|
simple,
|
||||||
} => {
|
} => {
|
||||||
// https://github.com/python/cpython/blob/master/Python/symtable.c#L1233
|
// https://github.com/python/cpython/blob/main/Python/symtable.c#L1233
|
||||||
match &target.node {
|
match &target.node {
|
||||||
ast::ExprKind::Name { id, .. } if *simple => {
|
ast::ExprKind::Name { id, .. } if *simple => {
|
||||||
self.register_name(id, SymbolUsage::AnnotationAssigned, location)?;
|
self.register_name(id, SymbolUsage::AnnotationAssigned, location)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue