Changeset 490


Ignore:
Timestamp:
Feb 4, 2017, 11:30:48 AM (6 years ago)
Author:
Maxim Reznik
Message:

Change name resolution in an instantination.

Drop package_instance use copy of generic_package instead.
Resolve each generic_association.Actual_Parameter independently on others.
Add Corresponding_View property.

The idea is to gather formal parameter list into Up of Generic_Actual_Part.
Then resolve the list at instantination node where template is available.
Propagate resolved formal names via Down. Actual parameter is resolved
at generic_association node, one by one, left to right.

Location:
trunk/ada-2012/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/ada-2012/src/ag/down.ag

    r488 r490  
    453453Rules for generic_association. :
    454454(.
    455       Self.Compilation.Context.Interpretation_Manager.Get_Down_Interpretation
    456         (${generic_association.Down}, 1, ${Actual_Parameter.Down});
     455      Gela.Pass_Utils.Resolve.Generic_Association
     456        (Self.Compilation,
     457         ${generic_association.env_in},
     458         ${Actual_Parameter.Up:Gela.Pass_Utils.Resolve.Placeholder (Self.Compilation)},
     459         ${Actual_Parameter.Down});
    457460.)
    458461
    459462Rules for generic_association. :
    460463(.
    461       Self.Compilation.Context.Interpretation_Manager.Get_Down_Interpretation
    462         (${generic_association.Down}, 2, ${Formal_Parameter.Down});
     464      ${Formal_Parameter.Down} := ${generic_association.Down};
    463465.)
    464466
     
    668670        (Self.Compilation,
    669671         ${function_instantiation.env_in},
     672         null,
    670673         ${Generic_Unit_Name.Defining_Name},
     674         Node.Generic_Actual_Part,
    671675         ${Generic_Actual_Part.Up},
    672676         ${Generic_Actual_Part.Down});
     
    704708Rules for package_instantiation. :
    705709(.
     710      Gela.Pass_Utils.Instantiation.Expand
     711        (Self.Compilation,
     712         Node,
     713         This_Expanded);
    706714      Gela.Pass_Utils.Resolve.Generic_Association_List
    707715        (Self.Compilation,
    708716         ${package_instantiation.env_in},
     717         This_Expanded,
    709718         ${Generic_Unit_Name.Defining_Name},
     719         Node.Generic_Actual_Part,
    710720         ${Generic_Actual_Part.Up},
    711721         ${Generic_Actual_Part.Down});
     
    731741        (Self.Compilation,
    732742         ${procedure_instantiation.env_in},
     743         null,
    733744         ${Generic_Unit_Name.Defining_Name},
     745         Node.Generic_Actual_Part,
    734746         ${Generic_Actual_Part.Up},
    735747         ${Generic_Actual_Part.Down});
  • trunk/ada-2012/src/ag/env_in.ag

    r483 r490  
    21702170.)
    21712171
    2172 Rules for Formal_Part_Copy.generic_formal :
    2173 (.
    2174       ${generic_formal.env_in} := 0;
    2175 .)
    2176 
    2177 Rules for package_instance. :
    2178 (.
    2179       ${Names.env_in} := 0;
    2180 .)
    2181 
    2182 Rules for package_instance. :
    2183 (.
    2184       ${Aspect_Specifications.env_in} := 0;
    2185 .)
    2186 
    2187 Rules for package_instance. :
    2188 (.
    2189       ${Visible_Part_Declarative_Items.env_in} := 0;
    2190 .)
    2191 
    2192 Rules for package_instance. :
    2193 (.
    2194       ${Private_Part_Declarative_Items.env_in} := 0;
    2195 .)
    2196 
    21972172Rules for package_renaming_declaration. :
    21982173(.
  • trunk/ada-2012/src/ag/main.ag.pp

    r489 r490  
    7878         ${defining_expanded_unit_name.Corresponding_Generic_Element} := null;
    7979.)
     80
     81Synthesized attributes
     82  defining_name,
     83  defining_identifier,
     84  defining_character_literal,
     85  defining_operator_symbol,
     86  defining_enumeration_literal,
     87  defining_program_unit_name,
     88  defining_expanded_unit_name
     89   : Gela.Elements.Element_Access : Corresponding_View;
     90
     91Rules for defining_identifier.identifier_token :
     92(.
     93         ${defining_identifier.Corresponding_View} := null;
     94.)
     95
     96Rules for defining_character_literal.character_literal :
     97(.
     98         ${defining_character_literal.Corresponding_View} := null;
     99.)
     100
     101Rules for defining_operator_symbol.operator_symbol_token :
     102(.
     103         ${defining_operator_symbol.Corresponding_View} := null;
     104.)
     105
     106Rules for defining_enumeration_literal.identifier :
     107(.
     108         ${defining_enumeration_literal.Corresponding_View} := null;
     109.)
     110
     111Rules for defining_expanded_unit_name. :
     112(.
     113         ${defining_expanded_unit_name.Corresponding_View} := null;
     114.)
  • trunk/ada-2012/src/ag/syntax.ag

    r483 r490  
    12681268;
    12691269
    1270 package_instance ::=
    1271   {generic_formal}           <Formal_Part_Copy>
    1272   defining_program_unit_name <Names>
    1273   {aspect_specification}     <Aspect_Specifications>
    1274   {basic_declarative_item}   <Visible_Part_Declarative_Items>
    1275   {basic_declarative_item}   <Private_Part_Declarative_Items>
    1276 ;
    1277 
    12781270package_instantiation ::=
    12791271  token                      <package_token>
  • trunk/ada-2012/src/ag/up.ag

    r474 r490  
    2525  extension_aggregate,
    2626  auxiliary_apply,
     27  generic_association,
    2728  generic_formal_parameter,
    2829  identifier,
     
    6566Synthesized attributes
    6667  Array_Component_Choices,
     68  Generic_Actual_Part,
    6769  Variant_Choices,
    6870  association,
    69   generic_association,
    7071  case_path,
    7172  variant
     
    7576  Associations,
    7677  Case_Statement_Paths,
    77   Generic_Actual_Part,
    7878  Record_Component_Associations,
    7979  Variants,
     
    112112Rules for Generic_Actual_Part.generic_association :
    113113(.
    114       Self.Compilation.Context.Interpretation_Manager.Add_Tuple_List
     114      Self.Compilation.Context.Interpretation_Manager.Add_Tuple
    115115        (${generic_association.Up}, ${tail.Up}, ${Generic_Actual_Part.Up});
    116116.)
     
    216216Rules for generic_association. :
    217217(.
    218       Self.Compilation.Context.Interpretation_Manager.Add_Tuple
    219         (${Formal_Parameter.Up:Gela.Pass_Utils.Resolve.Placeholder (Self.Compilation)},
    220          0,
    221          ${generic_association.Up});
    222 
    223       Self.Compilation.Context.Interpretation_Manager.Add_Tuple
    224         (${Actual_Parameter.Up:Gela.Pass_Utils.Resolve.Placeholder (Self.Compilation)},
    225          ${generic_association.Up},
    226          ${generic_association.Up});
     218      ${generic_association.Up} :=
     219        ${Formal_Parameter.Up:Gela.Pass_Utils.Resolve.Placeholder (Self.Compilation)};
    227220.)
    228221
  • trunk/ada-2012/src/api/gela-lexers.ads

    r415 r490  
    2929      Input   : League.Strings.Universal_String;
    3030      Output  : not null access Lexer_Destination'Class) is abstract;
    31    --  Analyse gigen Input and report events to Output
     31   --  Analyse given Input and report events to Output
    3232
    3333end Gela.Lexers;
  • trunk/ada-2012/src/api/gela-type_managers.ads

    r434 r490  
    3232     (Self  : access Type_Manager;
    3333      Env   : Gela.Semantic_Types.Env_Index;
    34       Node  : Gela.Elements.Element_Access)
     34      Node  : Gela.Elements.Element_Access)  --  FIXME access Element'Class?
    3535      return Gela.Semantic_Types.Type_Index is abstract;
    3636   --  Return type corresponding to Node of object declaration
  • trunk/ada-2012/src/asis/asis-extensions-flat_kinds.adb

    r486 r490  
    133133with Gela.Elements.Package_Body_Stubs;
    134134with Gela.Elements.Package_Declarations;
    135 with Gela.Elements.Package_Instances;
    136135with Gela.Elements.Package_Instantiations;
    137136with Gela.Elements.Package_Renaming_Declarations;
     
    877876      Node : not null Gela.Elements.Package_Declarations.
    878877        Package_Declaration_Access);
    879 
    880    overriding procedure Package_Instance
    881      (Self : in out Visiter;
    882       Node : not null Gela.Elements.Package_Instances.Package_Instance_Access);
    883878
    884879   overriding procedure Package_Instantiation
     
    21152110   end Package_Declaration;
    21162111
    2117    overriding procedure Package_Instance
    2118      (Self : in out Visiter;
    2119       Node : not null Gela.Elements.Package_Instances.Package_Instance_Access)
    2120    is
    2121       pragma Unreferenced (Node);
    2122    begin
    2123       Self.Result := A_Package_Declaration;
    2124    end Package_Instance;
    2125 
    21262112   overriding procedure Package_Instantiation
    21272113     (Self : in out Visiter;
  • trunk/ada-2012/src/semantic/gela-instantiation.adb

    r489 r490  
    77with Gela.Property_Visiters;
    88
    9 with Gela.Elements.Aspect_Specifications;
    109with Gela.Elements.Basic_Declarative_Items;
    1110with Gela.Elements.Defining_Identifiers;
    1211with Gela.Elements.Defining_Names;
    13 with Gela.Elements.Defining_Program_Unit_Names;
    1412with Gela.Elements.Full_Type_Declarations;
    15 with Gela.Elements.Generic_Formals;
    1613with Gela.Elements.Generic_Package_Declarations;
    17 with Gela.Elements.Package_Instances;
    1814with Gela.Elements.Subtype_Declarations;
    1915with Gela.Interpretations;
     
    4440   package Cloners is
    4541      type Cloner is new Gela.Element_Cloners.Cloner with record
    46          Map           : Name_Maps.Map;
    47          Instance_Name : Gela.Elements.Defining_Names.Defining_Name_Access;
    48          Template      : access Gela.Elements.Element'Class;
     42         Map              : Name_Maps.Map;
     43         Instance_Name    : Gela.Elements.Defining_Names.Defining_Name_Access;
     44         Template         : access Gela.Elements.Element'Class;
    4945      end record;
    5046
     
    5854         Node : not null Gela.Elements.Defining_Identifiers.
    5955           Defining_Identifier_Access);
    60 
    61       overriding procedure Generic_Package_Declaration
    62         (Self : in out Cloner;
    63          Node : not null Gela.Elements.Generic_Package_Declarations.
    64            Generic_Package_Declaration_Access);
    6556
    6657   end Cloners;
     
    168159         Value   : out Gela.Elements.Element_Access);
    169160
     161      overriding procedure On_Corresponding_View
     162        (Self    : in out Property_Setter;
     163         Element : Gela.Elements.Element_Access;
     164         Value   : out Gela.Elements.Element_Access);
     165
    170166      overriding procedure On_Expanded
    171167        (Self    : in out Property_Setter;
     
    187183           Full_Type_Declaration_Access);
    188184
    189       overriding procedure Package_Instance
     185      overriding procedure Generic_Package_Declaration
    190186        (Self : in out Visiter;
    191          Node : not null Gela.Elements.Package_Instances.
    192            Package_Instance_Access);
     187         Node : not null Gela.Elements.Generic_Package_Declarations.
     188           Generic_Package_Declaration_Access);
    193189
    194190      overriding procedure Subtype_Declaration
     
    445441      end On_Corresponding_Generic_Element;
    446442
     443      overriding procedure On_Corresponding_View
     444        (Self    : in out Property_Setter;
     445         Element : Gela.Elements.Element_Access;
     446         Value   : out Gela.Elements.Element_Access)
     447      is
     448         pragma Unreferenced (Self, Element);
     449      begin
     450         Value := null;
     451      end On_Corresponding_View;
     452
    447453      overriding procedure On_Expanded
    448454        (Self    : in out Property_Setter;
     
    508514      end Defining_Identifier;
    509515
    510       ---------------------------------
    511       -- Generic_Package_Declaration --
    512       ---------------------------------
    513 
    514       overriding procedure Generic_Package_Declaration
    515         (Self : in out Cloner;
    516          Node : not null Gela.Elements.Generic_Package_Declarations.
    517            Generic_Package_Declaration_Access)
    518       is
    519          Element : constant Gela.Elements.Element_Access :=
    520            Gela.Elements.Element_Access (Node);
    521          Formal_Part_Copy               : Gela.Elements.Generic_Formals.
    522            Generic_Formal_Sequence_Access;
    523          Names                          : Gela.Elements.
    524            Defining_Program_Unit_Names.Defining_Program_Unit_Name_Access;
    525          Aspect_Specifications          : Gela.Elements.Aspect_Specifications.
    526            Aspect_Specification_Sequence_Access;
    527          Visible_Part_Declarative_Items : Gela.Elements.Basic_Declarative_Items
    528            .Basic_Declarative_Item_Sequence_Access;
    529          Private_Part_Declarative_Items : Gela.Elements.Basic_Declarative_Items
    530            .Basic_Declarative_Item_Sequence_Access;
    531 
    532          Result : Gela.Elements.Package_Instances.Package_Instance_Access;
    533       begin
    534          if Self.Template = Element then
    535             if Node.Generic_Formal_Part not in null then
    536                declare
    537                   Item   : Gela.Elements.Generic_Formals.
    538                     Generic_Formal_Access;
    539                   Cursor : Gela.Elements.Generic_Formals.
    540                     Generic_Formal_Sequence_Cursor :=
    541                       Node.Generic_Formal_Part.First;
    542                begin
    543                   Formal_Part_Copy := Self.Factory.Generic_Formal_Sequence;
    544 
    545                   while Cursor.Has_Element loop
    546                      Item := Gela.Elements.Generic_Formals.
    547                        Generic_Formal_Access
    548                          (Cloner'Class (Self).Clone (Cursor.Element));
    549                      Formal_Part_Copy.Append (Item);
    550                      Cursor.Next;
    551                   end loop;
    552                end;
    553             end if;
    554 
    555             Names := Gela.Elements.Defining_Program_Unit_Names.
    556               Defining_Program_Unit_Name_Access
    557                 (Cloner'Class (Self).Clone (Self.Instance_Name));
    558 
    559             if Node.Aspect_Specifications not in null then
    560                declare
    561                   Item   : Gela.Elements.Aspect_Specifications.
    562                     Aspect_Specification_Access;
    563                   Cursor : Gela.Elements.Aspect_Specifications.
    564                     Aspect_Specification_Sequence_Cursor :=
    565                       Node.Aspect_Specifications.First;
    566                begin
    567                   Aspect_Specifications := Self.Factory.
    568                     Aspect_Specification_Sequence;
    569 
    570                   while Cursor.Has_Element loop
    571                      Item := Gela.Elements.Aspect_Specifications.
    572                        Aspect_Specification_Access
    573                          (Cloner'Class (Self).Clone (Cursor.Element));
    574                      Aspect_Specifications.Append (Item);
    575                      Cursor.Next;
    576                   end loop;
    577                end;
    578             end if;
    579 
    580             if Node.Visible_Part_Declarative_Items not in null then
    581                declare
    582                   Item  : Gela.Elements.Basic_Declarative_Items.
    583                     Basic_Declarative_Item_Access;
    584                   Cursor  : Gela.Elements.Basic_Declarative_Items.
    585                     Basic_Declarative_Item_Sequence_Cursor :=
    586                       Node.Visible_Part_Declarative_Items.First;
    587                begin
    588                   Visible_Part_Declarative_Items := Self.Factory.
    589                     Basic_Declarative_Item_Sequence;
    590 
    591                   while Cursor.Has_Element loop
    592                      Item := Gela.Elements.Basic_Declarative_Items.
    593                        Basic_Declarative_Item_Access
    594                          (Cloner'Class (Self).Clone (Cursor.Element));
    595                      Visible_Part_Declarative_Items.Append (Item);
    596                      Cursor.Next;
    597                   end loop;
    598                end;
    599             end if;
    600 
    601             if Node.Private_Part_Declarative_Items not in null then
    602                declare
    603                   Item  : Gela.Elements.Basic_Declarative_Items.
    604                     Basic_Declarative_Item_Access;
    605                   Cursor : Gela.Elements.Basic_Declarative_Items.
    606                     Basic_Declarative_Item_Sequence_Cursor :=
    607                       Node.Private_Part_Declarative_Items.First;
    608                begin
    609                   Private_Part_Declarative_Items := Self.Factory.
    610                     Basic_Declarative_Item_Sequence;
    611 
    612                   while Cursor.Has_Element loop
    613                      Item := Gela.Elements.Basic_Declarative_Items.
    614                        Basic_Declarative_Item_Access
    615                          (Cloner'Class (Self).Clone (Cursor.Element));
    616                      Private_Part_Declarative_Items.Append (Item);
    617                      Cursor.Next;
    618                   end loop;
    619                end;
    620             end if;
    621 
    622             Result := Self.Factory.Package_Instance
    623               (Formal_Part_Copy, Names, Aspect_Specifications,
    624                Visible_Part_Declarative_Items,
    625                Private_Part_Declarative_Items);
    626 
    627             Self.Result := Gela.Elements.Element_Access (Result);
    628          else
    629             Gela.Element_Cloners.Cloner (Self)
    630               .Generic_Package_Declaration (Node);
    631          end if;
    632       end Generic_Package_Declaration;
    633 
    634516   end Cloners;
    635517
     
    652534      end Full_Type_Declaration;
    653535
    654       overriding procedure Package_Instance
     536      overriding procedure Generic_Package_Declaration
    655537        (Self : in out Visiter;
    656          Node : not null Gela.Elements.Package_Instances.
    657            Package_Instance_Access)
     538         Node : not null Gela.Elements.Generic_Package_Declarations.
     539           Generic_Package_Declaration_Access)
    658540      is
    659541         Name : Gela.Elements.Defining_Names.Defining_Name_Access;
     
    687569
    688570         Self.Env := Self.Set.Leave_Declarative_Region (Self.Env);
    689       end Package_Instance;
     571      end Generic_Package_Declaration;
    690572
    691573      overriding procedure Subtype_Declaration
  • trunk/ada-2012/src/semantic/gela-instantiation.ads

    r485 r490  
    55package Gela.Instantiation is
    66   pragma Preelaborate;
     7
     8   --  Each instantination declaration has property Expanded with
     9   --  deep copy of corresponding generic declaration.
     10   --
     11   --  Defining_Name property of each identifier in this copy is fixed to refer
     12   --  to copied defining name. Each defining_name in the copy has property
     13   --  named Corresponding_Generic_Element. It refers to corresponding
     14   --  defining name in the template.
     15   --
     16   --  Each formal declaration of this copy has property Corresponding_View.
     17   --  It refers to corresponding expression of Generic_Actual_Part.
     18   --  Type manager takes this property into account when resolves types in
     19   --  Generic_Actual_Part and in other places outside of instance.
    720
    821   procedure Expand
  • trunk/ada-2012/src/semantic/gela-plain_type_managers.adb

    r488 r490  
    909909            Node : not null Gela.Elements.Identifiers.Identifier_Access)
    910910         is
     911            View          : Gela.Elements.Subtype_Marks.Subtype_Mark_Access;
    911912            Defining_Name : constant Gela.Elements.Defining_Names.
    912913              Defining_Name_Access := Node.Defining_Name;
    913914         begin
    914             if Defining_Name.Assigned then
     915            if not Defining_Name.Assigned then
     916               return;
     917            end if;
     918
     919            View := Gela.Elements.Subtype_Marks.Subtype_Mark_Access
     920              (Defining_Name.Corresponding_View);
     921
     922            if View.Assigned then
     923               Self.Result := Type_From_Subtype_Mark.Self.
     924                 Type_From_Subtype_Mark (Env, View);
     925            else
    915926               Self.Result :=
    916927                 Type_From_Subtype_Mark.Self.Type_By_Name (Env, Defining_Name);
  • trunk/ada-2012/src/semantic/gela-resolve.adb

    r488 r490  
    11941194   end Function_Call;
    11951195
     1196   procedure Generic_Association
     1197     (Comp         : Gela.Compilations.Compilation_Access;
     1198      Env          : Gela.Semantic_Types.Env_Index;
     1199--      Actual_Part  : Gela.Elements.Generic_Associations.
     1200--                       Generic_Association_Sequence_Access;
     1201      Up      : Gela.Interpretations.Interpretation_Set_Index;
     1202      Result       : out Gela.Interpretations.Interpretation_Index) is
     1203   begin
     1204      Interpretation
     1205        (Comp,
     1206         Env,
     1207         Up,
     1208         Result);
     1209   end Generic_Association;
     1210
    11961211   ------------------------------
    11971212   -- Generic_Association_List --
     
    12011216     (Comp         : Gela.Compilations.Compilation_Access;
    12021217      Env          : Gela.Semantic_Types.Env_Index;
     1218      Instance     : Gela.Elements.Element_Access;
    12031219      Generic_Name : Gela.Elements.Defining_Names.Defining_Name_Access;
    1204       Associations : Gela.Interpretations.Interpretation_Tuple_List_Index;
     1220      Actual_Part  : Gela.Elements.Generic_Associations.
     1221                       Generic_Association_Sequence_Access;
     1222      Associations : Gela.Interpretations.Interpretation_Tuple_Index;
    12051223      Result       : out Gela.Interpretations.Interpretation_Index)
    12061224   is
    1207 
    1208       procedure Resolve_Formal
    1209         (Value  : Gela.Interpretations.Interpretation_Set_Index;
    1210          Result : out Gela.Interpretations.Interpretation_Index);
     1225      pragma Unreferenced (Env);
    12111226
    12121227      function Hash
     
    12281243         "="          => Gela.Elements.Defining_Names."=");
    12291244
    1230       Names : Name_Vectors.Vector;
    1231       Map   : Symbol_To_Name_Index_Maps.Map;
     1245      type Formal_Defining_Names is record
     1246         Names : Name_Vectors.Vector;
     1247         Map   : Symbol_To_Name_Index_Maps.Map;
     1248      end record;
     1249
     1250      procedure Resolve_Formal
     1251        (Formal : Formal_Defining_Names;
     1252         Value  : Gela.Interpretations.Interpretation_Set_Index;
     1253         Name   : out Gela.Elements.Defining_Names.Defining_Name_Access);
     1254
    12321255
    12331256      IM : constant Gela.Interpretations.Interpretation_Manager_Access :=
     
    12351258
    12361259      package Visiters is
    1237          type Visiter is new Gela.Element_Visiters.Visiter with null record;
     1260         type Visiter is new Gela.Element_Visiters.Visiter with record
     1261            Formal : Formal_Defining_Names;
     1262         end record;
    12381263
    12391264         overriding procedure Formal_Object_Declaration
     
    12611286              Formal_Object_Declaration_Access)
    12621287         is
    1263             pragma Unreferenced (Self);
    1264 
    12651288            List   : constant Gela.Elements.Defining_Identifiers.
    12661289              Defining_Identifier_Sequence_Access := Node.Names;
     
    12721295               Item := Gela.Elements.Defining_Names.Defining_Name_Access
    12731296                 (Cursor.Element);
    1274                Names.Append (Item);
    1275                Map.Include (Item.Full_Name, Names.Last_Index);
     1297               Self.Formal.Names.Append (Item);
     1298               Self.Formal.Map.Include
     1299                 (Item.Full_Name, Self.Formal.Names.Last_Index);
    12761300               Cursor.Next;
    12771301            end loop;
     
    12871311              Formal_Type_Declaration_Access)
    12881312         is
    1289             pragma Unreferenced (Self);
    1290 
    12911313            Name : constant Gela.Elements.Defining_Identifiers.
    12921314              Defining_Identifier_Access := Node.Names;
     
    12941316              := Gela.Elements.Defining_Names.Defining_Name_Access (Name);
    12951317         begin
    1296             Names.Append (Item);
    1297             Map.Include (Item.Full_Name, Names.Last_Index);
     1318            Self.Formal.Names.Append (Item);
     1319            Self.Formal.Map.Include
     1320              (Item.Full_Name, Self.Formal.Names.Last_Index);
    12981321         end Formal_Type_Declaration;
    12991322
     
    13221345      end Visiters;
    13231346
     1347
     1348      --------------------
     1349      -- Resolve_Formal --
     1350      --------------------
     1351
    13241352      procedure Resolve_Formal
    1325         (Value  : Gela.Interpretations.Interpretation_Set_Index;
    1326          Result : out Gela.Interpretations.Interpretation_Index)
     1353        (Formal : Formal_Defining_Names;
     1354         Value  : Gela.Interpretations.Interpretation_Set_Index;
     1355         Name   : out Gela.Elements.Defining_Names.Defining_Name_Access)
    13271356      is
     1357
    13281358         package Each is
    13291359            type Visiter is new Gela.Interpretations.Up_Visiter with
     
    13461376
    13471377               Found : constant Symbol_To_Name_Index_Maps.Cursor :=
    1348                  Map.Find (Symbol);
    1349                Name  : Gela.Elements.Defining_Names.Defining_Name_Access;
     1378                 Formal.Map.Find (Symbol);
    13501379            begin
    13511380               if Symbol_To_Name_Index_Maps.Has_Element (Found) then
    1352                   Name := Names (Symbol_To_Name_Index_Maps.Element (Found));
    1353                   IM.Get_Defining_Name_Index (Name, Result);
     1381                  Name := Formal.Names
     1382                    (Symbol_To_Name_Index_Maps.Element (Found));
    13541383               end if;
    13551384            end On_Symbol;
     
    13671396      end Resolve_Formal;
    13681397
    1369       Generic_Declaration : Gela.Elements.Element_Access;
    1370 
    1371       Tuples : constant Gela.Interpretations.Interpretation_Tuple_Index_Array
    1372         := IM.Get_Tuple_List (Associations);
    1373 
    1374       Output  : Gela.Interpretations.Interpretation_Index_Array (Tuples'Range);
     1398      Visitor  : Visiters.Visiter;
     1399      Tuples   : constant Gela.Interpretations.Interpretation_Set_Index_Array
     1400        := IM.Get_Tuple (Associations);
     1401
     1402      Name    : Gela.Elements.Defining_Names.Defining_Name_Access;
     1403      Formal  : Gela.Interpretations.Interpretation_Index_Array (Tuples'Range)
     1404        := (others => 0);
    13751405      Chosen  : Gela.Interpretations.Interpretation_Index;
    1376       Visiter : Visiters.Visiter;
    1377    begin
    1378       if not Generic_Name.Assigned then
     1406      Element : Gela.Elements.Defining_Names.Defining_Name_Access;
     1407      Cursor  : Gela.Elements.Generic_Associations
     1408        .Generic_Association_Sequence_Cursor := Actual_Part.First;
     1409   begin
     1410      if not Generic_Name.Assigned or not Instance.Assigned then
    13791411         Result := 0;
    13801412         return;
    13811413      end if;
    1382 
    1383       Generic_Declaration := Generic_Name.Enclosing_Element;
    1384       Generic_Declaration.Visit (Visiter);
     1414      --  Collect defining names of formal declarations in the instance
     1415      Instance.Visit (Visitor);
    13851416
    13861417      for J in Tuples'Range loop
    1387          declare
    1388             Value  : constant Gela.Interpretations
    1389               .Interpretation_Set_Index_Array :=
    1390                 IM.Get_Tuple (Tuples (J));
    1391             List   : Gela.Interpretations.Interpretation_Index_Array
    1392               (Value'Range);
    1393          begin
    1394             Resolve_Formal (Value (Value'Last), List (List'Last));
    1395 
    1396             --  FIXME Shall depend on formal parameter declaration
    1397             Shall_Be_Subtype
    1398               (Comp, Env, Value (Value'First), List (List'First));
    1399 
    1400             IM.Get_Tuple_Index
    1401               (List (List'First), List (List'Last), Output (J));
    1402          end;
     1418         Resolve_Formal (Visitor.Formal, Tuples (J), Name);
     1419
     1420         if Name.Assigned then
     1421            Name.Set_Corresponding_View
     1422              (Gela.Elements.Element_Access
     1423                 (Cursor.Element.Actual_Parameter));
     1424
     1425            Element := Gela.Elements.Defining_Names.Defining_Name_Access
     1426              (Name.Corresponding_Generic_Element);
     1427
     1428            IM.Get_Defining_Name_Index (Element, Formal (J));
     1429         end if;
     1430
     1431         Cursor.Next;
    14031432      end loop;
    14041433
    14051434      Chosen := 0;
    14061435
    1407       for K in reverse Output'Range loop
    1408          IM.Get_Tuple_Index (Output (K), Chosen, Chosen);
     1436      for K in reverse Formal'Range loop
     1437         IM.Get_Tuple_Index (Formal (K), Chosen, Chosen);
    14091438      end loop;
    14101439
  • trunk/ada-2012/src/semantic/gela-resolve.ads

    r474 r490  
    55with Gela.Semantic_Types;
    66with Gela.Elements.Defining_Names;
     7with Gela.Elements.Generic_Associations;
    78
    89package Gela.Resolve is
     
    186187      Result   : out Gela.Interpretations.Interpretation_Index);
    187188
     189   procedure Generic_Association
     190     (Comp         : Gela.Compilations.Compilation_Access;
     191      Env          : Gela.Semantic_Types.Env_Index;
     192--      Actual_Part  : Gela.Elements.Generic_Associations.
     193--                       Generic_Association_Sequence_Access;
     194      Up      : Gela.Interpretations.Interpretation_Set_Index;
     195      Result  : out Gela.Interpretations.Interpretation_Index);
     196
    188197   procedure Generic_Association_List
    189198     (Comp         : Gela.Compilations.Compilation_Access;
    190199      Env          : Gela.Semantic_Types.Env_Index;
     200      Instance     : Gela.Elements.Element_Access;
    191201      Generic_Name : Gela.Elements.Defining_Names.Defining_Name_Access;
    192       Associations : Gela.Interpretations.Interpretation_Tuple_List_Index;
     202      Actual_Part  : Gela.Elements.Generic_Associations.
     203                       Generic_Association_Sequence_Access;
     204      Associations : Gela.Interpretations.Interpretation_Tuple_Index;
    193205      Result       : out Gela.Interpretations.Interpretation_Index);
    194206
Note: See TracChangeset for help on using the changeset viewer.