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 "Boxes.hpp" | |||
16 | #include "Conditional.hpp" | |||
17 | #include "Gate/Gate.hpp" | |||
18 | #include "OpType/OpType.hpp" | |||
19 | #include "OpType/OpTypeFunctions.hpp" | |||
20 | #include "Ops/ClassicalOps.hpp" | |||
21 | #include "Ops/MetaOp.hpp" | |||
22 | #include "Ops/OpPtr.hpp" | |||
23 | #include "Utils/Json.hpp" | |||
24 | ||||
25 | namespace tket { | |||
26 | ||||
27 | 1860 | void from_json(const nlohmann::json& j, Op_ptr& op) { | ||
28 |
2/4✓ Branch 1 taken 1860 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1860 times.
✗ Branch 5 not taken.
|
1860 | OpType optype = j.at("type").get<OpType>(); | |
29 |
3/4✓ Branch 1 taken 1860 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1858 times.
|
2/2✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 1858 times.
|
1860 | if (is_metaop_type(optype)) { |
30 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | op = MetaOp::deserialize(j); | |
31 |
3/4✓ Branch 1 taken 1858 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 1845 times.
|
2/2✓ Decision 'true' taken 13 times.
✓ Decision 'false' taken 1845 times.
|
1858 | } else if (is_box_type(optype)) { |
32 |
1/2✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
|
13 | op = Box::deserialize(j); | |
33 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1842 times.
|
2/2✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 1842 times.
|
1845 | } else if (optype == OpType::Conditional) { |
34 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | op = Conditional::deserialize(j); | |
35 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1842 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 1842 times.
|
1842 | } else if (optype == OpType::WASM) { |
36 | ✗ | op = WASMOp::deserialize(j); | ||
37 |
2/4✓ Branch 1 taken 1842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1842 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 1842 times.
|
1842 | } else if (is_classical_type(optype)) { |
38 | ✗ | op = ClassicalOp::deserialize(j); | ||
39 |
2/4✓ Branch 1 taken 1842 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1842 times.
✗ Branch 4 not taken.
|
1/2✓ Decision 'true' taken 1842 times.
✗ Decision 'false' not taken.
|
1842 | } else if (is_gate_type(optype)) { |
40 |
1/2✓ Branch 1 taken 1842 times.
✗ Branch 2 not taken.
|
1842 | op = Gate::deserialize(j); | |
41 | } else { | |||
42 | ✗ | throw JsonError( | ||
43 | ✗ | "Deserialization not yet implemented for " + | ||
44 | ✗ | optypeinfo().at(optype).name); | ||
45 | } | |||
46 | 1860 | } | ||
47 | ||||
48 | } // namespace tket | |||
49 |