evalUnaryExpression method

  1. @protected
dynamic evalUnaryExpression(
  1. UnaryExpression expression,
  2. Map<String, dynamic> context
)
inherited

Implementation

@protected
dynamic evalUnaryExpression(
  UnaryExpression expression,
  Map<String, dynamic> context,
) {
  final argument = eval(expression.argument, context);
  dynamic result;
  switch (expression.operator) {
    case '-':
      result = -argument;
      break;

    case '+':
      result = argument;
      break;

    case '!':
      result = !argument;
      break;

    case '~':
      result = ~argument;
      break;

    default:
      throw ArgumentError('Unknown unary operator ${expression.operator}');
  }

  return result;
}