51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#ifndef ALSK_ALSK_EDSL_IMPL_H
|
|
#define ALSK_ALSK_EDSL_IMPL_H
|
|
|
|
#include <utility>
|
|
|
|
#include "../executor/traits.h"
|
|
#include "../skeleton/utility.h"
|
|
#include "../impl/impl.h"
|
|
|
|
#include "op/impl/serial.h"
|
|
#include "op/traits.h"
|
|
#include "link.h"
|
|
|
|
namespace alsk {
|
|
namespace edsl {
|
|
|
|
template<typename Expression>
|
|
constexpr auto getSkeleton(Expression) -> BuildSkeletonT<typename Expression::Struct, typename Expression::Links>;
|
|
|
|
template<
|
|
template<typename> class Executor, typename Context = DefaultContext,
|
|
typename Expression,
|
|
std::enable_if_t<isBranch<std::decay_t<Expression>>>* = nullptr
|
|
>
|
|
constexpr auto implement(Expression&& expression) {
|
|
using Skeleton = decltype(getSkeleton(expression));
|
|
|
|
auto f = alsk::implement<Executor, Skeleton, Context>();
|
|
std::forward<Expression>(expression).setup(f.skeleton);
|
|
return f;
|
|
}
|
|
|
|
template<
|
|
template<typename> class Executor, typename Context = DefaultContext,
|
|
typename Expression,
|
|
std::enable_if_t<isLeaf<std::decay_t<Expression>>>* = nullptr
|
|
>
|
|
constexpr auto implement(Expression&& expression) {
|
|
using Signature = typename std::decay_t<Expression>::Signature;
|
|
using FixedSignatures = AutoLinkSerial<Signature>;
|
|
auto linkedExpression = link<typename FixedSignatures::in>(std::forward<Expression>(expression));
|
|
|
|
using LinkedExpression = std::decay_t<decltype(linkedExpression)>;
|
|
return implement<Executor, Context>(Serial<typename FixedSignatures::out, LinkedExpression>{std::move(linkedExpression)});
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|