visitBinaryExpr method

  1. @override
void visitBinaryExpr(
  1. BinaryExpr node
)
override

*, /, ~/, %, +, -, <, >, <=, >=, ==, !=, &&, ||

Implementation

@override
void visitBinaryExpr(BinaryExpr node) {
  node.left.accept(this);
  node.right.accept(this);
  final left = node.left.value;
  final right = node.right.value;
  if (node.op == _lexicon.multiply) {
    if (left != null && right != null) {
      node.value = left * right;
    }
  } else if (node.op == _lexicon.devide) {
    if (left != null && right != null) {
      node.value = left / right;
    }
  } else if (node.op == _lexicon.truncatingDevide) {
    if (left != null && right != null) {
      node.value = left ~/ right;
    }
  } else if (node.op == _lexicon.modulo) {
    if (left != null && right != null) {
      node.value = left % right;
    }
  } else if (node.op == _lexicon.add) {
    if (left != null && right != null) {
      node.value = left + right;
    }
  } else if (node.op == _lexicon.subtract) {
    if (left != null && right != null) {
      node.value = left - right;
    }
  } else if (node.op == _lexicon.lesser) {
    if (left != null && right != null) {
      node.value = left < right;
    }
  } else if (node.op == _lexicon.lesserOrEqual) {
    if (left != null && right != null) {
      node.value = left <= right;
    }
  } else if (node.op == _lexicon.greater) {
    if (left != null && right != null) {
      node.value = left > right;
    }
  } else if (node.op == _lexicon.greaterOrEqual) {
    if (left != null && right != null) {
      node.value = left >= right;
    }
  } else if (node.op == _lexicon.equal) {
    if (left != null && right != null) {
      node.value = left == right;
    }
  } else if (node.op == _lexicon.notEqual) {
    if (left != null && right != null) {
      node.value = left != right;
    }
  } else if (node.op == _lexicon.logicalAnd) {
    if (left != null && right != null) {
      node.value = left && right;
    }
  } else if (node.op == _lexicon.logicalOr) {
    if (left != null && right != null) {
      node.value = left || right;
    }
  }
}