• R/O
  • SSH
  • HTTPS

eircompile: Commit


Commit MetaInfo

Revision74 (tree)
Time2022-01-21 10:18:04
Authorquiret

Log Message

- (partially) implemented the GC-exactly-once-discovery logic for the COS nodes; still have to implement it for the COS::EnumDefinition node

Change Summary

Incremental Difference

--- commonlangs/include/commonlangs/cos.h (revision 73)
+++ commonlangs/include/commonlangs/cos.h (revision 74)
@@ -5,7 +5,11 @@
55 #include <sdk/Vector.h>
66 #include <sdk/String.h>
77 #include <sdk/MultiString.h>
8+#include <sdk/UniqueIterate.h>
89
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+
913 namespace COS
1014 {
1115
@@ -27,8 +31,11 @@
2731 delete this;
2832 }
2933
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+ }
3239 };
3340
3441 struct Program final : public COSNode
@@ -40,6 +47,11 @@
4047 inline Program( const Program& ) = default;
4148 inline Program( Program&& ) = default;
4249
50+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
51+ {
52+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, statements );
53+ }
54+
4355 cosCommonVector <COSNode*> statements;
4456 };
4557
@@ -56,6 +68,15 @@
5668 inline UnaryOperation( const UnaryOperation& ) = default;
5769 inline UnaryOperation( UnaryOperation&& ) = default;
5870
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+
5980 COSNode *op;
6081 };
6182
@@ -109,6 +130,11 @@
109130 inline BinaryOperation( const BinaryOperation& ) = default;
110131 inline BinaryOperation( BinaryOperation&& ) = default;
111132
133+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
134+ {
135+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ left, right } );
136+ }
137+
112138 COSNode *left;
113139 COSNode *right;
114140 };
@@ -267,6 +293,11 @@
267293 right.what = nullptr;
268294 }
269295
296+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
297+ {
298+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ what }, params );
299+ }
300+
270301 COSNode *what;
271302 cosCommonVector <COSNode*> params;
272303 };
@@ -284,6 +315,11 @@
284315 right.what = nullptr;
285316 }
286317
318+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
319+ {
320+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ what }, items );
321+ }
322+
287323 COSNode *what;
288324 cosCommonVector <COSNode*> items;
289325 };
@@ -302,6 +338,11 @@
302338 right.type = nullptr;
303339 }
304340
341+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
342+ {
343+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ type }, params );
344+ }
345+
305346 COSNode *type;
306347 cosCommonVector <COSNode*> params;
307348 };
@@ -314,6 +355,11 @@
314355 inline ReplaceOperation( const ReplaceOperation& ) = default;
315356 inline ReplaceOperation( ReplaceOperation&& ) = default;
316357
358+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
359+ {
360+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ what, with } );
361+ }
362+
317363 COSNode *what;
318364 COSNode *with;
319365 };
@@ -338,6 +384,11 @@
338384 right.castobj = nullptr;
339385 }
340386
387+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
388+ {
389+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ totype, castobj } );
390+ }
391+
341392 COSNode *totype;
342393 COSNode *castobj;
343394 };
@@ -356,6 +407,11 @@
356407 right.templ = nullptr;
357408 }
358409
410+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
411+ {
412+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ templ }, tparams );
413+ }
414+
359415 COSNode *templ;
360416 cosCommonVector <COSNode*> tparams;
361417 };
@@ -378,6 +434,11 @@
378434 right.false_branch = nullptr;
379435 }
380436
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+
381442 COSNode *condition;
382443 COSNode *true_branch;
383444 COSNode *false_branch;
@@ -398,6 +459,11 @@
398459 right.exec = nullptr;
399460 }
400461
462+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
463+ {
464+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ condition, exec } );
465+ }
466+
401467 COSNode *condition;
402468 COSNode *exec;
403469 };
@@ -421,6 +487,11 @@
421487 right.exec = nullptr;
422488 }
423489
490+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
491+ {
492+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ init, condition, iteration, exec } );
493+ }
494+
424495 COSNode *init;
425496 COSNode *condition;
426497 COSNode *iteration;
@@ -447,6 +518,15 @@
447518 right.op = nullptr;
448519 }
449520
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+
450530 COSNode *op;
451531 };
452532
@@ -468,6 +548,11 @@
468548 right.initializer = nullptr;
469549 }
470550
551+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
552+ {
553+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ name, type, initializer } );
554+ }
555+
471556 COSNode *name;
472557 COSNode *type;
473558 COSNode *initializer;
@@ -481,6 +566,11 @@
481566 inline MultiDeclarationStatement( const MultiDeclarationStatement& ) = default;
482567 inline MultiDeclarationStatement( MultiDeclarationStatement&& ) = default;
483568
569+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
570+ {
571+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, decls );
572+ }
573+
484574 cosCommonVector <DeclarationStatement*> decls;
485575 };
486576
@@ -500,6 +590,11 @@
500590 right.dsttype = nullptr;
501591 }
502592
593+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
594+ {
595+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ srctype, dsttype } );
596+ }
597+
503598 COSNode *srctype;
504599 COSNode *dsttype;
505600 };
@@ -512,6 +607,11 @@
512607 inline MultiTypedefStatement( const MultiTypedefStatement& ) = default;
513608 inline MultiTypedefStatement( MultiTypedefStatement&& ) = default;
514609
610+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
611+ {
612+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, defs );
613+ }
614+
515615 cosCommonVector <TypedefStatement*> defs;
516616 };
517617
@@ -527,6 +627,11 @@
527627 return;
528628 }
529629
630+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
631+ {
632+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, statements );
633+ }
634+
530635 cosCommonVector <COSNode*> statements;
531636 };
532637
@@ -544,6 +649,15 @@
544649 right.op = nullptr;
545650 }
546651
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+
547661 COSNode *op;
548662 };
549663 struct CatchStatement final : public COSNode
@@ -562,6 +676,11 @@
562676 right.catch_body = nullptr;
563677 }
564678
679+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
680+ {
681+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ caught_decl, catch_body } );
682+ }
683+
565684 COSNode *caught_decl;
566685 COSNode *catch_body;
567686 };
@@ -579,6 +698,11 @@
579698 right.try_body = nullptr;
580699 }
581700
701+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
702+ {
703+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ try_body }, errors );
704+ }
705+
582706 COSNode *try_body;
583707 cosCommonVector <CatchStatement*> errors;
584708 };
@@ -599,6 +723,11 @@
599723 right.body = nullptr;
600724 }
601725
726+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
727+ {
728+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ name, body } );
729+ }
730+
602731 COSNode *name;
603732 COSNode *body;
604733 };
@@ -616,6 +745,11 @@
616745 right.body = nullptr;
617746 }
618747
748+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
749+ {
750+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, params, std::array{ body } );
751+ }
752+
619753 cosCommonVector <COSNode*> params;
620754 COSNode *body;
621755 };
@@ -633,6 +767,15 @@
633767 right.body = nullptr;
634768 }
635769
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+
636779 COSNode *body;
637780 };
638781
@@ -750,6 +893,15 @@
750893 return nullptr;
751894 }
752895
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+
753905 COSNode *spec;
754906 };
755907 struct PointerTypeSpecifier final : public TypeSpecifier
@@ -774,6 +926,15 @@
774926 right.array_size_op = nullptr;
775927 }
776928
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+
777938 COSNode *array_size_op;
778939 };
779940
@@ -786,6 +947,11 @@
786947 inline CurlyPack( const CurlyPack& ) = default;
787948 inline CurlyPack( CurlyPack&& ) = default;
788949
950+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
951+ {
952+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, params );
953+ }
954+
789955 cosCommonVector <COSNode*> params;
790956 };
791957 struct ArrayDefinition final : public COSNode
@@ -799,6 +965,11 @@
799965 inline ArrayDefinition( const ArrayDefinition& ) = default;
800966 inline ArrayDefinition( ArrayDefinition&& ) = default;
801967
968+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
969+ {
970+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, items );
971+ }
972+
802973 cosCommonVector <COSNode*> items;
803974 };
804975 struct FuncsigDefinition final : public COSNode
@@ -826,6 +997,11 @@
826997 return deepest;
827998 }
828999
1000+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
1001+ {
1002+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ return_type }, params );
1003+ }
1004+
8291005 COSNode *return_type;
8301006 cosCommonVector <COSNode*> params;
8311007 };
@@ -846,6 +1022,11 @@
8461022 right.toinclude = nullptr;
8471023 }
8481024
1025+ COSNode* GetNextConnectionsToNode_Reach( COSNode *prev ) const noexcept override
1026+ {
1027+ return eir::uniqueFetchNextPtr <COSNode*> ( prev, std::array{ name, toinclude } );
1028+ }
1029+
8491030 COSNode *name;
8501031 COSNode *toinclude;
8511032 };
@@ -863,6 +1044,15 @@
8631044 right.nsname = nullptr;
8641045 }
8651046
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+
8661056 COSNode *nsname;
8671057 };
8681058
@@ -886,6 +1076,12 @@
8861076 right.name = nullptr;
8871077 }
8881078
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+
8891085 COSNode *name;
8901086 cosCommonVector <item> items;
8911087 };
--- eircompile/include/eircompile/lexing_env.h (revision 73)
+++ eircompile/include/eircompile/lexing_env.h (revision 74)
@@ -17,6 +17,7 @@
1717 #include <sdk/StackedAllocator.h>
1818 #include <sdk/rwlist.hpp>
1919 #include <sdk/BitVector.h>
20+#include <sdk/UniqueIterate.h>
2021
2122 #include <type_traits>
2223 #include <optional>
@@ -1352,7 +1353,7 @@
13521353
13531354 inline ~SerializedStep( void )
13541355 {
1355- eir::unique_iterate( steps,
1356+ eir::unique_iterate <Step*> ( steps,
13561357 [this]( Step *item )
13571358 {
13581359 this->env->gcReachSched.OnRemoveConnection( this, item );
@@ -1515,7 +1516,7 @@
15151516
15161517 ~StepSeparation( void )
15171518 {
1518- eir::unique_iterate( std::array{ this->itemStep, this->separationStep },
1519+ eir::unique_iterate <Step*> ( std::array{ this->itemStep, this->separationStep },
15191520 [this]( Step *item )
15201521 {
15211522 if ( item != nullptr )
@@ -1671,7 +1672,7 @@
16711672
16721673 ~StepExtend( void )
16731674 {
1674- eir::unique_iterate( std::array{ extended, extension },
1675+ eir::unique_iterate <Step*> ( std::array{ extended, extension },
16751676 [this]( Step *n )
16761677 {
16771678 if ( n != nullptr )
@@ -2128,7 +2129,7 @@
21282129
21292130 inline ~StepProceduralSequence( void )
21302131 {
2131- eir::unique_iterate( steps,
2132+ eir::unique_iterate <Step*> ( steps,
21322133 [this]( Step *item )
21332134 {
21342135 this->env->gcReachSched.OnRemoveConnection( this, item );
Show on old repository browser