evaluate method

dynamic evaluate(
  1. Evaluator evaluator,
  2. Buffer buffer
)

Implementation

dynamic evaluate(Evaluator evaluator, Buffer buffer) {
  evaluator.context.pushScope();

  final innerEvaluator = evaluator.createInnerEvaluator()
    ..context.setRoot(evaluator.context.getRoot());

  var result = evaluateWithContext(innerEvaluator, buffer);

  // Store the variables from the current scope before popping it
  final currentScopeVariables = innerEvaluator.context.all();
  evaluator.context.popScope();

  // Merge the stored variables back into the previous scope
  evaluator.context.merge(currentScopeVariables);

  return result;
}