|
runtime 1.0.0
Checked CEL programs, owned values, and reusable execution stacks
|
Owns a complete runtime value; copies own independent mutable payloads. Installed callables are explicit reference-semantic code handles: copies share frozen code, callback references, and the carrier's recursive-entry guard, not mutable aggregate payloads. Moved-from and default values are source unit. Internal descriptors may be shared. Opaque leaves own their bytes, not objects reachable through client pointers. Composite admission rejects incompatible opaque ownership operations even for equal shapes. Example: auto number = value::from(2.0); auto copy = number;. More...
#include <cel/runtime/value.hpp>
Public Member Functions | |
| value () noexcept | |
| Creates source unit without allocating payload storage. | |
| ~value () | |
| Destroys owned children and releases storage without allocating. Complexity: O(visited canonical ownership paths, array nodes, and released metadata) time and O(1) auxiliary space; destruction does not recurse with nesting depth. | |
| value (const value &other) | |
| Copies mutable aggregate payloads independently; callable code handles retain reference semantics. Complexity: O(canonical payload bytes + visited ownership paths) time and owned space. | |
| value (value &&other) noexcept | |
| Transfers ownership and leaves other as source unit. | |
| value & | operator= (const value &other) |
| Replaces this value with a copy under the class's aggregate and callable copy semantics. Leaves other unchanged; self-assignment leaves this value unchanged. Failure leaves this unchanged without copying its prior payload. Complexity: O(canonical source bytes + visited source/old ownership paths) time and O(source payload size) new owned space. | |
| value & | operator= (value &&other) noexcept |
| Releases old ownership, transfers other, and leaves other as unit; self-move is unchanged. Complexity: O(visited old ownership paths, array nodes, and released metadata) time. | |
| const value_type & | type () const |
| Borrows the complete descriptor until this value is assigned or destroyed. Example: value::from(true).type().kind() == type_kind::leaf. | |
| template<class T> | |
| T | as () const |
| Returns a concrete copy of the exact requested leaf, vector, or tuple type. Returned vectors and tuples own independent mutable payloads; leaf pointers remain pointers. Throws std::invalid_argument if the complete concrete type does not match. Complexity: O(payload size) time and owned result space. Example: value::from(2.0).as<double>() == 2.0. | |
| std::size_t | size () const |
| Returns array length, fixed aggregate arity, or range endpoint count. Throws std::invalid_argument for leaves or callables. Example: value::tuple({}).size() == 0. | |
| value | at (std::size_t index) const |
| Copies a source-order child under the class's aggregate and callable copy semantics. Throws std::out_of_range for an invalid index, std::invalid_argument for non-composites. Complexity: O(child payload size) time and owned result space. Example: value::from(std::vector<double>{2.0}).at(0).as<double>() == 2.0. | |
| void | set (std::size_t index, const value &replacement) |
| Replaces one child with a copy of the exact expected shape and ownership operations. Leaves replacement unchanged; callable children retain reference-semantic code. Throws std::out_of_range for invalid index, std::invalid_argument for shape mismatch or non-composites. Failure leaves the value unchanged; no rollback copy is needed. Complexity: O(old and new child payload size) time and O(new child size) new space. Example: auto a = value::from(std::vector<double>{1.0}); a.set(0, value::from(2.0));. | |
| value | field (std::string_view name) const |
| Copies a named record field; throws std::invalid_argument for non-record/missing name. Complexity: O(field count + name bytes + child payload size) time and child space. See the class example for a complete record and field lookup. | |
| void | set_field (std::string_view name, const value &replacement) |
| Replaces a named record field with a copy of the exact expected shape. Throws std::invalid_argument for non-record/missing name or shape mismatch. Follows set's ownership compatibility, copy semantics, and unchanged-on-failure guarantee. Complexity: O(field count + name bytes + old/new child size) time and new child space. See the class example for a complete record and field replacement. | |
Static Public Member Functions | |
| template<class T> | |
| static value | from (const T &source) |
| Copies a concrete leaf or recursively nested owning vector/tuple into a runtime value. Nontrivial opaque leaves fail compilation; vector/tuple facades are supported. Leaves source unchanged; pointer members in opaque leaves do not confer pointee ownership. Complexity: O(payload size) time and owned space. Example: auto numbers = value::from(std::vector<double>{1.0, 2.0});. | |
| static value | array (value_type element, std::span< const value > elements) |
| Copies a sequence of elements with the specified complete shape and ownership operations. Retains element for an empty sequence; leaves all input values unchanged. Throws std::invalid_argument for incompatible elements, releasing earlier copies. Throws std::overflow_error if count times canonical element extent overflows. Complexity: O(payload size + element count) time and owned space. Example: auto empty = value::array(value_type::leaf<double>(), {});. | |
| static value | tuple (std::span< const value > fields) |
| Copies source-order fields into a canonical tuple; empty fields are source unit. Leaves input fields unchanged, with the class's copy semantics for every component. Throws std::overflow_error for layout overflow. Complexity: O(payload size + field count) time and owned space. Example: auto unit = value::tuple({});. | |
| static value | record (value_type type, std::span< const value > fields) |
| Copies source-order fields into a record of the specified nominal type. Throws std::invalid_argument for a non-record, wrong arity, or incompatible fields. Field compatibility includes complete shape and ownership operations. Failure releases earlier children without leaking resources. Complexity: O(payload size + field count) time and owned space. Example: auto empty = value::record(value_type::record("sample", {}), {});. | |
| static value | range (value_type type, std::span< const value > endpoints) |
| Copies endpoints in source order for the given range descriptor. Throws std::invalid_argument for a non-range, wrong arity, or incompatible endpoint type. Complexity: O(endpoint byte size) time and owned space. Example: auto full = value::range(value_type::range(
range_kind::range_full, value_type::leaf<double>()), {});. | |
Friends | |
| struct | detail::value_access |
| template<class T> | |
| struct | detail::concrete_adapter |
Owns a complete runtime value; copies own independent mutable payloads. Installed callables are explicit reference-semantic code handles: copies share frozen code, callback references, and the carrier's recursive-entry guard, not mutable aggregate payloads. Moved-from and default values are source unit. Internal descriptors may be shared. Opaque leaves own their bytes, not objects reachable through client pointers. Composite admission rejects incompatible opaque ownership operations even for equal shapes. Example: auto number = value::from(2.0); auto copy = number;.
Create a record and change a copied field without changing the original: