Yume
Public Member Functions | List of all members
yume::ty::Type Class Reference

A "qualified" type, with a non-stackable qualifier, i.e. mut. More...

#include <type_base.hpp>

Public Member Functions

 Type (nonnull< const BaseType * > base, bool mut, bool ref) noexcept
 
 Type (nonnull< const BaseType * > base) noexcept
 
auto operator<=> (const Type &) const noexcept=default
 
auto opaque_equal (const Type &other) const noexcept -> bool
 
auto kind () const noexcept -> Kind
 
auto base () const noexcept -> nonnull< const BaseType * >
 
template<typename T >
auto base_cast () const noexcept -> nonnull< const T * >
 
template<typename T >
auto base_dyn_cast () const noexcept -> nullable< const T * >
 
template<typename T >
auto try_as () const noexcept -> optional< Type >
 
template<typename T >
auto base_isa () const noexcept -> bool
 
auto has_qualifier (Qualifier qual) const -> bool
 
auto name () const -> string
 
auto base_name () const -> string
 
auto determine_generic_subs (Type generic, const Substitutions &subs) const -> optional< Substitutions >
 
auto apply_generic_substitution (const Substitutions &sub) const -> Type
 
auto compatibility (Type other, Compat compat=Compat()) const -> Compat
 
auto known_qual (Qualifier qual) const -> Type
 Get this type with a given qualifier applied. More...
 
auto known_ptr () const -> Type
 
auto known_mut () const -> Type
 
auto known_ref () const -> Type
 
auto known_meta () const -> Type
 
auto known_opaque () const -> Type
 
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. More...
 
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. More...
 
auto is_mut () const noexcept -> bool
 
auto is_ref () const noexcept -> bool
 
auto is_unqualified () const noexcept -> bool
 
auto is_slice () const noexcept -> bool
 
auto is_generic () const noexcept -> bool
 
auto is_opaque_self () const noexcept -> bool
 
auto is_meta () const noexcept -> bool
 
auto is_trivially_destructible () const -> bool
 
auto mut_base () const noexcept -> optional< Type >
 If this type is a mutable reference, return the base of it (T mut -> T) More...
 
auto ensure_mut_base () const noexcept(false) -> Type
 If this type is a mutable reference, return the base of it (T mut -> T) More...
 
auto ptr_base () const noexcept -> optional< Type >
 If this type is a pointer type, return the base of it (T ptr -> T) More...
 
auto ensure_ptr_base () const noexcept(false) -> Type
 If this type is a pointer type, return the base of it (T ptr -> T) More...
 
auto without_mut () const noexcept -> Type
 If this type is a mutable reference, return the base of it, otherwise return itself. More...
 
auto without_opaque () const noexcept -> Type
 If this type is a opaque wrapper type, return the wrapper type, otherwise return itself. More...
 
auto without_meta () const noexcept -> Type
 
auto generic_base () const noexcept -> Type
 

Detailed Description

A "qualified" type, with a non-stackable qualifier, i.e. mut.

Definition at line 66 of file type_base.hpp.

Constructor & Destructor Documentation

◆ Type() [1/2]

yume::ty::Type::Type ( nonnull< const BaseType * >  base,
bool  mut,
bool  ref 
)
inlinenoexcept

Definition at line 72 of file type_base.hpp.

Referenced by mut_base().

◆ Type() [2/2]

yume::ty::Type::Type ( nonnull< const BaseType * >  base)
inlinenoexcept

Definition at line 73 of file type_base.hpp.

Member Function Documentation

◆ apply_generic_substitution()

auto yume::ty::Type::apply_generic_substitution ( const Substitutions sub) const -> Type

Definition at line 279 of file type.cpp.

References base().

Referenced by yume::semantic::OverloadSet::is_valid_overload().

◆ base()

auto yume::ty::Type::base ( ) const -> nonnull<const BaseType*>
inlinenoexcept

Definition at line 79 of file type_base.hpp.

Referenced by apply_generic_substitution(), and is_slice().

◆ base_cast()

template<typename T >
auto yume::ty::Type::base_cast ( ) const -> nonnull<const T*>
inlinenoexcept

Definition at line 80 of file type_base.hpp.

Referenced by yume::Compiler::destruct(), and yume::ty::visit_subs().

◆ base_dyn_cast()

template<typename T >
auto yume::ty::Type::base_dyn_cast ( ) const -> nullable<const T*>
inlinenoexcept

Definition at line 81 of file type_base.hpp.

Referenced by yume::Compiler::destruct(), and yume::ty::visit_subs().

◆ base_isa()

template<typename T >
auto yume::ty::Type::base_isa ( ) const -> bool
inlinenoexcept

Definition at line 90 of file type_base.hpp.

Referenced by yume::ty::visit_subs().

◆ base_name()

auto yume::ty::Type::base_name ( ) const -> string

Definition at line 458 of file type.cpp.

◆ coalesce()

auto yume::ty::Type::coalesce ( Type  other) const -> optional<Type>
noexcept

The union of this and other. For example, the union of T and T mut is T mut.

Returns
nullopt if an union cannot be created.

Definition at line 405 of file type.cpp.

◆ compatibility()

auto yume::ty::Type::compatibility ( Type  other,
Compat  compat = Compat() 
) const -> Compat

Definition at line 135 of file type.cpp.

References yume::ty::BaseType::kind(), and yume::ty::Compat::valid.

◆ determine_generic_subs()

auto yume::ty::Type::determine_generic_subs ( Type  generic,
const Substitutions subs 
) const -> optional<Substitutions>

Definition at line 96 of file type.cpp.

References yume::ty::visit_subs(), and YUME_ASSERT.

Referenced by yume::semantic::OverloadSet::is_valid_overload().

◆ ensure_mut_base()

auto yume::ty::Type::ensure_mut_base ( ) const -> Type
noexcept

If this type is a mutable reference, return the base of it (T mut -> T)

Exceptions
ifthis type isn't a mutable reference.

Definition at line 387 of file type.cpp.

References is_mut().

Referenced by yume::ty::visit_subs().

◆ ensure_ptr_base()

auto yume::ty::Type::ensure_ptr_base ( ) const -> Type
noexcept

If this type is a pointer type, return the base of it (T ptr -> T)

Exceptions
ifthis type isn't a pointer type.

Definition at line 399 of file type.cpp.

Referenced by is_generic().

◆ generic_base()

auto yume::ty::Type::generic_base ( ) const -> Type
noexcept

Definition at line 441 of file type.cpp.

References YUME_ASSERT.

◆ has_qualifier()

auto yume::ty::Type::has_qualifier ( Qualifier  qual) const -> bool

Definition at line 269 of file type.cpp.

References yume::Mut, and yume::Ref.

◆ intersect()

auto yume::ty::Type::intersect ( Type  other) const -> optional<Type>
noexcept

Return the intersection of this and other. For example, the intersection of T and T mut is T.

Returns
nullopt is there's not intersection between the types.

Definition at line 416 of file type.cpp.

◆ is_generic()

auto yume::ty::Type::is_generic ( ) const -> bool
noexcept

◆ is_meta()

auto yume::ty::Type::is_meta ( ) const -> bool
noexcept

Definition at line 251 of file type.cpp.

Referenced by yume::ty::visit_subs().

◆ is_mut()

auto yume::ty::Type::is_mut ( ) const -> bool
inlinenoexcept

◆ is_opaque_self()

auto yume::ty::Type::is_opaque_self ( ) const -> bool
noexcept

Definition at line 249 of file type.cpp.

◆ is_ref()

auto yume::ty::Type::is_ref ( ) const -> bool
inlinenoexcept

Definition at line 115 of file type_base.hpp.

◆ is_slice()

auto yume::ty::Type::is_slice ( ) const -> bool
noexcept

◆ is_trivially_destructible()

auto yume::ty::Type::is_trivially_destructible ( ) const -> bool

Definition at line 253 of file type.cpp.

References yume::ast::AST::ensure_ty(), is_slice(), and name().

Referenced by yume::Compiler::destruct().

◆ is_unqualified()

auto yume::ty::Type::is_unqualified ( ) const -> bool
inlinenoexcept

Definition at line 116 of file type_base.hpp.

Referenced by yume::semantic::TypeWalker::expression().

◆ kind()

auto yume::ty::Type::kind ( ) const -> Kind
inlinenoexcept

Definition at line 78 of file type_base.hpp.

◆ known_meta()

auto yume::ty::Type::known_meta ( ) const -> Type
inline

Definition at line 104 of file type_base.hpp.

References known_qual(), and yume::Type.

Referenced by yume::semantic::TypeWalker::expression().

◆ known_mut()

auto yume::ty::Type::known_mut ( ) const -> Type
inline

Definition at line 102 of file type_base.hpp.

References known_qual(), and yume::Mut.

◆ known_opaque()

auto yume::ty::Type::known_opaque ( ) const -> Type
inline

Definition at line 105 of file type_base.hpp.

References known_qual(), and yume::Opaque.

◆ known_ptr()

auto yume::ty::Type::known_ptr ( ) const -> Type
inline

Definition at line 101 of file type_base.hpp.

References known_qual(), and yume::Ptr.

◆ known_qual()

auto yume::ty::Type::known_qual ( Qualifier  qual) const -> Type

Get this type with a given qualifier applied.

Definition at line 31 of file type.cpp.

References yume::Mut, yume::Opaque, yume::Ptr, yume::Ref, and yume::Type.

Referenced by known_meta(), known_mut(), known_opaque(), known_ptr(), and known_ref().

◆ known_ref()

auto yume::ty::Type::known_ref ( ) const -> Type
inline

Definition at line 103 of file type_base.hpp.

References known_qual(), and yume::Ref.

◆ mut_base()

auto yume::ty::Type::mut_base ( ) const -> optional<Type>
noexcept

If this type is a mutable reference, return the base of it (T mut -> T)

Returns
nullopt if this type isn't a mutable reference.

Definition at line 381 of file type.cpp.

References is_mut(), and Type().

Referenced by yume::Compiler::destruct().

◆ name()

auto yume::ty::Type::name ( ) const -> string

◆ opaque_equal()

auto yume::ty::Type::opaque_equal ( const Type other) const -> bool
noexcept

Definition at line 506 of file type.cpp.

◆ operator<=>()

auto yume::ty::Type::operator<=> ( const Type ) const
defaultnoexcept

◆ ptr_base()

auto yume::ty::Type::ptr_base ( ) const -> optional<Type>
noexcept

If this type is a pointer type, return the base of it (T ptr -> T)

Returns
nullopt if this type isn't a pointer type.

Definition at line 393 of file type.cpp.

Referenced by yume::ty::visit_subs().

◆ try_as()

template<typename T >
auto yume::ty::Type::try_as ( ) const -> optional<Type>
inlinenoexcept

Definition at line 84 of file type_base.hpp.

◆ without_meta()

auto yume::ty::Type::without_meta ( ) const -> Type
noexcept

Definition at line 435 of file type.cpp.

Referenced by is_generic(), and yume::ty::visit_subs().

◆ without_mut()

auto yume::ty::Type::without_mut ( ) const -> Type
noexcept

If this type is a mutable reference, return the base of it, otherwise return itself.

Definition at line 427 of file type.cpp.

◆ without_opaque()

auto yume::ty::Type::without_opaque ( ) const -> Type
noexcept

If this type is a opaque wrapper type, return the wrapper type, otherwise return itself.

Definition at line 429 of file type.cpp.


The documentation for this class was generated from the following files: