| 2896 | |
| 2897 | |
| 2898 | bool FunctionCast::isCompilable() const |
| 2899 | { |
| 2900 | if (getName() != "CAST" || argument_types.size() != 2) |
| 2901 | return false; |
| 2902 | |
| 2903 | const auto & input_type = argument_types[0]; |
| 2904 | const auto & result_type = getResultType(); |
| 2905 | auto denull_input_type = removeNullable(input_type); |
| 2906 | auto denull_result_type = removeNullable(result_type); |
| 2907 | if (!canBeNativeType(denull_input_type) || !canBeNativeType(denull_result_type)) |
| 2908 | return false; |
| 2909 | |
| 2910 | return castBothTypes(denull_input_type.get(), denull_result_type.get(), [](const auto & left, const auto & right) |
| 2911 | { |
| 2912 | using LeftDataType = std::decay_t<decltype(left)>; |
| 2913 | using RightDataType = std::decay_t<decltype(right)>; |
| 2914 | if constexpr (IsDataTypeDecimalOrNumber<LeftDataType> && IsDataTypeDecimalOrNumber<RightDataType>) |
| 2915 | { |
| 2916 | if constexpr (IsDataTypeNumber<LeftDataType> && IsDataTypeNumber<RightDataType>) |
| 2917 | return true; |
| 2918 | else if constexpr (IsDataTypeNumber<LeftDataType> && IsDataTypeDecimal<RightDataType>) |
| 2919 | return true; |
| 2920 | else if constexpr (IsDataTypeDecimal<LeftDataType> && IsDataTypeNumber<RightDataType>) |
| 2921 | return true; |
| 2922 | } |
| 2923 | return false; |
| 2924 | }); |
| 2925 | } |
| 2926 | |
| 2927 | llvm::Value * FunctionCast::compile(llvm::IRBuilderBase & builder, const ValuesWithType & arguments) const |
| 2928 | { |
nothing calls this directly
no test coverage detected