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

daisytuner / sdfglib / 15947600317

28 Jun 2025 07:47PM UTC coverage: 65.01% (+0.04%) from 64.97%
15947600317

push

github

web-flow
Merge pull request #116 from daisytuner/robust-replace

makes symbolic replace more robust

10 of 14 new or added lines in 4 files covered. (71.43%)

1 existing line in 1 file now uncovered.

8554 of 13158 relevant lines covered (65.01%)

144.54 hits per line

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

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

3
namespace sdfg {
4
namespace structured_control_flow {
5

6
Transition::Transition(size_t element_id, const DebugInfo& debug_info, Sequence& parent)
114✔
7
    : Element(element_id, debug_info), parent_(parent) {
57✔
8

9
      };
57✔
10

11
Transition::Transition(size_t element_id, const DebugInfo& debug_info, Sequence& parent,
884✔
12
                       const control_flow::Assignments& assignments)
13
    : Element(element_id, debug_info), parent_(parent), assignments_(assignments) {
884✔
14

15
      };
884✔
16

17
const control_flow::Assignments& Transition::assignments() const { return this->assignments_; };
22✔
18

19
control_flow::Assignments& Transition::assignments() { return this->assignments_; };
1,452✔
20

21
Sequence& Transition::parent() { return this->parent_; };
×
22

23
const Sequence& Transition::parent() const { return this->parent_; };
×
24

25
bool Transition::empty() const { return this->assignments_.empty(); };
109✔
26

27
size_t Transition::size() const { return this->assignments_.size(); };
45✔
28

29
void Transition::replace(const symbolic::Expression& old_expression,
×
30
                         const symbolic::Expression& new_expression) {
31

32
};
×
33

34
Sequence::Sequence(size_t element_id, const DebugInfo& debug_info)
1,808✔
35
    : ControlFlowNode(element_id, debug_info) {
904✔
36

37
      };
904✔
38

39
size_t Sequence::size() const { return this->children_.size(); };
7,084✔
40

41
std::pair<const ControlFlowNode&, const Transition&> Sequence::at(size_t i) const {
245✔
42
    return {*this->children_.at(i), *this->transitions_.at(i)};
245✔
43
};
44

45
std::pair<ControlFlowNode&, Transition&> Sequence::at(size_t i) {
3,813✔
46
    return {*this->children_.at(i), *this->transitions_.at(i)};
3,813✔
47
};
48

49
void Sequence::replace(const symbolic::Expression& old_expression,
14✔
50
                       const symbolic::Expression& new_expression) {
51
    for (auto& child : this->children_) {
24✔
52
        child->replace(old_expression, new_expression);
10✔
53
    }
54

55
    for (auto& trans : this->transitions_) {
24✔
56
        if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) &&
10✔
57
            SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
10✔
58
            auto old_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression);
10✔
59
            auto new_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression);
10✔
60

61
            if (trans->assignments().find(old_symbol) != trans->assignments().end()) {
10✔
UNCOV
62
                trans->assignments()[new_symbol] = trans->assignments()[old_symbol];
×
63
                trans->assignments().erase(old_symbol);
×
64
            }
×
65
        }
10✔
66

67
        for (auto& entry : trans->assignments()) {
10✔
NEW
68
            entry.second = symbolic::subs(entry.second, old_expression, new_expression);
×
69
        }
70
    }
71
};
14✔
72

73
}  // namespace structured_control_flow
74
}  // 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