| 1714 | } |
| 1715 | |
| 1716 | static uint32_t python_nearest_namespace(const WalkState *state, uint32_t start_id) { |
| 1717 | uint32_t id = start_id; |
| 1718 | int remaining = state ? state->lexical_scope_count : 0; |
| 1719 | while (id != 0 && remaining-- > 0) { |
| 1720 | const CBMLexicalScope *scope = usage_lexical_scope(state, id); |
| 1721 | if (!scope) { |
| 1722 | return 0; |
| 1723 | } |
| 1724 | if (scope->kind == CBM_LEXICAL_SCOPE_FUNCTION || |
| 1725 | scope->kind == CBM_LEXICAL_SCOPE_COMPREHENSION || |
| 1726 | scope->kind == CBM_LEXICAL_SCOPE_CLASS || scope->kind == CBM_LEXICAL_SCOPE_MODULE) { |
| 1727 | return id; |
| 1728 | } |
| 1729 | id = scope->parent_id; |
| 1730 | } |
| 1731 | return 0; |
| 1732 | } |
| 1733 | |
| 1734 | static bool ensure_lexical_binding_capacity(WalkState *state) { |
| 1735 | if (!state->lexical_bindings) { |
no test coverage detected