visitBlock method

  1. @override
void visitBlock(
  1. SBlock node
)
override

Resolve a block frame, then commit compacted slots (perf plan_3 ยง4.6): eligible candidate decls get dense indices 0..k-1 in lexical order, their pending depth-0 reads get resolvedSlot, and the block records slotCount.

Implementation

@override
void visitBlock(SBlock node) {
  // A block inside an async/generator function body is non-slottable: its
  // locals can be rebound by the state-machine resume back-channel.
  final frame = _ScopeFrame(!_inAsyncFunction);
  _stack.add(frame);
  node.visitChildren(this);
  _stack.removeLast();

  var slot = 0;
  for (final decl in frame.decls) {
    if (!decl.isCandidate || !decl.eligible) continue;
    decl.node!.declSlot = slot;
    for (final use in decl.pendingReads) {
      use.resolvedDepth = 0;
      use.resolvedSlot = slot;
    }
    slot++;
  }
  node.slotCount = slot;
}