|
runtime 1.1.4
Checked CEL programs, owned values, and reusable execution stacks
|
A reference-semantic handle to frozen code and its complete declared signature. More...
#include <cel/runtime/callable.hpp>
Public Member Functions | |
| callable (compiled_segment body, std::span< const value_type > parameters) | |
| Binds independent one-result code and every explicit source-order parameter. | |
| 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. | |
| callable & | operator= (const callable &) noexcept=default |
| Shares the handle and releases the previous code on last ownership. | |
| callable & | operator= (callable &&) noexcept=default |
| Transfers the handle and releases previous last-owned code. | |
| ~callable () | |
| Releases last-owned frozen code and signature metadata. | |
| const value_type & | type () const noexcept |
| Borrows the full installed signature, including unused parameters. | |
| const stack_requirements & | requirements () const noexcept |
| Borrows known body storage requirements; external callback costs are not inferred. | |
| value | call (raw_stack &stack, std::span< const value > arguments) const |
| Executes declared positional inputs and returns one independent result owner. | |
| value | to_value () const |
| Creates an owning value carrier sharing this explicitly reference-semantic code. | |
Static Public Member Functions | |
| static callable | from_value (const value &source) |
| Returns a shared handle to the installed callable stored in source. | |
Friends | |
| struct | detail::callable_access |
| class | detail::callable_invocation |
A reference-semantic handle to frozen code and its complete declared signature.
Copies share code, explicit callback references, and the same-carrier entry guard. There is no implicit lexical environment or shared invocation argument/result table. Requires exclusive access to the carrier and any mutable callback state. Distinct carriers can nest on the caller's stack. Callback references stay caller-owned. Moves between distinct handles leave the source without code; assign a live handle before using source's borrowed accessors. Borrowed signatures and requirements remain valid while an unchanged live handle retains their code. Last ownership retires runtime-managed executable graphs without allocation or recursive descent, including callable literals and lazy bodies. Client destructors retain their costs.
Recursive entry into the same carrier throws std::logic_error.
Bind a declared parameter and call through a shared handle:
| cel::callable::callable | ( | compiled_segment | body, |
| std::span< const value_type > | parameters ) |
Binds independent one-result code and every explicit source-order parameter.
Retains code and copies parameter descriptors; the span need not outlive construction. Unused declarations remain parameters. Parameters admit bool/double and their composites; results admit every complete owned type, including client leaves and installed callables.
Throws std::invalid_argument for a dependent origin, undeclared or incompatible reads, or invalid parameter/result types.
Complexity: O(parameter count + complete type-comparison work) time and parameter binding storage, plus comparison auxiliary space.
Example: callable fn(std::move(b).finish(), std::array{value_type::leaf<double>()});.
|
defaultnoexcept |
Shares the reference-semantic code handle, not an independent callback-state copy.
Example: auto alias = fn;.
|
defaultnoexcept |
Transfers the code handle.
Example: auto moved = std::move(fn);.
| cel::callable::~callable | ( | ) |
Releases last-owned frozen code and signature metadata.
Complexity: O(last-owned captures and binding metadata).
Executes declared positional inputs and returns one independent result owner.
Validates arity and every complete parameter before body effects. Arguments are borrowed, not consumed. Returned aggregates own independent payloads; callable components share code, and opaque leaves do not acquire pointee ownership. Same-carrier exclusion covers validation, storage acquisition, body work, and result extraction.
Throws std::invalid_argument for a signature mismatch; std::logic_error for a moved-from handle, same-carrier entry, or stack access during a canonical ownership phase. Exceptions propagate unchanged and retire only the execution suffix, preserving the caller prefix. Cleanup does not undo external callback effects.
Complexity: O(parameter count + complete type-comparison work + executed instructions + payload and callback work) time. Allocates argument views and result outer storage, not per-scalar public owner boxes.
Example: auto result = fn.call(stack, std::array{value::from(2.0)});.
Returns a shared handle to the installed callable stored in source.
The returned handle shares the value's reference-semantic code and entry guard. Leaves source unchanged and retains code independently of source's lifetime. Performs no payload clone or recursive signature comparison.
Throws std::invalid_argument if source is not a callable with runtime-installed ownership.
Example: auto fn = callable::from_value(factory.call(stack, {}));.
Transfers the handle and releases previous last-owned code.
Leaves a distinct source without code; self-move is unchanged. Complexity: O(last-owned captures and binding metadata).
Example: alias = std::move(fn);.
Shares the handle and releases the previous code on last ownership.
Leaves the source unchanged; self-copy is unchanged. Complexity: O(last-owned captures and binding metadata).
Example: alias = fn;.
|
noexcept |
Borrows known body storage requirements; external callback costs are not inferred.
Example: auto r = fn.requirements().for_prefix(stack.cursor(), stack.depth());.
| value cel::callable::to_value | ( | ) | const |
Creates an owning value carrier sharing this explicitly reference-semantic code.
Throws std::logic_error for a moved-from handle.
Complexity: a constant number of allocations for constant-size carrier storage.
Example: auto carrier = fn.to_value();.
|
noexcept |
Borrows the full installed signature, including unused parameters.
Example: auto arity = fn.type().parameters().size();.