withActiveVisitor<T> static method

T withActiveVisitor<T>(
  1. InterpreterVisitor visitor,
  2. T fn()
)

Execute fn with the given visitor as the active visitor. Restores the previous visitor when done (supports nesting).

Implementation

static T withActiveVisitor<T>(InterpreterVisitor visitor, T Function() fn) {
  final previous = _activeVisitor;
  _activeVisitor = visitor;
  try {
    return fn();
  } finally {
    _activeVisitor = previous;
  }
}