Changeset 2628
- Timestamp:
- 02/21/08 15:14:22 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tendra/src/producers/ada/asis/asis-compilation_units-relations.adb
r2626 r2628 27 27 with Asis.Expressions; 28 28 with Asis.Iterator; 29 with Ada.Wide_Text_IO; 29 30 30 31 package body Asis.Compilation_Units.Relations is … … 67 68 type Tree_Node_Access is access all Tree_Node; 68 69 70 -- Tree_Node_Array -- 69 71 type Tree_Node_Array is array (Positive range <>) of Tree_Node_Access; 70 72 type Tree_Node_Array_Access is access all Tree_Node_Array; … … 85 87 return Boolean; 86 88 87 function Append_Parent 88 (This : in Tree_Node_Access; 89 Unit : in Compilation_Unit) 90 return Tree_Node_Access; 91 92 procedure Add_Thread 93 (This : in Tree_Node_Access; 94 To_Node : in Tree_Node_Access; 95 From_Tree : in out Tree_Node_Access); 89 -- Tree_Node -- 90 91 type Orders is (Ascending, Descending); 92 93 procedure Dependence_Order 94 (This : in Tree_Node_Access; 95 Order : in Orders); 96 96 97 97 function Add_Child … … 101 101 return Tree_Node_Access; 102 102 103 function Add_Child _Body103 function Add_Child 104 104 (This : in Tree_Node_Access; 105 105 Node : in Tree_Node_Access; … … 119 119 To_Node : in Tree_Node_Access); 120 120 121 procedure Add_Body_Dependents 122 (This : in Tree_Node_Access; 123 To_Node : in Tree_Node_Access); 124 125 function Is_Child 126 (This : in Tree_Node_Access; 127 Node : in Tree_Node_Access) 128 return Boolean; 129 130 procedure Set_Parent 131 (This : in Tree_Node_Access; 132 Node : in Tree_Node_Access; 133 Parent : in Tree_Node_Access); 134 121 135 procedure Clear 122 136 (This : in out Tree_Node); … … 127 141 return Tree_Node_Access; 128 142 129 type Orders is (Ascending, Descending);130 131 143 procedure Check 132 144 (This : in Tree_Node_Access; 133 Order : in Orders;134 145 The_Context : in Asis.Context); 135 146 … … 137 148 (This : in Tree_Node_Access; 138 149 Limit_List : in Utils.Compilation_Unit_List_Access; 139 List_Last : in ASIS_Integer; 140 Order : in Orders) 150 List_Last : in ASIS_Integer) 141 151 return Relationship; 142 152 … … 154 164 155 165 function Spec 166 (This : in Tree_Node_Access) 167 return Compilation_Unit; 168 169 function Get_Body 156 170 (This : in Tree_Node_Access) 157 171 return Compilation_Unit; … … 173 187 Self : Tree_Node_Access := Tree_Node'Unchecked_Access; 174 188 189 Order : Orders := Descending; 190 175 191 -- ÑÑÑлка Ма пÑеЎÑÐŽÑÑОй ÐµÐ»ÐµÐŒÐµÐœÑ 176 192 Prev : Tree_Node_Access := null; … … 183 199 184 200 Added : Boolean := False; 185 Consistent : Boolean := True; 186 187 -- пПÑлеЎÑÑÑОе елеЌеМÑÑ 0-Ñ 188 201 202 Consistent : Boolean := True; 203 Body_Consistent : Boolean := True; 204 205 -- пПÑлеЎÑÑÑОе елеЌеМÑÑ 189 206 Next : Tree_Node_Array_Access := null; 190 207 191 -- ÑпОÑПк ПкПМÑÐ°ÐœÐžÑ "веÑвей", 192 -- ÐŽÐ»Ñ Ð±ÑÑÑÑПгП ОзÑÐŒÐ°ÐœÐžÑ ÐŸÐœÑÑ 193 194 -- а Ме пеÑебПÑПЌ вÑÐµÑ 195 веÑвей 196 -- запПлМÑÐµÑ ÑПлÑкП кПÑМевПй ÐµÐ»ÐµÐŒÐµÐœÑ 197 Last_Nodes : Tree_Node_Array_Access := null; 208 -- завОÑОЌПÑÑО Ñела (with) 209 Body_Dependences : Tree_Node_Array_Access := null; 198 210 199 211 -- ÑПÑÑОÑПваММÑй ÑпОÑПк вÑÐµÑ … … 238 250 (List : in out Tree_Node_Array_Access; 239 251 Node : in Tree_Node_Access); 252 253 function Remove 254 (List : in Tree_Node_Array_Access; 255 Node : in Tree_Node_Access) 256 return Tree_Node_Array_Access; 240 257 241 258 function Add_Node_Ordered … … 291 308 return Utils.Tree_Node_Access; 292 309 310 function Get_Family 311 (List : in Asis.Compilation_Unit_List; 312 The_Context : in Asis.Context) 313 return Utils.Tree_Node_Access; 314 315 function Get_Needed_Units 316 (List : in Asis.Compilation_Unit_List; 317 The_Context : in Asis.Context) 318 return Utils.Tree_Node_Access; 319 320 procedure Get_Subunits 321 (Tree : in Utils.Tree_Node_Access; 322 Unit : in Compilation_Unit; 323 Node : in Utils.Tree_Node_Access; 324 The_Context : in Asis.Context); 325 293 326 function Get_Compilation_Unit 294 (Target : in Asis.Element) 327 (Unit : in Compilation_Unit; 328 Target : in Asis.Element; 329 Number : in List_Index; 330 The_Context : in Asis.Context) 295 331 return Asis.Compilation_Unit; 296 332 297 333 function Have_With 298 (Library : in Compilation_Unit; 299 Unit : in Compilation_Unit) 334 (Library : in Compilation_Unit; 335 Unit : in Compilation_Unit; 336 The_Context : in Asis.Context) 300 337 return Boolean; 338 339 type Check_10_1_1_26c_26b_Information is record 340 Exceptions : Boolean := False; 341 System : Boolean := False; 342 end record; 343 344 function Check_10_1_1_26c_26b 345 (Unit : in Compilation_Unit; 346 The_Context : in Asis.Context) 347 return Check_10_1_1_26c_26b_Information; 301 348 302 349 ------------------------- … … 318 365 319 366 --------------------------------- 320 -- Semantic_Dependence_Order -- *367 -- Semantic_Dependence_Order -- 321 368 --------------------------------- 322 369 … … 356 403 Asis.Implementation.Set_Status 357 404 (Data_Error, "Semantic_Dependence_Order " 358 & Message & " invalid " & Unit_Full_Name (Unit));405 & Message & " invalid unit " & Unit_Full_Name (Unit)); 359 406 360 407 raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; … … 366 413 Asis.Implementation.Set_Status 367 414 (Data_Error, "Semantic_Dependence_Order " 368 & Message & " invalid context " & Unit_Full_Name (Unit));415 & Message & " invalid unit's context " & Unit_Full_Name (Unit)); 369 416 370 417 raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; … … 458 505 The_Context); 459 506 460 Utils.Check (Tree, Utils.Ascending, The_Context);461 declare462 Relation : Relationship := Utils.Generate_Relationship463 (Tree, null, 0, Utils.Ascending);464 begin465 Clear;466 return Relation;467 end;468 469 507 when Descendants => 470 508 Tree := Get_Descendants … … 472 510 (1 .. Compilation_Units_Last), The_Context); 473 511 474 Utils.Check (Tree, Utils.Ascending, The_Context);475 declare476 Relation : Relationship := Utils.Generate_Relationship477 (Tree, Normalized_Dependent_Units,478 Dependent_Units_Last, Utils.Descending);479 begin480 Clear;481 return Relation;482 end;483 484 512 when Supporters => 485 513 Tree := Get_Supporters … … 487 515 The_Context); 488 516 489 Utils.Check (Tree, Utils.Descending, The_Context);490 491 declare492 Relation : Relationship := Utils.Generate_Relationship493 (Tree, null, 0, Utils.Descending);494 begin495 Clear;496 return Relation;497 end;498 499 517 when Dependents => 500 518 Tree := Get_Dependents … … 502 520 The_Context); 503 521 504 Utils.Check (Tree, Utils.Ascending, The_Context);505 506 declare507 Relation : Relationship := Utils.Generate_Relationship508 (Tree, Normalized_Dependent_Units,509 Dependent_Units_Last, Utils.Descending);510 begin511 Clear;512 return Relation;513 end;514 515 522 when Family => 516 Clear; 517 518 Asis.Implementation.Set_Status 519 (Not_Implemented_Error, 520 "Semantic_Dependence_Order not implemented"); 521 raise Asis.Exceptions.ASIS_Failed; 523 Tree := Get_Family 524 (Normalized_Compilation_Units (1 .. Compilation_Units_Last), 525 The_Context); 522 526 523 527 when Needed_Units => 524 Clear; 525 526 Asis.Implementation.Set_Status 527 (Not_Implemented_Error, 528 "Semantic_Dependence_Order not implemented"); 529 raise Asis.Exceptions.ASIS_Failed; 528 Tree := Get_Needed_Units 529 (Normalized_Compilation_Units (1 .. Compilation_Units_Last), 530 The_Context); 530 531 end case; 532 533 Utils.Check (Tree, The_Context); 534 declare 535 Relation : Relationship := Utils.Generate_Relationship 536 (Tree, Normalized_Dependent_Units, Dependent_Units_Last); 537 begin 538 Clear; 539 return Relation; 540 end; 531 541 532 542 exception … … 550 560 Kinds : Unit_Kinds; 551 561 552 Result : Tree_Node_Access := null;553 Tmp_Tree : Tree_Node_Access := null; 554 Node : Tree_Node_Access := null;555 556 function Append_Node557 (Unit : in Compilation_Unit) 558 return Boolean;559 560 procedure Retrive_Declarations;562 Result : Tree_Node_Access := new Tree_Node; 563 564 procedure Append_Node 565 (Unit : in Compilation_Unit; 566 Node : in out Tree_Node_Access); 567 568 procedure Retrive 569 (Unit : in Compilation_Unit; 570 Node : in Tree_Node_Access); 561 571 562 572 -- Append_Node -- 563 function Append_Node 564 (Unit : in Compilation_Unit) 565 return Boolean 566 is 567 begin 568 if Result /= null then 569 Node := Find (Result.all, Unit); 573 procedure Append_Node 574 (Unit : in Compilation_Unit; 575 Node : in out Tree_Node_Access) 576 is 577 Exist_Node : Tree_Node_Access; 578 begin 579 Exist_Node := Find (Result.all, Unit); 580 581 if Exist_Node /= null then 582 Glue_Nodes (Result, Node, Exist_Node); 583 Node := null; 570 584 else 571 Node := null; 572 end if; 573 574 if Node /= null then 575 Add_Thread (Result, Node, Tmp_Tree); 576 return True; 577 else 578 Tmp_Tree := Append_Parent (Tmp_Tree, Unit); 579 return False; 585 Node := Add_Child (Result, Node, Unit); 580 586 end if; 581 587 end Append_Node; 582 588 583 -- Retrive_Declarations -- 584 procedure Retrive_Declarations is begin 585 while Unit_Kind (Unit) in 589 -- Retrive -- 590 procedure Retrive 591 (Unit : in Compilation_Unit; 592 Node : in Tree_Node_Access) 593 is 594 Internal_Node : Tree_Node_Access := Node; 595 Internal_Unit : Compilation_Unit := Unit; 596 begin 597 while Unit_Kind (Internal_Unit) in 586 598 A_Procedure .. A_Generic_Package_Renaming 587 599 loop 588 if Append_Node (Unit) then 600 Append_Node (Internal_Unit, Internal_Node); 601 if Internal_Node = null then 589 602 return; 590 603 end if; 591 604 592 Unit := Corresponding_Parent_Declaration (Unit);605 Internal_Unit := Corresponding_Parent_Declaration (Internal_Unit); 593 606 end loop; 594 607 595 if not Is_Nil (Unit) then 596 if Append_Node (Unit) then 608 if not Is_Nil (Internal_Unit) then 609 Append_Node (Internal_Unit, Internal_Node); 610 if Internal_Node = null then 597 611 return; 598 612 end if; 599 613 600 614 -- add Standart as root 601 if Append_Node 602 (Library_Unit_Declaration ("Standard", The_Context)) 603 then 604 return; 605 end if; 606 end if; 607 end Retrive_Declarations; 615 Append_Node 616 (Library_Unit_Declaration ("Standard", The_Context), 617 Internal_Node); 618 end if; 619 end Retrive; 608 620 609 621 begin 622 Dependence_Order (Result, Ascending); 623 610 624 for Index in List'Range loop 611 if Tmp_Tree /= null then612 Asis.Implementation.Set_Status613 (Asis.Errors.Internal_Error,614 "Bug (or inapropriate use) detected in "615 & "Asis.Compilation_Units.Relations.Semantic_Dependence_Order"616 & " (Ancestors)");617 618 raise Asis.Exceptions.ASIS_Failed;619 end if;620 621 625 Unit := List (Index); 622 626 623 if Result = null 624 or else Find (Result.all, Unit) = null 627 if Find (Result.all, Unit) = null 625 628 then 626 629 Kinds := Unit_Kind (Unit); … … 634 637 635 638 elsif Kinds in A_Library_Unit_Body then 636 Tmp_Tree := new Tree_Node;637 639 Unit := Corresponding_Parent_Declaration (Unit, The_Context); 638 Retrive_Declarations; 639 else 640 Tmp_Tree := new Tree_Node; 641 Retrive_Declarations; 642 end if; 643 644 if Result = null then 645 Result := Tmp_Tree; 646 Tmp_Tree := null; 647 end if; 640 end if; 641 642 Retrive (Unit, null); 648 643 end if; 649 644 end loop; 650 645 651 Deallocate (Tmp_Tree);652 646 return Result; 653 647 exception 654 648 when others => 655 Deallocate (Tmp_Tree);656 649 Deallocate (Result); 657 650 raise; … … 683 676 Node : in Utils.Tree_Node_Access) 684 677 is 678 Exist_Node : Utils.Tree_Node_Access := null; 679 685 680 Children_List : Asis.Compilation_Unit_List := 686 Corresponding_Children (Target, The_Context); 687 Exist_Node : Utils.Tree_Node_Access := null; 681 Corresponding_Children (Target, The_Context); 688 682 689 683 -- Process -- … … 693 687 is 694 688 begin 695 if Is_Nil (Unit) then 696 return False; 697 end if; 698 699 Kinds := Unit_Kind (Unit); 700 Exist_Node := Find (Result.all, Unit); 689 Kinds := Unit_Kind (Unit); 690 Exist_Node := Find (Result.all, Unit); 691 Second_Unit := Nil_Compilation_Unit; 701 692 702 693 if Exist_Node /= null then 703 694 Glue_Nodes (Result, Node, Exist_Node); 704 Second_Unit := Nil_Compilation_Unit;705 695 706 696 if Kinds in A_Procedure .. A_Generic_Package then … … 729 719 730 720 if not Is_Nil (Second_Unit) 731 and then not Is_Identical (Second_Unit, Unit) then 732 Exist_Node := Add_Child_Body 733 (Result, Node, Unit, Second_Unit); 734 721 and then not Is_Identical (Second_Unit, Unit) 722 then 723 Exist_Node := Add_Child (Result, Node, Unit, Second_Unit); 735 724 Remove_From_List (Children_List, Index + 1, Second_Unit); 736 725 else … … 744 733 and then not Is_Identical (Second_Unit, Unit) 745 734 then 746 Exist_Node := Add_Child_Body 747 (Result, Node, Second_Unit, Unit); 735 Exist_Node := Add_Child (Result, Node, Second_Unit, Unit); 748 736 749 737 Remove_From_List (Children_List, Index + 1, Second_Unit); … … 785 773 786 774 begin 775 Dependence_Order (Result, Descending); 776 787 777 Declarations_List := new Asis.Compilation_Unit_List (1 .. List'Length); 788 778 … … 791 781 Kinds := Unit_Kind (Unit); 792 782 793 -- eliminate A_Subunit794 if Kinds not in A_Subunit then795 if Kinds in A_Library_Unit_Body then796 -- get declaration (spec+body)797 Unit := Corresponding_Declaration (Unit);798 Kinds := Unit_Kind (Unit); 799 end if;800 801 if Kinds = A_Package802 or else Kinds = A_Generic_Package803 or else Kinds = A_Package_Instance 804 then805 if not In_List806 (Declarations_List, Declarations_Last, Unit)807 then808 Declarations_Last := Declarations_Last + 1;809 Declarations_List (Declarations_Last) := Unit;810 end if;783 if Kinds in A_Subunit then 784 Asis.Implementation.Set_Status 785 (Data_Error, "Subunit not valid for Descendants request " 786 & Unit_Full_Name (Unit)); 787 end if; 788 789 if Kinds in A_Library_Unit_Body then 790 Unit := Corresponding_Declaration (Unit); 791 Kinds := Unit_Kind (Unit); 792 end if; 793 794 if Kinds = A_Package 795 or else Kinds = A_Generic_Package 796 or else Kinds = A_Package_Instance 797 then 798 if not In_List (Declarations_List, Declarations_Last, Unit) then 799 Declarations_Last := Declarations_Last + 1; 800 Declarations_List (Declarations_Last) := Unit; 811 801 end if; 812 802 end if; … … 819 809 Second_Unit := Corresponding_Body (Unit, The_Context); 820 810 821 if not Is_Identical (Second_Unit, Unit) then 822 Retrive 823 (Unit, Add_Child_Body (Result, null, Unit, Second_Unit)); 811 if not Is_Nil (Second_Unit) 812 and then not Is_Identical (Second_Unit, Unit) 813 then 814 Retrive (Unit, Add_Child (Result, null, Unit, Second_Unit)); 824 815 else 825 816 Retrive (Unit, Add_Child (Result, null, Unit)); … … 857 848 Std : Compilation_Unit := Library_Unit_Declaration ("Standard", The_Context); 858 849 859 procedure Append_Standart 860 (Node : in Tree_Node_Access); 850 procedure Append_Unit 851 (Unit : in Compilation_Unit; 852 Node : in out Tree_Node_Access); 861 853 862 854 procedure Retrive … … 880 872 881 873 procedure Retrive_With_Clause 882 (Unit : in Compilation_Unit; 883 Node : in Tree_Node_Access); 874 (Unit : in Compilation_Unit; 875 Node : in Tree_Node_Access; 876 For_Body : in Boolean := False); 884 877 885 878 procedure Check_10_1_1_26c_26b 886 (Unit : in Compilation_Unit; 887 Node : in Tree_Node_Access); 888 889 -- Append_Standart -- 890 procedure Append_Standart 891 (Node : in Tree_Node_Access) 879 (Unit : in Compilation_Unit; 880 Node : in Tree_Node_Access; 881 For_Body : in Boolean := False); 882 883 -- Append_Unit -- 884 procedure Append_Unit 885 (Unit : in Compilation_Unit; 886 Node : in out Tree_Node_Access) 892 887 is 893 888 Exist_Node : Tree_Node_Access; 894 889 begin 895 Exist_Node := Find (Result.all, Std);890 Exist_Node := Find (Result.all, Unit); 896 891 897 892 if Exist_Node = null then 898 Exist_Node := Add_Child (Result, Node, Std);893 Node := Add_Child (Result, Node, Unit); 899 894 else 900 895 if Node /= null then 901 896 Glue_Nodes_Checked (Result, Node, Exist_Node); 902 end if; 903 end if; 904 end Append_Standart; 897 Node := null; 898 end if; 899 end if; 900 end Append_Unit; 905 901 906 902 -- Retrive -- … … 910 906 First_Node : in Boolean := False) 911 907 is 908 Internal_Node : Tree_Node_Access := Node; 912 909 begin 913 910 if Is_Nil (Unit) then … … 918 915 919 916 if Kinds in A_Nonexistent_Declaration .. An_Unknown_Unit then 920 Append_ Standart (Node);917 Append_Unit (Std, Internal_Node); 921 918 922 919 elsif Kinds in A_Subunit then … … 937 934 First_Node : in Boolean) 938 935 is 939 Parent : Compilation_Unit; 940 vNode : Tree_Node_Access := Node; 941 Exist_Node : Tree_Node_Access; 936 Parent : Compilation_Unit; 937 Internal_Node : Tree_Node_Access := Node; 942 938 begin 943 939 if not First_Node then 944 Exist_Node := Find (Result.all, Unit); 945 946 if Exist_Node = null then 947 vNode := Add_Child (Result, vNode, Unit); 948 949 if Is_Identical (Unit, Std) then 950 return; 951 end if; 952 953 Check_10_1_1_26c_26b (Unit, vNode); 954 Retrive_With_Clause (Unit, vNode); 955 else 956 if vNode /= null then 957 Glue_Nodes_Checked (Result, vNode, Exist_Node); 958 return; 959 end if; 960 end if; 961 else 962 if Is_Identical (Unit, Std) then 940 Append_Unit (Unit, Internal_Node); 941 942 if Internal_Node = null then 963 943 return; 964 944 end if; 965 966 Check_10_1_1_26c_26b (Unit, vNode); 967 Retrive_With_Clause (Unit, vNode); 968 end if; 945 end if; 946 947 if Is_Identical (Unit, Std) then 948 return; 949 end if; 950 951 Check_10_1_1_26c_26b (Unit, Internal_Node); 952 Retrive_With_Clause (Unit, Internal_Node); 969 953 970 954 Parent := Corresponding_Parent_Declaration (Unit, The_Context); … … 973 957 A_Procedure .. A_Generic_Package_Renaming 974 958 loop 975 Exist_Node := Find (Result.all, Parent); 976 977 if Exist_Node = null then 978 vNode := Add_Child (Result, vNode, Parent); 979 Check_10_1_1_26c_26b (Parent, vNode); 980 Retrive_With_Clause (Parent, vNode); 981 else 982 if vNode /= null then 983 Glue_Nodes_Checked (Result, vNode, Exist_Node); 984 return; 985 end if; 986 end if; 959 Append_Unit (Parent, Internal_Node); 960 961 if Internal_Node = null 962 or else Is_Identical (Unit, Std) 963 then 964 return; 965 end if; 966 967 Check_10_1_1_26c_26b (Parent, Internal_Node); 968 Retrive_With_Clause (Parent, Internal_Node); 987 969 988 970 Parent := Corresponding_Parent_Declaration (Parent, The_Context); 989 971 end loop; 990 972 991 Retrive (Parent, vNode);973 Retrive (Parent, Internal_Node); 992 974 end Retrive_Declarations; 993 975 … … 998 980 First_Node : in Boolean) 999 981 is 1000 Exist_Node : Tree_Node_Access := Node;982 Internal_Node : Tree_Node_Access := Node; 1001 983 begin 1002 984 if not First_Node then 1003 Exist_Node := Find (Result.all, Unit); 1004 1005 if Exist_Node = null then 1006 Exist_Node := Add_Child (Result, Node, Unit); 1007 Check_10_1_1_26c_26b (Unit, Exist_Node); 1008 Retrive_With_Clause (Unit, Exist_Node); 1009 else 1010 if Node /= null then 1011 Glue_Nodes_Checked (Result, Node, Exist_Node); 1012 return; 1013 end if; 1014 end if; 1015 else 1016 Check_10_1_1_26c_26b (Unit, Node); 1017 Retrive_With_Clause (Unit, Node); 1018 end if; 985 Append_Unit (Unit, Internal_Node); 986 987 if Internal_Node = null then 988 return; 989 end if; 990 end if; 991 992 Check_10_1_1_26c_26b (Unit, Internal_Node, True); 993 Retrive_With_Clause (Unit, Internal_Node, True); 1019 994 1020 995 Retrive 1021 996 (Corresponding_Parent_Declaration (Unit, The_Context), 1022 Exist_Node);997 Internal_Node); 1023 998 end Retrive_Body; 1024 999 … … 1028 1003 Node : in Tree_Node_Access) 1029 1004 is 1030 Parent : Compilation_Unit;1031 vNode : Tree_Node_Access := Node;1032 Exist_Node : Tree_Node_Access;1033 begin1034 Check_10_1_1_26c_26b (Unit, null);1035 Retrive_With_Clause (Unit, null); 1005 Parent : Compilation_Unit; 1006 vNode : Tree_Node_Access := Node; 1007 begin 1008 Check_10_1_1_26c_26b (Unit, null, True); 1009 Retrive_With_Clause (Unit, null, True); 1010 1036 1011 Parent := Corresponding_Subunit_Parent_Body (Unit); 1037 1012 1038 1013 while Unit_Kind (Parent) in A_Subunit loop 1039 Exist_Node := Find (Result.all, Parent); 1040 1041 if Exist_Node = null then 1042 vNode := Add_Child (Result, vNode, Parent); 1043 Check_10_1_1_26c_26b (Parent, vNode); 1044 Retrive_With_Clause (Parent, vNode); 1045 else 1046 if vNode /= null then 1047 Glue_Nodes_Checked (Result, vNode, Exist_Node); 1048 return; 1049 end if; 1050 end if; 1014 Append_Unit (Unit, vNode); 1015 1016 if vNode = null then 1017 return; 1018 end if; 1019 1020 Check_10_1_1_26c_26b (Parent, vNode, True); 1021 Retrive_With_Clause (Parent, vNode, True); 1051 1022 1052 1023 Parent := Corresponding_Subunit_Parent_Body (Parent); … … 1058 1029 -- Retrive_With_Clause -- 1059 1030 procedure Retrive_With_Clause 1060 (Unit : in Compilation_Unit; 1061 Node : in Tree_Node_Access) 1031 (Unit : in Compilation_Unit; 1032 Node : in Tree_Node_Access; 1033 For_Body : in Boolean := False) 1062 1034 is 1063 1035 With_List : constant Asis.Context_Clause_List := … … 1065 1037 1066 1038 Internal_Unit : Compilation_Unit; 1039 Exist_Node : Tree_Node_Access; 1067 1040 begin 1068 1041 for Index in With_List'Range loop 1069 1042 if Clause_Kind (With_List (Index).all) = A_With_Clause then 1070 1043 1071 Internal_Unit := Get_Compilation_Unit (With_List (Index));1072 1073 -- Send warning if null !!! 1044 Internal_Unit := Get_Compilation_Unit 1045 (Unit, With_List (Index), Index, The_Context); 1046 1074 1047 if not Is_Nil (Internal_Unit) then 1075 Retrive (Internal_Unit, Node); 1048 if not For_Body then 1049 Retrive (Internal_Unit, Node); 1050 else 1051 Exist_Node := Find (Result.all, Internal_Unit); 1052 1053 if Exist_Node = null then 1054 Exist_Node := Add_Child (Result, null, Internal_Unit); 1055 1056 if Node /= null then 1057 Add_Body_Dependents (Exist_Node, Node); 1058 end if; 1059 1060 Retrive (Internal_Unit, Exist_Node, True); 1061 else 1062 if Node /= null then 1063 Add_Body_Dependents (Exist_Node, Node); 1064 end if; 1065 end if; 1066 end if; 1076 1067 end if; 1077 1068 end if; … … 1081 1072 -- Check_10_1_1_26c_26b -- 1082 1073 procedure Check_10_1_1_26c_26b 1083 (Unit : in Compilation_Unit; 1084 Node : in Tree_Node_Access) 1085 is 1086 -- 10.1.1 (26.c) 1087 -- 10.1.1 (26.b) 1088 1074 (Unit : in Compilation_Unit; 1075 Node : in Tree_Node_Access; 1076 For_Body : in Boolean := False) 1077 is 1089 1078 Except : Compilation_Unit := Library_Unit_Declaration 1090 1079 ("Ada.Exceptions", The_Context); … … 1093 1082 ("System", The_Context); 1094 1083 1095 Is_Except : Boolean; 1096 Is_Sys : Boolean; 1097 1098 type State_Information is record 1099 Exceptions : Boolean := False; 1100 System : Boolean := False; 1101 end record; 1102 1103 Control : Traverse_Control := Continue; 1104 State : State_Information; 1105 1106 procedure Pre_Operation 1107 (Element : in Asis.Element; 1108 Control : in out Traverse_Control; 1109 State : in out State_Information) 1084 State : Check_10_1_1_26c_26b_Information; 1085 1086 -- Retrive_For_Body -- 1087 procedure Retrive_For_Body 1088 (Unit : in Compilation_Unit) 1110 1089 is 1111 use Asis.Elements;1090 Exist_Node : Tree_Node_Access; 1112 1091 begin 1113 if not Is_Except 1114 and then Declaration_Kind (Element) = 1115 A_Choice_Parameter_Specification 1116 then 1117 State.Exceptions := True; 1118 end if; 1119 1120 if not Is_Sys 1121 and then Expression_Kind (Element) = An_Attribute_Reference 1122 and then Attribute_Kind (Element) = An_Address_Attribute 1123 then 1124 State.System := True; 1125 end if; 1126 end Pre_Operation; 1127 1128 procedure Post_Operation 1129 (Element : in Asis.Element; 1130 Control : in out Traverse_Control; 1131 State : in out State_Information) 1132 is 1133 begin 1134 null; 1135 end Post_Operation; 1136 1137 procedure Check_Choice_Iterator is new 1138 Asis.Iterator.Traverse_Element 1139 (State_Information, Pre_Operation, Post_Operation); 1140 1141 begin 1142 Is_Except := Is_Identical (Unit, Except); 1143 Is_Sys := Is_Identical (Unit, Sys); 1144 1145 Check_Choice_Iterator 1146 (Asis.Elements.Unit_Declaration (Unit), Control, State); 1092 Exist_Node := Find (Result.all, Unit); 1093 1094 if Exist_Node = null then 1095 Exist_Node := Add_Child (Result, null, Unit); 1096 1097 if Node /= null then 1098 Add_Body_Dependents (Exist_Node, Node); 1099 end if; 1100 1101 Retrive (Unit, Exist_Node, True); 1102 else 1103 if Node /= null then 1104 Add_Body_Dependents (Exist_Node, Node); 1105 end if; 1106 end if; 1107 end Retrive_For_Body; 1108 1109 begin 1110 State := Check_10_1_1_26c_26b (Unit, The_Context); 1147 1111 1148 1112 if State.Exceptions then 1149 Retrive (Except, Node); 1113 if not For_Body then 1114 Retrive (Except, Node); 1115 else 1116 Retrive_For_Body (Except); 1117 end if; 1150 1118 end if; 1151 1119 1152 1120 if State.System then 1153 Retrive (Sys, Node); 1121 if not For_Body then 1122 Retrive (Sys, Node); 1123 else 1124 Retrive_For_Body (Sys); 1125 end if; 1154 1126 end if; 1155 1127 end Check_10_1_1_26c_26b; 1156 1128 1157 1129 begin 1130 Dependence_Order (Result, Ascending); 1131 1158 1132 for Index in List'Range loop 1159 1133 Unit := List (Index); … … 1207 1181 if Kinds in A_Procedure .. A_Generic_Package then 1208 1182 if Exist_Node /= null then 1209 Glue_Nodes_Checked (Result, Node, Exist_Node); 1183 if Is_Child (Result, Exist_Node) then 1184 Set_Parent (Result, Exist_Node, Node); 1185 else 1186 Glue_Nodes_Checked (Result, Node, Exist_Node); 1187 end if; 1210 1188 1211 1189 if not Is_Skip_Spec (Exist_Node) then … … 1216 1194 else 1217 1195 Second_Unit := Corresponding_Body (Unit, The_Context); 1218 Exist_Node := Add_Child _Body(Result, Node, Unit, Second_Unit);1196 Exist_Node := Add_Child (Result, Node, Unit, Second_Unit); 1219 1197 end if; 1220 1198 1221 1199 elsif Kinds in A_Library_Unit_Body then 1222 1200 if Exist_Node /= null then 1223 Glue_Nodes_Checked (Result, Node, Exist_Node); 1224