frontend.adb: Update call to Unnest_Subprograms.
2016-04-21 Javier Miranda <miranda@adacore.com> * frontend.adb: Update call to Unnest_Subprograms. * exp_ch6.ads, exp_ch6.adb, exp_unst.ads, exp_unst.adb (Unnest_Subprograms): Moved to package exp_unst. * exp_unst.ads (Unnest_Subprogram): Moved to the body of the package. * exp_dbug.adb (Qualify_Entity_Name): Enable qualification of enumeration literals when generating C code. From-SVN: r235303
This commit is contained in:
parent
e379beb56f
commit
29a56f611a
@ -1,3 +1,13 @@
|
||||
2016-04-21 Javier Miranda <miranda@adacore.com>
|
||||
|
||||
* frontend.adb: Update call to Unnest_Subprograms.
|
||||
* exp_ch6.ads, exp_ch6.adb, exp_unst.ads, exp_unst.adb
|
||||
(Unnest_Subprograms): Moved to package exp_unst.
|
||||
* exp_unst.ads (Unnest_Subprogram): Moved to the body of the
|
||||
package.
|
||||
* exp_dbug.adb (Qualify_Entity_Name): Enable qualification of
|
||||
enumeration literals when generating C code.
|
||||
|
||||
2016-04-21 Javier Miranda <miranda@adacore.com>
|
||||
|
||||
* frontend.adb: Remove call to initialize Exp_Ch6.
|
||||
|
@ -42,7 +42,6 @@ with Exp_Dist; use Exp_Dist;
|
||||
with Exp_Intr; use Exp_Intr;
|
||||
with Exp_Pakd; use Exp_Pakd;
|
||||
with Exp_Tss; use Exp_Tss;
|
||||
with Exp_Unst; use Exp_Unst;
|
||||
with Exp_Util; use Exp_Util;
|
||||
with Freeze; use Freeze;
|
||||
with Ghost; use Ghost;
|
||||
@ -8434,59 +8433,4 @@ package body Exp_Ch6 is
|
||||
end loop;
|
||||
end Set_Enclosing_Sec_Stack_Return;
|
||||
|
||||
------------------------
|
||||
-- Unnest_Subprograms --
|
||||
------------------------
|
||||
|
||||
procedure Unnest_Subprograms (N : Node_Id) is
|
||||
|
||||
function Search_Subprograms (N : Node_Id) return Traverse_Result;
|
||||
-- Tree visitor that search for outer level procedures with nested
|
||||
-- subprograms and invokes Unnest_Subprogram()
|
||||
|
||||
------------------------
|
||||
-- Search_Subprograms --
|
||||
------------------------
|
||||
|
||||
function Search_Subprograms (N : Node_Id) return Traverse_Result is
|
||||
begin
|
||||
if Nkind_In (N, N_Subprogram_Body,
|
||||
N_Subprogram_Body_Stub)
|
||||
then
|
||||
declare
|
||||
Spec_Id : constant Entity_Id := Unique_Defining_Entity (N);
|
||||
|
||||
begin
|
||||
-- We are only interested in subprograms (not generic
|
||||
-- subprograms), that have nested subprograms.
|
||||
|
||||
if Is_Subprogram (Spec_Id)
|
||||
and then Has_Nested_Subprogram (Spec_Id)
|
||||
and then Is_Library_Level_Entity (Spec_Id)
|
||||
then
|
||||
Unnest_Subprogram (Spec_Id, N);
|
||||
end if;
|
||||
end;
|
||||
end if;
|
||||
|
||||
return OK;
|
||||
end Search_Subprograms;
|
||||
|
||||
---------------
|
||||
-- Do_Search --
|
||||
---------------
|
||||
|
||||
procedure Do_Search is new Traverse_Proc (Search_Subprograms);
|
||||
-- Subtree visitor instantiation
|
||||
|
||||
-- Start of processing for Unnest_Subprograms
|
||||
|
||||
begin
|
||||
if not Opt.Unnest_Subprogram_Mode then
|
||||
return;
|
||||
end if;
|
||||
|
||||
Do_Search (N);
|
||||
end Unnest_Subprograms;
|
||||
|
||||
end Exp_Ch6;
|
||||
|
@ -209,9 +209,4 @@ package Exp_Ch6 is
|
||||
-- parameter to identify the accessibility level of the function result
|
||||
-- "determined by the point of call".
|
||||
|
||||
procedure Unnest_Subprograms (N : Node_Id);
|
||||
-- Called to unnest subprograms. If we are in unnest subprogram mode, this
|
||||
-- is the call that traverses the tree N and locates all the library level
|
||||
-- subprograms with nested subprograms to process them.
|
||||
|
||||
end Exp_Ch6;
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- Copyright (C) 1996-2015, Free Software Foundation, Inc. --
|
||||
-- Copyright (C) 1996-2016, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
@ -1441,6 +1441,17 @@ package body Exp_Dbug is
|
||||
Name_Len := Full_Qualify_Len;
|
||||
Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len);
|
||||
|
||||
-- Qualification needed for enumeration literals when generating C code
|
||||
-- (to simplify their management in the backend).
|
||||
|
||||
elsif Generate_C_Code
|
||||
and then Ekind (Ent) = E_Enumeration_Literal
|
||||
and then Scope (Ultimate_Alias (Ent)) /= Standard_Standard
|
||||
then
|
||||
Fully_Qualify_Name (Ent);
|
||||
Name_Len := Full_Qualify_Len;
|
||||
Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len);
|
||||
|
||||
elsif Qualify_Needed (Scope (Ent)) then
|
||||
Name_Len := 0;
|
||||
Set_Entity_Name (Ent);
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- Copyright (C) 2014-2015, Free Software Foundation, Inc. --
|
||||
-- Copyright (C) 2014-2016, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
@ -47,6 +47,18 @@ with Uintp; use Uintp;
|
||||
|
||||
package body Exp_Unst is
|
||||
|
||||
-----------------------
|
||||
-- Local Subprograms --
|
||||
-----------------------
|
||||
|
||||
procedure Unnest_Subprogram (Subp : Entity_Id; Subp_Body : Node_Id);
|
||||
-- Subp is a library-level subprogram which has nested subprograms, and
|
||||
-- Subp_Body is the corresponding N_Subprogram_Body node. This procedure
|
||||
-- declares the AREC types and objects, adds assignments to the AREC record
|
||||
-- as required, defines the xxxPTR types for uplevel referenced objects,
|
||||
-- adds the ARECP parameter to all nested subprograms which need it, and
|
||||
-- modifies all uplevel references appropriately.
|
||||
|
||||
-----------
|
||||
-- Calls --
|
||||
-----------
|
||||
@ -1704,4 +1716,59 @@ package body Exp_Unst is
|
||||
return;
|
||||
end Unnest_Subprogram;
|
||||
|
||||
------------------------
|
||||
-- Unnest_Subprograms --
|
||||
------------------------
|
||||
|
||||
procedure Unnest_Subprograms (N : Node_Id) is
|
||||
|
||||
function Search_Subprograms (N : Node_Id) return Traverse_Result;
|
||||
-- Tree visitor that search for outer level procedures with nested
|
||||
-- subprograms and invokes Unnest_Subprogram()
|
||||
|
||||
------------------------
|
||||
-- Search_Subprograms --
|
||||
------------------------
|
||||
|
||||
function Search_Subprograms (N : Node_Id) return Traverse_Result is
|
||||
begin
|
||||
if Nkind_In (N, N_Subprogram_Body,
|
||||
N_Subprogram_Body_Stub)
|
||||
then
|
||||
declare
|
||||
Spec_Id : constant Entity_Id := Unique_Defining_Entity (N);
|
||||
|
||||
begin
|
||||
-- We are only interested in subprograms (not generic
|
||||
-- subprograms), that have nested subprograms.
|
||||
|
||||
if Is_Subprogram (Spec_Id)
|
||||
and then Has_Nested_Subprogram (Spec_Id)
|
||||
and then Is_Library_Level_Entity (Spec_Id)
|
||||
then
|
||||
Unnest_Subprogram (Spec_Id, N);
|
||||
end if;
|
||||
end;
|
||||
end if;
|
||||
|
||||
return OK;
|
||||
end Search_Subprograms;
|
||||
|
||||
---------------
|
||||
-- Do_Search --
|
||||
---------------
|
||||
|
||||
procedure Do_Search is new Traverse_Proc (Search_Subprograms);
|
||||
-- Subtree visitor instantiation
|
||||
|
||||
-- Start of processing for Unnest_Subprograms
|
||||
|
||||
begin
|
||||
if not Opt.Unnest_Subprogram_Mode then
|
||||
return;
|
||||
end if;
|
||||
|
||||
Do_Search (N);
|
||||
end Unnest_Subprograms;
|
||||
|
||||
end Exp_Unst;
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- S p e c --
|
||||
-- --
|
||||
-- Copyright (C) 2014-2015, Free Software Foundation, Inc. --
|
||||
-- Copyright (C) 2014-2016, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
@ -686,12 +686,9 @@ package Exp_Unst is
|
||||
function Subp_Index (Sub : Entity_Id) return SI_Type;
|
||||
-- Given the entity for a subprogram, return corresponding Subp's index
|
||||
|
||||
procedure Unnest_Subprogram (Subp : Entity_Id; Subp_Body : Node_Id);
|
||||
-- Subp is a library-level subprogram which has nested subprograms, and
|
||||
-- Subp_Body is the corresponding N_Subprogram_Body node. This procedure
|
||||
-- declares the AREC types and objects, adds assignments to the AREC record
|
||||
-- as required, defines the xxxPTR types for uplevel referenced objects,
|
||||
-- adds the ARECP parameter to all nested subprograms which need it, and
|
||||
-- modifies all uplevel references appropriately.
|
||||
procedure Unnest_Subprograms (N : Node_Id);
|
||||
-- Called to unnest subprograms. If we are in unnest subprogram mode, this
|
||||
-- is the call that traverses the tree N and locates all the library level
|
||||
-- subprograms with nested subprograms to process them.
|
||||
|
||||
end Exp_Unst;
|
||||
|
@ -30,8 +30,8 @@ with Checks;
|
||||
with CStand;
|
||||
with Debug; use Debug;
|
||||
with Elists;
|
||||
with Exp_Ch6;
|
||||
with Exp_Dbug;
|
||||
with Exp_Unst;
|
||||
with Fmap;
|
||||
with Fname.UF;
|
||||
with Ghost; use Ghost;
|
||||
@ -439,7 +439,7 @@ begin
|
||||
|
||||
-- At this stage we can unnest subprogram bodies if required
|
||||
|
||||
Exp_Ch6.Unnest_Subprograms (Cunit (Main_Unit));
|
||||
Exp_Unst.Unnest_Subprograms (Cunit (Main_Unit));
|
||||
|
||||
-- List library units if requested
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user