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

Function symtable

crates/vm/src/stdlib/_symtable.rs:113–129  ·  view source on GitHub ↗
(
        source: PyUtf8StrRef,
        filename: PyUtf8StrRef,
        mode: PyUtf8StrRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

111
112 #[pyfunction]
113 fn symtable(
114 source: PyUtf8StrRef,
115 filename: PyUtf8StrRef,
116 mode: PyUtf8StrRef,
117 vm: &VirtualMachine,
118 ) -> PyResult<PyRef<PySymbolTable>> {
119 let mode = mode
120 .as_str()
121 .parse::<compiler::Mode>()
122 .map_err(|err| vm.new_value_error(err.to_string()))?;
123
124 let symtable = compiler::compile_symtable(source.as_str(), mode, filename.as_str())
125 .map_err(|err| vm.new_syntax_error(&err, Some(source.as_str())))?;
126
127 let py_symbol_table = to_py_symbol_table(symtable);
128 Ok(py_symbol_table.into_ref(&vm.ctx))
129 }
130
131 const fn to_py_symbol_table(symtable: SymbolTable) -> PySymbolTable {
132 PySymbolTable { symtable }

Callers

nothing calls this directly

Calls 7

compile_symtableFunction · 0.85
to_py_symbol_tableFunction · 0.85
to_stringMethod · 0.80
new_syntax_errorMethod · 0.80
SomeClass · 0.50
as_strMethod · 0.45
into_refMethod · 0.45

Tested by

no test coverage detected