Changeset 2630

Show
Ignore:
Timestamp:
02/22/08 10:51:37 (11 months ago)
Author:
ogorod
Message:

some bugfixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tendra/src/producers/ada/asis/asis-compilation_units-relations.adb

    r2628 r2630  
    6262         return Compilation_Unit_List_Access; 
    6363 
    64       --  Tree_Node  -- 
     64      -- Tree -- 
     65      type Root_Tree is 
     66        new Ada.Finalization.Limited_Controlled with private; 
     67 
     68      type Root_Tree_Access is access all Root_Tree; 
     69 
    6570      type Tree_Node is 
    6671        new Ada.Finalization.Limited_Controlled with private; 
     
    8792         return Boolean; 
    8893 
    89       --  Tree_Node  -- 
    90  
     94      -- Root_Tree -- 
    9195      type Orders is (Ascending, Descending); 
    9296 
    9397      procedure Dependence_Order 
    94         (This  : in Tree_Node_Access; 
     98        (This  : in Root_Tree_Access; 
    9599         Order : in Orders); 
    96100 
    97101      function Add_Child 
    98         (This      : in Tree_Node_Access; 
     102        (This      : in Root_Tree_Access; 
    99103         Node      : in Tree_Node_Access; 
    100104         Spec_Unit : in Compilation_Unit) 
     
    102106 
    103107      function Add_Child 
    104         (This      : in Tree_Node_Access; 
     108        (This      : in Root_Tree_Access; 
    105109         Node      : in Tree_Node_Access; 
    106110         Spec_Unit : in Compilation_Unit; 
     
    109113         return Tree_Node_Access; 
    110114 
     115      procedure Append 
     116        (This : in Root_Tree_Access; 
     117         Unit : in Compilation_Unit); 
     118 
    111119      procedure Glue_Nodes 
    112         (This    : in Tree_Node_Access; 
     120        (This    : in Root_Tree_Access; 
    113121         Node    : in Tree_Node_Access; 
    114122         To_Node : in Tree_Node_Access); 
    115123 
    116124      procedure Glue_Nodes_Checked 
    117         (This    : in Tree_Node_Access; 
     125        (This    : in Root_Tree_Access; 
    118126         Node    : in Tree_Node_Access; 
    119127         To_Node : in Tree_Node_Access); 
    120128 
    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  
    130129      procedure Set_Parent 
    131         (This   : in Tree_Node_Access; 
     130        (This   : in Root_Tree_Access; 
    132131         Node   : in Tree_Node_Access; 
    133132         Parent : in Tree_Node_Access); 
    134133 
    135134      procedure Clear 
    136         (This : in out Tree_Node); 
     135        (This : in out Root_Tree); 
     136 
     137      procedure Add_Body_Dependents 
     138        (This    : in Root_Tree_Access; 
     139         Node    : in Tree_Node_Access; 
     140         To_Node : in Tree_Node_Access); 
    137141 
    138142      function Find 
    139         (This : in Tree_Node
     143        (This : in Root_Tree_Access
    140144         Unit : in Compilation_Unit) 
    141145         return Tree_Node_Access; 
    142146 
    143147      procedure Check 
    144         (This        : in Tree_Node_Access; 
     148        (This        : in Root_Tree_Access; 
    145149         The_Context : in Asis.Context); 
    146150 
    147151      function Generate_Relationship 
    148         (This       : in Tree_Node_Access; 
     152        (This       : in Root_Tree_Access; 
    149153         Limit_List : in Utils.Compilation_Unit_List_Access; 
    150154         List_Last  : in ASIS_Integer) 
    151155         return Relationship; 
    152156 
     157      function Create_Elaboration_Tree 
     158        (This        : in Root_Tree_Access; 
     159         The_Context : in Asis.Context) 
     160         return Root_Tree_Access; 
     161 
     162      function Is_Child 
     163        (This : in Root_Tree_Access; 
     164         Node : in Tree_Node_Access) 
     165        return Boolean; 
     166 
     167      function Is_Have_Circular_Dependences 
     168        (This : in Root_Tree_Access) 
     169         return Boolean; 
     170 
     171      -- Tree_Node -- 
    153172      function Is_Skip_Spec 
    154173        (This : in Tree_Node_Access) 
     
    163182         return Tree_Node_Array_Access; 
    164183 
    165       function Spec 
     184      function Get_Spec 
    166185        (This : in Tree_Node_Access) 
    167186         return Compilation_Unit; 
     
    174193 
    175194   private 
     195 
     196      -- Tree_Node -- 
     197      type Extended_Boolean is (Unknown, Extended_True, Extended_False); 
     198 
     199      type Tree_Node is 
     200        new Ada.Finalization.Limited_Controlled with record 
     201         Self : Tree_Node_Access := Tree_Node'Unchecked_Access; 
     202 
     203         --  ссылка Ма преЎыЎущОе елеЌеМты 
     204         Prevs : Tree_Node_Array_Access := null; 
     205 
     206         --  пПслеЎующОе елеЌеМты 
     207         Next : Tree_Node_Array_Access := null; 
     208 
     209         --  ЌПЎуль_кПЌпОляцОО 
     210         Unit      : Compilation_Unit := Nil_Compilation_Unit; 
     211         Unit_Body : Compilation_Unit := Nil_Compilation_Unit; 
     212         Skip_Spec : Boolean := False; 
     213 
     214         Added      : Boolean := False; 
     215 
     216         Consistent      : Boolean := True; 
     217         Body_Consistent : Boolean := True; 
     218 
     219         -- завОсОЌПстО тела (with) 
     220         Body_Dependences : Tree_Node_Array_Access := null; 
     221 
     222         --  спОсПк цОклОческОѠ
     223 Ð·Ð°Ð²ÐžÑÐžÐŒÐŸÑÑ‚ей 
     224         Circular       : Compilation_Unit_List_Access := null; 
     225         Circular_Added : Boolean := False; 
     226 
     227         --  спОсПк прПпавшОѠ
     228 ÑŽÐœÐžÑ‚Пв 
     229         Missing       : Compilation_Unit_List_Access := null; 
     230         Missing_Added : Boolean := False; 
     231 
     232         --  спОсПк МесПглассПваММыѠ
     233 ÑŽÐœÐžÑ‚Пв 
     234         Inconsistent       : Compilation_Unit_List_Access := null; 
     235         Inconsistent_Added : Boolean := False; 
     236 
     237         Elaborated      : Boolean := False; 
     238         Body_Elaborated : Boolean := False; 
     239 
     240         Internal_Pure : Extended_Boolean := Unknown; 
     241      end record; 
     242 
     243      procedure Finalize 
     244        (This : in out Tree_Node); 
     245 
     246      function Is_Pure 
     247        (This : in Tree_Node_Access) 
     248         return Boolean; 
     249 
     250      -- Root_Tree -- 
    176251 
    177252      type Unit_Node is record 
     
    183258      type Unit_Node_Array_Access is access all Unit_Node_Array; 
    184259 
    185       type Tree_Node is 
     260      type Root_Tree is 
    186261        new Ada.Finalization.Limited_Controlled with record 
    187          Self : Tree_Node_Access := Tree_Node'Unchecked_Access; 
     262         Self : Root_Tree_Access := Root_Tree'Unchecked_Access; 
    188263 
    189264         Order : Orders := Descending; 
    190  
    191          --  ссылка Ма преЎыЎущОй елеЌеМт 
    192          Prev  : Tree_Node_Access := null; 
    193          Prevs : Tree_Node_Array_Access := null; 
    194  
    195          --  ЌПЎуль_кПЌпОляцОО 
    196          Unit      : Compilation_Unit := Nil_Compilation_Unit; 
    197          Unit_Body : Compilation_Unit := Nil_Compilation_Unit; 
    198          Skip_Spec : Boolean := False; 
    199  
    200          Added      : Boolean := False; 
    201  
    202          Consistent      : Boolean := True; 
    203          Body_Consistent : Boolean := True; 
    204  
    205          --  пПслеЎующОе елеЌеМты 
    206          Next : Tree_Node_Array_Access := null; 
    207  
    208          -- завОсОЌПстО тела (with) 
    209          Body_Dependences : Tree_Node_Array_Access := null; 
     265         Next  : Tree_Node_Array_Access := null; 
    210266 
    211267         --  сПртОрПваММый спОсПк всеѠ
     
    214270         --  ПпреЎелеМОя МалОчОя елеЌеМта 
    215271         --  в спОске 
    216          --  запПлМяет тПлькП кПрМевПй елеЌеМт 
    217272         Units : Unit_Node_Array_Access := null; 
    218273 
    219          --  спОсПк цОклОческОѠ
    220  Ð·Ð°Ð²ÐžÑÐžÐŒÐŸÑÑ‚ей 
    221          Circular       : Compilation_Unit_List_Access := null; 
    222          Circular_Added : Boolean := False; 
    223  
    224          --  спОсПк прПпавшОѠ
    225  ÑŽÐœÐžÑ‚Пв 
    226          Missing       : Compilation_Unit_List_Access := null; 
    227          Missing_Added : Boolean := False; 
    228  
    229          --  спОсПк МесПглассПваММыѠ
    230  ÑŽÐœÐžÑ‚Пв 
    231          Inconsistent       : Compilation_Unit_List_Access := null; 
    232          Inconsistent_Added : Boolean := False; 
     274         Last_Node : Tree_Node_Access := null; 
    233275      end record; 
    234276 
    235277      procedure Finalize 
    236         (This : in out Tree_Node); 
     278        (This : in out Root_Tree); 
     279 
     280      -- Additional -- 
     281      procedure Deallocate is 
     282        new Ada.Unchecked_Deallocation 
     283          (Tree_Node, Tree_Node_Access); 
    237284 
    238285      procedure Deallocate is 
     
    286333   procedure Deallocate is 
    287334     new Ada.Unchecked_Deallocation 
    288        (Utils.Tree_Node, Utils.Tree_Node_Access); 
     335       (Utils.Root_Tree, Utils.Root_Tree_Access); 
     336 
     337   procedure Check_Compilation_Unit 
     338     (Unit        : in Compilation_Unit; 
     339      The_Context : in Asis.Context; 
     340      Message     : in Wide_String); 
     341 
     342   procedure Normalize 
     343     (List   : in     Asis.Compilation_Unit_List; 
     344      Result : in     Utils.Compilation_Unit_List_Access; 
     345      Last   :    out ASIS_Integer); 
    289346 
    290347   function Get_Ancestors 
    291348     (List        : in Asis.Compilation_Unit_List; 
    292349      The_Context : in Asis.Context) 
    293       return Utils.Tree_Node_Access; 
     350      return Utils.Root_Tree_Access; 
    294351 
    295352   function Get_Descendants 
    296353     (List        : in Asis.Compilation_Unit_List; 
    297354      The_Context : in Asis.Context) 
    298       return Utils.Tree_Node_Access; 
     355      return Utils.Root_Tree_Access; 
    299356 
    300357   function Get_Supporters 
    301358     (List        : in Asis.Compilation_Unit_List; 
    302359      The_Context : in Asis.Context) 
    303       return Utils.Tree_Node_Access; 
     360      return Utils.Root_Tree_Access; 
    304361 
    305362   function Get_Dependents 
    306363     (List        : in Asis.Compilation_Unit_List; 
    307364      The_Context : in Asis.Context) 
    308       return Utils.Tree_Node_Access; 
     365      return Utils.Root_Tree_Access; 
    309366 
    310367   function Get_Family 
    311368     (List        : in Asis.Compilation_Unit_List; 
    312369      The_Context : in Asis.Context) 
    313       return Utils.Tree_Node_Access; 
     370      return Utils.Root_Tree_Access; 
    314371 
    315372   function Get_Needed_Units 
    316373     (List        : in Asis.Compilation_Unit_List; 
    317374      The_Context : in Asis.Context) 
    318       return Utils.Tree_Node_Access; 
     375      return Utils.Root_Tree_Access; 
    319376 
    320377   procedure Get_Subunits 
    321      (Tree        : in Utils.Tree_Node_Access; 
     378     (Tree        : in Utils.Root_Tree_Access; 
    322379      Unit        : in Compilation_Unit; 
    323380      Node        : in Utils.Tree_Node_Access; 
     
    347404      return Check_10_1_1_26c_26b_Information; 
    348405 
     406   ---------------------------- 
     407   -- Check_Compilation_Unit -- 
     408   ---------------------------- 
     409 
     410   procedure Check_Compilation_Unit 
     411     (Unit        : in Compilation_Unit; 
     412      The_Context : in Asis.Context; 
     413      Message     : in Wide_String) 
     414   is 
     415      Kind : Asis.Unit_Kinds; 
     416   begin 
     417      Kind := Unit_Kind (Unit); 
     418 
     419      if Kind = Not_A_Unit 
     420         or else Kind = A_Nonexistent_Declaration 
     421         or else Kind = A_Nonexistent_Body 
     422         or else Kind = A_Configuration_Compilation 
     423      then 
     424         Asis.Implementation.Set_Status 
     425           (Data_Error, Message & " invalid unit " & Unit_Full_Name (Unit)); 
     426 
     427         raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; 
     428      end if; 
     429 
     430      if not Asis.Ada_Environments.Is_Equal 
     431        (Enclosing_Context (Unit), The_Context) 
     432      then 
     433         Asis.Implementation.Set_Status 
     434           (Data_Error, Message & " invalid unit's context " 
     435            & Unit_Full_Name (Unit)); 
     436 
     437         raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; 
     438      end if; 
     439   end Check_Compilation_Unit; 
     440 
     441   --------------- 
     442   -- Normalize -- 
     443   --------------- 
     444 
     445   procedure Normalize 
     446     (List   : in     Asis.Compilation_Unit_List; 
     447      Result : in     Utils.Compilation_Unit_List_Access; 
     448      Last   :    out ASIS_Integer) 
     449   is 
     450      Unit : Compilation_Unit; 
     451   begin 
     452      Last := 0; 
     453 
     454      for Index in List'Range loop 
     455         Unit := List (Index); 
     456 
     457         if not Is_Nil (Unit) 
     458            and then Unit_Kind (Unit) /= An_Unknown_Unit 
     459         then 
     460            if not Utils.In_List (Result, Last, Unit) then 
     461               Last := Last + 1; 
     462               Result (Last) := List (Index); 
     463            end if; 
     464         end if; 
     465      end loop; 
     466   end Normalize; 
     467 
    349468   ------------------------- 
    350469   --  Elaboration_Order  -- * 
     
    356475      return Relationship 
    357476   is 
     477      procedure Clear; 
     478 
     479      Tree           : Utils.Root_Tree_Access := null; 
     480      Elaborate_Tree : Utils.Root_Tree_Access := null; 
     481 
     482      Compilation_Units_Last : ASIS_Integer := 0; 
     483 
     484      Normalized_Compilation_Units : 
     485         Utils.Compilation_Unit_List_Access := null; 
     486 
     487      -- Clear -- 
     488      procedure Clear is 
     489      begin 
     490         Deallocate (Tree); 
     491         Deallocate (Elaborate_Tree); 
     492         Utils.Deallocate (Normalized_Compilation_Units); 
     493      end Clear; 
    358494   begin 
    359       Asis.Implementation.Set_Status 
    360         (Not_Implemented_Error, "Elaboration_Order not implemented"); 
    361       raise Asis.Exceptions.ASIS_Failed; 
    362  
    363       return Nil_Relationship; 
     495      if Compilation_Units = Nil_Compilation_Unit_List then 
     496         return Nil_Relationship; 
     497      end if; 
     498 
     499      for Index in Compilation_Units'Range loop 
     500         Check_Compilation_Unit 
     501           (Compilation_Units (Index), The_Context, 
     502            "Elaboration_Order:Compilation_Unit"); 
     503      end loop; 
     504 
     505      Normalized_Compilation_Units := new 
     506        Asis.Compilation_Unit_List (1 .. Compilation_Units'Length); 
     507 
     508      Normalized_Compilation_Units.all := (others => Nil_Compilation_Unit); 
     509 
     510      Normalize (Compilation_Units, 
     511                 Normalized_Compilation_Units, 
     512                 Compilation_Units_Last); 
     513 
     514      Tree := Get_Needed_Units 
     515         (Normalized_Compilation_Units (1 .. Compilation_Units_Last), 
     516          The_Context); 
     517 
     518      Utils.Check (Tree, The_Context); 
     519 
     520      if Utils.Is_Have_Circular_Dependences (Tree) then 
     521         Clear; 
     522 
     523         Asis.Implementation.Set_Status 
     524           (Data_Error, "Elaboration_Order - " 
     525            & "Circular semantic dependence detected, can not create " 
     526            & "elaboration order"); 
     527 
     528         raise Asis.Exceptions.ASIS_Failed; 
     529      end if; 
     530 
     531      Elaborate_Tree := Utils.Create_Elaboration_Tree (Tree, The_Context); 
     532 
     533      declare 
     534         Relation : Relationship := Utils.Generate_Relationship 
     535            (Elaborate_Tree, null, 0); 
     536      begin 
     537         Clear; 
     538         return Relation; 
     539      end; 
     540 
     541   exception 
     542      when others => 
     543         Clear; 
     544         raise; 
    364545   end Elaboration_Order; 
    365546 
     
    375556      return Relationship 
    376557   is 
    377       Current_Unit_Kind : Asis.Unit_Kinds; 
    378  
    379       procedure Check_Compilation_Unit 
    380          (Unit    : in Compilation_Unit; 
    381           Message : in Wide_String); 
    382  
    383       procedure Normalize 
    384          (List   : in     Asis.Compilation_Unit_List; 
    385           Result : in     Utils.Compilation_Unit_List_Access; 
    386           Last   :    out ASIS_Integer); 
    387  
    388558      procedure Clear; 
    389  
    390       -- Check_Compilation_Unit -- 
    391       procedure Check_Compilation_Unit 
    392          (Unit    : in Compilation_Unit; 
    393           Message : in Wide_String) 
    394       is 
    395       begin 
    396          Current_Unit_Kind := Unit_Kind (Unit); 
    397  
    398          if Current_Unit_Kind = Not_A_Unit 
    399             or else Current_Unit_Kind = A_Nonexistent_Declaration 
    400             or else Current_Unit_Kind = A_Nonexistent_Body 
    401             or else Current_Unit_Kind = A_Configuration_Compilation 
    402          then 
    403             Asis.Implementation.Set_Status 
    404               (Data_Error, "Semantic_Dependence_Order " 
    405                & Message & " invalid unit " & Unit_Full_Name (Unit)); 
    406  
    407             raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; 
    408          end if; 
    409  
    410          if not Asis.Ada_Environments.Is_Equal 
    411            (Enclosing_Context (Unit), The_Context) 
    412          then 
    413             Asis.Implementation.Set_Status 
    414               (Data_Error, "Semantic_Dependence_Order " 
    415                & Message & " invalid unit's context " & Unit_Full_Name (Unit)); 
    416  
    417             raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit; 
    418          end if; 
    419       end Check_Compilation_Unit; 
    420559 
    421560      Compilation_Units_Last : ASIS_Integer := 0; 
     
    429568         Utils.Compilation_Unit_List_Access := null; 
    430569 
    431       -- Normalize -- 
    432       procedure Normalize 
    433          (List   : in     Asis.Compilation_Unit_List; 
    434           Result : in     Utils.Compilation_Unit_List_Access; 
    435           Last   :    out ASIS_Integer) 
    436       is 
    437          Unit : Compilation_Unit; 
    438       begin 
    439          Last := 0; 
    440  
    441          for Index in List'Range loop 
    442             Unit := List (Index); 
    443  
    444             if Assigned (Unit) 
    445                and then Unit_Kind (Unit) /= An_Unknown_Unit 
    446             then 
    447                if not Utils.In_List (Result, Last, Unit) then 
    448                   Last := Last + 1; 
    449                   Result (Last) := List (Index); 
    450                end if; 
    451             end if; 
    452          end loop; 
    453       end Normalize; 
    454  
    455       Tree : Utils.Tree_Node_Access := null; 
     570      Tree : Utils.Root_Tree_Access := null; 
    456571 
    457572      procedure Clear is begin 
     
    468583      for Index in Compilation_Units'Range loop 
    469584         Check_Compilation_Unit 
    470            (Compilation_Units (Index), "Compilation_Unit"); 
     585           (Compilation_Units (Index), The_Context, 
     586            "Semantic_Dependence_Order:Compilation_Unit"); 
    471587      end loop; 
    472588 
     
    486602      then 
    487603         for Index in Dependent_Units'Range loop 
    488             Check_Compilation_Unit (Dependent_Units (Index), "Dependent_Unit"); 
     604            Check_Compilation_Unit 
     605               (Dependent_Units (Index), The_Context, 
     606                "Semantic_Dependence_Order:Dependent_Unit"); 
    489607         end loop; 
    490608 
     
    553671     (List        : in Asis.Compilation_Unit_List; 
    554672      The_Context : in Asis.Context) 
    555       return Utils.Tree_Node_Access 
     673      return Utils.Root_Tree_Access 
    556674   is 
    557675      use Utils; 
     
    560678      Kinds : Unit_Kinds; 
    561679 
    562       Result : Tree_Node_Access := new Tree_Node; 
     680      Result : Root_Tree_Access := new Root_Tree; 
    563681 
    564682      procedure Append_Node 
     
    577695         Exist_Node : Tree_Node_Access; 
    578696      begin 
    579          Exist_Node := Find (Result.all, Unit); 
     697         Exist_Node := Find (Result, Unit); 
    580698 
    581699         if Exist_Node /= null then 
     
    625743         Unit := List (Index); 
    626744 
    627          if Find (Result.all, Unit) = null 
     745         if Find (Result, Unit) = null 
    628746         then 
    629747            Kinds := Unit_Kind (Unit); 
     
    658776     (List        : in Asis.Compilation_Unit_List; 
    659777      The_Context : in Asis.Context) 
    660       return Utils.Tree_Node_Access 
     778      return Utils.Root_Tree_Access 
    661779   is 
    662780      use Utils; 
    663781 
    664       Result      : Tree_Node_Access := new Tree_Node; 
     782      Result      : Root_Tree_Access := new Root_Tree; 
    665783      Unit        : Compilation_Unit; 
    666784      Second_Unit : Compilation_Unit; 
     
    688806         begin 
    689807            Kinds       := Unit_Kind (Unit); 
    690             Exist_Node  := Find (Result.all, Unit); 
     808            Exist_Node  := Find (Result, Unit); 
    691809            Second_Unit := Nil_Compilation_Unit; 
    692810 
     
    806924         Unit := Declarations_List (Index); 
    807925 
    808          if Find (Result.all, Unit) = null then 
     926         if Find (Result, Unit) = null then 
    809927            Second_Unit := Corresponding_Body (Unit, The_Context); 
    810928 
     
    836954     (List        : in Asis.Compilation_Unit_List; 
    837955      The_Context : in Asis.Context) 
    838       return Utils.Tree_Node_Access 
     956      return Utils.Root_Tree_Access 
    839957   is 
    840958      use Utils; 
     
    843961      Kinds : Unit_Kinds; 
    844962 
    845       Result : Tree_Node_Access := new Tree_Node; 
     963      Result : Root_Tree_Access := new Root_Tree; 
    846964      Node   : Tree_Node_Access := null; 
    847965 
     
    8881006         Exist_Node : Tree_Node_Access; 
    8891007      begin 
    890          Exist_Node := Find (Result.all, Unit); 
     1008         Exist_Node := Find (Result, Unit); 
    8911009 
    8921010         if Exist_Node = null then 
     
    10491167                     Retrive (Internal_Unit, Node); 
    10501168                  else 
    1051                      Exist_Node := Find (Result.all, Internal_Unit); 
     1169                     Exist_Node := Find (Result, Internal_Unit); 
    10521170 
    10531171                     if Exist_Node = null then 
     
    10551173 
    10561174                        if Node /= null then 
    1057                           Add_Body_Dependents (Exist_Node, Node); 
     1175                          Add_Body_Dependents (Result, Exist_Node, Node); 
    10581176                        end if; 
    10591177 
     
    10611179                     else 
    10621180                        if Node /= null then 
    1063                           Add_Body_Dependents (Exist_Node, Node); 
     1181                          Add_Body_Dependents (Result, Exist_Node, Node); 
    10641182                        end if; 
    10651183                     end if; 
     
    10901208            Exist_Node : Tree_Node_Access; 
    10911209         begin 
    1092             Exist_Node := Find (Result.all, Unit); 
     1210            Exist_Node := Find (Result, Unit); 
    10931211 
    10941212            if Exist_Node = null then 
     
    10961214 
    10971215               if Node /= null then 
    1098                   Add_Body_Dependents (Exist_Node, Node); 
     1216                  Add_Body_Dependents (Result, Exist_Node, Node); 
    10991217               end if; 
    11001218 
     
    11021220            else 
    11031221               if Node /= null then 
    1104                   Add_Body_Dependents (Exist_Node, Node); 
     1222                  Add_Body_Dependents (Result, Exist_Node, Node); 
    11051223               end if; 
    11061224            end if; 
     
    11331251         Unit := List (Index); 
    11341252 
    1135          if Find (Result.all, Unit) = null then 
     1253         if Find (Result, Unit) = null then 
    11361254            Retrive (Unit, null, True); 
    11371255         end if; 
     
    11521270     (List        : in Asis.Compilation_Unit_List; 
    11531271      The_Context : in Asis.Context) 
    1154       return Utils.Tree_Node_Access 
     1272      return Utils.Root_Tree_Access 
    11551273   is 
    11561274      use Utils; 
    11571275 
    1158       Result : Tree_Node_Access := new Tree_Node; 
     1276      Result : Root_Tree_Access := new Root_Tree; 
    11591277 
    11601278      Unit, Body_Unit : Compilation_Unit; 
     
    11761294         Second_Unit : Compilation_Unit; 
    11771295      begin 
    1178          Exist_Node := Find (Result.all, Unit); 
     1296         Exist_Node := Find (Result, Unit); 
    11791297         Kinds      := Unit_Kind (Unit); 
    11801298 
     
    11991317         elsif Kinds in A_Library_Unit_Body then 
    12001318            if Exist_Node /= null then 
    1201                Add_Body_Dependents (Exist_Node, Node); 
     1319               Add_Body_Dependents (Result, Exist_Node, Node); 
    12021320            else 
    12031321               Second_Unit := Corresponding_Declaration (Unit, The_Context); 
     
    12061324                  and then not Is_Identical (Second_Unit, Unit) 
    12071325               then 
    1208                   Exist_Node := Find (Result.all, Second_Unit); 
     1326                  Exist_Node := Find (Result, Second_Unit); 
    12091327 
    12101328                  if Exist_Node /= null then 
    1211                      Add_Body_Dependents (Exist_Node, Node); 
     1329                     Add_Body_Dependents (Result, Exist_Node, Node); 
    12121330                  else 
    12131331                     Exist_Node := Add_Child 
    12141332                        (Result, null, Second_Unit, Unit, True); 
    1215                      Add_Body_Dependents (Exist_Node, Node); 
     1333                     Add_Body_Dependents (Result, Exist_Node, Node); 
    12161334                  end if; 
    12171335               else 
    12181336                  Exist_Node := Add_Child (Result, null, Unit); 
    1219                   Add_Body_Dependents (Exist_Node, Node); 
     1337                  Add_Body_Dependents (Result, Exist_Node, Node); 
    12201338               end if; 
    12211339            end if; 
     
    12231341         elsif Kinds in A_Subunit then 
    12241342            if Exist_Node /= null then 
    1225                Add_Body_Dependents (Exist_Node, Node); 
     1343               Add_Body_Dependents (Result, Exist_Node, Node); 
    12261344            else 
    12271345               Exist_Node := Add_Child (Result, null, Unit); 
    1228                Add_Body_Dependents (Exist_Node, Node); 
     1346               Add_Body_Dependents (Result, Exist_Node, Node); 
    12291347            end if; 
    12301348 
     
    13521470 
    13531471                  Kinds      := Unit_Kind (Children); 
    1354                   Exist_Node := Find (Result.all, Children); 
     1472                  Exist_Node := Find (Result, Children); 
    13551473 
    13561474                  if Exist_Node /= null then 
     
    15001618                      (Glued, Glued.all'Last, Next_Node) 
    15011619                  then 
    1502                      Next_Unit := Spec (Next_Node); 
     1620                     Next_Unit := Get_Spec (Next_Node); 
    15031621                     Kinds     := Unit_Kind (Next_Unit); 
    15041622                     if Kinds in 
     
    15311649         Unit := List (Index); 
    15321650 
    1533          if Find (Result.all, Unit) = null then 
     1651         if Find (Result, Unit) = null then 
    15341652            Kinds := Unit_Kind (Unit); 
    15351653 
     
    15641682     (List        : in Asis.Compilation_Unit_List; 
    15651683      The_Context : in Asis.Context) 
    1566       return Utils.Tree_Node_Access 
     1684      return Utils.Root_Tree_Access 
    15671685   is 
    15681686      use Utils; 
    15691687 
    1570       Result : Tree_Node_Access := new Tree_Node; 
     1688      Result : Root_Tree_Access := new Root_Tree; 
    15711689 
    15721690      Unit, Body_Unit : Compilation_Unit; 
     
    16061724 
    16071725                  Kinds      := Unit_Kind (Children); 
    1608                   Exist_Node := Find (Result.all, Children); 
     1726                  Exist_Node := Find (Result, Children); 
    16091727 
    16101728                  if Exist_Node /= null then 
     
    16821800                  Next_Node := Next (Index); 
    16831801 
    1684                   Next_Unit := Spec (Next_Node); 
     1802                  Next_Unit := Get_Spec (Next_Node); 
    16851803                  Kinds     := Unit_Kind (Next_Unit); 
    16861804 
     
    17061824         Unit := List (Index); 
    17071825 
    1708          if Find (Result.all, Unit) = null then 
     1826         if Find (Result, Unit) = null then 
    17091827            Kinds := Unit_Kind (Unit); 
    17101828 
     
    17391857     (List        : in Asis.Compilation_Unit_List; 
    17401858      The_Context : in Asis.Context) 
    1741       return Utils.Tree_Node_Access 
     1859      return Utils.Root_Tree_Access 
    17421860   is 
    17431861      use Utils; 
    17441862 
    1745       Result : Tree_Node_Access := new Tree_Node; 
     1863      Result : Root_Tree_Access := new Root_Tree; 
    17461864 
    17471865      Unit, Body_Unit : Compilation_Unit; 
     
    17931911         Exist_Node : Tree_Node_Access; 
    17941912      begin 
    1795          Exist_Node := Find (Result.all, Unit); 
     1913         Exist_Node := Find (Result, Unit); 
    17961914 
    17971915         if Exist_Node = null then 
     
    18221940         end if; 
    18231941 
    1824          Ada.Wide_Text_IO.Put_Line ("Retrive :" & Unit_Full_Name (Unit)); 
    18251942         Kinds := Unit_Kind (Unit); 
    18261943 
     
    18852002 
    18862003         Parent := Corresponding_Parent_Declaration (Unit, The_Context); 
    1887          Ada.Wide_Text_IO.Put_Line ("Parent:" & Unit_Full_Name (Parent)); 
    18882004 
    18892005         while Unit_Kind (Parent) in 
     
    19552071 
    19562072            if not Is_Nil (Sub_Unit) then 
    1957                Exist_Node := Find (Result.all, Sub_Unit); 
     2073               Exist_Node := Find (Result, Sub_Unit); 
    19582074               if Exist_Node = null then 
    19592075                  Exist_Node := Add_Child (Result, Node, Sub_Unit); 
     
    19882104 
    19892105               if not Is_Nil (Internal_Unit) then 
    1990                   Ada.Wide_Text_IO.Put_Line ("With :" & Unit_Full_Name (Internal_Unit)); 
    19912106                  if not For_Body then 
    19922107                     Retrive (Internal_Unit, Node); 
    19932108                  else 
    1994                      Exist_Node := Find (Result.all, Internal_Unit); 
     2109                     Exist_Node := Find (Result, Internal_Unit); 
    19952110 
    19962111                     if Exist_Node = null then 
     
    20042119 
    20052120                        if Node /= null then 
    2006                           Add_Body_Dependents (Exist_Node, Node); 
     2121                          Add_Body_Dependents (Result, Exist_Node, Node); 
    20072122                        end if; 
    20082123 
     
    20102125                     else 
    20112126                        if Node /= null then 
    2012                           Add_Body_Dependents (Exist_Node, Node); 
     2127                          Add_Body_Dependents (Result, Exist_Node, Node); 
    20132128                        end if; 
    20142129                     end if; 
     
    20392154            Exist_Node : Tree_Node_Access; 
    20402155         begin 
    2041             Exist_Node := Find (Result.all, Unit); 
     2156            Exist_Node := Find (Result, Unit); 
    20422157 
    20432158            if Exist_Node = null then 
     
    20512166 
    20522167               if Node /= null then 
    2053                   Add_Body_Dependents (Exist_Node, Node); 
     2168                  Add_Body_Dependents (Result, Exist_Node, Node); 
    20542169               end if; 
    20552170 
     
    20572172            else 
    20582173               if Node /= null then 
    2059                   Add_Body_Dependents (Exist_Node, Node); 
     2174                  Add_Body_Dependents (Result, Exist_Node, Node); 
    20602175               end if; 
    20612176            end if; 
     
    20882203         Unit := List (Index); 
    20892204 
    2090          if Find (Result.all, Unit) = null then 
    2091             Ada.Wide_Text_IO.Put_Line ("Needed for :" & Unit_Full_Name (Unit)); 
     2205         if Find (Result, Unit) = null then 
    20922206            Retrive (Unit, null); 
    20932207         end if; 
     
    21072221 
    21082222   procedure Get_Subunits 
    2109      (Tree        : in Utils.Tree_Node_Access; 
     2223     (Tree        : in Utils.root_Tree_Access; 
    21102224      Unit        : in Compilation_Unit; 
    21112225      Node        : in Utils.Tree_Node_Access; 
     
    21222236 
    21232237         if not Is_Nil (Sub_Unit) then 
    2124             Exist_Node := Find (Tree.all, Sub_Unit); 
     2238            Exist_Node := Find (Tree, Sub_Unit); 
    21252239            if Exist_Node = null then 
    21262240               Exist_Node := Add_Child (Tree, Node, Sub_Unit); 
     
    23362450 
    23372451      procedure Dependence_Order 
    2338         (This  : in Tree_Node_Access; 
     2452        (This  : in Root_Tree_Access; 
    23392453         Order : in Orders) 
    23402454      is 
     
    23482462 
    23492463      function Add_Child 
    2350         (This      : in Tree_Node_Access; 
     2464        (This      : in Root_Tree_Access; 
    23512465         Node      : in Tree_Node_Access; 
    23522466         Spec_Unit : in Compilation_Unit) 
    23532467         return Tree_Node_Access 
    23542468      is 
    2355       begin 
    2356          if This.Prev /= null then 
    2357             --  not root 
    2358             raise Use_Error; 
    2359          end if; 
    2360  
    2361          declare 
    2362             New_Node : Tree_Node_Access := new Tree_Node; 
    2363          begin 
    2364             New_Node.Unit := Spec_Unit; 
    2365  
    2366             if Node = null then 
    2367                This.Next     := Add_Node (This.Next, New_Node.Self); 
    2368                New_Node.Prev := This.Self; 
    2369             else 
    2370                Node.Next     := Add_Node (Node.Next, New_Node.Self); 
    2371                New_Node.Prev := Node.Self; 
    2372             end if; 
    2373  
    2374             This.Units := Add_Node_Ordered (This.Units, New_Node.Self); 
    2375             return New_Node; 
    2376          end; 
     2469         New_Node : Tree_Node_Access := new Tree_Node; 
     2470      begin 
     2471         New_Node.Unit := Spec_Unit; 
     2472 
     2473         if Node = null then 
     2474            This.Next := Add_Node (This.Next, New_Node.Self); 
     2475         else 
     2476            Node.Next      := Add_Node (Node.Next, New_Node.Self); 
     2477            New_Node.Prevs := Add_Node (New_Node.Prevs, Node.Self); 
     2478         end if; 
     2479 
     2480         This.Units := Add_Node_Ordered (This.Units, New_Node.Self); 
     2481         return New_Node; 
    23772482      end Add_Child; 
    23782483 
    23792484      -- Add_Child -- 
    23802485      function Add_Child 
    2381