43 mutable unique_ptr<BaseType> m_known_ptr{};
44 mutable unique_ptr<BaseType> m_known_opaque_self{};
45 mutable unique_ptr<BaseType> m_known_meta{};
57 [[nodiscard]] auto
kind() const ->
Kind {
return m_kind; };
58 [[nodiscard]]
auto base_name() const ->
string {
return m_name; };
59 [[nodiscard]]
virtual auto name() const ->
string = 0;
78 [[nodiscard]]
auto kind() const noexcept ->
Kind {
return m_base->kind(); };
80 template <
typename T> [[nodiscard]]
auto base_cast() const noexcept ->
nonnull<const T*> {
return cast<T>(m_base); }
82 return dyn_cast<T>(m_base);
84 template <
typename T> [[nodiscard]]
auto try_as() const noexcept -> optional<
Type> {
85 const auto* cast = dyn_cast<T>(m_base);
90 template <
typename T> [[nodiscard]]
auto base_isa() const noexcept ->
bool {
return isa<T>(m_base); }
92 [[nodiscard]]
auto name() const ->
string;
93 [[nodiscard]] auto
base_name() const ->
string;
109 [[nodiscard]]
auto coalesce(
Type other)
const noexcept -> optional<Type>;
112 [[nodiscard]]
auto intersect(
Type other)
const noexcept -> optional<Type>;
114 [[nodiscard]]
auto is_mut() const noexcept ->
bool {
return m_mut; };
115 [[nodiscard]]
auto is_ref() const noexcept ->
bool {
return m_ref; };
116 [[nodiscard]]
auto is_unqualified() const noexcept ->
bool {
return !m_ref && !m_mut; };
117 [[nodiscard]]
auto is_slice() const noexcept ->
bool;
118 [[nodiscard]] auto
is_generic() const noexcept ->
bool;
120 [[nodiscard]] auto
is_meta() const noexcept ->
bool;
126 [[nodiscard]] auto
mut_base() const noexcept -> optional<
Type>;
134 [[nodiscard]] auto
ptr_base() const noexcept -> optional<
Type>;
Represents a type in the type system. NOTE: that this isn't the class to use for type introspection,...
BaseType(const BaseType &) noexcept=delete
virtual auto name() const -> string=0
auto kind() const -> Kind
BaseType(BaseType &&) noexcept=delete
auto base_name() const -> string
A "qualified" type, with a non-stackable qualifier, i.e. mut.
auto apply_generic_substitution(const Substitutions &sub) const -> Type
auto is_slice() const noexcept -> bool
auto operator<=>(const Type &) const noexcept=default
auto ensure_mut_base() const noexcept(false) -> Type
If this type is a mutable reference, return the base of it (T mut -> T)
auto is_mut() const noexcept -> bool
auto mut_base() const noexcept -> optional< Type >
If this type is a mutable reference, return the base of it (T mut -> T)
Type(nonnull< const BaseType * > base) noexcept
auto is_unqualified() const noexcept -> bool
auto try_as() const noexcept -> optional< Type >
auto known_ref() const -> Type
auto intersect(Type other) const noexcept -> optional< Type >
Return the intersection of this and other. For example, the intersection of T and T mut is T.
auto is_opaque_self() const noexcept -> bool
auto is_trivially_destructible() const -> bool
auto coalesce(Type other) const noexcept -> optional< Type >
The union of this and other. For example, the union of T and T mut is T mut.
auto generic_base() const noexcept -> Type
auto kind() const noexcept -> Kind
auto known_meta() const -> Type
auto determine_generic_subs(Type generic, const Substitutions &subs) const -> optional< Substitutions >
auto ensure_ptr_base() const noexcept(false) -> Type
If this type is a pointer type, return the base of it (T ptr -> T)
auto known_opaque() const -> Type
auto ptr_base() const noexcept -> optional< Type >
If this type is a pointer type, return the base of it (T ptr -> T)
auto known_ptr() const -> Type
auto has_qualifier(Qualifier qual) const -> bool
auto is_meta() const noexcept -> bool
auto base_isa() const noexcept -> bool
auto without_meta() const noexcept -> Type
auto base_name() const -> string
auto base_cast() const noexcept -> nonnull< const T * >
auto is_generic() const noexcept -> bool
auto base_dyn_cast() const noexcept -> nullable< const T * >
auto name() const -> string
auto without_mut() const noexcept -> Type
If this type is a mutable reference, return the base of it, otherwise return itself.
auto opaque_equal(const Type &other) const noexcept -> bool
auto is_ref() const noexcept -> bool
auto base() const noexcept -> nonnull< const BaseType * >
auto known_qual(Qualifier qual) const -> Type
Get this type with a given qualifier applied.
auto compatibility(Type other, Compat compat=Compat()) const -> Compat
auto known_mut() const -> Type
auto without_opaque() const noexcept -> Type
If this type is a opaque wrapper type, return the wrapper type, otherwise return itself.
Type(nonnull< const BaseType * > base, bool mut, bool ref) noexcept
@ K_Unknown
UnknownType, default, zero value. Hopefully never encountered!
@ Opaque
Opaque self types.
The compatibility between two types, for overload selection.