libqasm
library for handling cQASM files
cqasm-v1-ast-gen.cpp
Go to the documentation of this file.
1 
5 #include "cqasm-annotations.hpp"
6 #include "cqasm-v1-ast-gen.hpp"
7 
8 namespace cqasm {
9 namespace v1 {
10 namespace ast {
11 
15 void Node::dump(std::ostream &out, int indent) {
16  auto dumper = Dumper(out, indent);
17  visit(dumper);
18 }
19 
24 void Node::dump_seq(std::ostream &out, int indent) {
25  ::tree::base::PointerMap ids;
26  ids.enable_exceptions = false;
27  ids.add_ref(*this);
28  find_reachable(ids);
29  auto dumper = Dumper(out, indent, &ids);
30  visit(dumper);
31 }
32 
38  return nullptr;
39 }
40 
45 const Add *Node::as_add() const {
46  return nullptr;
47 }
48 
54  return nullptr;
55 }
56 
61 const Annotated *Node::as_annotated() const {
62  return nullptr;
63 }
64 
70  return nullptr;
71 }
72 
78  return nullptr;
79 }
80 
86  return nullptr;
87 }
88 
93 const ArithOp *Node::as_arith_op() const {
94  return nullptr;
95 }
96 
102  return nullptr;
103 }
104 
110  return nullptr;
111 }
112 
118  return nullptr;
119 }
120 
125 const BinaryOp *Node::as_binary_op() const {
126  return nullptr;
127 }
128 
134  return nullptr;
135 }
136 
142  return nullptr;
143 }
144 
150  return nullptr;
151 }
152 
158  return nullptr;
159 }
160 
166  return nullptr;
167 }
168 
174  return nullptr;
175 }
176 
182  return nullptr;
183 }
184 
190  return nullptr;
191 }
192 
198  return nullptr;
199 }
200 
206  return nullptr;
207 }
208 
214  return nullptr;
215 }
216 
222  return nullptr;
223 }
224 
230  return nullptr;
231 }
232 
237 const Bundle *Node::as_bundle() const {
238  return nullptr;
239 }
240 
246  return nullptr;
247 }
248 
253 const CmpEq *Node::as_cmp_eq() const {
254  return nullptr;
255 }
256 
262  return nullptr;
263 }
264 
269 const CmpGe *Node::as_cmp_ge() const {
270  return nullptr;
271 }
272 
278  return nullptr;
279 }
280 
285 const CmpGt *Node::as_cmp_gt() const {
286  return nullptr;
287 }
288 
294  return nullptr;
295 }
296 
301 const CmpLe *Node::as_cmp_le() const {
302  return nullptr;
303 }
304 
310  return nullptr;
311 }
312 
317 const CmpLt *Node::as_cmp_lt() const {
318  return nullptr;
319 }
320 
326  return nullptr;
327 }
328 
333 const CmpNe *Node::as_cmp_ne() const {
334  return nullptr;
335 }
336 
342  return nullptr;
343 }
344 
349 const CmpOp *Node::as_cmp_op() const {
350  return nullptr;
351 }
352 
358  return nullptr;
359 }
360 
366  return nullptr;
367 }
368 
374  return nullptr;
375 }
376 
381 const Divide *Node::as_divide() const {
382  return nullptr;
383 }
384 
390  return nullptr;
391 }
392 
398  return nullptr;
399 }
400 
406  return nullptr;
407 }
408 
414  return nullptr;
415 }
416 
422  return nullptr;
423 }
424 
430  return nullptr;
431 }
432 
438  return nullptr;
439 }
440 
446  return nullptr;
447 }
448 
454  return nullptr;
455 }
456 
462  return nullptr;
463 }
464 
470  return nullptr;
471 }
472 
478  return nullptr;
479 }
480 
486  return nullptr;
487 }
488 
493 const ForLoop *Node::as_for_loop() const {
494  return nullptr;
495 }
496 
502  return nullptr;
503 }
504 
510  return nullptr;
511 }
512 
518  return nullptr;
519 }
520 
526  return nullptr;
527 }
528 
534  return nullptr;
535 }
536 
542  return nullptr;
543 }
544 
550  return nullptr;
551 }
552 
557 const IfElse *Node::as_if_else() const {
558  return nullptr;
559 }
560 
566  return nullptr;
567 }
568 
574  return nullptr;
575 }
576 
582  return nullptr;
583 }
584 
589 const Index *Node::as_index() const {
590  return nullptr;
591 }
592 
598  return nullptr;
599 }
600 
606  return nullptr;
607 }
608 
614  return nullptr;
615 }
616 
622  return nullptr;
623 }
624 
630  return nullptr;
631 }
632 
638  return nullptr;
639 }
640 
646  return nullptr;
647 }
648 
654  return nullptr;
655 }
656 
662  return nullptr;
663 }
664 
670  return nullptr;
671 }
672 
678  return nullptr;
679 }
680 
686  return nullptr;
687 }
688 
694  return nullptr;
695 }
696 
702  return nullptr;
703 }
704 
710  return nullptr;
711 }
712 
718  return nullptr;
719 }
720 
726  return nullptr;
727 }
728 
734  return nullptr;
735 }
736 
742  return nullptr;
743 }
744 
750  return nullptr;
751 }
752 
758  return nullptr;
759 }
760 
766  return nullptr;
767 }
768 
774  return nullptr;
775 }
776 
782  return nullptr;
783 }
784 
790  return nullptr;
791 }
792 
798  return nullptr;
799 }
800 
806  return nullptr;
807 }
808 
813 const Mapping *Node::as_mapping() const {
814  return nullptr;
815 }
816 
822  return nullptr;
823 }
824 
830  return nullptr;
831 }
832 
838  return nullptr;
839 }
840 
845 const Modulo *Node::as_modulo() const {
846  return nullptr;
847 }
848 
854  return nullptr;
855 }
856 
861 const Multiply *Node::as_multiply() const {
862  return nullptr;
863 }
864 
870  return nullptr;
871 }
872 
877 const Negate *Node::as_negate() const {
878  return nullptr;
879 }
880 
886  return nullptr;
887 }
888 
893 const Power *Node::as_power() const {
894  return nullptr;
895 }
896 
902  return nullptr;
903 }
904 
909 const Program *Node::as_program() const {
910  return nullptr;
911 }
912 
918  return nullptr;
919 }
920 
926  return nullptr;
927 }
928 
934  return nullptr;
935 }
936 
941 const Root *Node::as_root() const {
942  return nullptr;
943 }
944 
950  return nullptr;
951 }
952 
958  return nullptr;
959 }
960 
966  return nullptr;
967 }
968 
973 const ShiftOp *Node::as_shift_op() const {
974  return nullptr;
975 }
976 
982  return nullptr;
983 }
984 
990  return nullptr;
991 }
992 
998  return nullptr;
999 }
1000 
1006  return nullptr;
1007 }
1008 
1014  return nullptr;
1015 }
1016 
1022  return nullptr;
1023 }
1024 
1030  return nullptr;
1031 }
1032 
1038  return nullptr;
1039 }
1040 
1046  return nullptr;
1047 }
1048 
1054  return nullptr;
1055 }
1056 
1062  return nullptr;
1063 }
1064 
1070  return nullptr;
1071 }
1072 
1078  return nullptr;
1079 }
1080 
1086  return nullptr;
1087 }
1088 
1094  return nullptr;
1095 }
1096 
1101 const Subtract *Node::as_subtract() const {
1102  return nullptr;
1103 }
1104 
1110  return nullptr;
1111 }
1112 
1118  return nullptr;
1119 }
1120 
1126  return nullptr;
1127 }
1128 
1133 const UnaryOp *Node::as_unary_op() const {
1134  return nullptr;
1135 }
1136 
1142  return nullptr;
1143 }
1144 
1150  return nullptr;
1151 }
1152 
1158  return nullptr;
1159 }
1160 
1165 const Version *Node::as_version() const {
1166  return nullptr;
1167 }
1168 
1174  return nullptr;
1175 }
1176 
1182  return nullptr;
1183 }
1184 
1188 std::shared_ptr<Node> Node::deserialize(
1189  const ::tree::cbor::MapReader &map,
1190  ::tree::base::IdentifierMap &ids
1191 ) {
1192  auto type = map.at("@t").as_string();
1193  if (type == "Add") return Add::deserialize(map, ids);
1194  if (type == "AnnotationData") return AnnotationData::deserialize(map, ids);
1195  if (type == "Assignment") return Assignment::deserialize(map, ids);
1196  if (type == "BitwiseAnd") return BitwiseAnd::deserialize(map, ids);
1197  if (type == "BitwiseNot") return BitwiseNot::deserialize(map, ids);
1198  if (type == "BitwiseOr") return BitwiseOr::deserialize(map, ids);
1199  if (type == "BitwiseXor") return BitwiseXor::deserialize(map, ids);
1200  if (type == "BreakStatement") return BreakStatement::deserialize(map, ids);
1201  if (type == "Bundle") return Bundle::deserialize(map, ids);
1202  if (type == "CmpEq") return CmpEq::deserialize(map, ids);
1203  if (type == "CmpGe") return CmpGe::deserialize(map, ids);
1204  if (type == "CmpGt") return CmpGt::deserialize(map, ids);
1205  if (type == "CmpLe") return CmpLe::deserialize(map, ids);
1206  if (type == "CmpLt") return CmpLt::deserialize(map, ids);
1207  if (type == "CmpNe") return CmpNe::deserialize(map, ids);
1208  if (type == "ContinueStatement") return ContinueStatement::deserialize(map, ids);
1209  if (type == "Divide") return Divide::deserialize(map, ids);
1210  if (type == "ErroneousExpression") return ErroneousExpression::deserialize(map, ids);
1211  if (type == "ErroneousProgram") return ErroneousProgram::deserialize(map, ids);
1212  if (type == "ErroneousStatement") return ErroneousStatement::deserialize(map, ids);
1213  if (type == "ExpressionList") return ExpressionList::deserialize(map, ids);
1214  if (type == "FloatLiteral") return FloatLiteral::deserialize(map, ids);
1215  if (type == "ForLoop") return ForLoop::deserialize(map, ids);
1216  if (type == "ForeachLoop") return ForeachLoop::deserialize(map, ids);
1217  if (type == "FunctionCall") return FunctionCall::deserialize(map, ids);
1218  if (type == "Identifier") return Identifier::deserialize(map, ids);
1219  if (type == "IfElse") return IfElse::deserialize(map, ids);
1220  if (type == "IfElseBranch") return IfElseBranch::deserialize(map, ids);
1221  if (type == "Index") return Index::deserialize(map, ids);
1222  if (type == "IndexItem") return IndexItem::deserialize(map, ids);
1223  if (type == "IndexList") return IndexList::deserialize(map, ids);
1224  if (type == "IndexRange") return IndexRange::deserialize(map, ids);
1225  if (type == "Instruction") return Instruction::deserialize(map, ids);
1226  if (type == "IntDivide") return IntDivide::deserialize(map, ids);
1227  if (type == "IntegerLiteral") return IntegerLiteral::deserialize(map, ids);
1228  if (type == "JsonLiteral") return JsonLiteral::deserialize(map, ids);
1229  if (type == "LogicalAnd") return LogicalAnd::deserialize(map, ids);
1230  if (type == "LogicalNot") return LogicalNot::deserialize(map, ids);
1231  if (type == "LogicalOr") return LogicalOr::deserialize(map, ids);
1232  if (type == "LogicalXor") return LogicalXor::deserialize(map, ids);
1233  if (type == "Mapping") return Mapping::deserialize(map, ids);
1234  if (type == "MatrixLiteral") return MatrixLiteral::deserialize(map, ids);
1235  if (type == "Modulo") return Modulo::deserialize(map, ids);
1236  if (type == "Multiply") return Multiply::deserialize(map, ids);
1237  if (type == "Negate") return Negate::deserialize(map, ids);
1238  if (type == "Power") return Power::deserialize(map, ids);
1239  if (type == "Program") return Program::deserialize(map, ids);
1240  if (type == "RepeatUntilLoop") return RepeatUntilLoop::deserialize(map, ids);
1241  if (type == "ShiftLeft") return ShiftLeft::deserialize(map, ids);
1242  if (type == "ShiftRightArith") return ShiftRightArith::deserialize(map, ids);
1243  if (type == "ShiftRightLogic") return ShiftRightLogic::deserialize(map, ids);
1244  if (type == "StatementList") return StatementList::deserialize(map, ids);
1245  if (type == "StringLiteral") return StringLiteral::deserialize(map, ids);
1246  if (type == "Subcircuit") return Subcircuit::deserialize(map, ids);
1247  if (type == "Subtract") return Subtract::deserialize(map, ids);
1248  if (type == "TernaryCond") return TernaryCond::deserialize(map, ids);
1249  if (type == "Variables") return Variables::deserialize(map, ids);
1250  if (type == "Version") return Version::deserialize(map, ids);
1251  if (type == "WhileLoop") return WhileLoop::deserialize(map, ids);
1252  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1253 }
1254 
1260  return dynamic_cast<Expression*>(this);
1261 }
1262 
1268  return dynamic_cast<const Expression*>(this);
1269 }
1270 
1274 std::shared_ptr<Expression> Expression::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1275  auto type = map.at("@t").as_string();
1276  if (type == "IntegerLiteral") return IntegerLiteral::deserialize(map, ids);
1277  if (type == "FloatLiteral") return FloatLiteral::deserialize(map, ids);
1278  if (type == "Identifier") return Identifier::deserialize(map, ids);
1279  if (type == "MatrixLiteral") return MatrixLiteral::deserialize(map, ids);
1280  if (type == "StringLiteral") return StringLiteral::deserialize(map, ids);
1281  if (type == "JsonLiteral") return JsonLiteral::deserialize(map, ids);
1282  if (type == "FunctionCall") return FunctionCall::deserialize(map, ids);
1283  if (type == "Index") return Index::deserialize(map, ids);
1284  if (type == "Negate") return Negate::deserialize(map, ids);
1285  if (type == "BitwiseNot") return BitwiseNot::deserialize(map, ids);
1286  if (type == "LogicalNot") return LogicalNot::deserialize(map, ids);
1287  if (type == "Power") return Power::deserialize(map, ids);
1288  if (type == "Multiply") return Multiply::deserialize(map, ids);
1289  if (type == "Divide") return Divide::deserialize(map, ids);
1290  if (type == "IntDivide") return IntDivide::deserialize(map, ids);
1291  if (type == "Modulo") return Modulo::deserialize(map, ids);
1292  if (type == "Add") return Add::deserialize(map, ids);
1293  if (type == "Subtract") return Subtract::deserialize(map, ids);
1294  if (type == "ShiftLeft") return ShiftLeft::deserialize(map, ids);
1295  if (type == "ShiftRightArith") return ShiftRightArith::deserialize(map, ids);
1296  if (type == "ShiftRightLogic") return ShiftRightLogic::deserialize(map, ids);
1297  if (type == "CmpEq") return CmpEq::deserialize(map, ids);
1298  if (type == "CmpNe") return CmpNe::deserialize(map, ids);
1299  if (type == "CmpGt") return CmpGt::deserialize(map, ids);
1300  if (type == "CmpGe") return CmpGe::deserialize(map, ids);
1301  if (type == "CmpLt") return CmpLt::deserialize(map, ids);
1302  if (type == "CmpLe") return CmpLe::deserialize(map, ids);
1303  if (type == "BitwiseAnd") return BitwiseAnd::deserialize(map, ids);
1304  if (type == "BitwiseXor") return BitwiseXor::deserialize(map, ids);
1305  if (type == "BitwiseOr") return BitwiseOr::deserialize(map, ids);
1306  if (type == "LogicalAnd") return LogicalAnd::deserialize(map, ids);
1307  if (type == "LogicalXor") return LogicalXor::deserialize(map, ids);
1308  if (type == "LogicalOr") return LogicalOr::deserialize(map, ids);
1309  if (type == "TernaryCond") return TernaryCond::deserialize(map, ids);
1310  if (type == "ErroneousExpression") return ErroneousExpression::deserialize(map, ids);
1311  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1312 }
1313 
1318  : Expression(), lhs(lhs), rhs(rhs)
1319 {}
1320 
1326  return dynamic_cast<BinaryOp*>(this);
1327 }
1328 
1334  return dynamic_cast<const BinaryOp*>(this);
1335 }
1336 
1340 std::shared_ptr<BinaryOp> BinaryOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1341  auto type = map.at("@t").as_string();
1342  if (type == "Power") return Power::deserialize(map, ids);
1343  if (type == "Multiply") return Multiply::deserialize(map, ids);
1344  if (type == "Divide") return Divide::deserialize(map, ids);
1345  if (type == "IntDivide") return IntDivide::deserialize(map, ids);
1346  if (type == "Modulo") return Modulo::deserialize(map, ids);
1347  if (type == "Add") return Add::deserialize(map, ids);
1348  if (type == "Subtract") return Subtract::deserialize(map, ids);
1349  if (type == "ShiftLeft") return ShiftLeft::deserialize(map, ids);
1350  if (type == "ShiftRightArith") return ShiftRightArith::deserialize(map, ids);
1351  if (type == "ShiftRightLogic") return ShiftRightLogic::deserialize(map, ids);
1352  if (type == "CmpEq") return CmpEq::deserialize(map, ids);
1353  if (type == "CmpNe") return CmpNe::deserialize(map, ids);
1354  if (type == "CmpGt") return CmpGt::deserialize(map, ids);
1355  if (type == "CmpGe") return CmpGe::deserialize(map, ids);
1356  if (type == "CmpLt") return CmpLt::deserialize(map, ids);
1357  if (type == "CmpLe") return CmpLe::deserialize(map, ids);
1358  if (type == "BitwiseAnd") return BitwiseAnd::deserialize(map, ids);
1359  if (type == "BitwiseXor") return BitwiseXor::deserialize(map, ids);
1360  if (type == "BitwiseOr") return BitwiseOr::deserialize(map, ids);
1361  if (type == "LogicalAnd") return LogicalAnd::deserialize(map, ids);
1362  if (type == "LogicalXor") return LogicalXor::deserialize(map, ids);
1363  if (type == "LogicalOr") return LogicalOr::deserialize(map, ids);
1364  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1365 }
1366 
1371  : BinaryOp(lhs, rhs)
1372 {}
1373 
1379  return dynamic_cast<ArithOp*>(this);
1380 }
1381 
1387  return dynamic_cast<const ArithOp*>(this);
1388 }
1389 
1393 std::shared_ptr<ArithOp> ArithOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1394  auto type = map.at("@t").as_string();
1395  if (type == "Power") return Power::deserialize(map, ids);
1396  if (type == "Multiply") return Multiply::deserialize(map, ids);
1397  if (type == "Divide") return Divide::deserialize(map, ids);
1398  if (type == "IntDivide") return IntDivide::deserialize(map, ids);
1399  if (type == "Modulo") return Modulo::deserialize(map, ids);
1400  if (type == "Add") return Add::deserialize(map, ids);
1401  if (type == "Subtract") return Subtract::deserialize(map, ids);
1402  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1403 }
1404 
1409  : ArithOp(lhs, rhs)
1410 {}
1411 
1415 void Add::find_reachable(::tree::base::PointerMap &map) const {
1416  (void)map;
1417  lhs.find_reachable(map);
1418  rhs.find_reachable(map);
1419 }
1420 
1424 void Add::check_complete(const ::tree::base::PointerMap &map) const {
1425  (void)map;
1426  lhs.check_complete(map);
1427  rhs.check_complete(map);
1428 }
1429 
1434  return NodeType::Add;
1435 }
1436 
1440 void Add::visit_internal(VisitorBase &visitor, void *retval) {
1441  visitor.raw_visit_add(*this, retval);
1442 }
1443 
1449  return dynamic_cast<Add*>(this);
1450 }
1451 
1456 const Add *Add::as_add() const {
1457  return dynamic_cast<const Add*>(this);
1458 }
1459 
1464  return cqasm::tree::make<Add>(*this);
1465 }
1466 
1471  auto node = cqasm::tree::make<Add>(*this);
1472  node->lhs = this->lhs.clone();
1473  node->rhs = this->rhs.clone();
1474  return node;
1475 }
1476 
1480 bool Add::equals(const Node &rhs) const {
1481  if (rhs.type() != NodeType::Add) return false;
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;
1485  return true;
1486 }
1487 
1491 bool Add::operator==(const Node &rhs) const {
1492  if (rhs.type() != NodeType::Add) 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;
1496  return true;
1497 }
1498 
1503  ::tree::cbor::MapWriter &map,
1504  const ::tree::base::PointerMap &ids
1505 ) const {
1506  (void)ids;
1507  map.append_string("@t", "Add");
1508  auto submap = map.append_map("lhs");
1509  lhs.serialize(submap, ids);
1510  submap.close();
1511  submap = map.append_map("rhs");
1512  rhs.serialize(submap, ids);
1513  submap.close();
1514  serialize_annotations(map);
1515 }
1516 
1520 std::shared_ptr<Add> Add::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1521  (void)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);
1525  }
1526  auto node = std::make_shared<Add>(
1527  One<Expression>(map.at("lhs").as_map(), ids),
1528  One<Expression>(map.at("rhs").as_map(), ids)
1529  );
1530  node->deserialize_annotations(map);
1531  return node;
1532 }
1533 
1538  : annotations(annotations)
1539 {}
1540 
1546  return dynamic_cast<Annotated*>(this);
1547 }
1548 
1554  return dynamic_cast<const Annotated*>(this);
1555 }
1556 
1560 std::shared_ptr<Annotated> Annotated::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1561  auto type = map.at("@t").as_string();
1562  if (type == "Instruction") return Instruction::deserialize(map, ids);
1563  if (type == "Bundle") return Bundle::deserialize(map, ids);
1564  if (type == "Mapping") return Mapping::deserialize(map, ids);
1565  if (type == "Variables") return Variables::deserialize(map, ids);
1566  if (type == "Subcircuit") return Subcircuit::deserialize(map, ids);
1567  if (type == "IfElse") return IfElse::deserialize(map, ids);
1568  if (type == "ForLoop") return ForLoop::deserialize(map, ids);
1569  if (type == "ForeachLoop") return ForeachLoop::deserialize(map, ids);
1570  if (type == "WhileLoop") return WhileLoop::deserialize(map, ids);
1571  if (type == "RepeatUntilLoop") return RepeatUntilLoop::deserialize(map, ids);
1572  if (type == "BreakStatement") return BreakStatement::deserialize(map, ids);
1573  if (type == "ContinueStatement") return ContinueStatement::deserialize(map, ids);
1574  if (type == "ErroneousStatement") return ErroneousStatement::deserialize(map, ids);
1575  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1576 }
1577 
1581 AnnotationData::AnnotationData(const One<Identifier> &interface, const One<Identifier> &operation, const One<ExpressionList> &operands)
1582  : interface(interface), operation(operation), operands(operands)
1583 {}
1584 
1588 void AnnotationData::find_reachable(::tree::base::PointerMap &map) const {
1589  (void)map;
1590  interface.find_reachable(map);
1591  operation.find_reachable(map);
1592  operands.find_reachable(map);
1593 }
1594 
1598 void AnnotationData::check_complete(const ::tree::base::PointerMap &map) const {
1599  (void)map;
1600  interface.check_complete(map);
1601  operation.check_complete(map);
1602  operands.check_complete(map);
1603 }
1604 
1609  return NodeType::AnnotationData;
1610 }
1611 
1615 void AnnotationData::visit_internal(VisitorBase &visitor, void *retval) {
1616  visitor.raw_visit_annotation_data(*this, retval);
1617 }
1618 
1624  return dynamic_cast<AnnotationData*>(this);
1625 }
1626 
1632  return dynamic_cast<const AnnotationData*>(this);
1633 }
1634 
1639  return cqasm::tree::make<AnnotationData>(*this);
1640 }
1641 
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();
1650  return node;
1651 }
1652 
1656 bool AnnotationData::equals(const Node &rhs) const {
1657  if (rhs.type() != NodeType::AnnotationData) return false;
1658  auto rhsc = dynamic_cast<const AnnotationData&>(rhs);
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;
1662  return true;
1663 }
1664 
1668 bool AnnotationData::operator==(const Node &rhs) const {
1669  if (rhs.type() != NodeType::AnnotationData) return false;
1670  auto rhsc = dynamic_cast<const AnnotationData&>(rhs);
1671  if (this->interface != rhsc.interface) return false;
1672  if (this->operation != rhsc.operation) return false;
1673  if (this->operands != rhsc.operands) return false;
1674  return true;
1675 }
1676 
1681  ::tree::cbor::MapWriter &map,
1682  const ::tree::base::PointerMap &ids
1683 ) const {
1684  (void)ids;
1685  map.append_string("@t", "AnnotationData");
1686  auto submap = map.append_map("interface");
1687  interface.serialize(submap, ids);
1688  submap.close();
1689  submap = map.append_map("operation");
1690  operation.serialize(submap, ids);
1691  submap.close();
1692  submap = map.append_map("operands");
1693  operands.serialize(submap, ids);
1694  submap.close();
1695  serialize_annotations(map);
1696 }
1697 
1701 std::shared_ptr<AnnotationData> AnnotationData::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1702  (void)ids;
1703  auto type = map.at("@t").as_string();
1704  if (type != "AnnotationData") {
1705  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1706  }
1707  auto node = std::make_shared<AnnotationData>(
1708  One<Identifier>(map.at("interface").as_map(), ids),
1709  One<Identifier>(map.at("operation").as_map(), ids),
1710  One<ExpressionList>(map.at("operands").as_map(), ids)
1711  );
1712  node->deserialize_annotations(map);
1713  return node;
1714 }
1715 
1720  : lhs(lhs), rhs(rhs)
1721 {}
1722 
1726 void Assignment::find_reachable(::tree::base::PointerMap &map) const {
1727  (void)map;
1728  lhs.find_reachable(map);
1729  rhs.find_reachable(map);
1730 }
1731 
1735 void Assignment::check_complete(const ::tree::base::PointerMap &map) const {
1736  (void)map;
1737  lhs.check_complete(map);
1738  rhs.check_complete(map);
1739 }
1740 
1745  return NodeType::Assignment;
1746 }
1747 
1751 void Assignment::visit_internal(VisitorBase &visitor, void *retval) {
1752  visitor.raw_visit_assignment(*this, retval);
1753 }
1754 
1760  return dynamic_cast<Assignment*>(this);
1761 }
1762 
1768  return dynamic_cast<const Assignment*>(this);
1769 }
1770 
1775  return cqasm::tree::make<Assignment>(*this);
1776 }
1777 
1782  auto node = cqasm::tree::make<Assignment>(*this);
1783  node->lhs = this->lhs.clone();
1784  node->rhs = this->rhs.clone();
1785  return node;
1786 }
1787 
1791 bool Assignment::equals(const Node &rhs) const {
1792  if (rhs.type() != NodeType::Assignment) return false;
1793  auto rhsc = dynamic_cast<const Assignment&>(rhs);
1794  if (!this->lhs.equals(rhsc.lhs)) return false;
1795  if (!this->rhs.equals(rhsc.rhs)) return false;
1796  return true;
1797 }
1798 
1802 bool Assignment::operator==(const Node &rhs) const {
1803  if (rhs.type() != NodeType::Assignment) return false;
1804  auto rhsc = dynamic_cast<const Assignment&>(rhs);
1805  if (this->lhs != rhsc.lhs) return false;
1806  if (this->rhs != rhsc.rhs) return false;
1807  return true;
1808 }
1809 
1814  ::tree::cbor::MapWriter &map,
1815  const ::tree::base::PointerMap &ids
1816 ) const {
1817  (void)ids;
1818  map.append_string("@t", "Assignment");
1819  auto submap = map.append_map("lhs");
1820  lhs.serialize(submap, ids);
1821  submap.close();
1822  submap = map.append_map("rhs");
1823  rhs.serialize(submap, ids);
1824  submap.close();
1825  serialize_annotations(map);
1826 }
1827 
1831 std::shared_ptr<Assignment> Assignment::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1832  (void)ids;
1833  auto type = map.at("@t").as_string();
1834  if (type != "Assignment") {
1835  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1836  }
1837  auto node = std::make_shared<Assignment>(
1838  One<Expression>(map.at("lhs").as_map(), ids),
1839  One<Expression>(map.at("rhs").as_map(), ids)
1840  );
1841  node->deserialize_annotations(map);
1842  return node;
1843 }
1844 
1849  : BinaryOp(lhs, rhs)
1850 {}
1851 
1857  return dynamic_cast<BitwiseOp*>(this);
1858 }
1859 
1865  return dynamic_cast<const BitwiseOp*>(this);
1866 }
1867 
1871 std::shared_ptr<BitwiseOp> BitwiseOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1872  auto type = map.at("@t").as_string();
1873  if (type == "BitwiseAnd") return BitwiseAnd::deserialize(map, ids);
1874  if (type == "BitwiseXor") return BitwiseXor::deserialize(map, ids);
1875  if (type == "BitwiseOr") return BitwiseOr::deserialize(map, ids);
1876  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1877 }
1878 
1883  : BitwiseOp(lhs, rhs)
1884 {}
1885 
1889 void BitwiseAnd::find_reachable(::tree::base::PointerMap &map) const {
1890  (void)map;
1891  lhs.find_reachable(map);
1892  rhs.find_reachable(map);
1893 }
1894 
1898 void BitwiseAnd::check_complete(const ::tree::base::PointerMap &map) const {
1899  (void)map;
1900  lhs.check_complete(map);
1901  rhs.check_complete(map);
1902 }
1903 
1908  return NodeType::BitwiseAnd;
1909 }
1910 
1914 void BitwiseAnd::visit_internal(VisitorBase &visitor, void *retval) {
1915  visitor.raw_visit_bitwise_and(*this, retval);
1916 }
1917 
1923  return dynamic_cast<BitwiseAnd*>(this);
1924 }
1925 
1931  return dynamic_cast<const BitwiseAnd*>(this);
1932 }
1933 
1938  return cqasm::tree::make<BitwiseAnd>(*this);
1939 }
1940 
1945  auto node = cqasm::tree::make<BitwiseAnd>(*this);
1946  node->lhs = this->lhs.clone();
1947  node->rhs = this->rhs.clone();
1948  return node;
1949 }
1950 
1954 bool BitwiseAnd::equals(const Node &rhs) const {
1955  if (rhs.type() != NodeType::BitwiseAnd) return false;
1956  auto rhsc = dynamic_cast<const BitwiseAnd&>(rhs);
1957  if (!this->lhs.equals(rhsc.lhs)) return false;
1958  if (!this->rhs.equals(rhsc.rhs)) return false;
1959  return true;
1960 }
1961 
1965 bool BitwiseAnd::operator==(const Node &rhs) const {
1966  if (rhs.type() != NodeType::BitwiseAnd) return false;
1967  auto rhsc = dynamic_cast<const BitwiseAnd&>(rhs);
1968  if (this->lhs != rhsc.lhs) return false;
1969  if (this->rhs != rhsc.rhs) return false;
1970  return true;
1971 }
1972 
1977  ::tree::cbor::MapWriter &map,
1978  const ::tree::base::PointerMap &ids
1979 ) const {
1980  (void)ids;
1981  map.append_string("@t", "BitwiseAnd");
1982  auto submap = map.append_map("lhs");
1983  lhs.serialize(submap, ids);
1984  submap.close();
1985  submap = map.append_map("rhs");
1986  rhs.serialize(submap, ids);
1987  submap.close();
1988  serialize_annotations(map);
1989 }
1990 
1994 std::shared_ptr<BitwiseAnd> BitwiseAnd::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
1995  (void)ids;
1996  auto type = map.at("@t").as_string();
1997  if (type != "BitwiseAnd") {
1998  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
1999  }
2000  auto node = std::make_shared<BitwiseAnd>(
2001  One<Expression>(map.at("lhs").as_map(), ids),
2002  One<Expression>(map.at("rhs").as_map(), ids)
2003  );
2004  node->deserialize_annotations(map);
2005  return node;
2006 }
2007 
2012  : Expression(), expr(expr)
2013 {}
2014 
2020  return dynamic_cast<UnaryOp*>(this);
2021 }
2022 
2028  return dynamic_cast<const UnaryOp*>(this);
2029 }
2030 
2034 std::shared_ptr<UnaryOp> UnaryOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2035  auto type = map.at("@t").as_string();
2036  if (type == "Negate") return Negate::deserialize(map, ids);
2037  if (type == "BitwiseNot") return BitwiseNot::deserialize(map, ids);
2038  if (type == "LogicalNot") return LogicalNot::deserialize(map, ids);
2039  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2040 }
2041 
2046  : UnaryOp(expr)
2047 {}
2048 
2052 void BitwiseNot::find_reachable(::tree::base::PointerMap &map) const {
2053  (void)map;
2054  expr.find_reachable(map);
2055 }
2056 
2060 void BitwiseNot::check_complete(const ::tree::base::PointerMap &map) const {
2061  (void)map;
2062  expr.check_complete(map);
2063 }
2064 
2069  return NodeType::BitwiseNot;
2070 }
2071 
2075 void BitwiseNot::visit_internal(VisitorBase &visitor, void *retval) {
2076  visitor.raw_visit_bitwise_not(*this, retval);
2077 }
2078 
2084  return dynamic_cast<BitwiseNot*>(this);
2085 }
2086 
2092  return dynamic_cast<const BitwiseNot*>(this);
2093 }
2094 
2099  return cqasm::tree::make<BitwiseNot>(*this);
2100 }
2101 
2106  auto node = cqasm::tree::make<BitwiseNot>(*this);
2107  node->expr = this->expr.clone();
2108  return node;
2109 }
2110 
2114 bool BitwiseNot::equals(const Node &rhs) const {
2115  if (rhs.type() != NodeType::BitwiseNot) return false;
2116  auto rhsc = dynamic_cast<const BitwiseNot&>(rhs);
2117  if (!this->expr.equals(rhsc.expr)) return false;
2118  return true;
2119 }
2120 
2124 bool BitwiseNot::operator==(const Node &rhs) const {
2125  if (rhs.type() != NodeType::BitwiseNot) return false;
2126  auto rhsc = dynamic_cast<const BitwiseNot&>(rhs);
2127  if (this->expr != rhsc.expr) return false;
2128  return true;
2129 }
2130 
2135  ::tree::cbor::MapWriter &map,
2136  const ::tree::base::PointerMap &ids
2137 ) const {
2138  (void)ids;
2139  map.append_string("@t", "BitwiseNot");
2140  auto submap = map.append_map("expr");
2141  expr.serialize(submap, ids);
2142  submap.close();
2143  serialize_annotations(map);
2144 }
2145 
2149 std::shared_ptr<BitwiseNot> BitwiseNot::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2150  (void)ids;
2151  auto type = map.at("@t").as_string();
2152  if (type != "BitwiseNot") {
2153  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2154  }
2155  auto node = std::make_shared<BitwiseNot>(
2156  One<Expression>(map.at("expr").as_map(), ids)
2157  );
2158  node->deserialize_annotations(map);
2159  return node;
2160 }
2161 
2166  : BitwiseOp(lhs, rhs)
2167 {}
2168 
2172 void BitwiseOr::find_reachable(::tree::base::PointerMap &map) const {
2173  (void)map;
2174  lhs.find_reachable(map);
2175  rhs.find_reachable(map);
2176 }
2177 
2181 void BitwiseOr::check_complete(const ::tree::base::PointerMap &map) const {
2182  (void)map;
2183  lhs.check_complete(map);
2184  rhs.check_complete(map);
2185 }
2186 
2191  return NodeType::BitwiseOr;
2192 }
2193 
2197 void BitwiseOr::visit_internal(VisitorBase &visitor, void *retval) {
2198  visitor.raw_visit_bitwise_or(*this, retval);
2199 }
2200 
2206  return dynamic_cast<BitwiseOr*>(this);
2207 }
2208 
2214  return dynamic_cast<const BitwiseOr*>(this);
2215 }
2216 
2221  return cqasm::tree::make<BitwiseOr>(*this);
2222 }
2223 
2228  auto node = cqasm::tree::make<BitwiseOr>(*this);
2229  node->lhs = this->lhs.clone();
2230  node->rhs = this->rhs.clone();
2231  return node;
2232 }
2233 
2237 bool BitwiseOr::equals(const Node &rhs) const {
2238  if (rhs.type() != NodeType::BitwiseOr) return false;
2239  auto rhsc = dynamic_cast<const BitwiseOr&>(rhs);
2240  if (!this->lhs.equals(rhsc.lhs)) return false;
2241  if (!this->rhs.equals(rhsc.rhs)) return false;
2242  return true;
2243 }
2244 
2248 bool BitwiseOr::operator==(const Node &rhs) const {
2249  if (rhs.type() != NodeType::BitwiseOr) return false;
2250  auto rhsc = dynamic_cast<const BitwiseOr&>(rhs);
2251  if (this->lhs != rhsc.lhs) return false;
2252  if (this->rhs != rhsc.rhs) return false;
2253  return true;
2254 }
2255 
2260  ::tree::cbor::MapWriter &map,
2261  const ::tree::base::PointerMap &ids
2262 ) const {
2263  (void)ids;
2264  map.append_string("@t", "BitwiseOr");
2265  auto submap = map.append_map("lhs");
2266  lhs.serialize(submap, ids);
2267  submap.close();
2268  submap = map.append_map("rhs");
2269  rhs.serialize(submap, ids);
2270  submap.close();
2271  serialize_annotations(map);
2272 }
2273 
2277 std::shared_ptr<BitwiseOr> BitwiseOr::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2278  (void)ids;
2279  auto type = map.at("@t").as_string();
2280  if (type != "BitwiseOr") {
2281  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2282  }
2283  auto node = std::make_shared<BitwiseOr>(
2284  One<Expression>(map.at("lhs").as_map(), ids),
2285  One<Expression>(map.at("rhs").as_map(), ids)
2286  );
2287  node->deserialize_annotations(map);
2288  return node;
2289 }
2290 
2295  : BitwiseOp(lhs, rhs)
2296 {}
2297 
2301 void BitwiseXor::find_reachable(::tree::base::PointerMap &map) const {
2302  (void)map;
2303  lhs.find_reachable(map);
2304  rhs.find_reachable(map);
2305 }
2306 
2310 void BitwiseXor::check_complete(const ::tree::base::PointerMap &map) const {
2311  (void)map;
2312  lhs.check_complete(map);
2313  rhs.check_complete(map);
2314 }
2315 
2320  return NodeType::BitwiseXor;
2321 }
2322 
2326 void BitwiseXor::visit_internal(VisitorBase &visitor, void *retval) {
2327  visitor.raw_visit_bitwise_xor(*this, retval);
2328 }
2329 
2335  return dynamic_cast<BitwiseXor*>(this);
2336 }
2337 
2343  return dynamic_cast<const BitwiseXor*>(this);
2344 }
2345 
2350  return cqasm::tree::make<BitwiseXor>(*this);
2351 }
2352 
2357  auto node = cqasm::tree::make<BitwiseXor>(*this);
2358  node->lhs = this->lhs.clone();
2359  node->rhs = this->rhs.clone();
2360  return node;
2361 }
2362 
2366 bool BitwiseXor::equals(const Node &rhs) const {
2367  if (rhs.type() != NodeType::BitwiseXor) return false;
2368  auto rhsc = dynamic_cast<const BitwiseXor&>(rhs);
2369  if (!this->lhs.equals(rhsc.lhs)) return false;
2370  if (!this->rhs.equals(rhsc.rhs)) return false;
2371  return true;
2372 }
2373 
2377 bool BitwiseXor::operator==(const Node &rhs) const {
2378  if (rhs.type() != NodeType::BitwiseXor) return false;
2379  auto rhsc = dynamic_cast<const BitwiseXor&>(rhs);
2380  if (this->lhs != rhsc.lhs) return false;
2381  if (this->rhs != rhsc.rhs) return false;
2382  return true;
2383 }
2384 
2389  ::tree::cbor::MapWriter &map,
2390  const ::tree::base::PointerMap &ids
2391 ) const {
2392  (void)ids;
2393  map.append_string("@t", "BitwiseXor");
2394  auto submap = map.append_map("lhs");
2395  lhs.serialize(submap, ids);
2396  submap.close();
2397  submap = map.append_map("rhs");
2398  rhs.serialize(submap, ids);
2399  submap.close();
2400  serialize_annotations(map);
2401 }
2402 
2406 std::shared_ptr<BitwiseXor> BitwiseXor::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2407  (void)ids;
2408  auto type = map.at("@t").as_string();
2409  if (type != "BitwiseXor") {
2410  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2411  }
2412  auto node = std::make_shared<BitwiseXor>(
2413  One<Expression>(map.at("lhs").as_map(), ids),
2414  One<Expression>(map.at("rhs").as_map(), ids)
2415  );
2416  node->deserialize_annotations(map);
2417  return node;
2418 }
2419 
2424  : Annotated(annotations)
2425 {}
2426 
2432  return dynamic_cast<Statement*>(this);
2433 }
2434 
2440  return dynamic_cast<const Statement*>(this);
2441 }
2442 
2446 std::shared_ptr<Statement> Statement::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2447  auto type = map.at("@t").as_string();
2448  if (type == "Bundle") return Bundle::deserialize(map, ids);
2449  if (type == "Mapping") return Mapping::deserialize(map, ids);
2450  if (type == "Variables") return Variables::deserialize(map, ids);
2451  if (type == "Subcircuit") return Subcircuit::deserialize(map, ids);
2452  if (type == "IfElse") return IfElse::deserialize(map, ids);
2453  if (type == "ForLoop") return ForLoop::deserialize(map, ids);
2454  if (type == "ForeachLoop") return ForeachLoop::deserialize(map, ids);
2455  if (type == "WhileLoop") return WhileLoop::deserialize(map, ids);
2456  if (type == "RepeatUntilLoop") return RepeatUntilLoop::deserialize(map, ids);
2457  if (type == "BreakStatement") return BreakStatement::deserialize(map, ids);
2458  if (type == "ContinueStatement") return ContinueStatement::deserialize(map, ids);
2459  if (type == "ErroneousStatement") return ErroneousStatement::deserialize(map, ids);
2460  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2461 }
2462 
2467  : Statement(annotations)
2468 {}
2469 
2475  return dynamic_cast<Structured*>(this);
2476 }
2477 
2483  return dynamic_cast<const Structured*>(this);
2484 }
2485 
2489 std::shared_ptr<Structured> Structured::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2490  auto type = map.at("@t").as_string();
2491  if (type == "IfElse") return IfElse::deserialize(map, ids);
2492  if (type == "ForLoop") return ForLoop::deserialize(map, ids);
2493  if (type == "ForeachLoop") return ForeachLoop::deserialize(map, ids);
2494  if (type == "WhileLoop") return WhileLoop::deserialize(map, ids);
2495  if (type == "RepeatUntilLoop") return RepeatUntilLoop::deserialize(map, ids);
2496  if (type == "BreakStatement") return BreakStatement::deserialize(map, ids);
2497  if (type == "ContinueStatement") return ContinueStatement::deserialize(map, ids);
2498  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2499 }
2500 
2505  : Structured(annotations)
2506 {}
2507 
2511 void BreakStatement::find_reachable(::tree::base::PointerMap &map) const {
2512  (void)map;
2513  annotations.find_reachable(map);
2514 }
2515 
2519 void BreakStatement::check_complete(const ::tree::base::PointerMap &map) const {
2520  (void)map;
2521  annotations.check_complete(map);
2522 }
2523 
2528  return NodeType::BreakStatement;
2529 }
2530 
2534 void BreakStatement::visit_internal(VisitorBase &visitor, void *retval) {
2535  visitor.raw_visit_break_statement(*this, retval);
2536 }
2537 
2543  return dynamic_cast<BreakStatement*>(this);
2544 }
2545 
2551  return dynamic_cast<const BreakStatement*>(this);
2552 }
2553 
2558  return cqasm::tree::make<BreakStatement>(*this);
2559 }
2560 
2565  auto node = cqasm::tree::make<BreakStatement>(*this);
2566  node->annotations = this->annotations.clone();
2567  return node;
2568 }
2569 
2573 bool BreakStatement::equals(const Node &rhs) const {
2574  if (rhs.type() != NodeType::BreakStatement) return false;
2575  auto rhsc = dynamic_cast<const BreakStatement&>(rhs);
2576  if (!this->annotations.equals(rhsc.annotations)) return false;
2577  return true;
2578 }
2579 
2583 bool BreakStatement::operator==(const Node &rhs) const {
2584  if (rhs.type() != NodeType::BreakStatement) return false;
2585  auto rhsc = dynamic_cast<const BreakStatement&>(rhs);
2586  if (this->annotations != rhsc.annotations) return false;
2587  return true;
2588 }
2589 
2594  ::tree::cbor::MapWriter &map,
2595  const ::tree::base::PointerMap &ids
2596 ) const {
2597  (void)ids;
2598  map.append_string("@t", "BreakStatement");
2599  auto submap = map.append_map("annotations");
2600  annotations.serialize(submap, ids);
2601  submap.close();
2602  serialize_annotations(map);
2603 }
2604 
2608 std::shared_ptr<BreakStatement> BreakStatement::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2609  (void)ids;
2610  auto type = map.at("@t").as_string();
2611  if (type != "BreakStatement") {
2612  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2613  }
2614  auto node = std::make_shared<BreakStatement>(
2615  Any<AnnotationData>(map.at("annotations").as_map(), ids)
2616  );
2617  node->deserialize_annotations(map);
2618  return node;
2619 }
2620 
2625  : Statement(annotations), items(items)
2626 {}
2627 
2631 void Bundle::find_reachable(::tree::base::PointerMap &map) const {
2632  (void)map;
2633  items.find_reachable(map);
2634  annotations.find_reachable(map);
2635 }
2636 
2640 void Bundle::check_complete(const ::tree::base::PointerMap &map) const {
2641  (void)map;
2642  items.check_complete(map);
2643  annotations.check_complete(map);
2644 }
2645 
2650  return NodeType::Bundle;
2651 }
2652 
2656 void Bundle::visit_internal(VisitorBase &visitor, void *retval) {
2657  visitor.raw_visit_bundle(*this, retval);
2658 }
2659 
2665  return dynamic_cast<Bundle*>(this);
2666 }
2667 
2672 const Bundle *Bundle::as_bundle() const {
2673  return dynamic_cast<const Bundle*>(this);
2674 }
2675 
2680  return cqasm::tree::make<Bundle>(*this);
2681 }
2682 
2687  auto node = cqasm::tree::make<Bundle>(*this);
2688  node->items = this->items.clone();
2689  node->annotations = this->annotations.clone();
2690  return node;
2691 }
2692 
2696 bool Bundle::equals(const Node &rhs) const {
2697  if (rhs.type() != NodeType::Bundle) return false;
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;
2701  return true;
2702 }
2703 
2707 bool Bundle::operator==(const Node &rhs) const {
2708  if (rhs.type() != NodeType::Bundle) 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;
2712  return true;
2713 }
2714 
2719  ::tree::cbor::MapWriter &map,
2720  const ::tree::base::PointerMap &ids
2721 ) const {
2722  (void)ids;
2723  map.append_string("@t", "Bundle");
2724  auto submap = map.append_map("items");
2725  items.serialize(submap, ids);
2726  submap.close();
2727  submap = map.append_map("annotations");
2728  annotations.serialize(submap, ids);
2729  submap.close();
2730  serialize_annotations(map);
2731 }
2732 
2736 std::shared_ptr<Bundle> Bundle::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2737  (void)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);
2741  }
2742  auto node = std::make_shared<Bundle>(
2743  Many<Instruction>(map.at("items").as_map(), ids),
2744  Any<AnnotationData>(map.at("annotations").as_map(), ids)
2745  );
2746  node->deserialize_annotations(map);
2747  return node;
2748 }
2749 
2754  : BinaryOp(lhs, rhs)
2755 {}
2756 
2762  return dynamic_cast<CmpOp*>(this);
2763 }
2764 
2769 const CmpOp *CmpOp::as_cmp_op() const {
2770  return dynamic_cast<const CmpOp*>(this);
2771 }
2772 
2776 std::shared_ptr<CmpOp> CmpOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2777  auto type = map.at("@t").as_string();
2778  if (type == "CmpEq") return CmpEq::deserialize(map, ids);
2779  if (type == "CmpNe") return CmpNe::deserialize(map, ids);
2780  if (type == "CmpGt") return CmpGt::deserialize(map, ids);
2781  if (type == "CmpGe") return CmpGe::deserialize(map, ids);
2782  if (type == "CmpLt") return CmpLt::deserialize(map, ids);
2783  if (type == "CmpLe") return CmpLe::deserialize(map, ids);
2784  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
2785 }
2786 
2791  : CmpOp(lhs, rhs)
2792 {}
2793 
2797 void CmpEq::find_reachable(::tree::base::PointerMap &map) const {
2798  (void)map;
2799  lhs.find_reachable(map);
2800  rhs.find_reachable(map);
2801 }
2802 
2806 void CmpEq::check_complete(const ::tree::base::PointerMap &map) const {
2807  (void)map;
2808  lhs.check_complete(map);
2809  rhs.check_complete(map);
2810 }
2811 
2816  return NodeType::CmpEq;
2817 }
2818 
2822 void CmpEq::visit_internal(VisitorBase &visitor, void *retval) {
2823  visitor.raw_visit_cmp_eq(*this, retval);
2824 }
2825 
2831  return dynamic_cast<CmpEq*>(this);
2832 }
2833 
2838 const CmpEq *CmpEq::as_cmp_eq() const {
2839  return dynamic_cast<const CmpEq*>(this);
2840 }
2841 
2846  return cqasm::tree::make<CmpEq>(*this);
2847 }
2848 
2853  auto node = cqasm::tree::make<CmpEq>(*this);
2854  node->lhs = this->lhs.clone();
2855  node->rhs = this->rhs.clone();
2856  return node;
2857 }
2858 
2862 bool CmpEq::equals(const Node &rhs) const {
2863  if (rhs.type() != NodeType::CmpEq) return false;
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;
2867  return true;
2868 }
2869 
2873 bool CmpEq::operator==(const Node &rhs) const {
2874  if (rhs.type() != NodeType::CmpEq) 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;
2878  return true;
2879 }
2880 
2885  ::tree::cbor::MapWriter &map,
2886  const ::tree::base::PointerMap &ids
2887 ) const {
2888  (void)ids;
2889  map.append_string("@t", "CmpEq");
2890  auto submap = map.append_map("lhs");
2891  lhs.serialize(submap, ids);
2892  submap.close();
2893  submap = map.append_map("rhs");
2894  rhs.serialize(submap, ids);
2895  submap.close();
2896  serialize_annotations(map);
2897 }
2898 
2902 std::shared_ptr<CmpEq> CmpEq::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
2903  (void)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);
2907  }
2908  auto node = std::make_shared<CmpEq>(
2909  One<Expression>(map.at("lhs").as_map(), ids),
2910  One<Expression>(map.at("rhs").as_map(), ids)
2911  );
2912  node->deserialize_annotations(map);
2913  return node;
2914 }
2915 
2920  : CmpOp(lhs, rhs)
2921 {}
2922 
2926 void CmpGe::find_reachable(::tree::base::PointerMap &map) const {
2927  (void)map;
2928  lhs.find_reachable(map);
2929  rhs.find_reachable(map);
2930 }
2931 
2935 void CmpGe::check_complete(const ::tree::base::PointerMap &map) const {
2936  (void)map;
2937  lhs.check_complete(map);
2938  rhs.check_complete(map);
2939 }
2940 
2945  return NodeType::CmpGe;
2946 }
2947 
2951 void CmpGe::visit_internal(VisitorBase &visitor, void *retval) {
2952  visitor.raw_visit_cmp_ge(*this, retval);
2953 }
2954 
2960  return dynamic_cast<CmpGe*>(this);
2961 }
2962 
2967 const CmpGe *CmpGe::as_cmp_ge() const {
2968  return dynamic_cast<const CmpGe*>(this);
2969 }
2970 
2975  return cqasm::tree::make<CmpGe>(*this);
2976 }
2977 
2982  auto node = cqasm::tree::make<CmpGe>(*this);
2983  node->lhs = this->lhs.clone();
2984  node->rhs = this->rhs.clone();
2985  return node;
2986 }
2987 
2991 bool CmpGe::equals(const Node &rhs) const {
2992  if (rhs.type() != NodeType::CmpGe) return false;
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;
2996  return true;
2997 }
2998 
3002 bool CmpGe::operator==(const Node &rhs) const {
3003  if (rhs.type() != NodeType::CmpGe) 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;
3007  return true;
3008 }
3009 
3014  ::tree::cbor::MapWriter &map,
3015  const ::tree::base::PointerMap &ids
3016 ) const {
3017  (void)ids;
3018  map.append_string("@t", "CmpGe");
3019  auto submap = map.append_map("lhs");
3020  lhs.serialize(submap, ids);
3021  submap.close();
3022  submap = map.append_map("rhs");
3023  rhs.serialize(submap, ids);
3024  submap.close();
3025  serialize_annotations(map);
3026 }
3027 
3031 std::shared_ptr<CmpGe> CmpGe::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3032  (void)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);
3036  }
3037  auto node = std::make_shared<CmpGe>(
3038  One<Expression>(map.at("lhs").as_map(), ids),
3039  One<Expression>(map.at("rhs").as_map(), ids)
3040  );
3041  node->deserialize_annotations(map);
3042  return node;
3043 }
3044 
3049  : CmpOp(lhs, rhs)
3050 {}
3051 
3055 void CmpGt::find_reachable(::tree::base::PointerMap &map) const {
3056  (void)map;
3057  lhs.find_reachable(map);
3058  rhs.find_reachable(map);
3059 }
3060 
3064 void CmpGt::check_complete(const ::tree::base::PointerMap &map) const {
3065  (void)map;
3066  lhs.check_complete(map);
3067  rhs.check_complete(map);
3068 }
3069 
3074  return NodeType::CmpGt;
3075 }
3076 
3080 void CmpGt::visit_internal(VisitorBase &visitor, void *retval) {
3081  visitor.raw_visit_cmp_gt(*this, retval);
3082 }
3083 
3089  return dynamic_cast<CmpGt*>(this);
3090 }
3091 
3096 const CmpGt *CmpGt::as_cmp_gt() const {
3097  return dynamic_cast<const CmpGt*>(this);
3098 }
3099 
3104  return cqasm::tree::make<CmpGt>(*this);
3105 }
3106 
3111  auto node = cqasm::tree::make<CmpGt>(*this);
3112  node->lhs = this->lhs.clone();
3113  node->rhs = this->rhs.clone();
3114  return node;
3115 }
3116 
3120 bool CmpGt::equals(const Node &rhs) const {
3121  if (rhs.type() != NodeType::CmpGt) return false;
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;
3125  return true;
3126 }
3127 
3131 bool CmpGt::operator==(const Node &rhs) const {
3132  if (rhs.type() != NodeType::CmpGt) 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;
3136  return true;
3137 }
3138 
3143  ::tree::cbor::MapWriter &map,
3144  const ::tree::base::PointerMap &ids
3145 ) const {
3146  (void)ids;
3147  map.append_string("@t", "CmpGt");
3148  auto submap = map.append_map("lhs");
3149  lhs.serialize(submap, ids);
3150  submap.close();
3151  submap = map.append_map("rhs");
3152  rhs.serialize(submap, ids);
3153  submap.close();
3154  serialize_annotations(map);
3155 }
3156 
3160 std::shared_ptr<CmpGt> CmpGt::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3161  (void)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);
3165  }
3166  auto node = std::make_shared<CmpGt>(
3167  One<Expression>(map.at("lhs").as_map(), ids),
3168  One<Expression>(map.at("rhs").as_map(), ids)
3169  );
3170  node->deserialize_annotations(map);
3171  return node;
3172 }
3173 
3178  : CmpOp(lhs, rhs)
3179 {}
3180 
3184 void CmpLe::find_reachable(::tree::base::PointerMap &map) const {
3185  (void)map;
3186  lhs.find_reachable(map);
3187  rhs.find_reachable(map);
3188 }
3189 
3193 void CmpLe::check_complete(const ::tree::base::PointerMap &map) const {
3194  (void)map;
3195  lhs.check_complete(map);
3196  rhs.check_complete(map);
3197 }
3198 
3203  return NodeType::CmpLe;
3204 }
3205 
3209 void CmpLe::visit_internal(VisitorBase &visitor, void *retval) {
3210  visitor.raw_visit_cmp_le(*this, retval);
3211 }
3212 
3218  return dynamic_cast<CmpLe*>(this);
3219 }
3220 
3225 const CmpLe *CmpLe::as_cmp_le() const {
3226  return dynamic_cast<const CmpLe*>(this);
3227 }
3228 
3233  return cqasm::tree::make<CmpLe>(*this);
3234 }
3235 
3240  auto node = cqasm::tree::make<CmpLe>(*this);
3241  node->lhs = this->lhs.clone();
3242  node->rhs = this->rhs.clone();
3243  return node;
3244 }
3245 
3249 bool CmpLe::equals(const Node &rhs) const {
3250  if (rhs.type() != NodeType::CmpLe) return false;
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;
3254  return true;
3255 }
3256 
3260 bool CmpLe::operator==(const Node &rhs) const {
3261  if (rhs.type() != NodeType::CmpLe) 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;
3265  return true;
3266 }
3267 
3272  ::tree::cbor::MapWriter &map,
3273  const ::tree::base::PointerMap &ids
3274 ) const {
3275  (void)ids;
3276  map.append_string("@t", "CmpLe");
3277  auto submap = map.append_map("lhs");
3278  lhs.serialize(submap, ids);
3279  submap.close();
3280  submap = map.append_map("rhs");
3281  rhs.serialize(submap, ids);
3282  submap.close();
3283  serialize_annotations(map);
3284 }
3285 
3289 std::shared_ptr<CmpLe> CmpLe::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3290  (void)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);
3294  }
3295  auto node = std::make_shared<CmpLe>(
3296  One<Expression>(map.at("lhs").as_map(), ids),
3297  One<Expression>(map.at("rhs").as_map(), ids)
3298  );
3299  node->deserialize_annotations(map);
3300  return node;
3301 }
3302 
3307  : CmpOp(lhs, rhs)
3308 {}
3309 
3313 void CmpLt::find_reachable(::tree::base::PointerMap &map) const {
3314  (void)map;
3315  lhs.find_reachable(map);
3316  rhs.find_reachable(map);
3317 }
3318 
3322 void CmpLt::check_complete(const ::tree::base::PointerMap &map) const {
3323  (void)map;
3324  lhs.check_complete(map);
3325  rhs.check_complete(map);
3326 }
3327 
3332  return NodeType::CmpLt;
3333 }
3334 
3338 void CmpLt::visit_internal(VisitorBase &visitor, void *retval) {
3339  visitor.raw_visit_cmp_lt(*this, retval);
3340 }
3341 
3347  return dynamic_cast<CmpLt*>(this);
3348 }
3349 
3354 const CmpLt *CmpLt::as_cmp_lt() const {
3355  return dynamic_cast<const CmpLt*>(this);
3356 }
3357 
3362  return cqasm::tree::make<CmpLt>(*this);
3363 }
3364 
3369  auto node = cqasm::tree::make<CmpLt>(*this);
3370  node->lhs = this->lhs.clone();
3371  node->rhs = this->rhs.clone();
3372  return node;
3373 }
3374 
3378 bool CmpLt::equals(const Node &rhs) const {
3379  if (rhs.type() != NodeType::CmpLt) return false;
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;
3383  return true;
3384 }
3385 
3389 bool CmpLt::operator==(const Node &rhs) const {
3390  if (rhs.type() != NodeType::CmpLt) 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;
3394  return true;
3395 }
3396 
3401  ::tree::cbor::MapWriter &map,
3402  const ::tree::base::PointerMap &ids
3403 ) const {
3404  (void)ids;
3405  map.append_string("@t", "CmpLt");
3406  auto submap = map.append_map("lhs");
3407  lhs.serialize(submap, ids);
3408  submap.close();
3409  submap = map.append_map("rhs");
3410  rhs.serialize(submap, ids);
3411  submap.close();
3412  serialize_annotations(map);
3413 }
3414 
3418 std::shared_ptr<CmpLt> CmpLt::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3419  (void)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);
3423  }
3424  auto node = std::make_shared<CmpLt>(
3425  One<Expression>(map.at("lhs").as_map(), ids),
3426  One<Expression>(map.at("rhs").as_map(), ids)
3427  );
3428  node->deserialize_annotations(map);
3429  return node;
3430 }
3431 
3436  : CmpOp(lhs, rhs)
3437 {}
3438 
3442 void CmpNe::find_reachable(::tree::base::PointerMap &map) const {
3443  (void)map;
3444  lhs.find_reachable(map);
3445  rhs.find_reachable(map);
3446 }
3447 
3451 void CmpNe::check_complete(const ::tree::base::PointerMap &map) const {
3452  (void)map;
3453  lhs.check_complete(map);
3454  rhs.check_complete(map);
3455 }
3456 
3461  return NodeType::CmpNe;
3462 }
3463 
3467 void CmpNe::visit_internal(VisitorBase &visitor, void *retval) {
3468  visitor.raw_visit_cmp_ne(*this, retval);
3469 }
3470 
3476  return dynamic_cast<CmpNe*>(this);
3477 }
3478 
3483 const CmpNe *CmpNe::as_cmp_ne() const {
3484  return dynamic_cast<const CmpNe*>(this);
3485 }
3486 
3491  return cqasm::tree::make<CmpNe>(*this);
3492 }
3493 
3498  auto node = cqasm::tree::make<CmpNe>(*this);
3499  node->lhs = this->lhs.clone();
3500  node->rhs = this->rhs.clone();
3501  return node;
3502 }
3503 
3507 bool CmpNe::equals(const Node &rhs) const {
3508  if (rhs.type() != NodeType::CmpNe) return false;
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;
3512  return true;
3513 }
3514 
3518 bool CmpNe::operator==(const Node &rhs) const {
3519  if (rhs.type() != NodeType::CmpNe) 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;
3523  return true;
3524 }
3525 
3530  ::tree::cbor::MapWriter &map,
3531  const ::tree::base::PointerMap &ids
3532 ) const {
3533  (void)ids;
3534  map.append_string("@t", "CmpNe");
3535  auto submap = map.append_map("lhs");
3536  lhs.serialize(submap, ids);
3537  submap.close();
3538  submap = map.append_map("rhs");
3539  rhs.serialize(submap, ids);
3540  submap.close();
3541  serialize_annotations(map);
3542 }
3543 
3547 std::shared_ptr<CmpNe> CmpNe::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3548  (void)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);
3552  }
3553  auto node = std::make_shared<CmpNe>(
3554  One<Expression>(map.at("lhs").as_map(), ids),
3555  One<Expression>(map.at("rhs").as_map(), ids)
3556  );
3557  node->deserialize_annotations(map);
3558  return node;
3559 }
3560 
3565  : Structured(annotations)
3566 {}
3567 
3571 void ContinueStatement::find_reachable(::tree::base::PointerMap &map) const {
3572  (void)map;
3573  annotations.find_reachable(map);
3574 }
3575 
3579 void ContinueStatement::check_complete(const ::tree::base::PointerMap &map) const {
3580  (void)map;
3581  annotations.check_complete(map);
3582 }
3583 
3589 }
3590 
3594 void ContinueStatement::visit_internal(VisitorBase &visitor, void *retval) {
3595  visitor.raw_visit_continue_statement(*this, retval);
3596 }
3597 
3603  return dynamic_cast<ContinueStatement*>(this);
3604 }
3605 
3611  return dynamic_cast<const ContinueStatement*>(this);
3612 }
3613 
3618  return cqasm::tree::make<ContinueStatement>(*this);
3619 }
3620 
3625  auto node = cqasm::tree::make<ContinueStatement>(*this);
3626  node->annotations = this->annotations.clone();
3627  return node;
3628 }
3629 
3633 bool ContinueStatement::equals(const Node &rhs) const {
3634  if (rhs.type() != NodeType::ContinueStatement) return false;
3635  auto rhsc = dynamic_cast<const ContinueStatement&>(rhs);
3636  if (!this->annotations.equals(rhsc.annotations)) return false;
3637  return true;
3638 }
3639 
3643 bool ContinueStatement::operator==(const Node &rhs) const {
3644  if (rhs.type() != NodeType::ContinueStatement) return false;
3645  auto rhsc = dynamic_cast<const ContinueStatement&>(rhs);
3646  if (this->annotations != rhsc.annotations) return false;
3647  return true;
3648 }
3649 
3654  ::tree::cbor::MapWriter &map,
3655  const ::tree::base::PointerMap &ids
3656 ) const {
3657  (void)ids;
3658  map.append_string("@t", "ContinueStatement");
3659  auto submap = map.append_map("annotations");
3660  annotations.serialize(submap, ids);
3661  submap.close();
3662  serialize_annotations(map);
3663 }
3664 
3668 std::shared_ptr<ContinueStatement> ContinueStatement::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3669  (void)ids;
3670  auto type = map.at("@t").as_string();
3671  if (type != "ContinueStatement") {
3672  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
3673  }
3674  auto node = std::make_shared<ContinueStatement>(
3675  Any<AnnotationData>(map.at("annotations").as_map(), ids)
3676  );
3677  node->deserialize_annotations(map);
3678  return node;
3679 }
3680 
3685  : ArithOp(lhs, rhs)
3686 {}
3687 
3691 void Divide::find_reachable(::tree::base::PointerMap &map) const {
3692  (void)map;
3693  lhs.find_reachable(map);
3694  rhs.find_reachable(map);
3695 }
3696 
3700 void Divide::check_complete(const ::tree::base::PointerMap &map) const {
3701  (void)map;
3702  lhs.check_complete(map);
3703  rhs.check_complete(map);
3704 }
3705 
3710  return NodeType::Divide;
3711 }
3712 
3716 void Divide::visit_internal(VisitorBase &visitor, void *retval) {
3717  visitor.raw_visit_divide(*this, retval);
3718 }
3719 
3725  return dynamic_cast<Divide*>(this);
3726 }
3727 
3732 const Divide *Divide::as_divide() const {
3733  return dynamic_cast<const Divide*>(this);
3734 }
3735 
3740  return cqasm::tree::make<Divide>(*this);
3741 }
3742 
3747  auto node = cqasm::tree::make<Divide>(*this);
3748  node->lhs = this->lhs.clone();
3749  node->rhs = this->rhs.clone();
3750  return node;
3751 }
3752 
3756 bool Divide::equals(const Node &rhs) const {
3757  if (rhs.type() != NodeType::Divide) return false;
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;
3761  return true;
3762 }
3763 
3767 bool Divide::operator==(const Node &rhs) const {
3768  if (rhs.type() != NodeType::Divide) 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;
3772  return true;
3773 }
3774 
3779  ::tree::cbor::MapWriter &map,
3780  const ::tree::base::PointerMap &ids
3781 ) const {
3782  (void)ids;
3783  map.append_string("@t", "Divide");
3784  auto submap = map.append_map("lhs");
3785  lhs.serialize(submap, ids);
3786  submap.close();
3787  submap = map.append_map("rhs");
3788  rhs.serialize(submap, ids);
3789  submap.close();
3790  serialize_annotations(map);
3791 }
3792 
3796 std::shared_ptr<Divide> Divide::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3797  (void)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);
3801  }
3802  auto node = std::make_shared<Divide>(
3803  One<Expression>(map.at("lhs").as_map(), ids),
3804  One<Expression>(map.at("rhs").as_map(), ids)
3805  );
3806  node->deserialize_annotations(map);
3807  return node;
3808 }
3809 
3813 void ErroneousExpression::find_reachable(::tree::base::PointerMap &map) const {
3814  (void)map;
3815 }
3816 
3820 void ErroneousExpression::check_complete(const ::tree::base::PointerMap &map) const {
3821  (void)map;
3822  throw ::tree::base::NotWellFormed("ErroneousExpression error node in tree");
3823 }
3824 
3830 }
3831 
3835 void ErroneousExpression::visit_internal(VisitorBase &visitor, void *retval) {
3836  visitor.raw_visit_erroneous_expression(*this, retval);
3837 }
3838 
3844  return dynamic_cast<ErroneousExpression*>(this);
3845 }
3846 
3852  return dynamic_cast<const ErroneousExpression*>(this);
3853 }
3854 
3859  return cqasm::tree::make<ErroneousExpression>(*this);
3860 }
3861 
3866  auto node = cqasm::tree::make<ErroneousExpression>(*this);
3867  return node;
3868 }
3869 
3874  if (rhs.type() != NodeType::ErroneousExpression) return false;
3875  return true;
3876 }
3877 
3882  if (rhs.type() != NodeType::ErroneousExpression) return false;
3883  return true;
3884 }
3885 
3890  ::tree::cbor::MapWriter &map,
3891  const ::tree::base::PointerMap &ids
3892 ) const {
3893  (void)ids;
3894  map.append_string("@t", "ErroneousExpression");
3895  serialize_annotations(map);
3896 }
3897 
3901 std::shared_ptr<ErroneousExpression> ErroneousExpression::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3902  (void)ids;
3903  auto type = map.at("@t").as_string();
3904  if (type != "ErroneousExpression") {
3905  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
3906  }
3907  auto node = std::make_shared<ErroneousExpression>(
3908 
3909  );
3910  node->deserialize_annotations(map);
3911  return node;
3912 }
3913 
3919  return dynamic_cast<Root*>(this);
3920 }
3921 
3926 const Root *Root::as_root() const {
3927  return dynamic_cast<const Root*>(this);
3928 }
3929 
3933 std::shared_ptr<Root> Root::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
3934  auto type = map.at("@t").as_string();
3935  if (type == "Program") return Program::deserialize(map, ids);
3936  if (type == "ErroneousProgram") return ErroneousProgram::deserialize(map, ids);
3937  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
3938 }
3939 
3943 void ErroneousProgram::find_reachable(::tree::base::PointerMap &map) const {
3944  (void)map;
3945 }
3946 
3950 void ErroneousProgram::check_complete(const ::tree::base::PointerMap &map) const {
3951  (void)map;
3952  throw ::tree::base::NotWellFormed("ErroneousProgram error node in tree");
3953 }
3954 
3960 }
3961 
3965 void ErroneousProgram::visit_internal(VisitorBase &visitor, void *retval) {
3966  visitor.raw_visit_erroneous_program(*this, retval);
3967 }
3968 
3974  return dynamic_cast<ErroneousProgram*>(this);
3975 }
3976 
3982  return dynamic_cast<const ErroneousProgram*>(this);
3983 }
3984 
3989  return cqasm::tree::make<ErroneousProgram>(*this);
3990 }
3991 
3996  auto node = cqasm::tree::make<ErroneousProgram>(*this);
3997  return node;
3998 }
3999 
4003 bool ErroneousProgram::equals(const Node &rhs) const {
4004  if (rhs.type() != NodeType::ErroneousProgram) return false;
4005  return true;
4006 }
4007 
4012  if (rhs.type() != NodeType::ErroneousProgram) return false;
4013  return true;
4014 }
4015 
4020  ::tree::cbor::MapWriter &map,
4021  const ::tree::base::PointerMap &ids
4022 ) const {
4023  (void)ids;
4024  map.append_string("@t", "ErroneousProgram");
4025  serialize_annotations(map);
4026 }
4027 
4031 std::shared_ptr<ErroneousProgram> ErroneousProgram::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4032  (void)ids;
4033  auto type = map.at("@t").as_string();
4034  if (type != "ErroneousProgram") {
4035  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
4036  }
4037  auto node = std::make_shared<ErroneousProgram>(
4038 
4039  );
4040  node->deserialize_annotations(map);
4041  return node;
4042 }
4043 
4048  : Statement(annotations)
4049 {}
4050 
4054 void ErroneousStatement::find_reachable(::tree::base::PointerMap &map) const {
4055  (void)map;
4056  annotations.find_reachable(map);
4057 }
4058 
4062 void ErroneousStatement::check_complete(const ::tree::base::PointerMap &map) const {
4063  (void)map;
4064  throw ::tree::base::NotWellFormed("ErroneousStatement error node in tree");
4065 }
4066 
4072 }
4073 
4077 void ErroneousStatement::visit_internal(VisitorBase &visitor, void *retval) {
4078  visitor.raw_visit_erroneous_statement(*this, retval);
4079 }
4080 
4086  return dynamic_cast<ErroneousStatement*>(this);
4087 }
4088 
4094  return dynamic_cast<const ErroneousStatement*>(this);
4095 }
4096 
4101  return cqasm::tree::make<ErroneousStatement>(*this);
4102 }
4103 
4108  auto node = cqasm::tree::make<ErroneousStatement>(*this);
4109  node->annotations = this->annotations.clone();
4110  return node;
4111 }
4112 
4116 bool ErroneousStatement::equals(const Node &rhs) const {
4117  if (rhs.type() != NodeType::ErroneousStatement) return false;
4118  auto rhsc = dynamic_cast<const ErroneousStatement&>(rhs);
4119  if (!this->annotations.equals(rhsc.annotations)) return false;
4120  return true;
4121 }
4122 
4126 bool ErroneousStatement::operator==(const Node &rhs) const {
4127  if (rhs.type() != NodeType::ErroneousStatement) return false;
4128  auto rhsc = dynamic_cast<const ErroneousStatement&>(rhs);
4129  if (this->annotations != rhsc.annotations) return false;
4130  return true;
4131 }
4132 
4137  ::tree::cbor::MapWriter &map,
4138  const ::tree::base::PointerMap &ids
4139 ) const {
4140  (void)ids;
4141  map.append_string("@t", "ErroneousStatement");
4142  auto submap = map.append_map("annotations");
4143  annotations.serialize(submap, ids);
4144  submap.close();
4145  serialize_annotations(map);
4146 }
4147 
4151 std::shared_ptr<ErroneousStatement> ErroneousStatement::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4152  (void)ids;
4153  auto type = map.at("@t").as_string();
4154  if (type != "ErroneousStatement") {
4155  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
4156  }
4157  auto node = std::make_shared<ErroneousStatement>(
4158  Any<AnnotationData>(map.at("annotations").as_map(), ids)
4159  );
4160  node->deserialize_annotations(map);
4161  return node;
4162 }
4163 
4168  : items(items)
4169 {}
4170 
4174 void ExpressionList::find_reachable(::tree::base::PointerMap &map) const {
4175  (void)map;
4176  items.find_reachable(map);
4177 }
4178 
4182 void ExpressionList::check_complete(const ::tree::base::PointerMap &map) const {
4183  (void)map;
4184  items.check_complete(map);
4185 }
4186 
4191  return NodeType::ExpressionList;
4192 }
4193 
4197 void ExpressionList::visit_internal(VisitorBase &visitor, void *retval) {
4198  visitor.raw_visit_expression_list(*this, retval);
4199 }
4200 
4206  return dynamic_cast<ExpressionList*>(this);
4207 }
4208 
4214  return dynamic_cast<const ExpressionList*>(this);
4215 }
4216 
4221  return cqasm::tree::make<ExpressionList>(*this);
4222 }
4223 
4228  auto node = cqasm::tree::make<ExpressionList>(*this);
4229  node->items = this->items.clone();
4230  return node;
4231 }
4232 
4236 bool ExpressionList::equals(const Node &rhs) const {
4237  if (rhs.type() != NodeType::ExpressionList) return false;
4238  auto rhsc = dynamic_cast<const ExpressionList&>(rhs);
4239  if (!this->items.equals(rhsc.items)) return false;
4240  return true;
4241 }
4242 
4246 bool ExpressionList::operator==(const Node &rhs) const {
4247  if (rhs.type() != NodeType::ExpressionList) return false;
4248  auto rhsc = dynamic_cast<const ExpressionList&>(rhs);
4249  if (this->items != rhsc.items) return false;
4250  return true;
4251 }
4252 
4257  ::tree::cbor::MapWriter &map,
4258  const ::tree::base::PointerMap &ids
4259 ) const {
4260  (void)ids;
4261  map.append_string("@t", "ExpressionList");
4262  auto submap = map.append_map("items");
4263  items.serialize(submap, ids);
4264  submap.close();
4265  serialize_annotations(map);
4266 }
4267 
4271 std::shared_ptr<ExpressionList> ExpressionList::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4272  (void)ids;
4273  auto type = map.at("@t").as_string();
4274  if (type != "ExpressionList") {
4275  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
4276  }
4277  auto node = std::make_shared<ExpressionList>(
4278  Any<Expression>(map.at("items").as_map(), ids)
4279  );
4280  node->deserialize_annotations(map);
4281  return node;
4282 }
4283 
4288  : Expression(), value(value)
4289 {}
4290 
4294 void FloatLiteral::find_reachable(::tree::base::PointerMap &map) const {
4295  (void)map;
4296 }
4297 
4301 void FloatLiteral::check_complete(const ::tree::base::PointerMap &map) const {
4302  (void)map;
4303 }
4304 
4309  return NodeType::FloatLiteral;
4310 }
4311 
4315 void FloatLiteral::visit_internal(VisitorBase &visitor, void *retval) {
4316  visitor.raw_visit_float_literal(*this, retval);
4317 }
4318 
4324  return dynamic_cast<FloatLiteral*>(this);
4325 }
4326 
4332  return dynamic_cast<const FloatLiteral*>(this);
4333 }
4334 
4339  return cqasm::tree::make<FloatLiteral>(*this);
4340 }
4341 
4346  auto node = cqasm::tree::make<FloatLiteral>(*this);
4347  return node;
4348 }
4349 
4353 bool FloatLiteral::equals(const Node &rhs) const {
4354  if (rhs.type() != NodeType::FloatLiteral) return false;
4355  auto rhsc = dynamic_cast<const FloatLiteral&>(rhs);
4356  if (this->value != rhsc.value) return false;
4357  return true;
4358 }
4359 
4363 bool FloatLiteral::operator==(const Node &rhs) const {
4364  if (rhs.type() != NodeType::FloatLiteral) return false;
4365  auto rhsc = dynamic_cast<const FloatLiteral&>(rhs);
4366  if (this->value != rhsc.value) return false;
4367  return true;
4368 }
4369 
4374  ::tree::cbor::MapWriter &map,
4375  const ::tree::base::PointerMap &ids
4376 ) const {
4377  (void)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);
4381  submap.close();
4382  serialize_annotations(map);
4383 }
4384 
4388 std::shared_ptr<FloatLiteral> FloatLiteral::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4389  (void)ids;
4390  auto type = map.at("@t").as_string();
4391  if (type != "FloatLiteral") {
4392  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
4393  }
4394  auto node = std::make_shared<FloatLiteral>(
4395  cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Real>(map.at("value").as_map())
4396  );
4397  node->deserialize_annotations(map);
4398  return node;
4399 }
4400 
4404 ForLoop::ForLoop(const Maybe<Assignment> &initialize, const One<Expression> &condition, const Maybe<Assignment> &update, const One<StatementList> &body, const Any<AnnotationData> &annotations)
4405  : Structured(annotations), initialize(initialize), condition(condition), update(update), body(body)
4406 {}
4407 
4411 void ForLoop::find_reachable(::tree::base::PointerMap &map) const {
4412  (void)map;
4413  initialize.find_reachable(map);
4414  condition.find_reachable(map);
4415  update.find_reachable(map);
4416  body.find_reachable(map);
4417  annotations.find_reachable(map);
4418 }
4419 
4423 void ForLoop::check_complete(const ::tree::base::PointerMap &map) const {
4424  (void)map;
4425  initialize.check_complete(map);
4426  condition.check_complete(map);
4427  update.check_complete(map);
4428  body.check_complete(map);
4429  annotations.check_complete(map);
4430 }
4431 
4436  return NodeType::ForLoop;
4437 }
4438 
4442 void ForLoop::visit_internal(VisitorBase &visitor, void *retval) {
4443  visitor.raw_visit_for_loop(*this, retval);
4444 }
4445 
4451  return dynamic_cast<ForLoop*>(this);
4452 }
4453 
4459  return dynamic_cast<const ForLoop*>(this);
4460 }
4461 
4466  return cqasm::tree::make<ForLoop>(*this);
4467 }
4468 
4473  auto node = cqasm::tree::make<ForLoop>(*this);
4474  node->initialize = this->initialize.clone();
4475  node->condition = this->condition.clone();
4476  node->update = this->update.clone();
4477  node->body = this->body.clone();
4478  node->annotations = this->annotations.clone();
4479  return node;
4480 }
4481 
4485 bool ForLoop::equals(const Node &rhs) const {
4486  if (rhs.type() != NodeType::ForLoop) return false;
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;
4493  return true;
4494 }
4495 
4499 bool ForLoop::operator==(const Node &rhs) const {
4500  if (rhs.type() != NodeType::ForLoop) 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;
4507  return true;
4508 }
4509 
4514  ::tree::cbor::MapWriter &map,
4515  const ::tree::base::PointerMap &ids
4516 ) const {
4517  (void)ids;
4518  map.append_string("@t", "ForLoop");
4519  auto submap = map.append_map("initialize");
4520  initialize.serialize(submap, ids);
4521  submap.close();
4522  submap = map.append_map("condition");
4523  condition.serialize(submap, ids);
4524  submap.close();
4525  submap = map.append_map("update");
4526  update.serialize(submap, ids);
4527  submap.close();
4528  submap = map.append_map("body");
4529  body.serialize(submap, ids);
4530  submap.close();
4531  submap = map.append_map("annotations");
4532  annotations.serialize(submap, ids);
4533  submap.close();
4534  serialize_annotations(map);
4535 }
4536 
4540 std::shared_ptr<ForLoop> ForLoop::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4541  (void)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);
4545  }
4546  auto node = std::make_shared<ForLoop>(
4547  Maybe<Assignment>(map.at("initialize").as_map(), ids),
4548  One<Expression>(map.at("condition").as_map(), ids),
4549  Maybe<Assignment>(map.at("update").as_map(), ids),
4550  One<StatementList>(map.at("body").as_map(), ids),
4551  Any<AnnotationData>(map.at("annotations").as_map(), ids)
4552  );
4553  node->deserialize_annotations(map);
4554  return node;
4555 }
4556 
4561  : Structured(annotations), lhs(lhs), frm(frm), to(to), body(body)
4562 {}
4563 
4567 void ForeachLoop::find_reachable(::tree::base::PointerMap &map) const {
4568  (void)map;
4569  lhs.find_reachable(map);
4570  frm.find_reachable(map);
4571  to.find_reachable(map);
4572  body.find_reachable(map);
4573  annotations.find_reachable(map);
4574 }
4575 
4579 void ForeachLoop::check_complete(const ::tree::base::PointerMap &map) const {
4580  (void)map;
4581  lhs.check_complete(map);
4582  frm.check_complete(map);
4583  to.check_complete(map);
4584  body.check_complete(map);
4585  annotations.check_complete(map);
4586 }
4587 
4592  return NodeType::ForeachLoop;
4593 }
4594 
4598 void ForeachLoop::visit_internal(VisitorBase &visitor, void *retval) {
4599  visitor.raw_visit_foreach_loop(*this, retval);
4600 }
4601 
4607  return dynamic_cast<ForeachLoop*>(this);
4608 }
4609 
4615  return dynamic_cast<const ForeachLoop*>(this);
4616 }
4617 
4622  return cqasm::tree::make<ForeachLoop>(*this);
4623 }
4624 
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();
4634  node->annotations = this->annotations.clone();
4635  return node;
4636 }
4637 
4641 bool ForeachLoop::equals(const Node &rhs) const {
4642  if (rhs.type() != NodeType::ForeachLoop) return false;
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;
4649  return true;
4650 }
4651 
4655 bool ForeachLoop::operator==(const Node &rhs) const {
4656  if (rhs.type() != NodeType::ForeachLoop) 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;
4663  return true;
4664 }
4665 
4670  ::tree::cbor::MapWriter &map,
4671  const ::tree::base::PointerMap &ids
4672 ) const {
4673  (void)ids;
4674  map.append_string("@t", "ForeachLoop");
4675  auto submap = map.append_map("lhs");
4676  lhs.serialize(submap, ids);
4677  submap.close();
4678  submap = map.append_map("frm");
4679  frm.serialize(submap, ids);
4680  submap.close();
4681  submap = map.append_map("to");
4682  to.serialize(submap, ids);
4683  submap.close();
4684  submap = map.append_map("body");
4685  body.serialize(submap, ids);
4686  submap.close();
4687  submap = map.append_map("annotations");
4688  annotations.serialize(submap, ids);
4689  submap.close();
4690  serialize_annotations(map);
4691 }
4692 
4696 std::shared_ptr<ForeachLoop> ForeachLoop::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4697  (void)ids;
4698  auto type = map.at("@t").as_string();
4699  if (type != "ForeachLoop") {
4700  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
4701  }
4702  auto node = std::make_shared<ForeachLoop>(
4703  One<Expression>(map.at("lhs").as_map(), ids),
4704  One<Expression>(map.at("frm").as_map(), ids),
4705  One<Expression>(map.at("to").as_map(), ids),
4706  One<StatementList>(map.at("body").as_map(), ids),
4707  Any<AnnotationData>(map.at("annotations").as_map(), ids)
4708  );
4709  node->deserialize_annotations(map);
4710  return node;
4711 }
4712 
4717  : Expression(), name(name), arguments(arguments)
4718 {}
4719 
4723 void FunctionCall::find_reachable(::tree::base::PointerMap &map) const {
4724  (void)map;
4725  name.find_reachable(map);
4726  arguments.find_reachable(map);
4727 }
4728 
4732 void FunctionCall::check_complete(const ::tree::base::PointerMap &map) const {
4733  (void)map;
4734  name.check_complete(map);
4735  arguments.check_complete(map);
4736 }
4737 
4742  return NodeType::FunctionCall;
4743 }
4744 
4748 void FunctionCall::visit_internal(VisitorBase &visitor, void *retval) {
4749  visitor.raw_visit_function_call(*this, retval);
4750 }
4751 
4757  return dynamic_cast<FunctionCall*>(this);
4758 }
4759 
4765  return dynamic_cast<const FunctionCall*>(this);
4766 }
4767 
4772  return cqasm::tree::make<FunctionCall>(*this);
4773 }
4774 
4779  auto node = cqasm::tree::make<FunctionCall>(*this);
4780  node->name = this->name.clone();
4781  node->arguments = this->arguments.clone();
4782  return node;
4783 }
4784 
4788 bool FunctionCall::equals(const Node &rhs) const {
4789  if (rhs.type() != NodeType::FunctionCall) return false;
4790  auto rhsc = dynamic_cast<const FunctionCall&>(rhs);
4791  if (!this->name.equals(rhsc.name)) return false;
4792  if (!this->arguments.equals(rhsc.arguments)) return false;
4793  return true;
4794 }
4795 
4799 bool FunctionCall::operator==(const Node &rhs) const {
4800  if (rhs.type() != NodeType::FunctionCall) return false;
4801  auto rhsc = dynamic_cast<const FunctionCall&>(rhs);
4802  if (this->name != rhsc.name) return false;
4803  if (this->arguments != rhsc.arguments) return false;
4804  return true;
4805 }
4806 
4811  ::tree::cbor::MapWriter &map,
4812  const ::tree::base::PointerMap &ids
4813 ) const {
4814  (void)ids;
4815  map.append_string("@t", "FunctionCall");
4816  auto submap = map.append_map("name");
4817  name.serialize(submap, ids);
4818  submap.close();
4819  submap = map.append_map("arguments");
4820  arguments.serialize(submap, ids);
4821  submap.close();
4822  serialize_annotations(map);
4823 }
4824 
4828 std::shared_ptr<FunctionCall> FunctionCall::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4829  (void)ids;
4830  auto type = map.at("@t").as_string();
4831  if (type != "FunctionCall") {
4832  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
4833  }
4834  auto node = std::make_shared<FunctionCall>(
4835  One<Identifier>(map.at("name").as_map(), ids),
4836  One<ExpressionList>(map.at("arguments").as_map(), ids)
4837  );
4838  node->deserialize_annotations(map);
4839  return node;
4840 }
4841 
4846  : Expression(), name(name)
4847 {}
4848 
4852 void Identifier::find_reachable(::tree::base::PointerMap &map) const {
4853  (void)map;
4854 }
4855 
4859 void Identifier::check_complete(const ::tree::base::PointerMap &map) const {
4860  (void)map;
4861 }
4862 
4867  return NodeType::Identifier;
4868 }
4869 
4873 void Identifier::visit_internal(VisitorBase &visitor, void *retval) {
4874  visitor.raw_visit_identifier(*this, retval);
4875 }
4876 
4882  return dynamic_cast<Identifier*>(this);
4883 }
4884 
4890  return dynamic_cast<const Identifier*>(this);
4891 }
4892 
4897  return cqasm::tree::make<Identifier>(*this);
4898 }
4899 
4904  auto node = cqasm::tree::make<Identifier>(*this);
4905  return node;
4906 }
4907 
4911 bool Identifier::equals(const Node &rhs) const {
4912  if (rhs.type() != NodeType::Identifier) return false;
4913  auto rhsc = dynamic_cast<const Identifier&>(rhs);
4914  if (this->name != rhsc.name) return false;
4915  return true;
4916 }
4917 
4921 bool Identifier::operator==(const Node &rhs) const {
4922  if (rhs.type() != NodeType::Identifier) return false;
4923  auto rhsc = dynamic_cast<const Identifier&>(rhs);
4924  if (this->name != rhsc.name) return false;
4925  return true;
4926 }
4927 
4932  ::tree::cbor::MapWriter &map,
4933  const ::tree::base::PointerMap &ids
4934 ) const {
4935  (void)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);
4939  submap.close();
4940  serialize_annotations(map);
4941 }
4942 
4946 std::shared_ptr<Identifier> Identifier::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
4947  (void)ids;
4948  auto type = map.at("@t").as_string();
4949  if (type != "Identifier") {
4950  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
4951  }
4952  auto node = std::make_shared<Identifier>(
4953  cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at("name").as_map())
4954  );
4955  node->deserialize_annotations(map);
4956  return node;
4957 }
4958 
4962 IfElse::IfElse(const Many<IfElseBranch> &branches, const Maybe<StatementList> &otherwise, const Any<AnnotationData> &annotations)
4963  : Structured(annotations), branches(branches), otherwise(otherwise)
4964 {}
4965 
4969 void IfElse::find_reachable(::tree::base::PointerMap &map) const {
4970  (void)map;
4971  branches.find_reachable(map);
4972  otherwise.find_reachable(map);
4973  annotations.find_reachable(map);
4974 }
4975 
4979 void IfElse::check_complete(const ::tree::base::PointerMap &map) const {
4980  (void)map;
4981  branches.check_complete(map);
4982  otherwise.check_complete(map);
4983  annotations.check_complete(map);
4984 }
4985 
4990  return NodeType::IfElse;
4991 }
4992 
4996 void IfElse::visit_internal(VisitorBase &visitor, void *retval) {
4997  visitor.raw_visit_if_else(*this, retval);
4998 }
4999 
5005  return dynamic_cast<IfElse*>(this);
5006 }
5007 
5012 const IfElse *IfElse::as_if_else() const {
5013  return dynamic_cast<const IfElse*>(this);
5014 }
5015 
5020  return cqasm::tree::make<IfElse>(*this);
5021 }
5022 
5027  auto node = cqasm::tree::make<IfElse>(*this);
5028  node->branches = this->branches.clone();
5029  node->otherwise = this->otherwise.clone();
5030  node->annotations = this->annotations.clone();
5031  return node;
5032 }
5033 
5037 bool IfElse::equals(const Node &rhs) const {
5038  if (rhs.type() != NodeType::IfElse) return false;
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;
5043  return true;
5044 }
5045 
5049 bool IfElse::operator==(const Node &rhs) const {
5050  if (rhs.type() != NodeType::IfElse) 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;
5055  return true;
5056 }
5057 
5062  ::tree::cbor::MapWriter &map,
5063  const ::tree::base::PointerMap &ids
5064 ) const {
5065  (void)ids;
5066  map.append_string("@t", "IfElse");
5067  auto submap = map.append_map("branches");
5068  branches.serialize(submap, ids);
5069  submap.close();
5070  submap = map.append_map("otherwise");
5071  otherwise.serialize(submap, ids);
5072  submap.close();
5073  submap = map.append_map("annotations");
5074  annotations.serialize(submap, ids);
5075  submap.close();
5076  serialize_annotations(map);
5077 }
5078 
5082 std::shared_ptr<IfElse> IfElse::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5083  (void)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);
5087  }
5088  auto node = std::make_shared<IfElse>(
5089  Many<IfElseBranch>(map.at("branches").as_map(), ids),
5090  Maybe<StatementList>(map.at("otherwise").as_map(), ids),
5091  Any<AnnotationData>(map.at("annotations").as_map(), ids)
5092  );
5093  node->deserialize_annotations(map);
5094  return node;
5095 }
5096 
5101  : condition(condition), body(body)
5102 {}
5103 
5107 void IfElseBranch::find_reachable(::tree::base::PointerMap &map) const {
5108  (void)map;
5109  condition.find_reachable(map);
5110  body.find_reachable(map);
5111 }
5112 
5116 void IfElseBranch::check_complete(const ::tree::base::PointerMap &map) const {
5117  (void)map;
5118  condition.check_complete(map);
5119  body.check_complete(map);
5120 }
5121 
5126  return NodeType::IfElseBranch;
5127 }
5128 
5132 void IfElseBranch::visit_internal(VisitorBase &visitor, void *retval) {
5133  visitor.raw_visit_if_else_branch(*this, retval);
5134 }
5135 
5141  return dynamic_cast<IfElseBranch*>(this);
5142 }
5143 
5149  return dynamic_cast<const IfElseBranch*>(this);
5150 }
5151 
5156  return cqasm::tree::make<IfElseBranch>(*this);
5157 }
5158 
5163  auto node = cqasm::tree::make<IfElseBranch>(*this);
5164  node->condition = this->condition.clone();
5165  node->body = this->body.clone();
5166  return node;
5167 }
5168 
5172 bool IfElseBranch::equals(const Node &rhs) const {
5173  if (rhs.type() != NodeType::IfElseBranch) return false;
5174  auto rhsc = dynamic_cast<const IfElseBranch&>(rhs);
5175  if (!this->condition.equals(rhsc.condition)) return false;
5176  if (!this->body.equals(rhsc.body)) return false;
5177  return true;
5178 }
5179 
5183 bool IfElseBranch::operator==(const Node &rhs) const {
5184  if (rhs.type() != NodeType::IfElseBranch) return false;
5185  auto rhsc = dynamic_cast<const IfElseBranch&>(rhs);
5186  if (this->condition != rhsc.condition) return false;
5187  if (this->body != rhsc.body) return false;
5188  return true;
5189 }
5190 
5195  ::tree::cbor::MapWriter &map,
5196  const ::tree::base::PointerMap &ids
5197 ) const {
5198  (void)ids;
5199  map.append_string("@t", "IfElseBranch");
5200  auto submap = map.append_map("condition");
5201  condition.serialize(submap, ids);
5202  submap.close();
5203  submap = map.append_map("body");
5204  body.serialize(submap, ids);
5205  submap.close();
5206  serialize_annotations(map);
5207 }
5208 
5212 std::shared_ptr<IfElseBranch> IfElseBranch::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5213  (void)ids;
5214  auto type = map.at("@t").as_string();
5215  if (type != "IfElseBranch") {
5216  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
5217  }
5218  auto node = std::make_shared<IfElseBranch>(
5219  One<Expression>(map.at("condition").as_map(), ids),
5220  One<StatementList>(map.at("body").as_map(), ids)
5221  );
5222  node->deserialize_annotations(map);
5223  return node;
5224 }
5225 
5229 Index::Index(const One<Expression> &expr, const One<IndexList> &indices)
5230  : Expression(), expr(expr), indices(indices)
5231 {}
5232 
5236 void Index::find_reachable(::tree::base::PointerMap &map) const {
5237  (void)map;
5238  expr.find_reachable(map);
5239  indices.find_reachable(map);
5240 }
5241 
5245 void Index::check_complete(const ::tree::base::PointerMap &map) const {
5246  (void)map;
5247  expr.check_complete(map);
5248  indices.check_complete(map);
5249 }
5250 
5255  return NodeType::Index;
5256 }
5257 
5261 void Index::visit_internal(VisitorBase &visitor, void *retval) {
5262  visitor.raw_visit_index(*this, retval);
5263 }
5264 
5270  return dynamic_cast<Index*>(this);
5271 }
5272 
5277 const Index *Index::as_index() const {
5278  return dynamic_cast<const Index*>(this);
5279 }
5280 
5285  return cqasm::tree::make<Index>(*this);
5286 }
5287 
5292  auto node = cqasm::tree::make<Index>(*this);
5293  node->expr = this->expr.clone();
5294  node->indices = this->indices.clone();
5295  return node;
5296 }
5297 
5301 bool Index::equals(const Node &rhs) const {
5302  if (rhs.type() != NodeType::Index) return false;
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;
5306  return true;
5307 }
5308 
5312 bool Index::operator==(const Node &rhs) const {
5313  if (rhs.type() != NodeType::Index) 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;
5317  return true;
5318 }
5319 
5324  ::tree::cbor::MapWriter &map,
5325  const ::tree::base::PointerMap &ids
5326 ) const {
5327  (void)ids;
5328  map.append_string("@t", "Index");
5329  auto submap = map.append_map("expr");
5330  expr.serialize(submap, ids);
5331  submap.close();
5332  submap = map.append_map("indices");
5333  indices.serialize(submap, ids);
5334  submap.close();
5335  serialize_annotations(map);
5336 }
5337 
5341 std::shared_ptr<Index> Index::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5342  (void)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);
5346  }
5347  auto node = std::make_shared<Index>(
5348  One<Expression>(map.at("expr").as_map(), ids),
5349  One<IndexList>(map.at("indices").as_map(), ids)
5350  );
5351  node->deserialize_annotations(map);
5352  return node;
5353 }
5354 
5360  return dynamic_cast<IndexEntry*>(this);
5361 }
5362 
5368  return dynamic_cast<const IndexEntry*>(this);
5369 }
5370 
5374 std::shared_ptr<IndexEntry> IndexEntry::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5375  auto type = map.at("@t").as_string();
5376  if (type == "IndexItem") return IndexItem::deserialize(map, ids);
5377  if (type == "IndexRange") return IndexRange::deserialize(map, ids);
5378  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
5379 }
5380 
5385  : IndexEntry(), index(index)
5386 {}
5387 
5391 void IndexItem::find_reachable(::tree::base::PointerMap &map) const {
5392  (void)map;
5393  index.find_reachable(map);
5394 }
5395 
5399 void IndexItem::check_complete(const ::tree::base::PointerMap &map) const {
5400  (void)map;
5401  index.check_complete(map);
5402 }
5403 
5408  return NodeType::IndexItem;
5409 }
5410 
5414 void IndexItem::visit_internal(VisitorBase &visitor, void *retval) {
5415  visitor.raw_visit_index_item(*this, retval);
5416 }
5417 
5423  return dynamic_cast<IndexItem*>(this);
5424 }
5425 
5431  return dynamic_cast<const IndexItem*>(this);
5432 }
5433 
5438  return cqasm::tree::make<IndexItem>(*this);
5439 }
5440 
5445  auto node = cqasm::tree::make<IndexItem>(*this);
5446  node->index = this->index.clone();
5447  return node;
5448 }
5449 
5453 bool IndexItem::equals(const Node &rhs) const {
5454  if (rhs.type() != NodeType::IndexItem) return false;
5455  auto rhsc = dynamic_cast<const IndexItem&>(rhs);
5456  if (!this->index.equals(rhsc.index)) return false;
5457  return true;
5458 }
5459 
5463 bool IndexItem::operator==(const Node &rhs) const {
5464  if (rhs.type() != NodeType::IndexItem) return false;
5465  auto rhsc = dynamic_cast<const IndexItem&>(rhs);
5466  if (this->index != rhsc.index) return false;
5467  return true;
5468 }
5469 
5474  ::tree::cbor::MapWriter &map,
5475  const ::tree::base::PointerMap &ids
5476 ) const {
5477  (void)ids;
5478  map.append_string("@t", "IndexItem");
5479  auto submap = map.append_map("index");
5480  index.serialize(submap, ids);
5481  submap.close();
5482  serialize_annotations(map);
5483 }
5484 
5488 std::shared_ptr<IndexItem> IndexItem::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5489  (void)ids;
5490  auto type = map.at("@t").as_string();
5491  if (type != "IndexItem") {
5492  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
5493  }
5494  auto node = std::make_shared<IndexItem>(
5495  One<Expression>(map.at("index").as_map(), ids)
5496  );
5497  node->deserialize_annotations(map);
5498  return node;
5499 }
5500 
5505  : items(items)
5506 {}
5507 
5511 void IndexList::find_reachable(::tree::base::PointerMap &map) const {
5512  (void)map;
5513  items.find_reachable(map);
5514 }
5515 
5519 void IndexList::check_complete(const ::tree::base::PointerMap &map) const {
5520  (void)map;
5521  items.check_complete(map);
5522 }
5523 
5528  return NodeType::IndexList;
5529 }
5530 
5534 void IndexList::visit_internal(VisitorBase &visitor, void *retval) {
5535  visitor.raw_visit_index_list(*this, retval);
5536 }
5537 
5543  return dynamic_cast<IndexList*>(this);
5544 }
5545 
5551  return dynamic_cast<const IndexList*>(this);
5552 }
5553 
5558  return cqasm::tree::make<IndexList>(*this);
5559 }
5560 
5565  auto node = cqasm::tree::make<IndexList>(*this);
5566  node->items = this->items.clone();
5567  return node;
5568 }
5569 
5573 bool IndexList::equals(const Node &rhs) const {
5574  if (rhs.type() != NodeType::IndexList) return false;
5575  auto rhsc = dynamic_cast<const IndexList&>(rhs);
5576  if (!this->items.equals(rhsc.items)) return false;
5577  return true;
5578 }
5579 
5583 bool IndexList::operator==(const Node &rhs) const {
5584  if (rhs.type() != NodeType::IndexList) return false;
5585  auto rhsc = dynamic_cast<const IndexList&>(rhs);
5586  if (this->items != rhsc.items) return false;
5587  return true;
5588 }
5589 
5594  ::tree::cbor::MapWriter &map,
5595  const ::tree::base::PointerMap &ids
5596 ) const {
5597  (void)ids;
5598  map.append_string("@t", "IndexList");
5599  auto submap = map.append_map("items");
5600  items.serialize(submap, ids);
5601  submap.close();
5602  serialize_annotations(map);
5603 }
5604 
5608 std::shared_ptr<IndexList> IndexList::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5609  (void)ids;
5610  auto type = map.at("@t").as_string();
5611  if (type != "IndexList") {
5612  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
5613  }
5614  auto node = std::make_shared<IndexList>(
5615  Many<IndexEntry>(map.at("items").as_map(), ids)
5616  );
5617  node->deserialize_annotations(map);
5618  return node;
5619 }
5620 
5625  : IndexEntry(), first(first), last(last)
5626 {}
5627 
5631 void IndexRange::find_reachable(::tree::base::PointerMap &map) const {
5632  (void)map;
5633  first.find_reachable(map);
5634  last.find_reachable(map);
5635 }
5636 
5640 void IndexRange::check_complete(const ::tree::base::PointerMap &map) const {
5641  (void)map;
5642  first.check_complete(map);
5643  last.check_complete(map);
5644 }
5645 
5650  return NodeType::IndexRange;
5651 }
5652 
5656 void IndexRange::visit_internal(VisitorBase &visitor, void *retval) {
5657  visitor.raw_visit_index_range(*this, retval);
5658 }
5659 
5665  return dynamic_cast<IndexRange*>(this);
5666 }
5667 
5673  return dynamic_cast<const IndexRange*>(this);
5674 }
5675 
5680  return cqasm::tree::make<IndexRange>(*this);
5681 }
5682 
5687  auto node = cqasm::tree::make<IndexRange>(*this);
5688  node->first = this->first.clone();
5689  node->last = this->last.clone();
5690  return node;
5691 }
5692 
5696 bool IndexRange::equals(const Node &rhs) const {
5697  if (rhs.type() != NodeType::IndexRange) return false;
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;
5701  return true;
5702 }
5703 
5707 bool IndexRange::operator==(const Node &rhs) const {
5708  if (rhs.type() != NodeType::IndexRange) 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;
5712  return true;
5713 }
5714 
5719  ::tree::cbor::MapWriter &map,
5720  const ::tree::base::PointerMap &ids
5721 ) const {
5722  (void)ids;
5723  map.append_string("@t", "IndexRange");
5724  auto submap = map.append_map("first");
5725  first.serialize(submap, ids);
5726  submap.close();
5727  submap = map.append_map("last");
5728  last.serialize(submap, ids);
5729  submap.close();
5730  serialize_annotations(map);
5731 }
5732 
5736 std::shared_ptr<IndexRange> IndexRange::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5737  (void)ids;
5738  auto type = map.at("@t").as_string();
5739  if (type != "IndexRange") {
5740  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
5741  }
5742  auto node = std::make_shared<IndexRange>(
5743  One<Expression>(map.at("first").as_map(), ids),
5744  One<Expression>(map.at("last").as_map(), ids)
5745  );
5746  node->deserialize_annotations(map);
5747  return node;
5748 }
5749 
5753 Instruction::Instruction(const One<Identifier> &name, const Maybe<Expression> &condition, const One<ExpressionList> &operands, const Any<AnnotationData> &annotations)
5754  : Annotated(annotations), name(name), condition(condition), operands(operands)
5755 {}
5756 
5760 void Instruction::find_reachable(::tree::base::PointerMap &map) const {
5761  (void)map;
5762  name.find_reachable(map);
5763  condition.find_reachable(map);
5764  operands.find_reachable(map);
5765  annotations.find_reachable(map);
5766 }
5767 
5771 void Instruction::check_complete(const ::tree::base::PointerMap &map) const {
5772  (void)map;
5773  name.check_complete(map);
5774  condition.check_complete(map);
5775  operands.check_complete(map);
5776  annotations.check_complete(map);
5777 }
5778 
5783  return NodeType::Instruction;
5784 }
5785 
5789 void Instruction::visit_internal(VisitorBase &visitor, void *retval) {
5790  visitor.raw_visit_instruction(*this, retval);
5791 }
5792 
5798  return dynamic_cast<Instruction*>(this);
5799 }
5800 
5806  return dynamic_cast<const Instruction*>(this);
5807 }
5808 
5813  return cqasm::tree::make<Instruction>(*this);
5814 }
5815 
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();
5824  node->annotations = this->annotations.clone();
5825  return node;
5826 }
5827 
5831 bool Instruction::equals(const Node &rhs) const {
5832  if (rhs.type() != NodeType::Instruction) return false;
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;
5838  return true;
5839 }
5840 
5844 bool Instruction::operator==(const Node &rhs) const {
5845  if (rhs.type() != NodeType::Instruction) 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;
5851  return true;
5852 }
5853 
5858  ::tree::cbor::MapWriter &map,
5859  const ::tree::base::PointerMap &ids
5860 ) const {
5861  (void)ids;
5862  map.append_string("@t", "Instruction");
5863  auto submap = map.append_map("name");
5864  name.serialize(submap, ids);
5865  submap.close();
5866  submap = map.append_map("condition");
5867  condition.serialize(submap, ids);
5868  submap.close();
5869  submap = map.append_map("operands");
5870  operands.serialize(submap, ids);
5871  submap.close();
5872  submap = map.append_map("annotations");
5873  annotations.serialize(submap, ids);
5874  submap.close();
5875  serialize_annotations(map);
5876 }
5877 
5881 std::shared_ptr<Instruction> Instruction::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
5882  (void)ids;
5883  auto type = map.at("@t").as_string();
5884  if (type != "Instruction") {
5885  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
5886  }
5887  auto node = std::make_shared<Instruction>(
5888  One<Identifier>(map.at("name").as_map(), ids),
5889  Maybe<Expression>(map.at("condition").as_map(), ids),
5890  One<ExpressionList>(map.at("operands").as_map(), ids),
5891  Any<AnnotationData>(map.at("annotations").as_map(), ids)
5892  );
5893  node->deserialize_annotations(map);
5894  return node;
5895 }
5896 
5901  : ArithOp(lhs, rhs)
5902 {}
5903 
5907 void IntDivide::find_reachable(::tree::base::PointerMap &map) const {
5908  (void)map;
5909  lhs.find_reachable(map);
5910  rhs.find_reachable(map);
5911 }
5912 
5916 void IntDivide::check_complete(const ::tree::base::PointerMap &map) const {
5917  (void)map;
5918  lhs.check_complete(map);
5919  rhs.check_complete(map);
5920 }
5921 
5926  return NodeType::IntDivide;
5927 }
5928 
5932 void IntDivide::visit_internal(VisitorBase &visitor, void *retval) {
5933  visitor.raw_visit_int_divide(*this, retval);
5934 }
5935 
5941  return dynamic_cast<IntDivide*>(this);
5942 }
5943 
5949  return dynamic_cast<const IntDivide*>(this);
5950 }
5951 
5956  return cqasm::tree::make<IntDivide>(*this);
5957 }
5958 
5963  auto node = cqasm::tree::make<IntDivide>(*this);
5964  node->lhs = this->lhs.clone();
5965  node->rhs = this->rhs.clone();
5966  return node;
5967 }
5968 
5972 bool IntDivide::equals(const Node &rhs) const {
5973  if (rhs.type() != NodeType::IntDivide) return false;
5974  auto rhsc = dynamic_cast<const IntDivide&>(rhs);
5975  if (!this->lhs.equals(rhsc.lhs)) return false;
5976  if (!this->rhs.equals(rhsc.rhs)) return false;
5977  return true;
5978 }
5979 
5983 bool IntDivide::operator==(const Node &rhs) const {
5984  if (rhs.type() != NodeType::IntDivide) return false;
5985  auto rhsc = dynamic_cast<const IntDivide&>(rhs);
5986  if (this->lhs != rhsc.lhs) return false;
5987  if (this->rhs != rhsc.rhs) return false;
5988  return true;
5989 }
5990 
5995  ::tree::cbor::MapWriter &map,
5996  const ::tree::base::PointerMap &ids
5997 ) const {
5998  (void)ids;
5999  map.append_string("@t", "IntDivide");
6000  auto submap = map.append_map("lhs");
6001  lhs.serialize(submap, ids);
6002  submap.close();
6003  submap = map.append_map("rhs");
6004  rhs.serialize(submap, ids);
6005  submap.close();
6006  serialize_annotations(map);
6007 }
6008 
6012 std::shared_ptr<IntDivide> IntDivide::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6013  (void)ids;
6014  auto type = map.at("@t").as_string();
6015  if (type != "IntDivide") {
6016  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6017  }
6018  auto node = std::make_shared<IntDivide>(
6019  One<Expression>(map.at("lhs").as_map(), ids),
6020  One<Expression>(map.at("rhs").as_map(), ids)
6021  );
6022  node->deserialize_annotations(map);
6023  return node;
6024 }
6025 
6030  : Expression(), value(value)
6031 {}
6032 
6036 void IntegerLiteral::find_reachable(::tree::base::PointerMap &map) const {
6037  (void)map;
6038 }
6039 
6043 void IntegerLiteral::check_complete(const ::tree::base::PointerMap &map) const {
6044  (void)map;
6045 }
6046 
6051  return NodeType::IntegerLiteral;
6052 }
6053 
6057 void IntegerLiteral::visit_internal(VisitorBase &visitor, void *retval) {
6058  visitor.raw_visit_integer_literal(*this, retval);
6059 }
6060 
6066  return dynamic_cast<IntegerLiteral*>(this);
6067 }
6068 
6074  return dynamic_cast<const IntegerLiteral*>(this);
6075 }
6076 
6081  return cqasm::tree::make<IntegerLiteral>(*this);
6082 }
6083 
6088  auto node = cqasm::tree::make<IntegerLiteral>(*this);
6089  return node;
6090 }
6091 
6095 bool IntegerLiteral::equals(const Node &rhs) const {
6096  if (rhs.type() != NodeType::IntegerLiteral) return false;
6097  auto rhsc = dynamic_cast<const IntegerLiteral&>(rhs);
6098  if (this->value != rhsc.value) return false;
6099  return true;
6100 }
6101 
6105 bool IntegerLiteral::operator==(const Node &rhs) const {
6106  if (rhs.type() != NodeType::IntegerLiteral) return false;
6107  auto rhsc = dynamic_cast<const IntegerLiteral&>(rhs);
6108  if (this->value != rhsc.value) return false;
6109  return true;
6110 }
6111 
6116  ::tree::cbor::MapWriter &map,
6117  const ::tree::base::PointerMap &ids
6118 ) const {
6119  (void)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);
6123  submap.close();
6124  serialize_annotations(map);
6125 }
6126 
6130 std::shared_ptr<IntegerLiteral> IntegerLiteral::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6131  (void)ids;
6132  auto type = map.at("@t").as_string();
6133  if (type != "IntegerLiteral") {
6134  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6135  }
6136  auto node = std::make_shared<IntegerLiteral>(
6137  cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Int>(map.at("value").as_map())
6138  );
6139  node->deserialize_annotations(map);
6140  return node;
6141 }
6142 
6147  : Expression(), value(value)
6148 {}
6149 
6153 void JsonLiteral::find_reachable(::tree::base::PointerMap &map) const {
6154  (void)map;
6155 }
6156 
6160 void JsonLiteral::check_complete(const ::tree::base::PointerMap &map) const {
6161  (void)map;
6162 }
6163 
6168  return NodeType::JsonLiteral;
6169 }
6170 
6174 void JsonLiteral::visit_internal(VisitorBase &visitor, void *retval) {
6175  visitor.raw_visit_json_literal(*this, retval);
6176 }
6177 
6183  return dynamic_cast<JsonLiteral*>(this);
6184 }
6185 
6191  return dynamic_cast<const JsonLiteral*>(this);
6192 }
6193 
6198  return cqasm::tree::make<JsonLiteral>(*this);
6199 }
6200 
6205  auto node = cqasm::tree::make<JsonLiteral>(*this);
6206  return node;
6207 }
6208 
6212 bool JsonLiteral::equals(const Node &rhs) const {
6213  if (rhs.type() != NodeType::JsonLiteral) return false;
6214  auto rhsc = dynamic_cast<const JsonLiteral&>(rhs);
6215  if (this->value != rhsc.value) return false;
6216  return true;
6217 }
6218 
6222 bool JsonLiteral::operator==(const Node &rhs) const {
6223  if (rhs.type() != NodeType::JsonLiteral) return false;
6224  auto rhsc = dynamic_cast<const JsonLiteral&>(rhs);
6225  if (this->value != rhsc.value) return false;
6226  return true;
6227 }
6228 
6233  ::tree::cbor::MapWriter &map,
6234  const ::tree::base::PointerMap &ids
6235 ) const {
6236  (void)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);
6240  submap.close();
6241  serialize_annotations(map);
6242 }
6243 
6247 std::shared_ptr<JsonLiteral> JsonLiteral::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6248  (void)ids;
6249  auto type = map.at("@t").as_string();
6250  if (type != "JsonLiteral") {
6251  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6252  }
6253  auto node = std::make_shared<JsonLiteral>(
6254  cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at("value").as_map())
6255  );
6256  node->deserialize_annotations(map);
6257  return node;
6258 }
6259 
6264  : BinaryOp(lhs, rhs)
6265 {}
6266 
6272  return dynamic_cast<LogicalOp*>(this);
6273 }
6274 
6280  return dynamic_cast<const LogicalOp*>(this);
6281 }
6282 
6286 std::shared_ptr<LogicalOp> LogicalOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6287  auto type = map.at("@t").as_string();
6288  if (type == "LogicalAnd") return LogicalAnd::deserialize(map, ids);
6289  if (type == "LogicalXor") return LogicalXor::deserialize(map, ids);
6290  if (type == "LogicalOr") return LogicalOr::deserialize(map, ids);
6291  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6292 }
6293 
6298  : LogicalOp(lhs, rhs)
6299 {}
6300 
6304 void LogicalAnd::find_reachable(::tree::base::PointerMap &map) const {
6305  (void)map;
6306  lhs.find_reachable(map);
6307  rhs.find_reachable(map);
6308 }
6309 
6313 void LogicalAnd::check_complete(const ::tree::base::PointerMap &map) const {
6314  (void)map;
6315  lhs.check_complete(map);
6316  rhs.check_complete(map);
6317 }
6318 
6323  return NodeType::LogicalAnd;
6324 }
6325 
6329 void LogicalAnd::visit_internal(VisitorBase &visitor, void *retval) {
6330  visitor.raw_visit_logical_and(*this, retval);
6331 }
6332 
6338  return dynamic_cast<LogicalAnd*>(this);
6339 }
6340 
6346  return dynamic_cast<const LogicalAnd*>(this);
6347 }
6348 
6353  return cqasm::tree::make<LogicalAnd>(*this);
6354 }
6355 
6360  auto node = cqasm::tree::make<LogicalAnd>(*this);
6361  node->lhs = this->lhs.clone();
6362  node->rhs = this->rhs.clone();
6363  return node;
6364 }
6365 
6369 bool LogicalAnd::equals(const Node &rhs) const {
6370  if (rhs.type() != NodeType::LogicalAnd) return false;
6371  auto rhsc = dynamic_cast<const LogicalAnd&>(rhs);
6372  if (!this->lhs.equals(rhsc.lhs)) return false;
6373  if (!this->rhs.equals(rhsc.rhs)) return false;
6374  return true;
6375 }
6376 
6380 bool LogicalAnd::operator==(const Node &rhs) const {
6381  if (rhs.type() != NodeType::LogicalAnd) return false;
6382  auto rhsc = dynamic_cast<const LogicalAnd&>(rhs);
6383  if (this->lhs != rhsc.lhs) return false;
6384  if (this->rhs != rhsc.rhs) return false;
6385  return true;
6386 }
6387 
6392  ::tree::cbor::MapWriter &map,
6393  const ::tree::base::PointerMap &ids
6394 ) const {
6395  (void)ids;
6396  map.append_string("@t", "LogicalAnd");
6397  auto submap = map.append_map("lhs");
6398  lhs.serialize(submap, ids);
6399  submap.close();
6400  submap = map.append_map("rhs");
6401  rhs.serialize(submap, ids);
6402  submap.close();
6403  serialize_annotations(map);
6404 }
6405 
6409 std::shared_ptr<LogicalAnd> LogicalAnd::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6410  (void)ids;
6411  auto type = map.at("@t").as_string();
6412  if (type != "LogicalAnd") {
6413  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6414  }
6415  auto node = std::make_shared<LogicalAnd>(
6416  One<Expression>(map.at("lhs").as_map(), ids),
6417  One<Expression>(map.at("rhs").as_map(), ids)
6418  );
6419  node->deserialize_annotations(map);
6420  return node;
6421 }
6422 
6427  : UnaryOp(expr)
6428 {}
6429 
6433 void LogicalNot::find_reachable(::tree::base::PointerMap &map) const {
6434  (void)map;
6435  expr.find_reachable(map);
6436 }
6437 
6441 void LogicalNot::check_complete(const ::tree::base::PointerMap &map) const {
6442  (void)map;
6443  expr.check_complete(map);
6444 }
6445 
6450  return NodeType::LogicalNot;
6451 }
6452 
6456 void LogicalNot::visit_internal(VisitorBase &visitor, void *retval) {
6457  visitor.raw_visit_logical_not(*this, retval);
6458 }
6459 
6465  return dynamic_cast<LogicalNot*>(this);
6466 }
6467 
6473  return dynamic_cast<const LogicalNot*>(this);
6474 }
6475 
6480  return cqasm::tree::make<LogicalNot>(*this);
6481 }
6482 
6487  auto node = cqasm::tree::make<LogicalNot>(*this);
6488  node->expr = this->expr.clone();
6489  return node;
6490 }
6491 
6495 bool LogicalNot::equals(const Node &rhs) const {
6496  if (rhs.type() != NodeType::LogicalNot) return false;
6497  auto rhsc = dynamic_cast<const LogicalNot&>(rhs);
6498  if (!this->expr.equals(rhsc.expr)) return false;
6499  return true;
6500 }
6501 
6505 bool LogicalNot::operator==(const Node &rhs) const {
6506  if (rhs.type() != NodeType::LogicalNot) return false;
6507  auto rhsc = dynamic_cast<const LogicalNot&>(rhs);
6508  if (this->expr != rhsc.expr) return false;
6509  return true;
6510 }
6511 
6516  ::tree::cbor::MapWriter &map,
6517  const ::tree::base::PointerMap &ids
6518 ) const {
6519  (void)ids;
6520  map.append_string("@t", "LogicalNot");
6521  auto submap = map.append_map("expr");
6522  expr.serialize(submap, ids);
6523  submap.close();
6524  serialize_annotations(map);
6525 }
6526 
6530 std::shared_ptr<LogicalNot> LogicalNot::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6531  (void)ids;
6532  auto type = map.at("@t").as_string();
6533  if (type != "LogicalNot") {
6534  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6535  }
6536  auto node = std::make_shared<LogicalNot>(
6537  One<Expression>(map.at("expr").as_map(), ids)
6538  );
6539  node->deserialize_annotations(map);
6540  return node;
6541 }
6542 
6547  : LogicalOp(lhs, rhs)
6548 {}
6549 
6553 void LogicalOr::find_reachable(::tree::base::PointerMap &map) const {
6554  (void)map;
6555  lhs.find_reachable(map);
6556  rhs.find_reachable(map);
6557 }
6558 
6562 void LogicalOr::check_complete(const ::tree::base::PointerMap &map) const {
6563  (void)map;
6564  lhs.check_complete(map);
6565  rhs.check_complete(map);
6566 }
6567 
6572  return NodeType::LogicalOr;
6573 }
6574 
6578 void LogicalOr::visit_internal(VisitorBase &visitor, void *retval) {
6579  visitor.raw_visit_logical_or(*this, retval);
6580 }
6581 
6587  return dynamic_cast<LogicalOr*>(this);
6588 }
6589 
6595  return dynamic_cast<const LogicalOr*>(this);
6596 }
6597 
6602  return cqasm::tree::make<LogicalOr>(*this);
6603 }
6604 
6609  auto node = cqasm::tree::make<LogicalOr>(*this);
6610  node->lhs = this->lhs.clone();
6611  node->rhs = this->rhs.clone();
6612  return node;
6613 }
6614 
6618 bool LogicalOr::equals(const Node &rhs) const {
6619  if (rhs.type() != NodeType::LogicalOr) return false;
6620  auto rhsc = dynamic_cast<const LogicalOr&>(rhs);
6621  if (!this->lhs.equals(rhsc.lhs)) return false;
6622  if (!this->rhs.equals(rhsc.rhs)) return false;
6623  return true;
6624 }
6625 
6629 bool LogicalOr::operator==(const Node &rhs) const {
6630  if (rhs.type() != NodeType::LogicalOr) return false;
6631  auto rhsc = dynamic_cast<const LogicalOr&>(rhs);
6632  if (this->lhs != rhsc.lhs) return false;
6633  if (this->rhs != rhsc.rhs) return false;
6634  return true;
6635 }
6636 
6641  ::tree::cbor::MapWriter &map,
6642  const ::tree::base::PointerMap &ids
6643 ) const {
6644  (void)ids;
6645  map.append_string("@t", "LogicalOr");
6646  auto submap = map.append_map("lhs");
6647  lhs.serialize(submap, ids);
6648  submap.close();
6649  submap = map.append_map("rhs");
6650  rhs.serialize(submap, ids);
6651  submap.close();
6652  serialize_annotations(map);
6653 }
6654 
6658 std::shared_ptr<LogicalOr> LogicalOr::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6659  (void)ids;
6660  auto type = map.at("@t").as_string();
6661  if (type != "LogicalOr") {
6662  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6663  }
6664  auto node = std::make_shared<LogicalOr>(
6665  One<Expression>(map.at("lhs").as_map(), ids),
6666  One<Expression>(map.at("rhs").as_map(), ids)
6667  );
6668  node->deserialize_annotations(map);
6669  return node;
6670 }
6671 
6676  : LogicalOp(lhs, rhs)
6677 {}
6678 
6682 void LogicalXor::find_reachable(::tree::base::PointerMap &map) const {
6683  (void)map;
6684  lhs.find_reachable(map);
6685  rhs.find_reachable(map);
6686 }
6687 
6691 void LogicalXor::check_complete(const ::tree::base::PointerMap &map) const {
6692  (void)map;
6693  lhs.check_complete(map);
6694  rhs.check_complete(map);
6695 }
6696 
6701  return NodeType::LogicalXor;
6702 }
6703 
6707 void LogicalXor::visit_internal(VisitorBase &visitor, void *retval) {
6708  visitor.raw_visit_logical_xor(*this, retval);
6709 }
6710 
6716  return dynamic_cast<LogicalXor*>(this);
6717 }
6718 
6724  return dynamic_cast<const LogicalXor*>(this);
6725 }
6726 
6731  return cqasm::tree::make<LogicalXor>(*this);
6732 }
6733 
6738  auto node = cqasm::tree::make<LogicalXor>(*this);
6739  node->lhs = this->lhs.clone();
6740  node->rhs = this->rhs.clone();
6741  return node;
6742 }
6743 
6747 bool LogicalXor::equals(const Node &rhs) const {
6748  if (rhs.type() != NodeType::LogicalXor) return false;
6749  auto rhsc = dynamic_cast<const LogicalXor&>(rhs);
6750  if (!this->lhs.equals(rhsc.lhs)) return false;
6751  if (!this->rhs.equals(rhsc.rhs)) return false;
6752  return true;
6753 }
6754 
6758 bool LogicalXor::operator==(const Node &rhs) const {
6759  if (rhs.type() != NodeType::LogicalXor) return false;
6760  auto rhsc = dynamic_cast<const LogicalXor&>(rhs);
6761  if (this->lhs != rhsc.lhs) return false;
6762  if (this->rhs != rhsc.rhs) return false;
6763  return true;
6764 }
6765 
6770  ::tree::cbor::MapWriter &map,
6771  const ::tree::base::PointerMap &ids
6772 ) const {
6773  (void)ids;
6774  map.append_string("@t", "LogicalXor");
6775  auto submap = map.append_map("lhs");
6776  lhs.serialize(submap, ids);
6777  submap.close();
6778  submap = map.append_map("rhs");
6779  rhs.serialize(submap, ids);
6780  submap.close();
6781  serialize_annotations(map);
6782 }
6783 
6787 std::shared_ptr<LogicalXor> LogicalXor::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6788  (void)ids;
6789  auto type = map.at("@t").as_string();
6790  if (type != "LogicalXor") {
6791  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
6792  }
6793  auto node = std::make_shared<LogicalXor>(
6794  One<Expression>(map.at("lhs").as_map(), ids),
6795  One<Expression>(map.at("rhs").as_map(), ids)
6796  );
6797  node->deserialize_annotations(map);
6798  return node;
6799 }
6800 
6804 Mapping::Mapping(const One<Identifier> &alias, const One<Expression> &expr, const Any<AnnotationData> &annotations)
6805  : Statement(annotations), alias(alias), expr(expr)
6806 {}
6807 
6811 void Mapping::find_reachable(::tree::base::PointerMap &map) const {
6812  (void)map;
6813  alias.find_reachable(map);
6814  expr.find_reachable(map);
6815  annotations.find_reachable(map);
6816 }
6817 
6821 void Mapping::check_complete(const ::tree::base::PointerMap &map) const {
6822  (void)map;
6823  alias.check_complete(map);
6824  expr.check_complete(map);
6825  annotations.check_complete(map);
6826 }
6827 
6832  return NodeType::Mapping;
6833 }
6834 
6838 void Mapping::visit_internal(VisitorBase &visitor, void *retval) {
6839  visitor.raw_visit_mapping(*this, retval);
6840 }
6841 
6847  return dynamic_cast<Mapping*>(this);
6848 }
6849 
6855  return dynamic_cast<const Mapping*>(this);
6856 }
6857 
6862  return cqasm::tree::make<Mapping>(*this);
6863 }
6864 
6869  auto node = cqasm::tree::make<Mapping>(*this);
6870  node->alias = this->alias.clone();
6871  node->expr = this->expr.clone();
6872  node->annotations = this->annotations.clone();
6873  return node;
6874 }
6875 
6879 bool Mapping::equals(const Node &rhs) const {
6880  if (rhs.type() != NodeType::Mapping) return false;
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;
6885  return true;
6886 }
6887 
6891 bool Mapping::operator==(const Node &rhs) const {
6892  if (rhs.type() != NodeType::Mapping) 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;
6897  return true;
6898 }
6899 
6904  ::tree::cbor::MapWriter &map,
6905  const ::tree::base::PointerMap &ids
6906 ) const {
6907  (void)ids;
6908  map.append_string("@t", "Mapping");
6909  auto submap = map.append_map("alias");
6910  alias.serialize(submap, ids);
6911  submap.close();
6912  submap = map.append_map("expr");
6913  expr.serialize(submap, ids);
6914  submap.close();
6915  submap = map.append_map("annotations");
6916  annotations.serialize(submap, ids);
6917  submap.close();
6918  serialize_annotations(map);
6919 }
6920 
6924 std::shared_ptr<Mapping> Mapping::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
6925  (void)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);
6929  }
6930  auto node = std::make_shared<Mapping>(
6931  One<Identifier>(map.at("alias").as_map(), ids),
6932  One<Expression>(map.at("expr").as_map(), ids),
6933  Any<AnnotationData>(map.at("annotations").as_map(), ids)
6934  );
6935  node->deserialize_annotations(map);
6936  return node;
6937 }
6938 
6943  : Expression(), rows(rows)
6944 {}
6945 
6949 void MatrixLiteral::find_reachable(::tree::base::PointerMap &map) const {
6950  (void)map;
6951  rows.find_reachable(map);
6952 }
6953 
6957 void MatrixLiteral::check_complete(const ::tree::base::PointerMap &map) const {
6958  (void)map;
6959  rows.check_complete(map);
6960 }
6961 
6966  return NodeType::MatrixLiteral;
6967 }
6968 
6972 void MatrixLiteral::visit_internal(VisitorBase &visitor, void *retval) {
6973  visitor.raw_visit_matrix_literal(*this, retval);
6974 }
6975 
6981  return dynamic_cast<MatrixLiteral*>(this);
6982 }
6983 
6989  return dynamic_cast<const MatrixLiteral*>(this);
6990 }
6991 
6996  return cqasm::tree::make<MatrixLiteral>(*this);
6997 }
6998 
7003  auto node = cqasm::tree::make<MatrixLiteral>(*this);
7004  node->rows = this->rows.clone();
7005  return node;
7006 }
7007 
7011 bool MatrixLiteral::equals(const Node &rhs) const {
7012  if (rhs.type() != NodeType::MatrixLiteral) return false;
7013  auto rhsc = dynamic_cast<const MatrixLiteral&>(rhs);
7014  if (!this->rows.equals(rhsc.rows)) return false;
7015  return true;
7016 }
7017 
7021 bool MatrixLiteral::operator==(const Node &rhs) const {
7022  if (rhs.type() != NodeType::MatrixLiteral) return false;
7023  auto rhsc = dynamic_cast<const MatrixLiteral&>(rhs);
7024  if (this->rows != rhsc.rows) return false;
7025  return true;
7026 }
7027 
7032  ::tree::cbor::MapWriter &map,
7033  const ::tree::base::PointerMap &ids
7034 ) const {
7035  (void)ids;
7036  map.append_string("@t", "MatrixLiteral");
7037  auto submap = map.append_map("rows");
7038  rows.serialize(submap, ids);
7039  submap.close();
7040  serialize_annotations(map);
7041 }
7042 
7046 std::shared_ptr<MatrixLiteral> MatrixLiteral::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7047  (void)ids;
7048  auto type = map.at("@t").as_string();
7049  if (type != "MatrixLiteral") {
7050  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
7051  }
7052  auto node = std::make_shared<MatrixLiteral>(
7053  Many<ExpressionList>(map.at("rows").as_map(), ids)
7054  );
7055  node->deserialize_annotations(map);
7056  return node;
7057 }
7058 
7063  : ArithOp(lhs, rhs)
7064 {}
7065 
7069 void Modulo::find_reachable(::tree::base::PointerMap &map) const {
7070  (void)map;
7071  lhs.find_reachable(map);
7072  rhs.find_reachable(map);
7073 }
7074 
7078 void Modulo::check_complete(const ::tree::base::PointerMap &map) const {
7079  (void)map;
7080  lhs.check_complete(map);
7081  rhs.check_complete(map);
7082 }
7083 
7088  return NodeType::Modulo;
7089 }
7090 
7094 void Modulo::visit_internal(VisitorBase &visitor, void *retval) {
7095  visitor.raw_visit_modulo(*this, retval);
7096 }
7097 
7103  return dynamic_cast<Modulo*>(this);
7104 }
7105 
7110 const Modulo *Modulo::as_modulo() const {
7111  return dynamic_cast<const Modulo*>(this);
7112 }
7113 
7118  return cqasm::tree::make<Modulo>(*this);
7119 }
7120 
7125  auto node = cqasm::tree::make<Modulo>(*this);
7126  node->lhs = this->lhs.clone();
7127  node->rhs = this->rhs.clone();
7128  return node;
7129 }
7130 
7134 bool Modulo::equals(const Node &rhs) const {
7135  if (rhs.type() != NodeType::Modulo) return false;
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;
7139  return true;
7140 }
7141 
7145 bool Modulo::operator==(const Node &rhs) const {
7146  if (rhs.type() != NodeType::Modulo) 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;
7150  return true;
7151 }
7152 
7157  ::tree::cbor::MapWriter &map,
7158  const ::tree::base::PointerMap &ids
7159 ) const {
7160  (void)ids;
7161  map.append_string("@t", "Modulo");
7162  auto submap = map.append_map("lhs");
7163  lhs.serialize(submap, ids);
7164  submap.close();
7165  submap = map.append_map("rhs");
7166  rhs.serialize(submap, ids);
7167  submap.close();
7168  serialize_annotations(map);
7169 }
7170 
7174 std::shared_ptr<Modulo> Modulo::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7175  (void)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);
7179  }
7180  auto node = std::make_shared<Modulo>(
7181  One<Expression>(map.at("lhs").as_map(), ids),
7182  One<Expression>(map.at("rhs").as_map(), ids)
7183  );
7184  node->deserialize_annotations(map);
7185  return node;
7186 }
7187 
7192  : ArithOp(lhs, rhs)
7193 {}
7194 
7198 void Multiply::find_reachable(::tree::base::PointerMap &map) const {
7199  (void)map;
7200  lhs.find_reachable(map);
7201  rhs.find_reachable(map);
7202 }
7203 
7207 void Multiply::check_complete(const ::tree::base::PointerMap &map) const {
7208  (void)map;
7209  lhs.check_complete(map);
7210  rhs.check_complete(map);
7211 }
7212 
7217  return NodeType::Multiply;
7218 }
7219 
7223 void Multiply::visit_internal(VisitorBase &visitor, void *retval) {
7224  visitor.raw_visit_multiply(*this, retval);
7225 }
7226 
7232  return dynamic_cast<Multiply*>(this);
7233 }
7234 
7240  return dynamic_cast<const Multiply*>(this);
7241 }
7242 
7247  return cqasm::tree::make<Multiply>(*this);
7248 }
7249 
7254  auto node = cqasm::tree::make<Multiply>(*this);
7255  node->lhs = this->lhs.clone();
7256  node->rhs = this->rhs.clone();
7257  return node;
7258 }
7259 
7263 bool Multiply::equals(const Node &rhs) const {
7264  if (rhs.type() != NodeType::Multiply) return false;
7265  auto rhsc = dynamic_cast<const Multiply&>(rhs);
7266  if (!this->lhs.equals(rhsc.lhs)) return false;
7267  if (!this->rhs.equals(rhsc.rhs)) return false;
7268  return true;
7269 }
7270 
7274 bool Multiply::operator==(const Node &rhs) const {
7275  if (rhs.type() != NodeType::Multiply) return false;
7276  auto rhsc = dynamic_cast<const Multiply&>(rhs);
7277  if (this->lhs != rhsc.lhs) return false;
7278  if (this->rhs != rhsc.rhs) return false;
7279  return true;
7280 }
7281 
7286  ::tree::cbor::MapWriter &map,
7287  const ::tree::base::PointerMap &ids
7288 ) const {
7289  (void)ids;
7290  map.append_string("@t", "Multiply");
7291  auto submap = map.append_map("lhs");
7292  lhs.serialize(submap, ids);
7293  submap.close();
7294  submap = map.append_map("rhs");
7295  rhs.serialize(submap, ids);
7296  submap.close();
7297  serialize_annotations(map);
7298 }
7299 
7303 std::shared_ptr<Multiply> Multiply::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7304  (void)ids;
7305  auto type = map.at("@t").as_string();
7306  if (type != "Multiply") {
7307  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
7308  }
7309  auto node = std::make_shared<Multiply>(
7310  One<Expression>(map.at("lhs").as_map(), ids),
7311  One<Expression>(map.at("rhs").as_map(), ids)
7312  );
7313  node->deserialize_annotations(map);
7314  return node;
7315 }
7316 
7321  : UnaryOp(expr)
7322 {}
7323 
7327 void Negate::find_reachable(::tree::base::PointerMap &map) const {
7328  (void)map;
7329  expr.find_reachable(map);
7330 }
7331 
7335 void Negate::check_complete(const ::tree::base::PointerMap &map) const {
7336  (void)map;
7337  expr.check_complete(map);
7338 }
7339 
7344  return NodeType::Negate;
7345 }
7346 
7350 void Negate::visit_internal(VisitorBase &visitor, void *retval) {
7351  visitor.raw_visit_negate(*this, retval);
7352 }
7353 
7359  return dynamic_cast<Negate*>(this);
7360 }
7361 
7366 const Negate *Negate::as_negate() const {
7367  return dynamic_cast<const Negate*>(this);
7368 }
7369 
7374  return cqasm::tree::make<Negate>(*this);
7375 }
7376 
7381  auto node = cqasm::tree::make<Negate>(*this);
7382  node->expr = this->expr.clone();
7383  return node;
7384 }
7385 
7389 bool Negate::equals(const Node &rhs) const {
7390  if (rhs.type() != NodeType::Negate) return false;
7391  auto rhsc = dynamic_cast<const Negate&>(rhs);
7392  if (!this->expr.equals(rhsc.expr)) return false;
7393  return true;
7394 }
7395 
7399 bool Negate::operator==(const Node &rhs) const {
7400  if (rhs.type() != NodeType::Negate) return false;
7401  auto rhsc = dynamic_cast<const Negate&>(rhs);
7402  if (this->expr != rhsc.expr) return false;
7403  return true;
7404 }
7405 
7410  ::tree::cbor::MapWriter &map,
7411  const ::tree::base::PointerMap &ids
7412 ) const {
7413  (void)ids;
7414  map.append_string("@t", "Negate");
7415  auto submap = map.append_map("expr");
7416  expr.serialize(submap, ids);
7417  submap.close();
7418  serialize_annotations(map);
7419 }
7420 
7424 std::shared_ptr<Negate> Negate::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7425  (void)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);
7429  }
7430  auto node = std::make_shared<Negate>(
7431  One<Expression>(map.at("expr").as_map(), ids)
7432  );
7433  node->deserialize_annotations(map);
7434  return node;
7435 }
7436 
7441  : ArithOp(lhs, rhs)
7442 {}
7443 
7447 void Power::find_reachable(::tree::base::PointerMap &map) const {
7448  (void)map;
7449  lhs.find_reachable(map);
7450  rhs.find_reachable(map);
7451 }
7452 
7456 void Power::check_complete(const ::tree::base::PointerMap &map) const {
7457  (void)map;
7458  lhs.check_complete(map);
7459  rhs.check_complete(map);
7460 }
7461 
7466  return NodeType::Power;
7467 }
7468 
7472 void Power::visit_internal(VisitorBase &visitor, void *retval) {
7473  visitor.raw_visit_power(*this, retval);
7474 }
7475 
7481  return dynamic_cast<Power*>(this);
7482 }
7483 
7488 const Power *Power::as_power() const {
7489  return dynamic_cast<const Power*>(this);
7490 }
7491 
7496  return cqasm::tree::make<Power>(*this);
7497 }
7498 
7503  auto node = cqasm::tree::make<Power>(*this);
7504  node->lhs = this->lhs.clone();
7505  node->rhs = this->rhs.clone();
7506  return node;
7507 }
7508 
7512 bool Power::equals(const Node &rhs) const {
7513  if (rhs.type() != NodeType::Power) return false;
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;
7517  return true;
7518 }
7519 
7523 bool Power::operator==(const Node &rhs) const {
7524  if (rhs.type() != NodeType::Power) 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;
7528  return true;
7529 }
7530 
7535  ::tree::cbor::MapWriter &map,
7536  const ::tree::base::PointerMap &ids
7537 ) const {
7538  (void)ids;
7539  map.append_string("@t", "Power");
7540  auto submap = map.append_map("lhs");
7541  lhs.serialize(submap, ids);
7542  submap.close();
7543  submap = map.append_map("rhs");
7544  rhs.serialize(submap, ids);
7545  submap.close();
7546  serialize_annotations(map);
7547 }
7548 
7552 std::shared_ptr<Power> Power::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7553  (void)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);
7557  }
7558  auto node = std::make_shared<Power>(
7559  One<Expression>(map.at("lhs").as_map(), ids),
7560  One<Expression>(map.at("rhs").as_map(), ids)
7561  );
7562  node->deserialize_annotations(map);
7563  return node;
7564 }
7565 
7569 Program::Program(const One<Version> &version, const Maybe<Expression> &num_qubits, const One<StatementList> &statements)
7570  : Root(), version(version), num_qubits(num_qubits), statements(statements)
7571 {}
7572 
7576 void Program::find_reachable(::tree::base::PointerMap &map) const {
7577  (void)map;
7578  version.find_reachable(map);
7579  num_qubits.find_reachable(map);
7580  statements.find_reachable(map);
7581 }
7582 
7586 void Program::check_complete(const ::tree::base::PointerMap &map) const {
7587  (void)map;
7588  version.check_complete(map);
7589  num_qubits.check_complete(map);
7590  statements.check_complete(map);
7591 }
7592 
7597  return NodeType::Program;
7598 }
7599 
7603 void Program::visit_internal(VisitorBase &visitor, void *retval) {
7604  visitor.raw_visit_program(*this, retval);
7605 }
7606 
7612  return dynamic_cast<Program*>(this);
7613 }
7614 
7620  return dynamic_cast<const Program*>(this);
7621 }
7622 
7627  return cqasm::tree::make<Program>(*this);
7628 }
7629 
7634  auto node = cqasm::tree::make<Program>(*this);
7635  node->version = this->version.clone();
7636  node->num_qubits = this->num_qubits.clone();
7637  node->statements = this->statements.clone();
7638  return node;
7639 }
7640 
7644 bool Program::equals(const Node &rhs) const {
7645  if (rhs.type() != NodeType::Program) return false;
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;
7650  return true;
7651 }
7652 
7656 bool Program::operator==(const Node &rhs) const {
7657  if (rhs.type() != NodeType::Program) 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;
7662  return true;
7663 }
7664 
7669  ::tree::cbor::MapWriter &map,
7670  const ::tree::base::PointerMap &ids
7671 ) const {
7672  (void)ids;
7673  map.append_string("@t", "Program");
7674  auto submap = map.append_map("version");
7675  version.serialize(submap, ids);
7676  submap.close();
7677  submap = map.append_map("num_qubits");
7678  num_qubits.serialize(submap, ids);
7679  submap.close();
7680  submap = map.append_map("statements");
7681  statements.serialize(submap, ids);
7682  submap.close();
7683  serialize_annotations(map);
7684 }
7685 
7689 std::shared_ptr<Program> Program::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7690  (void)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);
7694  }
7695  auto node = std::make_shared<Program>(
7696  One<Version>(map.at("version").as_map(), ids),
7697  Maybe<Expression>(map.at("num_qubits").as_map(), ids),
7698  One<StatementList>(map.at("statements").as_map(), ids)
7699  );
7700  node->deserialize_annotations(map);
7701  return node;
7702 }
7703 
7708  : Structured(annotations), body(body), condition(condition)
7709 {}
7710 
7714 void RepeatUntilLoop::find_reachable(::tree::base::PointerMap &map) const {
7715  (void)map;
7716  body.find_reachable(map);
7717  condition.find_reachable(map);
7718  annotations.find_reachable(map);
7719 }
7720 
7724 void RepeatUntilLoop::check_complete(const ::tree::base::PointerMap &map) const {
7725  (void)map;
7726  body.check_complete(map);
7727  condition.check_complete(map);
7728  annotations.check_complete(map);
7729 }
7730 
7736 }
7737 
7741 void RepeatUntilLoop::visit_internal(VisitorBase &visitor, void *retval) {
7742  visitor.raw_visit_repeat_until_loop(*this, retval);
7743 }
7744 
7750  return dynamic_cast<RepeatUntilLoop*>(this);
7751 }
7752 
7758  return dynamic_cast<const RepeatUntilLoop*>(this);
7759 }
7760 
7765  return cqasm::tree::make<RepeatUntilLoop>(*this);
7766 }
7767 
7772  auto node = cqasm::tree::make<RepeatUntilLoop>(*this);
7773  node->body = this->body.clone();
7774  node->condition = this->condition.clone();
7775  node->annotations = this->annotations.clone();
7776  return node;
7777 }
7778 
7782 bool RepeatUntilLoop::equals(const Node &rhs) const {
7783  if (rhs.type() != NodeType::RepeatUntilLoop) return false;
7784  auto rhsc = dynamic_cast<const RepeatUntilLoop&>(rhs);
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;
7788  return true;
7789 }
7790 
7794 bool RepeatUntilLoop::operator==(const Node &rhs) const {
7795  if (rhs.type() != NodeType::RepeatUntilLoop) return false;
7796  auto rhsc = dynamic_cast<const RepeatUntilLoop&>(rhs);
7797  if (this->body != rhsc.body) return false;
7798  if (this->condition != rhsc.condition) return false;
7799  if (this->annotations != rhsc.annotations) return false;
7800  return true;
7801 }
7802 
7807  ::tree::cbor::MapWriter &map,
7808  const ::tree::base::PointerMap &ids
7809 ) const {
7810  (void)ids;
7811  map.append_string("@t", "RepeatUntilLoop");
7812  auto submap = map.append_map("body");
7813  body.serialize(submap, ids);
7814  submap.close();
7815  submap = map.append_map("condition");
7816  condition.serialize(submap, ids);
7817  submap.close();
7818  submap = map.append_map("annotations");
7819  annotations.serialize(submap, ids);
7820  submap.close();
7821  serialize_annotations(map);
7822 }
7823 
7827 std::shared_ptr<RepeatUntilLoop> RepeatUntilLoop::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7828  (void)ids;
7829  auto type = map.at("@t").as_string();
7830  if (type != "RepeatUntilLoop") {
7831  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
7832  }
7833  auto node = std::make_shared<RepeatUntilLoop>(
7834  One<StatementList>(map.at("body").as_map(), ids),
7835  One<Expression>(map.at("condition").as_map(), ids),
7836  Any<AnnotationData>(map.at("annotations").as_map(), ids)
7837  );
7838  node->deserialize_annotations(map);
7839  return node;
7840 }
7841 
7846  : BinaryOp(lhs, rhs)
7847 {}
7848 
7854  return dynamic_cast<ShiftOp*>(this);
7855 }
7856 
7862  return dynamic_cast<const ShiftOp*>(this);
7863 }
7864 
7868 std::shared_ptr<ShiftOp> ShiftOp::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7869  auto type = map.at("@t").as_string();
7870  if (type == "ShiftLeft") return ShiftLeft::deserialize(map, ids);
7871  if (type == "ShiftRightArith") return ShiftRightArith::deserialize(map, ids);
7872  if (type == "ShiftRightLogic") return ShiftRightLogic::deserialize(map, ids);
7873  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
7874 }
7875 
7880  : ShiftOp(lhs, rhs)
7881 {}
7882 
7886 void ShiftLeft::find_reachable(::tree::base::PointerMap &map) const {
7887  (void)map;
7888  lhs.find_reachable(map);
7889  rhs.find_reachable(map);
7890 }
7891 
7895 void ShiftLeft::check_complete(const ::tree::base::PointerMap &map) const {
7896  (void)map;
7897  lhs.check_complete(map);
7898  rhs.check_complete(map);
7899 }
7900 
7905  return NodeType::ShiftLeft;
7906 }
7907 
7911 void ShiftLeft::visit_internal(VisitorBase &visitor, void *retval) {
7912  visitor.raw_visit_shift_left(*this, retval);
7913 }
7914 
7920  return dynamic_cast<ShiftLeft*>(this);
7921 }
7922 
7928  return dynamic_cast<const ShiftLeft*>(this);
7929 }
7930 
7935  return cqasm::tree::make<ShiftLeft>(*this);
7936 }
7937 
7942  auto node = cqasm::tree::make<ShiftLeft>(*this);
7943  node->lhs = this->lhs.clone();
7944  node->rhs = this->rhs.clone();
7945  return node;
7946 }
7947 
7951 bool ShiftLeft::equals(const Node &rhs) const {
7952  if (rhs.type() != NodeType::ShiftLeft) return false;
7953  auto rhsc = dynamic_cast<const ShiftLeft&>(rhs);
7954  if (!this->lhs.equals(rhsc.lhs)) return false;
7955  if (!this->rhs.equals(rhsc.rhs)) return false;
7956  return true;
7957 }
7958 
7962 bool ShiftLeft::operator==(const Node &rhs) const {
7963  if (rhs.type() != NodeType::ShiftLeft) return false;
7964  auto rhsc = dynamic_cast<const ShiftLeft&>(rhs);
7965  if (this->lhs != rhsc.lhs) return false;
7966  if (this->rhs != rhsc.rhs) return false;
7967  return true;
7968 }
7969 
7974  ::tree::cbor::MapWriter &map,
7975  const ::tree::base::PointerMap &ids
7976 ) const {
7977  (void)ids;
7978  map.append_string("@t", "ShiftLeft");
7979  auto submap = map.append_map("lhs");
7980  lhs.serialize(submap, ids);
7981  submap.close();
7982  submap = map.append_map("rhs");
7983  rhs.serialize(submap, ids);
7984  submap.close();
7985  serialize_annotations(map);
7986 }
7987 
7991 std::shared_ptr<ShiftLeft> ShiftLeft::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
7992  (void)ids;
7993  auto type = map.at("@t").as_string();
7994  if (type != "ShiftLeft") {
7995  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
7996  }
7997  auto node = std::make_shared<ShiftLeft>(
7998  One<Expression>(map.at("lhs").as_map(), ids),
7999  One<Expression>(map.at("rhs").as_map(), ids)
8000  );
8001  node->deserialize_annotations(map);
8002  return node;
8003 }
8004 
8009  : ShiftOp(lhs, rhs)
8010 {}
8011 
8015 void ShiftRightArith::find_reachable(::tree::base::PointerMap &map) const {
8016  (void)map;
8017  lhs.find_reachable(map);
8018  rhs.find_reachable(map);
8019 }
8020 
8024 void ShiftRightArith::check_complete(const ::tree::base::PointerMap &map) const {
8025  (void)map;
8026  lhs.check_complete(map);
8027  rhs.check_complete(map);
8028 }
8029 
8035 }
8036 
8040 void ShiftRightArith::visit_internal(VisitorBase &visitor, void *retval) {
8041  visitor.raw_visit_shift_right_arith(*this, retval);
8042 }
8043 
8049  return dynamic_cast<ShiftRightArith*>(this);
8050 }
8051 
8057  return dynamic_cast<const ShiftRightArith*>(this);
8058 }
8059 
8064  return cqasm::tree::make<ShiftRightArith>(*this);
8065 }
8066 
8071  auto node = cqasm::tree::make<ShiftRightArith>(*this);
8072  node->lhs = this->lhs.clone();
8073  node->rhs = this->rhs.clone();
8074  return node;
8075 }
8076 
8080 bool ShiftRightArith::equals(const Node &rhs) const {
8081  if (rhs.type() != NodeType::ShiftRightArith) return false;
8082  auto rhsc = dynamic_cast<const ShiftRightArith&>(rhs);
8083  if (!this->lhs.equals(rhsc.lhs)) return false;
8084  if (!this->rhs.equals(rhsc.rhs)) return false;
8085  return true;
8086 }
8087 
8092  if (rhs.type() != NodeType::ShiftRightArith) return false;
8093  auto rhsc = dynamic_cast<const ShiftRightArith&>(rhs);
8094  if (this->lhs != rhsc.lhs) return false;
8095  if (this->rhs != rhsc.rhs) return false;
8096  return true;
8097 }
8098 
8103  ::tree::cbor::MapWriter &map,
8104  const ::tree::base::PointerMap &ids
8105 ) const {
8106  (void)ids;
8107  map.append_string("@t", "ShiftRightArith");
8108  auto submap = map.append_map("lhs");
8109  lhs.serialize(submap, ids);
8110  submap.close();
8111  submap = map.append_map("rhs");
8112  rhs.serialize(submap, ids);
8113  submap.close();
8114  serialize_annotations(map);
8115 }
8116 
8120 std::shared_ptr<ShiftRightArith> ShiftRightArith::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
8121  (void)ids;
8122  auto type = map.at("@t").as_string();
8123  if (type != "ShiftRightArith") {
8124  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
8125  }
8126  auto node = std::make_shared<ShiftRightArith>(
8127  One<Expression>(map.at("lhs").as_map(), ids),
8128  One<Expression>(map.at("rhs").as_map(), ids)
8129  );
8130  node->deserialize_annotations(map);
8131  return node;
8132 }
8133 
8138  : ShiftOp(lhs, rhs)
8139 {}
8140 
8144 void ShiftRightLogic::find_reachable(::tree::base::PointerMap &map) const {
8145  (void)map;
8146  lhs.find_reachable(map);
8147  rhs.find_reachable(map);
8148 }
8149 
8153 void ShiftRightLogic::check_complete(const ::tree::base::PointerMap &map) const {
8154  (void)map;
8155  lhs.check_complete(map);
8156  rhs.check_complete(map);
8157 }
8158 
8164 }
8165 
8169 void ShiftRightLogic::visit_internal(VisitorBase &visitor, void *retval) {
8170  visitor.raw_visit_shift_right_logic(*this, retval);
8171 }
8172 
8178  return dynamic_cast<ShiftRightLogic*>(this);
8179 }
8180 
8186  return dynamic_cast<const ShiftRightLogic*>(this);
8187 }
8188 
8193  return cqasm::tree::make<ShiftRightLogic>(*this);
8194 }
8195 
8200  auto node = cqasm::tree::make<ShiftRightLogic>(*this);
8201  node->lhs = this->lhs.clone();
8202  node->rhs = this->rhs.clone();
8203  return node;
8204 }
8205 
8209 bool ShiftRightLogic::equals(const Node &rhs) const {
8210  if (rhs.type() != NodeType::ShiftRightLogic) return false;
8211  auto rhsc = dynamic_cast<const ShiftRightLogic&>(rhs);
8212  if (!this->lhs.equals(rhsc.lhs)) return false;
8213  if (!this->rhs.equals(rhsc.rhs)) return false;
8214  return true;
8215 }
8216 
8221  if (rhs.type() != NodeType::ShiftRightLogic) return false;
8222  auto rhsc = dynamic_cast<const ShiftRightLogic&>(rhs);
8223  if (this->lhs != rhsc.lhs) return false;
8224  if (this->rhs != rhsc.rhs) return false;
8225  return true;
8226 }
8227 
8232  ::tree::cbor::MapWriter &map,
8233  const ::tree::base::PointerMap &ids
8234 ) const {
8235  (void)ids;
8236  map.append_string("@t", "ShiftRightLogic");
8237  auto submap = map.append_map("lhs");
8238  lhs.serialize(submap, ids);
8239  submap.close();
8240  submap = map.append_map("rhs");
8241  rhs.serialize(submap, ids);
8242  submap.close();
8243  serialize_annotations(map);
8244 }
8245 
8249 std::shared_ptr<ShiftRightLogic> ShiftRightLogic::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
8250  (void)ids;
8251  auto type = map.at("@t").as_string();
8252  if (type != "ShiftRightLogic") {
8253  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
8254  }
8255  auto node = std::make_shared<ShiftRightLogic>(
8256  One<Expression>(map.at("lhs").as_map(), ids),
8257  One<Expression>(map.at("rhs").as_map(), ids)
8258  );
8259  node->deserialize_annotations(map);
8260  return node;
8261 }
8262 
8267  : items(items)
8268 {}
8269 
8273 void StatementList::find_reachable(::tree::base::PointerMap &map) const {
8274  (void)map;
8275  items.find_reachable(map);
8276 }
8277 
8281 void StatementList::check_complete(const ::tree::base::PointerMap &map) const {
8282  (void)map;
8283  items.check_complete(map);
8284 }
8285 
8290  return NodeType::StatementList;
8291 }
8292 
8296 void StatementList::visit_internal(VisitorBase &visitor, void *retval) {
8297  visitor.raw_visit_statement_list(*this, retval);
8298 }
8299 
8305  return dynamic_cast<StatementList*>(this);
8306 }
8307 
8313  return dynamic_cast<const StatementList*>(this);
8314 }
8315 
8320  return cqasm::tree::make<StatementList>(*this);
8321 }
8322 
8327  auto node = cqasm::tree::make<StatementList>(*this);
8328  node->items = this->items.clone();
8329  return node;
8330 }
8331 
8335 bool StatementList::equals(const Node &rhs) const {
8336  if (rhs.type() != NodeType::StatementList) return false;
8337  auto rhsc = dynamic_cast<const StatementList&>(rhs);
8338  if (!this->items.equals(rhsc.items)) return false;
8339  return true;
8340 }
8341 
8345 bool StatementList::operator==(const Node &rhs) const {
8346  if (rhs.type() != NodeType::StatementList) return false;
8347  auto rhsc = dynamic_cast<const StatementList&>(rhs);
8348  if (this->items != rhsc.items) return false;
8349  return true;
8350 }
8351 
8356  ::tree::cbor::MapWriter &map,
8357  const ::tree::base::PointerMap &ids
8358 ) const {
8359  (void)ids;
8360  map.append_string("@t", "StatementList");
8361  auto submap = map.append_map("items");
8362  items.serialize(submap, ids);
8363  submap.close();
8364  serialize_annotations(map);
8365 }
8366 
8370 std::shared_ptr<StatementList> StatementList::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
8371  (void)ids;
8372  auto type = map.at("@t").as_string();
8373  if (type != "StatementList") {
8374  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
8375  }
8376  auto node = std::make_shared<StatementList>(
8377  Any<Statement>(map.at("items").as_map(), ids)
8378  );
8379  node->deserialize_annotations(map);
8380  return node;
8381 }
8382 
8387  : Expression(), value(value)
8388 {}
8389 
8393 void StringLiteral::find_reachable(::tree::base::PointerMap &map) const {
8394  (void)map;
8395 }
8396 
8400 void StringLiteral::check_complete(const ::tree::base::PointerMap &map) const {
8401  (void)map;
8402 }
8403 
8408  return NodeType::StringLiteral;
8409 }
8410 
8414 void StringLiteral::visit_internal(VisitorBase &visitor, void *retval) {
8415  visitor.raw_visit_string_literal(*this, retval);
8416 }
8417 
8423  return dynamic_cast<StringLiteral*>(this);
8424 }
8425 
8431  return dynamic_cast<const StringLiteral*>(this);
8432 }
8433 
8438  return cqasm::tree::make<StringLiteral>(*this);
8439 }
8440 
8445  auto node = cqasm::tree::make<StringLiteral>(*this);
8446  return node;
8447 }
8448 
8452 bool StringLiteral::equals(const Node &rhs) const {
8453  if (rhs.type() != NodeType::StringLiteral) return false;
8454  auto rhsc = dynamic_cast<const StringLiteral&>(rhs);
8455  if (this->value != rhsc.value) return false;
8456  return true;
8457 }
8458 
8462 bool StringLiteral::operator==(const Node &rhs) const {
8463  if (rhs.type() != NodeType::StringLiteral) return false;
8464  auto rhsc = dynamic_cast<const StringLiteral&>(rhs);
8465  if (this->value != rhsc.value) return false;
8466  return true;
8467 }
8468 
8473  ::tree::cbor::MapWriter &map,
8474  const ::tree::base::PointerMap &ids
8475 ) const {
8476  (void)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);
8480  submap.close();
8481  serialize_annotations(map);
8482 }
8483 
8487 std::shared_ptr<StringLiteral> StringLiteral::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
8488  (void)ids;
8489  auto type = map.at("@t").as_string();
8490  if (type != "StringLiteral") {
8491  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
8492  }
8493  auto node = std::make_shared<StringLiteral>(
8494  cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Str>(map.at("value").as_map())
8495  );
8496  node->deserialize_annotations(map);
8497  return node;
8498 }
8499 
8503 Subcircuit::Subcircuit(const One<Identifier> &name, const Maybe<Expression> &iterations, const Any<AnnotationData> &annotations)
8504  : Statement(annotations), name(name), iterations(iterations)
8505 {}
8506 
8510 void Subcircuit::find_reachable(::tree::base::PointerMap &map) const {
8511  (void)map;
8512  name.find_reachable(map);
8513  iterations.find_reachable(map);
8514  annotations.find_reachable(map);
8515 }
8516 
8520 void Subcircuit::check_complete(const ::tree::base::PointerMap &map) const {
8521  (void)map;
8522  name.check_complete(map);
8523  iterations.check_complete(map);
8524  annotations.check_complete(map);
8525 }
8526 
8531  return NodeType::Subcircuit;
8532 }
8533 
8537 void Subcircuit::visit_internal(VisitorBase &visitor, void *retval) {
8538  visitor.raw_visit_subcircuit(*this, retval);
8539 }
8540 
8546  return dynamic_cast<Subcircuit*>(this);
8547 }
8548 
8554  return dynamic_cast<const Subcircuit*>(this);
8555 }
8556 
8561  return cqasm::tree::make<Subcircuit>(*this);
8562 }
8563 
8568  auto node = cqasm::tree::make<Subcircuit>(*this);
8569  node->name = this->name.clone();
8570  node->iterations = this->iterations.clone();
8571  node->annotations = this->annotations.clone();
8572  return node;
8573 }
8574 
8578 bool Subcircuit::equals(const Node &rhs) const {
8579  if (rhs.type() != NodeType::Subcircuit) return false;
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;
8584  return true;
8585 }
8586 
8590 bool Subcircuit::operator==(const Node &rhs) const {
8591  if (rhs.type() != NodeType::Subcircuit) 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;
8596  return true;
8597 }
8598 
8603  ::tree::cbor::MapWriter &map,
8604  const ::tree::base::PointerMap &ids
8605 ) const {
8606  (void)ids;
8607  map.append_string("@t", "Subcircuit");
8608  auto submap = map.append_map("name");
8609  name.serialize(submap, ids);
8610  submap.close();
8611  submap = map.append_map("iterations");
8612  iterations.serialize(submap, ids);
8613  submap.close();
8614  submap = map.append_map("annotations");
8615  annotations.serialize(submap, ids);
8616  submap.close();
8617  serialize_annotations(map);
8618 }
8619 
8623 std::shared_ptr<Subcircuit> Subcircuit::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
8624  (void)ids;
8625  auto type = map.at("@t").as_string();
8626  if (type != "Subcircuit") {
8627  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
8628  }
8629  auto node = std::make_shared<Subcircuit>(
8630  One<Identifier>(map.at("name").as_map(), ids),
8631  Maybe<Expression>(map.at("iterations").as_map(), ids),
8632  Any<AnnotationData>(map.at("annotations").as_map(), ids)
8633  );
8634  node->deserialize_annotations(map);
8635  return node;
8636 }
8637 
8642  : ArithOp(lhs, rhs)
8643 {}
8644 
8648 void Subtract::find_reachable(::tree::base::PointerMap &map) const {
8649  (void)map;
8650  lhs.find_reachable(map);
8651  rhs.find_reachable(map);
8652 }
8653 
8657 void Subtract::check_complete(const ::tree::base::PointerMap &map) const {
8658  (void)map;
8659  lhs.check_complete(map);
8660  rhs.check_complete(map);
8661 }
8662 
8667  return NodeType::Subtract;
8668 }
8669 
8673 void Subtract::visit_internal(VisitorBase &visitor, void *retval) {
8674  visitor.raw_visit_subtract(*this, retval);
8675 }
8676 
8682  return dynamic_cast<Subtract*>(this);
8683 }
8684 
8690  return dynamic_cast<const Subtract*>(this);
8691 }
8692 
8697  return cqasm::tree::make<Subtract>(*this);
8698 }
8699 
8704  auto node = cqasm::tree::make<Subtract>(*this);
8705  node->lhs = this->lhs.clone();
8706  node->rhs = this->rhs.clone();
8707  return node;
8708 }
8709 
8713 bool Subtract::equals(const Node &rhs) const {
8714  if (rhs.type() != NodeType::Subtract) return false;
8715  auto rhsc = dynamic_cast<const Subtract&>(rhs);
8716  if (!this->lhs.equals(rhsc.lhs)) return false;
8717  if (!this->rhs.equals(rhsc.rhs)) return false;
8718  return true;
8719 }
8720 
8724 bool Subtract::operator==(const Node &rhs) const {
8725  if (rhs.type() != NodeType::Subtract) return false;
8726  auto rhsc = dynamic_cast<const Subtract&>(rhs);
8727  if (this->lhs != rhsc.lhs) return false;
8728  if (this->rhs != rhsc.rhs) return false;
8729  return true;
8730 }
8731 
8736  ::tree::cbor::MapWriter &map,
8737  const ::tree::base::PointerMap &ids
8738 ) const {
8739  (void)ids;
8740  map.append_string("@t", "Subtract");
8741  auto submap = map.append_map("lhs");
8742  lhs.serialize(submap, ids);
8743  submap.close();
8744  submap = map.append_map("rhs");
8745  rhs.serialize(submap, ids);
8746  submap.close();
8747  serialize_annotations(map);
8748 }
8749 
8753 std::shared_ptr<Subtract> Subtract::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
8754  (void)ids;
8755  auto type = map.at("@t").as_string();
8756  if (type != "Subtract") {
8757  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
8758  }
8759  auto node = std::make_shared<Subtract>(
8760  One<Expression>(map.at("lhs").as_map(), ids),
8761  One<Expression>(map.at("rhs").as_map(), ids)
8762  );
8763  node->deserialize_annotations(map);
8764  return node;
8765 }
8766 
8770 TernaryCond::TernaryCond(const One<Expression> &cond, const One<Expression> &if_true, const One<Expression> &if_false)
8771  : Expression(), cond(cond), if_true(if_true), if_false(if_false)
8772 {}
8773 
8777 void TernaryCond::find_reachable(::tree::base::PointerMap &map) const {
8778  (void)map;
8779  cond.find_reachable(map);
8780  if_true.find_reachable(map);
8781  if_false.find_reachable(map);
8782 }
8783 
8787 void TernaryCond::check_complete(const ::tree::base::PointerMap &map) const {
8788  (void)map;
8789  cond.check_complete(map);
8790  if_true.check_complete(map);
8791  if_false.check_complete(map);
8792 }
8793 
8798  return NodeType::TernaryCond;
8799 }
8800 
8804 void TernaryCond::visit_internal(VisitorBase &visitor, void *retval) {
8805  visitor.raw_visit_ternary_cond(*this, retval);
8806 }
8807 
8813  return dynamic_cast<TernaryCond*>(this);
8814 }
8815 
8821  return dynamic_cast<const TernaryCond*>(this);
8822 }
8823 
8828  return cqasm::tree::make<TernaryCond>(*this);
8829 }
8830 
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();
8839  return node;
8840 }
8841 
8845 bool TernaryCond::equals(const Node &rhs) const {
8846  if (rhs.type() != NodeType::TernaryCond) return false;
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;
8851  return true;
8852 }
8853 
8857 bool TernaryCond::operator==(const Node &rhs) const {
8858  if (rhs.type() != NodeType::TernaryCond) 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;
8863  return true;
8864 }
8865 
8870  ::tree::cbor::MapWriter &map,
8871  const ::tree::base::PointerMap &ids
8872 ) const {
8873  (void)ids;
8874  map.append_string("@t", "TernaryCond");
8875  auto submap = map.append_map("cond");
8876  cond.serialize(submap, ids);
8877  submap.close();
8878  submap = map.append_map("if_true");
8879  if_true.serialize(submap, ids);
8880  submap.close();
8881  submap = map.append_map("if_false");
8882  if_false.serialize(submap, ids);
8883  submap.close();
8884  serialize_annotations(map);
8885 }
8886 
8890 std::shared_ptr<TernaryCond> TernaryCond::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
8891  (void)ids;
8892  auto type = map.at("@t").as_string();
8893  if (type != "TernaryCond") {
8894  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
8895  }
8896  auto node = std::make_shared<TernaryCond>(
8897  One<Expression>(map.at("cond").as_map(), ids),
8898  One<Expression>(map.at("if_true").as_map(), ids),
8899  One<Expression>(map.at("if_false").as_map(), ids)
8900  );
8901  node->deserialize_annotations(map);
8902  return node;
8903 }
8904 
8908 Variables::Variables(const Many<Identifier> &names, const One<Identifier> &typ, const Any<AnnotationData> &annotations)
8909  : Statement(annotations), names(names), typ(typ)
8910 {}
8911 
8915 void Variables::find_reachable(::tree::base::PointerMap &map) const {
8916  (void)map;
8917  names.find_reachable(map);
8918  typ.find_reachable(map);
8919  annotations.find_reachable(map);
8920 }
8921 
8925 void Variables::check_complete(const ::tree::base::PointerMap &map) const {
8926  (void)map;
8927  names.check_complete(map);
8928  typ.check_complete(map);
8929  annotations.check_complete(map);
8930 }
8931 
8936  return NodeType::Variables;
8937 }
8938 
8942 void Variables::visit_internal(VisitorBase &visitor, void *retval) {
8943  visitor.raw_visit_variables(*this, retval);
8944 }
8945 
8951  return dynamic_cast<Variables*>(this);
8952 }
8953 
8959  return dynamic_cast<const Variables*>(this);
8960 }
8961 
8966  return cqasm::tree::make<Variables>(*this);
8967 }
8968 
8973  auto node = cqasm::tree::make<Variables>(*this);
8974  node->names = this->names.clone();
8975  node->typ = this->typ.clone();
8976  node->annotations = this->annotations.clone();
8977  return node;
8978 }
8979 
8983 bool Variables::equals(const Node &rhs) const {
8984  if (rhs.type() != NodeType::Variables) return false;
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;
8989  return true;
8990 }
8991 
8995 bool Variables::operator==(const Node &rhs) const {
8996  if (rhs.type() != NodeType::Variables) 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;
9001  return true;
9002 }
9003 
9008  ::tree::cbor::MapWriter &map,
9009  const ::tree::base::PointerMap &ids
9010 ) const {
9011  (void)ids;
9012  map.append_string("@t", "Variables");
9013  auto submap = map.append_map("names");
9014  names.serialize(submap, ids);
9015  submap.close();
9016  submap = map.append_map("typ");
9017  typ.serialize(submap, ids);
9018  submap.close();
9019  submap = map.append_map("annotations");
9020  annotations.serialize(submap, ids);
9021  submap.close();
9022  serialize_annotations(map);
9023 }
9024 
9028 std::shared_ptr<Variables> Variables::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
9029  (void)ids;
9030  auto type = map.at("@t").as_string();
9031  if (type != "Variables") {
9032  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
9033  }
9034  auto node = std::make_shared<Variables>(
9035  Many<Identifier>(map.at("names").as_map(), ids),
9036  One<Identifier>(map.at("typ").as_map(), ids),
9037  Any<AnnotationData>(map.at("annotations").as_map(), ids)
9038  );
9039  node->deserialize_annotations(map);
9040  return node;
9041 }
9042 
9047  : items(items)
9048 {}
9049 
9053 void Version::find_reachable(::tree::base::PointerMap &map) const {
9054  (void)map;
9055 }
9056 
9060 void Version::check_complete(const ::tree::base::PointerMap &map) const {
9061  (void)map;
9062 }
9063 
9068  return NodeType::Version;
9069 }
9070 
9074 void Version::visit_internal(VisitorBase &visitor, void *retval) {
9075  visitor.raw_visit_version(*this, retval);
9076 }
9077 
9083  return dynamic_cast<Version*>(this);
9084 }
9085 
9091  return dynamic_cast<const Version*>(this);
9092 }
9093 
9098  return cqasm::tree::make<Version>(*this);
9099 }
9100 
9105  auto node = cqasm::tree::make<Version>(*this);
9106  return node;
9107 }
9108 
9112 bool Version::equals(const Node &rhs) const {
9113  if (rhs.type() != NodeType::Version) return false;
9114  auto rhsc = dynamic_cast<const Version&>(rhs);
9115  if (this->items != rhsc.items) return false;
9116  return true;
9117 }
9118 
9122 bool Version::operator==(const Node &rhs) const {
9123  if (rhs.type() != NodeType::Version) return false;
9124  auto rhsc = dynamic_cast<const Version&>(rhs);
9125  if (this->items != rhsc.items) return false;
9126  return true;
9127 }
9128 
9133  ::tree::cbor::MapWriter &map,
9134  const ::tree::base::PointerMap &ids
9135 ) const {
9136  (void)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);
9140  submap.close();
9141  serialize_annotations(map);
9142 }
9143 
9147 std::shared_ptr<Version> Version::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
9148  (void)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);
9152  }
9153  auto node = std::make_shared<Version>(
9154  cqasm::v1::primitives::deserialize<cqasm::v1::primitives::Version>(map.at("items").as_map())
9155  );
9156  node->deserialize_annotations(map);
9157  return node;
9158 }
9159 
9163 WhileLoop::WhileLoop(const One<Expression> &condition, const One<StatementList> &body, const Any<AnnotationData> &annotations)
9164  : Structured(annotations), condition(condition), body(body)
9165 {}
9166 
9170 void WhileLoop::find_reachable(::tree::base::PointerMap &map) const {
9171  (void)map;
9172  condition.find_reachable(map);
9173  body.find_reachable(map);
9174  annotations.find_reachable(map);
9175 }
9176 
9180 void WhileLoop::check_complete(const ::tree::base::PointerMap &map) const {
9181  (void)map;
9182  condition.check_complete(map);
9183  body.check_complete(map);
9184  annotations.check_complete(map);
9185 }
9186 
9191  return NodeType::WhileLoop;
9192 }
9193 
9197 void WhileLoop::visit_internal(VisitorBase &visitor, void *retval) {
9198  visitor.raw_visit_while_loop(*this, retval);
9199 }
9200 
9206  return dynamic_cast<WhileLoop*>(this);
9207 }
9208 
9214  return dynamic_cast<const WhileLoop*>(this);
9215 }
9216 
9221  return cqasm::tree::make<WhileLoop>(*this);
9222 }
9223 
9228  auto node = cqasm::tree::make<WhileLoop>(*this);
9229  node->condition = this->condition.clone();
9230  node->body = this->body.clone();
9231  node->annotations = this->annotations.clone();
9232  return node;
9233 }
9234 
9238 bool WhileLoop::equals(const Node &rhs) const {
9239  if (rhs.type() != NodeType::WhileLoop) return false;
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;
9244  return true;
9245 }
9246 
9250 bool WhileLoop::operator==(const Node &rhs) const {
9251  if (rhs.type() != NodeType::WhileLoop) 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;
9256  return true;
9257 }
9258 
9263  ::tree::cbor::MapWriter &map,
9264  const ::tree::base::PointerMap &ids
9265 ) const {
9266  (void)ids;
9267  map.append_string("@t", "WhileLoop");
9268  auto submap = map.append_map("condition");
9269  condition.serialize(submap, ids);
9270  submap.close();
9271  submap = map.append_map("body");
9272  body.serialize(submap, ids);
9273  submap.close();
9274  submap = map.append_map("annotations");
9275  annotations.serialize(submap, ids);
9276  submap.close();
9277  serialize_annotations(map);
9278 }
9279 
9283 std::shared_ptr<WhileLoop> WhileLoop::deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids) {
9284  (void)ids;
9285  auto type = map.at("@t").as_string();
9286  if (type != "WhileLoop") {
9287  throw std::runtime_error("Schema validation failed: unexpected node type " + type);
9288  }
9289  auto node = std::make_shared<WhileLoop>(
9290  One<Expression>(map.at("condition").as_map(), ids),
9291  One<StatementList>(map.at("body").as_map(), ids),
9292  Any<AnnotationData>(map.at("annotations").as_map(), ids)
9293  );
9294  node->deserialize_annotations(map);
9295  return node;
9296 }
9297 
9301 template <>
9302 void Visitor<void>::raw_visit_node(Node &node, void *retval) {
9303  (void)retval;
9304  this->visit_node(node);
9305 }
9306 
9310 template <>
9311 void Visitor<void>::raw_visit_add(Add &node, void *retval) {
9312  (void)retval;
9313  this->visit_add(node);
9314 }
9315 
9319 template <>
9321  (void)retval;
9322  this->visit_annotated(node);
9323 }
9324 
9328 template <>
9330  (void)retval;
9331  this->visit_annotation_data(node);
9332 }
9333 
9337 template <>
9338 void Visitor<void>::raw_visit_arith_op(ArithOp &node, void *retval) {
9339  (void)retval;
9340  this->visit_arith_op(node);
9341 }
9342 
9346 template <>
9348  (void)retval;
9349  this->visit_assignment(node);
9350 }
9351 
9355 template <>
9357  (void)retval;
9358  this->visit_binary_op(node);
9359 }
9360 
9364 template <>
9366  (void)retval;
9367  this->visit_bitwise_and(node);
9368 }
9369 
9373 template <>
9375  (void)retval;
9376  this->visit_bitwise_not(node);
9377 }
9378 
9382 template <>
9384  (void)retval;
9385  this->visit_bitwise_op(node);
9386 }
9387 
9391 template <>
9393  (void)retval;
9394  this->visit_bitwise_or(node);
9395 }
9396 
9400 template <>
9402  (void)retval;
9403  this->visit_bitwise_xor(node);
9404 }
9405 
9409 template <>
9411  (void)retval;
9412  this->visit_break_statement(node);
9413 }
9414 
9418 template <>
9419 void Visitor<void>::raw_visit_bundle(Bundle &node, void *retval) {
9420  (void)retval;
9421  this->visit_bundle(node);
9422 }
9423 
9427 template <>
9428 void Visitor<void>::raw_visit_cmp_eq(CmpEq &node, void *retval) {
9429  (void)retval;
9430  this->visit_cmp_eq(node);
9431 }
9432 
9436 template <>
9437 void Visitor<void>::raw_visit_cmp_ge(CmpGe &node, void *retval) {
9438  (void)retval;
9439  this->visit_cmp_ge(node);
9440 }
9441 
9445 template <>
9446 void Visitor<void>::raw_visit_cmp_gt(CmpGt &node, void *retval) {
9447  (void)retval;
9448  this->visit_cmp_gt(node);
9449 }
9450 
9454 template <>
9455 void Visitor<void>::raw_visit_cmp_le(CmpLe &node, void *retval) {
9456  (void)retval;
9457  this->visit_cmp_le(node);
9458 }
9459 
9463 template <>
9464 void Visitor<void>::raw_visit_cmp_lt(CmpLt &node, void *retval) {
9465  (void)retval;
9466  this->visit_cmp_lt(node);
9467 }
9468 
9472 template <>
9473 void Visitor<void>::raw_visit_cmp_ne(CmpNe &node, void *retval) {
9474  (void)retval;
9475  this->visit_cmp_ne(node);
9476 }
9477 
9481 template <>
9482 void Visitor<void>::raw_visit_cmp_op(CmpOp &node, void *retval) {
9483  (void)retval;
9484  this->visit_cmp_op(node);
9485 }
9486 
9490 template <>
9492  (void)retval;
9493  this->visit_continue_statement(node);
9494 }
9495 
9499 template <>
9500 void Visitor<void>::raw_visit_divide(Divide &node, void *retval) {
9501  (void)retval;
9502  this->visit_divide(node);
9503 }
9504 
9508 template <>
9510  (void)retval;
9511  this->visit_erroneous_expression(node);
9512 }
9513 
9517 template <>
9519  (void)retval;
9520  this->visit_erroneous_program(node);
9521 }
9522 
9526 template <>
9528  (void)retval;
9529  this->visit_erroneous_statement(node);
9530 }
9531 
9535 template <>
9537  (void)retval;
9538  this->visit_expression(node);
9539 }
9540 
9544 template <>
9546  (void)retval;
9547  this->visit_expression_list(node);
9548 }
9549 
9553 template <>
9555  (void)retval;
9556  this->visit_float_literal(node);
9557 }
9558 
9562 template <>
9563 void Visitor<void>::raw_visit_for_loop(ForLoop &node, void *retval) {
9564  (void)retval;
9565  this->visit_for_loop(node);
9566 }
9567 
9571 template <>
9573  (void)retval;
9574  this->visit_foreach_loop(node);
9575 }
9576 
9580 template <>
9582  (void)retval;
9583  this->visit_function_call(node);
9584 }
9585 
9589 template <>
9591  (void)retval;
9592  this->visit_identifier(node);
9593 }
9594 
9598 template <>
9599 void Visitor<void>::raw_visit_if_else(IfElse &node, void *retval) {
9600  (void)retval;
9601  this->visit_if_else(node);
9602 }
9603 
9607 template <>
9609  (void)retval;
9610  this->visit_if_else_branch(node);
9611 }
9612 
9616 template <>
9617 void Visitor<void>::raw_visit_index(Index &node, void *retval) {
9618  (void)retval;
9619  this->visit_index(node);
9620 }
9621 
9625 template <>
9627  (void)retval;
9628  this->visit_index_entry(node);
9629 }
9630 
9634 template <>
9636  (void)retval;
9637  this->visit_index_item(node);
9638 }
9639 
9643 template <>
9645  (void)retval;
9646  this->visit_index_list(node);
9647 }
9648 
9652 template <>
9654  (void)retval;
9655  this->visit_index_range(node);
9656 }
9657 
9661 template <>
9663  (void)retval;
9664  this->visit_instruction(node);
9665 }
9666 
9670 template <>
9672  (void)retval;
9673  this->visit_int_divide(node);
9674 }
9675 
9679 template <>
9681  (void)retval;
9682  this->visit_integer_literal(node);
9683 }
9684 
9688 template <>
9690  (void)retval;
9691  this->visit_json_literal(node);
9692 }
9693 
9697 template <>
9699  (void)retval;
9700  this->visit_logical_and(node);
9701 }
9702 
9706 template <>
9708  (void)retval;
9709  this->visit_logical_not(node);
9710 }
9711 
9715 template <>
9717  (void)retval;
9718  this->visit_logical_op(node);
9719 }
9720 
9724 template <>
9726  (void)retval;
9727  this->visit_logical_or(node);
9728 }
9729 
9733 template <>
9735  (void)retval;
9736  this->visit_logical_xor(node);
9737 }
9738 
9742 template <>
9743 void Visitor<void>::raw_visit_mapping(Mapping &node, void *retval) {
9744  (void)retval;
9745  this->visit_mapping(node);
9746 }
9747 
9751 template <>
9753  (void)retval;
9754  this->visit_matrix_literal(node);
9755 }
9756 
9760 template <>
9761 void Visitor<void>::raw_visit_modulo(Modulo &node, void *retval) {
9762  (void)retval;
9763  this->visit_modulo(node);
9764 }
9765 
9769 template <>
9770 void Visitor<void>::raw_visit_multiply(Multiply &node, void *retval) {
9771  (void)retval;
9772  this->visit_multiply(node);
9773 }
9774 
9778 template <>
9779 void Visitor<void>::raw_visit_negate(Negate &node, void *retval) {
9780  (void)retval;
9781  this->visit_negate(node);
9782 }
9783 
9787 template <>
9788 void Visitor<void>::raw_visit_power(Power &node, void *retval) {
9789  (void)retval;
9790  this->visit_power(node);
9791 }
9792 
9796 template <>
9797 void Visitor<void>::raw_visit_program(Program &node, void *retval) {
9798  (void)retval;
9799  this->visit_program(node);
9800 }
9801 
9805 template <>
9807  (void)retval;
9808  this->visit_repeat_until_loop(node);
9809 }
9810 
9814 template <>
9815 void Visitor<void>::raw_visit_root(Root &node, void *retval) {
9816  (void)retval;
9817  this->visit_root(node);
9818 }
9819 
9823 template <>
9825  (void)retval;
9826  this->visit_shift_left(node);
9827 }
9828 
9832 template <>
9833 void Visitor<void>::raw_visit_shift_op(ShiftOp &node, void *retval) {
9834  (void)retval;
9835  this->visit_shift_op(node);
9836 }
9837 
9841 template <>
9843  (void)retval;
9844  this->visit_shift_right_arith(node);
9845 }
9846 
9850 template <>
9852  (void)retval;
9853  this->visit_shift_right_logic(node);
9854 }
9855 
9859 template <>
9861  (void)retval;
9862  this->visit_statement(node);
9863 }
9864 
9868 template <>
9870  (void)retval;
9871  this->visit_statement_list(node);
9872 }
9873 
9877 template <>
9879  (void)retval;
9880  this->visit_string_literal(node);
9881 }
9882 
9886 template <>
9888  (void)retval;
9889  this->visit_structured(node);
9890 }
9891 
9895 template <>
9897  (void)retval;
9898  this->visit_subcircuit(node);
9899 }
9900 
9904 template <>
9905 void Visitor<void>::raw_visit_subtract(Subtract &node, void *retval) {
9906  (void)retval;
9907  this->visit_subtract(node);
9908 }
9909 
9913 template <>
9915  (void)retval;
9916  this->visit_ternary_cond(node);
9917 }
9918 
9922 template <>
9923 void Visitor<void>::raw_visit_unary_op(UnaryOp &node, void *retval) {
9924  (void)retval;
9925  this->visit_unary_op(node);
9926 }
9927 
9931 template <>
9933  (void)retval;
9934  this->visit_variables(node);
9935 }
9936 
9940 template <>
9941 void Visitor<void>::raw_visit_version(Version &node, void *retval) {
9942  (void)retval;
9943  this->visit_version(node);
9944 }
9945 
9949 template <>
9951  (void)retval;
9952  this->visit_while_loop(node);
9953 }
9954 
9959  visit_arith_op(node);
9960 }
9961 
9966  visit_node(node);
9967  node.annotations.visit(*this);
9968 }
9969 
9974  visit_node(node);
9975  node.interface.visit(*this);
9976  node.operation.visit(*this);
9977  node.operands.visit(*this);
9978 }
9979 
9984  visit_binary_op(node);
9985 }
9986 
9991  visit_node(node);
9992  node.lhs.visit(*this);
9993  node.rhs.visit(*this);
9994 }
9995 
10000  visit_expression(node);
10001  node.lhs.visit(*this);
10002  node.rhs.visit(*this);
10003 }
10004 
10009  visit_bitwise_op(node);
10010 }
10011 
10016  visit_unary_op(node);
10017 }
10018 
10023  visit_binary_op(node);
10024 }
10025 
10030  visit_bitwise_op(node);
10031 }
10032 
10037  visit_bitwise_op(node);
10038 }
10039 
10044  visit_structured(node);
10045 }
10046 
10051  visit_statement(node);
10052  node.items.visit(*this);
10053 }
10054 
10059  visit_cmp_op(node);
10060 }
10061 
10066  visit_cmp_op(node);
10067 }
10068 
10073  visit_cmp_op(node);
10074 }
10075 
10080  visit_cmp_op(node);
10081 }
10082 
10087  visit_cmp_op(node);
10088 }
10089 
10094  visit_cmp_op(node);
10095 }
10096 
10101  visit_binary_op(node);
10102 }
10103 
10108  visit_structured(node);
10109 }
10110 
10115  visit_arith_op(node);
10116 }
10117 
10122  visit_expression(node);
10123 }
10124 
10129  visit_root(node);
10130 }
10131 
10136  visit_statement(node);
10137 }
10138 
10143  visit_node(node);
10144 }
10145 
10150  visit_node(node);
10151  node.items.visit(*this);
10152 }
10153 
10158  visit_expression(node);
10159 }
10160 
10165  visit_structured(node);
10166  node.initialize.visit(*this);
10167  node.condition.visit(*this);
10168  node.update.visit(*this);
10169  node.body.visit(*this);
10170 }
10171 
10176  visit_structured(node);
10177  node.lhs.visit(*this);
10178  node.frm.visit(*this);
10179  node.to.visit(*this);
10180  node.body.visit(*this);
10181 }
10182 
10187  visit_expression(node);
10188  node.name.visit(*this);
10189  node.arguments.visit(*this);
10190 }
10191 
10196  visit_expression(node);
10197 }
10198 
10203  visit_structured(node);
10204  node.branches.visit(*this);
10205  node.otherwise.visit(*this);
10206 }
10207 
10212  visit_node(node);
10213  node.condition.visit(*this);
10214  node.body.visit(*this);
10215 }
10216 
10221  visit_expression(node);
10222  node.expr.visit(*this);
10223  node.indices.visit(*this);
10224 }
10225 
10230  visit_node(node);
10231 }
10232 
10237  visit_index_entry(node);
10238  node.index.visit(*this);
10239 }
10240 
10245  visit_node(node);
10246  node.items.visit(*this);
10247 }
10248 
10253  visit_index_entry(node);
10254  node.first.visit(*this);
10255  node.last.visit(*this);
10256 }
10257 
10262  visit_annotated(node);
10263  node.name.visit(*this);
10264  node.condition.visit(*this);
10265  node.operands.visit(*this);
10266 }
10267 
10272  visit_arith_op(node);
10273 }
10274 
10279  visit_expression(node);
10280 }
10281 
10286  visit_expression(node);
10287 }
10288 
10293  visit_logical_op(node);
10294 }
10295 
10300  visit_unary_op(node);
10301 }
10302 
10307  visit_binary_op(node);
10308 }
10309 
10314  visit_logical_op(node);
10315 }
10316 
10321  visit_logical_op(node);
10322 }
10323 
10328  visit_statement(node);
10329  node.alias.visit(*this);
10330  node.expr.visit(*this);
10331 }
10332 
10337  visit_expression(node);
10338  node.rows.visit(*this);
10339 }
10340 
10345  visit_arith_op(node);
10346 }
10347 
10352  visit_arith_op(node);
10353 }
10354 
10359  visit_unary_op(node);
10360 }
10361 
10366  visit_arith_op(node);
10367 }
10368 
10373  visit_root(node);
10374  node.version.visit(*this);
10375  node.num_qubits.visit(*this);
10376  node.statements.visit(*this);
10377 }
10378 
10383  visit_structured(node);
10384  node.body.visit(*this);
10385  node.condition.visit(*this);
10386 }
10387 
10392  visit_node(node);
10393 }
10394 
10399  visit_shift_op(node);
10400 }
10401 
10406  visit_binary_op(node);
10407 }
10408 
10413  visit_shift_op(node);
10414 }
10415 
10420  visit_shift_op(node);
10421 }
10422 
10427  visit_annotated(node);
10428 }
10429 
10434  visit_node(node);
10435  node.items.visit(*this);
10436 }
10437 
10442  visit_expression(node);
10443 }
10444 
10449  visit_statement(node);
10450 }
10451 
10456  visit_statement(node);
10457  node.name.visit(*this);
10458  node.iterations.visit(*this);
10459 }
10460 
10465  visit_arith_op(node);
10466 }
10467 
10472  visit_expression(node);
10473  node.cond.visit(*this);
10474  node.if_true.visit(*this);
10475  node.if_false.visit(*this);
10476 }
10477 
10482  visit_expression(node);
10483  node.expr.visit(*this);
10484 }
10485 
10490  visit_statement(node);
10491  node.names.visit(*this);
10492  node.typ.visit(*this);
10493 }
10494 
10499  visit_node(node);
10500 }
10501 
10506  visit_structured(node);
10507  node.condition.visit(*this);
10508  node.body.visit(*this);
10509 }
10510 
10515  for (int i = 0; i < indent; i++) {
10516  out << " ";
10517  }
10518 }
10519 
10524  (void)node;
10525  write_indent();
10526  out << "!Node()" << std::endl;
10527 }
10528 
10532 void Dumper::visit_add(Add &node) {
10533  write_indent();
10534  out << "Add";
10535  if (ids != nullptr) {
10536  out << "@" << ids->get_ref(node);
10537  }
10538  out << "(";
10539  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10540  out << " # " << *loc;
10541  }
10542  out << std::endl;
10543  indent++;
10544  write_indent();
10545  out << "lhs: ";
10546  if (node.lhs.empty()) {
10547  out << "!MISSING" << std::endl;
10548  } else {
10549  out << "<" << std::endl;
10550  indent++;
10551  node.lhs.visit(*this);
10552  indent--;
10553  write_indent();
10554  out << ">" << std::endl;
10555  }
10556  write_indent();
10557  out << "rhs: ";
10558  if (node.rhs.empty()) {
10559  out << "!MISSING" << std::endl;
10560  } else {
10561  out << "<" << std::endl;
10562  indent++;
10563  node.rhs.visit(*this);
10564  indent--;
10565  write_indent();
10566  out << ">" << std::endl;
10567  }
10568  indent--;
10569  write_indent();
10570  out << ")" << std::endl;
10571 }
10572 
10577  write_indent();
10578  out << "Annotated";
10579  if (ids != nullptr) {
10580  out << "@" << ids->get_ref(node);
10581  }
10582  out << "(";
10583  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10584  out << " # " << *loc;
10585  }
10586  out << std::endl;
10587  indent++;
10588  write_indent();
10589  out << "annotations: ";
10590  if (node.annotations.empty()) {
10591  out << "[]" << std::endl;
10592  } else {
10593  out << "[" << std::endl;
10594  indent++;
10595  for (auto &sptr : node.annotations) {
10596  if (!sptr.empty()) {
10597  sptr->visit(*this);
10598  } else {
10599  write_indent();
10600  out << "!NULL" << std::endl;
10601  }
10602  }
10603  indent--;
10604  write_indent();
10605  out << "]" << std::endl;
10606  }
10607  indent--;
10608  write_indent();
10609  out << ")" << std::endl;
10610 }
10611 
10616  write_indent();
10617  out << "AnnotationData";
10618  if (ids != nullptr) {
10619  out << "@" << ids->get_ref(node);
10620  }
10621  out << "(";
10622  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10623  out << " # " << *loc;
10624  }
10625  out << std::endl;
10626  indent++;
10627  write_indent();
10628  out << "interface: ";
10629  if (node.interface.empty()) {
10630  out << "!MISSING" << std::endl;
10631  } else {
10632  out << "<" << std::endl;
10633  indent++;
10634  node.interface.visit(*this);
10635  indent--;
10636  write_indent();
10637  out << ">" << std::endl;
10638  }
10639  write_indent();
10640  out << "operation: ";
10641  if (node.operation.empty()) {
10642  out << "!MISSING" << std::endl;
10643  } else {
10644  out << "<" << std::endl;
10645  indent++;
10646  node.operation.visit(*this);
10647  indent--;
10648  write_indent();
10649  out << ">" << std::endl;
10650  }
10651  write_indent();
10652  out << "operands: ";
10653  if (node.operands.empty()) {
10654  out << "!MISSING" << std::endl;
10655  } else {
10656  out << "<" << std::endl;
10657  indent++;
10658  node.operands.visit(*this);
10659  indent--;
10660  write_indent();
10661  out << ">" << std::endl;
10662  }
10663  indent--;
10664  write_indent();
10665  out << ")" << std::endl;
10666 }
10667 
10672  write_indent();
10673  out << "ArithOp";
10674  if (ids != nullptr) {
10675  out << "@" << ids->get_ref(node);
10676  }
10677  out << "(";
10678  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10679  out << " # " << *loc;
10680  }
10681  out << std::endl;
10682  indent++;
10683  write_indent();
10684  out << "lhs: ";
10685  if (node.lhs.empty()) {
10686  out << "!MISSING" << std::endl;
10687  } else {
10688  out << "<" << std::endl;
10689  indent++;
10690  node.lhs.visit(*this);
10691  indent--;
10692  write_indent();
10693  out << ">" << std::endl;
10694  }
10695  write_indent();
10696  out << "rhs: ";
10697  if (node.rhs.empty()) {
10698  out << "!MISSING" << std::endl;
10699  } else {
10700  out << "<" << std::endl;
10701  indent++;
10702  node.rhs.visit(*this);
10703  indent--;
10704  write_indent();
10705  out << ">" << std::endl;
10706  }
10707  indent--;
10708  write_indent();
10709  out << ")" << std::endl;
10710 }
10711 
10716  write_indent();
10717  out << "Assignment";
10718  if (ids != nullptr) {
10719  out << "@" << ids->get_ref(node);
10720  }
10721  out << "(";
10722  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10723  out << " # " << *loc;
10724  }
10725  out << std::endl;
10726  indent++;
10727  write_indent();
10728  out << "lhs: ";
10729  if (node.lhs.empty()) {
10730  out << "!MISSING" << std::endl;
10731  } else {
10732  out << "<" << std::endl;
10733  indent++;
10734  node.lhs.visit(*this);
10735  indent--;
10736  write_indent();
10737  out << ">" << std::endl;
10738  }
10739  write_indent();
10740  out << "rhs: ";
10741  if (node.rhs.empty()) {
10742  out << "!MISSING" << std::endl;
10743  } else {
10744  out << "<" << std::endl;
10745  indent++;
10746  node.rhs.visit(*this);
10747  indent--;
10748  write_indent();
10749  out << ">" << std::endl;
10750  }
10751  indent--;
10752  write_indent();
10753  out << ")" << std::endl;
10754 }
10755 
10760  write_indent();
10761  out << "BinaryOp";
10762  if (ids != nullptr) {
10763  out << "@" << ids->get_ref(node);
10764  }
10765  out << "(";
10766  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10767  out << " # " << *loc;
10768  }
10769  out << std::endl;
10770  indent++;
10771  write_indent();
10772  out << "lhs: ";
10773  if (node.lhs.empty()) {
10774  out << "!MISSING" << std::endl;
10775  } else {
10776  out << "<" << std::endl;
10777  indent++;
10778  node.lhs.visit(*this);
10779  indent--;
10780  write_indent();
10781  out << ">" << std::endl;
10782  }
10783  write_indent();
10784  out << "rhs: ";
10785  if (node.rhs.empty()) {
10786  out << "!MISSING" << std::endl;
10787  } else {
10788  out << "<" << std::endl;
10789  indent++;
10790  node.rhs.visit(*this);
10791  indent--;
10792  write_indent();
10793  out << ">" << std::endl;
10794  }
10795  indent--;
10796  write_indent();
10797  out << ")" << std::endl;
10798 }
10799 
10804  write_indent();
10805  out << "BitwiseAnd";
10806  if (ids != nullptr) {
10807  out << "@" << ids->get_ref(node);
10808  }
10809  out << "(";
10810  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10811  out << " # " << *loc;
10812  }
10813  out << std::endl;
10814  indent++;
10815  write_indent();
10816  out << "lhs: ";
10817  if (node.lhs.empty()) {
10818  out << "!MISSING" << std::endl;
10819  } else {
10820  out << "<" << std::endl;
10821  indent++;
10822  node.lhs.visit(*this);
10823  indent--;
10824  write_indent();
10825  out << ">" << std::endl;
10826  }
10827  write_indent();
10828  out << "rhs: ";
10829  if (node.rhs.empty()) {
10830  out << "!MISSING" << std::endl;
10831  } else {
10832  out << "<" << std::endl;
10833  indent++;
10834  node.rhs.visit(*this);
10835  indent--;
10836  write_indent();
10837  out << ">" << std::endl;
10838  }
10839  indent--;
10840  write_indent();
10841  out << ")" << std::endl;
10842 }
10843 
10848  write_indent();
10849  out << "BitwiseNot";
10850  if (ids != nullptr) {
10851  out << "@" << ids->get_ref(node);
10852  }
10853  out << "(";
10854  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10855  out << " # " << *loc;
10856  }
10857  out << std::endl;
10858  indent++;
10859  write_indent();
10860  out << "expr: ";
10861  if (node.expr.empty()) {
10862  out << "!MISSING" << std::endl;
10863  } else {
10864  out << "<" << std::endl;
10865  indent++;
10866  node.expr.visit(*this);
10867  indent--;
10868  write_indent();
10869  out << ">" << std::endl;
10870  }
10871  indent--;
10872  write_indent();
10873  out << ")" << std::endl;
10874 }
10875 
10880  write_indent();
10881  out << "BitwiseOp";
10882  if (ids != nullptr) {
10883  out << "@" << ids->get_ref(node);
10884  }
10885  out << "(";
10886  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10887  out << " # " << *loc;
10888  }
10889  out << std::endl;
10890  indent++;
10891  write_indent();
10892  out << "lhs: ";
10893  if (node.lhs.empty()) {
10894  out << "!MISSING" << std::endl;
10895  } else {
10896  out << "<" << std::endl;
10897  indent++;
10898  node.lhs.visit(*this);
10899  indent--;
10900  write_indent();
10901  out << ">" << std::endl;
10902  }
10903  write_indent();
10904  out << "rhs: ";
10905  if (node.rhs.empty()) {
10906  out << "!MISSING" << std::endl;
10907  } else {
10908  out << "<" << std::endl;
10909  indent++;
10910  node.rhs.visit(*this);
10911  indent--;
10912  write_indent();
10913  out << ">" << std::endl;
10914  }
10915  indent--;
10916  write_indent();
10917  out << ")" << std::endl;
10918 }
10919 
10924  write_indent();
10925  out << "BitwiseOr";
10926  if (ids != nullptr) {
10927  out << "@" << ids->get_ref(node);
10928  }
10929  out << "(";
10930  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10931  out << " # " << *loc;
10932  }
10933  out << std::endl;
10934  indent++;
10935  write_indent();
10936  out << "lhs: ";
10937  if (node.lhs.empty()) {
10938  out << "!MISSING" << std::endl;
10939  } else {
10940  out << "<" << std::endl;
10941  indent++;
10942  node.lhs.visit(*this);
10943  indent--;
10944  write_indent();
10945  out << ">" << std::endl;
10946  }
10947  write_indent();
10948  out << "rhs: ";
10949  if (node.rhs.empty()) {
10950  out << "!MISSING" << std::endl;
10951  } else {
10952  out << "<" << std::endl;
10953  indent++;
10954  node.rhs.visit(*this);
10955  indent--;
10956  write_indent();
10957  out << ">" << std::endl;
10958  }
10959  indent--;
10960  write_indent();
10961  out << ")" << std::endl;
10962 }
10963 
10968  write_indent();
10969  out << "BitwiseXor";
10970  if (ids != nullptr) {
10971  out << "@" << ids->get_ref(node);
10972  }
10973  out << "(";
10974  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
10975  out << " # " << *loc;
10976  }
10977  out << std::endl;
10978  indent++;
10979  write_indent();
10980  out << "lhs: ";
10981  if (node.lhs.empty()) {
10982  out << "!MISSING" << std::endl;
10983  } else {
10984  out << "<" << std::endl;
10985  indent++;
10986  node.lhs.visit(*this);
10987  indent--;
10988  write_indent();
10989  out << ">" << std::endl;
10990  }
10991  write_indent();
10992  out << "rhs: ";
10993  if (node.rhs.empty()) {
10994  out << "!MISSING" << std::endl;
10995  } else {
10996  out << "<" << std::endl;
10997  indent++;
10998  node.rhs.visit(*this);
10999  indent--;
11000  write_indent();
11001  out << ">" << std::endl;
11002  }
11003  indent--;
11004  write_indent();
11005  out << ")" << std::endl;
11006 }
11007 
11012  write_indent();
11013  out << "BreakStatement";
11014  if (ids != nullptr) {
11015  out << "@" << ids->get_ref(node);
11016  }
11017  out << "(";
11018  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11019  out << " # " << *loc;
11020  }
11021  out << std::endl;
11022  indent++;
11023  write_indent();
11024  out << "annotations: ";
11025  if (node.annotations.empty()) {
11026  out << "[]" << std::endl;
11027  } else {
11028  out << "[" << std::endl;
11029  indent++;
11030  for (auto &sptr : node.annotations) {
11031  if (!sptr.empty()) {
11032  sptr->visit(*this);
11033  } else {
11034  write_indent();
11035  out << "!NULL" << std::endl;
11036  }
11037  }
11038  indent--;
11039  write_indent();
11040  out << "]" << std::endl;
11041  }
11042  indent--;
11043  write_indent();
11044  out << ")" << std::endl;
11045 }
11046 
11051  write_indent();
11052  out << "Bundle";
11053  if (ids != nullptr) {
11054  out << "@" << ids->get_ref(node);
11055  }
11056  out << "(";
11057  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11058  out << " # " << *loc;
11059  }
11060  out << std::endl;
11061  indent++;
11062  write_indent();
11063  out << "items: ";
11064  if (node.items.empty()) {
11065  out << "!MISSING" << std::endl;
11066  } else {
11067  out << "[" << std::endl;
11068  indent++;
11069  for (auto &sptr : node.items) {
11070  if (!sptr.empty()) {
11071  sptr->visit(*this);
11072  } else {
11073  write_indent();
11074  out << "!NULL" << std::endl;
11075  }
11076  }
11077  indent--;
11078  write_indent();
11079  out << "]" << std::endl;
11080  }
11081  write_indent();
11082  out << "annotations: ";
11083  if (node.annotations.empty()) {
11084  out << "[]" << std::endl;
11085  } else {
11086  out << "[" << std::endl;
11087  indent++;
11088  for (auto &sptr : node.annotations) {
11089  if (!sptr.empty()) {
11090  sptr->visit(*this);
11091  } else {
11092  write_indent();
11093  out << "!NULL" << std::endl;
11094  }
11095  }
11096  indent--;
11097  write_indent();
11098  out << "]" << std::endl;
11099  }
11100  indent--;
11101  write_indent();
11102  out << ")" << std::endl;
11103 }
11104 
11109  write_indent();
11110  out << "CmpEq";
11111  if (ids != nullptr) {
11112  out << "@" << ids->get_ref(node);
11113  }
11114  out << "(";
11115  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11116  out << " # " << *loc;
11117  }
11118  out << std::endl;
11119  indent++;
11120  write_indent();
11121  out << "lhs: ";
11122  if (node.lhs.empty()) {
11123  out << "!MISSING" << std::endl;
11124  } else {
11125  out << "<" << std::endl;
11126  indent++;
11127  node.lhs.visit(*this);
11128  indent--;
11129  write_indent();
11130  out << ">" << std::endl;
11131  }
11132  write_indent();
11133  out << "rhs: ";
11134  if (node.rhs.empty()) {
11135  out << "!MISSING" << std::endl;
11136  } else {
11137  out << "<" << std::endl;
11138  indent++;
11139  node.rhs.visit(*this);
11140  indent--;
11141  write_indent();
11142  out << ">" << std::endl;
11143  }
11144  indent--;
11145  write_indent();
11146  out << ")" << std::endl;
11147 }
11148 
11153  write_indent();
11154  out << "CmpGe";
11155  if (ids != nullptr) {
11156  out << "@" << ids->get_ref(node);
11157  }
11158  out << "(";
11159  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11160  out << " # " << *loc;
11161  }
11162  out << std::endl;
11163  indent++;
11164  write_indent();
11165  out << "lhs: ";
11166  if (node.lhs.empty()) {
11167  out << "!MISSING" << std::endl;
11168  } else {
11169  out << "<" << std::endl;
11170  indent++;
11171  node.lhs.visit(*this);
11172  indent--;
11173  write_indent();
11174  out << ">" << std::endl;
11175  }
11176  write_indent();
11177  out << "rhs: ";
11178  if (node.rhs.empty()) {
11179  out << "!MISSING" << std::endl;
11180  } else {
11181  out << "<" << std::endl;
11182  indent++;
11183  node.rhs.visit(*this);
11184  indent--;
11185  write_indent();
11186  out << ">" << std::endl;
11187  }
11188  indent--;
11189  write_indent();
11190  out << ")" << std::endl;
11191 }
11192 
11197  write_indent();
11198  out << "CmpGt";
11199  if (ids != nullptr) {
11200  out << "@" << ids->get_ref(node);
11201  }
11202  out << "(";
11203  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11204  out << " # " << *loc;
11205  }
11206  out << std::endl;
11207  indent++;
11208  write_indent();
11209  out << "lhs: ";
11210  if (node.lhs.empty()) {
11211  out << "!MISSING" << std::endl;
11212  } else {
11213  out << "<" << std::endl;
11214  indent++;
11215  node.lhs.visit(*this);
11216  indent--;
11217  write_indent();
11218  out << ">" << std::endl;
11219  }
11220  write_indent();
11221  out << "rhs: ";
11222  if (node.rhs.empty()) {
11223  out << "!MISSING" << std::endl;
11224  } else {
11225  out << "<" << std::endl;
11226  indent++;
11227  node.rhs.visit(*this);
11228  indent--;
11229  write_indent();
11230  out << ">" << std::endl;
11231  }
11232  indent--;
11233  write_indent();
11234  out << ")" << std::endl;
11235 }
11236 
11241  write_indent();
11242  out << "CmpLe";
11243  if (ids != nullptr) {
11244  out << "@" << ids->get_ref(node);
11245  }
11246  out << "(";
11247  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11248  out << " # " << *loc;
11249  }
11250  out << std::endl;
11251  indent++;
11252  write_indent();
11253  out << "lhs: ";
11254  if (node.lhs.empty()) {
11255  out << "!MISSING" << std::endl;
11256  } else {
11257  out << "<" << std::endl;
11258  indent++;
11259  node.lhs.visit(*this);
11260  indent--;
11261  write_indent();
11262  out << ">" << std::endl;
11263  }
11264  write_indent();
11265  out << "rhs: ";
11266  if (node.rhs.empty()) {
11267  out << "!MISSING" << std::endl;
11268  } else {
11269  out << "<" << std::endl;
11270  indent++;
11271  node.rhs.visit(*this);
11272  indent--;
11273  write_indent();
11274  out << ">" << std::endl;
11275  }
11276  indent--;
11277  write_indent();
11278  out << ")" << std::endl;
11279 }
11280 
11285  write_indent();
11286  out << "CmpLt";
11287  if (ids != nullptr) {
11288  out << "@" << ids->get_ref(node);
11289  }
11290  out << "(";
11291  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11292  out << " # " << *loc;
11293  }
11294  out << std::endl;
11295  indent++;
11296  write_indent();
11297  out << "lhs: ";
11298  if (node.lhs.empty()) {
11299  out << "!MISSING" << std::endl;
11300  } else {
11301  out << "<" << std::endl;
11302  indent++;
11303  node.lhs.visit(*this);
11304  indent--;
11305  write_indent();
11306  out << ">" << std::endl;
11307  }
11308  write_indent();
11309  out << "rhs: ";
11310  if (node.rhs.empty()) {
11311  out << "!MISSING" << std::endl;
11312  } else {
11313  out << "<" << std::endl;
11314  indent++;
11315  node.rhs.visit(*this);
11316  indent--;
11317  write_indent();
11318  out << ">" << std::endl;
11319  }
11320  indent--;
11321  write_indent();
11322  out << ")" << std::endl;
11323 }
11324 
11329  write_indent();
11330  out << "CmpNe";
11331  if (ids != nullptr) {
11332  out << "@" << ids->get_ref(node);
11333  }
11334  out << "(";
11335  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11336  out << " # " << *loc;
11337  }
11338  out << std::endl;
11339  indent++;
11340  write_indent();
11341  out << "lhs: ";
11342  if (node.lhs.empty()) {
11343  out << "!MISSING" << std::endl;
11344  } else {
11345  out << "<" << std::endl;
11346  indent++;
11347  node.lhs.visit(*this);
11348  indent--;
11349  write_indent();
11350  out << ">" << std::endl;
11351  }
11352  write_indent();
11353  out << "rhs: ";
11354  if (node.rhs.empty()) {
11355  out << "!MISSING" << std::endl;
11356  } else {
11357  out << "<" << std::endl;
11358  indent++;
11359  node.rhs.visit(*this);
11360  indent--;
11361  write_indent();
11362  out << ">" << std::endl;
11363  }
11364  indent--;
11365  write_indent();
11366  out << ")" << std::endl;
11367 }
11368 
11373  write_indent();
11374  out << "CmpOp";
11375  if (ids != nullptr) {
11376  out << "@" << ids->get_ref(node);
11377  }
11378  out << "(";
11379  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11380  out << " # " << *loc;
11381  }
11382  out << std::endl;
11383  indent++;
11384  write_indent();
11385  out << "lhs: ";
11386  if (node.lhs.empty()) {
11387  out << "!MISSING" << std::endl;
11388  } else {
11389  out << "<" << std::endl;
11390  indent++;
11391  node.lhs.visit(*this);
11392  indent--;
11393  write_indent();
11394  out << ">" << std::endl;
11395  }
11396  write_indent();
11397  out << "rhs: ";
11398  if (node.rhs.empty()) {
11399  out << "!MISSING" << std::endl;
11400  } else {
11401  out << "<" << std::endl;
11402  indent++;
11403  node.rhs.visit(*this);
11404  indent--;
11405  write_indent();
11406  out << ">" << std::endl;
11407  }
11408  indent--;
11409  write_indent();
11410  out << ")" << std::endl;
11411 }
11412 
11417  write_indent();
11418  out << "ContinueStatement";
11419  if (ids != nullptr) {
11420  out << "@" << ids->get_ref(node);
11421  }
11422  out << "(";
11423  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11424  out << " # " << *loc;
11425  }
11426  out << std::endl;
11427  indent++;
11428  write_indent();
11429  out << "annotations: ";
11430  if (node.annotations.empty()) {
11431  out << "[]" << std::endl;
11432  } else {
11433  out << "[" << std::endl;
11434  indent++;
11435  for (auto &sptr : node.annotations) {
11436  if (!sptr.empty()) {
11437  sptr->visit(*this);
11438  } else {
11439  write_indent();
11440  out << "!NULL" << std::endl;
11441  }
11442  }
11443  indent--;
11444  write_indent();
11445  out << "]" << std::endl;
11446  }
11447  indent--;
11448  write_indent();
11449  out << ")" << std::endl;
11450 }
11451 
11456  write_indent();
11457  out << "Divide";
11458  if (ids != nullptr) {
11459  out << "@" << ids->get_ref(node);
11460  }
11461  out << "(";
11462  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11463  out << " # " << *loc;
11464  }
11465  out << std::endl;
11466  indent++;
11467  write_indent();
11468  out << "lhs: ";
11469  if (node.lhs.empty()) {
11470  out << "!MISSING" << std::endl;
11471  } else {
11472  out << "<" << std::endl;
11473  indent++;
11474  node.lhs.visit(*this);
11475  indent--;
11476  write_indent();
11477  out << ">" << std::endl;
11478  }
11479  write_indent();
11480  out << "rhs: ";
11481  if (node.rhs.empty()) {
11482  out << "!MISSING" << std::endl;
11483  } else {
11484  out << "<" << std::endl;
11485  indent++;
11486  node.rhs.visit(*this);
11487  indent--;
11488  write_indent();
11489  out << ">" << std::endl;
11490  }
11491  indent--;
11492  write_indent();
11493  out << ")" << std::endl;
11494 }
11495 
11500  write_indent();
11501  out << "ErroneousExpression";
11502  if (ids != nullptr) {
11503  out << "@" << ids->get_ref(node);
11504  }
11505  out << "(";
11506  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11507  out << " # " << *loc;
11508  }
11509  out << std::endl;
11510  out << ")" << std::endl;
11511 }
11512 
11517  write_indent();
11518  out << "ErroneousProgram";
11519  if (ids != nullptr) {
11520  out << "@" << ids->get_ref(node);
11521  }
11522  out << "(";
11523  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11524  out << " # " << *loc;
11525  }
11526  out << std::endl;
11527  out << ")" << std::endl;
11528 }
11529 
11534  write_indent();
11535  out << "ErroneousStatement";
11536  if (ids != nullptr) {
11537  out << "@" << ids->get_ref(node);
11538  }
11539  out << "(";
11540  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11541  out << " # " << *loc;
11542  }
11543  out << std::endl;
11544  indent++;
11545  write_indent();
11546  out << "annotations: ";
11547  if (node.annotations.empty()) {
11548  out << "[]" << std::endl;
11549  } else {
11550  out << "[" << std::endl;
11551  indent++;
11552  for (auto &sptr : node.annotations) {
11553  if (!sptr.empty()) {
11554  sptr->visit(*this);
11555  } else {
11556  write_indent();
11557  out << "!NULL" << std::endl;
11558  }
11559  }
11560  indent--;
11561  write_indent();
11562  out << "]" << std::endl;
11563  }
11564  indent--;
11565  write_indent();
11566  out << ")" << std::endl;
11567 }
11568 
11573  write_indent();
11574  out << "Expression";
11575  if (ids != nullptr) {
11576  out << "@" << ids->get_ref(node);
11577  }
11578  out << "(";
11579  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11580  out << " # " << *loc;
11581  }
11582  out << std::endl;
11583  out << ")" << std::endl;
11584 }
11585 
11590  write_indent();
11591  out << "ExpressionList";
11592  if (ids != nullptr) {
11593  out << "@" << ids->get_ref(node);
11594  }
11595  out << "(";
11596  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11597  out << " # " << *loc;
11598  }
11599  out << std::endl;
11600  indent++;
11601  write_indent();
11602  out << "items: ";
11603  if (node.items.empty()) {
11604  out << "[]" << std::endl;
11605  } else {
11606  out << "[" << std::endl;
11607  indent++;
11608  for (auto &sptr : node.items) {
11609  if (!sptr.empty()) {
11610  sptr->visit(*this);
11611  } else {
11612  write_indent();
11613  out << "!NULL" << std::endl;
11614  }
11615  }
11616  indent--;
11617  write_indent();
11618  out << "]" << std::endl;
11619  }
11620  indent--;
11621  write_indent();
11622  out << ")" << std::endl;
11623 }
11624 
11629  write_indent();
11630  out << "FloatLiteral";
11631  if (ids != nullptr) {
11632  out << "@" << ids->get_ref(node);
11633  }
11634  out << "(";
11635  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11636  out << " # " << *loc;
11637  }
11638  out << std::endl;
11639  indent++;
11640  write_indent();
11641  out << "value: ";
11642  std::stringstream ss;
11643  size_t pos;
11644  ss << node.value;
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));
11648  }
11649  if (ss.str().find('\n') == std::string::npos) {
11650  out << ss.str() << std::endl;
11651  } else {
11652  out << "cqasm::v1::primitives::Real<<" << std::endl;
11653  indent++;
11654  std::string s;
11655  while (!ss.eof()) {
11656  std::getline(ss, s);
11657  write_indent();
11658  out << s << std::endl;
11659  }
11660  indent--;
11661  write_indent();
11662  out << ">>" << std::endl;
11663  }
11664  indent--;
11665  write_indent();
11666  out << ")" << std::endl;
11667 }
11668 
11673  write_indent();
11674  out << "ForLoop";
11675  if (ids != nullptr) {
11676  out << "@" << ids->get_ref(node);
11677  }
11678  out << "(";
11679  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11680  out << " # " << *loc;
11681  }
11682  out << std::endl;
11683  indent++;
11684  write_indent();
11685  out << "initialize: ";
11686  if (node.initialize.empty()) {
11687  out << "-" << std::endl;
11688  } else {
11689  out << "<" << std::endl;
11690  indent++;
11691  node.initialize.visit(*this);
11692  indent--;
11693  write_indent();
11694  out << ">" << std::endl;
11695  }
11696  write_indent();
11697  out << "condition: ";
11698  if (node.condition.empty()) {
11699  out << "!MISSING" << std::endl;
11700  } else {
11701  out << "<" << std::endl;
11702  indent++;
11703  node.condition.visit(*this);
11704  indent--;
11705  write_indent();
11706  out << ">" << std::endl;
11707  }
11708  write_indent();
11709  out << "update: ";
11710  if (node.update.empty()) {
11711  out << "-" << std::endl;
11712  } else {
11713  out << "<" << std::endl;
11714  indent++;
11715  node.update.visit(*this);
11716  indent--;
11717  write_indent();
11718  out << ">" << std::endl;
11719  }
11720  write_indent();
11721  out << "body: ";
11722  if (node.body.empty()) {
11723  out << "!MISSING" << std::endl;
11724  } else {
11725  out << "<" << std::endl;
11726  indent++;
11727  node.body.visit(*this);
11728  indent--;
11729  write_indent();
11730  out << ">" << std::endl;
11731  }
11732  write_indent();
11733  out << "annotations: ";
11734  if (node.annotations.empty()) {
11735  out << "[]" << std::endl;
11736  } else {
11737  out << "[" << std::endl;
11738  indent++;
11739  for (auto &sptr : node.annotations) {
11740  if (!sptr.empty()) {
11741  sptr->visit(*this);
11742  } else {
11743  write_indent();
11744  out << "!NULL" << std::endl;
11745  }
11746  }
11747  indent--;
11748  write_indent();
11749  out << "]" << std::endl;
11750  }
11751  indent--;
11752  write_indent();
11753  out << ")" << std::endl;
11754 }
11755 
11760  write_indent();
11761  out << "ForeachLoop";
11762  if (ids != nullptr) {
11763  out << "@" << ids->get_ref(node);
11764  }
11765  out << "(";
11766  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11767  out << " # " << *loc;
11768  }
11769  out << std::endl;
11770  indent++;
11771  write_indent();
11772  out << "lhs: ";
11773  if (node.lhs.empty()) {
11774  out << "!MISSING" << std::endl;
11775  } else {
11776  out << "<" << std::endl;
11777  indent++;
11778  node.lhs.visit(*this);
11779  indent--;
11780  write_indent();
11781  out << ">" << std::endl;
11782  }
11783  write_indent();
11784  out << "frm: ";
11785  if (node.frm.empty()) {
11786  out << "!MISSING" << std::endl;
11787  } else {
11788  out << "<" << std::endl;
11789  indent++;
11790  node.frm.visit(*this);
11791  indent--;
11792  write_indent();
11793  out << ">" << std::endl;
11794  }
11795  write_indent();
11796  out << "to: ";
11797  if (node.to.empty()) {
11798  out << "!MISSING" << std::endl;
11799  } else {
11800  out << "<" << std::endl;
11801  indent++;
11802  node.to.visit(*this);
11803  indent--;
11804  write_indent();
11805  out << ">" << std::endl;
11806  }
11807  write_indent();
11808  out << "body: ";
11809  if (node.body.empty()) {
11810  out << "!MISSING" << std::endl;
11811  } else {
11812  out << "<" << std::endl;
11813  indent++;
11814  node.body.visit(*this);
11815  indent--;
11816  write_indent();
11817  out << ">" << std::endl;
11818  }
11819  write_indent();
11820  out << "annotations: ";
11821  if (node.annotations.empty()) {
11822  out << "[]" << std::endl;
11823  } else {
11824  out << "[" << std::endl;
11825  indent++;
11826  for (auto &sptr : node.annotations) {
11827  if (!sptr.empty()) {
11828  sptr->visit(*this);
11829  } else {
11830  write_indent();
11831  out << "!NULL" << std::endl;
11832  }
11833  }
11834  indent--;
11835  write_indent();
11836  out << "]" << std::endl;
11837  }
11838  indent--;
11839  write_indent();
11840  out << ")" << std::endl;
11841 }
11842 
11847  write_indent();
11848  out << "FunctionCall";
11849  if (ids != nullptr) {
11850  out << "@" << ids->get_ref(node);
11851  }
11852  out << "(";
11853  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11854  out << " # " << *loc;
11855  }
11856  out << std::endl;
11857  indent++;
11858  write_indent();
11859  out << "name: ";
11860  if (node.name.empty()) {
11861  out << "!MISSING" << std::endl;
11862  } else {
11863  out << "<" << std::endl;
11864  indent++;
11865  node.name.visit(*this);
11866  indent--;
11867  write_indent();
11868  out << ">" << std::endl;
11869  }
11870  write_indent();
11871  out << "arguments: ";
11872  if (node.arguments.empty()) {
11873  out << "!MISSING" << std::endl;
11874  } else {
11875  out << "<" << std::endl;
11876  indent++;
11877  node.arguments.visit(*this);
11878  indent--;
11879  write_indent();
11880  out << ">" << std::endl;
11881  }
11882  indent--;
11883  write_indent();
11884  out << ")" << std::endl;
11885 }
11886 
11891  write_indent();
11892  out << "Identifier";
11893  if (ids != nullptr) {
11894  out << "@" << ids->get_ref(node);
11895  }
11896  out << "(";
11897  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11898  out << " # " << *loc;
11899  }
11900  out << std::endl;
11901  indent++;
11902  write_indent();
11903  out << "name: ";
11904  std::stringstream ss;
11905  size_t pos;
11906  ss << node.name;
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));
11910  }
11911  if (ss.str().find('\n') == std::string::npos) {
11912  out << ss.str() << std::endl;
11913  } else {
11914  out << "cqasm::v1::primitives::Str<<" << std::endl;
11915  indent++;
11916  std::string s;
11917  while (!ss.eof()) {
11918  std::getline(ss, s);
11919  write_indent();
11920  out << s << std::endl;
11921  }
11922  indent--;
11923  write_indent();
11924  out << ">>" << std::endl;
11925  }
11926  indent--;
11927  write_indent();
11928  out << ")" << std::endl;
11929 }
11930 
11935  write_indent();
11936  out << "IfElse";
11937  if (ids != nullptr) {
11938  out << "@" << ids->get_ref(node);
11939  }
11940  out << "(";
11941  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
11942  out << " # " << *loc;
11943  }
11944  out << std::endl;
11945  indent++;
11946  write_indent();
11947  out << "branches: ";
11948  if (node.branches.empty()) {
11949  out << "!MISSING" << std::endl;
11950  } else {
11951  out << "[" << std::endl;
11952  indent++;
11953  for (auto &sptr : node.branches) {
11954  if (!sptr.empty()) {
11955  sptr->visit(*this);
11956  } else {
11957  write_indent();
11958  out << "!NULL" << std::endl;
11959  }
11960  }
11961  indent--;
11962  write_indent();
11963  out << "]" << std::endl;
11964  }
11965  write_indent();
11966  out << "otherwise: ";
11967  if (node.otherwise.empty()) {
11968  out << "-" << std::endl;
11969  } else {
11970  out << "<" << std::endl;
11971  indent++;
11972  node.otherwise.visit(*this);
11973  indent--;
11974  write_indent();
11975  out << ">" << std::endl;
11976  }
11977  write_indent();
11978  out << "annotations: ";
11979  if (node.annotations.empty()) {
11980  out << "[]" << std::endl;
11981  } else {
11982  out << "[" << std::endl;
11983  indent++;
11984  for (auto &sptr : node.annotations) {
11985  if (!sptr.empty()) {
11986  sptr->visit(*this);
11987  } else {
11988  write_indent();
11989  out << "!NULL" << std::endl;
11990  }
11991  }
11992  indent--;
11993  write_indent();
11994  out << "]" << std::endl;
11995  }
11996  indent--;
11997  write_indent();
11998  out << ")" << std::endl;
11999 }
12000 
12005  write_indent();
12006  out << "IfElseBranch";
12007  if (ids != nullptr) {
12008  out << "@" << ids->get_ref(node);
12009  }
12010  out << "(";
12011  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12012  out << " # " << *loc;
12013  }
12014  out << std::endl;
12015  indent++;
12016  write_indent();
12017  out << "condition: ";
12018  if (node.condition.empty()) {
12019  out << "!MISSING" << std::endl;
12020  } else {
12021  out << "<" << std::endl;
12022  indent++;
12023  node.condition.visit(*this);
12024  indent--;
12025  write_indent();
12026  out << ">" << std::endl;
12027  }
12028  write_indent();
12029  out << "body: ";
12030  if (node.body.empty()) {
12031  out << "!MISSING" << std::endl;
12032  } else {
12033  out << "<" << std::endl;
12034  indent++;
12035  node.body.visit(*this);
12036  indent--;
12037  write_indent();
12038  out << ">" << std::endl;
12039  }
12040  indent--;
12041  write_indent();
12042  out << ")" << std::endl;
12043 }
12044 
12049  write_indent();
12050  out << "Index";
12051  if (ids != nullptr) {
12052  out << "@" << ids->get_ref(node);
12053  }
12054  out << "(";
12055  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12056  out << " # " << *loc;
12057  }
12058  out << std::endl;
12059  indent++;
12060  write_indent();
12061  out << "expr: ";
12062  if (node.expr.empty()) {
12063  out << "!MISSING" << std::endl;
12064  } else {
12065  out << "<" << std::endl;
12066  indent++;
12067  node.expr.visit(*this);
12068  indent--;
12069  write_indent();
12070  out << ">" << std::endl;
12071  }
12072  write_indent();
12073  out << "indices: ";
12074  if (node.indices.empty()) {
12075  out << "!MISSING" << std::endl;
12076  } else {
12077  out << "<" << std::endl;
12078  indent++;
12079  node.indices.visit(*this);
12080  indent--;
12081  write_indent();
12082  out << ">" << std::endl;
12083  }
12084  indent--;
12085  write_indent();
12086  out << ")" << std::endl;
12087 }
12088 
12093  write_indent();
12094  out << "IndexEntry";
12095  if (ids != nullptr) {
12096  out << "@" << ids->get_ref(node);
12097  }
12098  out << "(";
12099  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12100  out << " # " << *loc;
12101  }
12102  out << std::endl;
12103  out << ")" << std::endl;
12104 }
12105 
12110  write_indent();
12111  out << "IndexItem";
12112  if (ids != nullptr) {
12113  out << "@" << ids->get_ref(node);
12114  }
12115  out << "(";
12116  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12117  out << " # " << *loc;
12118  }
12119  out << std::endl;
12120  indent++;
12121  write_indent();
12122  out << "index: ";
12123  if (node.index.empty()) {
12124  out << "!MISSING" << std::endl;
12125  } else {
12126  out << "<" << std::endl;
12127  indent++;
12128  node.index.visit(*this);
12129  indent--;
12130  write_indent();
12131  out << ">" << std::endl;
12132  }
12133  indent--;
12134  write_indent();
12135  out << ")" << std::endl;
12136 }
12137 
12142  write_indent();
12143  out << "IndexList";
12144  if (ids != nullptr) {
12145  out << "@" << ids->get_ref(node);
12146  }
12147  out << "(";
12148  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12149  out << " # " << *loc;
12150  }
12151  out << std::endl;
12152  indent++;
12153  write_indent();
12154  out << "items: ";
12155  if (node.items.empty()) {
12156  out << "!MISSING" << std::endl;
12157  } else {
12158  out << "[" << std::endl;
12159  indent++;
12160  for (auto &sptr : node.items) {
12161  if (!sptr.empty()) {
12162  sptr->visit(*this);
12163  } else {
12164  write_indent();
12165  out << "!NULL" << std::endl;
12166  }
12167  }
12168  indent--;
12169  write_indent();
12170  out << "]" << std::endl;
12171  }
12172  indent--;
12173  write_indent();
12174  out << ")" << std::endl;
12175 }
12176 
12181  write_indent();
12182  out << "IndexRange";
12183  if (ids != nullptr) {
12184  out << "@" << ids->get_ref(node);
12185  }
12186  out << "(";
12187  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12188  out << " # " << *loc;
12189  }
12190  out << std::endl;
12191  indent++;
12192  write_indent();
12193  out << "first: ";
12194  if (node.first.empty()) {
12195  out << "!MISSING" << std::endl;
12196  } else {
12197  out << "<" << std::endl;
12198  indent++;
12199  node.first.visit(*this);
12200  indent--;
12201  write_indent();
12202  out << ">" << std::endl;
12203  }
12204  write_indent();
12205  out << "last: ";
12206  if (node.last.empty()) {
12207  out << "!MISSING" << std::endl;
12208  } else {
12209  out << "<" << std::endl;
12210  indent++;
12211  node.last.visit(*this);
12212  indent--;
12213  write_indent();
12214  out << ">" << std::endl;
12215  }
12216  indent--;
12217  write_indent();
12218  out << ")" << std::endl;
12219 }
12220 
12225  write_indent();
12226  out << "Instruction";
12227  if (ids != nullptr) {
12228  out << "@" << ids->get_ref(node);
12229  }
12230  out << "(";
12231  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12232  out << " # " << *loc;
12233  }
12234  out << std::endl;
12235  indent++;
12236  write_indent();
12237  out << "name: ";
12238  if (node.name.empty()) {
12239  out << "!MISSING" << std::endl;
12240  } else {
12241  out << "<" << std::endl;
12242  indent++;
12243  node.name.visit(*this);
12244  indent--;
12245  write_indent();
12246  out << ">" << std::endl;
12247  }
12248  write_indent();
12249  out << "condition: ";
12250  if (node.condition.empty()) {
12251  out << "-" << std::endl;
12252  } else {
12253  out << "<" << std::endl;
12254  indent++;
12255  node.condition.visit(*this);
12256  indent--;
12257  write_indent();
12258  out << ">" << std::endl;
12259  }
12260  write_indent();
12261  out << "operands: ";
12262  if (node.operands.empty()) {
12263  out << "!MISSING" << std::endl;
12264  } else {
12265  out << "<" << std::endl;
12266  indent++;
12267  node.operands.visit(*this);
12268  indent--;
12269  write_indent();
12270  out << ">" << std::endl;
12271  }
12272  write_indent();
12273  out << "annotations: ";
12274  if (node.annotations.empty()) {
12275  out << "[]" << std::endl;
12276  } else {
12277  out << "[" << std::endl;
12278  indent++;
12279  for (auto &sptr : node.annotations) {
12280  if (!sptr.empty()) {
12281  sptr->visit(*this);
12282  } else {
12283  write_indent();
12284  out << "!NULL" << std::endl;
12285  }
12286  }
12287  indent--;
12288  write_indent();
12289  out << "]" << std::endl;
12290  }
12291  indent--;
12292  write_indent();
12293  out << ")" << std::endl;
12294 }
12295 
12300  write_indent();
12301  out << "IntDivide";
12302  if (ids != nullptr) {
12303  out << "@" << ids->get_ref(node);
12304  }
12305  out << "(";
12306  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12307  out << " # " << *loc;
12308  }
12309  out << std::endl;
12310  indent++;
12311  write_indent();
12312  out << "lhs: ";
12313  if (node.lhs.empty()) {
12314  out << "!MISSING" << std::endl;
12315  } else {
12316  out << "<" << std::endl;
12317  indent++;
12318  node.lhs.visit(*this);
12319  indent--;
12320  write_indent();
12321  out << ">" << std::endl;
12322  }
12323  write_indent();
12324  out << "rhs: ";
12325  if (node.rhs.empty()) {
12326  out << "!MISSING" << std::endl;
12327  } else {
12328  out << "<" << std::endl;
12329  indent++;
12330  node.rhs.visit(*this);
12331  indent--;
12332  write_indent();
12333  out << ">" << std::endl;
12334  }
12335  indent--;
12336  write_indent();
12337  out << ")" << std::endl;
12338 }
12339 
12344  write_indent();
12345  out << "IntegerLiteral";
12346  if (ids != nullptr) {
12347  out << "@" << ids->get_ref(node);
12348  }
12349  out << "(";
12350  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12351  out << " # " << *loc;
12352  }
12353  out << std::endl;
12354  indent++;
12355  write_indent();
12356  out << "value: ";
12357  std::stringstream ss;
12358  size_t pos;
12359  ss << node.value;
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));
12363  }
12364  if (ss.str().find('\n') == std::string::npos) {
12365  out << ss.str() << std::endl;
12366  } else {
12367  out << "cqasm::v1::primitives::Int<<" << std::endl;
12368  indent++;
12369  std::string s;
12370  while (!ss.eof()) {
12371  std::getline(ss, s);
12372  write_indent();
12373  out << s << std::endl;
12374  }
12375  indent--;
12376  write_indent();
12377  out << ">>" << std::endl;
12378  }
12379  indent--;
12380  write_indent();
12381  out << ")" << std::endl;
12382 }
12383 
12388  write_indent();
12389  out << "JsonLiteral";
12390  if (ids != nullptr) {
12391  out << "@" << ids->get_ref(node);
12392  }
12393  out << "(";
12394  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12395  out << " # " << *loc;
12396  }
12397  out << std::endl;
12398  indent++;
12399  write_indent();
12400  out << "value: ";
12401  std::stringstream ss;
12402  size_t pos;
12403  ss << node.value;
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));
12407  }
12408  if (ss.str().find('\n') == std::string::npos) {
12409  out << ss.str() << std::endl;
12410  } else {
12411  out << "cqasm::v1::primitives::Str<<" << std::endl;
12412  indent++;
12413  std::string s;
12414  while (!ss.eof()) {
12415  std::getline(ss, s);
12416  write_indent();
12417  out << s << std::endl;
12418  }
12419  indent--;
12420  write_indent();
12421  out << ">>" << std::endl;
12422  }
12423  indent--;
12424  write_indent();
12425  out << ")" << std::endl;
12426 }
12427 
12432  write_indent();
12433  out << "LogicalAnd";
12434  if (ids != nullptr) {
12435  out << "@" << ids->get_ref(node);
12436  }
12437  out << "(";
12438  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12439  out << " # " << *loc;
12440  }
12441  out << std::endl;
12442  indent++;
12443  write_indent();
12444  out << "lhs: ";
12445  if (node.lhs.empty()) {
12446  out << "!MISSING" << std::endl;
12447  } else {
12448  out << "<" << std::endl;
12449  indent++;
12450  node.lhs.visit(*this);
12451  indent--;
12452  write_indent();
12453  out << ">" << std::endl;
12454  }
12455  write_indent();
12456  out << "rhs: ";
12457  if (node.rhs.empty()) {
12458  out << "!MISSING" << std::endl;
12459  } else {
12460  out << "<" << std::endl;
12461  indent++;
12462  node.rhs.visit(*this);
12463  indent--;
12464  write_indent();
12465  out << ">" << std::endl;
12466  }
12467  indent--;
12468  write_indent();
12469  out << ")" << std::endl;
12470 }
12471 
12476  write_indent();
12477  out << "LogicalNot";
12478  if (ids != nullptr) {
12479  out << "@" << ids->get_ref(node);
12480  }
12481  out << "(";
12482  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12483  out << " # " << *loc;
12484  }
12485  out << std::endl;
12486  indent++;
12487  write_indent();
12488  out << "expr: ";
12489  if (node.expr.empty()) {
12490  out << "!MISSING" << std::endl;
12491  } else {
12492  out << "<" << std::endl;
12493  indent++;
12494  node.expr.visit(*this);
12495  indent--;
12496  write_indent();
12497  out << ">" << std::endl;
12498  }
12499  indent--;
12500  write_indent();
12501  out << ")" << std::endl;
12502 }
12503 
12508  write_indent();
12509  out << "LogicalOp";
12510  if (ids != nullptr) {
12511  out << "@" << ids->get_ref(node);
12512  }
12513  out << "(";
12514  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12515  out << " # " << *loc;
12516  }
12517  out << std::endl;
12518  indent++;
12519  write_indent();
12520  out << "lhs: ";
12521  if (node.lhs.empty()) {
12522  out << "!MISSING" << std::endl;
12523  } else {
12524  out << "<" << std::endl;
12525  indent++;
12526  node.lhs.visit(*this);
12527  indent--;
12528  write_indent();
12529  out << ">" << std::endl;
12530  }
12531  write_indent();
12532  out << "rhs: ";
12533  if (node.rhs.empty()) {
12534  out << "!MISSING" << std::endl;
12535  } else {
12536  out << "<" << std::endl;
12537  indent++;
12538  node.rhs.visit(*this);
12539  indent--;
12540  write_indent();
12541  out << ">" << std::endl;
12542  }
12543  indent--;
12544  write_indent();
12545  out << ")" << std::endl;
12546 }
12547 
12552  write_indent();
12553  out << "LogicalOr";
12554  if (ids != nullptr) {
12555  out << "@" << ids->get_ref(node);
12556  }
12557  out << "(";
12558  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12559  out << " # " << *loc;
12560  }
12561  out << std::endl;
12562  indent++;
12563  write_indent();
12564  out << "lhs: ";
12565  if (node.lhs.empty()) {
12566  out << "!MISSING" << std::endl;
12567  } else {
12568  out << "<" << std::endl;
12569  indent++;
12570  node.lhs.visit(*this);
12571  indent--;
12572  write_indent();
12573  out << ">" << std::endl;
12574  }
12575  write_indent();
12576  out << "rhs: ";
12577  if (node.rhs.empty()) {
12578  out << "!MISSING" << std::endl;
12579  } else {
12580  out << "<" << std::endl;
12581  indent++;
12582  node.rhs.visit(*this);
12583  indent--;
12584  write_indent();
12585  out << ">" << std::endl;
12586  }
12587  indent--;
12588  write_indent();
12589  out << ")" << std::endl;
12590 }
12591 
12596  write_indent();
12597  out << "LogicalXor";
12598  if (ids != nullptr) {
12599  out << "@" << ids->get_ref(node);
12600  }
12601  out << "(";
12602  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12603  out << " # " << *loc;
12604  }
12605  out << std::endl;
12606  indent++;
12607  write_indent();
12608  out << "lhs: ";
12609  if (node.lhs.empty()) {
12610  out << "!MISSING" << std::endl;
12611  } else {
12612  out << "<" << std::endl;
12613  indent++;
12614  node.lhs.visit(*this);
12615  indent--;
12616  write_indent();
12617  out << ">" << std::endl;
12618  }
12619  write_indent();
12620  out << "rhs: ";
12621  if (node.rhs.empty()) {
12622  out << "!MISSING" << std::endl;
12623  } else {
12624  out << "<" << std::endl;
12625  indent++;
12626  node.rhs.visit(*this);
12627  indent--;
12628  write_indent();
12629  out << ">" << std::endl;
12630  }
12631  indent--;
12632  write_indent();
12633  out << ")" << std::endl;
12634 }
12635 
12640  write_indent();
12641  out << "Mapping";
12642  if (ids != nullptr) {
12643  out << "@" << ids->get_ref(node);
12644  }
12645  out << "(";
12646  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12647  out << " # " << *loc;
12648  }
12649  out << std::endl;
12650  indent++;
12651  write_indent();
12652  out << "alias: ";
12653  if (node.alias.empty()) {
12654  out << "!MISSING" << std::endl;
12655  } else {
12656  out << "<" << std::endl;
12657  indent++;
12658  node.alias.visit(*this);
12659  indent--;
12660  write_indent();
12661  out << ">" << std::endl;
12662  }
12663  write_indent();
12664  out << "expr: ";
12665  if (node.expr.empty()) {
12666  out << "!MISSING" << std::endl;
12667  } else {
12668  out << "<" << std::endl;
12669  indent++;
12670  node.expr.visit(*this);
12671  indent--;
12672  write_indent();
12673  out << ">" << std::endl;
12674  }
12675  write_indent();
12676  out << "annotations: ";
12677  if (node.annotations.empty()) {
12678  out << "[]" << std::endl;
12679  } else {
12680  out << "[" << std::endl;
12681  indent++;
12682  for (auto &sptr : node.annotations) {
12683  if (!sptr.empty()) {
12684  sptr->visit(*this);
12685  } else {
12686  write_indent();
12687  out << "!NULL" << std::endl;
12688  }
12689  }
12690  indent--;
12691  write_indent();
12692  out << "]" << std::endl;
12693  }
12694  indent--;
12695  write_indent();
12696  out << ")" << std::endl;
12697 }
12698 
12703  write_indent();
12704  out << "MatrixLiteral";
12705  if (ids != nullptr) {
12706  out << "@" << ids->get_ref(node);
12707  }
12708  out << "(";
12709  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12710  out << " # " << *loc;
12711  }
12712  out << std::endl;
12713  indent++;
12714  write_indent();
12715  out << "rows: ";
12716  if (node.rows.empty()) {
12717  out << "!MISSING" << std::endl;
12718  } else {
12719  out << "[" << std::endl;
12720  indent++;
12721  for (auto &sptr : node.rows) {
12722  if (!sptr.empty()) {
12723  sptr->visit(*this);
12724  } else {
12725  write_indent();
12726  out << "!NULL" << std::endl;
12727  }
12728  }
12729  indent--;
12730  write_indent();
12731  out << "]" << std::endl;
12732  }
12733  indent--;
12734  write_indent();
12735  out << ")" << std::endl;
12736 }
12737 
12742  write_indent();
12743  out << "Modulo";
12744  if (ids != nullptr) {
12745  out << "@" << ids->get_ref(node);
12746  }
12747  out << "(";
12748  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12749  out << " # " << *loc;
12750  }
12751  out << std::endl;
12752  indent++;
12753  write_indent();
12754  out << "lhs: ";
12755  if (node.lhs.empty()) {
12756  out << "!MISSING" << std::endl;
12757  } else {
12758  out << "<" << std::endl;
12759  indent++;
12760  node.lhs.visit(*this);
12761  indent--;
12762  write_indent();
12763  out << ">" << std::endl;
12764  }
12765  write_indent();
12766  out << "rhs: ";
12767  if (node.rhs.empty()) {
12768  out << "!MISSING" << std::endl;
12769  } else {
12770  out << "<" << std::endl;
12771  indent++;
12772  node.rhs.visit(*this);
12773  indent--;
12774  write_indent();
12775  out << ">" << std::endl;
12776  }
12777  indent--;
12778  write_indent();
12779  out << ")" << std::endl;
12780 }
12781 
12786  write_indent();
12787  out << "Multiply";
12788  if (ids != nullptr) {
12789  out << "@" << ids->get_ref(node);
12790  }
12791  out << "(";
12792  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12793  out << " # " << *loc;
12794  }
12795  out << std::endl;
12796  indent++;
12797  write_indent();
12798  out << "lhs: ";
12799  if (node.lhs.empty()) {
12800  out << "!MISSING" << std::endl;
12801  } else {
12802  out << "<" << std::endl;
12803  indent++;
12804  node.lhs.visit(*this);
12805  indent--;
12806  write_indent();
12807  out << ">" << std::endl;
12808  }
12809  write_indent();
12810  out << "rhs: ";
12811  if (node.rhs.empty()) {
12812  out << "!MISSING" << std::endl;
12813  } else {
12814  out << "<" << std::endl;
12815  indent++;
12816  node.rhs.visit(*this);
12817  indent--;
12818  write_indent();
12819  out << ">" << std::endl;
12820  }
12821  indent--;
12822  write_indent();
12823  out << ")" << std::endl;
12824 }
12825 
12830  write_indent();
12831  out << "Negate";
12832  if (ids != nullptr) {
12833  out << "@" << ids->get_ref(node);
12834  }
12835  out << "(";
12836  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12837  out << " # " << *loc;
12838  }
12839  out << std::endl;
12840  indent++;
12841  write_indent();
12842  out << "expr: ";
12843  if (node.expr.empty()) {
12844  out << "!MISSING" << std::endl;
12845  } else {
12846  out << "<" << std::endl;
12847  indent++;
12848  node.expr.visit(*this);
12849  indent--;
12850  write_indent();
12851  out << ">" << std::endl;
12852  }
12853  indent--;
12854  write_indent();
12855  out << ")" << std::endl;
12856 }
12857 
12862  write_indent();
12863  out << "Power";
12864  if (ids != nullptr) {
12865  out << "@" << ids->get_ref(node);
12866  }
12867  out << "(";
12868  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12869  out << " # " << *loc;
12870  }
12871  out << std::endl;
12872  indent++;
12873  write_indent();
12874  out << "lhs: ";
12875  if (node.lhs.empty()) {
12876  out << "!MISSING" << std::endl;
12877  } else {
12878  out << "<" << std::endl;
12879  indent++;
12880  node.lhs.visit(*this);
12881  indent--;
12882  write_indent();
12883  out << ">" << std::endl;
12884  }
12885  write_indent();
12886  out << "rhs: ";
12887  if (node.rhs.empty()) {
12888  out << "!MISSING" << std::endl;
12889  } else {
12890  out << "<" << std::endl;
12891  indent++;
12892  node.rhs.visit(*this);
12893  indent--;
12894  write_indent();
12895  out << ">" << std::endl;
12896  }
12897  indent--;
12898  write_indent();
12899  out << ")" << std::endl;
12900 }
12901 
12906  write_indent();
12907  out << "Program";
12908  if (ids != nullptr) {
12909  out << "@" << ids->get_ref(node);
12910  }
12911  out << "(";
12912  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12913  out << " # " << *loc;
12914  }
12915  out << std::endl;
12916  indent++;
12917  write_indent();
12918  out << "version: ";
12919  if (node.version.empty()) {
12920  out << "!MISSING" << std::endl;
12921  } else {
12922  out << "<" << std::endl;
12923  indent++;
12924  node.version.visit(*this);
12925  indent--;
12926  write_indent();
12927  out << ">" << std::endl;
12928  }
12929  write_indent();
12930  out << "num_qubits: ";
12931  if (node.num_qubits.empty()) {
12932  out << "-" << std::endl;
12933  } else {
12934  out << "<" << std::endl;
12935  indent++;
12936  node.num_qubits.visit(*this);
12937  indent--;
12938  write_indent();
12939  out << ">" << std::endl;
12940  }
12941  write_indent();
12942  out << "statements: ";
12943  if (node.statements.empty()) {
12944  out << "!MISSING" << std::endl;
12945  } else {
12946  out << "<" << std::endl;
12947  indent++;
12948  node.statements.visit(*this);
12949  indent--;
12950  write_indent();
12951  out << ">" << std::endl;
12952  }
12953  indent--;
12954  write_indent();
12955  out << ")" << std::endl;
12956 }
12957 
12962  write_indent();
12963  out << "RepeatUntilLoop";
12964  if (ids != nullptr) {
12965  out << "@" << ids->get_ref(node);
12966  }
12967  out << "(";
12968  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
12969  out << " # " << *loc;
12970  }
12971  out << std::endl;
12972  indent++;
12973  write_indent();
12974  out << "body: ";
12975  if (node.body.empty()) {
12976  out << "!MISSING" << std::endl;
12977  } else {
12978  out << "<" << std::endl;
12979  indent++;
12980  node.body.visit(*this);
12981  indent--;
12982  write_indent();
12983  out << ">" << std::endl;
12984  }
12985  write_indent();
12986  out << "condition: ";
12987  if (node.condition.empty()) {
12988  out << "!MISSING" << std::endl;
12989  } else {
12990  out << "<" << std::endl;
12991  indent++;
12992  node.condition.visit(*this);
12993  indent--;
12994  write_indent();
12995  out << ">" << std::endl;
12996  }
12997  write_indent();
12998  out << "annotations: ";
12999  if (node.annotations.empty()) {
13000  out << "[]" << std::endl;
13001  } else {
13002  out << "[" << std::endl;
13003  indent++;
13004  for (auto &sptr : node.annotations) {
13005  if (!sptr.empty()) {
13006  sptr->visit(*this);
13007  } else {
13008  write_indent();
13009  out << "!NULL" << std::endl;
13010  }
13011  }
13012  indent--;
13013  write_indent();
13014  out << "]" << std::endl;
13015  }
13016  indent--;
13017  write_indent();
13018  out << ")" << std::endl;
13019 }
13020 
13025  write_indent();
13026  out << "Root";
13027  if (ids != nullptr) {
13028  out << "@" << ids->get_ref(node);
13029  }
13030  out << "(";
13031  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13032  out << " # " << *loc;
13033  }
13034  out << std::endl;
13035  out << ")" << std::endl;
13036 }
13037 
13042  write_indent();
13043  out << "ShiftLeft";
13044  if (ids != nullptr) {
13045  out << "@" << ids->get_ref(node);
13046  }
13047  out << "(";
13048  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13049  out << " # " << *loc;
13050  }
13051  out << std::endl;
13052  indent++;
13053  write_indent();
13054  out << "lhs: ";
13055  if (node.lhs.empty()) {
13056  out << "!MISSING" << std::endl;
13057  } else {
13058  out << "<" << std::endl;
13059  indent++;
13060  node.lhs.visit(*this);
13061  indent--;
13062  write_indent();
13063  out << ">" << std::endl;
13064  }
13065  write_indent();
13066  out << "rhs: ";
13067  if (node.rhs.empty()) {
13068  out << "!MISSING" << std::endl;
13069  } else {
13070  out << "<" << std::endl;
13071  indent++;
13072  node.rhs.visit(*this);
13073  indent--;
13074  write_indent();
13075  out << ">" << std::endl;
13076  }
13077  indent--;
13078  write_indent();
13079  out << ")" << std::endl;
13080 }
13081 
13086  write_indent();
13087  out << "ShiftOp";
13088  if (ids != nullptr) {
13089  out << "@" << ids->get_ref(node);
13090  }
13091  out << "(";
13092  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13093  out << " # " << *loc;
13094  }
13095  out << std::endl;
13096  indent++;
13097  write_indent();
13098  out << "lhs: ";
13099  if (node.lhs.empty()) {
13100  out << "!MISSING" << std::endl;
13101  } else {
13102  out << "<" << std::endl;
13103  indent++;
13104  node.lhs.visit(*this);
13105  indent--;
13106  write_indent();
13107  out << ">" << std::endl;
13108  }
13109  write_indent();
13110  out << "rhs: ";
13111  if (node.rhs.empty()) {
13112  out << "!MISSING" << std::endl;
13113  } else {
13114  out << "<" << std::endl;
13115  indent++;
13116  node.rhs.visit(*this);
13117  indent--;
13118  write_indent();
13119  out << ">" << std::endl;
13120  }
13121  indent--;
13122  write_indent();
13123  out << ")" << std::endl;
13124 }
13125 
13130  write_indent();
13131  out << "ShiftRightArith";
13132  if (ids != nullptr) {
13133  out << "@" << ids->get_ref(node);
13134  }
13135  out << "(";
13136  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13137  out << " # " << *loc;
13138  }
13139  out << std::endl;
13140  indent++;
13141  write_indent();
13142  out << "lhs: ";
13143  if (node.lhs.empty()) {
13144  out << "!MISSING" << std::endl;
13145  } else {
13146  out << "<" << std::endl;
13147  indent++;
13148  node.lhs.visit(*this);
13149  indent--;
13150  write_indent();
13151  out << ">" << std::endl;
13152  }
13153  write_indent();
13154  out << "rhs: ";
13155  if (node.rhs.empty()) {
13156  out << "!MISSING" << std::endl;
13157  } else {
13158  out << "<" << std::endl;
13159  indent++;
13160  node.rhs.visit(*this);
13161  indent--;
13162  write_indent();
13163  out << ">" << std::endl;
13164  }
13165  indent--;
13166  write_indent();
13167  out << ")" << std::endl;
13168 }
13169 
13174  write_indent();
13175  out << "ShiftRightLogic";
13176  if (ids != nullptr) {
13177  out << "@" << ids->get_ref(node);
13178  }
13179  out << "(";
13180  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13181  out << " # " << *loc;
13182  }
13183  out << std::endl;
13184  indent++;
13185  write_indent();
13186  out << "lhs: ";
13187  if (node.lhs.empty()) {
13188  out << "!MISSING" << std::endl;
13189  } else {
13190  out << "<" << std::endl;
13191  indent++;
13192  node.lhs.visit(*this);
13193  indent--;
13194  write_indent();
13195  out << ">" << std::endl;
13196  }
13197  write_indent();
13198  out << "rhs: ";
13199  if (node.rhs.empty()) {
13200  out << "!MISSING" << std::endl;
13201  } else {
13202  out << "<" << std::endl;
13203  indent++;
13204  node.rhs.visit(*this);
13205  indent--;
13206  write_indent();
13207  out << ">" << std::endl;
13208  }
13209  indent--;
13210  write_indent();
13211  out << ")" << std::endl;
13212 }
13213 
13218  write_indent();
13219  out << "Statement";
13220  if (ids != nullptr) {
13221  out << "@" << ids->get_ref(node);
13222  }
13223  out << "(";
13224  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13225  out << " # " << *loc;
13226  }
13227  out << std::endl;
13228  indent++;
13229  write_indent();
13230  out << "annotations: ";
13231  if (node.annotations.empty()) {
13232  out << "[]" << std::endl;
13233  } else {
13234  out << "[" << std::endl;
13235  indent++;
13236  for (auto &sptr : node.annotations) {
13237  if (!sptr.empty()) {
13238  sptr->visit(*this);
13239  } else {
13240  write_indent();
13241  out << "!NULL" << std::endl;
13242  }
13243  }
13244  indent--;
13245  write_indent();
13246  out << "]" << std::endl;
13247  }
13248  indent--;
13249  write_indent();
13250  out << ")" << std::endl;
13251 }
13252 
13257  write_indent();
13258  out << "StatementList";
13259  if (ids != nullptr) {
13260  out << "@" << ids->get_ref(node);
13261  }
13262  out << "(";
13263  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13264  out << " # " << *loc;
13265  }
13266  out << std::endl;
13267  indent++;
13268  write_indent();
13269  out << "items: ";
13270  if (node.items.empty()) {
13271  out << "[]" << std::endl;
13272  } else {
13273  out << "[" << std::endl;
13274  indent++;
13275  for (auto &sptr : node.items) {
13276  if (!sptr.empty()) {
13277  sptr->visit(*this);
13278  } else {
13279  write_indent();
13280  out << "!NULL" << std::endl;
13281  }
13282  }
13283  indent--;
13284  write_indent();
13285  out << "]" << std::endl;
13286  }
13287  indent--;
13288  write_indent();
13289  out << ")" << std::endl;
13290 }
13291 
13296  write_indent();
13297  out << "StringLiteral";
13298  if (ids != nullptr) {
13299  out << "@" << ids->get_ref(node);
13300  }
13301  out << "(";
13302  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13303  out << " # " << *loc;
13304  }
13305  out << std::endl;
13306  indent++;
13307  write_indent();
13308  out << "value: ";
13309  std::stringstream ss;
13310  size_t pos;
13311  ss << node.value;
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));
13315  }
13316  if (ss.str().find('\n') == std::string::npos) {
13317  out << ss.str() << std::endl;
13318  } else {
13319  out << "cqasm::v1::primitives::Str<<" << std::endl;
13320  indent++;
13321  std::string s;
13322  while (!ss.eof()) {
13323  std::getline(ss, s);
13324  write_indent();
13325  out << s << std::endl;
13326  }
13327  indent--;
13328  write_indent();
13329  out << ">>" << std::endl;
13330  }
13331  indent--;
13332  write_indent();
13333  out << ")" << std::endl;
13334 }
13335 
13340  write_indent();
13341  out << "Structured";
13342  if (ids != nullptr) {
13343  out << "@" << ids->get_ref(node);
13344  }
13345  out << "(";
13346  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13347  out << " # " << *loc;
13348  }
13349  out << std::endl;
13350  indent++;
13351  write_indent();
13352  out << "annotations: ";
13353  if (node.annotations.empty()) {
13354  out << "[]" << std::endl;
13355  } else {
13356  out << "[" << std::endl;
13357  indent++;
13358  for (auto &sptr : node.annotations) {
13359  if (!sptr.empty()) {
13360  sptr->visit(*this);
13361  } else {
13362  write_indent();
13363  out << "!NULL" << std::endl;
13364  }
13365  }
13366  indent--;
13367  write_indent();
13368  out << "]" << std::endl;
13369  }
13370  indent--;
13371  write_indent();
13372  out << ")" << std::endl;
13373 }
13374 
13379  write_indent();
13380  out << "Subcircuit";
13381  if (ids != nullptr) {
13382  out << "@" << ids->get_ref(node);
13383  }
13384  out << "(";
13385  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13386  out << " # " << *loc;
13387  }
13388  out << std::endl;
13389  indent++;
13390  write_indent();
13391  out << "name: ";
13392  if (node.name.empty()) {
13393  out << "!MISSING" << std::endl;
13394  } else {
13395  out << "<" << std::endl;
13396  indent++;
13397  node.name.visit(*this);
13398  indent--;
13399  write_indent();
13400  out << ">" << std::endl;
13401  }
13402  write_indent();
13403  out << "iterations: ";
13404  if (node.iterations.empty()) {
13405  out << "-" << std::endl;
13406  } else {
13407  out << "<" << std::endl;
13408  indent++;
13409  node.iterations.visit(*this);
13410  indent--;
13411  write_indent();
13412  out << ">" << std::endl;
13413  }
13414  write_indent();
13415  out << "annotations: ";
13416  if (node.annotations.empty()) {
13417  out << "[]" << std::endl;
13418  } else {
13419  out << "[" << std::endl;
13420  indent++;
13421  for (auto &sptr : node.annotations) {
13422  if (!sptr.empty()) {
13423  sptr->visit(*this);
13424  } else {
13425  write_indent();
13426  out << "!NULL" << std::endl;
13427  }
13428  }
13429  indent--;
13430  write_indent();
13431  out << "]" << std::endl;
13432  }
13433  indent--;
13434  write_indent();
13435  out << ")" << std::endl;
13436 }
13437 
13442  write_indent();
13443  out << "Subtract";
13444  if (ids != nullptr) {
13445  out << "@" << ids->get_ref(node);
13446  }
13447  out << "(";
13448  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13449  out << " # " << *loc;
13450  }
13451  out << std::endl;
13452  indent++;
13453  write_indent();
13454  out << "lhs: ";
13455  if (node.lhs.empty()) {
13456  out << "!MISSING" << std::endl;
13457  } else {
13458  out << "<" << std::endl;
13459  indent++;
13460  node.lhs.visit(*this);
13461  indent--;
13462  write_indent();
13463  out << ">" << std::endl;
13464  }
13465  write_indent();
13466  out << "rhs: ";
13467  if (node.rhs.empty()) {
13468  out << "!MISSING" << std::endl;
13469  } else {
13470  out << "<" << std::endl;
13471  indent++;
13472  node.rhs.visit(*this);
13473  indent--;
13474  write_indent();
13475  out << ">" << std::endl;
13476  }
13477  indent--;
13478  write_indent();
13479  out << ")" << std::endl;
13480 }
13481 
13486  write_indent();
13487  out << "TernaryCond";
13488  if (ids != nullptr) {
13489  out << "@" << ids->get_ref(node);
13490  }
13491  out << "(";
13492  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13493  out << " # " << *loc;
13494  }
13495  out << std::endl;
13496  indent++;
13497  write_indent();
13498  out << "cond: ";
13499  if (node.cond.empty()) {
13500  out << "!MISSING" << std::endl;
13501  } else {
13502  out << "<" << std::endl;
13503  indent++;
13504  node.cond.visit(*this);
13505  indent--;
13506  write_indent();
13507  out << ">" << std::endl;
13508  }
13509  write_indent();
13510  out << "if_true: ";
13511  if (node.if_true.empty()) {
13512  out << "!MISSING" << std::endl;
13513  } else {
13514  out << "<" << std::endl;
13515  indent++;
13516  node.if_true.visit(*this);
13517  indent--;
13518  write_indent();
13519  out << ">" << std::endl;
13520  }
13521  write_indent();
13522  out << "if_false: ";
13523  if (node.if_false.empty()) {
13524  out << "!MISSING" << std::endl;
13525  } else {
13526  out << "<" << std::endl;
13527  indent++;
13528  node.if_false.visit(*this);
13529  indent--;
13530  write_indent();
13531  out << ">" << std::endl;
13532  }
13533  indent--;
13534  write_indent();
13535  out << ")" << std::endl;
13536 }
13537 
13542  write_indent();
13543  out << "UnaryOp";
13544  if (ids != nullptr) {
13545  out << "@" << ids->get_ref(node);
13546  }
13547  out << "(";
13548  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13549  out << " # " << *loc;
13550  }
13551  out << std::endl;
13552  indent++;
13553  write_indent();
13554  out << "expr: ";
13555  if (node.expr.empty()) {
13556  out << "!MISSING" << std::endl;
13557  } else {
13558  out << "<" << std::endl;
13559  indent++;
13560  node.expr.visit(*this);
13561  indent--;
13562  write_indent();
13563  out << ">" << std::endl;
13564  }
13565  indent--;
13566  write_indent();
13567  out << ")" << std::endl;
13568 }
13569 
13574  write_indent();
13575  out << "Variables";
13576  if (ids != nullptr) {
13577  out << "@" << ids->get_ref(node);
13578  }
13579  out << "(";
13580  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13581  out << " # " << *loc;
13582  }
13583  out << std::endl;
13584  indent++;
13585  write_indent();
13586  out << "names: ";
13587  if (node.names.empty()) {
13588  out << "!MISSING" << std::endl;
13589  } else {
13590  out << "[" << std::endl;
13591  indent++;
13592  for (auto &sptr : node.names) {
13593  if (!sptr.empty()) {
13594  sptr->visit(*this);
13595  } else {
13596  write_indent();
13597  out << "!NULL" << std::endl;
13598  }
13599  }
13600  indent--;
13601  write_indent();
13602  out << "]" << std::endl;
13603  }
13604  write_indent();
13605  out << "typ: ";
13606  if (node.typ.empty()) {
13607  out << "!MISSING" << std::endl;
13608  } else {
13609  out << "<" << std::endl;
13610  indent++;
13611  node.typ.visit(*this);
13612  indent--;
13613  write_indent();
13614  out << ">" << std::endl;
13615  }
13616  write_indent();
13617  out << "annotations: ";
13618  if (node.annotations.empty()) {
13619  out << "[]" << std::endl;
13620  } else {
13621  out << "[" << std::endl;
13622  indent++;
13623  for (auto &sptr : node.annotations) {
13624  if (!sptr.empty()) {
13625  sptr->visit(*this);
13626  } else {
13627  write_indent();
13628  out << "!NULL" << std::endl;
13629  }
13630  }
13631  indent--;
13632  write_indent();
13633  out << "]" << std::endl;
13634  }
13635  indent--;
13636  write_indent();
13637  out << ")" << std::endl;
13638 }
13639 
13644  write_indent();
13645  out << "Version";
13646  if (ids != nullptr) {
13647  out << "@" << ids->get_ref(node);
13648  }
13649  out << "(";
13650  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13651  out << " # " << *loc;
13652  }
13653  out << std::endl;
13654  indent++;
13655  write_indent();
13656  out << "items: ";
13657  std::stringstream ss;
13658  size_t pos;
13659  ss << node.items;
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));
13663  }
13664  if (ss.str().find('\n') == std::string::npos) {
13665  out << ss.str() << std::endl;
13666  } else {
13667  out << "cqasm::v1::primitives::Version<<" << std::endl;
13668  indent++;
13669  std::string s;
13670  while (!ss.eof()) {
13671  std::getline(ss, s);
13672  write_indent();
13673  out << s << std::endl;
13674  }
13675  indent--;
13676  write_indent();
13677  out << ">>" << std::endl;
13678  }
13679  indent--;
13680  write_indent();
13681  out << ")" << std::endl;
13682 }
13683 
13688  write_indent();
13689  out << "WhileLoop";
13690  if (ids != nullptr) {
13691  out << "@" << ids->get_ref(node);
13692  }
13693  out << "(";
13694  if (auto loc = node.get_annotation_ptr<cqasm::annotations::SourceLocation>()) {
13695  out << " # " << *loc;
13696  }
13697  out << std::endl;
13698  indent++;
13699  write_indent();
13700  out << "condition: ";
13701  if (node.condition.empty()) {
13702  out << "!MISSING" << std::endl;
13703  } else {
13704  out << "<" << std::endl;
13705  indent++;
13706  node.condition.visit(*this);
13707  indent--;
13708  write_indent();
13709  out << ">" << std::endl;
13710  }
13711  write_indent();
13712  out << "body: ";
13713  if (node.body.empty()) {
13714  out << "!MISSING" << std::endl;
13715  } else {
13716  out << "<" << std::endl;
13717  indent++;
13718  node.body.visit(*this);
13719  indent--;
13720  write_indent();
13721  out << ">" << std::endl;
13722  }
13723  write_indent();
13724  out << "annotations: ";
13725  if (node.annotations.empty()) {
13726  out << "[]" << std::endl;
13727  } else {
13728  out << "[" << std::endl;
13729  indent++;
13730  for (auto &sptr : node.annotations) {
13731  if (!sptr.empty()) {
13732  sptr->visit(*this);
13733  } else {
13734  write_indent();
13735  out << "!NULL" << std::endl;
13736  }
13737  }
13738  indent--;
13739  write_indent();
13740  out << "]" << std::endl;
13741  }
13742  indent--;
13743  write_indent();
13744  out << ")" << std::endl;
13745 }
13746 
13750 template <>
13751 void Node::visit(Visitor<void> &visitor) {
13752  this->visit_internal(visitor);
13753 }
13754 
13758 std::ostream &operator<<(std::ostream &os, const Node &object) {
13759  const_cast<Node&>(object).dump(os);
13760  return os;
13761 }
13762 
13763 } // namespace ast
13764 } // namespace v1
13765 } // namespace cqasm
13766 
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.
Bitwise AND operator.
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.
Subtraction 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.
A C-style for loop.
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.
Less-than operator.
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&#39;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.
Logical AND operator.
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.
Any kind of instruction.
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.
Bitwise XOR operator.
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.
Addition operator.
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.
Any unary 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.
Any kind of statement.
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.
Inequality operator.
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.
Logical XOR operator.
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&#39;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.
Any binary operator.
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.
Equality operator.
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.
True division operator.
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.
A complete program.
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.
Exponentiation operator.
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.
Indexation operator.
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.
Arithmetic operators.
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.
Comparison operators.
One< Node > copy() const override
Returns a shallow copy of this node.
Multiplication operator.
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.
Any kind of expression.
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&#39;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.
Greater-than 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.