- (partially) implemented the GC-exactly-once-discovery logic for the COS nodes; still have to implement it for the COS::EnumDefinition node
@@ -5,7 +5,11 @@ | ||
5 | 5 | #include <sdk/Vector.h> |
6 | 6 | #include <sdk/String.h> |
7 | 7 | #include <sdk/MultiString.h> |
8 | +#include <sdk/UniqueIterate.h> | |
8 | 9 | |
10 | +// Thanks to selector-based nodes we can detach the actual node building from the node logic itself. | |
11 | +// This were a burden because it would require character-based methods that we would not want to lock to character encodings. | |
12 | + | |
9 | 13 | namespace COS |
10 | 14 | { |
11 | 15 |
@@ -27,8 +31,11 @@ | ||
27 | 31 | delete this; |
28 | 32 | } |
29 | 33 | |
30 | - // Thanks to selector-based nodes we can detach the actual node building from the node logic itself. | |
31 | - // This were a burden because it would require character-based methods that we would not want to lock to character encodings. | |
34 | + // Reachability node iteration. | |
35 | + virtual COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept | |
36 | + { | |
37 | + return nullptr; | |
38 | + } | |
32 | 39 | }; |
33 | 40 | |
34 | 41 | struct Program final : public COSNode |
@@ -40,6 +47,11 @@ | ||
40 | 47 | inline Program( const Program& ) = default; |
41 | 48 | inline Program( Program&& ) = default; |
42 | 49 | |
50 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
51 | + { | |
52 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, statements ); | |
53 | + } | |
54 | + | |
43 | 55 | cosCommonVector <COSNode*> statements; |
44 | 56 | }; |
45 | 57 |
@@ -56,6 +68,15 @@ | ||
56 | 68 | inline UnaryOperation( const UnaryOperation& ) = default; |
57 | 69 | inline UnaryOperation( UnaryOperation&& ) = default; |
58 | 70 | |
71 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
72 | + { | |
73 | + if ( prev == nullptr ) | |
74 | + { | |
75 | + return this->op; | |
76 | + } | |
77 | + return nullptr; | |
78 | + } | |
79 | + | |
59 | 80 | COSNode *op; |
60 | 81 | }; |
61 | 82 |
@@ -109,6 +130,11 @@ | ||
109 | 130 | inline BinaryOperation( const BinaryOperation& ) = default; |
110 | 131 | inline BinaryOperation( BinaryOperation&& ) = default; |
111 | 132 | |
133 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
134 | + { | |
135 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ left, right } ); | |
136 | + } | |
137 | + | |
112 | 138 | COSNode *left; |
113 | 139 | COSNode *right; |
114 | 140 | }; |
@@ -267,6 +293,11 @@ | ||
267 | 293 | right.what = nullptr; |
268 | 294 | } |
269 | 295 | |
296 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
297 | + { | |
298 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ what }, params ); | |
299 | + } | |
300 | + | |
270 | 301 | COSNode *what; |
271 | 302 | cosCommonVector <COSNode*> params; |
272 | 303 | }; |
@@ -284,6 +315,11 @@ | ||
284 | 315 | right.what = nullptr; |
285 | 316 | } |
286 | 317 | |
318 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
319 | + { | |
320 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ what }, items ); | |
321 | + } | |
322 | + | |
287 | 323 | COSNode *what; |
288 | 324 | cosCommonVector <COSNode*> items; |
289 | 325 | }; |
@@ -302,6 +338,11 @@ | ||
302 | 338 | right.type = nullptr; |
303 | 339 | } |
304 | 340 | |
341 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
342 | + { | |
343 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ type }, params ); | |
344 | + } | |
345 | + | |
305 | 346 | COSNode *type; |
306 | 347 | cosCommonVector <COSNode*> params; |
307 | 348 | }; |
@@ -314,6 +355,11 @@ | ||
314 | 355 | inline ReplaceOperation( const ReplaceOperation& ) = default; |
315 | 356 | inline ReplaceOperation( ReplaceOperation&& ) = default; |
316 | 357 | |
358 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
359 | + { | |
360 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ what, with } ); | |
361 | + } | |
362 | + | |
317 | 363 | COSNode *what; |
318 | 364 | COSNode *with; |
319 | 365 | }; |
@@ -338,6 +384,11 @@ | ||
338 | 384 | right.castobj = nullptr; |
339 | 385 | } |
340 | 386 | |
387 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
388 | + { | |
389 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ totype, castobj } ); | |
390 | + } | |
391 | + | |
341 | 392 | COSNode *totype; |
342 | 393 | COSNode *castobj; |
343 | 394 | }; |
@@ -356,6 +407,11 @@ | ||
356 | 407 | right.templ = nullptr; |
357 | 408 | } |
358 | 409 | |
410 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
411 | + { | |
412 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ templ }, tparams ); | |
413 | + } | |
414 | + | |
359 | 415 | COSNode *templ; |
360 | 416 | cosCommonVector <COSNode*> tparams; |
361 | 417 | }; |
@@ -378,6 +434,11 @@ | ||
378 | 434 | right.false_branch = nullptr; |
379 | 435 | } |
380 | 436 | |
437 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
438 | + { | |
439 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ condition, true_branch, false_branch } ); | |
440 | + } | |
441 | + | |
381 | 442 | COSNode *condition; |
382 | 443 | COSNode *true_branch; |
383 | 444 | COSNode *false_branch; |
@@ -398,6 +459,11 @@ | ||
398 | 459 | right.exec = nullptr; |
399 | 460 | } |
400 | 461 | |
462 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
463 | + { | |
464 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ condition, exec } ); | |
465 | + } | |
466 | + | |
401 | 467 | COSNode *condition; |
402 | 468 | COSNode *exec; |
403 | 469 | }; |
@@ -421,6 +487,11 @@ | ||
421 | 487 | right.exec = nullptr; |
422 | 488 | } |
423 | 489 | |
490 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
491 | + { | |
492 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ init, condition, iteration, exec } ); | |
493 | + } | |
494 | + | |
424 | 495 | COSNode *init; |
425 | 496 | COSNode *condition; |
426 | 497 | COSNode *iteration; |
@@ -447,6 +518,15 @@ | ||
447 | 518 | right.op = nullptr; |
448 | 519 | } |
449 | 520 | |
521 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
522 | + { | |
523 | + if ( prev == nullptr ) | |
524 | + { | |
525 | + return this->op; | |
526 | + } | |
527 | + return nullptr; | |
528 | + } | |
529 | + | |
450 | 530 | COSNode *op; |
451 | 531 | }; |
452 | 532 |
@@ -468,6 +548,11 @@ | ||
468 | 548 | right.initializer = nullptr; |
469 | 549 | } |
470 | 550 | |
551 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
552 | + { | |
553 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ name, type, initializer } ); | |
554 | + } | |
555 | + | |
471 | 556 | COSNode *name; |
472 | 557 | COSNode *type; |
473 | 558 | COSNode *initializer; |
@@ -481,6 +566,11 @@ | ||
481 | 566 | inline MultiDeclarationStatement( const MultiDeclarationStatement& ) = default; |
482 | 567 | inline MultiDeclarationStatement( MultiDeclarationStatement&& ) = default; |
483 | 568 | |
569 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
570 | + { | |
571 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, decls ); | |
572 | + } | |
573 | + | |
484 | 574 | cosCommonVector <DeclarationStatement*> decls; |
485 | 575 | }; |
486 | 576 |
@@ -500,6 +590,11 @@ | ||
500 | 590 | right.dsttype = nullptr; |
501 | 591 | } |
502 | 592 | |
593 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
594 | + { | |
595 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ srctype, dsttype } ); | |
596 | + } | |
597 | + | |
503 | 598 | COSNode *srctype; |
504 | 599 | COSNode *dsttype; |
505 | 600 | }; |
@@ -512,6 +607,11 @@ | ||
512 | 607 | inline MultiTypedefStatement( const MultiTypedefStatement& ) = default; |
513 | 608 | inline MultiTypedefStatement( MultiTypedefStatement&& ) = default; |
514 | 609 | |
610 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
611 | + { | |
612 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, defs ); | |
613 | + } | |
614 | + | |
515 | 615 | cosCommonVector <TypedefStatement*> defs; |
516 | 616 | }; |
517 | 617 |
@@ -527,6 +627,11 @@ | ||
527 | 627 | return; |
528 | 628 | } |
529 | 629 | |
630 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
631 | + { | |
632 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, statements ); | |
633 | + } | |
634 | + | |
530 | 635 | cosCommonVector <COSNode*> statements; |
531 | 636 | }; |
532 | 637 |
@@ -544,6 +649,15 @@ | ||
544 | 649 | right.op = nullptr; |
545 | 650 | } |
546 | 651 | |
652 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
653 | + { | |
654 | + if ( prev == nullptr ) | |
655 | + { | |
656 | + return this->op; | |
657 | + } | |
658 | + return nullptr; | |
659 | + } | |
660 | + | |
547 | 661 | COSNode *op; |
548 | 662 | }; |
549 | 663 | struct CatchStatement final : public COSNode |
@@ -562,6 +676,11 @@ | ||
562 | 676 | right.catch_body = nullptr; |
563 | 677 | } |
564 | 678 | |
679 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
680 | + { | |
681 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ caught_decl, catch_body } ); | |
682 | + } | |
683 | + | |
565 | 684 | COSNode *caught_decl; |
566 | 685 | COSNode *catch_body; |
567 | 686 | }; |
@@ -579,6 +698,11 @@ | ||
579 | 698 | right.try_body = nullptr; |
580 | 699 | } |
581 | 700 | |
701 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
702 | + { | |
703 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ try_body }, errors ); | |
704 | + } | |
705 | + | |
582 | 706 | COSNode *try_body; |
583 | 707 | cosCommonVector <CatchStatement*> errors; |
584 | 708 | }; |
@@ -599,6 +723,11 @@ | ||
599 | 723 | right.body = nullptr; |
600 | 724 | } |
601 | 725 | |
726 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
727 | + { | |
728 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ name, body } ); | |
729 | + } | |
730 | + | |
602 | 731 | COSNode *name; |
603 | 732 | COSNode *body; |
604 | 733 | }; |
@@ -616,6 +745,11 @@ | ||
616 | 745 | right.body = nullptr; |
617 | 746 | } |
618 | 747 | |
748 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
749 | + { | |
750 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, params, std::array{ body } ); | |
751 | + } | |
752 | + | |
619 | 753 | cosCommonVector <COSNode*> params; |
620 | 754 | COSNode *body; |
621 | 755 | }; |
@@ -633,6 +767,15 @@ | ||
633 | 767 | right.body = nullptr; |
634 | 768 | } |
635 | 769 | |
770 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
771 | + { | |
772 | + if ( prev == nullptr ) | |
773 | + { | |
774 | + return this->body; | |
775 | + } | |
776 | + return nullptr; | |
777 | + } | |
778 | + | |
636 | 779 | COSNode *body; |
637 | 780 | }; |
638 | 781 |
@@ -750,6 +893,15 @@ | ||
750 | 893 | return nullptr; |
751 | 894 | } |
752 | 895 | |
896 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
897 | + { | |
898 | + if ( prev == nullptr ) | |
899 | + { | |
900 | + return this->spec; | |
901 | + } | |
902 | + return nullptr; | |
903 | + } | |
904 | + | |
753 | 905 | COSNode *spec; |
754 | 906 | }; |
755 | 907 | struct PointerTypeSpecifier final : public TypeSpecifier |
@@ -774,6 +926,15 @@ | ||
774 | 926 | right.array_size_op = nullptr; |
775 | 927 | } |
776 | 928 | |
929 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
930 | + { | |
931 | + if ( prev == nullptr ) | |
932 | + { | |
933 | + return this->array_size_op; | |
934 | + } | |
935 | + return nullptr; | |
936 | + } | |
937 | + | |
777 | 938 | COSNode *array_size_op; |
778 | 939 | }; |
779 | 940 |
@@ -786,6 +947,11 @@ | ||
786 | 947 | inline CurlyPack( const CurlyPack& ) = default; |
787 | 948 | inline CurlyPack( CurlyPack&& ) = default; |
788 | 949 | |
950 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
951 | + { | |
952 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, params ); | |
953 | + } | |
954 | + | |
789 | 955 | cosCommonVector <COSNode*> params; |
790 | 956 | }; |
791 | 957 | struct ArrayDefinition final : public COSNode |
@@ -799,6 +965,11 @@ | ||
799 | 965 | inline ArrayDefinition( const ArrayDefinition& ) = default; |
800 | 966 | inline ArrayDefinition( ArrayDefinition&& ) = default; |
801 | 967 | |
968 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
969 | + { | |
970 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, items ); | |
971 | + } | |
972 | + | |
802 | 973 | cosCommonVector <COSNode*> items; |
803 | 974 | }; |
804 | 975 | struct FuncsigDefinition final : public COSNode |
@@ -826,6 +997,11 @@ | ||
826 | 997 | return deepest; |
827 | 998 | } |
828 | 999 | |
1000 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
1001 | + { | |
1002 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ return_type }, params ); | |
1003 | + } | |
1004 | + | |
829 | 1005 | COSNode *return_type; |
830 | 1006 | cosCommonVector <COSNode*> params; |
831 | 1007 | }; |
@@ -846,6 +1022,11 @@ | ||
846 | 1022 | right.toinclude = nullptr; |
847 | 1023 | } |
848 | 1024 | |
1025 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
1026 | + { | |
1027 | + return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ name, toinclude } ); | |
1028 | + } | |
1029 | + | |
849 | 1030 | COSNode *name; |
850 | 1031 | COSNode *toinclude; |
851 | 1032 | }; |
@@ -863,6 +1044,15 @@ | ||
863 | 1044 | right.nsname = nullptr; |
864 | 1045 | } |
865 | 1046 | |
1047 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
1048 | + { | |
1049 | + if ( prev == nullptr ) | |
1050 | + { | |
1051 | + return this->nsname; | |
1052 | + } | |
1053 | + return nullptr; | |
1054 | + } | |
1055 | + | |
866 | 1056 | COSNode *nsname; |
867 | 1057 | }; |
868 | 1058 |
@@ -886,6 +1076,12 @@ | ||
886 | 1076 | right.name = nullptr; |
887 | 1077 | } |
888 | 1078 | |
1079 | + COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override | |
1080 | + { | |
1081 | + // TODO: think about how to splice these tuples into single values for eir::uniqueFetchNextPtr | |
1082 | + return nullptr; | |
1083 | + } | |
1084 | + | |
889 | 1085 | COSNode *name; |
890 | 1086 | cosCommonVector <item> items; |
891 | 1087 | }; |
@@ -17,6 +17,7 @@ | ||
17 | 17 | #include <sdk/StackedAllocator.h> |
18 | 18 | #include <sdk/rwlist.hpp> |
19 | 19 | #include <sdk/BitVector.h> |
20 | +#include <sdk/UniqueIterate.h> | |
20 | 21 | |
21 | 22 | #include <type_traits> |
22 | 23 | #include <optional> |
@@ -1352,7 +1353,7 @@ | ||
1352 | 1353 | |
1353 | 1354 | inline ~SerializedStep( void ) |
1354 | 1355 | { |
1355 | - eir::unique_iterate( steps, | |
1356 | + eir::unique_iterate <Step*> ( steps, | |
1356 | 1357 | [this]( Step *item ) |
1357 | 1358 | { |
1358 | 1359 | this->env->gcReachSched.OnRemoveConnection( this, item ); |
@@ -1515,7 +1516,7 @@ | ||
1515 | 1516 | |
1516 | 1517 | ~StepSeparation( void ) |
1517 | 1518 | { |
1518 | - eir::unique_iterate( std::array{ this->itemStep, this->separationStep }, | |
1519 | + eir::unique_iterate <Step*> ( std::array{ this->itemStep, this->separationStep }, | |
1519 | 1520 | [this]( Step *item ) |
1520 | 1521 | { |
1521 | 1522 | if ( item != nullptr ) |
@@ -1671,7 +1672,7 @@ | ||
1671 | 1672 | |
1672 | 1673 | ~StepExtend( void ) |
1673 | 1674 | { |
1674 | - eir::unique_iterate( std::array{ extended, extension }, | |
1675 | + eir::unique_iterate <Step*> ( std::array{ extended, extension }, | |
1675 | 1676 | [this]( Step *n ) |
1676 | 1677 | { |
1677 | 1678 | if ( n != nullptr ) |
@@ -2128,7 +2129,7 @@ | ||
2128 | 2129 | |
2129 | 2130 | inline ~StepProceduralSequence( void ) |
2130 | 2131 | { |
2131 | - eir::unique_iterate( steps, | |
2132 | + eir::unique_iterate <Step*> ( steps, | |
2132 | 2133 | [this]( Step *item ) |
2133 | 2134 | { |
2134 | 2135 | this->env->gcReachSched.OnRemoveConnection( this, item ); |