eval method

  1. @override
Object? eval(
  1. Map<String, Object?> row
)
override

Evaluate this expression in the context of row (column name -> value).

Implementation

@override
Object? eval(Map<String, Object?> row) {
  final v = operand.eval(row);
  switch (op) {
    case 'NOT':
      if (v == null) return null;
      return !(v as bool);
    case '-':
      if (v == null) return null;
      return -(v as num);
    case '~':
      if (v == null) return null;
      return ~((v as num).toInt());
    case 'IS NULL':
      return v == null;
    case 'IS NOT NULL':
      return v != null;
    case 'IS TRUE':
      return _truthy(v) == true;
    case 'IS NOT TRUE':
      return _truthy(v) != true;
    case 'IS FALSE':
      return _truthy(v) == false;
    case 'IS NOT FALSE':
      return _truthy(v) != false;
  }
  throw StateError('Unknown unary op: $op');
}