pivot method

  1. @override
Object? pivot(
  1. DataInstance? model,
  2. EvaluationContext context,
  3. List<Object> pivots,
  4. Object sentinel,
)
override

Pivots this expression around sentinel (the validated node's reference), adding CmpPivots to pivots.

Returns sentinel when the value is the node, null when it depends on it in a supported way, otherwise the evaluated value. Throws UnpivotableExpressionException when the dependency can't be expressed as pivots.

Port of XPathExpression.pivot; see pivotsOf.

Implementation

@override
Object? pivot(
  DataInstance? model,
  EvaluationContext context,
  List<Object> pivots,
  Object sentinel,
) {
  final x = a.pivot(model, context, pivots, sentinel);
  final y = b.pivot(model, context, pivots, sentinel);
  if (identical(x, sentinel) || identical(y, sentinel)) {
    throw const UnpivotableExpressionException();
  }
  if (x == null || y == null) return null;
  return eval(model, context);
}