runtime 1.0.0
Checked CEL programs, owned values, and reusable execution stacks
Loading...
Searching...
No Matches
callable.hpp
1// SPDX-License-Identifier: BSL-1.0
2#ifndef CEL_RUNTIME_CALLABLE_HPP
3#define CEL_RUNTIME_CALLABLE_HPP
4#include <cel/runtime/dyn_segment.hpp>
5
6namespace cel {
9
10namespace detail {
11struct callable_state;
12struct callable_access;
13class callable_invocation;
14} // namespace detail
37class callable {
38 detail::retirement_ptr<detail::callable_state> _state;
39 friend struct detail::callable_access;
40 friend class detail::callable_invocation;
41
42public:
51 callable(compiled_segment body, std::span<const value_type> parameters);
54 callable(const callable&) noexcept = default;
57 callable(callable&&) noexcept = default;
62 callable& operator=(const callable&) noexcept = default;
67 callable& operator=(callable&&) noexcept = default;
74 const value_type& type() const noexcept;
78 const stack_requirements& requirements() const noexcept;
90 value call(raw_stack& stack, std::span<const value> arguments) const;
95 value to_value() const;
102 static callable from_value(const value& source);
103};
104
106} // namespace cel
107#endif
const stack_requirements & requirements() const noexcept
Borrows known body storage requirements; external callback costs are not inferred....
callable(const callable &) noexcept=default
Shares the reference-semantic code handle, not an independent callback-state copy....
callable(callable &&) noexcept=default
Transfers the code handle. Example: auto moved = std::move(fn);.
value call(raw_stack &stack, std::span< const value > arguments) const
Validates arity and every declared complete parameter before any body effect. Returns one independent...
static callable from_value(const value &source)
Returns a shared handle to the installed callable stored in source. Throws std::invalid_argument if s...
callable(compiled_segment body, std::span< const value_type > parameters)
Binds independent one-result code and every explicit source-order parameter. Precondition: body has n...
value to_value() const
Creates an owning value carrier sharing this explicitly reference-semantic code. Throws logic_error f...
const value_type & type() const noexcept
Borrows the full installed signature, including unused parameters. Precondition: this handle is live....
Retains immutable frozen code and its captures in a move-only handle. Prepared bindings and callables...
Definition dyn_segment.hpp:496
Owns reusable canonical operand bytes and complete live-slot metadata. The owner outlives every borro...
Definition raw_stack.hpp:33
Shares an immutable, complete semantic type and canonical byte layout. Leaf identity is concrete C++ ...
Definition value_type.hpp:55
Owns a complete runtime value; copies own independent mutable payloads. Installed callables are expli...
Definition value.hpp:58
Provides byte extents for stack reservation and type descriptors.
Definition callable.hpp:6
Describes statically known canonical frame storage for a frozen ordinary program. Extent and slots ar...
Definition dyn_segment.hpp:48