2#ifndef CEL_RUNTIME_VALUE_TYPE_HPP
3#define CEL_RUNTIME_VALUE_TYPE_HPP
5#include <cel/runtime/layout.hpp>
56 friend struct detail::type_access;
57 std::shared_ptr<const detail::type_plan> _plan;
60 explicit value_type(std::shared_ptr<const detail::type_plan> plan);
62 static value_type make_leaf(std::type_index identity,
layout bytes);
65 static void release_plan(std::shared_ptr<const detail::type_plan>& plan)
noexcept;
73 value_type(value_type&& other) noexcept : _plan(other._plan) {}
77 value_type&
operator=(
const value_type& other)
noexcept;
81 value_type&
operator=(value_type&& other)
noexcept {
82 return *
this =
static_cast<const value_type&
>(other);
94 static_assert(std::is_trivially_copyable_v<T>,
95 "opaque CEL leaves must be trivially copyable");
96 static const value_type descriptor = make_leaf(
typeid(T), {
sizeof(T),
alignof(T)});
115 static value_type
record(std::string_view identity, std::span<const record_field>
fields);
164 std::span<const value_type>
fields() const;
Owns a reference-semantic handle to frozen code and its complete declared signature....
Definition callable.hpp:37
Shares an immutable, complete semantic type and canonical byte layout. Leaf identity is concrete C++ ...
Definition value_type.hpp:55
static value_type array(value_type element)
Creates an array descriptor retaining the element's complete shape and capabilities....
layout byte_layout() const noexcept
Returns the canonical byte extent and alignment. Example: value_type{}.byte_layout()....
bool compatible_with(const value_type &other) const
Compares complete semantic shapes and compatible stored opaque ownership operations....
type_kind kind() const noexcept
Returns the structural category. Example: value_type{}.kind() == type_kind::tuple.
value_type & operator=(const value_type &other) noexcept
Replaces this descriptor with the source's shape and capabilities; self-assignment is valid....
std::span< const value_type > fields() const
Borrows ordered tuple/record fields; throws std::invalid_argument otherwise. Example: value_type{}...
value_type & operator=(value_type &&other) noexcept
Shares the source's shape and capabilities and releases this descriptor's prior metadata....
Definition value_type.hpp:81
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_argu...
range_kind form() const
Returns the range form; throws std::invalid_argument otherwise. Example: value_type::range(range_kind...
value_type(value_type &&other) noexcept
Shares the source's immutable metadata, leaving its shape and capabilities unchanged.
Definition value_type.hpp:73
value_type(const value_type &) noexcept=default
Shares the source's immutable metadata without changing the source.
std::span< const std::string > field_names() const
Borrows source-order record names; throws std::invalid_argument otherwise. Example: value_type::recor...
static value_type leaf()
Returns T's descriptor as an opaque, trivially copyable leaf. Rejects nontrivial T at compile time....
Definition value_type.hpp:93
std::type_index leaf_identity() const
Returns concrete leaf identity; throws std::invalid_argument for non-leaves. Example: value_type::lea...
value_type()
Creates the empty tuple descriptor (source unit).
~value_type()
Releases this reference and uniquely owned descendants without recursion or allocation....
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,...
const value_type & result() const
Borrows the complete callable result; throws std::invalid_argument otherwise. Example: value_type::ca...
std::span< const value_type > parameters() const
Borrows callable parameters; throws std::invalid_argument otherwise. Example: value_type::callable({}...
bool same_shape(const value_type &other) const
Returns true exactly when identities, shapes, source ordering, and canonical layouts match....
const value_type & element() const
Borrows the array element or range endpoint; throws std::invalid_argument otherwise....
static value_type tuple(std::span< const value_type > fields)
Creates a tuple descriptor with canonical source-order fields; empty fields describe unit....
bool owns_values() const noexcept
Returns whether clone/destruction capabilities exist for every inhabited component....
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....
std::string_view record_identity() const
Borrows nominal record identity; throws std::invalid_argument otherwise. Example: value_type::record(...
std::span< const std::size_t > offsets() const
Borrows canonical tuple/record/range offsets; throws std::invalid_argument otherwise....
value_type bind_runtime_ownership(const value_type &type)
Returns a runtime ownership-capable witness for the complete immutable type graph....
range_kind
Identifies every source range form independently of its endpoint layout. Example: range_kind::range_i...
Definition value_type.hpp:20
type_kind
Identifies a descriptor's structural category. Example: an empty source unit has type_kind::tuple.
Definition value_type.hpp:31
@ range
Describes start..end.
Definition value_type.hpp:21
@ range_to
Describes ..end.
Definition value_type.hpp:23
@ range_full
Describes .., retaining its scalar endpoint type.
Definition value_type.hpp:26
@ range_inclusive
Describes start..=end.
Definition value_type.hpp:25
@ range_to_inclusive
Describes ..=end.
Definition value_type.hpp:24
@ range_from
Describes start...
Definition value_type.hpp:22
@ tuple
Stores ordered, canonically laid-out fields.
Definition value_type.hpp:34
@ leaf
Stores a concrete trivially copyable client or built-in leaf.
Definition value_type.hpp:32
@ record
Stores named fields and a nominal identity.
Definition value_type.hpp:35
@ array
Owns a sequence of one element type.
Definition value_type.hpp:33
Provides byte extents for stack reservation and type descriptors.
Definition callable.hpp:6
Describes a byte extent and its requested alignment, both in bytes. A checked storage operation accep...
Definition layout.hpp:16
Supplies a source-order name/type pair to value_type::record, which validates its name....
Definition value_type.hpp:187
std::string name
Supplies a name; record construction rejects empty or duplicate names.
Definition value_type.hpp:188
value_type type
Retains the complete field descriptor.
Definition value_type.hpp:189