===================================================================
@@ -253,7 +253,7 @@
function Try_Container_Indexing
(N : Node_Id;
Prefix : Node_Id;
- Expr : Node_Id) return Boolean;
+ Exprs : List_Id) return Boolean;
-- AI05-0139: Generalized indexing to support iterators over containers
function Try_Indexed_Call
@@ -2114,7 +2114,7 @@
then
return;
- elsif Try_Container_Indexing (N, P, Exp) then
+ elsif Try_Container_Indexing (N, P, Exprs) then
return;
elsif Array_Type = Any_Type then
@@ -2276,7 +2276,7 @@
end;
end if;
- elsif Try_Container_Indexing (N, P, First (Exprs)) then
+ elsif Try_Container_Indexing (N, P, Exprs) then
return;
end if;
@@ -6475,9 +6475,10 @@
function Try_Container_Indexing
(N : Node_Id;
Prefix : Node_Id;
- Expr : Node_Id) return Boolean
+ Exprs : List_Id) return Boolean
is
Loc : constant Source_Ptr := Sloc (N);
+ Assoc : List_Id;
Disc : Entity_Id;
Func : Entity_Id;
Func_Name : Node_Id;
@@ -6508,19 +6509,34 @@
if Has_Implicit_Dereference (Etype (Prefix)) then
Build_Explicit_Dereference
(Prefix, First_Discriminant (Etype (Prefix)));
- return Try_Container_Indexing (N, Prefix, Expr);
+ return Try_Container_Indexing (N, Prefix, Exprs);
else
return False;
end if;
end if;
+ Assoc := New_List (Relocate_Node (Prefix));
+
+ -- A generalized iterator may have nore than one index expression, so
+ -- transfer all of them to the argument list to be used in the call.
+
+ declare
+ Arg : Node_Id;
+
+ begin
+ Arg := First (Exprs);
+ while Present (Arg) loop
+ Append (Relocate_Node (Arg), Assoc);
+ Next (Arg);
+ end loop;
+ end;
+
if not Is_Overloaded (Func_Name) then
Func := Entity (Func_Name);
Indexing := Make_Function_Call (Loc,
Name => New_Occurrence_Of (Func, Loc),
- Parameter_Associations =>
- New_List (Relocate_Node (Prefix), Relocate_Node (Expr)));
+ Parameter_Associations => Assoc);
Rewrite (N, Indexing);
Analyze (N);
@@ -6544,8 +6560,7 @@
else
Indexing := Make_Function_Call (Loc,
Name => Make_Identifier (Loc, Chars (Func_Name)),
- Parameter_Associations =>
- New_List (Relocate_Node (Prefix), Relocate_Node (Expr)));
+ Parameter_Associations => Assoc);
Rewrite (N, Indexing);
@@ -6586,7 +6601,8 @@
end if;
if Etype (N) = Any_Type then
- Error_Msg_NE ("container cannot be indexed with&", N, Etype (Expr));
+ Error_Msg_NE ("container cannot be indexed with&",
+ N, Etype (First (Exprs)));
Rewrite (N, New_Occurrence_Of (Any_Id, Loc));
else
Analyze (N);