|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Mutable substitution from type variables to replacement types. More...
#include <tpl_constraints.H>
Classes | |
| struct | Binding |
| One variable binding inside the substitution. More... | |
Public Member Functions | |
| size_t | size () const noexcept |
| Returns the number of stored variable bindings. | |
| bool | empty () const noexcept |
| Returns whether the substitution is empty. | |
| void | clear () noexcept |
| Removes every binding. | |
| const Binding & | binding (const size_t i) const |
Returns binding i. | |
| Compiler_Type_Id * | lookup (const Compiler_Type_Id variable) noexcept |
Looks up a bound replacement for variable. | |
| const Compiler_Type_Id * | lookup (const Compiler_Type_Id variable) const noexcept |
Looks up a bound replacement for variable. | |
| void | bind (const Compiler_Type_Id variable, const Compiler_Type_Id replacement) |
| Binds or updates one type-variable replacement. | |
| Compiler_Type_Id | apply (Compiler_Type_Context &ctx, const Compiler_Type_Id id) const |
Applies the substitution to id. | |
| std::string | to_string (Compiler_Type_Context &ctx) const |
| Renders all bindings in insertion order. | |
Private Member Functions | |
| Compiler_Type_Id | resolve_alias (const Compiler_Type_Id id) const |
Private Attributes | |
| DynArray< Binding > | bindings |
Mutable substitution from type variables to replacement types.
Definition at line 190 of file tpl_constraints.H.
|
inline |
Applies the substitution to id.
Composite types are rebuilt only when one of their children changes. This may append new nodes to ctx.
| ctx | Type context used to inspect and rebuild types. |
| id | Type to normalize. |
Definition at line 302 of file tpl_constraints.H.
References Aleph::DynArray< T >::access(), Aleph::DynArray< T >::append(), apply(), Aleph::blossom_maximum_cardinality_matching(), Aleph::Builtin, Aleph::Enum, Aleph::Function, Aleph::Compiler_Type_Context::make_function_type(), Aleph::Compiler_Type_Context::make_tuple_type(), resolve_alias(), Aleph::Struct, Aleph::Tuple, Aleph::Compiler_Type_Context::type(), and Aleph::Type_Variable.
Referenced by apply(), Aleph::Compiler_Type_Unifier::apply(), and to_string().
|
inline |
Binds or updates one type-variable replacement.
| variable | Type variable to bind. |
| replacement | Replacement type. |
Definition at line 281 of file tpl_constraints.H.
References bindings, Aleph::blossom_maximum_cardinality_matching(), and lookup().
Referenced by Aleph::Compiler_Type_Unifier::bind_variable().
Returns binding i.
| i | Binding index. |
| std::out_of_range | If i is invalid. |
Definition at line 243 of file tpl_constraints.H.
References ah_out_of_range_error_unless, and bindings.
|
inlinenoexcept |
Removes every binding.
Definition at line 232 of file tpl_constraints.H.
References bindings.
Referenced by Aleph::Compiler_Type_Unifier::clear().
|
inlinenoexcept |
Returns whether the substitution is empty.
Definition at line 226 of file tpl_constraints.H.
References bindings.
|
inlinenoexcept |
Looks up a bound replacement for variable.
| variable | Type variable id to search. |
nullptr if unbound. Definition at line 268 of file tpl_constraints.H.
References bindings.
|
inlinenoexcept |
Looks up a bound replacement for variable.
| variable | Type variable id to search. |
nullptr if unbound. Definition at line 255 of file tpl_constraints.H.
References bindings.
Referenced by bind(), Aleph::Compiler_Type_Unifier::resolve(), and resolve_alias().
|
inlineprivate |
Definition at line 204 of file tpl_constraints.H.
References ah_logic_error_if, bindings, and lookup().
Referenced by apply().
|
inlinenoexcept |
Returns the number of stored variable bindings.
Definition at line 220 of file tpl_constraints.H.
References bindings.
Referenced by Aleph::Compiler_Type_Unifier::resolve().
|
inline |
Renders all bindings in insertion order.
| ctx | Type context used to pretty-print type ids. |
Definition at line 362 of file tpl_constraints.H.
References apply(), bindings, out, and Aleph::Compiler_Type_Context::to_string().
Referenced by Aleph::Compiler_Type_Unifier::dump_substitution().
Definition at line 201 of file tpl_constraints.H.
Referenced by bind(), binding(), clear(), empty(), lookup(), lookup(), resolve_alias(), size(), and to_string().