• R/O
  • SSH
  • HTTPS

eircompile: Commit


Commit MetaInfo

Revision66 (tree)
Time2021-12-24 05:47:25
Authorquiret

Log Message

- improved the extension-lookup logic inside of the lexer so that all 6 COS function signature and definition unit tests succeed now

Change Summary

Incremental Difference

--- eircompile/include/eircompile/lexing_env.h (revision 65)
+++ eircompile/include/eircompile/lexing_env.h (revision 66)
@@ -4124,7 +4124,7 @@
41244124 auto find_next_specialized_step = [&]( Step *next_step, bool is_extension_chain = false ) -> Step*
41254125 {
41264126 size_t calcstack_size = get_calcstack_size();
4127-
4127+
41284128 // Look for the first call of the same-named step that is either an extension or a regular call and
41294129 // use that one instead.
41304130 size_t calcstack_iter = ( calcstack_size - 1 );
@@ -4155,8 +4155,12 @@
41554155 {
41564156 return next_extstep;
41574157 }
4158- // Otherwise we have already taken care of it, thus no need to check anymore.
4159- break;
4158+
4159+ if ( next_extstep->extended == next_step && next_extstep->extended_base_on_extension == false )
4160+ {
4161+ // There is nothing more to find.
4162+ break;
4163+ }
41604164 }
41614165 }
41624166 else if ( StepExtensionPoint *extptstep = dynamic_cast <StepExtensionPoint*> ( cstack_step ) )
@@ -4163,7 +4167,6 @@
41634167 {
41644168 // We check all extensions in the extension pack for any not yet called that may
41654169 // extend us.
4166- bool did_find_any_stemming_from = false;
41674170
41684171 for ( StepExtend *next_extstep : extptstep->extensions )
41694172 {
@@ -4173,20 +4176,16 @@
41734176 {
41744177 return next_extstep;
41754178 }
4176- did_find_any_stemming_from = true;
4179+
4180+ if ( next_extstep->extended == next_step && next_extstep->extended_base_on_extension == false )
4181+ {
4182+ // There is nothing more to find.
4183+ break;
4184+ }
4185+
41774186 break; // we do not allow finding new extensions if we enter recursively multiple times.
41784187 }
41794188 }
4180-
4181- // If any inside the extension pack were stemming from but they were already taken, then
4182- // we would have taken them anyway if not so. Since we are only interested in most-special
4183- // extensions, then by not taking any stemming froms that are most special we can be sure
4184- // that there are no ones that are more special than the ones we just declined above us.
4185- // Thus we can just bail the loop here.
4186- if ( did_find_any_stemming_from )
4187- {
4188- break;
4189- }
41904189 }
41914190 else if ( cstack_step == next_step )
41924191 {
@@ -4436,7 +4435,7 @@
44364435
44374436 if ( altsNode == nullptr )
44384437 {
4439- // Optimization: an empty alternatives results in a success.
4438+ // Optimization: an empty alternatives results is a success.
44404439 has_op_finished = true;
44414440 is_op_successful = true;
44424441 }
@@ -4591,8 +4590,6 @@
45914590
45924591 if ( extension_is_before_usual == false && idx == 0 || extension_is_before_usual == true && idx == 1 )
45934592 {
4594- size_t calcstack_size = get_calcstack_size();
4595-
45964593 Step *next_step = extstep->extended;
45974594
45984595 if ( extstep->extended_base_on_extension )
@@ -4605,12 +4602,13 @@
46054602 has_op_finished = false;
46064603
46074604 entry.process_idx++;
4608- break;
46094605 }
4610-
4611- // Mark the called frame as special.
4612- // Extension-search should know that the frame is not the most-special one.
4613- entry.was_called_by_extend = true;
4606+ else
4607+ {
4608+ // Mark the called frame as special.
4609+ // Extension-search should know that the frame is not the most-special one.
4610+ entry.was_called_by_extend = true;
4611+ }
46144612 }
46154613 else if ( extension_is_before_usual == false && idx == 1 || extension_is_before_usual == true && idx == 0 )
46164614 {
Show on old repository browser