defineSlot method

void defineSlot(
  1. int slot,
  2. String name,
  3. Object? value
)

Writes value into this frame's slot array at slot and records the nameslot mapping, growing/allocating _slots lazily.

S3b is additive: the caller still calls define to keep the name binding in _values; this records the parallel slot so the debug parity assert can validate the two views. The name is kept so a later assign to the same local keeps the slot in sync (the resolver only slots read-only locals, but async-init resume and late initialization set the value through a path other than the original define).

Implementation

void defineSlot(int slot, String name, Object? value) {
  var slots = _slots;
  if (slots == null) {
    slots = List<Object?>.filled(slot + 1, _unset, growable: true);
    _slots = slots;
  } else if (slot >= slots.length) {
    while (slots.length <= slot) {
      slots.add(_unset);
    }
  }
  slots[slot] = value;
  (_slotIndex ??= {})[name] = slot;
}