From 3f3b7033ef7c05acd60efb561060efd12f393e31 Mon Sep 17 00:00:00 2001 From: goodale Date: Mon, 30 Nov 1998 16:02:30 +0000 Subject: Finished get_implementation_ancestors git-svn-id: http://svn.cactuscode.org/flesh/trunk@31 17b73243-c579-4c4c-a9d2-2d5706c11dac --- lib/sbin/interface_parser.pl | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'lib/sbin/interface_parser.pl') diff --git a/lib/sbin/interface_parser.pl b/lib/sbin/interface_parser.pl index 5fdf7904..fb5fd3ce 100644 --- a/lib/sbin/interface_parser.pl +++ b/lib/sbin/interface_parser.pl @@ -59,6 +59,7 @@ sub cross_index_interface_data local(%interface_data); local(%implementations); local($implementation); + local(%ancestors); @thorns = @indata[0..$n_thorns-1]; %interface_data = @indata[$n_thorns..$#indata]; @@ -84,9 +85,11 @@ sub cross_index_interface_data &check_interface_consistency($implementation, %interface_data); - $interface_data{"IMPLEMENTATION \U$implementation\E ANCESTORS"} = &get_implementation_ancestors($implementation, %interface_data); + %ancestors = &get_implementation_ancestors($implementation, 0, %interface_data); + + $interface_data{"IMPLEMENTATION \U$implementation\E ANCESTORS"} = join(" ",( keys %ancestors)); - $interface_data{"IMPLEMENTATION \U$implementation\E FRIENDS"} = &get_implementation_friends($implementation, %interface_data); +# $interface_data{"IMPLEMENTATION \U$implementation\E FRIENDS"} = &get_implementation_friends($implementation, %interface_data); } @@ -124,10 +127,22 @@ sub get_implementation_friends sub get_implementation_ancestors { - local($implementation, %interface_data); + local($implementation, $n_ancestors, @indata) = @_; + local(%ancestors); + local(%interface_data); local($thorn); local($ancestor, $ancestors); - local(%ancestors); + + if($n_ancestors > 0) + { + %ancestors = @indata[0..2*$n_ancestors-1]; + %interface_data = @indata[2*$n_ancestors..$#indata]; + } + else + { + %ancestors = (); + %interface_data = @indata; + } $interface_data{"IMPLEMENTATION \U$implementation\E THORNS"} =~ m:(\w+):; @@ -136,19 +151,14 @@ sub get_implementation_ancestors # Recurse. This needs to be made robust against loops. foreach $ancestor (split(" ", $interface_data{"\U$thorn\E INHERITS"})) { - $ancestors .= &get_implementation_ancestors($ancestor, %interface_data); - $ancestors .= "$ancestor "; + if(! $ancestors{"\U$ancestor\E"}) + { + $ancestors{"\U$ancestor\E"} = 1; + %ancestors = &get_implementation_ancestors($ancestor, scalar(keys %ancestors), %ancestors,%interface_data); + } } - # Uniquify the list. - foreach $ancestor (split(" ", $ancestors)) - { - $ancestors{"\U$ancestor\E"} = 1; - } - - $ancestors = join(" ", %ancestors); - - return $ancestors; + return %ancestors; } sub check_interface_consistency -- cgit v1.2.3