Пример #1
0
Value NegationTranslator::DeriveValue(CodeGen &codegen,
                                      RowBatch::Row &row) const {
  const auto &negation_expr =
      GetExpressionAs<expression::OperatorUnaryMinusExpression>();
  Value child_value = row.DeriveValue(codegen, *negation_expr.GetChild(0));
  return child_value.CallUnaryOp(codegen, OperatorId::Negation);
}
Пример #2
0
// Produce the value that is the result of codegening the expression
codegen::Value ConjunctionTranslator::DeriveValue(CodeGen &codegen,
                                                  RowBatch::Row &row) const {
  const auto &conjunction =
      GetExpressionAs<expression::ConjunctionExpression>();
  codegen::Value left = row.DeriveValue(codegen, *conjunction.GetChild(0));
  codegen::Value right = row.DeriveValue(codegen, *conjunction.GetChild(1));

  switch (conjunction.GetExpressionType()) {
    case ExpressionType::CONJUNCTION_AND:
      return left.LogicalAnd(codegen, right);
    case ExpressionType::CONJUNCTION_OR:
      return left.LogicalOr(codegen, right);
    default:
      throw Exception{"Received a non-conjunction expression type: " +
                      ExpressionTypeToString(conjunction.GetExpressionType())};
  }
}