187 template <
typename T =
void>
243 virtual bool equals(
const Node& rhs)
const = 0;
248 virtual bool operator==(
const Node& rhs)
const = 0;
254 return !(*
this == rhs);
262 virtual void visit_internal(
VisitorBase &visitor,
void *retval=
nullptr) = 0;
269 template <
typename T>
275 void dump(std::ostream &out=std::cout,
int indent=0);
281 void dump_seq(std::ostream &out=std::cout,
int indent=0);
293 virtual const Annotated *as_annotated()
const;
311 virtual Block *as_block();
317 virtual const Block *as_block()
const;
335 virtual Bundle *as_bundle();
341 virtual const Bundle *as_bundle()
const;
353 virtual const BundleExt *as_bundle_ext()
const;
377 virtual const ErrorModel *as_error_model()
const;
383 virtual ForLoop *as_for_loop();
389 virtual const ForLoop *as_for_loop()
const;
401 virtual const ForeachLoop *as_foreach_loop()
const;
419 virtual IfElse *as_if_else();
425 virtual const IfElse *as_if_else()
const;
473 virtual const Mapping *as_mapping()
const;
485 virtual const Program *as_program()
const;
521 virtual const Statement *as_statement()
const;
533 virtual const Structured *as_structured()
const;
545 virtual const Subcircuit *as_subcircuit()
const;
557 virtual const Variable *as_variable()
const;
569 virtual const Version *as_version()
const;
575 virtual WhileLoop *as_while_loop();
581 virtual const WhileLoop *as_while_loop()
const;
587 ::tree::cbor::MapWriter &map,
588 const ::tree::base::PointerMap &ids
595 const ::tree::cbor::MapReader &map,
596 ::tree::base::IdentifierMap &ids
627 const Annotated *as_annotated()
const override;
632 static std::shared_ptr<Annotated>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
668 void find_reachable(::tree::base::PointerMap &map)
const override;
673 void check_complete(const ::tree::base::PointerMap &map)
const override;
685 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
714 bool equals(
const Node &rhs)
const override;
719 bool operator==(
const Node &rhs)
const override;
725 ::tree::cbor::MapWriter &map,
726 const ::tree::base::PointerMap &ids
732 static std::shared_ptr<AnnotationData>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
755 void find_reachable(::tree::base::PointerMap &map)
const override;
760 void check_complete(const ::tree::base::PointerMap &map)
const override;
772 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
780 Block *as_block()
override;
786 const Block *as_block()
const override;
801 bool equals(
const Node &rhs)
const override;
806 bool operator==(
const Node &rhs)
const override;
812 ::tree::cbor::MapWriter &map,
813 const ::tree::base::PointerMap &ids
819 static std::shared_ptr<Block>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
844 const Statement *as_statement()
const override;
849 static std::shared_ptr<Statement>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
874 const Structured *as_structured()
const override;
879 static std::shared_ptr<Structured>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
897 void find_reachable(::tree::base::PointerMap &map)
const override;
902 void check_complete(const ::tree::base::PointerMap &map)
const override;
914 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
943 bool equals(
const Node &rhs)
const override;
948 bool operator==(
const Node &rhs)
const override;
954 ::tree::cbor::MapWriter &map,
955 const ::tree::base::PointerMap &ids
961 static std::shared_ptr<BreakStatement>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
985 void find_reachable(::tree::base::PointerMap &map)
const override;
990 void check_complete(const ::tree::base::PointerMap &map)
const override;
1002 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1010 Bundle *as_bundle()
override;
1016 const Bundle *as_bundle()
const override;
1031 bool equals(
const Node &rhs)
const override;
1036 bool operator==(
const Node &rhs)
const override;
1042 ::tree::cbor::MapWriter &map,
1043 const ::tree::base::PointerMap &ids
1049 static std::shared_ptr<Bundle>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1073 void find_reachable(::tree::base::PointerMap &map)
const override;
1078 void check_complete(const ::tree::base::PointerMap &map)
const override;
1090 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1104 const BundleExt *as_bundle_ext()
const override;
1119 bool equals(
const Node &rhs)
const override;
1124 bool operator==(
const Node &rhs)
const override;
1130 ::tree::cbor::MapWriter &map,
1131 const ::tree::base::PointerMap &ids
1137 static std::shared_ptr<BundleExt>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1155 void find_reachable(::tree::base::PointerMap &map)
const override;
1160 void check_complete(const ::tree::base::PointerMap &map)
const override;
1172 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1201 bool equals(
const Node &rhs)
const override;
1206 bool operator==(
const Node &rhs)
const override;
1212 ::tree::cbor::MapWriter &map,
1213 const ::tree::base::PointerMap &ids
1219 static std::shared_ptr<ContinueStatement>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1252 void find_reachable(::tree::base::PointerMap &map)
const override;
1257 void check_complete(const ::tree::base::PointerMap &map)
const override;
1269 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1283 const ErrorModel *as_error_model()
const override;
1298 bool equals(
const Node &rhs)
const override;
1303 bool operator==(
const Node &rhs)
const override;
1309 ::tree::cbor::MapWriter &map,
1310 const ::tree::base::PointerMap &ids
1316 static std::shared_ptr<ErrorModel>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1355 void find_reachable(::tree::base::PointerMap &map)
const override;
1360 void check_complete(const ::tree::base::PointerMap &map)
const override;
1372 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1380 ForLoop *as_for_loop()
override;
1386 const ForLoop *as_for_loop()
const override;
1401 bool equals(
const Node &rhs)
const override;
1406 bool operator==(
const Node &rhs)
const override;
1412 ::tree::cbor::MapWriter &map,
1413 const ::tree::base::PointerMap &ids
1419 static std::shared_ptr<ForLoop>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1459 void find_reachable(::tree::base::PointerMap &map)
const override;
1464 void check_complete(const ::tree::base::PointerMap &map)
const override;
1476 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1490 const ForeachLoop *as_foreach_loop()
const override;
1505 bool equals(
const Node &rhs)
const override;
1510 bool operator==(
const Node &rhs)
const override;
1516 ::tree::cbor::MapWriter &map,
1517 const ::tree::base::PointerMap &ids
1523 static std::shared_ptr<ForeachLoop>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1559 static std::shared_ptr<InstructionBase>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1582 void find_reachable(::tree::base::PointerMap &map)
const override;
1587 void check_complete(const ::tree::base::PointerMap &map)
const override;
1599 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1628 bool equals(
const Node &rhs)
const override;
1633 bool operator==(
const Node &rhs)
const override;
1639 ::tree::cbor::MapWriter &map,
1640 const ::tree::base::PointerMap &ids
1646 static std::shared_ptr<GotoInstruction>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1674 void find_reachable(::tree::base::PointerMap &map)
const override;
1679 void check_complete(const ::tree::base::PointerMap &map)
const override;
1691 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1699 IfElse *as_if_else()
override;
1705 const IfElse *as_if_else()
const override;
1720 bool equals(
const Node &rhs)
const override;
1725 bool operator==(
const Node &rhs)
const override;
1731 ::tree::cbor::MapWriter &map,
1732 const ::tree::base::PointerMap &ids
1738 static std::shared_ptr<IfElse>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1766 void find_reachable(::tree::base::PointerMap &map)
const override;
1771 void check_complete(const ::tree::base::PointerMap &map)
const override;
1783 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1797 const IfElseBranch *as_if_else_branch()
const override;
1812 bool equals(
const Node &rhs)
const override;
1817 bool operator==(
const Node &rhs)
const override;
1823 ::tree::cbor::MapWriter &map,
1824 const ::tree::base::PointerMap &ids
1830 static std::shared_ptr<IfElseBranch>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1864 void find_reachable(::tree::base::PointerMap &map)
const override;
1869 void check_complete(const ::tree::base::PointerMap &map)
const override;
1881 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1895 const Instruction *as_instruction()
const override;
1910 bool equals(
const Node &rhs)
const override;
1915 bool operator==(
const Node &rhs)
const override;
1921 ::tree::cbor::MapWriter &map,
1922 const ::tree::base::PointerMap &ids
1928 static std::shared_ptr<Instruction>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1956 void find_reachable(::tree::base::PointerMap &map)
const override;
1961 void check_complete(const ::tree::base::PointerMap &map)
const override;
1973 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
1981 Mapping *as_mapping()
override;
1987 const Mapping *as_mapping()
const override;
2002 bool equals(
const Node &rhs)
const override;
2007 bool operator==(
const Node &rhs)
const override;
2013 ::tree::cbor::MapWriter &map,
2014 const ::tree::base::PointerMap &ids
2020 static std::shared_ptr<Mapping>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2076 void find_reachable(::tree::base::PointerMap &map)
const override;
2081 void check_complete(const ::tree::base::PointerMap &map)
const override;
2093 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
2101 Program *as_program()
override;
2107 const Program *as_program()
const override;
2122 bool equals(
const Node &rhs)
const override;
2127 bool operator==(
const Node &rhs)
const override;
2133 ::tree::cbor::MapWriter &map,
2134 const ::tree::base::PointerMap &ids
2140 static std::shared_ptr<Program>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2168 void find_reachable(::tree::base::PointerMap &map)
const override;
2173 void check_complete(const ::tree::base::PointerMap &map)
const override;
2185 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
2214 bool equals(
const Node &rhs)
const override;
2219 bool operator==(
const Node &rhs)
const override;
2225 ::tree::cbor::MapWriter &map,
2226 const ::tree::base::PointerMap &ids
2232 static std::shared_ptr<RepeatUntilLoop>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2260 void find_reachable(::tree::base::PointerMap &map)
const override;
2265 void check_complete(const ::tree::base::PointerMap &map)
const override;
2277 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
2306 bool equals(
const Node &rhs)
const override;
2311 bool operator==(
const Node &rhs)
const override;
2317 ::tree::cbor::MapWriter &map,
2318 const ::tree::base::PointerMap &ids
2324 static std::shared_ptr<SetInstruction>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2367 void find_reachable(::tree::base::PointerMap &map)
const override;
2372 void check_complete(const ::tree::base::PointerMap &map)
const override;
2384 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
2398 const Subcircuit *as_subcircuit()
const override;
2413 bool equals(
const Node &rhs)
const override;
2418 bool operator==(
const Node &rhs)
const override;
2424 ::tree::cbor::MapWriter &map,
2425 const ::tree::base::PointerMap &ids
2431 static std::shared_ptr<Subcircuit>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2459 void find_reachable(::tree::base::PointerMap &map)
const override;
2464 void check_complete(const ::tree::base::PointerMap &map)
const override;
2476 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
2490 const Variable *as_variable()
const override;
2505 bool equals(
const Node &rhs)
const override;
2510 bool operator==(
const Node &rhs)
const override;
2516 ::tree::cbor::MapWriter &map,
2517 const ::tree::base::PointerMap &ids
2523 static std::shared_ptr<Variable>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2546 void find_reachable(::tree::base::PointerMap &map)
const override;
2551 void check_complete(const ::tree::base::PointerMap &map)
const override;
2563 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
2571 Version *as_version()
override;
2577 const Version *as_version()
const override;
2592 bool equals(
const Node &rhs)
const override;
2597 bool operator==(
const Node &rhs)
const override;
2603 ::tree::cbor::MapWriter &map,
2604 const ::tree::base::PointerMap &ids
2610 static std::shared_ptr<Version>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2638 void find_reachable(::tree::base::PointerMap &map)
const override;
2643 void check_complete(const ::tree::base::PointerMap &map)
const override;
2655 void visit_internal(
VisitorBase &visitor,
void *retval)
override;
2663 WhileLoop *as_while_loop()
override;
2669 const WhileLoop *as_while_loop()
const override;
2684 bool equals(
const Node &rhs)
const override;
2689 bool operator==(
const Node &rhs)
const override;
2695 ::tree::cbor::MapWriter &map,
2696 const ::tree::base::PointerMap &ids
2702 static std::shared_ptr<WhileLoop>
deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2744 friend class WhileLoop;
2749 virtual void raw_visit_node(
Node &node,
void *retval) = 0;
2754 virtual void raw_visit_annotated(
Annotated &node,
void *retval) = 0;
2759 virtual void raw_visit_annotation_data(
AnnotationData &node,
void *retval) = 0;
2764 virtual void raw_visit_block(
Block &node,
void *retval) = 0;
2769 virtual void raw_visit_break_statement(
BreakStatement &node,
void *retval) = 0;
2774 virtual void raw_visit_bundle(
Bundle &node,
void *retval) = 0;
2779 virtual void raw_visit_bundle_ext(
BundleExt &node,
void *retval) = 0;
2784 virtual void raw_visit_continue_statement(
ContinueStatement &node,
void *retval) = 0;
2789 virtual void raw_visit_error_model(
ErrorModel &node,
void *retval) = 0;
2794 virtual void raw_visit_for_loop(
ForLoop &node,
void *retval) = 0;
2799 virtual void raw_visit_foreach_loop(
ForeachLoop &node,
void *retval) = 0;
2804 virtual void raw_visit_goto_instruction(
GotoInstruction &node,
void *retval) = 0;
2809 virtual void raw_visit_if_else(
IfElse &node,
void *retval) = 0;
2814 virtual void raw_visit_if_else_branch(
IfElseBranch &node,
void *retval) = 0;
2819 virtual void raw_visit_instruction(
Instruction &node,
void *retval) = 0;
2824 virtual void raw_visit_instruction_base(
InstructionBase &node,
void *retval) = 0;
2829 virtual void raw_visit_mapping(
Mapping &node,
void *retval) = 0;
2834 virtual void raw_visit_program(
Program &node,
void *retval) = 0;
2839 virtual void raw_visit_repeat_until_loop(
RepeatUntilLoop &node,
void *retval) = 0;
2844 virtual void raw_visit_set_instruction(
SetInstruction &node,
void *retval) = 0;
2849 virtual void raw_visit_statement(
Statement &node,
void *retval) = 0;
2854 virtual void raw_visit_structured(
Structured &node,
void *retval) = 0;
2859 virtual void raw_visit_subcircuit(
Subcircuit &node,
void *retval) = 0;
2864 virtual void raw_visit_variable(
Variable &node,
void *retval) = 0;
2869 virtual void raw_visit_version(
Version &node,
void *retval) = 0;
2874 virtual void raw_visit_while_loop(WhileLoop &node,
void *retval) = 0;
2888 template <
typename T>
2895 void raw_visit_node(
Node &node,
void *retval)
override;
2900 void raw_visit_annotated(
Annotated &node,
void *retval)
override;
2905 void raw_visit_annotation_data(
AnnotationData &node,
void *retval)
override;
2910 void raw_visit_block(
Block &node,
void *retval)
override;
2915 void raw_visit_break_statement(
BreakStatement &node,
void *retval)
override;
2920 void raw_visit_bundle(
Bundle &node,
void *retval)
override;
2925 void raw_visit_bundle_ext(
BundleExt &node,
void *retval)
override;
2930 void raw_visit_continue_statement(
ContinueStatement &node,
void *retval)
override;
2935 void raw_visit_error_model(
ErrorModel &node,
void *retval)
override;
2940 void raw_visit_for_loop(
ForLoop &node,
void *retval)
override;
2945 void raw_visit_foreach_loop(
ForeachLoop &node,
void *retval)
override;
2950 void raw_visit_goto_instruction(
GotoInstruction &node,
void *retval)
override;
2955 void raw_visit_if_else(
IfElse &node,
void *retval)
override;
2960 void raw_visit_if_else_branch(
IfElseBranch &node,
void *retval)
override;
2965 void raw_visit_instruction(
Instruction &node,
void *retval)
override;
2970 void raw_visit_instruction_base(
InstructionBase &node,
void *retval)
override;
2975 void raw_visit_mapping(
Mapping &node,
void *retval)
override;
2980 void raw_visit_program(
Program &node,
void *retval)
override;
2985 void raw_visit_repeat_until_loop(
RepeatUntilLoop &node,
void *retval)
override;
2990 void raw_visit_set_instruction(
SetInstruction &node,
void *retval)
override;
2995 void raw_visit_statement(
Statement &node,
void *retval)
override;
3000 void raw_visit_structured(
Structured &node,
void *retval)
override;
3005 void raw_visit_subcircuit(
Subcircuit &node,
void *retval)
override;
3010 void raw_visit_variable(
Variable &node,
void *retval)
override;
3015 void raw_visit_version(
Version &node,
void *retval)
override;
3020 void raw_visit_while_loop(WhileLoop &node,
void *retval)
override;
3027 virtual T visit_node(
Node &node) = 0;
3033 return visit_node(node);
3040 return visit_node(node);
3047 return visit_node(node);
3054 return visit_structured(node);
3061 return visit_annotated(node);
3068 return visit_statement(node);
3075 return visit_structured(node);
3082 return visit_annotated(node);
3089 return visit_structured(node);
3096 return visit_structured(node);
3103 return visit_instruction_base(node);
3110 return visit_structured(node);
3117 return visit_node(node);
3124 return visit_instruction_base(node);
3131 return visit_annotated(node);
3138 return visit_annotated(node);
3145 return visit_node(node);
3152 return visit_structured(node);
3159 return visit_instruction_base(node);
3166 return visit_annotated(node);
3173 return visit_statement(node);
3180 return visit_annotated(node);
3187 return visit_annotated(node);
3194 return visit_node(node);
3201 return visit_structured(node);
3209 template <
typename T>
3211 if (retval ==
nullptr) {
3212 this->visit_node(node);
3214 *((T*)retval) = this->visit_node(node);
3227 template <
typename T>
3229 if (retval ==
nullptr) {
3230 this->visit_annotated(node);
3232 *((T*)retval) = this->visit_annotated(node);
3245 template <
typename T>
3247 if (retval ==
nullptr) {
3248 this->visit_annotation_data(node);
3250 *((T*)retval) = this->visit_annotation_data(node);
3263 template <
typename T>
3265 if (retval ==
nullptr) {
3266 this->visit_block(node);
3268 *((T*)retval) = this->visit_block(node);
3281 template <
typename T>
3283 if (retval ==
nullptr) {
3284 this->visit_break_statement(node);
3286 *((T*)retval) = this->visit_break_statement(node);
3299 template <
typename T>
3301 if (retval ==
nullptr) {
3302 this->visit_bundle(node);
3304 *((T*)retval) = this->visit_bundle(node);
3317 template <
typename T>
3319 if (retval ==
nullptr) {
3320 this->visit_bundle_ext(node);
3322 *((T*)retval) = this->visit_bundle_ext(node);
3335 template <
typename T>
3337 if (retval ==
nullptr) {
3338 this->visit_continue_statement(node);
3340 *((T*)retval) = this->visit_continue_statement(node);
3353 template <
typename T>
3355 if (retval ==
nullptr) {
3356 this->visit_error_model(node);
3358 *((T*)retval) = this->visit_error_model(node);
3371 template <
typename T>
3373 if (retval ==
nullptr) {
3374 this->visit_for_loop(node);
3376 *((T*)retval) = this->visit_for_loop(node);
3389 template <
typename T>
3391 if (retval ==
nullptr) {
3392 this->visit_foreach_loop(node);
3394 *((T*)retval) = this->visit_foreach_loop(node);
3407 template <
typename T>
3409 if (retval ==
nullptr) {
3410 this->visit_goto_instruction(node);
3412 *((T*)retval) = this->visit_goto_instruction(node);
3425 template <
typename T>
3427 if (retval ==
nullptr) {
3428 this->visit_if_else(node);
3430 *((T*)retval) = this->visit_if_else(node);
3443 template <
typename T>
3445 if (retval ==
nullptr) {
3446 this->visit_if_else_branch(node);
3448 *((T*)retval) = this->visit_if_else_branch(node);
3461 template <
typename T>
3463 if (retval ==
nullptr) {
3464 this->visit_instruction(node);
3466 *((T*)retval) = this->visit_instruction(node);
3479 template <
typename T>
3481 if (retval ==
nullptr) {
3482 this->visit_instruction_base(node);
3484 *((T*)retval) = this->visit_instruction_base(node);
3497 template <
typename T>
3499 if (retval ==
nullptr) {
3500 this->visit_mapping(node);
3502 *((T*)retval) = this->visit_mapping(node);
3515 template <
typename T>
3517 if (retval ==
nullptr) {
3518 this->visit_program(node);
3520 *((T*)retval) = this->visit_program(node);
3533 template <
typename T>
3535 if (retval ==
nullptr) {
3536 this->visit_repeat_until_loop(node);
3538 *((T*)retval) = this->visit_repeat_until_loop(node);
3551 template <
typename T>
3553 if (retval ==
nullptr) {
3554 this->visit_set_instruction(node);
3556 *((T*)retval) = this->visit_set_instruction(node);
3569 template <
typename T>
3571 if (retval ==
nullptr) {
3572 this->visit_statement(node);
3574 *((T*)retval) = this->visit_statement(node);
3587 template <
typename T>
3589 if (retval ==
nullptr) {
3590 this->visit_structured(node);
3592 *((T*)retval) = this->visit_structured(node);
3605 template <
typename T>
3607 if (retval ==
nullptr) {
3608 this->visit_subcircuit(node);
3610 *((T*)retval) = this->visit_subcircuit(node);
3623 template <
typename T>
3625 if (retval ==
nullptr) {
3626 this->visit_variable(node);
3628 *((T*)retval) = this->visit_variable(node);
3641 template <
typename T>
3643 if (retval ==
nullptr) {
3644 this->visit_version(node);
3646 *((T*)retval) = this->visit_version(node);
3659 template <
typename T>
3661 if (retval ==
nullptr) {
3662 this->visit_while_loop(node);
3664 *((T*)retval) = this->visit_while_loop(node);
3687 void visit_annotated(
Annotated &node)
override;
3697 void visit_block(
Block &node)
override;
3707 void visit_bundle(
Bundle &node)
override;
3712 void visit_bundle_ext(
BundleExt &node)
override;
3722 void visit_error_model(
ErrorModel &node)
override;
3727 void visit_for_loop(
ForLoop &node)
override;
3732 void visit_foreach_loop(
ForeachLoop &node)
override;
3742 void visit_if_else(
IfElse &node)
override;
3747 void visit_if_else_branch(
IfElseBranch &node)
override;
3752 void visit_instruction(
Instruction &node)
override;
3762 void visit_mapping(
Mapping &node)
override;
3767 void visit_program(
Program &node)
override;
3782 void visit_statement(
Statement &node)
override;
3787 void visit_structured(
Structured &node)
override;
3792 void visit_subcircuit(
Subcircuit &node)
override;
3797 void visit_variable(
Variable &node)
override;
3802 void visit_version(
Version &node)
override;
3807 void visit_while_loop(WhileLoop &node)
override;
3830 ::tree::base::PointerMap *
ids;
3834 bool in_link =
false;
3839 void write_indent();
3846 Dumper(std::ostream &out,
int indent=0, ::tree::base::PointerMap *ids =
nullptr) : out(out), indent(indent), ids(ids) {};
3851 void visit_node(
Node &node)
override;
3855 void visit_annotated(
Annotated &node)
override;
3865 void visit_block(
Block &node)
override;
3875 void visit_bundle(
Bundle &node)
override;
3880 void visit_bundle_ext(
BundleExt &node)
override;
3890 void visit_error_model(
ErrorModel &node)
override;
3895 void visit_for_loop(
ForLoop &node)
override;
3900 void visit_foreach_loop(
ForeachLoop &node)
override;
3910 void visit_if_else(
IfElse &node)
override;
3915 void visit_if_else_branch(
IfElseBranch &node)
override;
3920 void visit_instruction(
Instruction &node)
override;
3930 void visit_mapping(
Mapping &node)
override;
3935 void visit_program(
Program &node)
override;
3950 void visit_statement(
Statement &node)
override;
3955 void visit_structured(
Structured &node)
override;
3960 void visit_subcircuit(
Subcircuit &node)
override;
3965 void visit_variable(
Variable &node)
override;
3970 void visit_version(
Version &node)
override;
3975 void visit_while_loop(WhileLoop &node)
override;
3982 template <
typename T>
3985 this->visit_internal(visitor, &retval);
The file version identifier.
Visitor class that debug-dumps a tree to a stream.
NodeType
Enumeration of all node types.
cqasm::v1::primitives::Str name
The name of the subcircuit.
void raw_visit_for_loop(ForLoop &node, void *retval) override
Internal visitor function for ForLoop nodes.
void raw_visit_annotation_data(AnnotationData &node, void *retval) override
Internal visitor function for AnnotationData nodes.
virtual T visit_structured(Structured &node)
Fallback function for Structured nodes.
Represents a node that carries annotation data.
::tree::base::Maybe< T > Maybe
void raw_visit_variable(Variable &node, void *retval) override
Internal visitor function for Variable nodes.
void raw_visit_break_statement(BreakStatement &node, void *retval) override
Internal visitor function for BreakStatement nodes.
T visit(Visitor< T > &visitor)
Visit this object.
tree::Maybe< ErrorModel > ErrorModelRef
Optional reference to an error model, used within the semantic tree.
Any< Variable > variables
This list of all user-defined variables at any point in the code.
virtual T visit_instruction_base(InstructionBase &node)
Fallback function for InstructionBase nodes.
::tree::base::Link< T > Link
tree::Maybe< Instruction > InstructionRef
Optional reference to an instruction, used within the semantic tree.
cqasm::v1::primitives::Str name
Name as it appears in the cQASM file.
::tree::base::OptLink< T > OptLink
cqasm::tree::Any< T > Any
This file contains the Instruction class and support types, each instance representing an instruction...
virtual T visit_annotated(Annotated &node)
Fallback function for Annotated nodes.
cqasm::tree::One< T > One
void raw_visit_foreach_loop(ForeachLoop &node, void *retval) override
Internal visitor function for ForeachLoop nodes.
A list of parallel instructions.
One< cqasm::v1::values::Node > lhs
The assignment target.
This file contains the ErrorModel class and support types, each instance representing an error model ...
cqasm::v1::primitives::Str interface
The interface this annotation is intended for.
void raw_visit_set_instruction(SetInstruction &node, void *retval) override
Internal visitor function for SetInstruction nodes.
error_model::ErrorModelRef deserialize(const ::tree::cbor::MapReader &map)
Deserializes the given primitive object from CBOR.
cqasm::v1::instruction::InstructionRef instruction
Instruction type as registered through the API.
cqasm::v1::primitives::Int to
The last value.
One< cqasm::v1::values::Node > condition
Condition (c- notation).
cqasm::v1::primitives::Str name
Name as it appears in the cQASM file.
virtual T visit_bundle(Bundle &node)
Visitor function for Bundle nodes.
Toplevel namespace with entry points for the new API.
Any< cqasm::v1::values::Node > parameters
Error model parameters.
One< Block > body
The loop body.
virtual T visit_version(Version &node)
Visitor function for Version nodes.
Any< cqasm::v1::values::Node > operands
Any operands attached to the annotation.
bool operator!=(const Node &rhs) const
Pointer-based inequality operator.
void raw_visit_block(Block &node, void *retval) override
Internal visitor function for Block nodes.
void raw_visit_node(Node &node, void *retval) override
Internal visitor function for nodes of any type.
Many< InstructionBase > items
The list of parallel instructions.
A mapping (alias) for an expression.
virtual T visit_subcircuit(Subcircuit &node)
Visitor function for Subcircuit nodes.
Any< Subcircuit > subcircuits
The list of subcircuit.
Defines classes representing the values (collective name for constants, references, and dynamically evaluated expressions) available within cQASM's type system, as well as some utility functions.
A single condition + block for use in an if-else chain.
One< Version > version
File version.
Internal class for implementing the visitor pattern.
Base class for the visitor pattern for the tree.
void raw_visit_error_model(ErrorModel &node, void *retval) override
Internal visitor function for ErrorModel nodes.
std::int64_t Int
Integer primitive used within the AST and semantic trees.
One< Block > body
The body.
Visitor base class defaulting to DFS pre-order traversal.
cqasm::v1::error_model::ErrorModelRef model
Error model type as registered through the API.
Main class for all nodes.
A version 1.2+ assignment instruction.
void raw_visit_goto_instruction(GotoInstruction &node, void *retval) override
Internal visitor function for GotoInstruction nodes.
Version number primitive used within the AST and semantic trees.
void serialize(const error_model::ErrorModelRef &obj, ::tree::cbor::MapWriter &map)
cqasm::v1::primitives::Int frm
The first value.
Dumper(std::ostream &out, int indent=0, ::tree::base::PointerMap *ids=nullptr)
Construct a dumping visitor.
A bundle of instructions, to be executed in parallel.
Maybe< Block > otherwise
The final else block, if any.
One< cqasm::v1::values::Node > lhs
Reference to the variable used for looping.
cqasm::v1::primitives::Int iterations
An optional integer expression representing the number of iterations for this subcircuit.
One< cqasm::v1::values::Node > condition
The condition for starting another iteration.
Main class for all nodes.
cqasm::tree::Maybe< T > Maybe
void raw_visit_instruction_base(InstructionBase &node, void *retval) override
Internal visitor function for InstructionBase nodes.
Any version 1.2+ structured control-flow statement.
One< cqasm::v1::values::Node > condition
The condition.
void raw_visit_subcircuit(Subcircuit &node, void *retval) override
Internal visitor function for Subcircuit nodes.
Represents an annotation.
T initialize()
Generates a default value for the given primitive type.
virtual T visit_repeat_until_loop(RepeatUntilLoop &node)
Visitor function for RepeatUntilLoop nodes.
std::ostream & operator<<(std::ostream &os, const Node &object)
Stream << overload for tree nodes (writes debug dump).
Defines primitive types for use in trees generated by tree-gen.
virtual T visit_for_loop(ForLoop &node)
Visitor function for ForLoop nodes.
void raw_visit_instruction(Instruction &node, void *retval) override
Internal visitor function for Instruction nodes.
virtual T visit_set_instruction(SetInstruction &node)
Visitor function for SetInstruction nodes.
Many< IfElseBranch > branches
The if-else branches.
virtual T visit_bundle_ext(BundleExt &node)
Visitor function for BundleExt nodes.
Namespace for the "new" cQASM 1.x API.
void raw_visit_structured(Structured &node, void *retval) override
Internal visitor function for Structured nodes.
One< cqasm::v1::values::Node > rhs
The value to assign.
void raw_visit_repeat_until_loop(RepeatUntilLoop &node, void *retval) override
Internal visitor function for RepeatUntilLoop nodes.
cqasm::v1::primitives::Version items
The list of version components, ordered major to minor.
void raw_visit_while_loop(WhileLoop &node, void *retval) override
Internal visitor function for WhileLoop nodes.
cqasm::tree::Link< T > Link
Wrapper for pulling parts of tree-gen's support library into libqasm.
virtual T visit_break_statement(BreakStatement &node)
Visitor function for BreakStatement nodes.
virtual T visit_block(Block &node)
Visitor function for Block nodes.
cqasm::v1::primitives::Str name
The name of the variable.
The file version identifier.
void raw_visit_statement(Statement &node, void *retval) override
Internal visitor function for Statement nodes.
std::ostream & out
Output stream to dump to.
Maybe< SetInstruction > initialize
The optional initializing assignment, run before the loop starts.
virtual T visit_goto_instruction(GotoInstruction &node)
Visitor function for GotoInstruction nodes.
cqasm::v1::primitives::Str operation
The operation within the interface that this annotation is intended for.
virtual T visit_while_loop(WhileLoop &node)
Visitor function for WhileLoop nodes.
One< cqasm::v1::values::Node > value
The value it maps to.
virtual T visit_instruction(Instruction &node)
Visitor function for Instruction nodes.
void raw_visit_version(Version &node, void *retval) override
Internal visitor function for Version nodes.
One< cqasm::v1::types::Node > typ
The type of the variable.
A single condition + block for use in an if-else chain.
::tree::base::Any< T > Any
std::string Str
String primitive used within the AST and semantic trees.
Many< Instruction > items
The list of parallel instructions.
virtual T visit_annotation_data(AnnotationData &node)
Visitor function for AnnotationData nodes.
void raw_visit_program(Program &node, void *retval) override
Internal visitor function for Program nodes.
cqasm::v1::primitives::Int num_qubits
The required qubit register size.
One< Block > body
The loop body.
Any< Bundle > bundles
The instruction bundles contained by this subcircuit.
::tree::base::Many< T > Many
void raw_visit_if_else(IfElse &node, void *retval) override
Internal visitor function for IfElse nodes.
cqasm::v1::primitives::Version api_version
API version.
void raw_visit_bundle(Bundle &node, void *retval) override
Internal visitor function for Bundle nodes.
Maybe< Block > body
The statements contained by this subcircuit.
virtual T visit_error_model(ErrorModel &node)
Visitor function for ErrorModel nodes.
Maybe< SetInstruction > update
The updating assignment, done at the end of the loop body and upon continue.
void raw_visit_mapping(Mapping &node, void *retval) override
Internal visitor function for Mapping nodes.
void raw_visit_continue_statement(ContinueStatement &node, void *retval) override
Internal visitor function for ContinueStatement nodes.
virtual T visit_foreach_loop(ForeachLoop &node)
Visitor function for ForeachLoop nodes.
virtual T visit_if_else_branch(IfElseBranch &node)
Visitor function for IfElseBranch nodes.
Any< Mapping > mappings
The list of all user-defined mappings after parsing.
Any< AnnotationData > annotations
Zero or more annotations attached to this object.
Any version 1.2+ structured control-flow statement.
virtual T visit_program(Program &node)
Visitor function for Program nodes.
A version 1.2+ goto instruction.
void raw_visit_annotated(Annotated &node, void *retval) override
Internal visitor function for Annotated nodes.
One< cqasm::v1::values::Node > condition
The condition for starting another iteration.
Represents an annotation.
One< Block > body
The loop body.
Any< cqasm::v1::values::Node > operands
Operands for the instruction.
cqasm::tree::Many< T > Many
Link< Subcircuit > target
Link to the target subcircuit, used as a label.
cqasm::v1::primitives::Str name
The name of the mapping.
::tree::base::PointerMap * ids
When non-null, the print node IDs from here instead of link contents.
void raw_visit_bundle_ext(BundleExt &node, void *retval) override
Internal visitor function for BundleExt nodes.
virtual T visit_variable(Variable &node)
Visitor function for Variable nodes.
One< cqasm::v1::values::Node > condition
The condition for stopping iteration.
cqasm::tree::OptLink< T > OptLink
::tree::base::One< T > One
void raw_visit_if_else_branch(IfElseBranch &node, void *retval) override
Internal visitor function for IfElseBranch nodes.
Represents a node that carries annotation data.
Any< Statement > statements
The statements contained by the block.
A bundle of instructions, to be executed in parallel.
Maybe< ErrorModel > error_model
Error model information.
One< Block > body
The loop body.
virtual T visit_if_else(IfElse &node)
Visitor function for IfElse nodes.
virtual T visit_mapping(Mapping &node)
Visitor function for Mapping nodes.
virtual T visit_statement(Statement &node)
Fallback function for Statement nodes.
virtual T visit_continue_statement(ContinueStatement &node)
Visitor function for ContinueStatement nodes.