• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 20573904830

29 Dec 2025 01:22PM UTC coverage: 40.359% (-0.007%) from 40.366%
20573904830

push

github

web-flow
Merge pull request #410 from daisytuner/compatibility-fixes

adds fixes for backward compatibility

14300 of 45908 branches covered (31.15%)

Branch coverage included in aggregate %.

3 of 5 new or added lines in 3 files covered. (60.0%)

1 existing line in 1 file now uncovered.

12241 of 19855 relevant lines covered (61.65%)

89.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.08
/src/data_flow/library_nodes/math/cmath/cmath_node.cpp
1
#include "sdfg/data_flow/library_nodes/math/cmath/cmath_node.h"
2
#include "sdfg/symbolic/symbolic.h"
3

4
namespace sdfg {
5
namespace math {
6
namespace cmath {
7

8
CMathNode::CMathNode(
46✔
9
    size_t element_id,
10
    const DebugInfo& debug_info,
11
    const graph::Vertex vertex,
12
    data_flow::DataFlowGraph& parent,
13
    const std::string& name,
14
    size_t arity
15
)
16
    : MathNode(
46!
17
          element_id, debug_info, vertex, parent, LibraryNodeType_CMath, {"_out"}, {}, data_flow::ImplementationType_NONE
46!
18
      ),
19
      name_(name) {
46!
20
    for (size_t i = 0; i < arity; i++) {
112✔
21
        this->inputs_.push_back("_in" + std::to_string(i + 1));
66!
22
    }
66✔
23
}
46✔
24

25
const std::string& CMathNode::name() const { return this->name_; }
×
26

27
symbolic::SymbolSet CMathNode::symbols() const { return {}; }
2✔
28

29
void CMathNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
30
    return;
×
31
}
32

33

34
void CMathNode::validate(const Function& function) const {}
1✔
35

36
std::unique_ptr<data_flow::DataFlowNode> CMathNode::
37
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
38
    return std::unique_ptr<
×
39
        CMathNode>(new CMathNode(element_id, this->debug_info(), vertex, parent, this->name_, this->inputs_.size()));
×
40
}
×
41

42
symbolic::Expression CMathNode::flop() const { return symbolic::one(); }
1✔
43

44
nlohmann::json CMathNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
45
    const CMathNode& node = static_cast<const CMathNode&>(library_node);
×
46
    nlohmann::json j;
×
47

48
    serializer::JSONSerializer serializer;
×
49
    j["code"] = node.code().value();
×
50
    j["name"] = node.name();
×
51
    j["arity"] = node.inputs().size();
×
52

53
    return j;
×
54
}
×
55

56
data_flow::LibraryNode& CMathNodeSerializer::deserialize(
×
57
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
58
) {
59
    // Assertions for required fields
60
    assert(j.contains("element_id"));
×
61
    assert(j.contains("code"));
×
62
    assert(j.contains("debug_info"));
×
63

64
    auto code = j["code"].get<std::string>();
×
65
    // Backward compatibility
NEW
66
    if (code != LibraryNodeType_CMath.value() && code != LibraryNodeType_CMath_Deprecated.value()) {
×
UNCOV
67
        throw std::runtime_error("Invalid library node code");
×
68
    }
69

70
    // Extract debug info using JSONSerializer
71
    sdfg::serializer::JSONSerializer serializer;
×
72
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
73

74
    auto name = j["name"].get<std::string>();
×
75
    auto arity = j["arity"].get<size_t>();
×
76

77
    return builder.add_library_node<CMathNode>(parent, debug_info, name, arity);
×
78
}
×
79

80
CMathNodeDispatcher::CMathNodeDispatcher(
×
81
    codegen::LanguageExtension& language_extension,
82
    const Function& function,
83
    const data_flow::DataFlowGraph& data_flow_graph,
84
    const CMathNode& node
85
)
86
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
87

88
void CMathNodeDispatcher::dispatch_code(
×
89
    codegen::PrettyPrinter& stream,
90
    codegen::PrettyPrinter& globals_stream,
91
    codegen::CodeSnippetFactory& library_snippet_factory
92
) {
93
    stream << "{" << std::endl;
×
94
    stream.setIndent(stream.indent() + 4);
×
95

96
    auto& node = static_cast<const CMathNode&>(this->node_);
×
97

98
    stream << node.outputs().at(0) << " = ";
×
99
    stream << node.name() << "(";
×
100
    for (size_t i = 0; i < node.inputs().size(); i++) {
×
101
        stream << node.inputs().at(i);
×
102
        if (i < node.inputs().size() - 1) {
×
103
            stream << ", ";
×
104
        }
×
105
    }
×
106
    stream << ");" << std::endl;
×
107

108
    stream.setIndent(stream.indent() - 4);
×
109
    stream << "}" << std::endl;
×
110
}
×
111

112
} // namespace cmath
113
} // namespace math
114
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc