| 1847 | } |
| 1848 | |
| 1849 | static uint32_t python_nearest_namespace(const WalkState *state, uint32_t start_id) { |
| 1850 | uint32_t id = start_id; |
| 1851 | int remaining = state ? state->lexical_scope_count : 0; |
| 1852 | while (id != 0 && remaining-- > 0) { |
| 1853 | const CBMLexicalScope *scope = usage_lexical_scope(state, id); |
| 1854 | if (!scope) { |
| 1855 | return 0; |
| 1856 | } |
| 1857 | if (scope->kind == CBM_LEXICAL_SCOPE_FUNCTION || |
| 1858 | scope->kind == CBM_LEXICAL_SCOPE_COMPREHENSION || |
| 1859 | scope->kind == CBM_LEXICAL_SCOPE_CLASS || scope->kind == CBM_LEXICAL_SCOPE_MODULE) { |
| 1860 | return id; |
| 1861 | } |
| 1862 | id = scope->parent_id; |
| 1863 | } |
| 1864 | return 0; |
| 1865 | } |
| 1866 | |
| 1867 | static bool ensure_lexical_binding_capacity(WalkState *state) { |
| 1868 | if (!state->lexical_bindings) { |
no test coverage detected