runtime 1.1.4
Checked CEL programs, owned values, and reusable execution stacks
Loading...
Searching...
No Matches
cel::value_type Class Reference

An immutable, shared semantic type with a canonical byte layout. 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.
value_type & operator= (value_type &&other) noexcept
 Shares the source's shape and capabilities and releases this descriptor's prior metadata.
 ~value_type ()
 Releases this reference and uniquely owned descendants without recursion or allocation.
bool same_shape (const value_type &other) const
 Returns true exactly when identities, shapes, source ordering, and canonical layouts match.
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.
layout byte_layout () const noexcept
 Returns the canonical byte extent and alignment.
bool owns_values () const noexcept
 Returns whether clone/destruction capabilities exist for every inhabited component.
std::type_index leaf_identity () const
 Returns concrete leaf identity.
const value_type & element () const
 Borrows this descriptor's array element or range endpoint.
std::span< const value_type > fields () const
 Borrows this descriptor's ordered tuple/record fields.
std::span< const std::size_t > offsets () const
 Borrows this descriptor's canonical tuple/record/range offsets.
std::string_view record_identity () const
 Borrows this descriptor's nominal record identity.
std::span< const std::string > field_names () const
 Borrows this descriptor's source-order record names.
range_kind form () const
 Returns the range form.
std::span< const value_type > parameters () const
 Borrows this descriptor's callable parameters.
const value_type & result () const
 Borrows this descriptor's complete callable result.

Static Public Member Functions

template<class T>
static value_type leaf ()
 Returns T's descriptor as an opaque, trivially copyable leaf.
static value_type array (value_type element)
 Creates an array descriptor retaining the element's complete shape and capabilities.
static value_type tuple (std::span< const value_type > fields)
 Creates a tuple descriptor with canonical source-order fields; empty fields describe unit.
static value_type record (std::string_view identity, std::span< const record_field > fields)
 Creates named fields with a nonempty nominal identity.
static value_type range (range_kind form, value_type endpoint)
 Creates a range with a concrete leaf endpoint and the specified source form.
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.

Friends

struct detail::type_access

Detailed Description

An immutable, shared semantic type with a 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. Access to one descriptor must not race its replacement or destruction. Factories retain component descriptors and copy supplied names; input spans and strings need not outlive construction. Ownership sequences share descendant ranges instead of expanding a table at every node. Across a descriptor graph, plan construction and metadata are linear in nodes and edges, plus copied identity/name bytes; record-name validation has expected linear time.

See value's shared example for record construction and descriptor copying. Example: auto numbers = value_type::array(value_type::leaf<double>()); auto copy = numbers;.

Constructor & Destructor Documentation

◆ value_type() [1/3]

cel::value_type::value_type ( )

Creates the empty tuple descriptor (source unit).

See the tuple example.

◆ value_type() [2/3]

cel::value_type::value_type ( const value_type & )
defaultnoexcept

Shares the source's immutable metadata without changing the source.

See the class's shared copying example.

◆ value_type() [3/3]

cel::value_type::value_type ( value_type && other)
inlinenoexcept

Shares the source's immutable metadata, leaving its shape and capabilities unchanged.

Example: auto copy = std::move(type); // type retains its descriptor.

◆ ~value_type()

cel::value_type::~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.

See the class's shared copying example.

Member Function Documentation

◆ array()

value_type cel::value_type::array ( value_type element)
static

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>());.

◆ byte_layout()

layout cel::value_type::byte_layout ( ) const
noexcept

Returns the canonical byte extent and alignment.

Example: value_type{}.byte_layout().size == 0.

◆ callable()

value_type cel::value_type::callable ( std::span< const value_type > parameters,
value_type result )
static

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 result metadata space.

Example: auto signature = value_type::callable({}, value_type::leaf<bool>());.

◆ compatible_with()

bool cel::value_type::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.

Allocation failures leave both descriptors unchanged.

Complexity: O(P + E + S) expected time and O(P + E) auxiliary space, with P, E, and S as in same_shape; identical plans compare in O(1).

Example: value_type::leaf<double>().compatible_with(value_type::leaf<bool>()) == false.

◆ element()

const value_type & cel::value_type::element ( ) const

Borrows this descriptor's array element or range endpoint.

Throws std::invalid_argument for other categories.

Example: value_type::array(value_type::leaf<bool>()).element().kind() == type_kind::leaf.

◆ field_names()

std::span< const std::string > cel::value_type::field_names ( ) const

Borrows this descriptor's source-order record names.

Throws std::invalid_argument for non-records.

Example: value_type::record("sample", {}).field_names().empty() == true.

◆ fields()

std::span< const value_type > cel::value_type::fields ( ) const

Borrows this descriptor's ordered tuple/record fields.

Throws std::invalid_argument for other categories.

Example: value_type{}.fields().empty() == true.

◆ form()

range_kind cel::value_type::form ( ) const

Returns the range form.

Throws std::invalid_argument for non-ranges.

Example: value_type::range(range_kind::range_full, value_type::leaf<bool>()).form().

◆ kind()

type_kind cel::value_type::kind ( ) const
noexcept

Returns the structural category.

Example: value_type{}.kind() == type_kind::tuple.

◆ leaf()

template<class T>
value_type cel::value_type::leaf ( )
inlinestatic

Returns T's descriptor as an opaque, trivially copyable leaf.

This does not infer equality or ownership of objects referenced by T.

Example: auto boolean = value_type::leaf<bool>();.

Examples
getting_started.cpp.

◆ leaf_identity()

std::type_index cel::value_type::leaf_identity ( ) const

Returns concrete leaf identity.

Throws std::invalid_argument for non-leaves.

Example: value_type::leaf<bool>().leaf_identity() == typeid(bool).

◆ offsets()

std::span< const std::size_t > cel::value_type::offsets ( ) const

Borrows this descriptor's canonical tuple/record/range offsets.

Throws std::invalid_argument for other categories.

Example: value_type{}.offsets().empty() == true.

◆ operator=() [1/2]

value_type & cel::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.

Example: auto type = value_type{}; type = value_type::leaf<bool>();.

◆ operator=() [2/2]

value_type & cel::value_type::operator= ( value_type && other)
inlinenoexcept

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.

Example: auto type = value_type{}; type = std::move(other); // other is unchanged.

◆ owns_values()

bool cel::value_type::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.

◆ parameters()

std::span< const value_type > cel::value_type::parameters ( ) const

Borrows this descriptor's callable parameters.

Throws std::invalid_argument for non-callables.

Example: value_type::callable({}, value_type{}).parameters().empty() == true.

◆ range()

value_type cel::value_type::range ( range_kind form,
value_type endpoint )
static

Creates a range with a concrete leaf endpoint and the specified source form.

Bounded forms store two endpoints, one-sided forms store one, and full stores none.

Throws std::invalid_argument for a non-leaf endpoint or invalid form. Throws std::overflow_error for canonical endpoint layout overflow.

Example: auto type = value_type::range(range_kind::range, value_type::leaf<double>());.

◆ record()

value_type cel::value_type::record ( std::string_view identity,
std::span< const record_field > fields )
static

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 + identity/name bytes) expected time and result metadata space; O(field count) auxiliary space for name validation.

Example: auto empty = value_type::record("sample", {});.

◆ record_identity()

std::string_view cel::value_type::record_identity ( ) const

Borrows this descriptor's nominal record identity.

Throws std::invalid_argument for non-records.

Example: value_type::record("sample", {}).record_identity() == "sample".

◆ result()

const value_type & cel::value_type::result ( ) const

Borrows this descriptor's complete callable result.

Throws std::invalid_argument for non-callables.

Example: value_type::callable({}, value_type{}).result().kind() == type_kind::tuple.

◆ same_shape()

bool cel::value_type::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. Allocation failures leave both descriptors unchanged.

Complexity: O(P + E + S) expected time and O(P + E) auxiliary space, for distinct visited plan pairs P, their edges E, and compared identity/name bytes S. Shared subgraphs are not expanded recursively; identical plans compare in O(1).

Example: value_type::leaf<bool>().same_shape(value_type::leaf<double>()) == false.

◆ tuple()

value_type cel::value_type::tuple ( std::span< const value_type > fields)
static

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({});.


The documentation for this class was generated from the following file: