9 #include <hilti/rt/3rdparty/ArticleEnumClass-v2/EnumClass.h> 11 #include <hilti/ast/ctor.h> 12 #include <hilti/ast/expression.h> 13 #include <hilti/ast/operator.h> 14 #include <hilti/ast/type.h> 15 #include <hilti/base/util.h> 20 enum class CoercionStyle {
25 Assignment = (1U << 0U),
31 OperandMatching = (1U << 1U),
37 FunctionCall = (1U << 2U),
43 TryExactMatch = (1U << 3U),
49 TryConstPromotion = (1U << 4U),
56 TryCoercion = (1U << 5U),
59 DisallowTypeChanges = (1U << 7U),
67 ContextualConversion = (1U << 8U),
70 _Recursing = (1U << 10U),
76 TryAllForAssignment = (1U << 0U) | (1U << 3U) | (1U << 4U) | (1U << 5U) | (1U << 6U),
82 TryAllForMatching = (1U << 1U) | (1U << 3U) | (1U << 4U) | (1U << 5U) | (1U << 6U),
88 TryDirectMatchForFunctionCall = (1U << 2U) | (1U << 3U) | (1U << 4U) | (1U << 6U),
94 TryAllForFunctionCall = (1U << 2U) | (1U << 3U) | (1U << 4U) | (1U << 5U) | (1U << 6U),
100 TryDirectForMatching = (1U << 1U) | (1U << 3U) | (1U << 4U) | (1U << 6U)
107 extern std::string to_string(bitmask<CoercionStyle> style);
111 enableEnumClassBitmask(hilti::CoercionStyle);
118 operator bool()
const {
return coerced.hasValue(); }
131 std::optional<Expression> nexpr = {};
138 bool consider_type_changed =
false;
163 : coerced(coerced), nexpr(coerced), consider_type_changed(src.typename_() != coerced.type().typename_()) {}
194 bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
217 bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
237 const std::vector<operator_::Operand>& operands,
238 bitmask<CoercionStyle> style);
250 Result<Ctor> coerceCtor(Ctor c,
const Type& dst, bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
263 bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
267 std::optional<Ctor> coerceCtor(Ctor c,
const Type& dst, bitmask<CoercionStyle> style);
269 std::optional<Type> coerceType(
Type t,
const Type& dst, bitmask<CoercionStyle> style);
CoercedExpression(const Expression &src)
Definition: coercion.h:153
Definition: coercion.h:116
CoercedExpression(const result::Error &error)
Definition: coercion.h:172
CoercedExpression(const Type &src, Expression coerced)
Definition: coercion.h:162