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) {
  final dynamic firstEval = first.evaluate(type, context);
  final dynamic secondEval = second.evaluate(type, context);

  if (type == EvaluationType.VECTOR) {
    if (secondEval is double) {
      // scale - nothing special to do
    } else {
      // multiply
      final dynamic eval = firstEval.clone()..multiply(secondEval);
      return eval;
    }
  }

  return firstEval * secondEval;
}