evaluate method

  1. @override
dynamic evaluate(
  1. EvaluationType type,
  2. ContextModel context
)
override

Evaluates this expression according to given type and context.

Implementation

@override
dynamic evaluate(EvaluationType type, ContextModel context) {
  if (type == EvaluationType.REAL) {
    return value;
  }

  if (type == EvaluationType.INTERVAL) {
    // interpret number as interval
    final IntervalLiteral intLit = IntervalLiteral.fromSingle(this);
    return intLit.evaluate(type, context);
  }

  if (type == EvaluationType.VECTOR) {
    // interpret number as scalar
    return value;
  }

  throw UnsupportedError('Number $this can not be interpreted as: $type');
}