| 42 | } // namespace |
| 43 | |
| 44 | SwitchExpr::SwitchExpr( |
| 45 | TypePtr type, |
| 46 | const std::vector<ExprPtr>& inputs, |
| 47 | bool inputsSupportFlatNoNullsFastPath) |
| 48 | : SpecialForm( |
| 49 | std::move(type), |
| 50 | inputs, |
| 51 | "switch", |
| 52 | hasElseClause(inputs) && inputsSupportFlatNoNullsFastPath, |
| 53 | false /* trackCpuUsage */), |
| 54 | numCases_{inputs_.size() / 2}, |
| 55 | hasElseClause_{hasElseClause(inputs_)} { |
| 56 | std::vector<TypePtr> inputTypes; |
| 57 | inputTypes.reserve(inputs_.size()); |
| 58 | std::transform( |
| 59 | inputs_.begin(), |
| 60 | inputs_.end(), |
| 61 | std::back_inserter(inputTypes), |
| 62 | [](const ExprPtr& expr) { return expr->type(); }); |
| 63 | |
| 64 | // Apply type checking. |
| 65 | auto typeExpected = resolveType(inputTypes); |
| 66 | BOLT_CHECK( |
| 67 | *typeExpected == *this->type(), |
| 68 | "Switch expression type different than then clause. Expected {} but got Actual {}.", |
| 69 | typeExpected->toString(), |
| 70 | this->type()->toString()); |
| 71 | } |
| 72 | |
| 73 | void SwitchExpr::evalSpecialForm( |
| 74 | const SelectivityVector& rows, |
nothing calls this directly
no test coverage detected