@@ -393,6 +393,7 @@ class sema
393
393
public:
394
394
std::vector<error_entry>& errors;
395
395
stable_vector<symbol> symbols;
396
+ index_t global_token_counter = 1 ;
396
397
397
398
std::vector<selection_statement_node const *> active_selections;
398
399
@@ -567,12 +568,12 @@ class sema
567
568
++i;
568
569
}
569
570
571
+ initial_find_old = i;
572
+
570
573
if (i == symbols.cbegin ()) {
571
574
return nullptr ;
572
575
}
573
576
574
- initial_find_old = i;
575
-
576
577
auto depth = 0 ;
577
578
578
579
// If we found it exactly, we have its depth
@@ -754,35 +755,23 @@ class sema
754
755
755
756
// First find the position the query is coming from
756
757
// and remember its depth
757
- auto i = symbols.cbegin ();
758
- auto depth = 0 ;
759
-
760
- {
761
- CPP2_SCOPE_TIMER (" get_declaration_of_new - phase 1 initial loop" );
762
-
763
- // If the declaration_starts list got this far yet, use that to
764
- // skip repeating the whole linear search from the table beginning
765
- //
766
758
auto probe = std::lower_bound (
767
759
declaration_starts.begin (),
768
760
declaration_starts.end (),
769
761
t.get_global_token_order ()
770
762
);
771
- if (probe != declaration_starts.end ())
763
+ if (
764
+ probe != declaration_starts.end ()
765
+ && probe->token_order > t.get_global_token_order ()
766
+ )
772
767
{
773
- if (probe->iter ->get_global_token_order () != t.get_global_token_order ()) {
774
- --probe;
775
- }
776
- i = probe->iter ;
768
+ --probe;
777
769
}
770
+ auto i = probe != declaration_starts.end () ? probe->iter : declaration_starts.back ().iter ;
771
+ auto depth = 0 ;
778
772
779
- // Else resume appending values to the declaration_starts list
780
- //
781
- else
782
773
{
783
- // Start right after where we left off
784
- i = declaration_starts.back ().iter ;
785
- }
774
+ CPP2_SCOPE_TIMER (" get_declaration_of_new - phase 1 initial loop" );
786
775
787
776
while (
788
777
i != symbols.cend ()
@@ -805,12 +794,12 @@ class sema
805
794
++i;
806
795
}
807
796
797
+ initial_find_new = i;
798
+
808
799
if (i == symbols.cbegin ()) {
809
800
return nullptr ;
810
801
}
811
802
812
- initial_find_new = i;
813
-
814
803
// If we found it exactly, we have its depth
815
804
if (
816
805
i != symbols.cend ()
@@ -2789,6 +2778,7 @@ class sema
2789
2778
2790
2779
if (n.pass != passing_style::out) {
2791
2780
push_activation ( declaration_sym ( true , n.declaration .get (), n.declaration ->name (), n.declaration ->initializer .get (), &n, inside_returns_list));
2781
+ declaration_starts.emplace_back ( global_token_counter, symbols.cend ()-1 );
2792
2782
}
2793
2783
}
2794
2784
@@ -2864,6 +2854,13 @@ class sema
2864
2854
)
2865
2855
{
2866
2856
push_activation ( declaration_sym ( true , &n, n.name (), n.initializer .get (), inside_out_parameter, false , inside_returns_list ) );
2857
+ if (
2858
+ n.has_name ()
2859
+ && !n.has_name (" _" )
2860
+ )
2861
+ {
2862
+ declaration_starts.emplace_back ( global_token_counter, symbols.cend ()-1 );
2863
+ }
2867
2864
if (!n.is_object ()) {
2868
2865
++scope_depth;
2869
2866
}
@@ -2961,7 +2958,6 @@ class sema
2961
2958
2962
2959
// By giving tokens an order during sema
2963
2960
// generated code can be equally checked
2964
- static index_t global_token_counter = 1 ; // TODO static
2965
2961
t.set_global_token_order ( global_token_counter++ );
2966
2962
2967
2963
auto started_member_access =
0 commit comments