18 auto dumper =
Dumper(out, indent);
27 ::tree::base::PointerMap ids;
28 ids.enable_exceptions =
false;
31 auto dumper =
Dumper(out, indent, &ids);
279 const ::tree::cbor::MapReader &map,
280 ::tree::base::IdentifierMap &ids
282 auto type = map.at(
"@t").as_string();
296 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
312 return dynamic_cast<const Reference*
>(
this);
318 std::shared_ptr<Reference>
Reference::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
319 auto type = map.at(
"@t").as_string();
323 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
338 index.find_reachable(map);
346 index.check_complete(map);
368 return dynamic_cast<BitRefs*
>(
this);
376 return dynamic_cast<const BitRefs*
>(
this);
383 return cqasm::tree::make<BitRefs>(*this);
390 auto node = cqasm::tree::make<BitRefs>(*this);
391 node->index = this->
index.clone();
400 auto rhsc =
dynamic_cast<const BitRefs&
>(rhs);
401 if (!this->
index.equals(rhsc.index))
return false;
410 auto rhsc =
dynamic_cast<const BitRefs&
>(rhs);
411 if (this->
index != rhsc.index)
return false;
419 ::tree::cbor::MapWriter &map,
420 const ::tree::base::PointerMap &ids
423 map.append_string(
"@t",
"BitRefs");
424 auto submap = map.append_map(
"index");
425 index.serialize(submap, ids);
427 serialize_annotations(map);
433 std::shared_ptr<BitRefs>
BitRefs::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
435 auto type = map.at(
"@t").as_string();
436 if (
type !=
"BitRefs") {
437 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
439 auto node = std::make_shared<BitRefs>(
442 node->deserialize_annotations(map);
451 return dynamic_cast<Constant*
>(
this);
459 return dynamic_cast<const Constant*
>(
this);
465 std::shared_ptr<Constant>
Constant::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
466 auto type = map.at(
"@t").as_string();
476 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
527 return dynamic_cast<const ConstAxis*
>(
this);
534 return cqasm::tree::make<ConstAxis>(*this);
541 auto node = cqasm::tree::make<ConstAxis>(*this);
550 auto rhsc =
dynamic_cast<const ConstAxis&
>(rhs);
551 if (this->
value != rhsc.value)
return false;
560 auto rhsc =
dynamic_cast<const ConstAxis&
>(rhs);
561 if (this->
value != rhsc.value)
return false;
569 ::tree::cbor::MapWriter &map,
570 const ::tree::base::PointerMap &ids
573 map.append_string(
"@t",
"ConstAxis");
574 auto submap = map.append_map(
"value");
575 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Axis>(
value, submap);
577 serialize_annotations(map);
583 std::shared_ptr<ConstAxis>
ConstAxis::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
585 auto type = map.at(
"@t").as_string();
586 if (
type !=
"ConstAxis") {
587 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
589 auto node = std::make_shared<ConstAxis>(
590 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Axis>(map.at(
"value").as_map())
592 node->deserialize_annotations(map);
644 return dynamic_cast<const ConstBool*
>(
this);
651 return cqasm::tree::make<ConstBool>(*this);
658 auto node = cqasm::tree::make<ConstBool>(*this);
667 auto rhsc =
dynamic_cast<const ConstBool&
>(rhs);
668 if (this->
value != rhsc.value)
return false;
677 auto rhsc =
dynamic_cast<const ConstBool&
>(rhs);
678 if (this->
value != rhsc.value)
return false;
686 ::tree::cbor::MapWriter &map,
687 const ::tree::base::PointerMap &ids
690 map.append_string(
"@t",
"ConstBool");
691 auto submap = map.append_map(
"value");
692 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Bool>(
value, submap);
694 serialize_annotations(map);
700 std::shared_ptr<ConstBool>
ConstBool::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
702 auto type = map.at(
"@t").as_string();
703 if (
type !=
"ConstBool") {
704 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
706 auto node = std::make_shared<ConstBool>(
707 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Bool>(map.at(
"value").as_map())
709 node->deserialize_annotations(map);
768 return cqasm::tree::make<ConstComplex>(*this);
775 auto node = cqasm::tree::make<ConstComplex>(*this);
785 if (this->
value != rhsc.value)
return false;
795 if (this->
value != rhsc.value)
return false;
803 ::tree::cbor::MapWriter &map,
804 const ::tree::base::PointerMap &ids
807 map.append_string(
"@t",
"ConstComplex");
808 auto submap = map.append_map(
"value");
809 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Complex>(
value, submap);
811 serialize_annotations(map);
819 auto type = map.at(
"@t").as_string();
820 if (
type !=
"ConstComplex") {
821 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
823 auto node = std::make_shared<ConstComplex>(
824 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Complex>(map.at(
"value").as_map())
826 node->deserialize_annotations(map);
885 return cqasm::tree::make<ConstComplexMatrix>(*this);
892 auto node = cqasm::tree::make<ConstComplexMatrix>(*this);
902 if (this->
value != rhsc.value)
return false;
912 if (this->
value != rhsc.value)
return false;
920 ::tree::cbor::MapWriter &map,
921 const ::tree::base::PointerMap &ids
924 map.append_string(
"@t",
"ConstComplexMatrix");
925 auto submap = map.append_map(
"value");
926 cqasm::v1::primitives::serialize<cqasm::v1::primitives::CMatrix>(
value, submap);
928 serialize_annotations(map);
936 auto type = map.at(
"@t").as_string();
937 if (
type !=
"ConstComplexMatrix") {
938 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
940 auto node = std::make_shared<ConstComplexMatrix>(
941 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::CMatrix>(map.at(
"value").as_map())
943 node->deserialize_annotations(map);
987 return dynamic_cast<ConstInt*
>(
this);
995 return dynamic_cast<const ConstInt*
>(
this);
1002 return cqasm::tree::make<ConstInt>(*this);
1009 auto node = cqasm::tree::make<ConstInt>(*this);
1018 auto rhsc =
dynamic_cast<const ConstInt&
>(rhs);
1019 if (this->
value != rhsc.value)
return false;
1028 auto rhsc =
dynamic_cast<const ConstInt&
>(rhs);
1029 if (this->
value != rhsc.value)
return false;
1037 ::tree::cbor::MapWriter &map,
1038 const ::tree::base::PointerMap &ids
1041 map.append_string(
"@t",
"ConstInt");
1042 auto submap = map.append_map(
"value");
1043 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Int>(
value, submap);
1045 serialize_annotations(map);
1053 auto type = map.at(
"@t").as_string();
1054 if (
type !=
"ConstInt") {
1055 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1057 auto node = std::make_shared<ConstInt>(
1058 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Int>(map.at(
"value").as_map())
1060 node->deserialize_annotations(map);
1112 return dynamic_cast<const ConstJson*
>(
this);
1119 return cqasm::tree::make<ConstJson>(*this);
1126 auto node = cqasm::tree::make<ConstJson>(*this);
1135 auto rhsc =
dynamic_cast<const ConstJson&
>(rhs);
1136 if (this->
value != rhsc.value)
return false;
1145 auto rhsc =
dynamic_cast<const ConstJson&
>(rhs);
1146 if (this->
value != rhsc.value)
return false;
1154 ::tree::cbor::MapWriter &map,
1155 const ::tree::base::PointerMap &ids
1158 map.append_string(
"@t",
"ConstJson");
1159 auto submap = map.append_map(
"value");
1160 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Str>(
value, submap);
1162 serialize_annotations(map);
1170 auto type = map.at(
"@t").as_string();
1171 if (
type !=
"ConstJson") {
1172 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1174 auto node = std::make_shared<ConstJson>(
1175 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at(
"value").as_map())
1177 node->deserialize_annotations(map);
1229 return dynamic_cast<const ConstReal*
>(
this);
1236 return cqasm::tree::make<ConstReal>(*this);
1243 auto node = cqasm::tree::make<ConstReal>(*this);
1252 auto rhsc =
dynamic_cast<const ConstReal&
>(rhs);
1253 if (this->
value != rhsc.value)
return false;
1262 auto rhsc =
dynamic_cast<const ConstReal&
>(rhs);
1263 if (this->
value != rhsc.value)
return false;
1271 ::tree::cbor::MapWriter &map,
1272 const ::tree::base::PointerMap &ids
1275 map.append_string(
"@t",
"ConstReal");
1276 auto submap = map.append_map(
"value");
1277 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Real>(
value, submap);
1279 serialize_annotations(map);
1287 auto type = map.at(
"@t").as_string();
1288 if (
type !=
"ConstReal") {
1289 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1291 auto node = std::make_shared<ConstReal>(
1292 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Real>(map.at(
"value").as_map())
1294 node->deserialize_annotations(map);
1353 return cqasm::tree::make<ConstRealMatrix>(*this);
1360 auto node = cqasm::tree::make<ConstRealMatrix>(*this);
1370 if (this->
value != rhsc.value)
return false;
1380 if (this->
value != rhsc.value)
return false;
1388 ::tree::cbor::MapWriter &map,
1389 const ::tree::base::PointerMap &ids
1392 map.append_string(
"@t",
"ConstRealMatrix");
1393 auto submap = map.append_map(
"value");
1394 cqasm::v1::primitives::serialize<cqasm::v1::primitives::RMatrix>(
value, submap);
1396 serialize_annotations(map);
1404 auto type = map.at(
"@t").as_string();
1405 if (
type !=
"ConstRealMatrix") {
1406 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1408 auto node = std::make_shared<ConstRealMatrix>(
1409 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::RMatrix>(map.at(
"value").as_map())
1411 node->deserialize_annotations(map);
1470 return cqasm::tree::make<ConstString>(*this);
1477 auto node = cqasm::tree::make<ConstString>(*this);
1486 auto rhsc =
dynamic_cast<const ConstString&
>(rhs);
1487 if (this->
value != rhsc.value)
return false;
1496 auto rhsc =
dynamic_cast<const ConstString&
>(rhs);
1497 if (this->
value != rhsc.value)
return false;
1505 ::tree::cbor::MapWriter &map,
1506 const ::tree::base::PointerMap &ids
1509 map.append_string(
"@t",
"ConstString");
1510 auto submap = map.append_map(
"value");
1511 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Str>(
value, submap);
1513 serialize_annotations(map);
1521 auto type = map.at(
"@t").as_string();
1522 if (
type !=
"ConstString") {
1523 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1525 auto node = std::make_shared<ConstString>(
1526 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at(
"value").as_map())
1528 node->deserialize_annotations(map);
1536 : name(name), operands(operands), return_type(return_type)
1576 return dynamic_cast<Function*
>(
this);
1584 return dynamic_cast<const Function*
>(
this);
1591 return cqasm::tree::make<Function>(*this);
1598 auto node = cqasm::tree::make<Function>(*this);
1599 node->operands = this->
operands.clone();
1609 auto rhsc =
dynamic_cast<const Function&
>(rhs);
1610 if (this->
name != rhsc.name)
return false;
1611 if (!this->
operands.equals(rhsc.operands))
return false;
1612 if (!this->
return_type.equals(rhsc.return_type))
return false;
1621 auto rhsc =
dynamic_cast<const Function&
>(rhs);
1622 if (this->
name != rhsc.name)
return false;
1623 if (this->
operands != rhsc.operands)
return false;
1624 if (this->
return_type != rhsc.return_type)
return false;
1632 ::tree::cbor::MapWriter &map,
1633 const ::tree::base::PointerMap &ids
1636 map.append_string(
"@t",
"Function");
1637 auto submap = map.append_map(
"name");
1638 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Str>(
name, submap);
1640 submap = map.append_map(
"operands");
1643 submap = map.append_map(
"return_type");
1646 serialize_annotations(map);
1654 auto type = map.at(
"@t").as_string();
1655 if (
type !=
"Function") {
1656 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1658 auto node = std::make_shared<Function>(
1659 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at(
"name").as_map()),
1663 node->deserialize_annotations(map);
1679 index.find_reachable(map);
1687 index.check_complete(map);
1717 return dynamic_cast<const QubitRefs*
>(
this);
1724 return cqasm::tree::make<QubitRefs>(*this);
1731 auto node = cqasm::tree::make<QubitRefs>(*this);
1732 node->index = this->
index.clone();
1741 auto rhsc =
dynamic_cast<const QubitRefs&
>(rhs);
1742 if (!this->
index.equals(rhsc.index))
return false;
1751 auto rhsc =
dynamic_cast<const QubitRefs&
>(rhs);
1752 if (this->
index != rhsc.index)
return false;
1760 ::tree::cbor::MapWriter &map,
1761 const ::tree::base::PointerMap &ids
1764 map.append_string(
"@t",
"QubitRefs");
1765 auto submap = map.append_map(
"index");
1766 index.serialize(submap, ids);
1768 serialize_annotations(map);
1776 auto type = map.at(
"@t").as_string();
1777 if (
type !=
"QubitRefs") {
1778 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1780 auto node = std::make_shared<QubitRefs>(
1783 node->deserialize_annotations(map);
1844 return cqasm::tree::make<VariableRef>(*this);
1851 auto node = cqasm::tree::make<VariableRef>(*this);
1860 auto rhsc =
dynamic_cast<const VariableRef&
>(rhs);
1861 if (!this->
variable.equals(rhsc.variable))
return false;
1870 auto rhsc =
dynamic_cast<const VariableRef&
>(rhs);
1871 if (this->
variable != rhsc.variable)
return false;
1879 ::tree::cbor::MapWriter &map,
1880 const ::tree::base::PointerMap &ids
1883 map.append_string(
"@t",
"VariableRef");
1884 auto submap = map.append_map(
"variable");
1887 serialize_annotations(map);
1895 auto type = map.at(
"@t").as_string();
1896 if (
type !=
"VariableRef") {
1897 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1899 auto node = std::make_shared<VariableRef>(
1902 auto link = map.at(
"variable").as_map().at(
"@l");
1903 if (!link.is_null()) {
1904 ids.register_link(node->variable, link.as_int());
1906 node->deserialize_annotations(map);
1916 this->visit_node(node);
1925 this->visit_bit_refs(node);
1934 this->visit_const_axis(node);
1943 this->visit_const_bool(node);
1952 this->visit_const_complex(node);
1961 this->visit_const_complex_matrix(node);
1970 this->visit_const_int(node);
1979 this->visit_const_json(node);
1988 this->visit_const_real(node);
1997 this->visit_const_real_matrix(node);
2006 this->visit_const_string(node);
2015 this->visit_constant(node);
2024 this->visit_function(node);
2033 this->visit_qubit_refs(node);
2042 this->visit_reference(node);
2051 this->visit_variable_ref(node);
2058 visit_reference(node);
2059 node.
index.visit(*
this);
2066 visit_constant(node);
2073 visit_constant(node);
2080 visit_constant(node);
2087 visit_constant(node);
2094 visit_constant(node);
2101 visit_constant(node);
2108 visit_constant(node);
2115 visit_constant(node);
2122 visit_constant(node);
2143 visit_reference(node);
2144 node.
index.visit(*
this);
2158 visit_reference(node);
2165 for (
int i = 0; i < indent; i++) {
2176 out <<
"!Node()" << std::endl;
2185 if (ids !=
nullptr) {
2186 out <<
"@" << ids->get_ref(node);
2190 out <<
" # " << *loc;
2196 if (node.
index.empty()) {
2197 out <<
"!MISSING" << std::endl;
2199 out <<
"[" << std::endl;
2201 for (
auto &sptr : node.
index) {
2202 if (!sptr.empty()) {
2206 out <<
"!NULL" << std::endl;
2211 out <<
"]" << std::endl;
2215 out <<
")" << std::endl;
2224 if (ids !=
nullptr) {
2225 out <<
"@" << ids->get_ref(node);
2229 out <<
" # " << *loc;
2235 std::stringstream ss;
2238 pos = ss.str().find_last_not_of(
" \n\r\t");
2239 if (pos != std::string::npos) {
2240 ss.str(ss.str().erase(pos+1));
2242 if (ss.str().find(
'\n') == std::string::npos) {
2243 out << ss.str() << std::endl;
2245 out <<
"cqasm::v1::primitives::Axis<<" << std::endl;
2249 std::getline(ss, s);
2251 out << s << std::endl;
2255 out <<
">>" << std::endl;
2259 out <<
")" << std::endl;
2268 if (ids !=
nullptr) {
2269 out <<
"@" << ids->get_ref(node);
2273 out <<
" # " << *loc;
2279 std::stringstream ss;
2282 pos = ss.str().find_last_not_of(
" \n\r\t");
2283 if (pos != std::string::npos) {
2284 ss.str(ss.str().erase(pos+1));
2286 if (ss.str().find(
'\n') == std::string::npos) {
2287 out << ss.str() << std::endl;
2289 out <<
"cqasm::v1::primitives::Bool<<" << std::endl;
2293 std::getline(ss, s);
2295 out << s << std::endl;
2299 out <<
">>" << std::endl;
2303 out <<
")" << std::endl;
2311 out <<
"ConstComplex";
2312 if (ids !=
nullptr) {
2313 out <<
"@" << ids->get_ref(node);
2317 out <<
" # " << *loc;
2323 std::stringstream ss;
2326 pos = ss.str().find_last_not_of(
" \n\r\t");
2327 if (pos != std::string::npos) {
2328 ss.str(ss.str().erase(pos+1));
2330 if (ss.str().find(
'\n') == std::string::npos) {
2331 out << ss.str() << std::endl;
2333 out <<
"cqasm::v1::primitives::Complex<<" << std::endl;
2337 std::getline(ss, s);
2339 out << s << std::endl;
2343 out <<
">>" << std::endl;
2347 out <<
")" << std::endl;
2355 out <<
"ConstComplexMatrix";
2356 if (ids !=
nullptr) {
2357 out <<
"@" << ids->get_ref(node);
2361 out <<
" # " << *loc;
2367 std::stringstream ss;
2370 pos = ss.str().find_last_not_of(
" \n\r\t");
2371 if (pos != std::string::npos) {
2372 ss.str(ss.str().erase(pos+1));
2374 if (ss.str().find(
'\n') == std::string::npos) {
2375 out << ss.str() << std::endl;
2377 out <<
"cqasm::v1::primitives::CMatrix<<" << std::endl;
2381 std::getline(ss, s);
2383 out << s << std::endl;
2387 out <<
">>" << std::endl;
2391 out <<
")" << std::endl;
2400 if (ids !=
nullptr) {
2401 out <<
"@" << ids->get_ref(node);
2405 out <<
" # " << *loc;
2411 std::stringstream ss;
2414 pos = ss.str().find_last_not_of(
" \n\r\t");
2415 if (pos != std::string::npos) {
2416 ss.str(ss.str().erase(pos+1));
2418 if (ss.str().find(
'\n') == std::string::npos) {
2419 out << ss.str() << std::endl;
2421 out <<
"cqasm::v1::primitives::Int<<" << std::endl;
2425 std::getline(ss, s);
2427 out << s << std::endl;
2431 out <<
">>" << std::endl;
2435 out <<
")" << std::endl;
2444 if (ids !=
nullptr) {
2445 out <<
"@" << ids->get_ref(node);
2449 out <<
" # " << *loc;
2455 std::stringstream ss;
2458 pos = ss.str().find_last_not_of(
" \n\r\t");
2459 if (pos != std::string::npos) {
2460 ss.str(ss.str().erase(pos+1));
2462 if (ss.str().find(
'\n') == std::string::npos) {
2463 out << ss.str() << std::endl;
2465 out <<
"cqasm::v1::primitives::Str<<" << std::endl;
2469 std::getline(ss, s);
2471 out << s << std::endl;
2475 out <<
">>" << std::endl;
2479 out <<
")" << std::endl;
2488 if (ids !=
nullptr) {
2489 out <<
"@" << ids->get_ref(node);
2493 out <<
" # " << *loc;
2499 std::stringstream ss;
2502 pos = ss.str().find_last_not_of(
" \n\r\t");
2503 if (pos != std::string::npos) {
2504 ss.str(ss.str().erase(pos+1));
2506 if (ss.str().find(
'\n') == std::string::npos) {
2507 out << ss.str() << std::endl;
2509 out <<
"cqasm::v1::primitives::Real<<" << std::endl;
2513 std::getline(ss, s);
2515 out << s << std::endl;
2519 out <<
">>" << std::endl;
2523 out <<
")" << std::endl;
2531 out <<
"ConstRealMatrix";
2532 if (ids !=
nullptr) {
2533 out <<
"@" << ids->get_ref(node);
2537 out <<
" # " << *loc;
2543 std::stringstream ss;
2546 pos = ss.str().find_last_not_of(
" \n\r\t");
2547 if (pos != std::string::npos) {
2548 ss.str(ss.str().erase(pos+1));
2550 if (ss.str().find(
'\n') == std::string::npos) {
2551 out << ss.str() << std::endl;
2553 out <<
"cqasm::v1::primitives::RMatrix<<" << std::endl;
2557 std::getline(ss, s);
2559 out << s << std::endl;
2563 out <<
">>" << std::endl;
2567 out <<
")" << std::endl;
2575 out <<
"ConstString";
2576 if (ids !=
nullptr) {
2577 out <<
"@" << ids->get_ref(node);
2581 out <<
" # " << *loc;
2587 std::stringstream ss;
2590 pos = ss.str().find_last_not_of(
" \n\r\t");
2591 if (pos != std::string::npos) {
2592 ss.str(ss.str().erase(pos+1));
2594 if (ss.str().find(
'\n') == std::string::npos) {
2595 out << ss.str() << std::endl;
2597 out <<
"cqasm::v1::primitives::Str<<" << std::endl;
2601 std::getline(ss, s);
2603 out << s << std::endl;
2607 out <<
">>" << std::endl;
2611 out <<
")" << std::endl;
2620 if (ids !=
nullptr) {
2621 out <<
"@" << ids->get_ref(node);
2625 out <<
" # " << *loc;
2628 out <<
")" << std::endl;
2637 if (ids !=
nullptr) {
2638 out <<
"@" << ids->get_ref(node);
2642 out <<
" # " << *loc;
2648 std::stringstream ss;
2651 pos = ss.str().find_last_not_of(
" \n\r\t");
2652 if (pos != std::string::npos) {
2653 ss.str(ss.str().erase(pos+1));
2655 if (ss.str().find(
'\n') == std::string::npos) {
2656 out << ss.str() << std::endl;
2658 out <<
"cqasm::v1::primitives::Str<<" << std::endl;
2662 std::getline(ss, s);
2664 out << s << std::endl;
2668 out <<
">>" << std::endl;
2671 out <<
"operands: ";
2673 out <<
"[]" << std::endl;
2675 out <<
"[" << std::endl;
2678 if (!sptr.empty()) {
2679 sptr->dump(out, indent);
2682 out <<
"!NULL" << std::endl;
2687 out <<
"]" << std::endl;
2690 out <<
"return_type: ";
2692 out <<
"!MISSING" << std::endl;
2694 out <<
"<" << std::endl;
2701 out <<
">" << std::endl;
2705 out <<
")" << std::endl;
2714 if (ids !=
nullptr) {
2715 out <<
"@" << ids->get_ref(node);
2719 out <<
" # " << *loc;
2725 if (node.
index.empty()) {
2726 out <<
"!MISSING" << std::endl;
2728 out <<
"[" << std::endl;
2730 for (
auto &sptr : node.
index) {
2731 if (!sptr.empty()) {
2735 out <<
"!NULL" << std::endl;
2740 out <<
"]" << std::endl;
2744 out <<
")" << std::endl;
2753 if (ids !=
nullptr) {
2754 out <<
"@" << ids->get_ref(node);
2758 out <<
" # " << *loc;
2761 out <<
")" << std::endl;
2769 out <<
"VariableRef";
2770 if (ids !=
nullptr) {
2771 out <<
"@" << ids->get_ref(node);
2775 out <<
" # " << *loc;
2780 out <<
"variable --> ";
2782 out <<
"!MISSING" << std::endl;
2783 }
else if (ids !=
nullptr && ids->get(node.
variable) != (size_t)-1) {
2784 out <<
"Link<cqasm::v1::semantic::Variable>@" << ids->get(node.
variable) << std::endl;
2786 out <<
"<" << std::endl;
2796 out <<
"..." << std::endl;
2800 out <<
">" << std::endl;
2804 out <<
")" << std::endl;
2819 const_cast<Node&
>(object).
dump(os);
ConstString * as_const_string() override
Interprets this node to a node of type ConstString.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
Two-dimensional matrix of some kind of type.
cqasm::v1::primitives::RMatrix value
The contained value.
void write_indent()
Writes the current indentation level's worth of spaces.
void visit_const_complex_matrix(ConstComplexMatrix &node) override
Dumps a ConstComplexMatrix node.
Represents a reference to some storage location.
void visit_const_real(ConstReal &node) override
Recursive traversal for ConstReal nodes.
BitRefs(const Many< ConstInt > &index=Many< ConstInt >())
Constructor.
ConstBool * as_const_bool() override
Interprets this node to a node of type ConstBool.
std::complex< double > Complex
Complex number primitive used within the semantic trees.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
Internal class for implementing the visitor pattern.
One< Node > copy() const override
Returns a shallow copy of this node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void raw_visit_function(Function &node, void *retval) override
Internal visitor function for Function nodes.
void raw_visit_const_real_matrix(ConstRealMatrix &node, void *retval) override
Internal visitor function for ConstRealMatrix nodes.
NodeType type() const override
Returns the NodeType of this node.
void visit_const_bool(ConstBool &node) override
Dumps a ConstBool node.
void raw_visit_const_bool(ConstBool &node, void *retval) override
Internal visitor function for ConstBool nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
static std::shared_ptr< ConstRealMatrix > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
ConstComplex(const cqasm::v1::primitives::Complex &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Complex >())
Constructor.
ConstString(const cqasm::v1::primitives::Str &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Str >())
Constructor.
void visit_const_json(ConstJson &node) override
Recursive traversal for ConstJson nodes.
ConstInt * as_const_int() override
Interprets this node to a node of type ConstInt.
NodeType type() const override
Returns the NodeType of this node.
This can be returned by user-defined functions as a placeholder value for something that needs to be ...
ConstInt(const cqasm::v1::primitives::Int &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Int >())
Constructor.
NodeType type() const override
Returns the NodeType of this node.
ConstAxis * as_const_axis() override
Interprets this node to a node of type ConstAxis.
void visit_constant(Constant &node) override
Dumps a Constant node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
One< Node > clone() const override
Returns a deep copy of this node.
virtual Constant * as_constant()
Interprets this node to a node of type Constant.
ConstReal * as_const_real() override
Interprets this node to a node of type ConstReal.
bool equals(const Node &rhs) const override
Value-based equality operator.
std::ostream & operator<<(std::ostream &os, const Value &value)
Stream << overload for a single value.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
static std::shared_ptr< ConstJson > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_const_bool(ConstBool &node) override
Recursive traversal for ConstBool nodes.
void visit_const_complex(ConstComplex &node) override
Dumps a ConstComplex node.
Represents a qubit, or a set of qubits for single-gate-multiple-qubit notation.
bool equals(const Node &rhs) const override
Value-based equality operator.
void raw_visit_const_real(ConstReal &node, void *retval) override
Internal visitor function for ConstReal nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
bool equals(const Node &rhs) const override
Value-based equality operator.
Constant * as_constant() override
Interprets this node to a node of type Constant.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
ConstBool(const cqasm::v1::primitives::Bool &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Bool >())
Constructor.
void raw_visit_node(Node &node, void *retval) override
Internal visitor function for nodes of any type.
void dump_seq(std::ostream &out=std::cout, int indent=0)
Alternate debug dump that represents links and node uniqueness via sequence number tags...
Contains annotation objects used within the trees by libqasm.
void visit_variable_ref(VariableRef &node) override
Recursive traversal for VariableRef nodes.
Represents a variable reference.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
ConstComplexMatrix * as_const_complex_matrix() override
Interprets this node to a node of type ConstComplexMatrix.
virtual ConstComplex * as_const_complex()
Interprets this node to a node of type ConstComplex.
Toplevel namespace with entry points for the new API.
ConstComplexMatrix(const cqasm::v1::primitives::CMatrix &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::CMatrix >())
Constructor.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
NodeType type() const override
Returns the NodeType of this node.
static std::shared_ptr< Reference > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual void raw_visit_const_bool(ConstBool &node, void *retval)=0
Internal visitor function for ConstBool nodes.
virtual Function * as_function()
Interprets this node to a node of type Function.
Represents a value of type string.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void raw_visit_const_int(ConstInt &node, void *retval) override
Internal visitor function for ConstInt nodes.
virtual void raw_visit_const_string(ConstString &node, void *retval)=0
Internal visitor function for ConstString nodes.
ConstJson(const cqasm::v1::primitives::Str &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Str >())
Constructor.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
QubitRefs(const Many< ConstInt > &index=Many< ConstInt >())
Constructor.
virtual ConstAxis * as_const_axis()
Interprets this node to a node of type ConstAxis.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
virtual QubitRefs * as_qubit_refs()
Interprets this node to a node of type QubitRefs.
One< Node > clone() const override
Returns a deep copy of this node.
Source location annotation object, containing source file line numbers etc.
static std::shared_ptr< BitRefs > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual void raw_visit_const_axis(ConstAxis &node, void *retval)=0
Internal visitor function for ConstAxis nodes.
ConstRealMatrix * as_const_real_matrix() override
Interprets this node to a node of type ConstRealMatrix.
VariableRef(const Link< cqasm::v1::semantic::Variable > &variable=cqasm::v1::primitives::initialize< Link< cqasm::v1::semantic::Variable >>())
Constructor.
double Real
Real number primitive used within the AST and semantic trees.
static std::shared_ptr< ConstReal > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
ConstJson * as_const_json() override
Interprets this node to a node of type ConstJson.
NodeType type() const override
Returns the NodeType of this node.
Main class for all nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
T visit(Visitor< T > &visitor)
Visit this object.
void raw_visit_const_string(ConstString &node, void *retval) override
Internal visitor function for ConstString nodes.
cqasm::v1::primitives::Bool value
The contained value.
void visit_const_complex_matrix(ConstComplexMatrix &node) override
Recursive traversal for ConstComplexMatrix nodes.
static std::shared_ptr< ConstAxis > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
One< Node > clone() const override
Returns a deep copy of this node.
bool equals(const Node &rhs) const override
Value-based equality operator.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
cqasm::v1::primitives::Int value
The contained value.
cqasm::v1::primitives::Real value
The contained value.
void dump(std::ostream &out=std::cout, int indent=0)
Writes a debug dump of this node to the given stream.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
std::int64_t Int
Integer primitive used within the AST and semantic trees.
void visit_const_real_matrix(ConstRealMatrix &node) override
Dumps a ConstRealMatrix node.
void raw_visit_const_json(ConstJson &node, void *retval) override
Internal visitor function for ConstJson nodes.
Main class for all nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
Defines the types for the cQASM semantic tree, based on the classes from cqasm::tree.
virtual void raw_visit_const_real_matrix(ConstRealMatrix &node, void *retval)=0
Internal visitor function for ConstRealMatrix nodes.
One< Node > copy() const override
Returns a shallow copy of this node.
Link< cqasm::v1::semantic::Variable > variable
The referenced variable.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstAxis is complete/fully defined.
Represents a value of type complex.
Many< ConstInt > index
The qubit index that this is a measurement bit for, starting at 0.
void visit_const_complex(ConstComplex &node) override
Recursive traversal for ConstComplex nodes.
Represents a value of type bool.
NodeType type() const override
Returns the NodeType of this node.
Many< ConstInt > index
Set of qubit indices referred to, starting at 0.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
One< Node > copy() const override
Returns a shallow copy of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstJson is complete/fully defined.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
NodeType type() const override
Returns the NodeType of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
virtual void raw_visit_variable_ref(VariableRef &node, void *retval)=0
Internal visitor function for VariableRef nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
One< Node > copy() const override
Returns a shallow copy of this node.
cqasm::v1::primitives::Complex value
The contained value.
void visit_qubit_refs(QubitRefs &node) override
Recursive traversal for QubitRefs nodes.
static std::shared_ptr< Node > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_variable_ref(VariableRef &node) override
Dumps a VariableRef node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
cqasm::v1::primitives::CMatrix value
The contained value.
virtual void raw_visit_const_complex_matrix(ConstComplexMatrix &node, void *retval)=0
Internal visitor function for ConstComplexMatrix nodes.
Function(const cqasm::v1::primitives::Str &name=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Str >(), const Any< cqasm::v1::values::Node > &operands=cqasm::v1::primitives::initialize< Any< cqasm::v1::values::Node >>(), const One< cqasm::v1::types::Node > &return_type=cqasm::v1::primitives::initialize< One< cqasm::v1::types::Node >>())
Constructor.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
NodeType type() const override
Returns the NodeType of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void raw_visit_const_axis(ConstAxis &node, void *retval) override
Internal visitor function for ConstAxis nodes.
virtual ConstComplexMatrix * as_const_complex_matrix()
Interprets this node to a node of type ConstComplexMatrix.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstReal is complete/fully defined.
void raw_visit_const_complex(ConstComplex &node, void *retval) override
Internal visitor function for ConstComplex nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
static std::shared_ptr< Constant > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
One< Node > clone() const override
Returns a deep copy of this node.
VariableRef * as_variable_ref() override
Interprets this node to a node of type VariableRef.
bool Bool
Boolean primitive used within the semantic trees.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this BitRefs is complete/fully defined.
Visitor class that debug-dumps a tree to a stream.
virtual void raw_visit_function(Function &node, void *retval)=0
Internal visitor function for Function nodes.
virtual BitRefs * as_bit_refs()
Interprets this node to a node of type BitRefs.
virtual ConstBool * as_const_bool()
Interprets this node to a node of type ConstBool.
cqasm::tree::Any< T > Any
virtual void raw_visit_const_json(ConstJson &node, void *retval)=0
Internal visitor function for ConstJson nodes.
cqasm::tree::Link< T > Link
void visit_function(Function &node) override
Dumps a Function node.
NodeType type() const override
Returns the NodeType of this node.
BitRefs * as_bit_refs() override
Interprets this node to a node of type BitRefs.
void visit_const_int(ConstInt &node) override
Recursive traversal for ConstInt nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void visit_bit_refs(BitRefs &node) override
Recursive traversal for BitRefs nodes.
static std::shared_ptr< ConstInt > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
bool equals(const Node &rhs) const override
Value-based equality operator.
Namespace for the "new" cQASM 1.x API.
void visit_constant(Constant &node) override
Recursive traversal for Constant nodes.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< QubitRefs > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
cqasm::v1::primitives::Str name
Name of the function as it appears or should appear in the cQASM file.
void visit_bit_refs(BitRefs &node) override
Dumps a BitRefs node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void raw_visit_bit_refs(BitRefs &node, void *retval) override
Internal visitor function for BitRefs nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
ConstComplex * as_const_complex() override
Interprets this node to a node of type ConstComplex.
Represents a value of type json.
Represents an axis value (x, y, or z).
void raw_visit_reference(Reference &node, void *retval) override
Internal visitor function for Reference nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
Represents a value of type real_matrix.
void visit_const_axis(ConstAxis &node) override
Recursive traversal for ConstAxis nodes.
One< Node > clone() const override
Returns a deep copy of this node.
virtual NodeType type() const =0
Returns the NodeType of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstComplexMatrix is complete/fully defined.
void visit_reference(Reference &node) override
Recursive traversal for Reference nodes.
cqasm::v1::primitives::Str value
The contained value.
virtual void raw_visit_qubit_refs(QubitRefs &node, void *retval)=0
Internal visitor function for QubitRefs nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this QubitRefs is complete/fully defined.
ConstReal(const cqasm::v1::primitives::Real &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Real >())
Constructor.
One< Node > copy() const override
Returns a shallow copy of this node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstRealMatrix is complete/fully defined.
std::string Str
String primitive used within the AST and semantic trees.
cqasm::v1::primitives::Axis value
The contained value.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< ConstComplexMatrix > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual Reference * as_reference()
Interprets this node to a node of type Reference.
QubitRefs * as_qubit_refs() override
Interprets this node to a node of type QubitRefs.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_qubit_refs(QubitRefs &node) override
Dumps a QubitRefs node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
One< Node > copy() const override
Returns a shallow copy of this node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_const_string(ConstString &node) override
Recursive traversal for ConstString nodes.
void visit_const_int(ConstInt &node) override
Dumps a ConstInt node.
void raw_visit_qubit_refs(QubitRefs &node, void *retval) override
Internal visitor function for QubitRefs nodes.
virtual ConstString * as_const_string()
Interprets this node to a node of type ConstString.
static std::shared_ptr< ConstString > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_const_json(ConstJson &node) override
Dumps a ConstJson node.
One< Node > clone() const override
Returns a deep copy of this node.
void visit_reference(Reference &node) override
Dumps a Reference node.
static std::shared_ptr< Function > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_const_string(ConstString &node) override
Dumps a ConstString node.
One< Node > copy() const override
Returns a shallow copy of this node.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Node > clone() const override
Returns a deep copy of this node.
virtual ConstRealMatrix * as_const_real_matrix()
Interprets this node to a node of type ConstRealMatrix.
virtual void raw_visit_const_int(ConstInt &node, void *retval)=0
Internal visitor function for ConstInt nodes.
Represents a measurement bit, or a number of measurement bits for conditional gates with multiple con...
bool equals(const Node &rhs) const override
Value-based equality operator.
virtual void raw_visit_const_real(ConstReal &node, void *retval)=0
Internal visitor function for ConstReal nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
Represents a constant value.
One< Node > clone() const override
Returns a deep copy of this node.
NodeType type() const override
Returns the NodeType of this node.
Any< cqasm::v1::values::Node > operands
Operands for the function.
One< Node > copy() const override
Returns a shallow copy of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstInt is complete/fully defined.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< cqasm::v1::types::Node > return_type
Operands for the function.
NodeType type() const override
Returns the NodeType of this node.
NodeType type() const override
Returns the NodeType of this node.
virtual ConstJson * as_const_json()
Interprets this node to a node of type ConstJson.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
cqasm::tree::One< T > One
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Function is complete/fully defined.
static std::shared_ptr< ConstComplex > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
bool equals(const Node &rhs) const override
Value-based equality operator.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstBool is complete/fully defined.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
One< Node > clone() const override
Returns a deep copy of this node.
virtual void raw_visit_bit_refs(BitRefs &node, void *retval)=0
Internal visitor function for BitRefs nodes.
virtual ConstInt * as_const_int()
Interprets this node to a node of type ConstInt.
void visit_function(Function &node) override
Recursive traversal for Function nodes.
void visit_const_real_matrix(ConstRealMatrix &node) override
Recursive traversal for ConstRealMatrix nodes.
Header file for the various classes representing constants, references, and dynamic expressions in cQ...
Represents a value of type int.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this VariableRef is complete/fully defined.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
Represents a value of type real.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
One< Node > clone() const override
Returns a deep copy of this node.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_const_real(ConstReal &node) override
Dumps a ConstReal node.
Reference * as_reference() override
Interprets this node to a node of type Reference.
static std::shared_ptr< VariableRef > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
One< Node > copy() const override
Returns a shallow copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
cqasm::tree::Many< T > Many
virtual ConstReal * as_const_real()
Interprets this node to a node of type ConstReal.
void visit_const_axis(ConstAxis &node) override
Dumps a ConstAxis node.
ConstRealMatrix(const cqasm::v1::primitives::RMatrix &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::RMatrix >())
Constructor.
NodeType type() const override
Returns the NodeType of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void raw_visit_const_complex_matrix(ConstComplexMatrix &node, void *retval) override
Internal visitor function for ConstComplexMatrix nodes.
Represents a value of type complex_matrix.
Axis
Axis primitive used within the semantic trees.
One< Node > copy() const override
Returns a shallow copy of this node.
cqasm::v1::primitives::Str value
The contained value.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstComplex is complete/fully defined.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
NodeType
Enumeration of all node types.
Function * as_function() override
Interprets this node to a node of type Function.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< ConstBool > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual VariableRef * as_variable_ref()
Interprets this node to a node of type VariableRef.
virtual void raw_visit_const_complex(ConstComplex &node, void *retval)=0
Internal visitor function for ConstComplex nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ConstString is complete/fully defined.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void raw_visit_variable_ref(VariableRef &node, void *retval) override
Internal visitor function for VariableRef nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void raw_visit_constant(Constant &node, void *retval) override
Internal visitor function for Constant nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_node(Node &node) override
Dumps a Node.
ConstAxis(const cqasm::v1::primitives::Axis &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Axis >())
Constructor.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.