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

daisytuner / sdfglib / 19233097446

10 Nov 2025 01:22PM UTC coverage: 61.551% (+0.02%) from 61.533%
19233097446

Pull #331

github

web-flow
Merge bee958fc7 into 6b22fe1a8
Pull Request #331: allow interpretation of pointers as ints in symbolic expressions

54 of 95 new or added lines in 19 files covered. (56.84%)

3 existing lines in 3 files now uncovered.

10391 of 16882 relevant lines covered (61.55%)

107.15 hits per line

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

72.62
/src/structured_control_flow/sequence.cpp
1
#include "sdfg/structured_control_flow/sequence.h"
2

3
#include "sdfg/function.h"
4

5
namespace sdfg {
6
namespace structured_control_flow {
7

8
Transition::Transition(size_t element_id, const DebugInfo& debug_info, Sequence& parent)
×
9
    : Element(element_id, debug_info), parent_(&parent) {
×
10

11
      };
×
12

13
Transition::Transition(
883✔
14
    size_t element_id, const DebugInfo& debug_info, Sequence& parent, const control_flow::Assignments& assignments
15
)
16
    : Element(element_id, debug_info), parent_(&parent), assignments_(assignments) {
883✔
17

18
      };
883✔
19

20
void Transition::validate(const Function& function) const {
808✔
21
    for (const auto& entry : this->assignments_) {
1,011✔
22
        if (entry.first.is_null() || entry.second.is_null()) {
203✔
23
            throw InvalidSDFGException("Transition: Assignments cannot have null expressions");
×
24
        }
25
    }
26

27
    for (auto& entry : this->assignments_) {
1,011✔
28
        auto& lhs = entry.first;
203✔
29
        auto& type = function.type(lhs->get_name());
203✔
30
        if (type.type_id() != types::TypeID::Scalar) {
203✔
NEW
31
            throw InvalidSDFGException("Assignment - LHS: must be scalar type");
×
32
        }
33
        if (!types::is_integer(type.primitive_type())) {
203✔
34
            throw InvalidSDFGException("Assignment - LHS: must be integer type");
×
35
        }
36

37
        auto& rhs = entry.second;
203✔
38
        for (auto& atom : symbolic::atoms(rhs)) {
280✔
39
            if (symbolic::is_nullptr(atom)) {
77✔
40
                continue;
×
41
            }
42
            auto& atom_type = function.type(atom->get_name());
77✔
43

44
            // Scalar integers
45
            if (atom_type.type_id() == types::TypeID::Scalar) {
77✔
46
                if (!types::is_integer(atom_type.primitive_type())) {
74✔
47
                    throw InvalidSDFGException("Assignment - RHS: must evaluate to integer type");
×
48
                }
49
                continue;
74✔
50
            } else if (atom_type.type_id() == types::TypeID::Pointer) {
3✔
51
                continue;
3✔
52
            } else {
NEW
53
                throw InvalidSDFGException("Assignment - RHS: must evaluate to integer or pointer type");
×
54
            }
55
        }
56
    }
57
};
808✔
58

59
const control_flow::Assignments& Transition::assignments() const { return this->assignments_; };
49✔
60

61
control_flow::Assignments& Transition::assignments() { return this->assignments_; };
1,754✔
62

63
Sequence& Transition::parent() { return *this->parent_; };
6✔
64

65
const Sequence& Transition::parent() const { return *this->parent_; };
×
66

67
bool Transition::empty() const { return this->assignments_.empty(); };
17✔
68

69
size_t Transition::size() const { return this->assignments_.size(); };
50✔
70

71
void Transition::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
2✔
72
    if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) && SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
2✔
73
        auto old_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression);
2✔
74
        auto new_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression);
2✔
75

76
        if (this->assignments().find(old_symbol) != this->assignments().end()) {
2✔
77
            this->assignments()[new_symbol] = this->assignments()[old_symbol];
×
78
            this->assignments().erase(old_symbol);
×
79
        }
×
80
    }
2✔
81

82
    for (auto& entry : this->assignments()) {
2✔
83
        entry.second = symbolic::subs(entry.second, old_expression, new_expression);
×
84
    }
85
};
2✔
86

87
Sequence::Sequence(size_t element_id, const DebugInfo& debug_info)
1,634✔
88
    : ControlFlowNode(element_id, debug_info) {
817✔
89

90
      };
817✔
91

92
void Sequence::validate(const Function& function) const {
656✔
93
    // children and transition have same length
94
    if (this->children_.size() != this->transitions_.size()) {
656✔
95
        throw InvalidSDFGException("Sequence must have the same number of children and transitions");
×
96
    }
97

98
    for (auto& child : this->children_) {
1,464✔
99
        child->validate(function);
808✔
100
    }
101
    for (auto& trans : this->transitions_) {
1,464✔
102
        trans->validate(function);
808✔
103
    }
104
};
656✔
105

106
size_t Sequence::size() const { return this->children_.size(); };
3,934✔
107

108
std::pair<const ControlFlowNode&, const Transition&> Sequence::at(size_t i) const {
158✔
109
    return {*this->children_.at(i), *this->transitions_.at(i)};
158✔
110
};
111

112
std::pair<ControlFlowNode&, Transition&> Sequence::at(size_t i) {
2,371✔
113
    return {*this->children_.at(i), *this->transitions_.at(i)};
2,371✔
114
};
115

116
int Sequence::index(const ControlFlowNode& child) const {
77✔
117
    for (size_t i = 0; i < this->children_.size(); i++) {
83✔
118
        if (this->children_.at(i).get() == &child) {
83✔
119
            return static_cast<int>(i);
77✔
120
        }
121
    }
6✔
122

123
    return -1;
×
124
};
77✔
125

126
int Sequence::index(const Transition& transition) const {
×
127
    for (size_t i = 0; i < this->transitions_.size(); i++) {
×
128
        if (this->transitions_.at(i).get() == &transition) {
×
129
            return static_cast<int>(i);
×
130
        }
131
    }
×
132

133
    return -1;
×
134
};
×
135

136
void Sequence::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
2✔
137
    for (auto& child : this->children_) {
4✔
138
        child->replace(old_expression, new_expression);
2✔
139
    }
140

141
    for (auto& trans : this->transitions_) {
4✔
142
        trans->replace(old_expression, new_expression);
2✔
143
    }
144
};
2✔
145

146
} // namespace structured_control_flow
147
} // 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

© 2025 Coveralls, Inc