@@ -9,9 +9,7 @@ mod _symtable { |
9 | 9 | types::Representable, |
10 | 10 | }; |
11 | 11 | use alloc::fmt; |
12 | | - use rustpython_codegen::symboltable::{ |
13 | | - CompilerScope, Symbol, SymbolFlags, SymbolScope, SymbolTable, |
14 | | - }; |
| 12 | + use rustpython_codegen::symboltable::{CompilerScope, SymbolFlags, SymbolScope, SymbolTable}; |
15 | 13 |
|
16 | 14 | /// [CPython's `SCOPE_OFFSET`](https://github.com/python/cpython/blob/v3.14.6/Include/internal/pycore_symtable.h#L176) |
17 | 15 | const SCOPE_OFFSET: i32 = 12; |
@@ -183,15 +181,6 @@ mod _symtable { |
183 | 181 | self as *const Self as *const core::ffi::c_void as usize |
184 | 182 | } |
185 | 183 |
|
186 | | - #[pygetset] |
187 | | - fn identifiers(&self, vm: &VirtualMachine) -> Vec<PyObjectRef> { |
188 | | - self.symtable |
189 | | - .symbols |
190 | | - .keys() |
191 | | - .map(|s| vm.ctx.new_str(s.as_str()).into()) |
192 | | - .collect() |
193 | | - } |
194 | | - |
195 | 184 | #[pygetset] |
196 | 185 | fn symbols(&self, vm: &VirtualMachine) -> PyDictRef { |
197 | 186 | let dict = vm.ctx.new_dict(); |
@@ -220,106 +209,4 @@ mod _symtable { |
220 | 209 | )) |
221 | 210 | } |
222 | 211 | } |
223 | | - |
224 | | - #[pyattr] |
225 | | - #[pyclass(name = "Symbol")] |
226 | | - #[derive(PyPayload)] |
227 | | - struct PySymbol { |
228 | | - symbol: Symbol, |
229 | | - namespaces: Vec<SymbolTable>, |
230 | | - is_top_scope: bool, |
231 | | - } |
232 | | - |
233 | | - impl fmt::Debug for PySymbol { |
234 | | - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
235 | | - write!(f, "Symbol()") |
236 | | - } |
237 | | - } |
238 | | - |
239 | | - #[pyclass] |
240 | | - impl PySymbol { |
241 | | - #[pymethod] |
242 | | - fn get_name(&self) -> String { |
243 | | - self.symbol.name.clone() |
244 | | - } |
245 | | - |
246 | | - #[pymethod] |
247 | | - const fn is_global(&self) -> bool { |
248 | | - self.symbol.is_global() || (self.is_top_scope && self.symbol.is_bound()) |
249 | | - } |
250 | | - |
251 | | - #[pymethod] |
252 | | - const fn is_declared_global(&self) -> bool { |
253 | | - matches!(self.symbol.scope, SymbolScope::GlobalExplicit) |
254 | | - } |
255 | | - |
256 | | - #[pymethod] |
257 | | - const fn is_local(&self) -> bool { |
258 | | - self.symbol.is_local() || (self.is_top_scope && self.symbol.is_bound()) |
259 | | - } |
260 | | - |
261 | | - #[pymethod] |
262 | | - const fn is_imported(&self) -> bool { |
263 | | - self.symbol.flags.contains(SymbolFlags::DEF_IMPORT) |
264 | | - } |
265 | | - |
266 | | - #[pymethod] |
267 | | - const fn is_nested(&self) -> bool { |
268 | | - // TODO |
269 | | - false |
270 | | - } |
271 | | - |
272 | | - #[pymethod] |
273 | | - const fn is_nonlocal(&self) -> bool { |
274 | | - self.symbol.flags.contains(SymbolFlags::DEF_NONLOCAL) |
275 | | - } |
276 | | - |
277 | | - #[pymethod] |
278 | | - const fn is_referenced(&self) -> bool { |
279 | | - self.symbol.flags.contains(SymbolFlags::USE) |
280 | | - } |
281 | | - |
282 | | - #[pymethod] |
283 | | - const fn is_assigned(&self) -> bool { |
284 | | - self.symbol.flags.contains(SymbolFlags::DEF_LOCAL) |
285 | | - } |
286 | | - |
287 | | - #[pymethod] |
288 | | - const fn is_parameter(&self) -> bool { |
289 | | - self.symbol.flags.contains(SymbolFlags::DEF_PARAM) |
290 | | - } |
291 | | - |
292 | | - #[pymethod] |
293 | | - const fn is_free(&self) -> bool { |
294 | | - matches!(self.symbol.scope, SymbolScope::Free) |
295 | | - } |
296 | | - |
297 | | - #[pymethod] |
298 | | - const fn is_namespace(&self) -> bool { |
299 | | - !self.namespaces.is_empty() |
300 | | - } |
301 | | - |
302 | | - #[pymethod] |
303 | | - const fn is_annotated(&self) -> bool { |
304 | | - self.symbol.flags.contains(SymbolFlags::DEF_ANNOT) |
305 | | - } |
306 | | - |
307 | | - #[pymethod] |
308 | | - fn get_namespaces(&self, vm: &VirtualMachine) -> Vec<PyObjectRef> { |
309 | | - self.namespaces |
310 | | - .iter() |
311 | | - .map(|table| to_py_symbol_table(table.clone()).into_pyobject(vm)) |
312 | | - .collect() |
313 | | - } |
314 | | - |
315 | | - #[pymethod] |
316 | | - fn get_namespace(&self, vm: &VirtualMachine) -> PyResult { |
317 | | - if self.namespaces.len() != 1 { |
318 | | - return Err(vm.new_value_error("namespace is bound to multiple namespaces")); |
319 | | - } |
320 | | - Ok(to_py_symbol_table(self.namespaces.first().unwrap().clone()) |
321 | | - .into_ref(&vm.ctx) |
322 | | - .into()) |
323 | | - } |
324 | | - } |
325 | 212 | } |