summaryrefslogtreecommitdiff
path: root/src/buildtool/build_engine/expression/target_node.cpp
blob: 03fc47f516a0c573445698b4d62fad6e976df60f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "src/buildtool/build_engine/expression/target_node.hpp"

#include "src/buildtool/build_engine/expression/expression.hpp"

auto TargetNode::Abstract::IsCacheable() const noexcept -> bool {
    return target_fields->IsCacheable();
}

auto TargetNode::ToJson() const -> nlohmann::json {
    if (IsValue()) {
        return {{"type", "VALUE_NODE"}, {"result", GetValue()->ToJson()}};
    }
    auto const& data = GetAbstract();
    return {{"type", "ABSTRACT_NODE"},
            {"node_type", data.node_type},
            {"string_fields", data.string_fields->ToJson()},
            {"target_fields",
             data.target_fields->ToJson(
                 Expression::JsonMode::SerializeAllButNodes)}};
}