deref method

DartValue? deref(
  1. DartValue? v
)

Follows references and project calls to the values they stand for.

Implementation

DartValue? deref(DartValue? v) {
  var current = v;
  for (var i = 0; i < 16; i++) {
    final next = switch (current) {
      RefValue(:final resolved?) => resolved,
      CallValue(:final result?) => result,
      AccessValue(:final target, :final name) => _field(deref(target), name),
      _ => null,
    };
    if (next == null) return current;
    current = next;
  }
  return current;
}