|
runtime 1.0.0
Checked CEL programs, owned values, and reusable execution stacks
|
Shares an immutable, complete semantic type and canonical byte layout. Leaf identity is concrete C++ type identity; records additionally retain their nominal identity and field names. Capabilities do not change semantic identity. Copies share immutable metadata, never mutable value payloads. Borrowed references, spans, and string views remain valid while a descriptor retaining their metadata remains alive. Keep this descriptor unchanged while using its views. Factories retain component descriptors and copy supplied names; input spans and strings need not outlive construction. See the example for value for record construction. Example: auto numbers = value_type::array(value_type::leaf<double>());. More...
#include <cel/runtime/value_type.hpp>
Public Member Functions | |
| value_type () | |
| Creates the empty tuple descriptor (source unit). | |
| value_type (const value_type &) noexcept=default | |
| Shares the source's immutable metadata without changing the source. | |
| value_type (value_type &&other) noexcept | |
| Shares the source's immutable metadata, leaving its shape and capabilities unchanged. | |
| value_type & | operator= (const value_type &other) noexcept |
| Replaces this descriptor with the source's shape and capabilities; self-assignment is valid. Leaves the source unchanged and releases prior unique metadata without allocating. Complexity: O(released plans + edges + name bytes) time and O(1) auxiliary space. | |
| value_type & | operator= (value_type &&other) noexcept |
| Shares the source's shape and capabilities and releases this descriptor's prior metadata. Leaves the source unchanged; self-move leaves this descriptor unchanged. Complexity: O(released prior plans + edges + name bytes) time and O(1) auxiliary space. | |
| ~value_type () | |
| Releases this reference and uniquely owned descendants without recursion or allocation. Complexity: O(released plans + edges + name bytes) time and O(1) auxiliary space. | |
| bool | same_shape (const value_type &other) const |
| Returns true exactly when identities, shapes, source ordering, and canonical layouts match. Ignores ownership capabilities; use compatible_with to admit stored representations. Complexity: O(distinct visited plan pairs, their edges, and name bytes) expected time and O(distinct visited plan pairs) auxiliary space; shared DAGs are not expanded. Example: value_type::leaf<bool>().same_shape(value_type::leaf<double>()) == false. | |
| bool | compatible_with (const value_type &other) const |
| Compares complete semantic shapes and compatible stored opaque ownership operations. Returns false for any shape, layout, identity, or stored-operation mismatch. Semantic comparison precedes ownership comparison; same_shape alone is insufficient. Callable compatibility includes the ownership of every nested result component. Compatibility does not prove installed ownership or initialized borrowed canonical data. Comparison can allocate and propagates allocation failures. Complexity: O(distinct visited plan pairs, their edges, and name bytes) expected time and O(distinct visited plan pairs) auxiliary space; shared DAGs are not expanded. Example: value_type::leaf<double>().compatible_with(value_type::leaf<bool>()) == false. | |
| type_kind | kind () const noexcept |
| Returns the structural category. Example: value_type{}.kind() == type_kind::tuple. | |
| layout | byte_layout () const noexcept |
| Returns the canonical byte extent and alignment. Example: value_type{}.byte_layout().size == 0. | |
| bool | owns_values () const noexcept |
| Returns whether clone/destruction capabilities exist for every inhabited component. This describes capabilities, not the presence of initialized bytes. Callable ownership is unavailable until code ownership is installed. Example: value_type::leaf<double>().owns_values() == true. | |
| std::type_index | leaf_identity () const |
| Returns concrete leaf identity; throws std::invalid_argument for non-leaves. Example: value_type::leaf<bool>().leaf_identity() == typeid(bool). | |
| const value_type & | element () const |
| Borrows the array element or range endpoint; throws std::invalid_argument otherwise. Example: value_type::array(value_type::leaf<bool>()).element().kind() == type_kind::leaf. | |
| std::span< const value_type > | fields () const |
| Borrows ordered tuple/record fields; throws std::invalid_argument otherwise. Example: value_type{}.fields().empty() == true. | |
| std::span< const std::size_t > | offsets () const |
| Borrows canonical tuple/record/range offsets; throws std::invalid_argument otherwise. Example: value_type{}.offsets().empty() == true. | |
| std::string_view | record_identity () const |
| Borrows nominal record identity; throws std::invalid_argument otherwise. Example: value_type::record("sample", {}).record_identity() == "sample". | |
| std::span< const std::string > | field_names () const |
| Borrows source-order record names; throws std::invalid_argument otherwise. Example: value_type::record("sample", {}).field_names().empty() == true. | |
| range_kind | form () const |
| Returns the range form; throws std::invalid_argument otherwise. Example: value_type::range(range_kind::range_full, value_type::leaf<bool>()).form(). | |
| std::span< const value_type > | parameters () const |
| Borrows callable parameters; throws std::invalid_argument otherwise. Example: value_type::callable({}, value_type{}).parameters().empty() == true. | |
| const value_type & | result () const |
| Borrows the complete callable result; throws std::invalid_argument otherwise. Example: value_type::callable({}, value_type{}).result().kind() == type_kind::tuple. | |
Static Public Member Functions | |
| template<class T> | |
| static value_type | leaf () |
| Returns T's descriptor as an opaque, trivially copyable leaf. Rejects nontrivial T at compile time. This does not infer equality or ownership of objects referenced by T. Example: auto boolean = value_type::leaf<bool>();. | |
| static value_type | array (value_type element) |
| Creates an array descriptor retaining the element's complete shape and capabilities. Reports owns_values() exactly when element does; constructing a type creates no values. Example: auto type = value_type::array(value_type::leaf<bool>());. | |
| static value_type | tuple (std::span< const value_type > fields) |
| Creates a tuple descriptor with canonical source-order fields; empty fields describe unit. Retains every field's complete shape and ownership capabilities. Throws std::overflow_error if the canonical extent overflows. Complexity: O(field count) construction time and metadata space. Example: auto unit = value_type::tuple({});. | |
| static value_type | record (std::string_view identity, std::span< const record_field > fields) |
| Creates named fields with a nonempty nominal identity. Copies identity and field names, retaining each field's complete descriptor in source order. Throws std::invalid_argument for empty identity/names or duplicate field names. Throws std::overflow_error for canonical layout overflow. Complexity: O(field count + name bytes) expected time and metadata space. Example: auto empty = value_type::record("sample", {});. | |
| static value_type | range (range_kind form, value_type endpoint) |
| Creates a range with a concrete leaf endpoint and the specified source form. Throws std::invalid_argument for a non-leaf endpoint or invalid form. Throws std::overflow_error for canonical endpoint layout overflow. Bounded forms store two endpoints, one-sided forms store one, and full stores none. Example: auto type = value_type::range(range_kind::range, value_type::leaf<double>());. | |
| static value_type | callable (std::span< const value_type > parameters, value_type result) |
| Creates a callable signature with bool/double parameters or composites of those leaves. Retains any complete result descriptor, but installs no callable ownership operations. Use bind_runtime_ownership when emission needs an ownership-capable signature. Throws std::invalid_argument if a parameter contains a client leaf or callable. Complexity: O(parameter count) time and metadata space; predicates are cached per plan. Example: auto signature = value_type::callable({}, value_type::leaf<bool>());. | |
Friends | |
| struct | detail::type_access |
Shares an immutable, complete semantic type and canonical byte layout. Leaf identity is concrete C++ type identity; records additionally retain their nominal identity and field names. Capabilities do not change semantic identity. Copies share immutable metadata, never mutable value payloads. Borrowed references, spans, and string views remain valid while a descriptor retaining their metadata remains alive. Keep this descriptor unchanged while using its views. Factories retain component descriptors and copy supplied names; input spans and strings need not outlive construction. See the example for value for record construction. Example: auto numbers = value_type::array(value_type::leaf<double>());.