- improved the extension-lookup logic inside of the lexer so that all 6 COS function signature and definition unit tests succeed now
@@ -4124,7 +4124,7 @@ | ||
4124 | 4124 | auto find_next_specialized_step = [&]( Step *next_step, bool is_extension_chain = false ) -> Step* |
4125 | 4125 | { |
4126 | 4126 | size_t calcstack_size = get_calcstack_size(); |
4127 | - | |
4127 | + | |
4128 | 4128 | // Look for the first call of the same-named step that is either an extension or a regular call and |
4129 | 4129 | // use that one instead. |
4130 | 4130 | size_t calcstack_iter = ( calcstack_size - 1 ); |
@@ -4155,8 +4155,12 @@ | ||
4155 | 4155 | { |
4156 | 4156 | return next_extstep; |
4157 | 4157 | } |
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 | + } | |
4160 | 4164 | } |
4161 | 4165 | } |
4162 | 4166 | else if ( StepExtensionPoint *extptstep = dynamic_cast <StepExtensionPoint*> ( cstack_step ) ) |
@@ -4163,7 +4167,6 @@ | ||
4163 | 4167 | { |
4164 | 4168 | // We check all extensions in the extension pack for any not yet called that may |
4165 | 4169 | // extend us. |
4166 | - bool did_find_any_stemming_from = false; | |
4167 | 4170 | |
4168 | 4171 | for ( StepExtend *next_extstep : extptstep->extensions ) |
4169 | 4172 | { |
@@ -4173,20 +4176,16 @@ | ||
4173 | 4176 | { |
4174 | 4177 | return next_extstep; |
4175 | 4178 | } |
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 | + | |
4177 | 4186 | break; // we do not allow finding new extensions if we enter recursively multiple times. |
4178 | 4187 | } |
4179 | 4188 | } |
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 | - } | |
4190 | 4189 | } |
4191 | 4190 | else if ( cstack_step == next_step ) |
4192 | 4191 | { |
@@ -4436,7 +4435,7 @@ | ||
4436 | 4435 | |
4437 | 4436 | if ( altsNode == nullptr ) |
4438 | 4437 | { |
4439 | - // Optimization: an empty alternatives results in a success. | |
4438 | + // Optimization: an empty alternatives results is a success. | |
4440 | 4439 | has_op_finished = true; |
4441 | 4440 | is_op_successful = true; |
4442 | 4441 | } |
@@ -4591,8 +4590,6 @@ | ||
4591 | 4590 | |
4592 | 4591 | if ( extension_is_before_usual == false && idx == 0 || extension_is_before_usual == true && idx == 1 ) |
4593 | 4592 | { |
4594 | - size_t calcstack_size = get_calcstack_size(); | |
4595 | - | |
4596 | 4593 | Step *next_step = extstep->extended; |
4597 | 4594 | |
4598 | 4595 | if ( extstep->extended_base_on_extension ) |
@@ -4605,12 +4602,13 @@ | ||
4605 | 4602 | has_op_finished = false; |
4606 | 4603 | |
4607 | 4604 | entry.process_idx++; |
4608 | - break; | |
4609 | 4605 | } |
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 | + } | |
4614 | 4612 | } |
4615 | 4613 | else if ( extension_is_before_usual == false && idx == 1 || extension_is_before_usual == true && idx == 0 ) |
4616 | 4614 | { |