+2010-10-22 Robert Dewar <dewar@adacore.com>
+
+ * exp_ch5.adb, par-ch4.adb, par-ch5.adb, sem_ch5.adb, sinfo.ads: Minor
+ reformatting.
+
2010-10-22 Arnaud Charlet <charlet@adacore.com>
* a-locale.adb: Minor code clean up.
Isc : constant Node_Id := Iteration_Scheme (N);
I_Spec : constant Node_Id := Iterator_Specification (Isc);
Id : constant Entity_Id := Defining_Identifier (I_Spec);
- Container : constant Entity_Id := Entity (Name (I_Spec));
+ Container : constant Entity_Id := Entity (Name (I_Spec));
+ Typ : constant Entity_Id := Etype (Container);
- Typ : constant Entity_Id := Etype (Container);
-
- Cursor : Entity_Id;
- New_Loop : Node_Id;
- Stats : List_Id;
+ Cursor : Entity_Id;
+ New_Loop : Node_Id;
+ Stats : List_Id;
begin
if Is_Array_Type (Typ) then
end;
else
-
-- for Index in Array loop ...
-- The cursor (index into the array) is the source Id
End_Label => Empty);
end if;
+ -- Iterators over containers
+
else
+ -- In both cases these require a cursor of the proper type
- -- Iterators over containers. In both cases these require a cursor of
- -- the proper type.
+ -- Cursor : P.Cursor_Type := Container.First;
+ -- while Cursor /= P.No_Element loop
- -- Cursor : P.Cursor_Type := Container.First;
- -- while Cursor /= P.No_Element loop
+ -- Obj : P.Element_Type renames Element (Cursor);
+ -- -- For the "of" form, the element name renames the element
+ -- -- designated by the cursor.
- -- Obj : P.Element_Type renames Element (Cursor);
- -- -- For the "of" form, the element name renames the element
- -- -- designated by the cursor.
+ -- Statements;
+ -- P.Next (Cursor);
+ -- end loop;
- -- Statements;
- -- P.Next (Cursor);
- -- end loop;
- --
-- with the obvious replacements if "reverse" is specified.
declare
Element_Type : constant Entity_Id := Etype (Id);
Pack : constant Entity_Id := Scope (Etype (Container));
-
Name_Init : Name_Id;
Name_Step : Name_Id;
-
Cond : Node_Id;
Cursor_Decl : Node_Id;
Renaming_Decl : Node_Id;
if Of_Present (I_Spec) then
Cursor := Make_Temporary (Loc, 'C');
-
else
Cursor := Id;
end if;
raise Error_Resync;
end if;
- Scan;
+ Scan; -- past SOME
I_Spec := P_Loop_Parameter_Specification;
if Nkind (I_Spec) = N_Loop_Parameter_Specification then
Scan; -- past FOR
Iter_Scheme_Node := New_Node (N_Iteration_Scheme, Token_Ptr);
Spec := P_Loop_Parameter_Specification;
+
if Nkind (Spec) = N_Loop_Parameter_Specification then
Set_Loop_Parameter_Specification (Iter_Scheme_Node, Spec);
else
function P_Iterator_Specification (Def_Id : Node_Id) return Node_Id is
Node1 : Node_Id;
+
begin
Node1 := New_Node (N_Iterator_Specification, Token_Ptr);
Set_Defining_Identifier (Node1, Def_Id);
end if;
Set_Name (Node1, P_Name);
-
return Node1;
end P_Iterator_Specification;
-- Start of processing for Analyze_Iteration_Scheme
begin
+ -- Why is following check needed ???
+
if Analyzed (N) then
return;
end if;
if Nkind (DS) = N_Function_Call
or else
(Is_Entity_Name (DS)
- and then not Is_Type (Entity (DS)))
+ and then not Is_Type (Entity (DS)))
then
-
-- This is an iterator specification. Rewrite as such
-- and analyze.
Empty,
Reverse_Present =>
Reverse_Present (LP));
-
begin
Set_Iterator_Specification (N, I_Spec);
Set_Loop_Parameter_Specification (N, Empty);
Subt : constant Node_Id := Subtype_Indication (N);
Container : constant Node_Id := Name (N);
- Ent : Entity_Id;
- Typ : Entity_Id;
+ Ent : Entity_Id;
+ Typ : Entity_Id;
begin
Enter_Name (Def_Id);
if Is_Array_Type (Typ) then
if Of_Present (N) then
Set_Etype (Def_Id, Component_Type (Typ));
-
else
Set_Etype (Def_Id, Etype (First_Index (Typ)));
end if;
- else
- -- Iteration over a container
+ -- Iteration over a container
+ else
Set_Ekind (Def_Id, E_Loop_Parameter);
+
if Of_Present (N) then
-- Find the Element_Type in the package instance that defines the
end loop;
else
-
-- Find the Cursor type in similar fashion
Ent := First_Entity (Scope (Typ));
-- is used for properly setting out of range values for use by pragmas
-- Initialize_Scalars and Normalize_Scalars.
- -- Of_Present (Flag16)
- -- Present in N_Iterator_Specification nodes, to mark the Ada 2012 iterator
- -- form over arrays and containers.
-
-- Original_Discriminant (Node2-Sem)
-- Present in identifiers. Used in references to discriminants that
-- appear in generic units. Because the names of the discriminants may be
-- Of_Present (Flag16)
-- Subtype_Indication (Node5)
+ -- Note: The Of_Present flag distinguishes the two forms
+
--------------------------
-- 5.6 Block Statement --
--------------------------
pragma Inline (Inherited_Discriminant);
pragma Inline (Instance_Spec);
pragma Inline (Intval);
+ pragma Inline (Iterator_Specification);
pragma Inline (Is_Accessibility_Actual);
pragma Inline (Is_Asynchronous_Call_Block);
pragma Inline (Is_Component_Left_Opnd);
pragma Inline (Null_Exclusion_In_Return_Present);
pragma Inline (Null_Record_Present);
pragma Inline (Object_Definition);
+ pragma Inline (Of_Present);
pragma Inline (Original_Discriminant);
pragma Inline (Original_Entity);
pragma Inline (Others_Discrete_Choices);
pragma Inline (Set_Inherited_Discriminant);
pragma Inline (Set_Instance_Spec);
pragma Inline (Set_Intval);
+ pragma Inline (Set_Iterator_Specification);
pragma Inline (Set_Is_Accessibility_Actual);
pragma Inline (Set_Is_Asynchronous_Call_Block);
pragma Inline (Set_Is_Component_Left_Opnd);
pragma Inline (Set_Null_Exclusion_In_Return_Present);
pragma Inline (Set_Null_Record_Present);
pragma Inline (Set_Object_Definition);
+ pragma Inline (Set_Of_Present);
pragma Inline (Set_Original_Discriminant);
pragma Inline (Set_Original_Entity);
pragma Inline (Set_Others_Discrete_Choices);