| 307 | } |
| 308 | |
| 309 | static bool push_scope(WalkState *state, uint8_t kind, uint32_t depth, const char *qn) { |
| 310 | if (!ensure_scope_capacity(state)) { |
| 311 | return false; |
| 312 | } |
| 313 | CBMWalkScope *f = &state->scopes[state->scope_top]; |
| 314 | f->prev_py_param_stack_count = state->py_param_stack_count; |
| 315 | f->kind = kind; |
| 316 | f->depth = depth; |
| 317 | f->qn = qn; |
| 318 | f->lexical_scope_id = 0; |
| 319 | f->invocation_kind = CBM_INVOCATION_NONE; |
| 320 | f->callee_expr = (TSNode){0}; |
| 321 | f->callee_leaf = (TSNode){0}; |
| 322 | /* Save the complete displaced tuple, then apply this frame's effect -- |
| 323 | * pop_expired_scopes restores verbatim. O(1) either way; see the |
| 324 | * CBMWalkScope comment for the quadratic recompute this replaces. */ |
| 325 | f->prev_enclosing_func_qn = state->enclosing_func_qn; |
| 326 | f->prev_enclosing_class_qn = state->enclosing_class_qn; |
| 327 | f->prev_invocation_kind = state->invocation_kind; |
| 328 | f->prev_callee_expr = state->callee_expr; |
| 329 | f->prev_callee_leaf = state->callee_leaf; |
| 330 | f->prev_inside_import = state->inside_import; |
| 331 | f->prev_loop_depth = state->loop_depth; |
| 332 | f->prev_branch_depth = state->branch_depth; |
| 333 | switch (kind) { |
| 334 | case SCOPE_FUNC: |
| 335 | state->enclosing_func_qn = qn; |
| 336 | break; |
| 337 | case SCOPE_CLASS: |
| 338 | case SCOPE_NAMESPACE: |
| 339 | state->enclosing_class_qn = qn; |
| 340 | break; |
| 341 | case SCOPE_CALL: |
| 342 | /* The invocation triple is applied by push_call_scope once the caller |
| 343 | * has filled the frame fields. */ |
| 344 | break; |
| 345 | case SCOPE_IMPORT: |
| 346 | state->inside_import = true; |
| 347 | break; |
| 348 | case SCOPE_LOOP: |
| 349 | state->loop_depth++; |
| 350 | break; |
| 351 | case SCOPE_BRANCH: |
| 352 | state->branch_depth++; |
| 353 | break; |
| 354 | default: |
| 355 | break; |
| 356 | } |
| 357 | state->scope_top++; |
| 358 | return true; |
| 359 | } |
| 360 | |
| 361 | static bool push_lexical_scope(WalkState *state, uint8_t walk_kind, uint32_t depth, const char *qn, |
| 362 | TSNode node, CBMLexicalScopeKind lexical_kind) { |
no test coverage detected