pivot method

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

. or the node itself is the sentinel; paths with predicates can't be pivoted; other paths evaluate normally.

Implementation

@override
Object? pivot(
  DataInstance? model,
  EvaluationContext context,
  List<Object> pivots,
  Object sentinel,
) {
  final ref = _reference;
  if (ref == sentinel || ref.refLevel == 0) return sentinel;
  for (var i = 0; i < ref.size; i++) {
    final predicates = ref.predicatesAt(i);
    if (predicates != null && predicates.isNotEmpty) {
      throw UnpivotableExpressionException(
        "Can't pivot filtered treereferences. Ref: "
        '${ref.toString(includePredicates: true)} has predicates.',
      );
    }
  }
  return eval(model, context);
}