visitBinaryOperatorExpr method

  1. @override
void visitBinaryOperatorExpr(
  1. BinaryOperatorExpr ast,
  2. EmitterVisitorContext context
)
override

Implementation

@override
void visitBinaryOperatorExpr(
    o.BinaryOperatorExpr ast, EmitterVisitorContext context) {
  String opStr;
  switch (ast.operator) {
    case o.BinaryOperator.Equals:
      opStr = '==';
      break;
    case o.BinaryOperator.Identical:
      opStr = '===';
      break;
    case o.BinaryOperator.NotEquals:
      opStr = '!=';
      break;
    case o.BinaryOperator.NotIdentical:
      opStr = '!==';
      break;
    case o.BinaryOperator.And:
      opStr = '&&';
      break;
    case o.BinaryOperator.Or:
      opStr = '||';
      break;
    case o.BinaryOperator.Plus:
      opStr = '+';
      break;
    case o.BinaryOperator.Minus:
      opStr = '-';
      break;
    case o.BinaryOperator.Divide:
      opStr = '/';
      break;
    case o.BinaryOperator.Multiply:
      opStr = '*';
      break;
    case o.BinaryOperator.Modulo:
      opStr = '%';
      break;
    case o.BinaryOperator.Lower:
      opStr = '<';
      break;
    case o.BinaryOperator.LowerEquals:
      opStr = '<=';
      break;
    case o.BinaryOperator.Bigger:
      opStr = '>';
      break;
    case o.BinaryOperator.BiggerEquals:
      opStr = '>=';
      break;
    default:
      throw StateError('Unknown operator ${ast.operator}');
  }
  context.print('(');
  ast.lhs.visitExpression(this, context);
  context.print(' $opStr ');
  ast.rhs.visitExpression(this, context);
  context.print(')');
}