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

daisytuner / sdfglib / 17559474002

08 Sep 2025 05:49PM UTC coverage: 61.347% (+2.2%) from 59.145%
17559474002

Pull #219

github

web-flow
Merge 2ae413ec1 into b8fdeb232
Pull Request #219: stdlib Library Nodes and ConstantNodes

424 of 1301 new or added lines in 74 files covered. (32.59%)

89 existing lines in 31 files now uncovered.

9318 of 15189 relevant lines covered (61.35%)

109.36 hits per line

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

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

56
size_t FunctionBuilder::new_element_id() const { return ++this->function().element_counter_; };
3,912✔
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 {
885✔
66
    if (is_argument && is_external) {
885✔
67
        throw InvalidSDFGException("Container " + name + " cannot be both an argument and an external");
×
68
    }
69
    // Legal name
70
    check_name(name);
885✔
71

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

75
    if (is_argument) {
885✔
76
        this->function().arguments_.push_back(name);
247✔
77
    }
247✔
78
    if (is_external) {
885✔
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)) {
885✔
83
        auto sym = symbolic::symbol(name);
639✔
84
        this->function().assumptions_.insert({sym, symbolic::Assumption::create(sym, type)});
639✔
85
    }
639✔
86

87
    return *(*res.first).second;
885✔
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

120
void FunctionBuilder::change_type(const std::string& name, const types::IType& type) const {
9✔
121
    auto& function = this->function();
9✔
122
    if (!function.is_transient(name)) {
9✔
123
        throw InvalidSDFGException("Container " + name + " is not transient");
×
124
    }
125
    if (function.containers_.find(name) == function.containers_.end()) {
9✔
126
        throw InvalidSDFGException("Container " + name + " does not exist");
×
127
    }
128

129
    function.containers_[name] = type.clone();
9✔
130
};
9✔
131

132
types::StructureDefinition& FunctionBuilder::add_structure(const std::string& name, bool is_packed) const {
18✔
133
    if (this->function().structures_.find(name) != this->function().structures_.end()) {
18✔
134
        throw InvalidSDFGException("Structure " + name + " already exists");
×
135
    }
136

137
    auto res = this->function().structures_.insert({name, std::make_unique<types::StructureDefinition>(name, is_packed)}
18✔
138
    );
139
    assert(res.second);
18✔
140

141
    return *(*res.first).second;
18✔
142
};
×
143

144
void FunctionBuilder::make_array(const std::string& name, const symbolic::Expression& size) const {
2✔
145
    auto& function = this->function();
2✔
146
    if (!function.is_transient(name)) {
2✔
147
        throw InvalidSDFGException("Container " + name + " is not transient");
1✔
148
    }
149
    if (function.containers_.find(name) == function.containers_.end()) {
1✔
150
        throw InvalidSDFGException("Container " + name + " does not exist");
×
151
    }
152

153
    auto& old_type = function.containers_[name];
1✔
154
    if (old_type->is_symbol() && dynamic_cast<const types::Scalar*>(old_type.get())) {
1✔
155
        function.assumptions_.erase(symbolic::symbol(name));
1✔
156
    }
1✔
157

158
    function.containers_[name] = std::make_unique<types::Array>(*old_type, size);
1✔
159
};
2✔
160

161
std::string FunctionBuilder::find_new_name(std::string prefix) const {
40✔
162
    size_t i = 0;
40✔
163
    std::string new_name = prefix + std::to_string(i);
40✔
164
    while (this->function().exists(new_name)) {
63✔
165
        i++;
23✔
166
        new_name = prefix + std::to_string(i);
23✔
167
    }
168
    return new_name;
40✔
169
};
40✔
170

171
void FunctionBuilder::update_tasklet(data_flow::Tasklet& tasklet, const data_flow::TaskletCode code) {
×
172
    tasklet.code_ = code;
×
173
}
×
174

175
} // namespace builder
176
} // 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