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

daisytuner / sdfglib / 17697974118

13 Sep 2025 02:36PM UTC coverage: 60.51% (+1.2%) from 59.335%
17697974118

Pull #219

github

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

565 of 1799 new or added lines in 102 files covered. (31.41%)

102 existing lines in 38 files now uncovered.

9442 of 15604 relevant lines covered (60.51%)

107.02 hits per line

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

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

3
namespace sdfg {
4
namespace stdlib {
5

NEW
6
MallocNode::MallocNode(
×
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
)
NEW
13
    : LibraryNode(
×
NEW
14
          element_id,
×
NEW
15
          debug_info,
×
NEW
16
          vertex,
×
NEW
17
          parent,
×
18
          LibraryNodeType_Malloc,
NEW
19
          {"_ret"},
×
NEW
20
          {},
×
21
          true,
22
          data_flow::ImplementationType_NONE
23
      ),
NEW
24
      size_(size) {}
×
25

NEW
26
const symbolic::Expression MallocNode::size() const { return size_; }
×
27

NEW
28
void MallocNode::validate(const Function& function) const {}
×
29

NEW
30
symbolic::SymbolSet MallocNode::symbols() const { return symbolic::atoms(this->size_); }
×
31

32
std::unique_ptr<data_flow::DataFlowNode> MallocNode::
NEW
33
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
NEW
34
    return std::make_unique<MallocNode>(element_id, debug_info_, vertex, parent, size_);
×
35
}
36

NEW
37
void MallocNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
NEW
38
    this->size_ = symbolic::subs(this->size_, old_expression, new_expression);
×
NEW
39
}
×
40

NEW
41
nlohmann::json MallocNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
NEW
42
    const MallocNode& node = static_cast<const MallocNode&>(library_node);
×
43

NEW
44
    nlohmann::json j;
×
NEW
45
    j["code"] = node.code().value();
×
46

NEW
47
    sdfg::serializer::JSONSerializer serializer;
×
NEW
48
    j["size"] = serializer.expression(node.size());
×
49

NEW
50
    return j;
×
NEW
51
}
×
52

NEW
53
data_flow::LibraryNode& MallocNodeSerializer::deserialize(
×
54
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
55
) {
NEW
56
    assert(j.contains("code"));
×
NEW
57
    assert(j.contains("debug_info"));
×
NEW
58
    assert(j.contains("size"));
×
59

NEW
60
    auto code = j["code"].get<std::string>();
×
NEW
61
    if (code != LibraryNodeType_Malloc.value()) {
×
NEW
62
        throw InvalidSDFGException("Invalid library node code");
×
63
    }
64

NEW
65
    sdfg::serializer::JSONSerializer serializer;
×
NEW
66
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
67

NEW
68
    auto size = symbolic::parse(j.at("size"));
×
69

NEW
70
    return builder.add_library_node<MallocNode>(parent, debug_info, size);
×
NEW
71
}
×
72

NEW
73
MallocNodeDispatcher::MallocNodeDispatcher(
×
74
    codegen::LanguageExtension& language_extension,
75
    const Function& function,
76
    const data_flow::DataFlowGraph& data_flow_graph,
77
    const MallocNode& node
78
)
NEW
79
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
80

NEW
81
void MallocNodeDispatcher::dispatch_code(
×
82
    codegen::PrettyPrinter& stream,
83
    codegen::PrettyPrinter& globals_stream,
84
    codegen::CodeSnippetFactory& library_snippet_factory
85
) {
NEW
86
    auto& malloc_node = static_cast<const MallocNode&>(node_);
×
87

NEW
88
    stream << malloc_node.outputs().at(0);
×
NEW
89
    stream << " = ";
×
NEW
90
    stream << "malloc(" << language_extension_.expression(malloc_node.size()) << ")" << ";";
×
NEW
91
    stream << std::endl;
×
NEW
92
}
×
93

94
} // namespace stdlib
95
} // 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