summaryrefslogtreecommitdiffstats
path: root/yql/essentials/core/yql_node_transform.h
blob: a5c452f99070d80e2c0bfc93ee4f8557c51289c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include <yql/essentials/core/expr_nodes/yql_expr_nodes.h>

#include <util/generic/hash.h>

namespace NYql {

class TNodeTransform {
public:
    explicit TNodeTransform(TExprNode::TPtr lambda)
        : Func_(std::move(lambda))
    {
    }

    TExprNode::TPtr operator()(const TExprNode::TPtr& node, TExprContext& ctx) const {
        // clang-format off
        return ctx.Builder(node->Pos())
            .Apply(Func_)
                .With(0, node)
            .Seal()
            .Build();
        // clang-format on
    }

    TExprNode::TPtr Func() const {
        return Func_;
    }

private:
    TExprNode::TPtr Func_;
};

} // namespace NYql