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

daisytuner / sdfglib / 17697650771

13 Sep 2025 02:09PM UTC coverage: 60.533% (+1.2%) from 59.335%
17697650771

Pull #219

github

web-flow
Merge 0edf508a7 into 6c1992b40
Pull Request #219: stdlib Library Nodes and ConstantNodes

563 of 1790 new or added lines in 102 files covered. (31.45%)

102 existing lines in 38 files now uncovered.

9442 of 15598 relevant lines covered (60.53%)

107.06 hits per line

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

0.0
/src/data_flow/library_nodes/stdlib/fwrite.cpp
1
#include "sdfg/data_flow/library_nodes/stdlib/fwrite.h"
2

3
namespace sdfg {
4
namespace stdlib {
5

NEW
6
FWriteNode::FWriteNode(
×
7
    size_t element_id,
8
    const DebugInfo& debug_info,
9
    const graph::Vertex vertex,
10
    data_flow::DataFlowGraph& parent,
11
    const symbolic::Expression size,
12
    const symbolic::Expression count
13
)
NEW
14
    : LibraryNode(
×
NEW
15
          element_id,
×
NEW
16
          debug_info,
×
NEW
17
          vertex,
×
NEW
18
          parent,
×
19
          LibraryNodeType_FWrite,
NEW
20
          {"_ret", "_stream"},
×
NEW
21
          {"_buffer", "_stream"},
×
22
          true,
23
          data_flow::ImplementationType_NONE
24
      ),
NEW
25
      size_(size), count_(count) {}
×
26

NEW
27
const symbolic::Expression FWriteNode::size() const { return size_; }
×
28

NEW
29
const symbolic::Expression FWriteNode::count() const { return count_; }
×
30

NEW
31
void FWriteNode::validate(const Function& function) const {}
×
32

NEW
33
symbolic::SymbolSet FWriteNode::symbols() const {
×
NEW
34
    symbolic::SymbolSet syms = symbolic::atoms(this->count_);
×
NEW
35
    for (auto& sym : symbolic::atoms(this->size_)) {
×
NEW
36
        syms.insert(sym);
×
37
    }
NEW
38
    return syms;
×
NEW
39
}
×
40

41
std::unique_ptr<data_flow::DataFlowNode> FWriteNode::
NEW
42
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
NEW
43
    return std::make_unique<FWriteNode>(element_id, debug_info_, vertex, parent, size_, count_);
×
44
}
45

NEW
46
void FWriteNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
NEW
47
    this->size_ = symbolic::subs(this->size_, old_expression, new_expression);
×
NEW
48
    this->count_ = symbolic::subs(this->count_, old_expression, new_expression);
×
NEW
49
}
×
50

NEW
51
nlohmann::json FWriteNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
NEW
52
    const FWriteNode& node = static_cast<const FWriteNode&>(library_node);
×
53

NEW
54
    nlohmann::json j;
×
NEW
55
    j["code"] = node.code().value();
×
56

NEW
57
    sdfg::serializer::JSONSerializer serializer;
×
NEW
58
    j["size"] = serializer.expression(node.size());
×
NEW
59
    j["count"] = serializer.expression(node.count());
×
60

NEW
61
    return j;
×
NEW
62
}
×
63

NEW
64
data_flow::LibraryNode& FWriteNodeSerializer::deserialize(
×
65
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
66
) {
NEW
67
    assert(j.contains("code"));
×
NEW
68
    assert(j.contains("debug_info"));
×
NEW
69
    assert(j.contains("size"));
×
NEW
70
    assert(j.contains("count"));
×
71

NEW
72
    auto code = j["code"].get<std::string>();
×
NEW
73
    if (code != LibraryNodeType_FWrite.value()) {
×
NEW
74
        throw InvalidSDFGException("Invalid library node code");
×
75
    }
76

NEW
77
    sdfg::serializer::JSONSerializer serializer;
×
NEW
78
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
79

NEW
80
    auto size = symbolic::parse(j.at("size"));
×
NEW
81
    auto count = symbolic::parse(j.at("count"));
×
82

NEW
83
    return builder.add_library_node<FWriteNode>(parent, debug_info, size, count);
×
NEW
84
}
×
85

NEW
86
FWriteNodeDispatcher::FWriteNodeDispatcher(
×
87
    codegen::LanguageExtension& language_extension,
88
    const Function& function,
89
    const data_flow::DataFlowGraph& data_flow_graph,
90
    const FWriteNode& node
91
)
NEW
92
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
93

NEW
94
void FWriteNodeDispatcher::dispatch_code(
×
95
    codegen::PrettyPrinter& stream,
96
    codegen::PrettyPrinter& globals_stream,
97
    codegen::CodeSnippetFactory& library_snippet_factory
98
) {
NEW
99
    auto& fwrite_node = static_cast<const FWriteNode&>(node_);
×
100

NEW
101
    stream << fwrite_node.outputs().at(0);
×
NEW
102
    stream << " = ";
×
NEW
103
    stream << "fwrite(";
×
NEW
104
    stream << fwrite_node.inputs().at(0) << ", ";
×
NEW
105
    stream << language_extension_.expression(fwrite_node.size()) << ", ";
×
NEW
106
    stream << language_extension_.expression(fwrite_node.count()) << ", ";
×
NEW
107
    stream << fwrite_node.inputs().at(1) << ");";
×
NEW
108
    stream << std::endl;
×
NEW
109
}
×
110

111
} // namespace stdlib
112
} // 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