GCC Code Coverage Report


Directory: ./
File: Ops/FlowOp.cpp
Date: 2022-10-15 05:10:18
Exec Total Coverage
Lines: 0 26 0.0%
Functions: 0 9 0.0%
Branches: 0 48 0.0%
Decisions: 0 8 0.0%

Line Branch Decision Exec Source
1 // Copyright 2019-2022 Cambridge Quantum Computing
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "FlowOp.hpp"
16
17 #include "OpType/OpTypeInfo.hpp"
18
19 namespace tket {
20
21 FlowOp::FlowOp(OpType type, std::optional<std::string> label)
22 : Op(type), label_(label) {
23
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
if (!is_flowop_type(type)) {
24 throw BadOpType(type);
25 }
26 }
27
28 Op_ptr FlowOp::symbol_substitution(const SymEngine::map_basic_basic&) const {
29 return Op_ptr();
30 }
31
32 SymSet FlowOp::free_symbols() const { return {}; }
33
34 std::optional<std::string> FlowOp::get_label() const { return label_; }
35
36 FlowOp::~FlowOp() {}
37
38 FlowOp::FlowOp() : Op(OpType::Stop) {}
39
40 bool FlowOp::is_equal(const Op& op_other) const {
41 const FlowOp& other = dynamic_cast<const FlowOp&>(op_other);
42 return (this->get_label() == other.get_label());
43 }
44
45 op_signature_t FlowOp::get_signature() const {
46 std::optional<op_signature_t> sig = desc_.signature();
47
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
if (sig)
48 return *sig;
49 else
50 throw BadOpType(get_type());
51 }
52
53 std::string FlowOp::get_name(bool latex) const {
54 std::stringstream name;
55
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
if (latex) {
56 name << get_desc().latex() << "(";
57 } else {
58 name << get_desc().name();
59 }
60
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
if (type_ != OpType::Stop) {
61 name << " " << *label_;
62 }
63 return name.str();
64 }
65
66 } // namespace tket
67