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),
62 PreferOriginalType = (1U << 6U),
65 DisallowTypeChanges = (1U << 7U),
73 ContextualConversion = (1U << 8U),
76 _Recursing = (1U << 10U),
82 TryAllForAssignment = (1U << 0U) | (1U << 3U) | (1U << 4U) | (1U << 5U) | (1U << 6U),
88 TryAllForMatching = (1U << 1U) | (1U << 3U) | (1U << 4U) | (1U << 5U) | (1U << 6U),
94 TryDirectMatchForFunctionCall = (1U << 2U) | (1U << 3U) | (1U << 4U) | (1U << 6U),
100 TryAllForFunctionCall = (1U << 2U) | (1U << 3U) | (1U << 4U) | (1U << 5U) | (1U << 6U),
106 TryDirectForMatching = (1U << 1U) | (1U << 3U) | (1U << 4U) | (1U << 6U)
113 extern std::string to_string(bitmask<CoercionStyle> style);
117 enableEnumClassBitmask(hilti::CoercionStyle);
124 operator bool()
const {
return coerced.hasValue(); }
137 std::optional<Expression> nexpr = {};
144 bool consider_type_changed =
false;
171 consider_type_changed(type::effectiveType(
std::move(src)).typename_() !=
172 type::effectiveType(coerced.type()).typename_()) {}
203 bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
225 CoercedExpression coerceExpression(
const Expression& e,
const Type& src_,
const Type& dst_,
226 bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
246 const std::vector<operator_::Operand>& operands,
247 bitmask<CoercionStyle> style);
259 Result<Ctor> coerceCtor(Ctor c,
const Type& dst, bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
271 Result<Type> coerceType(
const Type& src_,
const Type& dst_,
272 bitmask<CoercionStyle> style = CoercionStyle::TryAllForAssignment);
CoercedExpression(Type src, Expression coerced)
Definition: coercion.h:168
Definition: optional.h:79
CoercedExpression(const Expression &src)
Definition: coercion.h:159
Definition: coercion.h:122
CoercedExpression(const result::Error &error)
Definition: coercion.h:181