Weird Code in parse.y (java_layout_seen_class_methods)
Bryce McKinlay
mckinlay@redhat.com
Tue Jun 15 16:41:00 GMT 2004
Hi Ranjit,
Ranjit Mathew wrote:
> Consider the body of java_layout_seen_class_methods()
>in parse.y:
>-------------------------- 8< --------------------------
> 7577 void java_layout_seen_class_methods (void)
> 7578 {
> 7579 tree previous_list = all_class_list;
> 7580 tree end = NULL_TREE;
> 7581 tree current;
> 7582
> 7583 while (1)
> 7584 {
> 7585 for (current = previous_list;
> 7586 current != end; current = TREE_CHAIN (current))
> 7587 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
> 7588
> 7589 if (previous_list != all_class_list)
> 7590 {
> 7591 end = previous_list;
> 7592 previous_list = all_class_list;
> 7593 }
> 7594 else
> 7595 break;
> 7596 }
> 7597 }
>-------------------------- 8< --------------------------
>>How can code between 7590-7593 ever execute?
>And why is there a while(1) around the for loop?
>>Is this some vestigial code that should have been
>removed?
>>
I suspect that layout_class_methods can end up adding things to
all_class_list, because new classes may be added/resolved during method
layout. This changes the value of all_class_list. The while(1) is
presumably there so that the for-loop gets re-run on any new classes
which appear in the list.
Regards
Bryce
More information about the Java
mailing list