Commit 1d24fc5e by Emmanuel Briot Committed by Arnaud Charlet

fmap.ads, [...] (Source_Data.Get_Object): Field removed, since it can be…

fmap.ads, [...] (Source_Data.Get_Object): Field removed, since it can be computed efficiently from the other fields.

2009-06-25  Emmanuel Briot  <briot@adacore.com>

	* fmap.ads, make.adb, prj.adb, prj.ads, prj-nmsc.adb, prj-env.adb,
	prj-env.ads (Source_Data.Get_Object): Field removed, since it can be
	computed efficiently from the other fields.
	(Object_To_Global_Archive): New subprogram
	(Create_Mapping): Remove unneeded call to Remove_Forbidden_File_Name.
	(Override_Kind): Fix handling of separates in Ada.
	(Create_Mapping_File): Remove duplicate code
	(Naming_Data.Implementation_Exception, Specification_Exception):
	field removed, since never used.
	(Naming_Data.Specs, .Bodies): field removed, since this is only
	used while processing the project and is not needed once the tree
	is in memory. This brings Naming_Data and Lang_Naming_Data
	closer (same content now, but different use still).

From-SVN: r148934
parent 8f2eeab7
2009-06-25 Emmanuel Briot <briot@adacore.com>
* fmap.ads, make.adb, prj.adb, prj.ads, prj-nmsc.adb, prj-env.adb,
prj-env.ads (Source_Data.Get_Object): Field removed, since it can be
computed efficiently from the other fields.
(Object_To_Global_Archive): New subprogram
(Create_Mapping): Remove unneeded call to Remove_Forbidden_File_Name.
(Override_Kind): Fix handling of separates in Ada.
(Create_Mapping_File): Remove duplicate code
(Naming_Data.Implementation_Exception, Specification_Exception):
field removed, since never used.
(Naming_Data.Specs, .Bodies): field removed, since this is only
used while processing the project and is not needed once the tree
is in memory. This brings Naming_Data and Lang_Naming_Data
closer (same content now, but different use still).
2009-06-25 Pascal Obry <obry@adacore.com>
* sem_ch4.adb: Minor reformatting.
......
......@@ -31,6 +31,7 @@
-- following:
-- For each source file, there are three lines in the mapping file:
-- Unit name with %b or %s added depending on whether it is a body or a spec
-- This line is omitted for file-based languages
-- File name
-- Path name (set to '/' if the file should be ignored in fact, ie for
-- a Locally_Removed_File in a project)
......
......@@ -6643,7 +6643,7 @@ package body Make is
Prj.Env.Create_Mapping_File
(Project,
In_Tree => Project_Tree,
Language => No_Name,
Language => Name_Ada,
Name => Data.Mapping_File_Names
(Data.Last_Mapping_File_Names));
......
......@@ -41,17 +41,13 @@ package Prj.Env is
procedure Create_Mapping_File
(Project : Project_Id;
Language : Name_Id := No_Name;
Language : Name_Id;
In_Tree : Project_Tree_Ref;
Name : out Path_Name_Type);
-- Create a temporary mapping file for project Project. For each source or
-- template of Language in the Project, put the mapping of its file
-- name and path name in this file.
--
-- This function either looks at all the source files for the specified
-- language in the project, or if Language is set to No_Name, at all
-- units in the project.
--
-- Implementation note: we pass a language name, not a language_index here,
-- since the latter would have to match exactly the index of that language
-- for the specified project, and that is not information available in
......
......@@ -277,9 +277,14 @@ package body Prj.Nmsc is
procedure Check_Naming_Schemes
(Project : Project_Id;
In_Tree : Project_Tree_Ref;
Is_Config_File : Boolean);
Is_Config_File : Boolean;
Bodies : out Array_Element_Id;
Specs : out Array_Element_Id);
-- Check the naming scheme part of Data.
-- Is_Config_File should be True if Project is a config file (.cgpr)
-- This also returns the naming scheme exceptions for unit-based
-- languages (Bodies and Specs are associative arrays mapping individual
-- unit names to source file names).
procedure Check_Configuration
(Project : Project_Id;
......@@ -831,6 +836,8 @@ package body Prj.Nmsc is
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
is
Specs : Array_Element_Id;
Bodies : Array_Element_Id;
Extending : Boolean := False;
begin
......@@ -908,13 +915,11 @@ package body Prj.Nmsc is
Extending := Project.Extends /= No_Project;
Check_Naming_Schemes (Project, In_Tree, Is_Config_File);
Check_Naming_Schemes (Project, In_Tree, Is_Config_File, Bodies, Specs);
if Get_Mode = Ada_Only then
Prepare_Ada_Naming_Exceptions
(Project.Naming.Bodies, In_Tree, Impl);
Prepare_Ada_Naming_Exceptions
(Project.Naming.Specs, In_Tree, Spec);
Prepare_Ada_Naming_Exceptions (Bodies, In_Tree, Impl);
Prepare_Ada_Naming_Exceptions (Specs, In_Tree, Spec);
end if;
-- Find the sources
......@@ -929,11 +934,11 @@ package body Prj.Nmsc is
-- of this project file.
Warn_If_Not_Sources
(Project, In_Tree, Project.Naming.Bodies,
(Project, In_Tree, Bodies,
Specs => False,
Extending => Extending);
Warn_If_Not_Sources
(Project, In_Tree, Project.Naming.Specs,
(Project, In_Tree, Specs,
Specs => True,
Extending => Extending);
......@@ -2700,7 +2705,9 @@ package body Prj.Nmsc is
procedure Check_Naming_Schemes
(Project : Project_Id;
In_Tree : Project_Tree_Ref;
Is_Config_File : Boolean)
Is_Config_File : Boolean;
Bodies : out Array_Element_Id;
Specs : out Array_Element_Id)
is
Naming_Id : constant Package_Id :=
Util.Value_Of (Name_Naming, Project.Decl.Packages, In_Tree);
......@@ -3163,20 +3170,18 @@ package body Prj.Nmsc is
Separate_Suffix => Project.Naming.Separate_Suffix,
Sep_Suffix_Loc => Sep_Suffix_Loc);
Project.Naming.Bodies :=
Util.Value_Of (Name_Body, Naming.Decl.Arrays, In_Tree);
Bodies := Util.Value_Of (Name_Body, Naming.Decl.Arrays, In_Tree);
if Project.Naming.Bodies /= No_Array_Element then
if Bodies /= No_Array_Element then
Check_And_Normalize_Unit_Names
(Project, In_Tree, Project.Naming.Bodies, "Naming.Bodies");
(Project, In_Tree, Bodies, "Naming.Bodies");
end if;
Project.Naming.Specs :=
Util.Value_Of (Name_Spec, Naming.Decl.Arrays, In_Tree);
Specs := Util.Value_Of (Name_Spec, Naming.Decl.Arrays, In_Tree);
if Project.Naming.Specs /= No_Array_Element then
if Specs /= No_Array_Element then
Check_And_Normalize_Unit_Names
(Project, In_Tree, Project.Naming.Specs, "Naming.Specs");
(Project, In_Tree, Specs, "Naming.Specs");
end if;
-- Check Spec_Suffix
......@@ -3374,6 +3379,9 @@ package body Prj.Nmsc is
-- Start of processing for Check_Naming_Schemes
begin
Specs := No_Array_Element;
Bodies := No_Array_Element;
-- No Naming package or parsing a configuration file? nothing to do
if Naming_Id /= No_Package and not Is_Config_File then
......@@ -4229,20 +4237,6 @@ package body Prj.Nmsc is
Project.Naming.Body_Suffix := Impl_Suffixs;
end if;
end;
-- Get the exceptions, if any
Project.Naming.Specification_Exceptions :=
Util.Value_Of
(Name_Specification_Exceptions,
In_Arrays => Naming.Decl.Arrays,
In_Tree => In_Tree);
Project.Naming.Implementation_Exceptions :=
Util.Value_Of
(Name_Implementation_Exceptions,
In_Arrays => Naming.Decl.Arrays,
In_Tree => In_Tree);
end if;
end Check_Package_Naming;
......@@ -7324,16 +7318,22 @@ package body Prj.Nmsc is
-------------------
procedure Override_Kind (Source : Source_Id; Kind : Source_Kind) is
Unit : constant Unit_Index := Source.Unit;
begin
-- Remove reference in the unit, if necessary
-- If the file was previously already associated with a unit, change it
if Unit /= null
if Source.Unit /= null
and then Source.Kind in Spec_Or_Body
and then Unit.File_Names (Source.Kind) /= null
and then Source.Unit.File_Names (Source.Kind) /= null
then
Unit.File_Names (Source.Kind).Unit := No_Unit_Index;
Unit.File_Names (Source.Kind) := null;
-- If we had another file referencing the same unit (for instance it
-- was in an extended project), that source file is in fact invisible
-- from now on, and in particular doesn't belong to the same unit
if Source.Unit.File_Names (Source.Kind) /= Source then
Source.Unit.File_Names (Source.Kind).Unit := No_Unit_Index;
end if;
Source.Unit.File_Names (Source.Kind) := null;
end if;
Source.Kind := Kind;
......
......@@ -73,11 +73,7 @@ package body Prj is
Casing => All_Lower_Case,
Spec_Suffix => No_Array_Element,
Body_Suffix => No_Array_Element,
Separate_Suffix => No_File,
Specs => No_Array_Element,
Bodies => No_Array_Element,
Specification_Exceptions => No_Array_Element,
Implementation_Exceptions => No_Array_Element);
Separate_Suffix => No_File);
Project_Empty : constant Project_Data :=
(Qualifier => Unspecified,
......@@ -1455,6 +1451,19 @@ package body Prj is
and then not Source.Locally_Removed;
end Is_Compilable;
------------------------------
-- Object_To_Global_Archive --
------------------------------
function Object_To_Global_Archive (Source : Source_Id) return Boolean is
begin
return Source.Language.Config.Kind = File_Based
and then Source.Kind = Impl
and then Source.Language.Config.Objects_Linked
and then Is_Compilable (Source)
and then Source.Language.Config.Object_Generated;
end Object_To_Global_Archive;
----------------------------
-- Get_Language_From_Name --
----------------------------
......
......@@ -399,6 +399,12 @@ package Prj is
-- Return True if we know how to compile Source (i.e. if a compiler is
-- defined). This doesn't indicate whether the source should be compiled.
function Object_To_Global_Archive (Source : Source_Id) return Boolean;
pragma Inline (Object_To_Global_Archive);
-- Return True if the object file should be put in the global archive.
-- This is for Ada, when only the closure of a main needs to be
-- (re)compiled.
function Other_Part (Source : Source_Id) return Source_Id;
pragma Inline (Other_Part);
-- Source ID for the other part, if any: for a spec, indicates its body;
......@@ -662,7 +668,10 @@ package Prj is
-- Kind of the source: spec, body or subunit
Unit : Unit_Index := No_Unit_Index;
-- Name of the unit, if language is unit based
-- Name of the unit, if language is unit based. This is only set for
-- those finles that are part of the compilation set (for instance a
-- file in an extended project that is overridden will not have this
-- field set).
Index : Int := 0;
-- Index of the source in a multi unit source file (the same Source_Data
......@@ -673,11 +682,6 @@ package Prj is
Locally_Removed : Boolean := False;
-- True if the source has been "excluded"
Get_Object : Boolean := False;
-- Indicates that the object of the source should be put in the global
-- archive. This is for Ada, when only the closure of a main needs to
-- be compiled/recompiled.
Replaced_By : Source_Id := No_Source;
File : File_Name_Type := No_File;
......@@ -747,7 +751,6 @@ package Prj is
Unit => No_Unit_Index,
Index => 0,
Locally_Removed => False,
Get_Object => False,
Replaced_By => No_Source,
File => No_File,
Display_File => No_File,
......@@ -848,22 +851,6 @@ package Prj is
Separate_Suffix : File_Name_Type := No_File;
-- String to append to unit name for source file name of an Ada subunit
Specs : Array_Element_Id := No_Array_Element;
-- An associative array mapping individual specs to source file names
-- This is specific to unit-based languages.
Bodies : Array_Element_Id := No_Array_Element;
-- An associative array mapping individual bodies to source file names
-- This is specific to unit-based languages.
Specification_Exceptions : Array_Element_Id := No_Array_Element;
-- An associative array listing spec file names that do not have the
-- spec suffix. Not used by Ada. Indexed by programming language name.
Implementation_Exceptions : Array_Element_Id := No_Array_Element;
-- An associative array listing body file names that do not have the
-- body suffix. Not used by Ada. Indexed by programming language name.
end record;
function Spec_Suffix_Of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment