Changeset 2550

Show
Ignore:
Timestamp:
11/19/07 23:20:47 (1 year ago)
Author:
maxr
Message:

Inherit subprograms from types in interface_list

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ada-2005/tendra/src/producers/ada/asis/asis-gela-inheritance.adb

    r2455 r2550  
    2929      Tipe   : Classes.Type_Info; 
    3030      Parent : Classes.Type_Info); 
     31 
     32   function Get_Parents (Decl  : Asis.Declaration) return Asis.Name_List; 
    3133 
    3234   type Cloner is new Asis.Cloner with record 
     
    165167      return Nil_Element_List; 
    166168   end Get_Declarative_Items; 
     169 
     170   ----------------- 
     171   -- Get_Parents -- 
     172   ----------------- 
     173 
     174   function Get_Parents (Decl  : Asis.Declaration) return Asis.Name_List is 
     175   begin 
     176      case Asis.Elements.Declaration_Kind (Decl) is 
     177         when An_Ordinary_Type_Declaration => 
     178            declare 
     179               Def  : constant Asis.Definition := 
     180                 Asis.Declarations.Type_Declaration_View (Decl); 
     181            begin 
     182               case Asis.Elements.Type_Kind (Def) is 
     183                  when A_Derived_Type_Definition => 
     184                     declare 
     185                        use Asis.Definitions; 
     186                        Ind  : constant Asis.Subtype_Indication := 
     187                          Parent_Subtype_Indication (Def); 
     188                        Mark : constant  Asis.Expression := 
     189                          Asis.Definitions.Subtype_Mark (Ind); 
     190                     begin 
     191                        return (1 => Mark); 
     192                     end; 
     193 
     194                  when A_Derived_Record_Extension_Definition => 
     195                     declare 
     196                        use Asis.Definitions; 
     197                        Ind  : constant Asis.Subtype_Indication := 
     198                          Parent_Subtype_Indication (Def); 
     199                        Mark : constant  Asis.Expression := 
     200                          Asis.Definitions.Subtype_Mark (Ind); 
     201                     begin 
     202                        return Mark & Progenitor_List (Def); 
     203                     end; 
     204                  when An_Interface_Type_Definition => 
     205                     return Asis.Definitions.Progenitor_List (Def); 
     206                  when others => 
     207                     null; 
     208               end case; 
     209            end; 
     210         when A_Task_Type_Declaration | A_Protected_Type_Declaration => 
     211            return Asis.Declarations.Progenitor_List (Decl); 
     212         when A_Private_Extension_Declaration => 
     213            declare 
     214               Def  : constant Asis.Definition := 
     215                 Asis.Declarations.Type_Declaration_View (Decl); 
     216               Ind  : constant Asis.Subtype_Indication := 
     217                 Asis.Definitions.Ancestor_Subtype_Indication (Def); 
     218               Mark : constant  Asis.Expression := 
     219                 Asis.Definitions.Subtype_Mark (Ind); 
     220            begin 
     221               return Mark & Asis.Declarations.Progenitor_List (Decl); 
     222            end; 
     223         -- when A_Formal_Type_Definition => 
     224         when others => 
     225            null; 
     226      end case; 
     227 
     228      return Asis.Nil_Element_List; 
     229   end Get_Parents; 
    167230 
    168231   --------------------------- 
     
    260323   is 
    261324      Tipe   : Classes.Type_Info := Classes.Type_From_Declaration (Decl, Decl); 
    262       Parent : Classes.Type_Info := Classes.Parent_Type (Tipe); 
    263    begin 
    264       if Classes.Is_Not_Type (Parent) then 
    265          return; 
    266       end if; 
    267  
    268       declare 
    269          List : Asis.Declaration_List := User_Primitive_Subprograms (Parent); 
    270       begin 
    271          for I in List'Range loop 
    272             if not Is_Ext_Equal_Operator (List (I), Tipe) then 
    273                Make_Inherited_Subprogram (List (I), Point, Tipe, Parent); 
    274             end if; 
    275          end loop; 
    276       end; 
     325      List   : Asis.Name_List := Get_Parents (Decl); 
     326   begin 
     327      for J in List'Range loop 
     328         declare 
     329            Parent : constant Classes.Type_Info := 
     330              Classes.Type_From_Subtype_Mark (List (J), Decl); 
     331            Proc   : Asis.Declaration_List := 
     332              User_Primitive_Subprograms (Parent); 
     333         begin 
     334            for I in Proc'Range loop 
     335               if not Is_Ext_Equal_Operator (Proc (I), Tipe) then 
     336                  Make_Inherited_Subprogram (Proc (I), Point, Tipe, Parent); 
     337               end if; 
     338            end loop; 
     339         end; 
     340      end loop; 
    277341   end Make_Inherited_Subprograms; 
    278342