2#ifndef CEL_RUNTIME_VALUE_TYPE_HPP
3#define CEL_RUNTIME_VALUE_TYPE_HPP
5#include <cel/runtime/detail/retirement.hpp>
6#include <cel/runtime/layout.hpp>
66 friend struct detail::type_access;
67 detail::retirement_ptr<const detail::type_plan> _plan;
72 explicit value_type(std::unique_ptr<detail::type_plan> plan);
78 static value_type make_leaf(std::type_index identity,
layout bytes);
92 value_type(value_type&& other) noexcept : _plan(other._plan) {}
99 value_type&
operator=(
const value_type& other)
noexcept;
107 return *
this =
static_cast<const value_type&
>(other);
123 static_assert(std::is_trivially_copyable_v<T>,
124 "opaque CEL leaves must be trivially copyable");
125 static const value_type descriptor = make_leaf(
typeid(T), {
sizeof(T),
alignof(T)});
153 static value_type
record(std::string_view identity, std::span<const record_field>
fields);
230 std::span<const value_type>
fields() const;
A reference-semantic handle to frozen code and its complete declared signature.
Definition callable.hpp:40
An immutable, shared semantic type with a canonical byte layout.
Definition value_type.hpp:65
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.
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.
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 this descriptor's ordered tuple/record fields.
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:106
static value_type range(range_kind form, value_type endpoint)
Creates a range with a concrete leaf endpoint and the specified source form.
range_kind form() const
Returns the range form.
value_type(value_type &&other) noexcept
Shares the source's immutable metadata, leaving its shape and capabilities unchanged.
Definition value_type.hpp:92
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 this descriptor's source-order record names.
static value_type leaf()
Returns T's descriptor as an opaque, trivially copyable leaf.
Definition value_type.hpp:122
std::type_index leaf_identity() const
Returns concrete leaf identity.
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.
const value_type & result() const
Borrows this descriptor's complete callable result.
std::span< const value_type > parameters() const
Borrows this descriptor's callable parameters.
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 this descriptor's array element or range endpoint.
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 this descriptor's nominal record identity.
std::span< const std::size_t > offsets() const
Borrows this descriptor's canonical tuple/record/range offsets.
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.
Definition value_type.hpp:22
type_kind
Identifies a descriptor's structural category.
Definition value_type.hpp:34
@ range
Describes start..end.
Definition value_type.hpp:23
@ range_to
Describes ..end.
Definition value_type.hpp:25
@ range_full
Describes .., retaining its scalar endpoint type.
Definition value_type.hpp:28
@ range_inclusive
Describes start..=end.
Definition value_type.hpp:27
@ range_to_inclusive
Describes ..=end.
Definition value_type.hpp:26
@ range_from
Describes start...
Definition value_type.hpp:24
@ tuple
Stores ordered, canonically laid-out fields.
Definition value_type.hpp:37
@ leaf
Stores a concrete trivially copyable client or built-in leaf.
Definition value_type.hpp:35
@ record
Stores named fields and a nominal identity.
Definition value_type.hpp:38
@ array
Owns a sequence of one element type.
Definition value_type.hpp:36
Byte extents for stack reservation and type descriptors.
Definition callable.hpp:6
A byte extent and its requested alignment, both in bytes.
Definition layout.hpp:18
A source-order name/type pair validated by value_type::record.
Definition value_type.hpp:272
std::string name
Supplies a name; record construction rejects empty or duplicate names.
Definition value_type.hpp:273
value_type type
Retains the complete field descriptor.
Definition value_type.hpp:274