• 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

56.46
/src/builder/function_builder.cpp
1
#include "sdfg/builder/function_builder.h"
2

3
namespace sdfg {
4
namespace builder {
5

6
void check_name(const std::string& name) {
910✔
7
    if (name.find(".") != std::string::npos) {
910✔
8
        throw InvalidSDFGException("Container name " + name + " contains a dot");
×
9
    } else if (name.find(" ") != std::string::npos) {
910✔
10
        throw InvalidSDFGException("Container name " + name + " contains a space");
×
11
    } else if (name.find("(") != std::string::npos) {
910✔
12
        throw InvalidSDFGException("Container name " + name + " contains a parenthesis");
×
13
    } else if (name.find(")") != std::string::npos) {
910✔
14
        throw InvalidSDFGException("Container name " + name + " contains a parenthesis");
×
15
    } else if (name.find("[") != std::string::npos) {
910✔
16
        throw InvalidSDFGException("Container name " + name + " contains a bracket");
×
17
    } else if (name.find("]") != std::string::npos) {
910✔
18
        throw InvalidSDFGException("Container name " + name + " contains a bracket");
×
19
    } else if (name.find("*") != std::string::npos) {
910✔
20
        throw InvalidSDFGException("Container name " + name + " contains a star");
×
21
    } else if (name.find("&") != std::string::npos) {
910✔
22
        throw InvalidSDFGException("Container name " + name + " contains a ampersand");
×
23
    } else if (name.find("!") != std::string::npos) {
910✔
24
        throw InvalidSDFGException("Container name " + name + " contains a bang");
×
25
    } else if (name.find("~") != std::string::npos) {
910✔
26
        throw InvalidSDFGException("Container name " + name + " contains a tilde");
×
27
    } else if (name.find("`") != std::string::npos) {
910✔
28
        throw InvalidSDFGException("Container name " + name + " contains a backtick");
×
29
    } else if (name.find("\"") != std::string::npos) {
910✔
30
        throw InvalidSDFGException("Container name " + name + " contains a quote");
×
31
    } else if (name.find("'") != std::string::npos) {
910✔
32
        throw InvalidSDFGException("Container name " + name + " contains a single quote");
×
33
    } else if (name.find(";") != std::string::npos) {
910✔
34
        throw InvalidSDFGException("Container name " + name + " contains a semicolon");
×
35
    } else if (name.find(":") != std::string::npos) {
910✔
36
        throw InvalidSDFGException("Container name " + name + " contains a colon");
×
37
    } else if (name.find(",") != std::string::npos) {
910✔
38
        throw InvalidSDFGException("Container name " + name + " contains a comma");
×
39
    } else if (name.find("=") != std::string::npos) {
910✔
40
        throw InvalidSDFGException("Container name " + name + " contains a equal sign");
×
41
    } else if (name.find("+") != std::string::npos) {
910✔
42
        throw InvalidSDFGException("Container name " + name + " contains a plus sign");
×
43
    } else if (name.find("-") != std::string::npos) {
910✔
44
        throw InvalidSDFGException("Container name " + name + " contains a minus sign");
×
45
    } else if (name.find("/") != std::string::npos) {
910✔
46
        throw InvalidSDFGException("Container name " + name + " contains a slash");
×
47
    } else if (name.find("%") != std::string::npos) {
910✔
48
        throw InvalidSDFGException("Container name " + name + " contains a percent sign");
×
49
    } else if (name.find("^") != std::string::npos) {
910✔
50
        throw InvalidSDFGException("Container name " + name + " contains a caret");
×
51
    } else if (name.find("|") != std::string::npos) {
910✔
52
        throw InvalidSDFGException("Container name " + name + " contains a pipe");
×
53
    }
54
};
910✔
55

56
size_t FunctionBuilder::new_element_id() const { return ++this->function().element_counter_; };
3,966✔
57

58
void FunctionBuilder::set_element_counter(size_t element_counter) {
10✔
59
    this->function().element_counter_ = element_counter;
10✔
60
};
10✔
61

NEW
62
void FunctionBuilder::set_return_type(const types::IType& type) const { this->function().return_type_ = type.clone(); };
×
63

64
const types::IType& FunctionBuilder::
65
    add_container(const std::string& name, const types::IType& type, bool is_argument, bool is_external) const {
901✔
66
    if (is_argument && is_external) {
901✔
67
        throw InvalidSDFGException("Container " + name + " cannot be both an argument and an external");
×
68
    }
69
    // Legal name
70
    check_name(name);
901✔
71

72
    auto res = this->function().containers_.insert({name, type.clone()});
901✔
73
    assert(res.second);
901✔
74

75
    if (is_argument) {
901✔
76
        this->function().arguments_.push_back(name);
246✔
77
    }
246✔
78
    if (is_external) {
901✔
79
        this->function().externals_.push_back(name);
13✔
80
        this->function().externals_linkage_types_[name] = LinkageType_External;
13✔
81
    }
13✔
82
    if (type.is_symbol() && dynamic_cast<const types::Scalar*>(&type)) {
901✔
83
        auto sym = symbolic::symbol(name);
655✔
84
        this->function().assumptions_.insert({sym, symbolic::Assumption::create(sym, type)});
655✔
85
    }
655✔
86

87
    return *(*res.first).second;
901✔
88
};
×
89

90
const types::IType& FunctionBuilder::
91
    add_external(const std::string& name, const types::IType& type, LinkageType linkage_type) const {
9✔
92
    check_name(name);
9✔
93

94
    auto res = this->function().containers_.insert({name, type.clone()});
9✔
95
    assert(res.second);
9✔
96

97
    this->function().externals_.push_back(name);
9✔
98
    this->function().externals_linkage_types_[name] = linkage_type;
9✔
99

100
    return *(*res.first).second;
9✔
101
};
×
102

103
void FunctionBuilder::remove_container(const std::string& name) const {
6✔
104
    auto& function = this->function();
6✔
105
    if (!function.is_transient(name)) {
6✔
106
        throw InvalidSDFGException("Container " + name + " is not transient");
2✔
107
    }
108
    if (this->function().containers_.find(name) == this->function().containers_.end()) {
4✔
109
        throw InvalidSDFGException("Container " + name + " does not exist");
×
110
    }
111

112
    auto& type = function.containers_[name];
4✔
113
    if (type->is_symbol() && dynamic_cast<const types::Scalar*>(type.get())) {
4✔
114
        function.assumptions_.erase(symbolic::symbol(name));
4✔
115
    }
4✔
116

117
    function.containers_.erase(name);
4✔
118
};
6✔
119

NEW
120
void FunctionBuilder::rename_container(const std::string& old_name, const std::string& new_name) const {
×
NEW
121
    auto& function = this->function();
×
NEW
122
    if (!function.exists(old_name)) {
×
NEW
123
        throw InvalidSDFGException("Container " + old_name + " does not exist");
×
124
    }
125

126
    // Move type
NEW
127
    function.containers_[new_name] = std::move(function.containers_[old_name]);
×
NEW
128
    function.containers_.erase(old_name);
×
129

130
    // Handling of argument
NEW
131
    if (function.is_argument(old_name)) {
×
NEW
132
        auto it = std::find(function.arguments_.begin(), function.arguments_.end(), old_name);
×
NEW
133
        assert(it != function.arguments_.end());
×
NEW
134
        *it = new_name;
×
NEW
135
    }
×
136
    // Handling of external
NEW
137
    if (function.is_external(old_name)) {
×
NEW
138
        auto it = std::find(function.externals_.begin(), function.externals_.end(), old_name);
×
NEW
139
        assert(it != function.externals_.end());
×
NEW
140
        *it = new_name;
×
NEW
141
        function.externals_linkage_types_[new_name] = function.externals_linkage_types_[old_name];
×
NEW
142
        function.externals_linkage_types_.erase(old_name);
×
NEW
143
    }
×
144
    // Handling of assumption
NEW
145
    if (function.assumptions().find(symbolic::symbol(old_name)) != function.assumptions().end()) {
×
NEW
146
        auto assumption = function.assumption(symbolic::symbol(old_name));
×
147

NEW
148
        symbolic::Assumption new_assumption(symbolic::symbol(new_name));
×
NEW
149
        new_assumption.lower_bound(assumption.lower_bound());
×
NEW
150
        new_assumption.upper_bound(assumption.upper_bound());
×
NEW
151
        new_assumption.constant(assumption.constant());
×
NEW
152
        new_assumption.map(assumption.map());
×
153

NEW
154
        function.assumptions_.erase(symbolic::symbol(old_name));
×
NEW
155
        function.assumptions_.insert({new_assumption.symbol(), new_assumption});
×
NEW
156
    }
×
NEW
157
};
×
158

159
void FunctionBuilder::change_type(const std::string& name, const types::IType& type) const {
9✔
160
    auto& function = this->function();
9✔
161
    if (!function.is_transient(name)) {
9✔
162
        throw InvalidSDFGException("Container " + name + " is not transient");
×
163
    }
164
    if (function.containers_.find(name) == function.containers_.end()) {
9✔
165
        throw InvalidSDFGException("Container " + name + " does not exist");
×
166
    }
167

168
    function.containers_[name] = type.clone();
9✔
169
};
9✔
170

171
types::StructureDefinition& FunctionBuilder::add_structure(const std::string& name, bool is_packed) const {
18✔
172
    if (this->function().structures_.find(name) != this->function().structures_.end()) {
18✔
173
        throw InvalidSDFGException("Structure " + name + " already exists");
×
174
    }
175

176
    auto res = this->function().structures_.insert({name, std::make_unique<types::StructureDefinition>(name, is_packed)}
18✔
177
    );
178
    assert(res.second);
18✔
179

180
    return *(*res.first).second;
18✔
181
};
×
182

183
std::string FunctionBuilder::find_new_name(std::string prefix) const {
40✔
184
    size_t i = 0;
40✔
185
    std::string new_name = prefix + std::to_string(i);
40✔
186
    while (this->function().exists(new_name)) {
63✔
187
        i++;
23✔
188
        new_name = prefix + std::to_string(i);
23✔
189
    }
190
    return new_name;
40✔
191
};
40✔
192

193
void FunctionBuilder::update_tasklet(data_flow::Tasklet& tasklet, const data_flow::TaskletCode code) {
×
194
    tasklet.code_ = code;
×
195
}
×
196

197
} // namespace builder
198
} // 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