Changeset 2626
- Timestamp:
- 02/19/08 18:03:33 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tendra/src/producers/ada/asis/asis-compilation_units-relations.adb
r2620 r2626 15 15 ------------------------------------------------------------------------------ 16 16 17 with Ada.Finalization; 18 with Ada.Unchecked_Deallocation; 19 with System; 20 17 21 with Asis.Errors; use Asis.Errors; 18 22 with Asis.Exceptions; 19 23 with Asis.Implementation; 24 with Asis.Elements; 20 25 with Asis.Ada_Environments; 21 22 with Ada.Finalization; 23 with Ada.Unchecked_Deallocation; 24 with System; 26 with Asis.Clauses; 27 with Asis.Expressions; 28 with Asis.Iterator; 25 29 26 30 package body Asis.Compilation_Units.Relations is … … 63 67 type Tree_Node_Access is access all Tree_Node; 64 68 65 function Is_Empty 66 (This : in Tree_Node) 69 type Tree_Node_Array is array (Positive range <>) of Tree_Node_Access; 70 type Tree_Node_Array_Access is access all Tree_Node_Array; 71 72 procedure Deallocate is 73 new Ada.Unchecked_Deallocation 74 (Tree_Node_Array, Tree_Node_Array_Access); 75 76 function Append 77 (List : in Tree_Node_Array_Access; 78 Node : in Tree_Node_Access) 79 return Tree_Node_Array_Access; 80 81 function In_List 82 (List : in Tree_Node_Array_Access; 83 Last : in Natural; 84 Node : in Tree_Node_Access) 67 85 return Boolean; 68 86 … … 80 98 (This : in Tree_Node_Access; 81 99 Node : in Tree_Node_Access; 100 Spec_Unit : in Compilation_Unit) 101 return Tree_Node_Access; 102 103 function Add_Child_Body 104 (This : in Tree_Node_Access; 105 Node : in Tree_Node_Access; 82 106 Spec_Unit : in Compilation_Unit; 83 Body_Unit : in Compilation_Unit) 107 Body_Unit : in Compilation_Unit; 108 Skip_Spec : in Boolean := False) 84 109 return Tree_Node_Access; 85 110 … … 89 114 To_Node : in Tree_Node_Access); 90 115 116 procedure Glue_Nodes_Checked 117 (This : in Tree_Node_Access; 118 Node : in Tree_Node_Access; 119 To_Node : in Tree_Node_Access); 120 91 121 procedure Clear 92 122 (This : in out Tree_Node); … … 100 130 101 131 procedure Check 102 (This : in Tree_Node_Access; 103 Order : in Orders); 132 (This : in Tree_Node_Access; 133 Order : in Orders; 134 The_Context : in Asis.Context); 104 135 105 136 function Generate_Relationship … … 110 141 return Relationship; 111 142 143 function Is_Skip_Spec 144 (This : in Tree_Node_Access) 145 return Boolean; 146 147 procedure Skip_Spec 148 (This : in Tree_Node_Access; 149 Value : in Boolean); 150 151 function Nexts 152 (This : in Tree_Node_Access) 153 return Tree_Node_Array_Access; 154 155 function Spec 156 (This : in Tree_Node_Access) 157 return Compilation_Unit; 158 112 159 Use_Error : exception; 113 160 114 161 private 115 116 type Tree_Node_Array is array (Positive range <>) of Tree_Node_Access;117 type Tree_Node_Array_Access is access all Tree_Node_Array;118 162 119 163 type Unit_Node is record … … 130 174 131 175 -- ÑÑÑлка Ма пÑеЎÑÐŽÑÑОй ÐµÐ»ÐµÐŒÐµÐœÑ 132 Prev : Tree_Node_Access := null; 176 Prev : Tree_Node_Access := null; 177 Prevs : Tree_Node_Array_Access := null; 133 178 134 179 -- ЌПЎÑлÑ_кПЌпОлÑÑОО 135 180 Unit : Compilation_Unit := Nil_Compilation_Unit; 136 181 Unit_Body : Compilation_Unit := Nil_Compilation_Unit; 182 Skip_Spec : Boolean := False; 137 183 138 184 Added : Boolean := False; … … 178 224 (This : in out Tree_Node); 179 225 180 function Set_Inconsistent181 (This : in Tree_Node_Access;182 List : in Compilation_Unit_List_Access;183 Order : in Orders)184 return Compilation_Unit_List_Access;185 186 226 procedure Deallocate is 187 227 new Ada.Unchecked_Deallocation … … 194 234 Node : in Tree_Node_Access) 195 235 return Tree_Node_Array_Access; 236 237 procedure Remove 238 (List : in out Tree_Node_Array_Access; 239 Node : in Tree_Node_Access); 196 240 197 241 function Add_Node_Ordered … … 241 285 The_Context : in Asis.Context) 242 286 return Utils.Tree_Node_Access; 287 288 function Get_Dependents 289 (List : in Asis.Compilation_Unit_List; 290 The_Context : in Asis.Context) 291 return Utils.Tree_Node_Access; 292 293 function Get_Compilation_Unit 294 (Target : in Asis.Element) 295 return Asis.Compilation_Unit; 296 297 function Have_With 298 (Library : in Compilation_Unit; 299 Unit : in Compilation_Unit) 300 return Boolean; 243 301 244 302 ------------------------- … … 272 330 Current_Unit_Kind : Asis.Unit_Kinds; 273 331 332 procedure Check_Compilation_Unit 333 (Unit : in Compilation_Unit; 334 Message : in Wide_String); 335 336 procedure Normalize 337 (List : in Asis.Compilation_Unit_List; 338 Result : in Utils.Compilation_Unit_List_Access; 339 Last : out ASIS_Integer); 340 341 procedure Clear; 342 274 343 -- Check_Compilation_Unit -- 275 344 procedure Check_Compilation_Unit … … 287 356 Asis.Implementation.Set_Status 288 357 (Data_Error, "Semantic_Dependence_Order " 289 & Message & " invalid ");358 & Message & " invalid " & Unit_Full_Name (Unit)); 290 359 291 360 raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; … … 297 366 Asis.Implementation.Set_Status 298 367 (Data_Error, "Semantic_Dependence_Order " 299 & Message & " invalid context ");368 & Message & " invalid context " & Unit_Full_Name (Unit)); 300 369 301 370 raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; … … 339 408 Tree : Utils.Tree_Node_Access := null; 340 409 341 procedure Clear is 342 begin 410 procedure Clear is begin 343 411 Deallocate (Tree); 344 412 Utils.Deallocate (Normalized_Compilation_Units); … … 367 435 -- Dependent_Units are ignored unless the Relation 368 436 -- is Descendants or Dependents 369 if Relation = Descendants370 or else Relation = Dependents437 if (Relation = Descendants or else Relation = Dependents) 438 and then Dependent_Units /= Nil_Compilation_Unit_List 371 439 then 372 440 for Index in Dependent_Units'Range loop … … 390 458 The_Context); 391 459 392 Utils.Check (Tree, Utils.Ascending );460 Utils.Check (Tree, Utils.Ascending, The_Context); 393 461 declare 394 462 Relation : Relationship := Utils.Generate_Relationship … … 401 469 when Descendants => 402 470 Tree := Get_Descendants 403 (Normalized_Compilation_Units (1 .. Compilation_Units_Last), The_Context); 404 405 Utils.Check (Tree, Utils.Ascending); 471 (Normalized_Compilation_Units 472 (1 .. Compilation_Units_Last), The_Context); 473 474 Utils.Check (Tree, Utils.Ascending, The_Context); 406 475 declare 407 476 Relation : Relationship := Utils.Generate_Relationship 408 (Tree, Normalized_Dependent_Units, Dependent_Units_Last, Utils.Descending); 477 (Tree, Normalized_Dependent_Units, 478 Dependent_Units_Last, Utils.Descending); 409 479 begin 410 480 Clear; … … 417 487 The_Context); 418 488 419 Asis.Implementation.Set_Status 420 (Not_Implemented_Error, 421 "Semantic_Dependence_Order not implemented"); 422 423 raise Asis.Exceptions.ASIS_Failed; 489 Utils.Check (Tree, Utils.Descending, The_Context); 490 491 declare 492 Relation : Relationship := Utils.Generate_Relationship 493 (Tree, null, 0, Utils.Descending); 494 begin 495 Clear; 496 return Relation; 497 end; 424 498 425 499 when Dependents => 426 Asis.Implementation.Set_Status 427 (Not_Implemented_Error, 428 "Semantic_Dependence_Order not implemented"); 429 430 raise Asis.Exceptions.ASIS_Failed; 500 Tree := Get_Dependents 501 (Normalized_Compilation_Units (1 .. Compilation_Units_Last), 502 The_Context); 503 504 Utils.Check (Tree, Utils.Ascending, The_Context); 505 506 declare 507 Relation : Relationship := Utils.Generate_Relationship 508 (Tree, Normalized_Dependent_Units, 509 Dependent_Units_Last, Utils.Descending); 510 begin 511 Clear; 512 return Relation; 513 end; 431 514 432 515 when Family => 516 Clear; 517 433 518 Asis.Implementation.Set_Status 434 519 (Not_Implemented_Error, … … 437 522 438 523 when Needed_Units => 524 Clear; 525 439 526 Asis.Implementation.Set_Status 440 527 (Not_Implemented_Error, … … 442 529 raise Asis.Exceptions.ASIS_Failed; 443 530 end case; 444 445 Clear;446 return Nil_Relationship;447 531 448 532 exception … … 470 554 Node : Tree_Node_Access := null; 471 555 556 function Append_Node 557 (Unit : in Compilation_Unit) 558 return Boolean; 559 560 procedure Retrive_Declarations; 561 472 562 -- Append_Node -- 473 563 function Append_Node … … 492 582 493 583 -- Retrive_Declarations -- 494 procedure Retrive_Declarations is 495 begin 496 while Unit_Kind (Unit) in A_Procedure .. A_Generic_Package_Renaming loop 584 procedure Retrive_Declarations is begin 585 while Unit_Kind (Unit) in 586 A_Procedure .. A_Generic_Package_Renaming 587 loop 497 588 if Append_Node (Unit) then 498 589 return; … … 515 606 end if; 516 607 end Retrive_Declarations; 517 518 -- Retrive_Subunit --519 -- procedure Retrive_Subunit is520 -- begin521 -- if Append_Node (Unit) then522 -- return;523 -- end if;524 525 -- loop526 -- Unit := Corresponding_Subunit_Parent_Body (Unit);527 528 -- if Append_Node (Unit) then529 -- return;530 -- end if;531 532 -- exit when Unit_Kind (Unit) not in A_Subunit;533 -- end loop;534 535 -- if Unit_Kind (Unit) /= A_Nonexistent_Body then536 -- Unit := Corresponding_Parent_Declaration (Unit, The_Context);537 -- Retrive_Declarations;538 -- else539 -- add Standart as root540 -- if Append_Node541 -- (Library_Unit_Declaration ("Standard", The_Context))542 -- then543 -- return;544 -- end if;545 -- end if;546 -- end Retrive_Subunit;547 608 548 609 begin … … 552 613 (Asis.Errors.Internal_Error, 553 614 "Bug (or inapropriate use) detected in " 554 & "Asis.Compilation_Units.Relations.Semantic_Dependence_Order(Ancestors)"); 615 & "Asis.Compilation_Units.Relations.Semantic_Dependence_Order" 616 & " (Ancestors)"); 555 617 556 618 raise Asis.Exceptions.ASIS_Failed; 557 619 end if; 558 620 559 Tmp_Tree := new Tree_Node; 560 561 Unit := List (Index); 562 Kinds := Unit_Kind (Unit); 563 564 if Kinds in A_Subunit then 565 -- Retrive_Subunit; 566 null; 567 568 elsif Kinds in A_Library_Unit_Body then 569 Unit := Corresponding_Parent_Declaration (Unit, The_Context); 570 Retrive_Declarations; 571 572 else 573 Retrive_Declarations; 574 end if; 575 576 if Result = null then 577 Result := Tmp_Tree; 578 Tmp_Tree := null; 621 Unit := List (Index); 622 623 if Result = null 624 or else Find (Result.all, Unit) = null 625 then 626 Kinds := Unit_Kind (Unit); 627 628 if Kinds in A_Subunit then 629 Asis.Implementation.Set_Status 630 (Data_Error, "Subunit not valid for Ancestors request " 631 & Unit_Full_Name (Unit)); 632 633 raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; 634 635 elsif Kinds in A_Library_Unit_Body then 636 Tmp_Tree := new Tree_Node; 637 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; 579 648 end if; 580 649 end loop; … … 605 674 Kinds : Unit_Kinds; 606 675 676 procedure Retrive 677 (Target : in Compilation_Unit; 678 Node : in Utils.Tree_Node_Access); 679 607 680 -- Retrive -- 608 681 procedure Retrive … … 624 697 end if; 625 698 699 Kinds := Unit_Kind (Unit); 626 700 Exist_Node := Find (Result.all, Unit); 627 701 628 702 if Exist_Node /= null then 629 703 Glue_Nodes (Result, Node, Exist_Node); 704 Second_Unit := Nil_Compilation_Unit; 705 706 if Kinds in A_Procedure .. A_Generic_Package then 707 Second_Unit := Corresponding_Body (Unit, The_Context); 708 709 elsif Kinds in A_Library_Unit_Body then 710 Second_Unit := Corresponding_Declaration (Unit, The_Context); 711 end if; 712 713 if not Is_Nil (Second_Unit) 714 and then not Is_Identical (Second_Unit, Unit) 715 then 716 Remove_From_List (Children_List, Index + 1, Second_Unit); 717 end if; 718 630 719 return False; 631 720 end if; 632 633 Kinds := Unit_Kind (Unit);634 721 635 722 if Kinds in 636 723 A_Procedure_Instance .. A_Generic_Package_Renaming 637 724 then 638 Exist_Node := Add_Child (Result, Node, Unit , null);725 Exist_Node := Add_Child (Result, Node, Unit); 639 726 640 727 elsif Kinds in A_Procedure .. A_Generic_Package then 641 728 Second_Unit := Corresponding_Body (Unit, The_Context); 642 729 643 if not Is_Identical (Second_Unit, Nil_Compilation_Unit) 730 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 735 Remove_From_List (Children_List, Index + 1, Second_Unit); 736 else 737 Exist_Node := Add_Child (Result, Node, Unit); 738 end if; 739 740 elsif Kinds in A_Library_Unit_Body then 741 Second_Unit := Corresponding_Declaration (Unit, The_Context); 742 743 if not Is_Nil (Second_Unit) 644 744 and then not Is_Identical (Second_Unit, Unit) 645 745 then 646 Exist_Node := Add_Child (Result, Node, Unit, Second_Unit); 647 Remove_From_List (Children_List, Index + 1, Second_Unit); 648 else 649 Exist_Node := Add_Child (Result, Node, Unit, null); 650 end if; 651 652 elsif Kinds in A_Library_Unit_Body then 653 Second_Unit := Corresponding_Declaration (Unit, The_Context); 654 655 if not Is_Identical (Second_Unit, Nil_Compilation_Unit) 656 and then not Is_Identical (Second_Unit, Unit) 657 then 658 Exist_Node := Add_Child (Result, Node, Second_Unit, Unit); 746 Exist_Node := Add_Child_Body 747 (Result, Node, Second_Unit, Unit); 748 659 749 Remove_From_List (Children_List, Index + 1, Second_Unit); 660 750 Unit := Second_Unit; 661 751 else 662 Exist_Node := Add_Child (Result, Node, Unit , null);752 Exist_Node := Add_Child (Result, Node, Unit); 663 753 end if; 664 754 665 755 else 666 Exist_Node := Add_Child (Result, Node, Unit , null);756 Exist_Node := Add_Child (Result, Node, Unit); 667 757 end if; 668 758 … … 674 764 Unit := Children_List (Index); 675 765 676 if Process (Index) then 677 Kinds := Unit_Kind (Unit); 678 679 if Kinds = A_Package 680 or else Kinds = A_Generic_Package 681 or else Kinds = A_Package_Instance 682 then 683 Retrive (Unit, Exist_Node); 766 if not Is_Nil (Unit) then 767 if Process (Index) then 768 Kinds := Unit_Kind (Unit); 769 770 if Kinds = A_Package 771 or else Kinds = A_Generic_Package 772 or else Kinds = A_Package_Instance 773 then 774 Retrive (Unit, Exist_Node); 775 end if; 684 776 end if; 685 777 end if; … … 688 780 689 781 Declarations_List : 690 Utils.Compilation_Unit_List_Access := null; 782 Utils.Compilation_Unit_List_Access := null; 783 691 784 Declarations_Last : ASIS_Integer := 0; 692 785 … … 701 794 if Kinds not in A_Subunit then 702 795 if Kinds in A_Library_Unit_Body then 703 -- get declaration 796 -- get declaration (spec+body) 704 797 Unit := Corresponding_Declaration (Unit); 705 798 Kinds := Unit_Kind (Unit); … … 726 819 Second_Unit := Corresponding_Body (Unit, The_Context); 727 820 728 if not Is_Identical (Second_Unit, Nil_Compilation_Unit) 729 and then not Is_Identical (Second_Unit, Unit) 730 then 731 Retrive (Unit, Add_Child (Result, null, Unit, Second_Unit)); 821 if not Is_Identical (Second_Unit, Unit) then 822 Retrive 823 (Unit, Add_Child_Body (Result, null, Unit, Second_Unit)); 732 824 else 733 Retrive (Unit, Add_Child (Result, null, Unit , null));825 Retrive (Unit, Add_Child (Result, null, Unit)); 734 826 end if; 735 827 end if; … … 757 849 use Utils; 758 850 759 --Unit : Compilation_Unit;760 --Kinds : Unit_Kinds;851 Unit : Compilation_Unit; 852 Kinds : Unit_Kinds; 761 853 762 854 Result : Tree_Node_Access := new Tree_Node; 763 -- Node : Tree_Node_Access := null; 855 Node : Tree_Node_Access := null; 856 857 Std : Compilation_Unit := Library_Unit_Declaration ("Standard", The_Context); 858 859 procedure Append_Standart 860 (Node : in Tree_Node_Access); 861 862 procedure Retrive 863 (Unit : in Compilation_Unit; 864 Node : in Tree_Node_Access; 865 First_Node : in Boolean := False); 866 867 procedure Retrive_Declarations 868 (Unit : in Compilation_Unit; 869 Node : in Tree_Node_Access; 870 First_Node : in Boolean); 871 872 procedure Retrive_Body 873 (Unit : in Compilation_Unit; 874 Node : in Tree_Node_Access; 875 First_Node : in Boolean); 876 877 procedure Retrive_Subunit 878 (Unit : in Compilation_Unit; 879 Node : in Tree_Node_Access); 880 881 procedure Retrive_With_Clause 882 (Unit : in Compilation_Unit; 883 Node : in Tree_Node_Access); 884 885 procedure Check_10_1_1_26c_26b 886 (Unit : in Compilation_Unit; 887 Node : in Tree_Node_Access); 764 888 765 889 -- Append_Standart -- 766 -- procedure Append_Standart 767 -- (Node : in Tree_Node_Access) 768 -- is 769 -- Std : Compilation_Unit := Library_Unit_Declaration 770 -- ("Standard", The_Context); 771 772 -- Exist_Node : Tree_Node_Access; 773 -- begin 774 -- Exist_Node := Find (Result.all, Std); 775 776 -- if Exist_Node = null then 777 -- Exist_Node := Add_Child (Result, Node, Unit); 778 -- else 779 -- if Node /= null then 780 -- Glue_Nodes (Result, Node, Exist_Node); 781 -- end if; 782 -- end if; 783 -- end Append_Standart; 784 785 -- Reorder -- 786 -- procedure Reorder 787 -- (Unit : in Compilation_Unit; 788 -- Node : in Tree_Node_Access) 789 -- is 790 -- begin 791 -- Kinds := Unit_Kind (Unit); 792 793 -- if Is_Nill (Unit) 794 -- or else Kinds in A_Nonexistent_Declaration .. An_Unknown_Unit 795 -- then 796 -- Append_Standart (Node); 797 798 -- elsif Kinds in A_Subunit then 799 -- Retrive_Subunit (Unit, Node); 800 801 -- elsif Kinds = A_Package_Body then 802 -- Retrive_Body (Unit, Node); 803 804 -- elsif Kinds in A_Subprogram_Body then 805 -- Retrive_Subprogram_Body (Get_Package_Body (Unit), Node); 806 807 -- else 808 -- Retrive_Declarations (Unit, Node); 809 -- end if; 810 -- end Reorder; 890 procedure Append_Standart 891 (Node : in Tree_Node_Access) 892 is 893 Exist_Node : Tree_Node_Access; 894 begin 895 Exist_Node := Find (Result.all, Std); 896 897 if Exist_Node = null then 898 Exist_Node := Add_Child (Result, Node, Std); 899 else 900 if Node /= null then 901 Glue_Nodes_Checked (Result, Node, Exist_Node); 902 end if; 903 end if; 904 end Append_Standart; 905 906 -- Retrive -- 907 procedure Retrive 908 (Unit : in Compilation_Unit; 909 Node : in Tree_Node_Access; 910 First_Node : in Boolean := False) 911 is 912 begin 913 if Is_Nil (Unit) then 914 return; 915 end if; 916 917 Kinds := Unit_Kind (Unit); 918 919 if Kinds in A_Nonexistent_Declaration .. An_Unknown_Unit then 920 Append_Standart (Node); 921 922 elsif Kinds in A_Subunit then 923 Retrive_Subunit (Unit, Node); 924 925 elsif Kinds in A_Procedure_Body .. A_Package_Body then 926 Retrive_Body (Unit, Node, First_Node); 927 928 else 929 Retrive_Declarations (Unit, Node, First_Node); 930 end if; 931 end Retrive; 932 933 -- Retrive_Declarations -- 934 procedure Retrive_Declarations 935 (Unit : in Compilation_Unit; 936 Node : in Tree_Node_Access; 937 First_Node : in Boolean) 938 is 939 Parent : Compilation_Unit; 940 vNode : Tree_Node_Access := Node; 941 Exist_Node : Tree_Node_Access; 942 begin 943 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 963 return; 964 end if; 965 966 Check_10_1_1_26c_26b (Unit, vNode); 967 Retrive_With_Clause (Unit, vNode); 968 end if; 969 970 Parent := Corresponding_Parent_Declaration (Unit, The_Context); 971 972 while Unit_Kind (Parent) in 973 A_Procedure .. A_Generic_Package_Renaming 974 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; 987 988 Parent := Corresponding_Parent_Declaration (Parent, The_Context); 989 end loop; 990 991 Retrive (Parent, vNode); 992 end Retrive_Declarations; 993 994 -- Retrive_Body -- 995 procedure Retrive_Body 996 (Unit : in Compilation_Unit; 997 Node : in Tree_Node_Access; 998 First_Node : in Boolean) 999 is 1000 Exist_Node : Tree_Node_Access := Node; 1001 begin 1002 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; 1019 1020 Retrive 1021 (Corresponding_Parent_Declaration (Unit, The_Context), 1022 Exist_Node); 1023 end Retrive_Body; 811 1024 812 1025 -- Retrive_Subunit -- 813 -- procedure Retrive_Subunit 814 -- (Unit : in Compilation_Unit; 815 -- Node : in Tree_Node_Access) 816 -- is 817 -- Parent : Compilation_Unit; 818 -- Exist_Node : Tree_Node_Access := Node; 819 -- begin 820 -- Parent := Corresponding_Subunit_Parent_Body (Unit); 821 822 -- while Unit_Kind (Parent) in A_Subunit loop 823 -- Exist_Node := Find (Result.all, Parent); 824 825 -- if Exist_Node = null then 826 -- Exist_Node := Add_Child (Result, Node, Unit); 827 -- else 828 -- if Node /= null then 829 -- Glue_Nodes (Result, Node, Exist_Node); 830 -- return; 831 -- end if; 832 -- end if; 833 834 -- Parent := Corresponding_Subunit_Parent_Body (Unit); 835 -- end loop; 836 837 -- Reorder (Parent, Exist_Node); 838 -- end Retrive_Subunit; 1026 procedure Retrive_Subunit 1027 (Unit : in Compilation_Unit; 1028 Node : in Tree_Node_Access) 1029 is 1030 Parent : Compilation_Unit; 1031 vNode : Tree_Node_Access := Node; 1032 Exist_Node : Tree_Node_Access; 1033 begin 1034 Check_10_1_1_26c_26b (Unit, null); 1035 Retrive_With_Clause (Unit, null); 1036 Parent := Corresponding_Subunit_Parent_Body (Unit); 1037 1038 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; 1051 1052 Parent := Corresponding_Subunit_Parent_Body (Parent); 1053 end loop; 1054 1055 Retrive (Parent, vNode); 1056 end Retrive_Subunit; 1057 1058 -- Retrive_With_Clause -- 1059 procedure Retrive_With_Clause 1060 (Unit : in Compilation_Unit; 1061 Node : in Tree_Node_Access) 1062 is 1063 With_List : constant Asis.Context_Clause_List := 1064 Asis.Elements.Context_Clause_Elements (Unit); 1065 1066 Internal_Unit : Compilation_Unit; 1067 begin 1068 for Index in With_List'Range loop 1069 if Clause_Kind (With_List (Index).all) = A_With_Clause then 1070 1071 Internal_Unit := Get_Compilation_Unit (With_List (Index)); 1072 1073 -- Send warning if null !!! 1074 if not Is_Nil (Internal_Unit) then 1075 Retrive (Internal_Unit, Node); 1076 end if; 1077 end if; 1078 end loop; 1079 end Retrive_With_Clause; 1080 1081 -- Check_10_1_1_26c_26b -- 1082 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 1089 Except : Compilation_Unit := Library_Unit_Declaration 1090 ("Ada.Exceptions", The_Context); 1091 1092 Sys : Compilation_Unit := Library_Unit_Declaration 1093 ("System", The_Context); 1094 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) 1110 is 1111 use Asis.Elements; 1112 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); 1147 1148 if State.Exceptions then 1149 Retrive (Except, Node); 1150 end if; 1151 1152 if State.System then 1153 Retrive (Sys, Node); 1154 end if; 1155 end Check_10_1_1_26c_26b; 839 1156 840 1157 begin 841 -- for Index in List'Range loop 842 -- Unit := List (Index); 843 -- Reorder (List (Index), null); 844 -- end loop; 1158 for Index in List'Range loop 1159 Unit := List (Index); 1160 1161 if Find (Result.all, Unit) = null then 1162 Retrive (Unit, null, True); 1163 end if; 1164 end loop; 845 1165 846 1166 return Result; … … 851 1171 end Get_Supporters; 852 1172 1173 -------------------- 1174 -- Get_Dependents -- 1175 -------------------- 1176 1177 function Get_Dependents 1178 (List : in Asis.Compilation_Unit_List; 1179 The_Context : in Asis.Context) 1180 return Utils.Tree_Node_Access 1181 is 1182 use Utils; 1183 1184 Result : Tree_Node_Access := new Tree_Node; 1185 1186 Unit, Body_Unit : Compilation_Unit; 1187 1188 Kinds : Unit_Kinds; 1189 1190 Except : Compilation_Unit := Library_Unit_Declaration 1191 ("Ada.Exceptions", The_Context); 1192 1193 Sys : Compilation_Unit := Library_Unit_Declaration 1194 ("System", The_Context); 1195 1196 procedure Append_To_Node 1197 (Unit : in Compilation_Unit; 1198 Node : in Tree_Node_Access; 1199 Glued : in out Tree_Node_Array_Access) 1200 is 1201 Exist_Node : Tree_Node_Access := null; 1202 Second_Unit : Compilation_Unit; 1203 begin 1204 Exist_Node := Find (Result.all, Unit); 1205 Kinds := Unit_Kind (Unit); 1206 1207 if Kinds in A_Procedure .. A_Generic_Package then 1208 if Exist_Node /= null then 1209 Glue_Nodes_Checked (Result, Node, Exist_Node); 1210 1211 if not Is_Skip_Spec (Exist_Node) then 1212 Glued := Append (Glued, Exist_Node); 1213 else 1214 Skip_Spec (Exist_Node, False); 1215 end if; 1216 else 1217 Second_Unit := Corresponding_Body (Unit, The_Context); 1218 Exist_Node := Add_Child_Body (Result, Node, Unit, Second_Unit); 1219 end if; 1220 1221 elsif Kinds in A_Library_Unit_Body then 1222 if Exist_Node /= null then 1223 Glue_Nodes_Checked (Result, Node, Exist_Node); 1224 Glued := Append (Glued, Exist_Node); 1225 else 1226 Second_Unit := Corresponding_Declaration (Unit, The_Context); 1227 1228 if not Is_Nil (Sec