16 auto dumper =
Dumper(out, indent);
25 ::tree::base::PointerMap ids;
26 ids.enable_exceptions =
false;
29 auto dumper =
Dumper(out, indent, &ids);
1189 const ::tree::cbor::MapReader &map,
1190 ::tree::base::IdentifierMap &ids
1192 auto type = map.at(
"@t").as_string();
1252 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1268 return dynamic_cast<const Expression*
>(
this);
1275 auto type = map.at(
"@t").as_string();
1311 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1326 return dynamic_cast<BinaryOp*
>(
this);
1334 return dynamic_cast<const BinaryOp*
>(
this);
1341 auto type = map.at(
"@t").as_string();
1364 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1379 return dynamic_cast<ArithOp*
>(
this);
1387 return dynamic_cast<const ArithOp*
>(
this);
1393 std::shared_ptr<ArithOp>
ArithOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1394 auto type = map.at(
"@t").as_string();
1402 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1417 lhs.find_reachable(map);
1418 rhs.find_reachable(map);
1426 lhs.check_complete(map);
1427 rhs.check_complete(map);
1449 return dynamic_cast<Add*
>(
this);
1457 return dynamic_cast<const Add*
>(
this);
1464 return cqasm::tree::make<Add>(*this);
1471 auto node = cqasm::tree::make<Add>(*this);
1472 node->lhs = this->
lhs.clone();
1473 node->rhs = this->
rhs.clone();
1482 auto rhsc =
dynamic_cast<const Add&
>(
rhs);
1483 if (!this->
lhs.equals(rhsc.lhs))
return false;
1484 if (!this->rhs.
equals(rhsc.rhs))
return false;
1493 auto rhsc =
dynamic_cast<const Add&
>(
rhs);
1494 if (this->
lhs != rhsc.lhs)
return false;
1495 if (this->rhs != rhsc.rhs)
return false;
1503 ::tree::cbor::MapWriter &map,
1504 const ::tree::base::PointerMap &ids
1507 map.append_string(
"@t",
"Add");
1508 auto submap = map.append_map(
"lhs");
1509 lhs.serialize(submap, ids);
1511 submap = map.append_map(
"rhs");
1512 rhs.serialize(submap, ids);
1514 serialize_annotations(map);
1520 std::shared_ptr<Add>
Add::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1522 auto type = map.at(
"@t").as_string();
1523 if (
type !=
"Add") {
1524 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1526 auto node = std::make_shared<Add>(
1530 node->deserialize_annotations(map);
1538 : annotations(annotations)
1554 return dynamic_cast<const Annotated*
>(
this);
1561 auto type = map.at(
"@t").as_string();
1575 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1582 : interface(interface), operation(operation), operands(operands)
1639 return cqasm::tree::make<AnnotationData>(*this);
1646 auto node = cqasm::tree::make<AnnotationData>(*this);
1647 node->interface = this->
interface.clone();
1648 node->operation = this->
operation.clone();
1649 node->operands = this->
operands.clone();
1659 if (!this->
interface.equals(rhsc.interface))
return false;
1660 if (!this->
operation.equals(rhsc.operation))
return false;
1661 if (!this->
operands.equals(rhsc.operands))
return false;
1671 if (this->
interface != rhsc.interface)
return false;
1672 if (this->
operation != rhsc.operation)
return false;
1673 if (this->
operands != rhsc.operands)
return false;
1681 ::tree::cbor::MapWriter &map,
1682 const ::tree::base::PointerMap &ids
1685 map.append_string(
"@t",
"AnnotationData");
1686 auto submap = map.append_map(
"interface");
1689 submap = map.append_map(
"operation");
1692 submap = map.append_map(
"operands");
1695 serialize_annotations(map);
1703 auto type = map.at(
"@t").as_string();
1704 if (
type !=
"AnnotationData") {
1705 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1707 auto node = std::make_shared<AnnotationData>(
1712 node->deserialize_annotations(map);
1720 : lhs(lhs), rhs(rhs)
1728 lhs.find_reachable(map);
1729 rhs.find_reachable(map);
1737 lhs.check_complete(map);
1738 rhs.check_complete(map);
1768 return dynamic_cast<const Assignment*
>(
this);
1775 return cqasm::tree::make<Assignment>(*this);
1782 auto node = cqasm::tree::make<Assignment>(*this);
1783 node->lhs = this->
lhs.clone();
1784 node->rhs = this->
rhs.clone();
1794 if (!this->
lhs.equals(rhsc.lhs))
return false;
1795 if (!this->rhs.
equals(rhsc.rhs))
return false;
1805 if (this->
lhs != rhsc.lhs)
return false;
1806 if (this->rhs != rhsc.rhs)
return false;
1814 ::tree::cbor::MapWriter &map,
1815 const ::tree::base::PointerMap &ids
1818 map.append_string(
"@t",
"Assignment");
1819 auto submap = map.append_map(
"lhs");
1820 lhs.serialize(submap, ids);
1822 submap = map.append_map(
"rhs");
1823 rhs.serialize(submap, ids);
1825 serialize_annotations(map);
1833 auto type = map.at(
"@t").as_string();
1834 if (
type !=
"Assignment") {
1835 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1837 auto node = std::make_shared<Assignment>(
1841 node->deserialize_annotations(map);
1865 return dynamic_cast<const BitwiseOp*
>(
this);
1872 auto type = map.at(
"@t").as_string();
1876 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
1891 lhs.find_reachable(map);
1892 rhs.find_reachable(map);
1900 lhs.check_complete(map);
1901 rhs.check_complete(map);
1931 return dynamic_cast<const BitwiseAnd*
>(
this);
1938 return cqasm::tree::make<BitwiseAnd>(*this);
1945 auto node = cqasm::tree::make<BitwiseAnd>(*this);
1946 node->lhs = this->
lhs.clone();
1947 node->rhs = this->
rhs.clone();
1957 if (!this->
lhs.equals(rhsc.lhs))
return false;
1958 if (!this->rhs.
equals(rhsc.rhs))
return false;
1968 if (this->
lhs != rhsc.lhs)
return false;
1969 if (this->rhs != rhsc.rhs)
return false;
1977 ::tree::cbor::MapWriter &map,
1978 const ::tree::base::PointerMap &ids
1981 map.append_string(
"@t",
"BitwiseAnd");
1982 auto submap = map.append_map(
"lhs");
1983 lhs.serialize(submap, ids);
1985 submap = map.append_map(
"rhs");
1986 rhs.serialize(submap, ids);
1988 serialize_annotations(map);
1996 auto type = map.at(
"@t").as_string();
1997 if (
type !=
"BitwiseAnd") {
1998 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2000 auto node = std::make_shared<BitwiseAnd>(
2004 node->deserialize_annotations(map);
2020 return dynamic_cast<UnaryOp*
>(
this);
2028 return dynamic_cast<const UnaryOp*
>(
this);
2034 std::shared_ptr<UnaryOp>
UnaryOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2035 auto type = map.at(
"@t").as_string();
2039 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2054 expr.find_reachable(map);
2062 expr.check_complete(map);
2092 return dynamic_cast<const BitwiseNot*
>(
this);
2099 return cqasm::tree::make<BitwiseNot>(*this);
2106 auto node = cqasm::tree::make<BitwiseNot>(*this);
2107 node->expr = this->
expr.clone();
2116 auto rhsc =
dynamic_cast<const BitwiseNot&
>(rhs);
2117 if (!this->
expr.equals(rhsc.expr))
return false;
2126 auto rhsc =
dynamic_cast<const BitwiseNot&
>(rhs);
2127 if (this->
expr != rhsc.expr)
return false;
2135 ::tree::cbor::MapWriter &map,
2136 const ::tree::base::PointerMap &ids
2139 map.append_string(
"@t",
"BitwiseNot");
2140 auto submap = map.append_map(
"expr");
2141 expr.serialize(submap, ids);
2143 serialize_annotations(map);
2151 auto type = map.at(
"@t").as_string();
2152 if (
type !=
"BitwiseNot") {
2153 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2155 auto node = std::make_shared<BitwiseNot>(
2158 node->deserialize_annotations(map);
2174 lhs.find_reachable(map);
2175 rhs.find_reachable(map);
2183 lhs.check_complete(map);
2184 rhs.check_complete(map);
2214 return dynamic_cast<const BitwiseOr*
>(
this);
2221 return cqasm::tree::make<BitwiseOr>(*this);
2228 auto node = cqasm::tree::make<BitwiseOr>(*this);
2229 node->lhs = this->
lhs.clone();
2230 node->rhs = this->
rhs.clone();
2240 if (!this->
lhs.equals(rhsc.lhs))
return false;
2241 if (!this->rhs.
equals(rhsc.rhs))
return false;
2251 if (this->
lhs != rhsc.lhs)
return false;
2252 if (this->rhs != rhsc.rhs)
return false;
2260 ::tree::cbor::MapWriter &map,
2261 const ::tree::base::PointerMap &ids
2264 map.append_string(
"@t",
"BitwiseOr");
2265 auto submap = map.append_map(
"lhs");
2266 lhs.serialize(submap, ids);
2268 submap = map.append_map(
"rhs");
2269 rhs.serialize(submap, ids);
2271 serialize_annotations(map);
2279 auto type = map.at(
"@t").as_string();
2280 if (
type !=
"BitwiseOr") {
2281 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2283 auto node = std::make_shared<BitwiseOr>(
2287 node->deserialize_annotations(map);
2303 lhs.find_reachable(map);
2304 rhs.find_reachable(map);
2312 lhs.check_complete(map);
2313 rhs.check_complete(map);
2343 return dynamic_cast<const BitwiseXor*
>(
this);
2350 return cqasm::tree::make<BitwiseXor>(*this);
2357 auto node = cqasm::tree::make<BitwiseXor>(*this);
2358 node->lhs = this->
lhs.clone();
2359 node->rhs = this->
rhs.clone();
2369 if (!this->
lhs.equals(rhsc.lhs))
return false;
2370 if (!this->rhs.
equals(rhsc.rhs))
return false;
2380 if (this->
lhs != rhsc.lhs)
return false;
2381 if (this->rhs != rhsc.rhs)
return false;
2389 ::tree::cbor::MapWriter &map,
2390 const ::tree::base::PointerMap &ids
2393 map.append_string(
"@t",
"BitwiseXor");
2394 auto submap = map.append_map(
"lhs");
2395 lhs.serialize(submap, ids);
2397 submap = map.append_map(
"rhs");
2398 rhs.serialize(submap, ids);
2400 serialize_annotations(map);
2408 auto type = map.at(
"@t").as_string();
2409 if (
type !=
"BitwiseXor") {
2410 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2412 auto node = std::make_shared<BitwiseXor>(
2416 node->deserialize_annotations(map);
2440 return dynamic_cast<const Statement*
>(
this);
2447 auto type = map.at(
"@t").as_string();
2460 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2483 return dynamic_cast<const Structured*
>(
this);
2490 auto type = map.at(
"@t").as_string();
2498 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2558 return cqasm::tree::make<BreakStatement>(*this);
2565 auto node = cqasm::tree::make<BreakStatement>(*this);
2576 if (!this->
annotations.equals(rhsc.annotations))
return false;
2586 if (this->
annotations != rhsc.annotations)
return false;
2594 ::tree::cbor::MapWriter &map,
2595 const ::tree::base::PointerMap &ids
2598 map.append_string(
"@t",
"BreakStatement");
2599 auto submap = map.append_map(
"annotations");
2602 serialize_annotations(map);
2610 auto type = map.at(
"@t").as_string();
2611 if (
type !=
"BreakStatement") {
2612 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2614 auto node = std::make_shared<BreakStatement>(
2617 node->deserialize_annotations(map);
2633 items.find_reachable(map);
2642 items.check_complete(map);
2665 return dynamic_cast<Bundle*
>(
this);
2673 return dynamic_cast<const Bundle*
>(
this);
2680 return cqasm::tree::make<Bundle>(*this);
2687 auto node = cqasm::tree::make<Bundle>(*this);
2688 node->items = this->
items.clone();
2698 auto rhsc =
dynamic_cast<const Bundle&
>(rhs);
2699 if (!this->
items.equals(rhsc.items))
return false;
2700 if (!this->
annotations.equals(rhsc.annotations))
return false;
2709 auto rhsc =
dynamic_cast<const Bundle&
>(rhs);
2710 if (this->
items != rhsc.items)
return false;
2711 if (this->
annotations != rhsc.annotations)
return false;
2719 ::tree::cbor::MapWriter &map,
2720 const ::tree::base::PointerMap &ids
2723 map.append_string(
"@t",
"Bundle");
2724 auto submap = map.append_map(
"items");
2725 items.serialize(submap, ids);
2727 submap = map.append_map(
"annotations");
2730 serialize_annotations(map);
2736 std::shared_ptr<Bundle>
Bundle::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2738 auto type = map.at(
"@t").as_string();
2739 if (
type !=
"Bundle") {
2740 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2742 auto node = std::make_shared<Bundle>(
2746 node->deserialize_annotations(map);
2762 return dynamic_cast<CmpOp*
>(
this);
2770 return dynamic_cast<const CmpOp*
>(
this);
2776 std::shared_ptr<CmpOp>
CmpOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2777 auto type = map.at(
"@t").as_string();
2784 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2799 lhs.find_reachable(map);
2800 rhs.find_reachable(map);
2808 lhs.check_complete(map);
2809 rhs.check_complete(map);
2831 return dynamic_cast<CmpEq*
>(
this);
2839 return dynamic_cast<const CmpEq*
>(
this);
2846 return cqasm::tree::make<CmpEq>(*this);
2853 auto node = cqasm::tree::make<CmpEq>(*this);
2854 node->lhs = this->
lhs.clone();
2855 node->rhs = this->
rhs.clone();
2864 auto rhsc =
dynamic_cast<const CmpEq&
>(
rhs);
2865 if (!this->
lhs.equals(rhsc.lhs))
return false;
2866 if (!this->rhs.
equals(rhsc.rhs))
return false;
2875 auto rhsc =
dynamic_cast<const CmpEq&
>(
rhs);
2876 if (this->
lhs != rhsc.lhs)
return false;
2877 if (this->rhs != rhsc.rhs)
return false;
2885 ::tree::cbor::MapWriter &map,
2886 const ::tree::base::PointerMap &ids
2889 map.append_string(
"@t",
"CmpEq");
2890 auto submap = map.append_map(
"lhs");
2891 lhs.serialize(submap, ids);
2893 submap = map.append_map(
"rhs");
2894 rhs.serialize(submap, ids);
2896 serialize_annotations(map);
2902 std::shared_ptr<CmpEq>
CmpEq::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2904 auto type = map.at(
"@t").as_string();
2905 if (
type !=
"CmpEq") {
2906 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
2908 auto node = std::make_shared<CmpEq>(
2912 node->deserialize_annotations(map);
2928 lhs.find_reachable(map);
2929 rhs.find_reachable(map);
2937 lhs.check_complete(map);
2938 rhs.check_complete(map);
2960 return dynamic_cast<CmpGe*
>(
this);
2968 return dynamic_cast<const CmpGe*
>(
this);
2975 return cqasm::tree::make<CmpGe>(*this);
2982 auto node = cqasm::tree::make<CmpGe>(*this);
2983 node->lhs = this->
lhs.clone();
2984 node->rhs = this->
rhs.clone();
2993 auto rhsc =
dynamic_cast<const CmpGe&
>(
rhs);
2994 if (!this->
lhs.equals(rhsc.lhs))
return false;
2995 if (!this->rhs.
equals(rhsc.rhs))
return false;
3004 auto rhsc =
dynamic_cast<const CmpGe&
>(
rhs);
3005 if (this->
lhs != rhsc.lhs)
return false;
3006 if (this->rhs != rhsc.rhs)
return false;
3014 ::tree::cbor::MapWriter &map,
3015 const ::tree::base::PointerMap &ids
3018 map.append_string(
"@t",
"CmpGe");
3019 auto submap = map.append_map(
"lhs");
3020 lhs.serialize(submap, ids);
3022 submap = map.append_map(
"rhs");
3023 rhs.serialize(submap, ids);
3025 serialize_annotations(map);
3031 std::shared_ptr<CmpGe>
CmpGe::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3033 auto type = map.at(
"@t").as_string();
3034 if (
type !=
"CmpGe") {
3035 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3037 auto node = std::make_shared<CmpGe>(
3041 node->deserialize_annotations(map);
3057 lhs.find_reachable(map);
3058 rhs.find_reachable(map);
3066 lhs.check_complete(map);
3067 rhs.check_complete(map);
3089 return dynamic_cast<CmpGt*
>(
this);
3097 return dynamic_cast<const CmpGt*
>(
this);
3104 return cqasm::tree::make<CmpGt>(*this);
3111 auto node = cqasm::tree::make<CmpGt>(*this);
3112 node->lhs = this->
lhs.clone();
3113 node->rhs = this->
rhs.clone();
3122 auto rhsc =
dynamic_cast<const CmpGt&
>(
rhs);
3123 if (!this->
lhs.equals(rhsc.lhs))
return false;
3124 if (!this->rhs.
equals(rhsc.rhs))
return false;
3133 auto rhsc =
dynamic_cast<const CmpGt&
>(
rhs);
3134 if (this->
lhs != rhsc.lhs)
return false;
3135 if (this->rhs != rhsc.rhs)
return false;
3143 ::tree::cbor::MapWriter &map,
3144 const ::tree::base::PointerMap &ids
3147 map.append_string(
"@t",
"CmpGt");
3148 auto submap = map.append_map(
"lhs");
3149 lhs.serialize(submap, ids);
3151 submap = map.append_map(
"rhs");
3152 rhs.serialize(submap, ids);
3154 serialize_annotations(map);
3160 std::shared_ptr<CmpGt>
CmpGt::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3162 auto type = map.at(
"@t").as_string();
3163 if (
type !=
"CmpGt") {
3164 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3166 auto node = std::make_shared<CmpGt>(
3170 node->deserialize_annotations(map);
3186 lhs.find_reachable(map);
3187 rhs.find_reachable(map);
3195 lhs.check_complete(map);
3196 rhs.check_complete(map);
3218 return dynamic_cast<CmpLe*
>(
this);
3226 return dynamic_cast<const CmpLe*
>(
this);
3233 return cqasm::tree::make<CmpLe>(*this);
3240 auto node = cqasm::tree::make<CmpLe>(*this);
3241 node->lhs = this->
lhs.clone();
3242 node->rhs = this->
rhs.clone();
3251 auto rhsc =
dynamic_cast<const CmpLe&
>(
rhs);
3252 if (!this->
lhs.equals(rhsc.lhs))
return false;
3253 if (!this->rhs.
equals(rhsc.rhs))
return false;
3262 auto rhsc =
dynamic_cast<const CmpLe&
>(
rhs);
3263 if (this->
lhs != rhsc.lhs)
return false;
3264 if (this->rhs != rhsc.rhs)
return false;
3272 ::tree::cbor::MapWriter &map,
3273 const ::tree::base::PointerMap &ids
3276 map.append_string(
"@t",
"CmpLe");
3277 auto submap = map.append_map(
"lhs");
3278 lhs.serialize(submap, ids);
3280 submap = map.append_map(
"rhs");
3281 rhs.serialize(submap, ids);
3283 serialize_annotations(map);
3289 std::shared_ptr<CmpLe>
CmpLe::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3291 auto type = map.at(
"@t").as_string();
3292 if (
type !=
"CmpLe") {
3293 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3295 auto node = std::make_shared<CmpLe>(
3299 node->deserialize_annotations(map);
3315 lhs.find_reachable(map);
3316 rhs.find_reachable(map);
3324 lhs.check_complete(map);
3325 rhs.check_complete(map);
3347 return dynamic_cast<CmpLt*
>(
this);
3355 return dynamic_cast<const CmpLt*
>(
this);
3362 return cqasm::tree::make<CmpLt>(*this);
3369 auto node = cqasm::tree::make<CmpLt>(*this);
3370 node->lhs = this->
lhs.clone();
3371 node->rhs = this->
rhs.clone();
3380 auto rhsc =
dynamic_cast<const CmpLt&
>(
rhs);
3381 if (!this->
lhs.equals(rhsc.lhs))
return false;
3382 if (!this->rhs.
equals(rhsc.rhs))
return false;
3391 auto rhsc =
dynamic_cast<const CmpLt&
>(
rhs);
3392 if (this->
lhs != rhsc.lhs)
return false;
3393 if (this->rhs != rhsc.rhs)
return false;
3401 ::tree::cbor::MapWriter &map,
3402 const ::tree::base::PointerMap &ids
3405 map.append_string(
"@t",
"CmpLt");
3406 auto submap = map.append_map(
"lhs");
3407 lhs.serialize(submap, ids);
3409 submap = map.append_map(
"rhs");
3410 rhs.serialize(submap, ids);
3412 serialize_annotations(map);
3418 std::shared_ptr<CmpLt>
CmpLt::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3420 auto type = map.at(
"@t").as_string();
3421 if (
type !=
"CmpLt") {
3422 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3424 auto node = std::make_shared<CmpLt>(
3428 node->deserialize_annotations(map);
3444 lhs.find_reachable(map);
3445 rhs.find_reachable(map);
3453 lhs.check_complete(map);
3454 rhs.check_complete(map);
3476 return dynamic_cast<CmpNe*
>(
this);
3484 return dynamic_cast<const CmpNe*
>(
this);
3491 return cqasm::tree::make<CmpNe>(*this);
3498 auto node = cqasm::tree::make<CmpNe>(*this);
3499 node->lhs = this->
lhs.clone();
3500 node->rhs = this->
rhs.clone();
3509 auto rhsc =
dynamic_cast<const CmpNe&
>(
rhs);
3510 if (!this->
lhs.equals(rhsc.lhs))
return false;
3511 if (!this->rhs.
equals(rhsc.rhs))
return false;
3520 auto rhsc =
dynamic_cast<const CmpNe&
>(
rhs);
3521 if (this->
lhs != rhsc.lhs)
return false;
3522 if (this->rhs != rhsc.rhs)
return false;
3530 ::tree::cbor::MapWriter &map,
3531 const ::tree::base::PointerMap &ids
3534 map.append_string(
"@t",
"CmpNe");
3535 auto submap = map.append_map(
"lhs");
3536 lhs.serialize(submap, ids);
3538 submap = map.append_map(
"rhs");
3539 rhs.serialize(submap, ids);
3541 serialize_annotations(map);
3547 std::shared_ptr<CmpNe>
CmpNe::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3549 auto type = map.at(
"@t").as_string();
3550 if (
type !=
"CmpNe") {
3551 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3553 auto node = std::make_shared<CmpNe>(
3557 node->deserialize_annotations(map);
3618 return cqasm::tree::make<ContinueStatement>(*this);
3625 auto node = cqasm::tree::make<ContinueStatement>(*this);
3636 if (!this->
annotations.equals(rhsc.annotations))
return false;
3646 if (this->
annotations != rhsc.annotations)
return false;
3654 ::tree::cbor::MapWriter &map,
3655 const ::tree::base::PointerMap &ids
3658 map.append_string(
"@t",
"ContinueStatement");
3659 auto submap = map.append_map(
"annotations");
3662 serialize_annotations(map);
3670 auto type = map.at(
"@t").as_string();
3671 if (
type !=
"ContinueStatement") {
3672 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3674 auto node = std::make_shared<ContinueStatement>(
3677 node->deserialize_annotations(map);
3693 lhs.find_reachable(map);
3694 rhs.find_reachable(map);
3702 lhs.check_complete(map);
3703 rhs.check_complete(map);
3725 return dynamic_cast<Divide*
>(
this);
3733 return dynamic_cast<const Divide*
>(
this);
3740 return cqasm::tree::make<Divide>(*this);
3747 auto node = cqasm::tree::make<Divide>(*this);
3748 node->lhs = this->
lhs.clone();
3749 node->rhs = this->
rhs.clone();
3758 auto rhsc =
dynamic_cast<const Divide&
>(
rhs);
3759 if (!this->
lhs.equals(rhsc.lhs))
return false;
3760 if (!this->rhs.
equals(rhsc.rhs))
return false;
3769 auto rhsc =
dynamic_cast<const Divide&
>(
rhs);
3770 if (this->
lhs != rhsc.lhs)
return false;
3771 if (this->rhs != rhsc.rhs)
return false;
3779 ::tree::cbor::MapWriter &map,
3780 const ::tree::base::PointerMap &ids
3783 map.append_string(
"@t",
"Divide");
3784 auto submap = map.append_map(
"lhs");
3785 lhs.serialize(submap, ids);
3787 submap = map.append_map(
"rhs");
3788 rhs.serialize(submap, ids);
3790 serialize_annotations(map);
3796 std::shared_ptr<Divide>
Divide::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3798 auto type = map.at(
"@t").as_string();
3799 if (
type !=
"Divide") {
3800 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3802 auto node = std::make_shared<Divide>(
3806 node->deserialize_annotations(map);
3822 throw ::tree::base::NotWellFormed(
"ErroneousExpression error node in tree");
3859 return cqasm::tree::make<ErroneousExpression>(*this);
3866 auto node = cqasm::tree::make<ErroneousExpression>(*this);
3890 ::tree::cbor::MapWriter &map,
3891 const ::tree::base::PointerMap &ids
3894 map.append_string(
"@t",
"ErroneousExpression");
3895 serialize_annotations(map);
3903 auto type = map.at(
"@t").as_string();
3904 if (
type !=
"ErroneousExpression") {
3905 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3907 auto node = std::make_shared<ErroneousExpression>(
3910 node->deserialize_annotations(map);
3919 return dynamic_cast<Root*
>(
this);
3927 return dynamic_cast<const Root*
>(
this);
3933 std::shared_ptr<Root>
Root::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3934 auto type = map.at(
"@t").as_string();
3937 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
3952 throw ::tree::base::NotWellFormed(
"ErroneousProgram error node in tree");
3989 return cqasm::tree::make<ErroneousProgram>(*this);
3996 auto node = cqasm::tree::make<ErroneousProgram>(*this);
4020 ::tree::cbor::MapWriter &map,
4021 const ::tree::base::PointerMap &ids
4024 map.append_string(
"@t",
"ErroneousProgram");
4025 serialize_annotations(map);
4033 auto type = map.at(
"@t").as_string();
4034 if (
type !=
"ErroneousProgram") {
4035 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4037 auto node = std::make_shared<ErroneousProgram>(
4040 node->deserialize_annotations(map);
4064 throw ::tree::base::NotWellFormed(
"ErroneousStatement error node in tree");
4101 return cqasm::tree::make<ErroneousStatement>(*this);
4108 auto node = cqasm::tree::make<ErroneousStatement>(*this);
4119 if (!this->
annotations.equals(rhsc.annotations))
return false;
4129 if (this->
annotations != rhsc.annotations)
return false;
4137 ::tree::cbor::MapWriter &map,
4138 const ::tree::base::PointerMap &ids
4141 map.append_string(
"@t",
"ErroneousStatement");
4142 auto submap = map.append_map(
"annotations");
4145 serialize_annotations(map);
4153 auto type = map.at(
"@t").as_string();
4154 if (
type !=
"ErroneousStatement") {
4155 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4157 auto node = std::make_shared<ErroneousStatement>(
4160 node->deserialize_annotations(map);
4176 items.find_reachable(map);
4184 items.check_complete(map);
4221 return cqasm::tree::make<ExpressionList>(*this);
4228 auto node = cqasm::tree::make<ExpressionList>(*this);
4229 node->items = this->
items.clone();
4239 if (!this->
items.equals(rhsc.items))
return false;
4249 if (this->
items != rhsc.items)
return false;
4257 ::tree::cbor::MapWriter &map,
4258 const ::tree::base::PointerMap &ids
4261 map.append_string(
"@t",
"ExpressionList");
4262 auto submap = map.append_map(
"items");
4263 items.serialize(submap, ids);
4265 serialize_annotations(map);
4273 auto type = map.at(
"@t").as_string();
4274 if (
type !=
"ExpressionList") {
4275 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4277 auto node = std::make_shared<ExpressionList>(
4280 node->deserialize_annotations(map);
4339 return cqasm::tree::make<FloatLiteral>(*this);
4346 auto node = cqasm::tree::make<FloatLiteral>(*this);
4356 if (this->
value != rhsc.value)
return false;
4366 if (this->
value != rhsc.value)
return false;
4374 ::tree::cbor::MapWriter &map,
4375 const ::tree::base::PointerMap &ids
4378 map.append_string(
"@t",
"FloatLiteral");
4379 auto submap = map.append_map(
"value");
4380 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Real>(
value, submap);
4382 serialize_annotations(map);
4390 auto type = map.at(
"@t").as_string();
4391 if (
type !=
"FloatLiteral") {
4392 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4394 auto node = std::make_shared<FloatLiteral>(
4395 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Real>(map.at(
"value").as_map())
4397 node->deserialize_annotations(map);
4405 :
Structured(annotations), initialize(initialize), condition(condition), update(update), body(body)
4415 update.find_reachable(map);
4416 body.find_reachable(map);
4427 update.check_complete(map);
4428 body.check_complete(map);
4451 return dynamic_cast<ForLoop*
>(
this);
4459 return dynamic_cast<const ForLoop*
>(
this);
4466 return cqasm::tree::make<ForLoop>(*this);
4473 auto node = cqasm::tree::make<ForLoop>(*this);
4475 node->condition = this->
condition.clone();
4476 node->update = this->
update.clone();
4477 node->body = this->
body.clone();
4487 auto rhsc =
dynamic_cast<const ForLoop&
>(rhs);
4488 if (!this->
initialize.equals(rhsc.initialize))
return false;
4489 if (!this->
condition.equals(rhsc.condition))
return false;
4490 if (!this->
update.equals(rhsc.update))
return false;
4491 if (!this->
body.equals(rhsc.body))
return false;
4492 if (!this->
annotations.equals(rhsc.annotations))
return false;
4501 auto rhsc =
dynamic_cast<const ForLoop&
>(rhs);
4502 if (this->
initialize != rhsc.initialize)
return false;
4503 if (this->
condition != rhsc.condition)
return false;
4504 if (this->
update != rhsc.update)
return false;
4505 if (this->
body != rhsc.body)
return false;
4506 if (this->
annotations != rhsc.annotations)
return false;
4514 ::tree::cbor::MapWriter &map,
4515 const ::tree::base::PointerMap &ids
4518 map.append_string(
"@t",
"ForLoop");
4519 auto submap = map.append_map(
"initialize");
4522 submap = map.append_map(
"condition");
4525 submap = map.append_map(
"update");
4526 update.serialize(submap, ids);
4528 submap = map.append_map(
"body");
4529 body.serialize(submap, ids);
4531 submap = map.append_map(
"annotations");
4534 serialize_annotations(map);
4540 std::shared_ptr<ForLoop>
ForLoop::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4542 auto type = map.at(
"@t").as_string();
4543 if (
type !=
"ForLoop") {
4544 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4546 auto node = std::make_shared<ForLoop>(
4553 node->deserialize_annotations(map);
4561 :
Structured(annotations), lhs(lhs), frm(frm), to(to), body(body)
4569 lhs.find_reachable(map);
4570 frm.find_reachable(map);
4571 to.find_reachable(map);
4572 body.find_reachable(map);
4581 lhs.check_complete(map);
4582 frm.check_complete(map);
4583 to.check_complete(map);
4584 body.check_complete(map);
4622 return cqasm::tree::make<ForeachLoop>(*this);
4629 auto node = cqasm::tree::make<ForeachLoop>(*this);
4630 node->lhs = this->
lhs.clone();
4631 node->frm = this->
frm.clone();
4632 node->to = this->
to.clone();
4633 node->body = this->
body.clone();
4643 auto rhsc =
dynamic_cast<const ForeachLoop&
>(rhs);
4644 if (!this->
lhs.equals(rhsc.lhs))
return false;
4645 if (!this->
frm.equals(rhsc.frm))
return false;
4646 if (!this->
to.equals(rhsc.to))
return false;
4647 if (!this->
body.equals(rhsc.body))
return false;
4648 if (!this->
annotations.equals(rhsc.annotations))
return false;
4657 auto rhsc =
dynamic_cast<const ForeachLoop&
>(rhs);
4658 if (this->
lhs != rhsc.lhs)
return false;
4659 if (this->
frm != rhsc.frm)
return false;
4660 if (this->
to != rhsc.to)
return false;
4661 if (this->
body != rhsc.body)
return false;
4662 if (this->
annotations != rhsc.annotations)
return false;
4670 ::tree::cbor::MapWriter &map,
4671 const ::tree::base::PointerMap &ids
4674 map.append_string(
"@t",
"ForeachLoop");
4675 auto submap = map.append_map(
"lhs");
4676 lhs.serialize(submap, ids);
4678 submap = map.append_map(
"frm");
4679 frm.serialize(submap, ids);
4681 submap = map.append_map(
"to");
4682 to.serialize(submap, ids);
4684 submap = map.append_map(
"body");
4685 body.serialize(submap, ids);
4687 submap = map.append_map(
"annotations");
4690 serialize_annotations(map);
4698 auto type = map.at(
"@t").as_string();
4699 if (
type !=
"ForeachLoop") {
4700 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4702 auto node = std::make_shared<ForeachLoop>(
4709 node->deserialize_annotations(map);
4717 :
Expression(), name(name), arguments(arguments)
4725 name.find_reachable(map);
4734 name.check_complete(map);
4772 return cqasm::tree::make<FunctionCall>(*this);
4779 auto node = cqasm::tree::make<FunctionCall>(*this);
4780 node->name = this->
name.clone();
4781 node->arguments = this->
arguments.clone();
4791 if (!this->
name.equals(rhsc.name))
return false;
4792 if (!this->
arguments.equals(rhsc.arguments))
return false;
4802 if (this->
name != rhsc.name)
return false;
4803 if (this->
arguments != rhsc.arguments)
return false;
4811 ::tree::cbor::MapWriter &map,
4812 const ::tree::base::PointerMap &ids
4815 map.append_string(
"@t",
"FunctionCall");
4816 auto submap = map.append_map(
"name");
4817 name.serialize(submap, ids);
4819 submap = map.append_map(
"arguments");
4822 serialize_annotations(map);
4830 auto type = map.at(
"@t").as_string();
4831 if (
type !=
"FunctionCall") {
4832 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4834 auto node = std::make_shared<FunctionCall>(
4838 node->deserialize_annotations(map);
4890 return dynamic_cast<const Identifier*
>(
this);
4897 return cqasm::tree::make<Identifier>(*this);
4904 auto node = cqasm::tree::make<Identifier>(*this);
4913 auto rhsc =
dynamic_cast<const Identifier&
>(rhs);
4914 if (this->
name != rhsc.name)
return false;
4923 auto rhsc =
dynamic_cast<const Identifier&
>(rhs);
4924 if (this->
name != rhsc.name)
return false;
4932 ::tree::cbor::MapWriter &map,
4933 const ::tree::base::PointerMap &ids
4936 map.append_string(
"@t",
"Identifier");
4937 auto submap = map.append_map(
"name");
4938 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Str>(
name, submap);
4940 serialize_annotations(map);
4948 auto type = map.at(
"@t").as_string();
4949 if (
type !=
"Identifier") {
4950 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
4952 auto node = std::make_shared<Identifier>(
4953 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at(
"name").as_map())
4955 node->deserialize_annotations(map);
4963 :
Structured(annotations), branches(branches), otherwise(otherwise)
5005 return dynamic_cast<IfElse*
>(
this);
5013 return dynamic_cast<const IfElse*
>(
this);
5020 return cqasm::tree::make<IfElse>(*this);
5027 auto node = cqasm::tree::make<IfElse>(*this);
5028 node->branches = this->
branches.clone();
5029 node->otherwise = this->
otherwise.clone();
5039 auto rhsc =
dynamic_cast<const IfElse&
>(rhs);
5040 if (!this->
branches.equals(rhsc.branches))
return false;
5041 if (!this->
otherwise.equals(rhsc.otherwise))
return false;
5042 if (!this->
annotations.equals(rhsc.annotations))
return false;
5051 auto rhsc =
dynamic_cast<const IfElse&
>(rhs);
5052 if (this->
branches != rhsc.branches)
return false;
5053 if (this->
otherwise != rhsc.otherwise)
return false;
5054 if (this->
annotations != rhsc.annotations)
return false;
5062 ::tree::cbor::MapWriter &map,
5063 const ::tree::base::PointerMap &ids
5066 map.append_string(
"@t",
"IfElse");
5067 auto submap = map.append_map(
"branches");
5070 submap = map.append_map(
"otherwise");
5073 submap = map.append_map(
"annotations");
5076 serialize_annotations(map);
5082 std::shared_ptr<IfElse>
IfElse::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5084 auto type = map.at(
"@t").as_string();
5085 if (
type !=
"IfElse") {
5086 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5088 auto node = std::make_shared<IfElse>(
5093 node->deserialize_annotations(map);
5101 : condition(condition), body(body)
5110 body.find_reachable(map);
5119 body.check_complete(map);
5156 return cqasm::tree::make<IfElseBranch>(*this);
5163 auto node = cqasm::tree::make<IfElseBranch>(*this);
5164 node->condition = this->
condition.clone();
5165 node->body = this->
body.clone();
5175 if (!this->
condition.equals(rhsc.condition))
return false;
5176 if (!this->
body.equals(rhsc.body))
return false;
5186 if (this->
condition != rhsc.condition)
return false;
5187 if (this->
body != rhsc.body)
return false;
5195 ::tree::cbor::MapWriter &map,
5196 const ::tree::base::PointerMap &ids
5199 map.append_string(
"@t",
"IfElseBranch");
5200 auto submap = map.append_map(
"condition");
5203 submap = map.append_map(
"body");
5204 body.serialize(submap, ids);
5206 serialize_annotations(map);
5214 auto type = map.at(
"@t").as_string();
5215 if (
type !=
"IfElseBranch") {
5216 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5218 auto node = std::make_shared<IfElseBranch>(
5222 node->deserialize_annotations(map);
5238 expr.find_reachable(map);
5247 expr.check_complete(map);
5270 return dynamic_cast<Index*
>(
this);
5278 return dynamic_cast<const Index*
>(
this);
5285 return cqasm::tree::make<Index>(*this);
5292 auto node = cqasm::tree::make<Index>(*this);
5293 node->expr = this->
expr.clone();
5294 node->indices = this->
indices.clone();
5303 auto rhsc =
dynamic_cast<const Index&
>(rhs);
5304 if (!this->
expr.equals(rhsc.expr))
return false;
5305 if (!this->
indices.equals(rhsc.indices))
return false;
5314 auto rhsc =
dynamic_cast<const Index&
>(rhs);
5315 if (this->
expr != rhsc.expr)
return false;
5316 if (this->
indices != rhsc.indices)
return false;
5324 ::tree::cbor::MapWriter &map,
5325 const ::tree::base::PointerMap &ids
5328 map.append_string(
"@t",
"Index");
5329 auto submap = map.append_map(
"expr");
5330 expr.serialize(submap, ids);
5332 submap = map.append_map(
"indices");
5333 indices.serialize(submap, ids);
5335 serialize_annotations(map);
5341 std::shared_ptr<Index>
Index::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5343 auto type = map.at(
"@t").as_string();
5344 if (
type !=
"Index") {
5345 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5347 auto node = std::make_shared<Index>(
5351 node->deserialize_annotations(map);
5368 return dynamic_cast<const IndexEntry*
>(
this);
5375 auto type = map.at(
"@t").as_string();
5378 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5393 index.find_reachable(map);
5401 index.check_complete(map);
5431 return dynamic_cast<const IndexItem*
>(
this);
5438 return cqasm::tree::make<IndexItem>(*this);
5445 auto node = cqasm::tree::make<IndexItem>(*this);
5446 node->index = this->
index.clone();
5455 auto rhsc =
dynamic_cast<const IndexItem&
>(rhs);
5456 if (!this->
index.equals(rhsc.index))
return false;
5465 auto rhsc =
dynamic_cast<const IndexItem&
>(rhs);
5466 if (this->
index != rhsc.index)
return false;
5474 ::tree::cbor::MapWriter &map,
5475 const ::tree::base::PointerMap &ids
5478 map.append_string(
"@t",
"IndexItem");
5479 auto submap = map.append_map(
"index");
5480 index.serialize(submap, ids);
5482 serialize_annotations(map);
5490 auto type = map.at(
"@t").as_string();
5491 if (
type !=
"IndexItem") {
5492 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5494 auto node = std::make_shared<IndexItem>(
5497 node->deserialize_annotations(map);
5513 items.find_reachable(map);
5521 items.check_complete(map);
5551 return dynamic_cast<const IndexList*
>(
this);
5558 return cqasm::tree::make<IndexList>(*this);
5565 auto node = cqasm::tree::make<IndexList>(*this);
5566 node->items = this->
items.clone();
5575 auto rhsc =
dynamic_cast<const IndexList&
>(rhs);
5576 if (!this->
items.equals(rhsc.items))
return false;
5585 auto rhsc =
dynamic_cast<const IndexList&
>(rhs);
5586 if (this->
items != rhsc.items)
return false;
5594 ::tree::cbor::MapWriter &map,
5595 const ::tree::base::PointerMap &ids
5598 map.append_string(
"@t",
"IndexList");
5599 auto submap = map.append_map(
"items");
5600 items.serialize(submap, ids);
5602 serialize_annotations(map);
5610 auto type = map.at(
"@t").as_string();
5611 if (
type !=
"IndexList") {
5612 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5614 auto node = std::make_shared<IndexList>(
5617 node->deserialize_annotations(map);
5633 first.find_reachable(map);
5634 last.find_reachable(map);
5642 first.check_complete(map);
5643 last.check_complete(map);
5673 return dynamic_cast<const IndexRange*
>(
this);
5680 return cqasm::tree::make<IndexRange>(*this);
5687 auto node = cqasm::tree::make<IndexRange>(*this);
5688 node->first = this->
first.clone();
5689 node->last = this->
last.clone();
5698 auto rhsc =
dynamic_cast<const IndexRange&
>(rhs);
5699 if (!this->
first.equals(rhsc.first))
return false;
5700 if (!this->
last.equals(rhsc.last))
return false;
5709 auto rhsc =
dynamic_cast<const IndexRange&
>(rhs);
5710 if (this->
first != rhsc.first)
return false;
5711 if (this->
last != rhsc.last)
return false;
5719 ::tree::cbor::MapWriter &map,
5720 const ::tree::base::PointerMap &ids
5723 map.append_string(
"@t",
"IndexRange");
5724 auto submap = map.append_map(
"first");
5725 first.serialize(submap, ids);
5727 submap = map.append_map(
"last");
5728 last.serialize(submap, ids);
5730 serialize_annotations(map);
5738 auto type = map.at(
"@t").as_string();
5739 if (
type !=
"IndexRange") {
5740 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5742 auto node = std::make_shared<IndexRange>(
5746 node->deserialize_annotations(map);
5754 :
Annotated(annotations), name(name), condition(condition), operands(operands)
5762 name.find_reachable(map);
5773 name.check_complete(map);
5813 return cqasm::tree::make<Instruction>(*this);
5820 auto node = cqasm::tree::make<Instruction>(*this);
5821 node->name = this->
name.clone();
5822 node->condition = this->
condition.clone();
5823 node->operands = this->
operands.clone();
5833 auto rhsc =
dynamic_cast<const Instruction&
>(rhs);
5834 if (!this->
name.equals(rhsc.name))
return false;
5835 if (!this->
condition.equals(rhsc.condition))
return false;
5836 if (!this->
operands.equals(rhsc.operands))
return false;
5837 if (!this->
annotations.equals(rhsc.annotations))
return false;
5846 auto rhsc =
dynamic_cast<const Instruction&
>(rhs);
5847 if (this->
name != rhsc.name)
return false;
5848 if (this->
condition != rhsc.condition)
return false;
5849 if (this->
operands != rhsc.operands)
return false;
5850 if (this->
annotations != rhsc.annotations)
return false;
5858 ::tree::cbor::MapWriter &map,
5859 const ::tree::base::PointerMap &ids
5862 map.append_string(
"@t",
"Instruction");
5863 auto submap = map.append_map(
"name");
5864 name.serialize(submap, ids);
5866 submap = map.append_map(
"condition");
5869 submap = map.append_map(
"operands");
5872 submap = map.append_map(
"annotations");
5875 serialize_annotations(map);
5883 auto type = map.at(
"@t").as_string();
5884 if (
type !=
"Instruction") {
5885 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
5887 auto node = std::make_shared<Instruction>(
5893 node->deserialize_annotations(map);
5909 lhs.find_reachable(map);
5910 rhs.find_reachable(map);
5918 lhs.check_complete(map);
5919 rhs.check_complete(map);
5949 return dynamic_cast<const IntDivide*
>(
this);
5956 return cqasm::tree::make<IntDivide>(*this);
5963 auto node = cqasm::tree::make<IntDivide>(*this);
5964 node->lhs = this->
lhs.clone();
5965 node->rhs = this->
rhs.clone();
5975 if (!this->
lhs.equals(rhsc.lhs))
return false;
5976 if (!this->rhs.
equals(rhsc.rhs))
return false;
5986 if (this->
lhs != rhsc.lhs)
return false;
5987 if (this->rhs != rhsc.rhs)
return false;
5995 ::tree::cbor::MapWriter &map,
5996 const ::tree::base::PointerMap &ids
5999 map.append_string(
"@t",
"IntDivide");
6000 auto submap = map.append_map(
"lhs");
6001 lhs.serialize(submap, ids);
6003 submap = map.append_map(
"rhs");
6004 rhs.serialize(submap, ids);
6006 serialize_annotations(map);
6014 auto type = map.at(
"@t").as_string();
6015 if (
type !=
"IntDivide") {
6016 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6018 auto node = std::make_shared<IntDivide>(
6022 node->deserialize_annotations(map);
6081 return cqasm::tree::make<IntegerLiteral>(*this);
6088 auto node = cqasm::tree::make<IntegerLiteral>(*this);
6098 if (this->
value != rhsc.value)
return false;
6108 if (this->
value != rhsc.value)
return false;
6116 ::tree::cbor::MapWriter &map,
6117 const ::tree::base::PointerMap &ids
6120 map.append_string(
"@t",
"IntegerLiteral");
6121 auto submap = map.append_map(
"value");
6122 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Int>(
value, submap);
6124 serialize_annotations(map);
6132 auto type = map.at(
"@t").as_string();
6133 if (
type !=
"IntegerLiteral") {
6134 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6136 auto node = std::make_shared<IntegerLiteral>(
6137 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Int>(map.at(
"value").as_map())
6139 node->deserialize_annotations(map);
6198 return cqasm::tree::make<JsonLiteral>(*this);
6205 auto node = cqasm::tree::make<JsonLiteral>(*this);
6214 auto rhsc =
dynamic_cast<const JsonLiteral&
>(rhs);
6215 if (this->
value != rhsc.value)
return false;
6224 auto rhsc =
dynamic_cast<const JsonLiteral&
>(rhs);
6225 if (this->
value != rhsc.value)
return false;
6233 ::tree::cbor::MapWriter &map,
6234 const ::tree::base::PointerMap &ids
6237 map.append_string(
"@t",
"JsonLiteral");
6238 auto submap = map.append_map(
"value");
6239 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Str>(
value, submap);
6241 serialize_annotations(map);
6249 auto type = map.at(
"@t").as_string();
6250 if (
type !=
"JsonLiteral") {
6251 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6253 auto node = std::make_shared<JsonLiteral>(
6254 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at(
"value").as_map())
6256 node->deserialize_annotations(map);
6280 return dynamic_cast<const LogicalOp*
>(
this);
6287 auto type = map.at(
"@t").as_string();
6291 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6306 lhs.find_reachable(map);
6307 rhs.find_reachable(map);
6315 lhs.check_complete(map);
6316 rhs.check_complete(map);
6346 return dynamic_cast<const LogicalAnd*
>(
this);
6353 return cqasm::tree::make<LogicalAnd>(*this);
6360 auto node = cqasm::tree::make<LogicalAnd>(*this);
6361 node->lhs = this->
lhs.clone();
6362 node->rhs = this->
rhs.clone();
6372 if (!this->
lhs.equals(rhsc.lhs))
return false;
6373 if (!this->rhs.
equals(rhsc.rhs))
return false;
6383 if (this->
lhs != rhsc.lhs)
return false;
6384 if (this->rhs != rhsc.rhs)
return false;
6392 ::tree::cbor::MapWriter &map,
6393 const ::tree::base::PointerMap &ids
6396 map.append_string(
"@t",
"LogicalAnd");
6397 auto submap = map.append_map(
"lhs");
6398 lhs.serialize(submap, ids);
6400 submap = map.append_map(
"rhs");
6401 rhs.serialize(submap, ids);
6403 serialize_annotations(map);
6411 auto type = map.at(
"@t").as_string();
6412 if (
type !=
"LogicalAnd") {
6413 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6415 auto node = std::make_shared<LogicalAnd>(
6419 node->deserialize_annotations(map);
6435 expr.find_reachable(map);
6443 expr.check_complete(map);
6473 return dynamic_cast<const LogicalNot*
>(
this);
6480 return cqasm::tree::make<LogicalNot>(*this);
6487 auto node = cqasm::tree::make<LogicalNot>(*this);
6488 node->expr = this->
expr.clone();
6497 auto rhsc =
dynamic_cast<const LogicalNot&
>(rhs);
6498 if (!this->
expr.equals(rhsc.expr))
return false;
6507 auto rhsc =
dynamic_cast<const LogicalNot&
>(rhs);
6508 if (this->
expr != rhsc.expr)
return false;
6516 ::tree::cbor::MapWriter &map,
6517 const ::tree::base::PointerMap &ids
6520 map.append_string(
"@t",
"LogicalNot");
6521 auto submap = map.append_map(
"expr");
6522 expr.serialize(submap, ids);
6524 serialize_annotations(map);
6532 auto type = map.at(
"@t").as_string();
6533 if (
type !=
"LogicalNot") {
6534 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6536 auto node = std::make_shared<LogicalNot>(
6539 node->deserialize_annotations(map);
6555 lhs.find_reachable(map);
6556 rhs.find_reachable(map);
6564 lhs.check_complete(map);
6565 rhs.check_complete(map);
6595 return dynamic_cast<const LogicalOr*
>(
this);
6602 return cqasm::tree::make<LogicalOr>(*this);
6609 auto node = cqasm::tree::make<LogicalOr>(*this);
6610 node->lhs = this->
lhs.clone();
6611 node->rhs = this->
rhs.clone();
6621 if (!this->
lhs.equals(rhsc.lhs))
return false;
6622 if (!this->rhs.
equals(rhsc.rhs))
return false;
6632 if (this->
lhs != rhsc.lhs)
return false;
6633 if (this->rhs != rhsc.rhs)
return false;
6641 ::tree::cbor::MapWriter &map,
6642 const ::tree::base::PointerMap &ids
6645 map.append_string(
"@t",
"LogicalOr");
6646 auto submap = map.append_map(
"lhs");
6647 lhs.serialize(submap, ids);
6649 submap = map.append_map(
"rhs");
6650 rhs.serialize(submap, ids);
6652 serialize_annotations(map);
6660 auto type = map.at(
"@t").as_string();
6661 if (
type !=
"LogicalOr") {
6662 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6664 auto node = std::make_shared<LogicalOr>(
6668 node->deserialize_annotations(map);
6684 lhs.find_reachable(map);
6685 rhs.find_reachable(map);
6693 lhs.check_complete(map);
6694 rhs.check_complete(map);
6724 return dynamic_cast<const LogicalXor*
>(
this);
6731 return cqasm::tree::make<LogicalXor>(*this);
6738 auto node = cqasm::tree::make<LogicalXor>(*this);
6739 node->lhs = this->
lhs.clone();
6740 node->rhs = this->
rhs.clone();
6750 if (!this->
lhs.equals(rhsc.lhs))
return false;
6751 if (!this->rhs.
equals(rhsc.rhs))
return false;
6761 if (this->
lhs != rhsc.lhs)
return false;
6762 if (this->rhs != rhsc.rhs)
return false;
6770 ::tree::cbor::MapWriter &map,
6771 const ::tree::base::PointerMap &ids
6774 map.append_string(
"@t",
"LogicalXor");
6775 auto submap = map.append_map(
"lhs");
6776 lhs.serialize(submap, ids);
6778 submap = map.append_map(
"rhs");
6779 rhs.serialize(submap, ids);
6781 serialize_annotations(map);
6789 auto type = map.at(
"@t").as_string();
6790 if (
type !=
"LogicalXor") {
6791 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6793 auto node = std::make_shared<LogicalXor>(
6797 node->deserialize_annotations(map);
6805 :
Statement(annotations), alias(alias), expr(expr)
6813 alias.find_reachable(map);
6814 expr.find_reachable(map);
6823 alias.check_complete(map);
6824 expr.check_complete(map);
6847 return dynamic_cast<Mapping*
>(
this);
6855 return dynamic_cast<const Mapping*
>(
this);
6862 return cqasm::tree::make<Mapping>(*this);
6869 auto node = cqasm::tree::make<Mapping>(*this);
6870 node->alias = this->
alias.clone();
6871 node->expr = this->
expr.clone();
6881 auto rhsc =
dynamic_cast<const Mapping&
>(rhs);
6882 if (!this->
alias.equals(rhsc.alias))
return false;
6883 if (!this->
expr.equals(rhsc.expr))
return false;
6884 if (!this->
annotations.equals(rhsc.annotations))
return false;
6893 auto rhsc =
dynamic_cast<const Mapping&
>(rhs);
6894 if (this->
alias != rhsc.alias)
return false;
6895 if (this->
expr != rhsc.expr)
return false;
6896 if (this->
annotations != rhsc.annotations)
return false;
6904 ::tree::cbor::MapWriter &map,
6905 const ::tree::base::PointerMap &ids
6908 map.append_string(
"@t",
"Mapping");
6909 auto submap = map.append_map(
"alias");
6910 alias.serialize(submap, ids);
6912 submap = map.append_map(
"expr");
6913 expr.serialize(submap, ids);
6915 submap = map.append_map(
"annotations");
6918 serialize_annotations(map);
6924 std::shared_ptr<Mapping>
Mapping::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6926 auto type = map.at(
"@t").as_string();
6927 if (
type !=
"Mapping") {
6928 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
6930 auto node = std::make_shared<Mapping>(
6935 node->deserialize_annotations(map);
6951 rows.find_reachable(map);
6959 rows.check_complete(map);
6996 return cqasm::tree::make<MatrixLiteral>(*this);
7003 auto node = cqasm::tree::make<MatrixLiteral>(*this);
7004 node->rows = this->
rows.clone();
7014 if (!this->
rows.equals(rhsc.rows))
return false;
7024 if (this->
rows != rhsc.rows)
return false;
7032 ::tree::cbor::MapWriter &map,
7033 const ::tree::base::PointerMap &ids
7036 map.append_string(
"@t",
"MatrixLiteral");
7037 auto submap = map.append_map(
"rows");
7038 rows.serialize(submap, ids);
7040 serialize_annotations(map);
7048 auto type = map.at(
"@t").as_string();
7049 if (
type !=
"MatrixLiteral") {
7050 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7052 auto node = std::make_shared<MatrixLiteral>(
7055 node->deserialize_annotations(map);
7071 lhs.find_reachable(map);
7072 rhs.find_reachable(map);
7080 lhs.check_complete(map);
7081 rhs.check_complete(map);
7103 return dynamic_cast<Modulo*
>(
this);
7111 return dynamic_cast<const Modulo*
>(
this);
7118 return cqasm::tree::make<Modulo>(*this);
7125 auto node = cqasm::tree::make<Modulo>(*this);
7126 node->lhs = this->
lhs.clone();
7127 node->rhs = this->
rhs.clone();
7136 auto rhsc =
dynamic_cast<const Modulo&
>(
rhs);
7137 if (!this->
lhs.equals(rhsc.lhs))
return false;
7138 if (!this->rhs.
equals(rhsc.rhs))
return false;
7147 auto rhsc =
dynamic_cast<const Modulo&
>(
rhs);
7148 if (this->
lhs != rhsc.lhs)
return false;
7149 if (this->rhs != rhsc.rhs)
return false;
7157 ::tree::cbor::MapWriter &map,
7158 const ::tree::base::PointerMap &ids
7161 map.append_string(
"@t",
"Modulo");
7162 auto submap = map.append_map(
"lhs");
7163 lhs.serialize(submap, ids);
7165 submap = map.append_map(
"rhs");
7166 rhs.serialize(submap, ids);
7168 serialize_annotations(map);
7174 std::shared_ptr<Modulo>
Modulo::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7176 auto type = map.at(
"@t").as_string();
7177 if (
type !=
"Modulo") {
7178 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7180 auto node = std::make_shared<Modulo>(
7184 node->deserialize_annotations(map);
7200 lhs.find_reachable(map);
7201 rhs.find_reachable(map);
7209 lhs.check_complete(map);
7210 rhs.check_complete(map);
7232 return dynamic_cast<Multiply*
>(
this);
7240 return dynamic_cast<const Multiply*
>(
this);
7247 return cqasm::tree::make<Multiply>(*this);
7254 auto node = cqasm::tree::make<Multiply>(*this);
7255 node->lhs = this->
lhs.clone();
7256 node->rhs = this->
rhs.clone();
7266 if (!this->
lhs.equals(rhsc.lhs))
return false;
7267 if (!this->rhs.
equals(rhsc.rhs))
return false;
7277 if (this->
lhs != rhsc.lhs)
return false;
7278 if (this->rhs != rhsc.rhs)
return false;
7286 ::tree::cbor::MapWriter &map,
7287 const ::tree::base::PointerMap &ids
7290 map.append_string(
"@t",
"Multiply");
7291 auto submap = map.append_map(
"lhs");
7292 lhs.serialize(submap, ids);
7294 submap = map.append_map(
"rhs");
7295 rhs.serialize(submap, ids);
7297 serialize_annotations(map);
7305 auto type = map.at(
"@t").as_string();
7306 if (
type !=
"Multiply") {
7307 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7309 auto node = std::make_shared<Multiply>(
7313 node->deserialize_annotations(map);
7329 expr.find_reachable(map);
7337 expr.check_complete(map);
7359 return dynamic_cast<Negate*
>(
this);
7367 return dynamic_cast<const Negate*
>(
this);
7374 return cqasm::tree::make<Negate>(*this);
7381 auto node = cqasm::tree::make<Negate>(*this);
7382 node->expr = this->
expr.clone();
7391 auto rhsc =
dynamic_cast<const Negate&
>(rhs);
7392 if (!this->
expr.equals(rhsc.expr))
return false;
7401 auto rhsc =
dynamic_cast<const Negate&
>(rhs);
7402 if (this->
expr != rhsc.expr)
return false;
7410 ::tree::cbor::MapWriter &map,
7411 const ::tree::base::PointerMap &ids
7414 map.append_string(
"@t",
"Negate");
7415 auto submap = map.append_map(
"expr");
7416 expr.serialize(submap, ids);
7418 serialize_annotations(map);
7424 std::shared_ptr<Negate>
Negate::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7426 auto type = map.at(
"@t").as_string();
7427 if (
type !=
"Negate") {
7428 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7430 auto node = std::make_shared<Negate>(
7433 node->deserialize_annotations(map);
7449 lhs.find_reachable(map);
7450 rhs.find_reachable(map);
7458 lhs.check_complete(map);
7459 rhs.check_complete(map);
7481 return dynamic_cast<Power*
>(
this);
7489 return dynamic_cast<const Power*
>(
this);
7496 return cqasm::tree::make<Power>(*this);
7503 auto node = cqasm::tree::make<Power>(*this);
7504 node->lhs = this->
lhs.clone();
7505 node->rhs = this->
rhs.clone();
7514 auto rhsc =
dynamic_cast<const Power&
>(
rhs);
7515 if (!this->
lhs.equals(rhsc.lhs))
return false;
7516 if (!this->rhs.
equals(rhsc.rhs))
return false;
7525 auto rhsc =
dynamic_cast<const Power&
>(
rhs);
7526 if (this->
lhs != rhsc.lhs)
return false;
7527 if (this->rhs != rhsc.rhs)
return false;
7535 ::tree::cbor::MapWriter &map,
7536 const ::tree::base::PointerMap &ids
7539 map.append_string(
"@t",
"Power");
7540 auto submap = map.append_map(
"lhs");
7541 lhs.serialize(submap, ids);
7543 submap = map.append_map(
"rhs");
7544 rhs.serialize(submap, ids);
7546 serialize_annotations(map);
7552 std::shared_ptr<Power>
Power::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7554 auto type = map.at(
"@t").as_string();
7555 if (
type !=
"Power") {
7556 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7558 auto node = std::make_shared<Power>(
7562 node->deserialize_annotations(map);
7570 :
Root(), version(version), num_qubits(num_qubits), statements(statements)
7612 return dynamic_cast<Program*
>(
this);
7620 return dynamic_cast<const Program*
>(
this);
7627 return cqasm::tree::make<Program>(*this);
7634 auto node = cqasm::tree::make<Program>(*this);
7635 node->version = this->
version.clone();
7646 auto rhsc =
dynamic_cast<const Program&
>(rhs);
7647 if (!this->
version.equals(rhsc.version))
return false;
7648 if (!this->
num_qubits.equals(rhsc.num_qubits))
return false;
7649 if (!this->
statements.equals(rhsc.statements))
return false;
7658 auto rhsc =
dynamic_cast<const Program&
>(rhs);
7659 if (this->
version != rhsc.version)
return false;
7660 if (this->
num_qubits != rhsc.num_qubits)
return false;
7661 if (this->
statements != rhsc.statements)
return false;
7669 ::tree::cbor::MapWriter &map,
7670 const ::tree::base::PointerMap &ids
7673 map.append_string(
"@t",
"Program");
7674 auto submap = map.append_map(
"version");
7675 version.serialize(submap, ids);
7677 submap = map.append_map(
"num_qubits");
7680 submap = map.append_map(
"statements");
7683 serialize_annotations(map);
7689 std::shared_ptr<Program>
Program::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7691 auto type = map.at(
"@t").as_string();
7692 if (
type !=
"Program") {
7693 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7695 auto node = std::make_shared<Program>(
7700 node->deserialize_annotations(map);
7708 :
Structured(annotations), body(body), condition(condition)
7716 body.find_reachable(map);
7726 body.check_complete(map);
7765 return cqasm::tree::make<RepeatUntilLoop>(*this);
7772 auto node = cqasm::tree::make<RepeatUntilLoop>(*this);
7773 node->body = this->
body.clone();
7774 node->condition = this->
condition.clone();
7785 if (!this->
body.equals(rhsc.body))
return false;
7786 if (!this->
condition.equals(rhsc.condition))
return false;
7787 if (!this->
annotations.equals(rhsc.annotations))
return false;
7797 if (this->
body != rhsc.body)
return false;
7798 if (this->
condition != rhsc.condition)
return false;
7799 if (this->
annotations != rhsc.annotations)
return false;
7807 ::tree::cbor::MapWriter &map,
7808 const ::tree::base::PointerMap &ids
7811 map.append_string(
"@t",
"RepeatUntilLoop");
7812 auto submap = map.append_map(
"body");
7813 body.serialize(submap, ids);
7815 submap = map.append_map(
"condition");
7818 submap = map.append_map(
"annotations");
7821 serialize_annotations(map);
7829 auto type = map.at(
"@t").as_string();
7830 if (
type !=
"RepeatUntilLoop") {
7831 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7833 auto node = std::make_shared<RepeatUntilLoop>(
7838 node->deserialize_annotations(map);
7854 return dynamic_cast<ShiftOp*
>(
this);
7862 return dynamic_cast<const ShiftOp*
>(
this);
7868 std::shared_ptr<ShiftOp>
ShiftOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7869 auto type = map.at(
"@t").as_string();
7873 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7888 lhs.find_reachable(map);
7889 rhs.find_reachable(map);
7897 lhs.check_complete(map);
7898 rhs.check_complete(map);
7928 return dynamic_cast<const ShiftLeft*
>(
this);
7935 return cqasm::tree::make<ShiftLeft>(*this);
7942 auto node = cqasm::tree::make<ShiftLeft>(*this);
7943 node->lhs = this->
lhs.clone();
7944 node->rhs = this->
rhs.clone();
7954 if (!this->
lhs.equals(rhsc.lhs))
return false;
7955 if (!this->rhs.
equals(rhsc.rhs))
return false;
7965 if (this->
lhs != rhsc.lhs)
return false;
7966 if (this->rhs != rhsc.rhs)
return false;
7974 ::tree::cbor::MapWriter &map,
7975 const ::tree::base::PointerMap &ids
7978 map.append_string(
"@t",
"ShiftLeft");
7979 auto submap = map.append_map(
"lhs");
7980 lhs.serialize(submap, ids);
7982 submap = map.append_map(
"rhs");
7983 rhs.serialize(submap, ids);
7985 serialize_annotations(map);
7993 auto type = map.at(
"@t").as_string();
7994 if (
type !=
"ShiftLeft") {
7995 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
7997 auto node = std::make_shared<ShiftLeft>(
8001 node->deserialize_annotations(map);
8017 lhs.find_reachable(map);
8018 rhs.find_reachable(map);
8026 lhs.check_complete(map);
8027 rhs.check_complete(map);
8064 return cqasm::tree::make<ShiftRightArith>(*this);
8071 auto node = cqasm::tree::make<ShiftRightArith>(*this);
8072 node->lhs = this->
lhs.clone();
8073 node->rhs = this->
rhs.clone();
8083 if (!this->
lhs.equals(rhsc.lhs))
return false;
8084 if (!this->rhs.
equals(rhsc.rhs))
return false;
8094 if (this->
lhs != rhsc.lhs)
return false;
8095 if (this->rhs != rhsc.rhs)
return false;
8103 ::tree::cbor::MapWriter &map,
8104 const ::tree::base::PointerMap &ids
8107 map.append_string(
"@t",
"ShiftRightArith");
8108 auto submap = map.append_map(
"lhs");
8109 lhs.serialize(submap, ids);
8111 submap = map.append_map(
"rhs");
8112 rhs.serialize(submap, ids);
8114 serialize_annotations(map);
8122 auto type = map.at(
"@t").as_string();
8123 if (
type !=
"ShiftRightArith") {
8124 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
8126 auto node = std::make_shared<ShiftRightArith>(
8130 node->deserialize_annotations(map);
8146 lhs.find_reachable(map);
8147 rhs.find_reachable(map);
8155 lhs.check_complete(map);
8156 rhs.check_complete(map);
8193 return cqasm::tree::make<ShiftRightLogic>(*this);
8200 auto node = cqasm::tree::make<ShiftRightLogic>(*this);
8201 node->lhs = this->
lhs.clone();
8202 node->rhs = this->
rhs.clone();
8212 if (!this->
lhs.equals(rhsc.lhs))
return false;
8213 if (!this->rhs.
equals(rhsc.rhs))
return false;
8223 if (this->
lhs != rhsc.lhs)
return false;
8224 if (this->rhs != rhsc.rhs)
return false;
8232 ::tree::cbor::MapWriter &map,
8233 const ::tree::base::PointerMap &ids
8236 map.append_string(
"@t",
"ShiftRightLogic");
8237 auto submap = map.append_map(
"lhs");
8238 lhs.serialize(submap, ids);
8240 submap = map.append_map(
"rhs");
8241 rhs.serialize(submap, ids);
8243 serialize_annotations(map);
8251 auto type = map.at(
"@t").as_string();
8252 if (
type !=
"ShiftRightLogic") {
8253 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
8255 auto node = std::make_shared<ShiftRightLogic>(
8259 node->deserialize_annotations(map);
8275 items.find_reachable(map);
8283 items.check_complete(map);
8320 return cqasm::tree::make<StatementList>(*this);
8327 auto node = cqasm::tree::make<StatementList>(*this);
8328 node->items = this->
items.clone();
8338 if (!this->
items.equals(rhsc.items))
return false;
8348 if (this->
items != rhsc.items)
return false;
8356 ::tree::cbor::MapWriter &map,
8357 const ::tree::base::PointerMap &ids
8360 map.append_string(
"@t",
"StatementList");
8361 auto submap = map.append_map(
"items");
8362 items.serialize(submap, ids);
8364 serialize_annotations(map);
8372 auto type = map.at(
"@t").as_string();
8373 if (
type !=
"StatementList") {
8374 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
8376 auto node = std::make_shared<StatementList>(
8379 node->deserialize_annotations(map);
8438 return cqasm::tree::make<StringLiteral>(*this);
8445 auto node = cqasm::tree::make<StringLiteral>(*this);
8455 if (this->
value != rhsc.value)
return false;
8465 if (this->
value != rhsc.value)
return false;
8473 ::tree::cbor::MapWriter &map,
8474 const ::tree::base::PointerMap &ids
8477 map.append_string(
"@t",
"StringLiteral");
8478 auto submap = map.append_map(
"value");
8479 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Str>(
value, submap);
8481 serialize_annotations(map);
8489 auto type = map.at(
"@t").as_string();
8490 if (
type !=
"StringLiteral") {
8491 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
8493 auto node = std::make_shared<StringLiteral>(
8494 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at(
"value").as_map())
8496 node->deserialize_annotations(map);
8504 :
Statement(annotations), name(name), iterations(iterations)
8512 name.find_reachable(map);
8522 name.check_complete(map);
8554 return dynamic_cast<const Subcircuit*
>(
this);
8561 return cqasm::tree::make<Subcircuit>(*this);
8568 auto node = cqasm::tree::make<Subcircuit>(*this);
8569 node->name = this->
name.clone();
8580 auto rhsc =
dynamic_cast<const Subcircuit&
>(rhs);
8581 if (!this->
name.equals(rhsc.name))
return false;
8582 if (!this->
iterations.equals(rhsc.iterations))
return false;
8583 if (!this->
annotations.equals(rhsc.annotations))
return false;
8592 auto rhsc =
dynamic_cast<const Subcircuit&
>(rhs);
8593 if (this->
name != rhsc.name)
return false;
8594 if (this->
iterations != rhsc.iterations)
return false;
8595 if (this->
annotations != rhsc.annotations)
return false;
8603 ::tree::cbor::MapWriter &map,
8604 const ::tree::base::PointerMap &ids
8607 map.append_string(
"@t",
"Subcircuit");
8608 auto submap = map.append_map(
"name");
8609 name.serialize(submap, ids);
8611 submap = map.append_map(
"iterations");
8614 submap = map.append_map(
"annotations");
8617 serialize_annotations(map);
8625 auto type = map.at(
"@t").as_string();
8626 if (
type !=
"Subcircuit") {
8627 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
8629 auto node = std::make_shared<Subcircuit>(
8634 node->deserialize_annotations(map);
8650 lhs.find_reachable(map);
8651 rhs.find_reachable(map);
8659 lhs.check_complete(map);
8660 rhs.check_complete(map);
8682 return dynamic_cast<Subtract*
>(
this);
8690 return dynamic_cast<const Subtract*
>(
this);
8697 return cqasm::tree::make<Subtract>(*this);
8704 auto node = cqasm::tree::make<Subtract>(*this);
8705 node->lhs = this->
lhs.clone();
8706 node->rhs = this->
rhs.clone();
8716 if (!this->
lhs.equals(rhsc.lhs))
return false;
8717 if (!this->rhs.
equals(rhsc.rhs))
return false;
8727 if (this->
lhs != rhsc.lhs)
return false;
8728 if (this->rhs != rhsc.rhs)
return false;
8736 ::tree::cbor::MapWriter &map,
8737 const ::tree::base::PointerMap &ids
8740 map.append_string(
"@t",
"Subtract");
8741 auto submap = map.append_map(
"lhs");
8742 lhs.serialize(submap, ids);
8744 submap = map.append_map(
"rhs");
8745 rhs.serialize(submap, ids);
8747 serialize_annotations(map);
8755 auto type = map.at(
"@t").as_string();
8756 if (
type !=
"Subtract") {
8757 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
8759 auto node = std::make_shared<Subtract>(
8763 node->deserialize_annotations(map);
8771 :
Expression(), cond(cond), if_true(if_true), if_false(if_false)
8779 cond.find_reachable(map);
8789 cond.check_complete(map);
8828 return cqasm::tree::make<TernaryCond>(*this);
8835 auto node = cqasm::tree::make<TernaryCond>(*this);
8836 node->cond = this->
cond.clone();
8837 node->if_true = this->
if_true.clone();
8838 node->if_false = this->
if_false.clone();
8847 auto rhsc =
dynamic_cast<const TernaryCond&
>(rhs);
8848 if (!this->
cond.equals(rhsc.cond))
return false;
8849 if (!this->
if_true.equals(rhsc.if_true))
return false;
8850 if (!this->
if_false.equals(rhsc.if_false))
return false;
8859 auto rhsc =
dynamic_cast<const TernaryCond&
>(rhs);
8860 if (this->
cond != rhsc.cond)
return false;
8861 if (this->
if_true != rhsc.if_true)
return false;
8862 if (this->
if_false != rhsc.if_false)
return false;
8870 ::tree::cbor::MapWriter &map,
8871 const ::tree::base::PointerMap &ids
8874 map.append_string(
"@t",
"TernaryCond");
8875 auto submap = map.append_map(
"cond");
8876 cond.serialize(submap, ids);
8878 submap = map.append_map(
"if_true");
8879 if_true.serialize(submap, ids);
8881 submap = map.append_map(
"if_false");
8884 serialize_annotations(map);
8892 auto type = map.at(
"@t").as_string();
8893 if (
type !=
"TernaryCond") {
8894 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
8896 auto node = std::make_shared<TernaryCond>(
8901 node->deserialize_annotations(map);
8909 :
Statement(annotations), names(names), typ(typ)
8917 names.find_reachable(map);
8918 typ.find_reachable(map);
8927 names.check_complete(map);
8928 typ.check_complete(map);
8959 return dynamic_cast<const Variables*
>(
this);
8966 return cqasm::tree::make<Variables>(*this);
8973 auto node = cqasm::tree::make<Variables>(*this);
8974 node->names = this->
names.clone();
8975 node->typ = this->
typ.clone();
8985 auto rhsc =
dynamic_cast<const Variables&
>(rhs);
8986 if (!this->
names.equals(rhsc.names))
return false;
8987 if (!this->
typ.equals(rhsc.typ))
return false;
8988 if (!this->
annotations.equals(rhsc.annotations))
return false;
8997 auto rhsc =
dynamic_cast<const Variables&
>(rhs);
8998 if (this->
names != rhsc.names)
return false;
8999 if (this->
typ != rhsc.typ)
return false;
9000 if (this->
annotations != rhsc.annotations)
return false;
9008 ::tree::cbor::MapWriter &map,
9009 const ::tree::base::PointerMap &ids
9012 map.append_string(
"@t",
"Variables");
9013 auto submap = map.append_map(
"names");
9014 names.serialize(submap, ids);
9016 submap = map.append_map(
"typ");
9017 typ.serialize(submap, ids);
9019 submap = map.append_map(
"annotations");
9022 serialize_annotations(map);
9030 auto type = map.at(
"@t").as_string();
9031 if (
type !=
"Variables") {
9032 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
9034 auto node = std::make_shared<Variables>(
9039 node->deserialize_annotations(map);
9083 return dynamic_cast<Version*
>(
this);
9091 return dynamic_cast<const Version*
>(
this);
9098 return cqasm::tree::make<Version>(*this);
9105 auto node = cqasm::tree::make<Version>(*this);
9114 auto rhsc =
dynamic_cast<const Version&
>(rhs);
9115 if (this->
items != rhsc.items)
return false;
9124 auto rhsc =
dynamic_cast<const Version&
>(rhs);
9125 if (this->
items != rhsc.items)
return false;
9133 ::tree::cbor::MapWriter &map,
9134 const ::tree::base::PointerMap &ids
9137 map.append_string(
"@t",
"Version");
9138 auto submap = map.append_map(
"items");
9139 cqasm::v1::primitives::serialize<cqasm::v1::primitives::Version>(
items, submap);
9141 serialize_annotations(map);
9147 std::shared_ptr<Version>
Version::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
9149 auto type = map.at(
"@t").as_string();
9150 if (
type !=
"Version") {
9151 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
9153 auto node = std::make_shared<Version>(
9154 cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Version>(map.at(
"items").as_map())
9156 node->deserialize_annotations(map);
9164 :
Structured(annotations), condition(condition), body(body)
9173 body.find_reachable(map);
9183 body.check_complete(map);
9214 return dynamic_cast<const WhileLoop*
>(
this);
9221 return cqasm::tree::make<WhileLoop>(*this);
9228 auto node = cqasm::tree::make<WhileLoop>(*this);
9229 node->condition = this->
condition.clone();
9230 node->body = this->
body.clone();
9240 auto rhsc =
dynamic_cast<const WhileLoop&
>(rhs);
9241 if (!this->
condition.equals(rhsc.condition))
return false;
9242 if (!this->
body.equals(rhsc.body))
return false;
9243 if (!this->
annotations.equals(rhsc.annotations))
return false;
9252 auto rhsc =
dynamic_cast<const WhileLoop&
>(rhs);
9253 if (this->
condition != rhsc.condition)
return false;
9254 if (this->
body != rhsc.body)
return false;
9255 if (this->
annotations != rhsc.annotations)
return false;
9263 ::tree::cbor::MapWriter &map,
9264 const ::tree::base::PointerMap &ids
9267 map.append_string(
"@t",
"WhileLoop");
9268 auto submap = map.append_map(
"condition");
9271 submap = map.append_map(
"body");
9272 body.serialize(submap, ids);
9274 submap = map.append_map(
"annotations");
9277 serialize_annotations(map);
9285 auto type = map.at(
"@t").as_string();
9286 if (
type !=
"WhileLoop") {
9287 throw std::runtime_error(
"Schema validation failed: unexpected node type " +
type);
9289 auto node = std::make_shared<WhileLoop>(
9294 node->deserialize_annotations(map);
9304 this->visit_node(node);
9313 this->visit_add(node);
9322 this->visit_annotated(node);
9331 this->visit_annotation_data(node);
9340 this->visit_arith_op(node);
9349 this->visit_assignment(node);
9358 this->visit_binary_op(node);
9367 this->visit_bitwise_and(node);
9376 this->visit_bitwise_not(node);
9385 this->visit_bitwise_op(node);
9394 this->visit_bitwise_or(node);
9403 this->visit_bitwise_xor(node);
9412 this->visit_break_statement(node);
9421 this->visit_bundle(node);
9430 this->visit_cmp_eq(node);
9439 this->visit_cmp_ge(node);
9448 this->visit_cmp_gt(node);
9457 this->visit_cmp_le(node);
9466 this->visit_cmp_lt(node);
9475 this->visit_cmp_ne(node);
9484 this->visit_cmp_op(node);
9493 this->visit_continue_statement(node);
9502 this->visit_divide(node);
9511 this->visit_erroneous_expression(node);
9520 this->visit_erroneous_program(node);
9529 this->visit_erroneous_statement(node);
9538 this->visit_expression(node);
9547 this->visit_expression_list(node);
9556 this->visit_float_literal(node);
9565 this->visit_for_loop(node);
9574 this->visit_foreach_loop(node);
9583 this->visit_function_call(node);
9592 this->visit_identifier(node);
9601 this->visit_if_else(node);
9610 this->visit_if_else_branch(node);
9619 this->visit_index(node);
9628 this->visit_index_entry(node);
9637 this->visit_index_item(node);
9646 this->visit_index_list(node);
9655 this->visit_index_range(node);
9664 this->visit_instruction(node);
9673 this->visit_int_divide(node);
9682 this->visit_integer_literal(node);
9691 this->visit_json_literal(node);
9700 this->visit_logical_and(node);
9709 this->visit_logical_not(node);
9718 this->visit_logical_op(node);
9727 this->visit_logical_or(node);
9736 this->visit_logical_xor(node);
9745 this->visit_mapping(node);
9754 this->visit_matrix_literal(node);
9763 this->visit_modulo(node);
9772 this->visit_multiply(node);
9781 this->visit_negate(node);
9790 this->visit_power(node);
9799 this->visit_program(node);
9808 this->visit_repeat_until_loop(node);
9817 this->visit_root(node);
9826 this->visit_shift_left(node);
9835 this->visit_shift_op(node);
9844 this->visit_shift_right_arith(node);
9853 this->visit_shift_right_logic(node);
9862 this->visit_statement(node);
9871 this->visit_statement_list(node);
9880 this->visit_string_literal(node);
9889 this->visit_structured(node);
9898 this->visit_subcircuit(node);
9907 this->visit_subtract(node);
9916 this->visit_ternary_cond(node);
9925 this->visit_unary_op(node);
9934 this->visit_variables(node);
9943 this->visit_version(node);
9952 this->visit_while_loop(node);
9959 visit_arith_op(node);
9984 visit_binary_op(node);
9992 node.
lhs.visit(*
this);
9993 node.
rhs.visit(*
this);
10000 visit_expression(node);
10001 node.
lhs.visit(*
this);
10002 node.
rhs.visit(*
this);
10009 visit_bitwise_op(node);
10016 visit_unary_op(node);
10023 visit_binary_op(node);
10030 visit_bitwise_op(node);
10037 visit_bitwise_op(node);
10044 visit_structured(node);
10051 visit_statement(node);
10052 node.
items.visit(*
this);
10059 visit_cmp_op(node);
10066 visit_cmp_op(node);
10073 visit_cmp_op(node);
10080 visit_cmp_op(node);
10087 visit_cmp_op(node);
10094 visit_cmp_op(node);
10101 visit_binary_op(node);
10108 visit_structured(node);
10115 visit_arith_op(node);
10122 visit_expression(node);
10136 visit_statement(node);
10151 node.
items.visit(*
this);
10158 visit_expression(node);
10165 visit_structured(node);
10168 node.
update.visit(*
this);
10169 node.
body.visit(*
this);
10176 visit_structured(node);
10177 node.
lhs.visit(*
this);
10178 node.
frm.visit(*
this);
10179 node.
to.visit(*
this);
10180 node.
body.visit(*
this);
10187 visit_expression(node);
10188 node.
name.visit(*
this);
10196 visit_expression(node);
10203 visit_structured(node);
10214 node.
body.visit(*
this);
10221 visit_expression(node);
10222 node.
expr.visit(*
this);
10237 visit_index_entry(node);
10238 node.
index.visit(*
this);
10246 node.
items.visit(*
this);
10253 visit_index_entry(node);
10254 node.
first.visit(*
this);
10255 node.
last.visit(*
this);
10262 visit_annotated(node);
10263 node.
name.visit(*
this);
10272 visit_arith_op(node);
10279 visit_expression(node);
10286 visit_expression(node);
10293 visit_logical_op(node);
10300 visit_unary_op(node);
10307 visit_binary_op(node);
10314 visit_logical_op(node);
10321 visit_logical_op(node);
10328 visit_statement(node);
10329 node.
alias.visit(*
this);
10330 node.
expr.visit(*
this);
10337 visit_expression(node);
10338 node.
rows.visit(*
this);
10345 visit_arith_op(node);
10352 visit_arith_op(node);
10359 visit_unary_op(node);
10366 visit_arith_op(node);
10383 visit_structured(node);
10384 node.
body.visit(*
this);
10399 visit_shift_op(node);
10406 visit_binary_op(node);
10413 visit_shift_op(node);
10420 visit_shift_op(node);
10427 visit_annotated(node);
10435 node.
items.visit(*
this);
10442 visit_expression(node);
10449 visit_statement(node);
10456 visit_statement(node);
10457 node.
name.visit(*
this);
10465 visit_arith_op(node);
10472 visit_expression(node);
10473 node.
cond.visit(*
this);
10482 visit_expression(node);
10483 node.
expr.visit(*
this);
10490 visit_statement(node);
10491 node.
names.visit(*
this);
10492 node.
typ.visit(*
this);
10506 visit_structured(node);
10508 node.
body.visit(*
this);
10515 for (
int i = 0; i < indent; i++) {
10526 out <<
"!Node()" << std::endl;
10535 if (ids !=
nullptr) {
10536 out <<
"@" << ids->get_ref(node);
10540 out <<
" # " << *loc;
10546 if (node.
lhs.empty()) {
10547 out <<
"!MISSING" << std::endl;
10549 out <<
"<" << std::endl;
10551 node.
lhs.visit(*
this);
10554 out <<
">" << std::endl;
10558 if (node.
rhs.empty()) {
10559 out <<
"!MISSING" << std::endl;
10561 out <<
"<" << std::endl;
10563 node.
rhs.visit(*
this);
10566 out <<
">" << std::endl;
10570 out <<
")" << std::endl;
10578 out <<
"Annotated";
10579 if (ids !=
nullptr) {
10580 out <<
"@" << ids->get_ref(node);
10584 out <<
" # " << *loc;
10589 out <<
"annotations: ";
10591 out <<
"[]" << std::endl;
10593 out <<
"[" << std::endl;
10596 if (!sptr.empty()) {
10597 sptr->visit(*
this);
10600 out <<
"!NULL" << std::endl;
10605 out <<
"]" << std::endl;
10609 out <<
")" << std::endl;
10617 out <<
"AnnotationData";
10618 if (ids !=
nullptr) {
10619 out <<
"@" << ids->get_ref(node);
10623 out <<
" # " << *loc;
10628 out <<
"interface: ";
10630 out <<
"!MISSING" << std::endl;
10632 out <<
"<" << std::endl;
10637 out <<
">" << std::endl;
10640 out <<
"operation: ";
10642 out <<
"!MISSING" << std::endl;
10644 out <<
"<" << std::endl;
10649 out <<
">" << std::endl;
10652 out <<
"operands: ";
10654 out <<
"!MISSING" << std::endl;
10656 out <<
"<" << std::endl;
10661 out <<
">" << std::endl;
10665 out <<
")" << std::endl;
10674 if (ids !=
nullptr) {
10675 out <<
"@" << ids->get_ref(node);
10679 out <<
" # " << *loc;
10685 if (node.
lhs.empty()) {
10686 out <<
"!MISSING" << std::endl;
10688 out <<
"<" << std::endl;
10690 node.
lhs.visit(*
this);
10693 out <<
">" << std::endl;
10697 if (node.
rhs.empty()) {
10698 out <<
"!MISSING" << std::endl;
10700 out <<
"<" << std::endl;
10702 node.
rhs.visit(*
this);
10705 out <<
">" << std::endl;
10709 out <<
")" << std::endl;
10717 out <<
"Assignment";
10718 if (ids !=
nullptr) {
10719 out <<
"@" << ids->get_ref(node);
10723 out <<
" # " << *loc;
10729 if (node.
lhs.empty()) {
10730 out <<
"!MISSING" << std::endl;
10732 out <<
"<" << std::endl;
10734 node.
lhs.visit(*
this);
10737 out <<
">" << std::endl;
10741 if (node.
rhs.empty()) {
10742 out <<
"!MISSING" << std::endl;
10744 out <<
"<" << std::endl;
10746 node.
rhs.visit(*
this);
10749 out <<
">" << std::endl;
10753 out <<
")" << std::endl;
10762 if (ids !=
nullptr) {
10763 out <<
"@" << ids->get_ref(node);
10767 out <<
" # " << *loc;
10773 if (node.
lhs.empty()) {
10774 out <<
"!MISSING" << std::endl;
10776 out <<
"<" << std::endl;
10778 node.
lhs.visit(*
this);
10781 out <<
">" << std::endl;
10785 if (node.
rhs.empty()) {
10786 out <<
"!MISSING" << std::endl;
10788 out <<
"<" << std::endl;
10790 node.
rhs.visit(*
this);
10793 out <<
">" << std::endl;
10797 out <<
")" << std::endl;
10805 out <<
"BitwiseAnd";
10806 if (ids !=
nullptr) {
10807 out <<
"@" << ids->get_ref(node);
10811 out <<
" # " << *loc;
10817 if (node.
lhs.empty()) {
10818 out <<
"!MISSING" << std::endl;
10820 out <<
"<" << std::endl;
10822 node.
lhs.visit(*
this);
10825 out <<
">" << std::endl;
10829 if (node.
rhs.empty()) {
10830 out <<
"!MISSING" << std::endl;
10832 out <<
"<" << std::endl;
10834 node.
rhs.visit(*
this);
10837 out <<
">" << std::endl;
10841 out <<
")" << std::endl;
10849 out <<
"BitwiseNot";
10850 if (ids !=
nullptr) {
10851 out <<
"@" << ids->get_ref(node);
10855 out <<
" # " << *loc;
10861 if (node.
expr.empty()) {
10862 out <<
"!MISSING" << std::endl;
10864 out <<
"<" << std::endl;
10866 node.
expr.visit(*
this);
10869 out <<
">" << std::endl;
10873 out <<
")" << std::endl;
10881 out <<
"BitwiseOp";
10882 if (ids !=
nullptr) {
10883 out <<
"@" << ids->get_ref(node);
10887 out <<
" # " << *loc;
10893 if (node.
lhs.empty()) {
10894 out <<
"!MISSING" << std::endl;
10896 out <<
"<" << std::endl;
10898 node.
lhs.visit(*
this);
10901 out <<
">" << std::endl;
10905 if (node.
rhs.empty()) {
10906 out <<
"!MISSING" << std::endl;
10908 out <<
"<" << std::endl;
10910 node.
rhs.visit(*
this);
10913 out <<
">" << std::endl;
10917 out <<
")" << std::endl;
10925 out <<
"BitwiseOr";
10926 if (ids !=
nullptr) {
10927 out <<
"@" << ids->get_ref(node);
10931 out <<
" # " << *loc;
10937 if (node.
lhs.empty()) {
10938 out <<
"!MISSING" << std::endl;
10940 out <<
"<" << std::endl;
10942 node.
lhs.visit(*
this);
10945 out <<
">" << std::endl;
10949 if (node.
rhs.empty()) {
10950 out <<
"!MISSING" << std::endl;
10952 out <<
"<" << std::endl;
10954 node.
rhs.visit(*
this);
10957 out <<
">" << std::endl;
10961 out <<
")" << std::endl;
10969 out <<
"BitwiseXor";
10970 if (ids !=
nullptr) {
10971 out <<
"@" << ids->get_ref(node);
10975 out <<
" # " << *loc;
10981 if (node.
lhs.empty()) {
10982 out <<
"!MISSING" << std::endl;
10984 out <<
"<" << std::endl;
10986 node.
lhs.visit(*
this);
10989 out <<
">" << std::endl;
10993 if (node.
rhs.empty()) {
10994 out <<
"!MISSING" << std::endl;
10996 out <<
"<" << std::endl;
10998 node.
rhs.visit(*
this);
11001 out <<
">" << std::endl;
11005 out <<
")" << std::endl;
11013 out <<
"BreakStatement";
11014 if (ids !=
nullptr) {
11015 out <<
"@" << ids->get_ref(node);
11019 out <<
" # " << *loc;
11024 out <<
"annotations: ";
11026 out <<
"[]" << std::endl;
11028 out <<
"[" << std::endl;
11031 if (!sptr.empty()) {
11032 sptr->visit(*
this);
11035 out <<
"!NULL" << std::endl;
11040 out <<
"]" << std::endl;
11044 out <<
")" << std::endl;
11053 if (ids !=
nullptr) {
11054 out <<
"@" << ids->get_ref(node);
11058 out <<
" # " << *loc;
11064 if (node.
items.empty()) {
11065 out <<
"!MISSING" << std::endl;
11067 out <<
"[" << std::endl;
11069 for (
auto &sptr : node.
items) {
11070 if (!sptr.empty()) {
11071 sptr->visit(*
this);
11074 out <<
"!NULL" << std::endl;
11079 out <<
"]" << std::endl;
11082 out <<
"annotations: ";
11084 out <<
"[]" << std::endl;
11086 out <<
"[" << std::endl;
11089 if (!sptr.empty()) {
11090 sptr->visit(*
this);
11093 out <<
"!NULL" << std::endl;
11098 out <<
"]" << std::endl;
11102 out <<
")" << std::endl;
11111 if (ids !=
nullptr) {
11112 out <<
"@" << ids->get_ref(node);
11116 out <<
" # " << *loc;
11122 if (node.
lhs.empty()) {
11123 out <<
"!MISSING" << std::endl;
11125 out <<
"<" << std::endl;
11127 node.
lhs.visit(*
this);
11130 out <<
">" << std::endl;
11134 if (node.
rhs.empty()) {
11135 out <<
"!MISSING" << std::endl;
11137 out <<
"<" << std::endl;
11139 node.
rhs.visit(*
this);
11142 out <<
">" << std::endl;
11146 out <<
")" << std::endl;
11155 if (ids !=
nullptr) {
11156 out <<
"@" << ids->get_ref(node);
11160 out <<
" # " << *loc;
11166 if (node.
lhs.empty()) {
11167 out <<
"!MISSING" << std::endl;
11169 out <<
"<" << std::endl;
11171 node.
lhs.visit(*
this);
11174 out <<
">" << std::endl;
11178 if (node.
rhs.empty()) {
11179 out <<
"!MISSING" << std::endl;
11181 out <<
"<" << std::endl;
11183 node.
rhs.visit(*
this);
11186 out <<
">" << std::endl;
11190 out <<
")" << std::endl;
11199 if (ids !=
nullptr) {
11200 out <<
"@" << ids->get_ref(node);
11204 out <<
" # " << *loc;
11210 if (node.
lhs.empty()) {
11211 out <<
"!MISSING" << std::endl;
11213 out <<
"<" << std::endl;
11215 node.
lhs.visit(*
this);
11218 out <<
">" << std::endl;
11222 if (node.
rhs.empty()) {
11223 out <<
"!MISSING" << std::endl;
11225 out <<
"<" << std::endl;
11227 node.
rhs.visit(*
this);
11230 out <<
">" << std::endl;
11234 out <<
")" << std::endl;
11243 if (ids !=
nullptr) {
11244 out <<
"@" << ids->get_ref(node);
11248 out <<
" # " << *loc;
11254 if (node.
lhs.empty()) {
11255 out <<
"!MISSING" << std::endl;
11257 out <<
"<" << std::endl;
11259 node.
lhs.visit(*
this);
11262 out <<
">" << std::endl;
11266 if (node.
rhs.empty()) {
11267 out <<
"!MISSING" << std::endl;
11269 out <<
"<" << std::endl;
11271 node.
rhs.visit(*
this);
11274 out <<
">" << std::endl;
11278 out <<
")" << std::endl;
11287 if (ids !=
nullptr) {
11288 out <<
"@" << ids->get_ref(node);
11292 out <<
" # " << *loc;
11298 if (node.
lhs.empty()) {
11299 out <<
"!MISSING" << std::endl;
11301 out <<
"<" << std::endl;
11303 node.
lhs.visit(*
this);
11306 out <<
">" << std::endl;
11310 if (node.
rhs.empty()) {
11311 out <<
"!MISSING" << std::endl;
11313 out <<
"<" << std::endl;
11315 node.
rhs.visit(*
this);
11318 out <<
">" << std::endl;
11322 out <<
")" << std::endl;
11331 if (ids !=
nullptr) {
11332 out <<
"@" << ids->get_ref(node);
11336 out <<
" # " << *loc;
11342 if (node.
lhs.empty()) {
11343 out <<
"!MISSING" << std::endl;
11345 out <<
"<" << std::endl;
11347 node.
lhs.visit(*
this);
11350 out <<
">" << std::endl;
11354 if (node.
rhs.empty()) {
11355 out <<
"!MISSING" << std::endl;
11357 out <<
"<" << std::endl;
11359 node.
rhs.visit(*
this);
11362 out <<
">" << std::endl;
11366 out <<
")" << std::endl;
11375 if (ids !=
nullptr) {
11376 out <<
"@" << ids->get_ref(node);
11380 out <<
" # " << *loc;
11386 if (node.
lhs.empty()) {
11387 out <<
"!MISSING" << std::endl;
11389 out <<
"<" << std::endl;
11391 node.
lhs.visit(*
this);
11394 out <<
">" << std::endl;
11398 if (node.
rhs.empty()) {
11399 out <<
"!MISSING" << std::endl;
11401 out <<
"<" << std::endl;
11403 node.
rhs.visit(*
this);
11406 out <<
">" << std::endl;
11410 out <<
")" << std::endl;
11418 out <<
"ContinueStatement";
11419 if (ids !=
nullptr) {
11420 out <<
"@" << ids->get_ref(node);
11424 out <<
" # " << *loc;
11429 out <<
"annotations: ";
11431 out <<
"[]" << std::endl;
11433 out <<
"[" << std::endl;
11436 if (!sptr.empty()) {
11437 sptr->visit(*
this);
11440 out <<
"!NULL" << std::endl;
11445 out <<
"]" << std::endl;
11449 out <<
")" << std::endl;
11458 if (ids !=
nullptr) {
11459 out <<
"@" << ids->get_ref(node);
11463 out <<
" # " << *loc;
11469 if (node.
lhs.empty()) {
11470 out <<
"!MISSING" << std::endl;
11472 out <<
"<" << std::endl;
11474 node.
lhs.visit(*
this);
11477 out <<
">" << std::endl;
11481 if (node.
rhs.empty()) {
11482 out <<
"!MISSING" << std::endl;
11484 out <<
"<" << std::endl;
11486 node.
rhs.visit(*
this);
11489 out <<
">" << std::endl;
11493 out <<
")" << std::endl;
11501 out <<
"ErroneousExpression";
11502 if (ids !=
nullptr) {
11503 out <<
"@" << ids->get_ref(node);
11507 out <<
" # " << *loc;
11510 out <<
")" << std::endl;
11518 out <<
"ErroneousProgram";
11519 if (ids !=
nullptr) {
11520 out <<
"@" << ids->get_ref(node);
11524 out <<
" # " << *loc;
11527 out <<
")" << std::endl;
11535 out <<
"ErroneousStatement";
11536 if (ids !=
nullptr) {
11537 out <<
"@" << ids->get_ref(node);
11541 out <<
" # " << *loc;
11546 out <<
"annotations: ";
11548 out <<
"[]" << std::endl;
11550 out <<
"[" << std::endl;
11553 if (!sptr.empty()) {
11554 sptr->visit(*
this);
11557 out <<
"!NULL" << std::endl;
11562 out <<
"]" << std::endl;
11566 out <<
")" << std::endl;
11574 out <<
"Expression";
11575 if (ids !=
nullptr) {
11576 out <<
"@" << ids->get_ref(node);
11580 out <<
" # " << *loc;
11583 out <<
")" << std::endl;
11591 out <<
"ExpressionList";
11592 if (ids !=
nullptr) {
11593 out <<
"@" << ids->get_ref(node);
11597 out <<
" # " << *loc;
11603 if (node.
items.empty()) {
11604 out <<
"[]" << std::endl;
11606 out <<
"[" << std::endl;
11608 for (
auto &sptr : node.
items) {
11609 if (!sptr.empty()) {
11610 sptr->visit(*
this);
11613 out <<
"!NULL" << std::endl;
11618 out <<
"]" << std::endl;
11622 out <<
")" << std::endl;
11630 out <<
"FloatLiteral";
11631 if (ids !=
nullptr) {
11632 out <<
"@" << ids->get_ref(node);
11636 out <<
" # " << *loc;
11642 std::stringstream ss;
11645 pos = ss.str().find_last_not_of(
" \n\r\t");
11646 if (pos != std::string::npos) {
11647 ss.str(ss.str().erase(pos+1));
11649 if (ss.str().find(
'\n') == std::string::npos) {
11650 out << ss.str() << std::endl;
11652 out <<
"cqasm::v1::primitives::Real<<" << std::endl;
11655 while (!ss.eof()) {
11656 std::getline(ss, s);
11658 out << s << std::endl;
11662 out <<
">>" << std::endl;
11666 out <<
")" << std::endl;
11675 if (ids !=
nullptr) {
11676 out <<
"@" << ids->get_ref(node);
11680 out <<
" # " << *loc;
11685 out <<
"initialize: ";
11687 out <<
"-" << std::endl;
11689 out <<
"<" << std::endl;
11694 out <<
">" << std::endl;
11697 out <<
"condition: ";
11699 out <<
"!MISSING" << std::endl;
11701 out <<
"<" << std::endl;
11706 out <<
">" << std::endl;
11710 if (node.
update.empty()) {
11711 out <<
"-" << std::endl;
11713 out <<
"<" << std::endl;
11715 node.
update.visit(*
this);
11718 out <<
">" << std::endl;
11722 if (node.
body.empty()) {
11723 out <<
"!MISSING" << std::endl;
11725 out <<
"<" << std::endl;
11727 node.
body.visit(*
this);
11730 out <<
">" << std::endl;
11733 out <<
"annotations: ";
11735 out <<
"[]" << std::endl;
11737 out <<
"[" << std::endl;
11740 if (!sptr.empty()) {
11741 sptr->visit(*
this);
11744 out <<
"!NULL" << std::endl;
11749 out <<
"]" << std::endl;
11753 out <<
")" << std::endl;
11761 out <<
"ForeachLoop";
11762 if (ids !=
nullptr) {
11763 out <<
"@" << ids->get_ref(node);
11767 out <<
" # " << *loc;
11773 if (node.
lhs.empty()) {
11774 out <<
"!MISSING" << std::endl;
11776 out <<
"<" << std::endl;
11778 node.
lhs.visit(*
this);
11781 out <<
">" << std::endl;
11785 if (node.
frm.empty()) {
11786 out <<
"!MISSING" << std::endl;
11788 out <<
"<" << std::endl;
11790 node.
frm.visit(*
this);
11793 out <<
">" << std::endl;
11797 if (node.
to.empty()) {
11798 out <<
"!MISSING" << std::endl;
11800 out <<
"<" << std::endl;
11802 node.
to.visit(*
this);
11805 out <<
">" << std::endl;
11809 if (node.
body.empty()) {
11810 out <<
"!MISSING" << std::endl;
11812 out <<
"<" << std::endl;
11814 node.
body.visit(*
this);
11817 out <<
">" << std::endl;
11820 out <<
"annotations: ";
11822 out <<
"[]" << std::endl;
11824 out <<
"[" << std::endl;
11827 if (!sptr.empty()) {
11828 sptr->visit(*
this);
11831 out <<
"!NULL" << std::endl;
11836 out <<
"]" << std::endl;
11840 out <<
")" << std::endl;
11848 out <<
"FunctionCall";
11849 if (ids !=
nullptr) {
11850 out <<
"@" << ids->get_ref(node);
11854 out <<
" # " << *loc;
11860 if (node.
name.empty()) {
11861 out <<
"!MISSING" << std::endl;
11863 out <<
"<" << std::endl;
11865 node.
name.visit(*
this);
11868 out <<
">" << std::endl;
11871 out <<
"arguments: ";
11873 out <<
"!MISSING" << std::endl;
11875 out <<
"<" << std::endl;
11880 out <<
">" << std::endl;
11884 out <<
")" << std::endl;
11892 out <<
"Identifier";
11893 if (ids !=
nullptr) {
11894 out <<
"@" << ids->get_ref(node);
11898 out <<
" # " << *loc;
11904 std::stringstream ss;
11907 pos = ss.str().find_last_not_of(
" \n\r\t");
11908 if (pos != std::string::npos) {
11909 ss.str(ss.str().erase(pos+1));
11911 if (ss.str().find(
'\n') == std::string::npos) {
11912 out << ss.str() << std::endl;
11914 out <<
"cqasm::v1::primitives::Str<<" << std::endl;
11917 while (!ss.eof()) {
11918 std::getline(ss, s);
11920 out << s << std::endl;
11924 out <<
">>" << std::endl;
11928 out <<
")" << std::endl;
11937 if (ids !=
nullptr) {
11938 out <<
"@" << ids->get_ref(node);
11942 out <<
" # " << *loc;
11947 out <<
"branches: ";
11949 out <<
"!MISSING" << std::endl;
11951 out <<
"[" << std::endl;
11953 for (
auto &sptr : node.
branches) {
11954 if (!sptr.empty()) {
11955 sptr->visit(*
this);
11958 out <<
"!NULL" << std::endl;
11963 out <<
"]" << std::endl;
11966 out <<
"otherwise: ";
11968 out <<
"-" << std::endl;
11970 out <<
"<" << std::endl;
11975 out <<
">" << std::endl;
11978 out <<
"annotations: ";
11980 out <<
"[]" << std::endl;
11982 out <<
"[" << std::endl;
11985 if (!sptr.empty()) {
11986 sptr->visit(*
this);
11989 out <<
"!NULL" << std::endl;
11994 out <<
"]" << std::endl;
11998 out <<
")" << std::endl;
12006 out <<
"IfElseBranch";
12007 if (ids !=
nullptr) {
12008 out <<
"@" << ids->get_ref(node);
12012 out <<
" # " << *loc;
12017 out <<
"condition: ";
12019 out <<
"!MISSING" << std::endl;
12021 out <<
"<" << std::endl;
12026 out <<
">" << std::endl;
12030 if (node.
body.empty()) {
12031 out <<
"!MISSING" << std::endl;
12033 out <<
"<" << std::endl;
12035 node.
body.visit(*
this);
12038 out <<
">" << std::endl;
12042 out <<
")" << std::endl;
12051 if (ids !=
nullptr) {
12052 out <<
"@" << ids->get_ref(node);
12056 out <<
" # " << *loc;
12062 if (node.
expr.empty()) {
12063 out <<
"!MISSING" << std::endl;
12065 out <<
"<" << std::endl;
12067 node.
expr.visit(*
this);
12070 out <<
">" << std::endl;
12073 out <<
"indices: ";
12075 out <<
"!MISSING" << std::endl;
12077 out <<
"<" << std::endl;
12082 out <<
">" << std::endl;
12086 out <<
")" << std::endl;
12094 out <<
"IndexEntry";
12095 if (ids !=
nullptr) {
12096 out <<
"@" << ids->get_ref(node);
12100 out <<
" # " << *loc;
12103 out <<
")" << std::endl;
12111 out <<
"IndexItem";
12112 if (ids !=
nullptr) {
12113 out <<
"@" << ids->get_ref(node);
12117 out <<
" # " << *loc;
12123 if (node.
index.empty()) {
12124 out <<
"!MISSING" << std::endl;
12126 out <<
"<" << std::endl;
12128 node.
index.visit(*
this);
12131 out <<
">" << std::endl;
12135 out <<
")" << std::endl;
12143 out <<
"IndexList";
12144 if (ids !=
nullptr) {
12145 out <<
"@" << ids->get_ref(node);
12149 out <<
" # " << *loc;
12155 if (node.
items.empty()) {
12156 out <<
"!MISSING" << std::endl;
12158 out <<
"[" << std::endl;
12160 for (
auto &sptr : node.
items) {
12161 if (!sptr.empty()) {
12162 sptr->visit(*
this);
12165 out <<
"!NULL" << std::endl;
12170 out <<
"]" << std::endl;
12174 out <<
")" << std::endl;
12182 out <<
"IndexRange";
12183 if (ids !=
nullptr) {
12184 out <<
"@" << ids->get_ref(node);
12188 out <<
" # " << *loc;
12194 if (node.
first.empty()) {
12195 out <<
"!MISSING" << std::endl;
12197 out <<
"<" << std::endl;
12199 node.
first.visit(*
this);
12202 out <<
">" << std::endl;
12206 if (node.
last.empty()) {
12207 out <<
"!MISSING" << std::endl;
12209 out <<
"<" << std::endl;
12211 node.
last.visit(*
this);
12214 out <<
">" << std::endl;
12218 out <<
")" << std::endl;
12226 out <<
"Instruction";
12227 if (ids !=
nullptr) {
12228 out <<
"@" << ids->get_ref(node);
12232 out <<
" # " << *loc;
12238 if (node.
name.empty()) {
12239 out <<
"!MISSING" << std::endl;
12241 out <<
"<" << std::endl;
12243 node.
name.visit(*
this);
12246 out <<
">" << std::endl;
12249 out <<
"condition: ";
12251 out <<
"-" << std::endl;
12253 out <<
"<" << std::endl;
12258 out <<
">" << std::endl;
12261 out <<
"operands: ";
12263 out <<
"!MISSING" << std::endl;
12265 out <<
"<" << std::endl;
12270 out <<
">" << std::endl;
12273 out <<
"annotations: ";
12275 out <<
"[]" << std::endl;
12277 out <<
"[" << std::endl;
12280 if (!sptr.empty()) {
12281 sptr->visit(*
this);
12284 out <<
"!NULL" << std::endl;
12289 out <<
"]" << std::endl;
12293 out <<
")" << std::endl;
12301 out <<
"IntDivide";
12302 if (ids !=
nullptr) {
12303 out <<
"@" << ids->get_ref(node);
12307 out <<
" # " << *loc;
12313 if (node.
lhs.empty()) {
12314 out <<
"!MISSING" << std::endl;
12316 out <<
"<" << std::endl;
12318 node.
lhs.visit(*
this);
12321 out <<
">" << std::endl;
12325 if (node.
rhs.empty()) {
12326 out <<
"!MISSING" << std::endl;
12328 out <<
"<" << std::endl;
12330 node.
rhs.visit(*
this);
12333 out <<
">" << std::endl;
12337 out <<
")" << std::endl;
12345 out <<
"IntegerLiteral";
12346 if (ids !=
nullptr) {
12347 out <<
"@" << ids->get_ref(node);
12351 out <<
" # " << *loc;
12357 std::stringstream ss;
12360 pos = ss.str().find_last_not_of(
" \n\r\t");
12361 if (pos != std::string::npos) {
12362 ss.str(ss.str().erase(pos+1));
12364 if (ss.str().find(
'\n') == std::string::npos) {
12365 out << ss.str() << std::endl;
12367 out <<
"cqasm::v1::primitives::Int<<" << std::endl;
12370 while (!ss.eof()) {
12371 std::getline(ss, s);
12373 out << s << std::endl;
12377 out <<
">>" << std::endl;
12381 out <<
")" << std::endl;
12389 out <<
"JsonLiteral";
12390 if (ids !=
nullptr) {
12391 out <<
"@" << ids->get_ref(node);
12395 out <<
" # " << *loc;
12401 std::stringstream ss;
12404 pos = ss.str().find_last_not_of(
" \n\r\t");
12405 if (pos != std::string::npos) {
12406 ss.str(ss.str().erase(pos+1));
12408 if (ss.str().find(
'\n') == std::string::npos) {
12409 out << ss.str() << std::endl;
12411 out <<
"cqasm::v1::primitives::Str<<" << std::endl;
12414 while (!ss.eof()) {
12415 std::getline(ss, s);
12417 out << s << std::endl;
12421 out <<
">>" << std::endl;
12425 out <<
")" << std::endl;
12433 out <<
"LogicalAnd";
12434 if (ids !=
nullptr) {
12435 out <<
"@" << ids->get_ref(node);
12439 out <<
" # " << *loc;
12445 if (node.
lhs.empty()) {
12446 out <<
"!MISSING" << std::endl;
12448 out <<
"<" << std::endl;
12450 node.
lhs.visit(*
this);
12453 out <<
">" << std::endl;
12457 if (node.
rhs.empty()) {
12458 out <<
"!MISSING" << std::endl;
12460 out <<
"<" << std::endl;
12462 node.
rhs.visit(*
this);
12465 out <<
">" << std::endl;
12469 out <<
")" << std::endl;
12477 out <<
"LogicalNot";
12478 if (ids !=
nullptr) {
12479 out <<
"@" << ids->get_ref(node);
12483 out <<
" # " << *loc;
12489 if (node.
expr.empty()) {
12490 out <<
"!MISSING" << std::endl;
12492 out <<
"<" << std::endl;
12494 node.
expr.visit(*
this);
12497 out <<
">" << std::endl;
12501 out <<
")" << std::endl;
12509 out <<
"LogicalOp";
12510 if (ids !=
nullptr) {
12511 out <<
"@" << ids->get_ref(node);
12515 out <<
" # " << *loc;
12521 if (node.
lhs.empty()) {
12522 out <<
"!MISSING" << std::endl;
12524 out <<
"<" << std::endl;
12526 node.
lhs.visit(*
this);
12529 out <<
">" << std::endl;
12533 if (node.
rhs.empty()) {
12534 out <<
"!MISSING" << std::endl;
12536 out <<
"<" << std::endl;
12538 node.
rhs.visit(*
this);
12541 out <<
">" << std::endl;
12545 out <<
")" << std::endl;
12553 out <<
"LogicalOr";
12554 if (ids !=
nullptr) {
12555 out <<
"@" << ids->get_ref(node);
12559 out <<
" # " << *loc;
12565 if (node.
lhs.empty()) {
12566 out <<
"!MISSING" << std::endl;
12568 out <<
"<" << std::endl;
12570 node.
lhs.visit(*
this);
12573 out <<
">" << std::endl;
12577 if (node.
rhs.empty()) {
12578 out <<
"!MISSING" << std::endl;
12580 out <<
"<" << std::endl;
12582 node.
rhs.visit(*
this);
12585 out <<
">" << std::endl;
12589 out <<
")" << std::endl;
12597 out <<
"LogicalXor";
12598 if (ids !=
nullptr) {
12599 out <<
"@" << ids->get_ref(node);
12603 out <<
" # " << *loc;
12609 if (node.
lhs.empty()) {
12610 out <<
"!MISSING" << std::endl;
12612 out <<
"<" << std::endl;
12614 node.
lhs.visit(*
this);
12617 out <<
">" << std::endl;
12621 if (node.
rhs.empty()) {
12622 out <<
"!MISSING" << std::endl;
12624 out <<
"<" << std::endl;
12626 node.
rhs.visit(*
this);
12629 out <<
">" << std::endl;
12633 out <<
")" << std::endl;
12642 if (ids !=
nullptr) {
12643 out <<
"@" << ids->get_ref(node);
12647 out <<
" # " << *loc;
12653 if (node.
alias.empty()) {
12654 out <<
"!MISSING" << std::endl;
12656 out <<
"<" << std::endl;
12658 node.
alias.visit(*
this);
12661 out <<
">" << std::endl;
12665 if (node.
expr.empty()) {
12666 out <<
"!MISSING" << std::endl;
12668 out <<
"<" << std::endl;
12670 node.
expr.visit(*
this);
12673 out <<
">" << std::endl;
12676 out <<
"annotations: ";
12678 out <<
"[]" << std::endl;
12680 out <<
"[" << std::endl;
12683 if (!sptr.empty()) {
12684 sptr->visit(*
this);
12687 out <<
"!NULL" << std::endl;
12692 out <<
"]" << std::endl;
12696 out <<
")" << std::endl;
12704 out <<
"MatrixLiteral";
12705 if (ids !=
nullptr) {
12706 out <<
"@" << ids->get_ref(node);
12710 out <<
" # " << *loc;
12716 if (node.
rows.empty()) {
12717 out <<
"!MISSING" << std::endl;
12719 out <<
"[" << std::endl;
12721 for (
auto &sptr : node.
rows) {
12722 if (!sptr.empty()) {
12723 sptr->visit(*
this);
12726 out <<
"!NULL" << std::endl;
12731 out <<
"]" << std::endl;
12735 out <<
")" << std::endl;
12744 if (ids !=
nullptr) {
12745 out <<
"@" << ids->get_ref(node);
12749 out <<
" # " << *loc;
12755 if (node.
lhs.empty()) {
12756 out <<
"!MISSING" << std::endl;
12758 out <<
"<" << std::endl;
12760 node.
lhs.visit(*
this);
12763 out <<
">" << std::endl;
12767 if (node.
rhs.empty()) {
12768 out <<
"!MISSING" << std::endl;
12770 out <<
"<" << std::endl;
12772 node.
rhs.visit(*
this);
12775 out <<
">" << std::endl;
12779 out <<
")" << std::endl;
12788 if (ids !=
nullptr) {
12789 out <<
"@" << ids->get_ref(node);
12793 out <<
" # " << *loc;
12799 if (node.
lhs.empty()) {
12800 out <<
"!MISSING" << std::endl;
12802 out <<
"<" << std::endl;
12804 node.
lhs.visit(*
this);
12807 out <<
">" << std::endl;
12811 if (node.
rhs.empty()) {
12812 out <<
"!MISSING" << std::endl;
12814 out <<
"<" << std::endl;
12816 node.
rhs.visit(*
this);
12819 out <<
">" << std::endl;
12823 out <<
")" << std::endl;
12832 if (ids !=
nullptr) {
12833 out <<
"@" << ids->get_ref(node);
12837 out <<
" # " << *loc;
12843 if (node.
expr.empty()) {
12844 out <<
"!MISSING" << std::endl;
12846 out <<
"<" << std::endl;
12848 node.
expr.visit(*
this);
12851 out <<
">" << std::endl;
12855 out <<
")" << std::endl;
12864 if (ids !=
nullptr) {
12865 out <<
"@" << ids->get_ref(node);
12869 out <<
" # " << *loc;
12875 if (node.
lhs.empty()) {
12876 out <<
"!MISSING" << std::endl;
12878 out <<
"<" << std::endl;
12880 node.
lhs.visit(*
this);
12883 out <<
">" << std::endl;
12887 if (node.
rhs.empty()) {
12888 out <<
"!MISSING" << std::endl;
12890 out <<
"<" << std::endl;
12892 node.
rhs.visit(*
this);
12895 out <<
">" << std::endl;
12899 out <<
")" << std::endl;
12908 if (ids !=
nullptr) {
12909 out <<
"@" << ids->get_ref(node);
12913 out <<
" # " << *loc;
12918 out <<
"version: ";
12920 out <<
"!MISSING" << std::endl;
12922 out <<
"<" << std::endl;
12927 out <<
">" << std::endl;
12930 out <<
"num_qubits: ";
12932 out <<
"-" << std::endl;
12934 out <<
"<" << std::endl;
12939 out <<
">" << std::endl;
12942 out <<
"statements: ";
12944 out <<
"!MISSING" << std::endl;
12946 out <<
"<" << std::endl;
12951 out <<
">" << std::endl;
12955 out <<
")" << std::endl;
12963 out <<
"RepeatUntilLoop";
12964 if (ids !=
nullptr) {
12965 out <<
"@" << ids->get_ref(node);
12969 out <<
" # " << *loc;
12975 if (node.
body.empty()) {
12976 out <<
"!MISSING" << std::endl;
12978 out <<
"<" << std::endl;
12980 node.
body.visit(*
this);
12983 out <<
">" << std::endl;
12986 out <<
"condition: ";
12988 out <<
"!MISSING" << std::endl;
12990 out <<
"<" << std::endl;
12995 out <<
">" << std::endl;
12998 out <<
"annotations: ";
13000 out <<
"[]" << std::endl;
13002 out <<
"[" << std::endl;
13005 if (!sptr.empty()) {
13006 sptr->visit(*
this);
13009 out <<
"!NULL" << std::endl;
13014 out <<
"]" << std::endl;
13018 out <<
")" << std::endl;
13027 if (ids !=
nullptr) {
13028 out <<
"@" << ids->get_ref(node);
13032 out <<
" # " << *loc;
13035 out <<
")" << std::endl;
13043 out <<
"ShiftLeft";
13044 if (ids !=
nullptr) {
13045 out <<
"@" << ids->get_ref(node);
13049 out <<
" # " << *loc;
13055 if (node.
lhs.empty()) {
13056 out <<
"!MISSING" << std::endl;
13058 out <<
"<" << std::endl;
13060 node.
lhs.visit(*
this);
13063 out <<
">" << std::endl;
13067 if (node.
rhs.empty()) {
13068 out <<
"!MISSING" << std::endl;
13070 out <<
"<" << std::endl;
13072 node.
rhs.visit(*
this);
13075 out <<
">" << std::endl;
13079 out <<
")" << std::endl;
13088 if (ids !=
nullptr) {
13089 out <<
"@" << ids->get_ref(node);
13093 out <<
" # " << *loc;
13099 if (node.
lhs.empty()) {
13100 out <<
"!MISSING" << std::endl;
13102 out <<
"<" << std::endl;
13104 node.
lhs.visit(*
this);
13107 out <<
">" << std::endl;
13111 if (node.
rhs.empty()) {
13112 out <<
"!MISSING" << std::endl;
13114 out <<
"<" << std::endl;
13116 node.
rhs.visit(*
this);
13119 out <<
">" << std::endl;
13123 out <<
")" << std::endl;
13131 out <<
"ShiftRightArith";
13132 if (ids !=
nullptr) {
13133 out <<
"@" << ids->get_ref(node);
13137 out <<
" # " << *loc;
13143 if (node.
lhs.empty()) {
13144 out <<
"!MISSING" << std::endl;
13146 out <<
"<" << std::endl;
13148 node.
lhs.visit(*
this);
13151 out <<
">" << std::endl;
13155 if (node.
rhs.empty()) {
13156 out <<
"!MISSING" << std::endl;
13158 out <<
"<" << std::endl;
13160 node.
rhs.visit(*
this);
13163 out <<
">" << std::endl;
13167 out <<
")" << std::endl;
13175 out <<
"ShiftRightLogic";
13176 if (ids !=
nullptr) {
13177 out <<
"@" << ids->get_ref(node);
13181 out <<
" # " << *loc;
13187 if (node.
lhs.empty()) {
13188 out <<
"!MISSING" << std::endl;
13190 out <<
"<" << std::endl;
13192 node.
lhs.visit(*
this);
13195 out <<
">" << std::endl;
13199 if (node.
rhs.empty()) {
13200 out <<
"!MISSING" << std::endl;
13202 out <<
"<" << std::endl;
13204 node.
rhs.visit(*
this);
13207 out <<
">" << std::endl;
13211 out <<
")" << std::endl;
13219 out <<
"Statement";
13220 if (ids !=
nullptr) {
13221 out <<
"@" << ids->get_ref(node);
13225 out <<
" # " << *loc;
13230 out <<
"annotations: ";
13232 out <<
"[]" << std::endl;
13234 out <<
"[" << std::endl;
13237 if (!sptr.empty()) {
13238 sptr->visit(*
this);
13241 out <<
"!NULL" << std::endl;
13246 out <<
"]" << std::endl;
13250 out <<
")" << std::endl;
13258 out <<
"StatementList";
13259 if (ids !=
nullptr) {
13260 out <<
"@" << ids->get_ref(node);
13264 out <<
" # " << *loc;
13270 if (node.
items.empty()) {
13271 out <<
"[]" << std::endl;
13273 out <<
"[" << std::endl;
13275 for (
auto &sptr : node.
items) {
13276 if (!sptr.empty()) {
13277 sptr->visit(*
this);
13280 out <<
"!NULL" << std::endl;
13285 out <<
"]" << std::endl;
13289 out <<
")" << std::endl;
13297 out <<
"StringLiteral";
13298 if (ids !=
nullptr) {
13299 out <<
"@" << ids->get_ref(node);
13303 out <<
" # " << *loc;
13309 std::stringstream ss;
13312 pos = ss.str().find_last_not_of(
" \n\r\t");
13313 if (pos != std::string::npos) {
13314 ss.str(ss.str().erase(pos+1));
13316 if (ss.str().find(
'\n') == std::string::npos) {
13317 out << ss.str() << std::endl;
13319 out <<
"cqasm::v1::primitives::Str<<" << std::endl;
13322 while (!ss.eof()) {
13323 std::getline(ss, s);
13325 out << s << std::endl;
13329 out <<
">>" << std::endl;
13333 out <<
")" << std::endl;
13341 out <<
"Structured";
13342 if (ids !=
nullptr) {
13343 out <<
"@" << ids->get_ref(node);
13347 out <<
" # " << *loc;
13352 out <<
"annotations: ";
13354 out <<
"[]" << std::endl;
13356 out <<
"[" << std::endl;
13359 if (!sptr.empty()) {
13360 sptr->visit(*
this);
13363 out <<
"!NULL" << std::endl;
13368 out <<
"]" << std::endl;
13372 out <<
")" << std::endl;
13380 out <<
"Subcircuit";
13381 if (ids !=
nullptr) {
13382 out <<
"@" << ids->get_ref(node);
13386 out <<
" # " << *loc;
13392 if (node.
name.empty()) {
13393 out <<
"!MISSING" << std::endl;
13395 out <<
"<" << std::endl;
13397 node.
name.visit(*
this);
13400 out <<
">" << std::endl;
13403 out <<
"iterations: ";
13405 out <<
"-" << std::endl;
13407 out <<
"<" << std::endl;
13412 out <<
">" << std::endl;
13415 out <<
"annotations: ";
13417 out <<
"[]" << std::endl;
13419 out <<
"[" << std::endl;
13422 if (!sptr.empty()) {
13423 sptr->visit(*
this);
13426 out <<
"!NULL" << std::endl;
13431 out <<
"]" << std::endl;
13435 out <<
")" << std::endl;
13444 if (ids !=
nullptr) {
13445 out <<
"@" << ids->get_ref(node);
13449 out <<
" # " << *loc;
13455 if (node.
lhs.empty()) {
13456 out <<
"!MISSING" << std::endl;
13458 out <<
"<" << std::endl;
13460 node.
lhs.visit(*
this);
13463 out <<
">" << std::endl;
13467 if (node.
rhs.empty()) {
13468 out <<
"!MISSING" << std::endl;
13470 out <<
"<" << std::endl;
13472 node.
rhs.visit(*
this);
13475 out <<
">" << std::endl;
13479 out <<
")" << std::endl;
13487 out <<
"TernaryCond";
13488 if (ids !=
nullptr) {
13489 out <<
"@" << ids->get_ref(node);
13493 out <<
" # " << *loc;
13499 if (node.
cond.empty()) {
13500 out <<
"!MISSING" << std::endl;
13502 out <<
"<" << std::endl;
13504 node.
cond.visit(*
this);
13507 out <<
">" << std::endl;
13510 out <<
"if_true: ";
13512 out <<
"!MISSING" << std::endl;
13514 out <<
"<" << std::endl;
13519 out <<
">" << std::endl;
13522 out <<
"if_false: ";
13524 out <<
"!MISSING" << std::endl;
13526 out <<
"<" << std::endl;
13531 out <<
">" << std::endl;
13535 out <<
")" << std::endl;
13544 if (ids !=
nullptr) {
13545 out <<
"@" << ids->get_ref(node);
13549 out <<
" # " << *loc;
13555 if (node.
expr.empty()) {
13556 out <<
"!MISSING" << std::endl;
13558 out <<
"<" << std::endl;
13560 node.
expr.visit(*
this);
13563 out <<
">" << std::endl;
13567 out <<
")" << std::endl;
13575 out <<
"Variables";
13576 if (ids !=
nullptr) {
13577 out <<
"@" << ids->get_ref(node);
13581 out <<
" # " << *loc;
13587 if (node.
names.empty()) {
13588 out <<
"!MISSING" << std::endl;
13590 out <<
"[" << std::endl;
13592 for (
auto &sptr : node.
names) {
13593 if (!sptr.empty()) {
13594 sptr->visit(*
this);
13597 out <<
"!NULL" << std::endl;
13602 out <<
"]" << std::endl;
13606 if (node.
typ.empty()) {
13607 out <<
"!MISSING" << std::endl;
13609 out <<
"<" << std::endl;
13611 node.
typ.visit(*
this);
13614 out <<
">" << std::endl;
13617 out <<
"annotations: ";
13619 out <<
"[]" << std::endl;
13621 out <<
"[" << std::endl;
13624 if (!sptr.empty()) {
13625 sptr->visit(*
this);
13628 out <<
"!NULL" << std::endl;
13633 out <<
"]" << std::endl;
13637 out <<
")" << std::endl;
13646 if (ids !=
nullptr) {
13647 out <<
"@" << ids->get_ref(node);
13651 out <<
" # " << *loc;
13657 std::stringstream ss;
13660 pos = ss.str().find_last_not_of(
" \n\r\t");
13661 if (pos != std::string::npos) {
13662 ss.str(ss.str().erase(pos+1));
13664 if (ss.str().find(
'\n') == std::string::npos) {
13665 out << ss.str() << std::endl;
13667 out <<
"cqasm::v1::primitives::Version<<" << std::endl;
13670 while (!ss.eof()) {
13671 std::getline(ss, s);
13673 out << s << std::endl;
13677 out <<
">>" << std::endl;
13681 out <<
")" << std::endl;
13689 out <<
"WhileLoop";
13690 if (ids !=
nullptr) {
13691 out <<
"@" << ids->get_ref(node);
13695 out <<
" # " << *loc;
13700 out <<
"condition: ";
13702 out <<
"!MISSING" << std::endl;
13704 out <<
"<" << std::endl;
13709 out <<
">" << std::endl;
13713 if (node.
body.empty()) {
13714 out <<
"!MISSING" << std::endl;
13716 out <<
"<" << std::endl;
13718 node.
body.visit(*
this);
13721 out <<
">" << std::endl;
13724 out <<
"annotations: ";
13726 out <<
"[]" << std::endl;
13728 out <<
"[" << std::endl;
13731 if (!sptr.empty()) {
13732 sptr->visit(*
this);
13735 out <<
"!NULL" << std::endl;
13740 out <<
"]" << std::endl;
13744 out <<
")" << std::endl;
13759 const_cast<Node&
>(object).
dump(os);
The file version identifier.
IndexList * as_index_list() override
Interprets this node to a node of type IndexList.
void visit_break_statement(BreakStatement &node) override
Recursive traversal for BreakStatement nodes.
void visit_index_item(IndexItem &node) override
Dumps a IndexItem node.
void raw_visit_index_list(IndexList &node, void *retval) override
Internal visitor function for IndexList nodes.
void visit_erroneous_statement(ErroneousStatement &node) override
Dumps a ErroneousStatement node.
Many< ExpressionList > rows
The list of rows in the matrix.
cqasm::v1::primitives::Version items
The list of version components, ordered major to minor.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
NodeType type() const override
Returns the NodeType of this node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_cmp_ne(CmpNe &node) override
Dumps a CmpNe node.
One< Node > clone() const override
Returns a deep copy of this node.
bool equals(const Node &rhs) const override
Value-based equality operator.
void raw_visit_arith_op(ArithOp &node, void *retval) override
Internal visitor function for ArithOp nodes.
virtual void raw_visit_bitwise_and(BitwiseAnd &node, void *retval)=0
Internal visitor function for BitwiseAnd nodes.
virtual IndexItem * as_index_item()
Interprets this node to a node of type IndexItem.
NodeType type() const override
Returns the NodeType of this node.
void visit_integer_literal(IntegerLiteral &node) override
Recursive traversal for IntegerLiteral nodes.
NodeType type() const override
Returns the NodeType of this node.
static std::shared_ptr< ForeachLoop > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual IntegerLiteral * as_integer_literal()
Interprets this node to a node of type IntegerLiteral.
NodeType type() const override
Returns the NodeType of this node.
virtual Statement * as_statement()
Interprets this node to a node of type Statement.
static std::shared_ptr< AnnotationData > 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 visit_binary_op(BinaryOp &node) override
Recursive traversal for BinaryOp nodes.
virtual NodeType type() const =0
Returns the NodeType of this node.
BitwiseXor(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
NodeType type() const override
Returns the NodeType of this node.
virtual Identifier * as_identifier()
Interprets this node to a node of type Identifier.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
One< Expression > lhs
Reference to the variable used for looping.
A floating point literal.
Integer division operator.
virtual void raw_visit_bitwise_not(BitwiseNot &node, void *retval)=0
Internal visitor function for BitwiseNot nodes.
Subtract(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void visit_cmp_le(CmpLe &node) override
Dumps a CmpLe node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
virtual LogicalOp * as_logical_op()
Interprets this node to a node of type LogicalOp.
void visit_json_literal(JsonLiteral &node) override
Recursive traversal for JsonLiteral nodes.
Many< Identifier > names
Name of the variables.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Add is complete/fully defined.
One< Expression > if_false
The result if cond is false.
virtual Instruction * as_instruction()
Interprets this node to a node of type Instruction.
NodeType type() const override
Returns the NodeType of this node.
void raw_visit_assignment(Assignment &node, void *retval) override
Internal visitor function for Assignment nodes.
void visit_repeat_until_loop(RepeatUntilLoop &node) override
Recursive traversal for RepeatUntilLoop nodes.
ShiftOp * as_shift_op() override
Interprets this node to a node of type ShiftOp.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Bundle is complete/fully defined.
ErroneousStatement * as_erroneous_statement() override
Interprets this node to a node of type ErroneousStatement.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
static std::shared_ptr< IntegerLiteral > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void raw_visit_while_loop(WhileLoop &node, void *retval) override
Internal visitor function for WhileLoop nodes.
Many< IndexEntry > items
The list of indices.
virtual ShiftRightArith * as_shift_right_arith()
Interprets this node to a node of type ShiftRightArith.
One< Node > clone() const override
Returns a deep copy of this node.
virtual void raw_visit_function_call(FunctionCall &node, void *retval)=0
Internal visitor function for FunctionCall nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
One< Version > version
File version.
void visit_bitwise_or(BitwiseOr &node) override
Recursive traversal for BitwiseOr nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ErroneousStatement is complete/fully defined.
void visit_statement_list(StatementList &node) override
Dumps a StatementList node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this IndexList is complete/fully defined.
bool equals(const Node &rhs) const override
Value-based equality operator.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_erroneous_expression(ErroneousExpression &node) override
Recursive traversal for ErroneousExpression nodes.
AnnotationData(const One< Identifier > &interface=One< Identifier >(), const One< Identifier > &operation=One< Identifier >(), const One< ExpressionList > &operands=One< ExpressionList >())
Constructor.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
Placeholder for an expression with a parse error.
One< Node > copy() const override
Returns a shallow copy of this node.
One< Node > clone() const override
Returns a deep copy of this node.
void raw_visit_shift_op(ShiftOp &node, void *retval) override
Internal visitor function for ShiftOp nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_instruction(Instruction &node) override
Dumps a Instruction node.
Internal class for implementing the visitor pattern.
static std::shared_ptr< BreakStatement > 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.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
virtual Power * as_power()
Interprets this node to a node of type Power.
virtual void raw_visit_index_range(IndexRange &node, void *retval)=0
Internal visitor function for IndexRange nodes.
void raw_visit_cmp_gt(CmpGt &node, void *retval) override
Internal visitor function for CmpGt nodes.
void visit_index_item(IndexItem &node) override
Recursive traversal for IndexItem nodes.
void visit_erroneous_program(ErroneousProgram &node) override
Dumps a ErroneousProgram node.
virtual IntDivide * as_int_divide()
Interprets this node to a node of type IntDivide.
One< Node > clone() const override
Returns a deep copy of this node.
void raw_visit_root(Root &node, void *retval) override
Internal visitor function for Root nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_continue_statement(ContinueStatement &node) override
Recursive traversal for ContinueStatement nodes.
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.
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 CmpLt is complete/fully defined.
Represents a node that carries annotation data.
IndexItem(const One< Expression > &index=One< Expression >())
Constructor.
Statement * as_statement() override
Interprets this node to a node of type Statement.
static std::shared_ptr< CmpEq > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< LogicalXor > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Placeholder for a program with a parse error.
NodeType type() const override
Returns the NodeType of this node.
virtual Multiply * as_multiply()
Interprets this node to a node of type Multiply.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void raw_visit_logical_op(LogicalOp &node, void *retval) override
Internal visitor function for LogicalOp nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
BitwiseNot(const One< Expression > &expr=One< Expression >())
Constructor.
void raw_visit_node(Node &node, void *retval) override
Internal visitor function for nodes of any type.
void visit_shift_right_arith(ShiftRightArith &node) override
Dumps a ShiftRightArith node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
NodeType type() const override
Returns the NodeType of this node.
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 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.
static std::shared_ptr< Subcircuit > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
static std::shared_ptr< LogicalOr > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_mapping(Mapping &node) override
Recursive traversal for Mapping nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Node > clone() const override
Returns a deep copy of this node.
One< Node > copy() const override
Returns a shallow copy of this node.
One< Node > clone() const override
Returns a deep copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void raw_visit_annotation_data(AnnotationData &node, void *retval) override
Internal visitor function for AnnotationData nodes.
virtual void raw_visit_int_divide(IntDivide &node, void *retval)=0
Internal visitor function for IntDivide nodes.
NodeType type() const override
Returns the NodeType of this node.
virtual Annotated * as_annotated()
Interprets this node to a node of type Annotated.
virtual IfElseBranch * as_if_else_branch()
Interprets this node to a node of type IfElseBranch.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Subtract is complete/fully defined.
void raw_visit_structured(Structured &node, void *retval) override
Internal visitor function for Structured nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Identifier > operation
The operation within the interface that this annotation is intended for.
One< Node > clone() const override
Returns a deep copy of this node.
void visit_version(Version &node) override
Dumps a Version node.
void visit_statement(Statement &node) override
Dumps a Statement node.
static std::shared_ptr< StringLiteral > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual void raw_visit_subtract(Subtract &node, void *retval)=0
Internal visitor function for Subtract nodes.
virtual IndexRange * as_index_range()
Interprets this node to a node of type IndexRange.
NodeType type() const override
Returns the NodeType of this node.
virtual void raw_visit_string_literal(StringLiteral &node, void *retval)=0
Internal visitor function for StringLiteral nodes.
void visit_binary_op(BinaryOp &node) override
Dumps a BinaryOp node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Power is complete/fully defined.
One< Node > clone() const override
Returns a deep copy of this node.
FunctionCall(const One< Identifier > &name=One< Identifier >(), const One< ExpressionList > &arguments=One< ExpressionList >())
Constructor.
void raw_visit_expression(Expression &node, void *retval) override
Internal visitor function for Expression nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
NodeType type() const override
Returns the NodeType of this node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_negate(Negate &node) override
Recursive traversal for Negate nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
LogicalAnd * as_logical_and() override
Interprets this node to a node of type LogicalAnd.
static std::shared_ptr< IndexItem > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
One< Expression > lhs
The left-hand side of the expression.
virtual TernaryCond * as_ternary_cond()
Interprets this node to a node of type TernaryCond.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
JsonLiteral * as_json_literal() override
Interprets this node to a node of type JsonLiteral.
static std::shared_ptr< IfElseBranch > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
ShiftLeft * as_shift_left() override
Interprets this node to a node of type ShiftLeft.
NodeType type() const override
Returns the NodeType of this node.
void raw_visit_erroneous_expression(ErroneousExpression &node, void *retval) override
Internal visitor function for ErroneousExpression nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this BitwiseOr is complete/fully defined.
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.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
virtual FloatLiteral * as_float_literal()
Interprets this node to a node of type FloatLiteral.
void visit_instruction(Instruction &node) override
Recursive traversal for Instruction nodes.
void visit_structured(Structured &node) override
Dumps a Structured node.
NodeType
Enumeration of all node types.
void visit_function_call(FunctionCall &node) override
Dumps a FunctionCall node.
virtual void raw_visit_mapping(Mapping &node, void *retval)=0
Internal visitor function for Mapping nodes.
virtual void raw_visit_cmp_le(CmpLe &node, void *retval)=0
Internal visitor function for CmpLe nodes.
One< ExpressionList > operands
Any operands attached to the annotation.
NodeType type() const override
Returns the NodeType of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
BinaryOp * as_binary_op() override
Interprets this node to a node of type BinaryOp.
void visit_index_range(IndexRange &node) override
Recursive traversal for IndexRange nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
One< Expression > lhs
Name of the variable being assigned.
static std::shared_ptr< Negate > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
One< Node > clone() const override
Returns a deep copy of this node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
MatrixLiteral(const Many< ExpressionList > &rows=Many< ExpressionList >())
Constructor.
NodeType type() const override
Returns the NodeType of this node.
Maybe< Expression > iterations
An optional integer expression representing the number of iterations for this subcircuit.
static std::shared_ptr< Node > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_erroneous_expression(ErroneousExpression &node) override
Dumps a ErroneousExpression node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
One< Identifier > name
The name of the subcircuit.
virtual void raw_visit_divide(Divide &node, void *retval)=0
Internal visitor function for Divide nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
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.
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.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
bool equals(const Node &rhs) const override
Value-based equality operator.
virtual void raw_visit_ternary_cond(TernaryCond &node, void *retval)=0
Internal visitor function for TernaryCond nodes.
void write_indent()
Writes the current indentation level's worth of spaces.
static std::shared_ptr< BitwiseAnd > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual ErroneousProgram * as_erroneous_program()
Interprets this node to a node of type ErroneousProgram.
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.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ErroneousExpression is complete/fully defined.
StatementList * as_statement_list() override
Interprets this node to a node of type StatementList.
static std::shared_ptr< Mapping > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
NodeType type() const override
Returns the NodeType of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this IndexItem is complete/fully defined.
BreakStatement * as_break_statement() override
Interprets this node to a node of type BreakStatement.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void visit_structured(Structured &node) override
Recursive traversal for Structured nodes.
One< Node > copy() const override
Returns a shallow copy of this node.
Identifier(const cqasm::v1::primitives::Str &name=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Str >())
Constructor.
A list of parallel instructions.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void raw_visit_shift_right_arith(ShiftRightArith &node, void *retval) override
Internal visitor function for ShiftRightArith nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
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.
AnnotationData * as_annotation_data() override
Interprets this node to a node of type AnnotationData.
bool equals(const Node &rhs) const override
Value-based equality operator.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
virtual ArithOp * as_arith_op()
Interprets this node to a node of type ArithOp.
void dump(std::ostream &out=std::cout, int indent=0)
Writes a debug dump of this node to the given stream.
bool equals(const Node &rhs) const override
Value-based equality operator.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
CmpOp * as_cmp_op() override
Interprets this node to a node of type CmpOp.
virtual void raw_visit_shift_right_logic(ShiftRightLogic &node, void *retval)=0
Internal visitor function for ShiftRightLogic nodes.
Placeholder for a statement with a parse error.
bool equals(const Node &rhs) const override
Value-based equality operator.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Index is complete/fully defined.
void visit_index(Index &node) override
Recursive traversal for Index nodes.
NodeType type() const override
Returns the NodeType of this node.
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.
Contains annotation objects used within the trees by libqasm.
virtual ForeachLoop * as_foreach_loop()
Interprets this node to a node of type ForeachLoop.
virtual void raw_visit_continue_statement(ContinueStatement &node, void *retval)=0
Internal visitor function for ContinueStatement nodes.
static std::shared_ptr< BitwiseOp > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual void raw_visit_cmp_eq(CmpEq &node, void *retval)=0
Internal visitor function for CmpEq nodes.
Represents a JSON literal.
virtual BitwiseOr * as_bitwise_or()
Interprets this node to a node of type BitwiseOr.
One< Node > clone() const override
Returns a deep copy of this node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
virtual Negate * as_negate()
Interprets this node to a node of type Negate.
Add(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void raw_visit_annotated(Annotated &node, void *retval) override
Internal visitor function for Annotated nodes.
virtual void raw_visit_annotation_data(AnnotationData &node, void *retval)=0
Internal visitor function for AnnotationData nodes.
Many< IfElseBranch > branches
The if-else branches.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_node(Node &node) override
Dumps a Node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Program is complete/fully defined.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Instruction is complete/fully defined.
void raw_visit_bundle(Bundle &node, void *retval) override
Internal visitor function for Bundle nodes.
One< Node > clone() const override
Returns a deep copy of this node.
Toplevel namespace with entry points for the new API.
bool equals(const Node &rhs) const override
Value-based equality operator.
Subcircuit(const One< Identifier > &name=One< Identifier >(), const Maybe< Expression > &iterations=Maybe< Expression >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
One< Node > clone() const override
Returns a deep copy of this node.
NodeType type() const override
Returns the NodeType of this node.
virtual Bundle * as_bundle()
Interprets this node to a node of type Bundle.
One< Node > clone() const override
Returns a deep copy of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this BitwiseAnd is complete/fully defined.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_expression(Expression &node) override
Dumps a Expression node.
NodeType type() const override
Returns the NodeType of this node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void raw_visit_if_else_branch(IfElseBranch &node, void *retval) override
Internal visitor function for IfElseBranch nodes.
void raw_visit_cmp_le(CmpLe &node, void *retval) override
Internal visitor function for CmpLe nodes.
CmpOp(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
static std::shared_ptr< ErroneousProgram > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Identifier is complete/fully defined.
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 serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
ForLoop * as_for_loop() override
Interprets this node to a node of type ForLoop.
One< Node > clone() const override
Returns a deep copy of this node.
Maybe< Assignment > initialize
The optional initializing assignment, run before the loop starts.
One< Node > clone() const override
Returns a deep copy of this node.
bool equals(const Node &rhs) const override
Value-based equality operator.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void raw_visit_string_literal(StringLiteral &node, void *retval) override
Internal visitor function for StringLiteral nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ForeachLoop is complete/fully defined.
Structured * as_structured() override
Interprets this node to a node of type Structured.
static std::shared_ptr< ForLoop > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
One< Expression > to
The last value.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_shift_right_logic(ShiftRightLogic &node) override
Recursive traversal for ShiftRightLogic nodes.
NodeType type() const override
Returns the NodeType of this node.
void visit_negate(Negate &node) override
Dumps a Negate node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void raw_visit_subtract(Subtract &node, void *retval) override
Internal visitor function for Subtract nodes.
LogicalXor * as_logical_xor() override
Interprets this node to a node of type LogicalXor.
One< Node > copy() const override
Returns a shallow copy of this node.
void raw_visit_version(Version &node, void *retval) override
Internal visitor function for Version nodes.
FloatLiteral(const cqasm::v1::primitives::Real &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Real >())
Constructor.
void raw_visit_bitwise_not(BitwiseNot &node, void *retval) override
Internal visitor function for BitwiseNot nodes.
virtual void raw_visit_shift_right_arith(ShiftRightArith &node, void *retval)=0
Internal visitor function for ShiftRightArith nodes.
virtual void raw_visit_logical_xor(LogicalXor &node, void *retval)=0
Internal visitor function for LogicalXor nodes.
virtual Variables * as_variables()
Interprets this node to a node of type Variables.
One< Node > clone() const override
Returns a deep copy of this node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
NodeType type() const override
Returns the NodeType of this node.
void visit_matrix_literal(MatrixLiteral &node) override
Recursive traversal for MatrixLiteral nodes.
RepeatUntilLoop * as_repeat_until_loop() override
Interprets this node to a node of type RepeatUntilLoop.
void visit_add(Add &node) override
Dumps a Add node.
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.
void visit_annotation_data(AnnotationData &node) override
Recursive traversal for AnnotationData nodes.
One< Node > clone() const override
Returns a deep copy of this node.
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.
bool equals(const Node &rhs) const override
Value-based equality operator.
void raw_visit_program(Program &node, void *retval) override
Internal visitor function for Program nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this WhileLoop is complete/fully defined.
CmpGe * as_cmp_ge() override
Interprets this node to a node of type CmpGe.
void visit_repeat_until_loop(RepeatUntilLoop &node) override
Dumps a RepeatUntilLoop node.
Logical/unsigned shift-right operator (shifts in zero).
One< Node > clone() const override
Returns a deep copy of this node.
One< Node > copy() const override
Returns a shallow copy of this node.
A mapping (alias) for an expression.
NodeType type() const override
Returns the NodeType of this node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
NodeType type() const override
Returns the NodeType of this node.
void visit_foreach_loop(ForeachLoop &node) override
Recursive traversal for ForeachLoop nodes.
void raw_visit_continue_statement(ContinueStatement &node, void *retval) override
Internal visitor function for ContinueStatement nodes.
virtual void raw_visit_for_loop(ForLoop &node, void *retval)=0
Internal visitor function for ForLoop nodes.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< MatrixLiteral > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
NodeType type() const override
Returns the NodeType of this node.
static std::shared_ptr< Bundle > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_bitwise_or(BitwiseOr &node) override
Dumps a BitwiseOr node.
static std::shared_ptr< BitwiseNot > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
One< Expression > condition
The condition.
void visit_bitwise_and(BitwiseAnd &node) override
Recursive traversal for BitwiseAnd nodes.
void raw_visit_index_entry(IndexEntry &node, void *retval) override
Internal visitor function for IndexEntry nodes.
Source location annotation object, containing source file line numbers etc.
void raw_visit_subcircuit(Subcircuit &node, void *retval) override
Internal visitor function for Subcircuit nodes.
void dump_seq(std::ostream &out=std::cout, int indent=0)
Alternate debug dump that represents links and node uniqueness via sequence number tags...
void visit_statement_list(StatementList &node) override
Recursive traversal for StatementList nodes.
virtual void raw_visit_if_else_branch(IfElseBranch &node, void *retval)=0
Internal visitor function for IfElseBranch nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
Negate(const One< Expression > &expr=One< Expression >())
Constructor.
One< Node > clone() const override
Returns a deep copy of this node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
A single condition + block for use in an if-else chain.
static std::shared_ptr< Statement > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
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.
void raw_visit_shift_right_logic(ShiftRightLogic &node, void *retval) override
Internal visitor function for ShiftRightLogic nodes.
NodeType type() const override
Returns the NodeType of this node.
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 ShiftRightArith is complete/fully defined.
void raw_visit_modulo(Modulo &node, void *retval) override
Internal visitor function for Modulo nodes.
virtual Subtract * as_subtract()
Interprets this node to a node of type Subtract.
void visit_if_else(IfElse &node) override
Recursive traversal for IfElse nodes.
void visit_index_entry(IndexEntry &node) override
Dumps a IndexEntry node.
virtual void raw_visit_logical_or(LogicalOr &node, void *retval)=0
Internal visitor function for LogicalOr nodes.
double Real
Real number primitive used within the AST and semantic trees.
One< Node > clone() const override
Returns a deep copy of this node.
One< Node > clone() const override
Returns a deep copy of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ExpressionList is complete/fully defined.
void visit_annotated(Annotated &node) override
Recursive traversal for Annotated nodes.
ArithOp(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_arith_op(ArithOp &node) override
Dumps a ArithOp node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_bitwise_xor(BitwiseXor &node) override
Dumps a BitwiseXor node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
virtual LogicalNot * as_logical_not()
Interprets this node to a node of type LogicalNot.
virtual Mapping * as_mapping()
Interprets this node to a node of type Mapping.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void visit_cmp_gt(CmpGt &node) override
Recursive traversal for CmpGt nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
virtual ContinueStatement * as_continue_statement()
Interprets this node to a node of type ContinueStatement.
virtual void raw_visit_if_else(IfElse &node, void *retval)=0
Internal visitor function for IfElse nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_erroneous_statement(ErroneousStatement &node) override
Recursive traversal for ErroneousStatement nodes.
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 Negate is complete/fully defined.
void visit_expression_list(ExpressionList &node) override
Recursive traversal for ExpressionList nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
An assignment statement within a loop definition.
void visit_cmp_ne(CmpNe &node) override
Recursive traversal for CmpNe nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
NodeType type() const override
Returns the NodeType of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this MatrixLiteral is complete/fully defined.
virtual ErroneousExpression * as_erroneous_expression()
Interprets this node to a node of type ErroneousExpression.
void raw_visit_binary_op(BinaryOp &node, void *retval) override
Internal visitor function for BinaryOp nodes.
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.
One< Node > clone() const override
Returns a deep copy of this node.
One< Expression > first
An integer expression representing the first index.
void visit_index_list(IndexList &node) override
Dumps a IndexList node.
bool equals(const Node &rhs) const override
Value-based equality operator.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
One< StatementList > body
The loop body.
One< Node > clone() const override
Returns a deep copy of this node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
static std::shared_ptr< IndexRange > 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.
void visit_bitwise_op(BitwiseOp &node) override
Recursive traversal for BitwiseOp nodes.
One< Expression > expr
The expression being indexed.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
LogicalAnd(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
cqasm::tree::Any< T > Any
CmpNe * as_cmp_ne() override
Interprets this node to a node of type CmpNe.
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_logical_or(LogicalOr &node, void *retval) override
Internal visitor function for LogicalOr nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
BitwiseAnd * as_bitwise_and() override
Interprets this node to a node of type BitwiseAnd.
virtual void raw_visit_logical_and(LogicalAnd &node, void *retval)=0
Internal visitor function for LogicalAnd nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
static std::shared_ptr< IndexList > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
std::int64_t Int
Integer primitive used within the AST and semantic trees.
One< Node > clone() const override
Returns a deep copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_ternary_cond(TernaryCond &node) override
Dumps a TernaryCond node.
virtual Program * as_program()
Interprets this node to a node of type Program.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
NodeType type() const override
Returns the NodeType of this node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_root(Root &node) override
Dumps a Root node.
bool equals(const Node &rhs) const override
Value-based equality operator.
static std::shared_ptr< Version > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_bundle(Bundle &node) override
Dumps a Bundle node.
One< Node > clone() const override
Returns a deep 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 visit_variables(Variables &node) override
Dumps a Variables node.
void visit_program(Program &node) override
Recursive traversal for Program nodes.
void visit_bundle(Bundle &node) override
Recursive traversal for Bundle nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Subcircuit is complete/fully defined.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
cqasm::tree::Many< T > Many
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_power(Power &node) override
Dumps a Power node.
void visit_expression(Expression &node) override
Recursive traversal for Expression nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
Identifier * as_identifier() override
Interprets this node to a node of type Identifier.
One< Identifier > name
Name identifying the instruction.
void raw_visit_power(Power &node, void *retval) override
Internal visitor function for Power nodes.
One< Expression > last
An integer expression representing the last index.
cqasm::v1::primitives::Str value
The string literal.
Main class for all nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
A list of one or more indices.
NodeType type() const override
Returns the NodeType of this node.
virtual LogicalOr * as_logical_or()
Interprets this node to a node of type LogicalOr.
void visit_divide(Divide &node) override
Recursive traversal for Divide nodes.
virtual void raw_visit_cmp_gt(CmpGt &node, void *retval)=0
Internal visitor function for CmpGt nodes.
void visit_int_divide(IntDivide &node) override
Dumps a IntDivide node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
Version * as_version() override
Interprets this node to a node of type Version.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void raw_visit_unary_op(UnaryOp &node, void *retval) override
Internal visitor function for UnaryOp nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
static std::shared_ptr< ExpressionList > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< ShiftOp > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual BitwiseOp * as_bitwise_op()
Interprets this node to a node of type BitwiseOp.
static std::shared_ptr< ShiftLeft > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
Instruction * as_instruction() override
Interprets this node to a node of type Instruction.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this LogicalOr is complete/fully defined.
static std::shared_ptr< Assignment > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Version number primitive used within the AST and semantic trees.
void visit_logical_and(LogicalAnd &node) override
Dumps a LogicalAnd node.
void raw_visit_erroneous_statement(ErroneousStatement &node, void *retval) override
Internal visitor function for ErroneousStatement nodes.
LogicalNot * as_logical_not() override
Interprets this node to a node of type LogicalNot.
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.
virtual CmpLt * as_cmp_lt()
Interprets this node to a node of type CmpLt.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this LogicalXor is complete/fully defined.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
NodeType type() const override
Returns the NodeType of this node.
static std::shared_ptr< TernaryCond > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< StatementList > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
BreakStatement(const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
bool equals(const Node &rhs) const override
Value-based equality operator.
Maybe< StatementList > otherwise
The final else block, if any.
std::ostream & operator<<(std::ostream &os, const Node &object)
Stream << overload for tree nodes (writes debug dump).
Add * as_add() override
Interprets this node to a node of type Add.
void visit_identifier(Identifier &node) override
Dumps a Identifier node.
virtual void raw_visit_assignment(Assignment &node, void *retval)=0
Internal visitor function for Assignment nodes.
virtual CmpOp * as_cmp_op()
Interprets this node to a node of type CmpOp.
void visit_erroneous_program(ErroneousProgram &node) override
Recursive traversal for ErroneousProgram nodes.
void visit_divide(Divide &node) override
Dumps a Divide node.
One< StatementList > statements
The statement list.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Expression > frm
The first value.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
CmpGt * as_cmp_gt() override
Interprets this node to a node of type CmpGt.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_cmp_ge(CmpGe &node) override
Dumps a CmpGe node.
void visit_unary_op(UnaryOp &node) override
Dumps a UnaryOp node.
CmpLt * as_cmp_lt() override
Interprets this node to a node of type CmpLt.
void visit_bitwise_not(BitwiseNot &node) override
Recursive traversal for BitwiseNot nodes.
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 LogicalAnd is complete/fully defined.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< Annotated > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
NodeType type() const override
Returns the NodeType of this node.
NodeType type() const override
Returns the NodeType of this node.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Node > copy() const override
Returns a shallow copy of this node.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_cmp_ge(CmpGe &node) override
Recursive traversal for CmpGe nodes.
One< Expression > condition
The condition for starting another iteration.
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.
bool equals(const Node &rhs) const override
Value-based equality operator.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
static std::shared_ptr< LogicalNot > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
ErroneousStatement(const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
One< Node > copy() const override
Returns a shallow copy of this node.
Bundle(const Many< Instruction > &items=Many< Instruction >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
Version(const cqasm::v1::primitives::Version &items=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Version >())
Constructor.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this StringLiteral is complete/fully defined.
virtual void raw_visit_statement_list(StatementList &node, void *retval)=0
Internal visitor function for StatementList nodes.
One or more variable declaration for some type.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< IfElse > 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.
virtual CmpEq * as_cmp_eq()
Interprets this node to a node of type CmpEq.
Program * as_program() override
Interprets this node to a node of type Program.
Represents a matrix literal.
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.
Visitor class that debug-dumps a tree to a stream.
void raw_visit_integer_literal(IntegerLiteral &node, void *retval) override
Internal visitor function for IntegerLiteral nodes.
void raw_visit_statement(Statement &node, void *retval) override
Internal visitor function for Statement nodes.
void visit_shift_left(ShiftLeft &node) override
Recursive traversal for ShiftLeft nodes.
A single index in an index list.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this CmpGt is complete/fully defined.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_if_else_branch(IfElseBranch &node) override
Recursive traversal for IfElseBranch nodes.
One< Node > clone() const override
Returns a deep copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_subtract(Subtract &node) override
Recursive traversal for Subtract nodes.
virtual void raw_visit_foreach_loop(ForeachLoop &node, void *retval)=0
Internal visitor function for ForeachLoop nodes.
cqasm::v1::primitives::Int value
The integer.
void raw_visit_bitwise_op(BitwiseOp &node, void *retval) override
Internal visitor function for BitwiseOp nodes.
void visit_multiply(Multiply &node) override
Recursive traversal for Multiply nodes.
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.
One< IndexList > indices
The list of indices.
cqasm::tree::One< T > One
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
IndexEntry * as_index_entry() override
Interprets this node to a node of type IndexEntry.
One< Node > clone() const override
Returns a deep 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 visit_identifier(Identifier &node) override
Recursive traversal for Identifier nodes.
Any version 1.2+ structured control-flow statement.
void visit_cmp_gt(CmpGt &node) override
Dumps a CmpGt node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
static std::shared_ptr< Power > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
NodeType type() const override
Returns the NodeType of this node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
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.
static std::shared_ptr< WhileLoop > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< Program > 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.
One< Node > copy() const override
Returns a shallow copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this CmpNe is complete/fully defined.
void raw_visit_mapping(Mapping &node, void *retval) override
Internal visitor function for Mapping nodes.
virtual LogicalAnd * as_logical_and()
Interprets this node to a node of type LogicalAnd.
ShiftRightArith(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
static std::shared_ptr< Structured > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
cqasm::v1::primitives::Str name
The identifier.
Represents an annotation.
virtual void raw_visit_logical_not(LogicalNot &node, void *retval)=0
Internal visitor function for LogicalNot nodes.
void raw_visit_shift_left(ShiftLeft &node, void *retval) override
Internal visitor function for ShiftLeft nodes.
One< ExpressionList > operands
Operands for the instruction.
static std::shared_ptr< FloatLiteral > 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.
static std::shared_ptr< ArithOp > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< IndexEntry > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
FunctionCall * as_function_call() override
Interprets this node to a node of type FunctionCall.
One< Node > copy() const override
Returns a shallow copy of this node.
virtual void raw_visit_index(Index &node, void *retval)=0
Internal visitor function for Index nodes.
void visit_while_loop(WhileLoop &node) override
Recursive traversal for WhileLoop nodes.
T initialize()
Generates a default value for the given primitive type.
One< Node > clone() const override
Returns a deep copy of this node.
void visit_version(Version &node) override
Recursive traversal for Version nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
Maybe< Expression > num_qubits
Integer expression indicating the number of qubits.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
static std::shared_ptr< FunctionCall > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_ternary_cond(TernaryCond &node) override
Recursive traversal for TernaryCond nodes.
Arithmetic/signed shift-right operator (shifts in sign).
MatrixLiteral * as_matrix_literal() override
Interprets this node to a node of type MatrixLiteral.
bool equals(const Node &rhs) const override
Value-based equality operator.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
Multiply * as_multiply() override
Interprets this node to a node of type Multiply.
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_statement_list(StatementList &node, void *retval) override
Internal visitor function for StatementList nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
ContinueStatement(const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
One< StatementList > body
The body.
virtual CmpNe * as_cmp_ne()
Interprets this node to a node of type CmpNe.
IntDivide(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void raw_visit_ternary_cond(TernaryCond &node, void *retval) override
Internal visitor function for TernaryCond nodes.
ShiftRightArith * as_shift_right_arith() override
Interprets this node to a node of type ShiftRightArith.
One< Node > clone() const override
Returns a deep copy of this node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this BitwiseNot is complete/fully defined.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
bool equals(const Node &rhs) const override
Value-based equality operator.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this IntDivide is complete/fully defined.
virtual IfElse * as_if_else()
Interprets this node to a node of type IfElse.
FloatLiteral * as_float_literal() override
Interprets this node to a node of type FloatLiteral.
One< Node > clone() const override
Returns a deep copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
One< Node > copy() const override
Returns a shallow copy of this node.
virtual Add * as_add()
Interprets this node to a node of type Add.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
static std::shared_ptr< RepeatUntilLoop > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Index * as_index() override
Interprets this node to a node of type Index.
void visit_foreach_loop(ForeachLoop &node) override
Dumps a ForeachLoop node.
static std::shared_ptr< Divide > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
NodeType type() const override
Returns the NodeType of this node.
One< Node > clone() const override
Returns a deep copy of this node.
BitwiseXor * as_bitwise_xor() override
Interprets this node to a node of type BitwiseXor.
Annotated(const Any< AnnotationData > &annotations=Any< AnnotationData >())
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.
NodeType type() const override
Returns the NodeType of this node.
void visit_index(Index &node) override
Dumps a Index node.
virtual RepeatUntilLoop * as_repeat_until_loop()
Interprets this node to a node of type RepeatUntilLoop.
virtual Expression * as_expression()
Interprets this node to a node of type Expression.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_bitwise_and(BitwiseAnd &node) override
Dumps a BitwiseAnd node.
virtual void raw_visit_erroneous_program(ErroneousProgram &node, void *retval)=0
Internal visitor function for ErroneousProgram nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
virtual void raw_visit_erroneous_statement(ErroneousStatement &node, void *retval)=0
Internal visitor function for ErroneousStatement nodes.
virtual void raw_visit_bitwise_xor(BitwiseXor &node, void *retval)=0
Internal visitor function for BitwiseXor nodes.
CmpEq * as_cmp_eq() override
Interprets this node to a node of type CmpEq.
One< StatementList > body
The loop body.
Modulo * as_modulo() override
Interprets this node to a node of type Modulo.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_mapping(Mapping &node) override
Dumps a Mapping node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
virtual ExpressionList * as_expression_list()
Interprets this node to a node of type ExpressionList.
void raw_visit_repeat_until_loop(RepeatUntilLoop &node, void *retval) override
Internal visitor function for RepeatUntilLoop nodes.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_continue_statement(ContinueStatement &node) override
Dumps a ContinueStatement node.
bool equals(const Node &rhs) const override
Value-based equality operator.
Expression * as_expression() override
Interprets this node to a node of type Expression.
virtual StatementList * as_statement_list()
Interprets this node to a node of type StatementList.
void visit_power(Power &node) override
Recursive traversal for Power nodes.
One< Node > clone() const override
Returns a deep copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
static std::shared_ptr< Subtract > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_bitwise_not(BitwiseNot &node) override
Dumps a BitwiseNot node.
void visit_statement(Statement &node) override
Recursive traversal for Statement nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_bitwise_xor(BitwiseXor &node) override
Recursive traversal for BitwiseXor nodes.
void visit_bitwise_op(BitwiseOp &node) override
Dumps a BitwiseOp node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Divide is complete/fully defined.
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 ContinueStatement is complete/fully defined.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
Program(const One< Version > &version=One< Version >(), const Maybe< Expression > &num_qubits=Maybe< Expression >(), const One< StatementList > &statements=One< StatementList >())
Constructor.
One< Identifier > interface
The interface this annotation is intended for.
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 find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
Namespace for the "new" cQASM 1.x API.
NodeType type() const override
Returns the NodeType of this node.
virtual Modulo * as_modulo()
Interprets this node to a node of type Modulo.
NodeType type() const override
Returns the NodeType of this node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
ExpressionList * as_expression_list() override
Interprets this node to a node of type ExpressionList.
void raw_visit_cmp_eq(CmpEq &node, void *retval) override
Internal visitor function for CmpEq nodes.
An inclusive range of indices in an index list.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this CmpLe is complete/fully defined.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_shift_right_arith(ShiftRightArith &node) override
Recursive traversal for ShiftRightArith nodes.
LogicalOr * as_logical_or() override
Interprets this node to a node of type LogicalOr.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
An entry in an index list.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this JsonLiteral is complete/fully defined.
Multiply(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
One< Identifier > name
The name of the function.
Negation operator (two's complement).
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.
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.
One< Node > clone() const override
Returns a deep copy of this node.
void visit_annotated(Annotated &node) override
Dumps a Annotated node.
One< ExpressionList > arguments
The function arguments.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< CmpLe > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_logical_not(LogicalNot &node) override
Recursive traversal for LogicalNot nodes.
void visit_cmp_eq(CmpEq &node) override
Dumps a CmpEq node.
virtual FunctionCall * as_function_call()
Interprets this node to a node of type FunctionCall.
cqasm::tree::Maybe< T > Maybe
void raw_visit_logical_and(LogicalAnd &node, void *retval) override
Internal visitor function for LogicalAnd nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this LogicalNot 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 visit_cmp_lt(CmpLt &node) override
Dumps a CmpLt node.
ExpressionList(const Any< Expression > &items=Any< Expression >())
Constructor.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Variables is complete/fully defined.
BitwiseOr * as_bitwise_or() override
Interprets this node to a node of type BitwiseOr.
IfElse * as_if_else() override
Interprets this node to a node of type IfElse.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
virtual JsonLiteral * as_json_literal()
Interprets this node to a node of type JsonLiteral.
void raw_visit_bitwise_or(BitwiseOr &node, void *retval) override
Internal visitor function for BitwiseOr nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ForLoop is complete/fully defined.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
ArithOp * as_arith_op() override
Interprets this node to a node of type ArithOp.
Structured(const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
void raw_visit_index(Index &node, void *retval) override
Internal visitor function for Index nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
NodeType type() const override
Returns the NodeType of this node.
Root * as_root() override
Interprets this node to a node of type Root.
virtual ErroneousStatement * as_erroneous_statement()
Interprets this node to a node of type ErroneousStatement.
Power(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
One< Node > clone() const override
Returns a deep copy of this node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
static std::shared_ptr< IntDivide > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_cmp_eq(CmpEq &node) override
Recursive traversal for CmpEq nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
StringLiteral(const cqasm::v1::primitives::Str &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Str >())
Constructor.
BinaryOp(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
static std::shared_ptr< Root > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void raw_visit_add(Add &node, void *retval) override
Internal visitor function for Add nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
virtual void raw_visit_shift_left(ShiftLeft &node, void *retval)=0
Internal visitor function for ShiftLeft nodes.
One< Node > clone() const override
Returns a deep copy of this node.
IntegerLiteral * as_integer_literal() override
Interprets this node to a node of type IntegerLiteral.
void visit_assignment(Assignment &node) override
Dumps a Assignment node.
One< Node > clone() const override
Returns a deep copy of this node.
CmpLe * as_cmp_le() override
Interprets this node to a node of type CmpLe.
void visit_logical_or(LogicalOr &node) override
Recursive traversal for LogicalOr nodes.
virtual void raw_visit_erroneous_expression(ErroneousExpression &node, void *retval)=0
Internal visitor function for ErroneousExpression nodes.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void raw_visit_foreach_loop(ForeachLoop &node, void *retval) override
Internal visitor function for ForeachLoop nodes.
void visit_program(Program &node) override
Dumps a Program node.
NodeType type() const override
Returns the NodeType of this node.
BitwiseOp(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
NodeType type() const override
Returns the NodeType of this node.
virtual MatrixLiteral * as_matrix_literal()
Interprets this node to a node of type MatrixLiteral.
One< Node > clone() const override
Returns a deep copy of this node.
One< Expression > rhs
The right-hand side of the expression.
void visit_index_range(IndexRange &node) override
Dumps a IndexRange node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
virtual CmpLe * as_cmp_le()
Interprets this node to a node of type CmpLe.
LogicalOr(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
Greater-than-or-equal operator.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_annotation_data(AnnotationData &node) override
Dumps a AnnotationData node.
One< Node > clone() const override
Returns a deep copy of this node.
virtual BitwiseNot * as_bitwise_not()
Interprets this node to a node of type BitwiseNot.
One< Identifier > alias
The identifier used to refer to the expression.
ForLoop(const Maybe< Assignment > &initialize=Maybe< Assignment >(), const One< Expression > &condition=One< Expression >(), const Maybe< Assignment > &update=Maybe< Assignment >(), const One< StatementList > &body=One< StatementList >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
One< Expression > cond
The boolean condition for selection.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
ForeachLoop(const One< Expression > &lhs=One< Expression >(), const One< Expression > &frm=One< Expression >(), const One< Expression > &to=One< Expression >(), const One< StatementList > &body=One< StatementList >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
virtual IndexEntry * as_index_entry()
Interprets this node to a node of type IndexEntry.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
One< Node > copy() const override
Returns a shallow copy of this node.
virtual void raw_visit_bundle(Bundle &node, void *retval)=0
Internal visitor function for Bundle nodes.
void visit_logical_and(LogicalAnd &node) override
Recursive traversal for LogicalAnd nodes.
void raw_visit_multiply(Multiply &node, void *retval) override
Internal visitor function for Multiply nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
IfElseBranch(const One< Expression > &condition=One< Expression >(), const One< StatementList > &body=One< StatementList >())
Constructor.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this FunctionCall is complete/fully defined.
virtual void raw_visit_version(Version &node, void *retval)=0
Internal visitor function for Version nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
std::string Str
String primitive used within the AST and semantic trees.
Bundle * as_bundle() override
Interprets this node to a node of type Bundle.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
cqasm::v1::primitives::Str value
The JSON literal.
virtual Assignment * as_assignment()
Interprets this node to a node of type Assignment.
void visit_shift_op(ShiftOp &node) override
Dumps a ShiftOp node.
bool equals(const Node &rhs) const override
Value-based equality operator.
StringLiteral * as_string_literal() override
Interprets this node to a node of type StringLiteral.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
virtual void raw_visit_expression_list(ExpressionList &node, void *retval)=0
Internal visitor function for ExpressionList nodes.
static std::shared_ptr< Multiply > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< BinaryOp > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
Statement(const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
Mapping(const One< Identifier > &alias=One< Identifier >(), const One< Expression > &expr=One< Expression >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
void visit_logical_xor(LogicalXor &node) override
Recursive traversal for LogicalXor nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_logical_not(LogicalNot &node) override
Dumps a LogicalNot node.
virtual void raw_visit_modulo(Modulo &node, void *retval)=0
Internal visitor function for Modulo nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
static std::shared_ptr< CmpOp > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void raw_visit_erroneous_program(ErroneousProgram &node, void *retval) override
Internal visitor function for ErroneousProgram nodes.
void raw_visit_logical_xor(LogicalXor &node, void *retval) override
Internal visitor function for LogicalXor nodes.
virtual void raw_visit_while_loop(WhileLoop &node, void *retval)=0
Internal visitor function for WhileLoop nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_add(Add &node) override
Recursive traversal for Add nodes.
NodeType type() const override
Returns the NodeType of this node.
virtual AnnotationData * as_annotation_data()
Interprets this node to a node of type AnnotationData.
void raw_visit_negate(Negate &node, void *retval) override
Internal visitor function for Negate nodes.
virtual void raw_visit_identifier(Identifier &node, void *retval)=0
Internal visitor function for Identifier nodes.
Many< Instruction > items
The list of parallel instructions.
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.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ErroneousProgram is complete/fully defined.
void visit_cmp_op(CmpOp &node) override
Recursive traversal for CmpOp nodes.
virtual ShiftOp * as_shift_op()
Interprets this node to a node of type ShiftOp.
virtual void raw_visit_break_statement(BreakStatement &node, void *retval)=0
Internal visitor function for BreakStatement nodes.
virtual IndexList * as_index_list()
Interprets this node to a node of type IndexList.
ShiftLeft(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void raw_visit_divide(Divide &node, void *retval) override
Internal visitor function for Divide nodes.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< Instruction > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
cqasm::v1::primitives::Real value
The floating point number.
void visit_for_loop(ForLoop &node) override
Recursive traversal for ForLoop nodes.
virtual UnaryOp * as_unary_op()
Interprets this node to a node of type UnaryOp.
virtual ShiftLeft * as_shift_left()
Interprets this node to a node of type ShiftLeft.
void raw_visit_index_item(IndexItem &node, void *retval) override
Internal visitor function for IndexItem nodes.
virtual Divide * as_divide()
Interprets this node to a node of type Divide.
BitwiseOp * as_bitwise_op() override
Interprets this node to a node of type BitwiseOp.
bool equals(const Node &rhs) const override
Value-based equality operator.
void raw_visit_logical_not(LogicalNot &node, void *retval) override
Internal visitor function for LogicalNot nodes.
NodeType type() const override
Returns the NodeType of this node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
static std::shared_ptr< Variables > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
NodeType type() const override
Returns the NodeType of this node.
virtual LogicalXor * as_logical_xor()
Interprets this node to a node of type LogicalXor.
void visit_break_statement(BreakStatement &node) override
Dumps a BreakStatement 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< Expression > expr
The expression being operated on.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this BreakStatement is complete/fully defined.
CmpLe(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
One< Node > copy() const override
Returns a shallow copy of this node.
virtual void raw_visit_multiply(Multiply &node, void *retval)=0
Internal visitor function for Multiply nodes.
void visit_logical_op(LogicalOp &node) override
Recursive traversal for LogicalOp nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
static std::shared_ptr< Add > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this RepeatUntilLoop is complete/fully defined.
IfElseBranch * as_if_else_branch() override
Interprets this node to a node of type IfElseBranch.
One< Node > clone() const override
Returns a deep copy of this node.
One< Node > copy() const override
Returns a shallow copy of this node.
virtual void raw_visit_negate(Negate &node, void *retval)=0
Internal visitor function for Negate nodes.
Power * as_power() override
Interprets this node to a node of type Power.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
TernaryCond * as_ternary_cond() override
Interprets this node to a node of type TernaryCond.
void raw_visit_bitwise_xor(BitwiseXor &node, void *retval) override
Internal visitor function for BitwiseXor nodes.
NodeType type() const override
Returns the NodeType of this node.
void visit_unary_op(UnaryOp &node) override
Recursive traversal for UnaryOp nodes.
virtual bool equals(const Node &rhs) const =0
Value-based equality operator.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
virtual void raw_visit_power(Power &node, void *retval)=0
Internal visitor function for Power nodes.
static std::shared_ptr< CmpNe > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Assignment * as_assignment() override
Interprets this node to a node of type Assignment.
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 IndexRange is complete/fully defined.
void visit_index_entry(IndexEntry &node) override
Recursive traversal for IndexEntry nodes.
Negate * as_negate() override
Interprets this node to a node of type Negate.
virtual void raw_visit_cmp_lt(CmpLt &node, void *retval)=0
Internal visitor function for CmpLt nodes.
Subcircuit * as_subcircuit() override
Interprets this node to a node of type Subcircuit.
void raw_visit_matrix_literal(MatrixLiteral &node, void *retval) override
Internal visitor function for MatrixLiteral nodes.
void visit_while_loop(WhileLoop &node) override
Dumps a WhileLoop node.
bool equals(const Node &rhs) const override
Value-based equality operator.
CmpEq(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_float_literal(FloatLiteral &node) override
Recursive traversal for FloatLiteral nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
static std::shared_ptr< LogicalOp > 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 find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
Subtract * as_subtract() override
Interprets this node to a node of type Subtract.
void raw_visit_json_literal(JsonLiteral &node, void *retval) override
Internal visitor function for JsonLiteral nodes.
void visit_if_else(IfElse &node) override
Dumps a IfElse node.
NodeType type() const override
Returns the NodeType of this node.
One< Expression > rhs
Value being assigned to the variable.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this ShiftLeft is complete/fully defined.
bool equals(const Node &rhs) const override
Value-based equality operator.
IndexList(const Many< IndexEntry > &items=Many< IndexEntry >())
Constructor.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
IndexRange(const One< Expression > &first=One< Expression >(), const One< Expression > &last=One< Expression >())
Constructor.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< Index > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< ContinueStatement > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
static std::shared_ptr< CmpGt > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Represents a string literal.
virtual Structured * as_structured()
Interprets this node to a node of type Structured.
void visit_shift_left(ShiftLeft &node) override
Dumps a ShiftLeft node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this TernaryCond is complete/fully defined.
void raw_visit_variables(Variables &node, void *retval) override
Internal visitor function for Variables nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
virtual ShiftRightLogic * as_shift_right_logic()
Interprets this node to a node of type ShiftRightLogic.
NodeType type() const override
Returns the NodeType of this node.
One< Node > clone() const override
Returns a deep copy of this node.
RepeatUntilLoop(const One< StatementList > &body=One< StatementList >(), const One< Expression > &condition=One< Expression >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Mapping is complete/fully defined.
Any< Statement > items
The list of statements.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
Divide * as_divide() override
Interprets this node to a node of type Divide.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this IfElseBranch is complete/fully defined.
One< Identifier > typ
Name of the type.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
bool equals(const Node &rhs) const override
Value-based equality operator.
UnaryOp(const One< Expression > &expr=One< Expression >())
Constructor.
Less-than-or-equal operator.
LogicalOp(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void visit_function_call(FunctionCall &node) override
Recursive traversal for FunctionCall nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_subcircuit(Subcircuit &node) override
Dumps a Subcircuit node.
static std::shared_ptr< BitwiseOr > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual BitwiseXor * as_bitwise_xor()
Interprets this node to a node of type BitwiseXor.
void visit_shift_op(ShiftOp &node) override
Recursive traversal for ShiftOp nodes.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this CmpEq is complete/fully defined.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
T visit(Visitor< T > &visitor)
Visit this object.
void visit_float_literal(FloatLiteral &node) override
Dumps a FloatLiteral node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
Assignment(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
One< Node > copy() const override
Returns a shallow copy of this node.
void raw_visit_cmp_lt(CmpLt &node, void *retval) override
Internal visitor function for CmpLt nodes.
static std::shared_ptr< ErroneousStatement > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this BitwiseXor is complete/fully defined.
LogicalNot(const One< Expression > &expr=One< Expression >())
Constructor.
void visit_multiply(Multiply &node) override
Dumps a Multiply node.
ForeachLoop * as_foreach_loop() override
Interprets this node to a node of type ForeachLoop.
Divide(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
void visit_subcircuit(Subcircuit &node) override
Recursive traversal for Subcircuit nodes.
UnaryOp * as_unary_op() override
Interprets this node to a node of type UnaryOp.
ShiftRightLogic(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
Any< Expression > items
The list of expressions.
virtual void raw_visit_instruction(Instruction &node, void *retval)=0
Internal visitor function for Instruction nodes.
virtual void raw_visit_integer_literal(IntegerLiteral &node, void *retval)=0
Internal visitor function for IntegerLiteral nodes.
void raw_visit_float_literal(FloatLiteral &node, void *retval) override
Internal visitor function for FloatLiteral nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void visit_logical_xor(LogicalXor &node) override
Dumps a LogicalXor node.
void visit_root(Root &node) override
Recursive traversal for Root nodes.
IntegerLiteral(const cqasm::v1::primitives::Int &value=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Int >())
Constructor.
One< Node > copy() const override
Returns a shallow copy of this node.
LogicalXor(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
One< StatementList > body
The loop body.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this AnnotationData is complete/fully defined.
BitwiseNot * as_bitwise_not() override
Interprets this node to a node of type BitwiseNot.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
IndexRange * as_index_range() override
Interprets this node to a node of type IndexRange.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this StatementList 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< Expression > expr
The aliased expression.
JsonLiteral(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.
One< Node > copy() const override
Returns a shallow copy of this node.
Maybe< Assignment > update
The updating assignment, done at the end of the loop body and upon continue.
virtual Root * as_root()
Interprets this node to a node of type Root.
virtual CmpGt * as_cmp_gt()
Interprets this node to a node of type CmpGt.
NodeType type() const override
Returns the NodeType of this node.
ShiftRightLogic * as_shift_right_logic() override
Interprets this node to a node of type ShiftRightLogic.
void raw_visit_break_statement(BreakStatement &node, void *retval) override
Internal visitor function for BreakStatement nodes.
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 FloatLiteral is complete/fully defined.
Modulo(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
NodeType type() const override
Returns the NodeType of this node.
Variables * as_variables() override
Interprets this node to a node of type Variables.
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< Expression > condition
The condition for starting another iteration.
void raw_visit_index_range(IndexRange &node, void *retval) override
Internal visitor function for IndexRange nodes.
NodeType type() const override
Returns the NodeType of this node.
Variables(const Many< Identifier > &names=Many< Identifier >(), const One< Identifier > &typ=One< Identifier >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
Mapping * as_mapping() override
Interprets this node to a node of type Mapping.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_arith_op(ArithOp &node) override
Recursive traversal for ArithOp nodes.
One< Node > copy() const override
Returns a shallow copy of this node.
One< Node > copy() const override
Returns a shallow copy of this node.
static std::shared_ptr< JsonLiteral > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Maybe< Expression > condition
Optional conditional expression.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
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 find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
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.
virtual Index * as_index()
Interprets this node to a node of type Index.
WhileLoop(const One< Expression > &condition=One< Expression >(), const One< StatementList > &body=One< StatementList >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
virtual void raw_visit_index_list(IndexList &node, void *retval)=0
Internal visitor function for IndexList nodes.
static std::shared_ptr< CmpLt > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
NodeType type() const override
Returns the NodeType of this node.
WhileLoop * as_while_loop() override
Interprets this node to a node of type WhileLoop.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
void raw_visit_bitwise_and(BitwiseAnd &node, void *retval) override
Internal visitor function for BitwiseAnd nodes.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
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.
void visit_expression_list(ExpressionList &node) override
Dumps a ExpressionList node.
bool equals(const Node &rhs) const override
Value-based equality operator.
void raw_visit_cmp_op(CmpOp &node, void *retval) override
Internal visitor function for CmpOp nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
NodeType type() const override
Returns the NodeType of this node.
One< Expression > index
An integer expression representing the index.
static std::shared_ptr< ShiftRightLogic > 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.
void visit_json_literal(JsonLiteral &node) override
Dumps a JsonLiteral node.
bool equals(const Node &rhs) const override
Value-based equality operator.
One< Node > copy() const override
Returns a shallow copy of this node.
virtual void raw_visit_program(Program &node, void *retval)=0
Internal visitor function for Program nodes.
ErroneousProgram * as_erroneous_program() override
Interprets this node to a node of type ErroneousProgram.
CmpLt(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
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 ShiftRightLogic is complete/fully defined.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< UnaryOp > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
Any root node for the AST.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_matrix_literal(MatrixLiteral &node) override
Dumps a MatrixLiteral node.
NodeType type() const override
Returns the NodeType of this node.
One< Node > clone() const override
Returns a deep copy of this node.
Annotated * as_annotated() override
Interprets this node to a node of type Annotated.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this CmpGe is complete/fully defined.
void raw_visit_identifier(Identifier &node, void *retval) override
Internal visitor function for Identifier nodes.
void visit_string_literal(StringLiteral &node) override
Recursive traversal for StringLiteral nodes.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
CmpGe(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this IntegerLiteral is complete/fully defined.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
IntDivide * as_int_divide() override
Interprets this node to a node of type IntDivide.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Assignment is complete/fully defined.
void raw_visit_function_call(FunctionCall &node, void *retval) override
Internal visitor function for FunctionCall nodes.
NodeType type() const override
Returns the NodeType of this node.
virtual void raw_visit_matrix_literal(MatrixLiteral &node, void *retval)=0
Internal visitor function for MatrixLiteral nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
virtual CmpGe * as_cmp_ge()
Interprets this node to a node of type CmpGe.
void visit_index_list(IndexList &node) override
Recursive traversal for IndexList nodes.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
CmpGt(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
One< Node > clone() const override
Returns a deep copy of this node.
void visit_logical_op(LogicalOp &node) override
Dumps a LogicalOp node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Version is complete/fully defined.
IfElse(const Many< IfElseBranch > &branches=Many< IfElseBranch >(), const Maybe< StatementList > &otherwise=Maybe< StatementList >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
One< Node > clone() const override
Returns a deep copy of this node.
NodeType type() const override
Returns the NodeType of this node.
void visit_variables(Variables &node) override
Recursive traversal for Variables nodes.
virtual void raw_visit_json_literal(JsonLiteral &node, void *retval)=0
Internal visitor function for JsonLiteral nodes.
virtual void raw_visit_cmp_ne(CmpNe &node, void *retval)=0
Internal visitor function for CmpNe nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void visit_string_literal(StringLiteral &node) override
Dumps a StringLiteral node.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
ErroneousExpression * as_erroneous_expression() override
Interprets this node to a node of type ErroneousExpression.
CmpNe(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void visit_cmp_op(CmpOp &node) override
Dumps a CmpOp node.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this Multiply is complete/fully defined.
ShiftOp(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void raw_visit_int_divide(IntDivide &node, void *retval) override
Internal visitor function for IntDivide nodes.
void raw_visit_cmp_ge(CmpGe &node, void *retval) override
Internal visitor function for CmpGe nodes.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_for_loop(ForLoop &node) override
Dumps a ForLoop node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
LogicalOp * as_logical_op() override
Interprets this node to a node of type LogicalOp.
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.
virtual StringLiteral * as_string_literal()
Interprets this node to a node of type StringLiteral.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
One< Node > copy() const override
Returns a shallow copy of this node.
One< StatementList > body
The loop body.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_cmp_le(CmpLe &node) override
Recursive traversal for CmpLe nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
One< Expression > if_true
The result if cond is true.
bool equals(const Node &rhs) const override
Value-based equality operator.
BitwiseOr(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
TernaryCond(const One< Expression > &cond=One< Expression >(), const One< Expression > &if_true=One< Expression >(), const One< Expression > &if_false=One< Expression >())
Constructor.
virtual ForLoop * as_for_loop()
Interprets this node to a node of type ForLoop.
One< Node > copy() const override
Returns a shallow copy of this node.
Header file for the abstract syntax tree node classes.
BitwiseAnd(const One< Expression > &lhs=One< Expression >(), const One< Expression > &rhs=One< Expression >())
Constructor.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
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_subtract(Subtract &node) override
Dumps a Subtract node.
NodeType type() const override
Returns the NodeType of this node.
NodeType type() const override
Returns the NodeType of this node.
void raw_visit_if_else(IfElse &node, void *retval) override
Internal visitor function for IfElse nodes.
static std::shared_ptr< ErroneousExpression > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void raw_visit_instruction(Instruction &node, void *retval) override
Internal visitor function for Instruction nodes.
void raw_visit_expression_list(ExpressionList &node, void *retval) override
Internal visitor function for ExpressionList nodes.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
void visit_int_divide(IntDivide &node) override
Recursive traversal for IntDivide nodes.
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.
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_modulo(Modulo &node) override
Dumps a Modulo node.
One< Node > copy() const override
Returns a shallow copy of this node.
One< Node > clone() const override
Returns a deep copy of this node.
One< Node > clone() const override
Returns a deep copy of this node.
static std::shared_ptr< Modulo > 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.
void raw_visit_for_loop(ForLoop &node, void *retval) override
Internal visitor function for ForLoop nodes.
virtual BreakStatement * as_break_statement()
Interprets this node to a node of type BreakStatement.
One< Node > copy() const override
Returns a shallow copy of this node.
static std::shared_ptr< Identifier > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
ContinueStatement * as_continue_statement() override
Interprets this node to a node of type ContinueStatement.
void visit_logical_or(LogicalOr &node) override
Dumps a LogicalOr node.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
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 Modulo is complete/fully defined.
virtual void raw_visit_repeat_until_loop(RepeatUntilLoop &node, void *retval)=0
Internal visitor function for RepeatUntilLoop nodes.
virtual BinaryOp * as_binary_op()
Interprets this node to a node of type BinaryOp.
static std::shared_ptr< ShiftRightArith > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
IndexItem * as_index_item() override
Interprets this node to a node of type IndexItem.
virtual void raw_visit_variables(Variables &node, void *retval)=0
Internal visitor function for Variables nodes.
static std::shared_ptr< LogicalAnd > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
virtual void raw_visit_bitwise_or(BitwiseOr &node, void *retval)=0
Internal visitor function for BitwiseOr nodes.
Represents a comma-separated list of expressions.
virtual void raw_visit_add(Add &node, void *retval)=0
Internal visitor function for Add 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.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
void visit_if_else_branch(IfElseBranch &node) override
Dumps a IfElseBranch node.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
virtual void raw_visit_index_item(IndexItem &node, void *retval)=0
Internal visitor function for IndexItem nodes.
One< Node > copy() const override
Returns a shallow copy of this node.
void visit_assignment(Assignment &node) override
Recursive traversal for Assignment nodes.
NodeType type() const override
Returns the NodeType of this node.
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.
void visit_modulo(Modulo &node) override
Recursive traversal for Modulo nodes.
virtual Subcircuit * as_subcircuit()
Interprets this node to a node of type Subcircuit.
virtual void raw_visit_subcircuit(Subcircuit &node, void *retval)=0
Internal visitor function for Subcircuit nodes.
StatementList(const Any< Statement > &items=Any< Statement >())
Constructor.
void check_complete(const ::tree::base::PointerMap &map) const override
Returns whether this IfElse is complete/fully defined.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
One< Expression > condition
The condition for stopping iteration.
void visit_shift_right_logic(ShiftRightLogic &node) override
Dumps a ShiftRightLogic node.
virtual WhileLoop * as_while_loop()
Interprets this node to a node of type WhileLoop.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
bool equals(const Node &rhs) const override
Value-based equality operator.
void visit_cmp_lt(CmpLt &node) override
Recursive traversal for CmpLt nodes.
virtual void raw_visit_cmp_ge(CmpGe &node, void *retval)=0
Internal visitor function for CmpGe nodes.
static std::shared_ptr< Expression > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Instruction(const One< Identifier > &name=One< Identifier >(), const Maybe< Expression > &condition=Maybe< Expression >(), const One< ExpressionList > &operands=One< ExpressionList >(), const Any< AnnotationData > &annotations=Any< AnnotationData >())
Constructor.
virtual Version * as_version()
Interprets this node to a node of type Version.
Bitwise NOT (one's complement).
void visit_internal(VisitorBase &visitor, void *retval) override
Helper method for visiting nodes.
Ternary conditional operator.
bool equals(const Node &rhs) const override
Value-based equality operator.
void serialize(::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
Serializes this node to the given map.
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.
Any< AnnotationData > annotations
Zero or more annotations attached to this object.
virtual void raw_visit_float_literal(FloatLiteral &node, void *retval)=0
Internal visitor function for FloatLiteral nodes.
One< Node > clone() const override
Returns a deep copy of this node.
NodeType type() const override
Returns the NodeType of this node.
void find_reachable(::tree::base::PointerMap &map) const override
Registers all reachable nodes with the given PointerMap.
bool operator==(const Node &rhs) const override
Pointer-based equality operator.
virtual BitwiseAnd * as_bitwise_and()
Interprets this node to a node of type BitwiseAnd.
void visit_integer_literal(IntegerLiteral &node) override
Dumps a IntegerLiteral node.
static std::shared_ptr< CmpGe > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
Index(const One< Expression > &expr=One< Expression >(), const One< IndexList > &indices=One< IndexList >())
Constructor.
static std::shared_ptr< BitwiseXor > deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
Deserializes the given node.
void raw_visit_cmp_ne(CmpNe &node, void *retval) override
Internal visitor function for CmpNe nodes.