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

Owns reusable canonical operand bytes and complete live-slot metadata. The owner outlives every borrowed frame. Moving rejects active frames. Exclusive access is required, including during nested evaluation. During canonical construction, operand acquisition, or retirement, reentrant mutation, extraction, execution, and frame entry throw std::logic_error. Ordinary operation callbacks may use the active frame or evaluate a nested frame. Example: raw_stack s; s.reserve(256, 256); s.push(2.0); auto n = s.pop<double>();. More...

#include <cel/runtime/raw_stack.hpp>

Public Member Functions

 raw_stack ()
 Creates an empty reusable stack.
 ~raw_stack ()
 Retires all live payloads and releases reserved storage. Precondition: no frame referring to this stack remains alive. Complexity: O(slots + visited payload ownership paths).
 raw_stack (const raw_stack &)=delete
 Disallows duplicated mutable ownership.
raw_stack & operator= (const raw_stack &)=delete
 Disallows copied assignment.
 raw_stack (raw_stack &&other)
 Transfers storage and live slots; leaves other empty and reusable. Throws logic_error if other has an active frame or canonical phase.
raw_stack & operator= (raw_stack &&other)
 Releases prior payloads and transfers other; self-assignment is unchanged. Throws logic_error if either stack has an active frame or canonical phase. Complexity: O(old slots + visited old payload ownership paths).
void reserve (std::size_t bytes, std::size_t alignment)
 Reserves bytes, alignment, and at least bytes live slots without changing the cursor. Zero-byte values may need reserve_depth in addition to byte reservation. Throws invalid_argument for invalid alignment and overflow_error for extent overflow. Throws logic_error if a frame is active. Complexity: O(retained initialized bytes + slots) time and allocated space on growth. Example: stack.reserve(1024, 256);.
void reserve_depth (std::size_t count)
 Reserves bookkeeping for count simultaneously live operands, including zero-byte units. Throws logic_error if a frame is active. Complexity: O(live slots) time and O(count) space on growth. Example: stack.reserve_depth(100);.
void clear ()
 Destroys every live payload while retaining reusable storage. Throws logic_error if a frame is active. Complexity: O(slots + visited payload ownership paths), without allocating. Example: stack.clear();.
std::size_t depth () const noexcept
 Returns the number of live operands, excluding spare initialized bytes. Example: raw_stack{}.depth() == 0.
std::size_t cursor () const noexcept
 Returns the active byte cursor, including padding preceding live operands. Example: raw_stack{}.cursor() == 0.
template<class T>
void push (const T &source)
 Writes a concrete leaf or packed composite without constructing scalar value boxes. Throws logic_error if a frame is active; failure preserves live operands. Complexity: O(payload construction + retained bytes/slots on growth). Example: stack.push(std::tuple{true, 2.0});.
template<class T>
T pop ()
 Returns an independent concrete top value, retiring its canonical owner. Throws out_of_range on underflow, invalid_argument on complete type mismatch, and logic_error if a frame is active. Failure preserves the operand. Complexity: O(result payload size + compared shape size) time and result space. Example: stack.push(true); auto flag = stack.pop<bool>();.
void push_clone (const value &source)
 Clones a public owner into canonical stack storage. Leaves source unchanged, preserving value's reference semantics for callable components. Throws logic_error if a frame is active; failure preserves all operands. Complexity: O(cloned payload + retained bytes/slots on growth) time and space. Example: stack.push_clone(value::from(std::vector{2.0}));.
void push_take (value &source)
 Transfers canonical ownership, leaving source unit after success. Throws logic_error if a frame is active; failure preserves source and stack. Complexity: O(outer bytes + retained bytes/slots on growth). Example: auto v = value::from(true); stack.push_take(v);.
value pop_value ()
 Removes the top operand and transfers its canonical ownership to the returned value. Throws out_of_range on underflow and logic_error if a frame is active. Failure preserves the stack. Complexity: O(outer bytes) time and space. Example: auto result = stack.pop_value();.

Friends

class detail::frame
struct detail::frame_access

Detailed Description

Owns reusable canonical operand bytes and complete live-slot metadata. The owner outlives every borrowed frame. Moving rejects active frames. Exclusive access is required, including during nested evaluation. During canonical construction, operand acquisition, or retirement, reentrant mutation, extraction, execution, and frame entry throw std::logic_error. Ordinary operation callbacks may use the active frame or evaluate a nested frame. Example: raw_stack s; s.reserve(256, 256); s.push(2.0); auto n = s.pop<double>();.


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