OSDN Git Service

* gcc.dg/attr-weakref-1.c: Add exit (0) to avoid spurious
[pf3gnuchains/gcc-fork.git] / gcc / ada / prj.ads
index 327e500..0f3429c 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2001-2004 Free Software Foundation, Inc.          --
+--          Copyright (C) 2001-2005 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- --
@@ -16,8 +16,8 @@
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -35,127 +35,205 @@ with Scans;  use Scans;
 with Table;
 with Types;  use Types;
 
-with GNAT.OS_Lib; use GNAT.OS_Lib;
+with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
+with GNAT.Dynamic_Tables;
+with GNAT.OS_Lib;           use GNAT.OS_Lib;
 
-package Prj is
+with System.HTable;
 
-   Empty_Name : Name_Id;
-   --  Name_Id for an empty name (no characters). Initialized by the call
-   --  to procedure Initialize.
+package Prj is
 
-   All_Packages : constant String_List_Access := null;
+   All_Packages : constant String_List_Access;
    --  Default value of parameter Packages of procedures Parse, in Prj.Pars and
    --  Prj.Part, indicating that all packages should be checked.
 
-   Virtual_Prefix : constant String := "v$";
-   --  The prefix for virtual extending projects. Because of the '$', which is
-   --  normally forbidden for project names, there cannot be any name clash.
+   type Project_Tree_Data;
+   type Project_Tree_Ref is access all Project_Tree_Data;
+   --  Reference to a project tree.
+   --  Several project trees may exist in memory at the same time.
 
-   Project_File_Extension : String := ".gpr";
-   --  The standard project file name extension. It is not a constant, because
-   --  Canonical_Case_File_Name is called on this variable in the body of Prj.
+   No_Project_Tree : constant Project_Tree_Ref;
 
-   Default_Ada_Spec_Suffix : Name_Id;
+   function Default_Ada_Spec_Suffix return Name_Id;
+   pragma Inline (Default_Ada_Spec_Suffix);
    --  The Name_Id for the standard GNAT suffix for Ada spec source file
    --  name ".ads". Initialized by Prj.Initialize.
 
-   Default_Ada_Body_Suffix : Name_Id;
+   function Default_Ada_Body_Suffix return Name_Id;
+   pragma Inline (Default_Ada_Body_Suffix);
    --  The Name_Id for the standard GNAT suffix for Ada body source file
    --  name ".adb". Initialized by Prj.Initialize.
 
-   Slash : Name_Id;
+   function Slash return Name_Id;
+   pragma Inline (Slash);
    --  "/", used as the path of locally removed files
 
-   type Languages_Processed is (Ada_Language, Other_Languages, All_Languages);
-   --  To specify how to process project files
+   Project_File_Extension : String := ".gpr";
+   --  The standard project file name extension. It is not a constant, because
+   --  Canonical_Case_File_Name is called on this variable in the body of Prj.
 
-   type Programming_Language is
-     (Lang_Ada, Lang_C, Lang_C_Plus_Plus);
-   --  The set of languages supported
+   -----------------------------------------------------
+   -- Multi-language stuff that will be modified soon --
+   -----------------------------------------------------
 
-   subtype Other_Programming_Language is
-     Programming_Language range Lang_C .. Programming_Language'Last;
-   --  The set of non-Ada languages supported
+   type Language_Index is new Nat;
 
-   type Languages_In_Project is array (Programming_Language) of Boolean;
+   No_Language_Index           : constant Language_Index := 0;
+   First_Language_Index        : constant Language_Index := 1;
+   First_Language_Indexes_Last : constant Language_Index := 5;
+
+   Ada_Language_Index         : constant Language_Index :=
+                                  First_Language_Index;
+   C_Language_Index           : constant Language_Index :=
+                                  Ada_Language_Index + 1;
+   C_Plus_Plus_Language_Index : constant Language_Index :=
+                                  C_Language_Index + 1;
+
+   Last_Language_Index : Language_Index := No_Language_Index;
+
+   subtype First_Language_Indexes is Language_Index
+      range First_Language_Index .. First_Language_Indexes_Last;
+
+   type Header_Num is range 0 .. 2047;
+
+   function Hash is new System.HTable.Hash (Header_Num => Header_Num);
+
+   function Hash (Name : Name_Id) return Header_Num;
+
+   package Language_Indexes is new System.HTable.Simple_HTable
+     (Header_Num => Header_Num,
+      Element    => Language_Index,
+      No_Element => No_Language_Index,
+      Key        => Name_Id,
+      Hash       => Hash,
+      Equal      => "=");
+   --  Mapping of language names to language indexes
+
+   package Language_Names is new Table.Table
+     (Table_Component_Type => Name_Id,
+      Table_Index_Type     => Language_Index,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 4,
+      Table_Increment      => 100,
+      Table_Name           => "Prj.Language_Names");
+   --  The table for the name of programming languages
+
+   procedure Add_Language_Name (Name : Name_Id);
+
+   procedure Display_Language_Name (Language : Language_Index);
+
+   type Languages_In_Project is array (First_Language_Indexes) of Boolean;
    --  Set of supported languages used in a project
 
    No_Languages : constant Languages_In_Project := (others => False);
    --  No supported languages are used
 
-   type Impl_Suffix_Array is array (Programming_Language) of Name_Id;
+   type Supp_Language_Index is new Nat;
+   No_Supp_Language_Index  : constant Supp_Language_Index := 0;
+
+   type Supp_Language is record
+      Index   : Language_Index := No_Language_Index;
+      Present : Boolean := False;
+      Next    : Supp_Language_Index := No_Supp_Language_Index;
+   end record;
+
+   package Present_Language_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Supp_Language,
+      Table_Index_Type     => Supp_Language_Index,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 4,
+      Table_Increment      => 100);
+   --  The table for the presence of languages with an index that is outside
+   --  of First_Language_Indexes.
+
+   type Impl_Suffix_Array is array (First_Language_Indexes) of Name_Id;
    --  Suffixes for the non spec sources of the different supported languages
    --  in a project.
 
    No_Impl_Suffixes : constant Impl_Suffix_Array := (others => No_Name);
    --  A default value for the non spec source suffixes
 
-   Lang_Ada_Name         : aliased String := "ada";
-   Lang_C_Name           : aliased String := "c";
-   Lang_C_Plus_Plus_Name : aliased String := "c++";
-   Lang_Names : constant array (Programming_Language) of String_Access :=
-     (Lang_Ada         => Lang_Ada_Name        'Access,
-      Lang_C           => Lang_C_Name          'Access,
-      Lang_C_Plus_Plus => Lang_C_Plus_Plus_Name'Access);
-   --  Names of the supported programming languages, to be used after switch
-   --  -x when using a GCC compiler.
-
-   Lang_Name_Ids : array (Programming_Language) of Name_Id;
-   --  Same as Lang_Names, but using Name_Id, instead of String_Access.
-   --  Initialized by Prj.Initialize.
-
-   Lang_Ada_Display_Name         : aliased String := "Ada";
-   Lang_C_Display_Name           : aliased String := "C";
-   Lang_C_Plus_Plus_Display_Name : aliased String := "C++";
-   Lang_Display_Names :
-     constant array (Programming_Language) of String_Access :=
-       (Lang_Ada         => Lang_Ada_Display_Name        'Access,
-        Lang_C           => Lang_C_Display_Name          'Access,
-        Lang_C_Plus_Plus => Lang_C_Plus_Plus_Display_Name'Access);
-   --  Names of the supported programming languages, to be used for display
-   --  purposes.
-
-   Ada_Impl_Suffix         : aliased String := ".adb";
-   C_Impl_Suffix           : aliased String := ".c";
-   C_Plus_Plus_Impl_Suffix : aliased String := ".cc";
-   Lang_Suffixes : constant array (Programming_Language) of String_Access :=
-     (Lang_Ada         => Ada_Impl_Suffix        'Access,
-      Lang_C           => C_Impl_Suffix          'Access,
-      Lang_C_Plus_Plus => C_Plus_Plus_Impl_Suffix'Access);
-   --  Default extension of the sources of the different languages.
-
-   Lang_Suffix_Ids         : array (Programming_Language) of Name_Id;
-   --  Same as Lang_Suffixes, but using Name_Id, instead of String_Access.
-   --  Initialized by Prj.Initialize.
-
-   Gnatmake_String    : aliased String := "gnatmake";
-   Gcc_String         : aliased String := "gcc";
-   G_Plus_Plus_String : aliased String := "g++";
-   Default_Compiler_Names  :
-     constant array (Programming_Language) of String_Access :=
-     (Lang_Ada         => Gnatmake_String   'Access,
-      Lang_C           => Gcc_String        'Access,
-      Lang_C_Plus_Plus => G_Plus_Plus_String'Access);
-   --  Default names of the compilers for the supported languages.
-   --  Used when no IDE'Compiler_Command is specified for a language.
-   --  For Ada, specify the gnatmake executable.
-
-   Ada_Args_Strings        : aliased String := "";
-   C_Args_String           : aliased String := "c";
-   C_Plus_Plus_Args_String : aliased String := "xx";
-   Lang_Args : constant array (Programming_Language) of String_Access :=
-     (Lang_Ada         => Ada_Args_Strings       'Access,
-      Lang_C           => C_Args_String          'Access,
-      Lang_C_Plus_Plus => C_Plus_Plus_Args_String'Access);
-   --  For each supported language, the string between "-c" and "args" to
-   --  be used in the gprmake switch for the start of the compiling switch
-   --  section for each supported language. For example, "-ccargs" indicates
-   --  the start of the C compiler switch section.
+   type Supp_Suffix is record
+      Index   : Language_Index := No_Language_Index;
+      Suffix  : Name_Id := No_Name;
+      Next    : Supp_Language_Index := No_Supp_Language_Index;
+   end record;
+
+   package Supp_Suffix_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Supp_Suffix,
+      Table_Index_Type     => Supp_Language_Index,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 4,
+      Table_Increment      => 100);
+   --  The table for the presence of languages with an index that is outside
+   --  of First_Language_Indexes.
+
+   type Language_Kind is (GNU, other);
+
+   type Name_List_Index is new Nat;
+   No_Name_List            : constant Name_List_Index := 0;
+
+   type Name_Node is record
+      Name : Name_Id         := No_Name;
+      Next : Name_List_Index := No_Name_List;
+   end record;
+
+   package Name_List_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Name_Node,
+      Table_Index_Type     => Name_List_Index,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 10,
+      Table_Increment      => 100);
+   --  The table for lists of names used in package Language_Processing
+
+   type Language_Processing_Data is record
+      Compiler_Drivers     : Name_List_Index := No_Name_List;
+      Compiler_Paths       : Name_Id         := No_Name;
+      Compiler_Kinds       : Language_Kind   := GNU;
+      Dependency_Options   : Name_List_Index := No_Name_List;
+      Compute_Dependencies : Name_List_Index := No_Name_List;
+      Include_Options      : Name_List_Index := No_Name_List;
+      Binder_Drivers       : Name_Id         := No_Name;
+      Binder_Driver_Paths  : Name_Id         := No_Name;
+   end record;
+
+   Default_Language_Processing_Data :
+     constant Language_Processing_Data :=
+       (Compiler_Drivers     => No_Name_List,
+        Compiler_Paths       => No_Name,
+        Compiler_Kinds       => GNU,
+        Dependency_Options   => No_Name_List,
+        Compute_Dependencies => No_Name_List,
+        Include_Options      => No_Name_List,
+        Binder_Drivers       => No_Name,
+        Binder_Driver_Paths  => No_Name);
+
+   type First_Language_Processing_Data is
+     array (First_Language_Indexes) of Language_Processing_Data;
+
+   Default_First_Language_Processing_Data :
+      constant First_Language_Processing_Data :=
+                 (others => Default_Language_Processing_Data);
+
+   type Supp_Language_Data is record
+      Index : Language_Index := No_Language_Index;
+      Data  : Language_Processing_Data := Default_Language_Processing_Data;
+      Next  : Supp_Language_Index := No_Supp_Language_Index;
+   end record;
+
+   package Supp_Language_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Supp_Language_Data,
+      Table_Index_Type     => Supp_Language_Index,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 4,
+      Table_Increment      => 100);
+   --  The table for language data when there are more languages than
+   --  in First_Language_Indexes.
 
    type Other_Source_Id is new Nat;
    No_Other_Source : constant Other_Source_Id := 0;
    type Other_Source is record
-      Language         : Programming_Language; --  language of the source
+      Language         : Language_Index;       --  language of the source
       File_Name        : Name_Id;              --  source file simple name
       Path_Name        : Name_Id;              --  source full path name
       Source_TS        : Time_Stamp_Type;      --  source file time stamp
@@ -170,21 +248,27 @@ package Prj is
    end record;
    --  Data for a source in a language other than Ada
 
-   package Other_Sources is new Table.Table
+   package Other_Source_Table is new GNAT.Dynamic_Tables
      (Table_Component_Type => Other_Source,
       Table_Index_Type     => Other_Source_Id,
       Table_Low_Bound      => 1,
       Table_Initial        => 200,
-      Table_Increment      => 100,
-      Table_Name           => "Prj.Other_Sources");
+      Table_Increment      => 100);
    --  The table for sources of languages other than Ada
 
+   ----------------------------------
+   --  End of multi-language stuff --
+   ----------------------------------
+
    type Verbosity is (Default, Medium, High);
    --  Verbosity when parsing GNAT Project Files
    --    Default is default (very quiet, if no errors).
    --    Medium is more verbose.
    --    High is extremely verbose.
 
+   Current_Verbosity : Verbosity := Default;
+   --  The current value of the verbosity the project files are parsed with
+
    type Lib_Kind is (Static, Dynamic, Relocatable);
    type Policy is (Autonomous, Compliant, Controlled, Restricted);
    --  Type to specify the symbol policy, when symbol control is supported.
@@ -201,7 +285,7 @@ package Prj is
    end record;
    --  Type to keep the symbol data to be used when building a shared library
 
-   No_Symbols : Symbol_Record :=
+   No_Symbols : constant Symbol_Record :=
      (Symbol_File   => No_Name,
       Reference     => No_Name,
       Symbol_Policy => Autonomous);
@@ -228,19 +312,21 @@ package Prj is
    --  Component Flag may be used for various purposes. For source
    --  directories, it indicates if the directory contains Ada source(s).
 
-   package String_Elements is new Table.Table
+   package String_Element_Table is new GNAT.Dynamic_Tables
      (Table_Component_Type => String_Element,
       Table_Index_Type     => String_List_Id,
       Table_Low_Bound      => 1,
       Table_Initial        => 200,
-      Table_Increment      => 100,
-      Table_Name           => "Prj.String_Elements");
+      Table_Increment      => 100);
    --  The table for string elements in string lists
 
    type Variable_Kind is (Undefined, List, Single);
    --  Different kinds of variables
 
-   Ignored : constant Variable_Kind := Single;
+   subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
+   --  The defined kinds of variables
+
+   Ignored : constant Variable_Kind;
    --  Used to indicate that a package declaration must be ignored
    --  while processing the project tree (unknown package name).
 
@@ -261,11 +347,7 @@ package Prj is
    --  Values for variables and array elements. Default is True if the
    --  current value is the default one for the variable
 
-   Nil_Variable_Value : constant Variable_Value :=
-     (Project  => No_Project,
-      Kind     => Undefined,
-      Location => No_Location,
-      Default  => False);
+   Nil_Variable_Value : constant Variable_Value;
    --  Value of a non existing variable or array element
 
    type Variable_Id is new Nat;
@@ -277,13 +359,12 @@ package Prj is
    end record;
    --  To hold the list of variables in a project file and in packages
 
-   package Variable_Elements is new Table.Table
+   package Variable_Element_Table is new GNAT.Dynamic_Tables
      (Table_Component_Type => Variable,
       Table_Index_Type     => Variable_Id,
       Table_Low_Bound      => 1,
       Table_Initial        => 200,
-      Table_Increment      => 100,
-      Table_Name           => "Prj.Variable_Elements");
+      Table_Increment      => 100);
    --  The table of variable in list of variables
 
    type Array_Element_Id is new Nat;
@@ -298,13 +379,12 @@ package Prj is
    --  Each Array_Element represents an array element and is linked (Next)
    --  to the next array element, if any, in the array.
 
-   package Array_Elements is new Table.Table
+   package Array_Element_Table is new GNAT.Dynamic_Tables
      (Table_Component_Type => Array_Element,
       Table_Index_Type     => Array_Element_Id,
       Table_Low_Bound      => 1,
       Table_Initial        => 200,
-      Table_Increment      => 100,
-      Table_Name           => "Prj.Array_Elements");
+      Table_Increment      => 100);
    --  The table that contains all array elements
 
    type Array_Id is new Nat;
@@ -318,13 +398,12 @@ package Prj is
    --  Value is the id of the first element.
    --  Next is the id of the next array in the project file or package.
 
-   package Arrays is new Table.Table
+   package Array_Table is new GNAT.Dynamic_Tables
      (Table_Component_Type => Array_Data,
       Table_Index_Type     => Array_Id,
       Table_Low_Bound      => 1,
       Table_Initial        => 200,
-      Table_Increment      => 100,
-      Table_Name           => "Prj.Arrays");
+      Table_Increment      => 100);
    --  The table that contains all arrays
 
    type Package_Id is new Nat;
@@ -343,7 +422,7 @@ package Prj is
       Attributes => No_Variable,
       Arrays     => No_Array,
       Packages   => No_Package);
-   --  Default value of Declarations: indicates that there is no declarations.
+   --  Default value of Declarations: indicates that there is no declarations
 
    type Package_Element is record
       Name   : Name_Id      := No_Name;
@@ -351,16 +430,15 @@ package Prj is
       Parent : Package_Id   := No_Package;
       Next   : Package_Id   := No_Package;
    end record;
-   --  A package. Includes declarations that may include other packages.
+   --  A package. Includes declarations that may include other packages
 
-   package Packages is new Table.Table
+   package Package_Table is new GNAT.Dynamic_Tables
      (Table_Component_Type => Package_Element,
       Table_Index_Type     => Package_Id,
       Table_Low_Bound      => 1,
       Table_Initial        => 100,
-      Table_Increment      => 100,
-      Table_Name           => "Prj.Packages");
-   --  The table that contains all packages.
+      Table_Increment      => 100);
+   --  The table that contains all packages
 
    function Image (Casing : Casing_Type) return String;
    --  Similar to 'Image (but avoid use of this attribute in compiler)
@@ -372,55 +450,57 @@ package Prj is
    --  The following record contains data for a naming scheme
 
    type Naming_Data is record
-      Current_Language : Name_Id := No_Name;
-      --  The programming language being currently considered
 
       Dot_Replacement : Name_Id := No_Name;
-      --  The string to replace '.' in the source file name (for Ada).
+      --  The string to replace '.' in the source file name (for Ada)
 
       Dot_Repl_Loc : Source_Ptr := No_Location;
-      --  The position in the project file source where
-      --  Dot_Replacement is defined.
+      --  The position in the project file source where Dot_Replacement is
+      --  defined.
 
       Casing : Casing_Type := All_Lower_Case;
-      --  The casing of the source file name (for Ada).
+      --  The casing of the source file name (for Ada)
 
       Spec_Suffix : Array_Element_Id := No_Array_Element;
       --  The string to append to the unit name for the
       --  source file name of a spec.
       --  Indexed by the programming language.
 
-      Current_Spec_Suffix : Name_Id := No_Name;
-      --  The "spec" suffix of the current programming language
+      Ada_Spec_Suffix : Name_Id := No_Name;
+      --  The suffix of the Ada spec sources
 
       Spec_Suffix_Loc : Source_Ptr := No_Location;
       --  The position in the project file source where
-      --  Current_Spec_Suffix is defined.
+      --  Ada_Spec_Suffix is defined.
+
+      Impl_Suffixes    : Impl_Suffix_Array   := No_Impl_Suffixes;
+      Supp_Suffixes    : Supp_Language_Index := No_Supp_Language_Index;
+      --  The source suffixes of the different languages
 
       Body_Suffix : Array_Element_Id := No_Array_Element;
       --  The string to append to the unit name for the
       --  source file name of a body.
       --  Indexed by the programming language.
 
-      Current_Body_Suffix : Name_Id := No_Name;
-      --  The "body" suffix of the current programming language
+      Ada_Body_Suffix : Name_Id := No_Name;
+      --  The suffix of the Ada body sources
 
       Body_Suffix_Loc : Source_Ptr := No_Location;
       --  The position in the project file source where
-      --  Current_Body_Suffix is defined.
+      --  Ada_Body_Suffix is defined.
 
       Separate_Suffix : Name_Id := No_Name;
-      --  String to append to unit name for source file name of an Ada subunit.
+      --  String to append to unit name for source file name of an Ada subunit
 
       Sep_Suffix_Loc : Source_Ptr := No_Location;
-      --  Position in the project file source where Separate_Suffix is defined.
+      --  Position in the project file source where Separate_Suffix is defined
 
       Specs : Array_Element_Id := No_Array_Element;
-      --  An associative array mapping individual specs to source file names.
+      --  An associative array mapping individual specs to source file names
       --  This is specific to Ada.
 
       Bodies : Array_Element_Id := No_Array_Element;
-      --  An associative array mapping individual bodies to source file names.
+      --  An associative array mapping individual bodies to source file names
       --  This is specific to Ada.
 
       Specification_Exceptions : Array_Element_Id := No_Array_Element;
@@ -433,13 +513,15 @@ package Prj is
 
    end record;
 
-   function Standard_Naming_Data return Naming_Data;
+   function Standard_Naming_Data
+     (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
    pragma Inline (Standard_Naming_Data);
-   --  The standard GNAT naming scheme
+   --  The standard GNAT naming scheme when Tree is No_Project_Tree.
+   --  Otherwise, return the default naming scheme for the project tree Tree,
+   --  which must have been Initialized.
 
    function Same_Naming_Scheme
-     (Left, Right : Naming_Data)
-      return        Boolean;
+     (Left, Right : Naming_Data) return Boolean;
    --  Returns True if Left and Right are the same naming scheme
    --  not considering Specs and Bodies.
 
@@ -454,34 +536,36 @@ package Prj is
    --  Element in a list of project files. Next is the id of the next
    --  project file in the list.
 
-   package Project_Lists is new Table.Table
+   package Project_List_Table is new GNAT.Dynamic_Tables
      (Table_Component_Type => Project_Element,
       Table_Index_Type     => Project_List,
       Table_Low_Bound      => 1,
       Table_Initial        => 100,
-      Table_Increment      => 100,
-      Table_Name           => "Prj.Project_Lists");
+      Table_Increment      => 100);
    --  The table that contains the lists of project files
 
    --  The following record describes a project file representation
 
    type Project_Data is record
-      Languages : Languages_In_Project := No_Languages;
-      --  Indicate the different languages of the source of this project
+      Externally_Built : Boolean := False;
 
-      Impl_Suffixes : Impl_Suffix_Array := No_Impl_Suffixes;
-      --  The source suffixes of the different languages other than Ada
+      Languages      : Languages_In_Project := No_Languages;
+      Supp_Languages : Supp_Language_Index  := No_Supp_Language_Index;
+      --  Indicate the different languages of the source of this project
 
       First_Referred_By  : Project_Id := No_Project;
-      --  The project, if any, that was the first to be known
-      --  as importing or extending this project.
-      --  Set by Prj.Proc.Process.
+      --  The project, if any, that was the first to be known as importing or
+      --  extending this project. Set by Prj.Proc.Process.
 
       Name : Name_Id := No_Name;
-      --  The name of the project. Set by Prj.Proc.Process.
+      --  The name of the project. Set by Prj.Proc.Process
+
+      Display_Name : Name_Id := No_Name;
+      --  The name of the project with the spelling of its declaration.
+      --  Set by Prj.Proc.Process.
 
       Path_Name : Name_Id := No_Name;
-      --  The path name of the project file. Set by Prj.Proc.Process.
+      --  The path name of the project file. Set by Prj.Proc.Process
 
       Display_Path_Name : Name_Id := No_Name;
       --  The path name used for display purposes. May be different from
@@ -495,36 +579,36 @@ package Prj is
       --  project. Set by Prj.Proc.Process.
 
       Mains : String_List_Id := Nil_String;
-      --  List of mains specified by attribute Main. Set by Prj.Nmsc.Ada_Check.
+      --  List of mains specified by attribute Main. Set by Prj.Nmsc.Check
 
       Directory : Name_Id := No_Name;
-      --  Directory where the project file resides. Set by Prj.Proc.Process.
+      --  Directory where the project file resides. Set by Prj.Proc.Process
 
       Display_Directory : Name_Id := No_Name;
 
       Dir_Path : String_Access;
-      --  Same as Directory, but as an access to String.
-      --  Set by Make.Compile_Sources.Collect_Arguments_And_Compile.
+      --  Same as Directory, but as an access to String. Set by
+      --  Make.Compile_Sources.Collect_Arguments_And_Compile.
 
       Library : Boolean := False;
-      --  True if this is a library project.
-      --  Set by Prj.Nmsc.Language_Independent_Check.
+      --  True if this is a library project. Set by
+      --  Prj.Nmsc.Language_Independent_Check.
 
       Library_Dir : Name_Id := No_Name;
-      --  If a library project, directory where resides the library
-      --  Set by Prj.Nmsc.Language_Independent_Check.
+      --  If a library project, directory where resides the library Set by
+      --  Prj.Nmsc.Language_Independent_Check.
 
       Display_Library_Dir : Name_Id := No_Name;
-      --  The name of the library directory, for display purposes.
-      --  May be different from Library_Dir for platforms where the file names
-      --  are case-insensitive.
+      --  The name of the library directory, for display purposes. May be
+      --  different from Library_Dir for platforms where the file names are
+      --  case-insensitive.
 
       Library_Src_Dir : Name_Id := No_Name;
       --  If a library project, directory where the sources and the ALI files
       --  of the library are copied. By default, if attribute Library_Src_Dir
       --  is not specified, sources are not copied anywhere and ALI files are
-      --  copied in the Library Directory.
-      --  Set by Prj.Nmsc.Language_Independent_Check.
+      --  copied in the Library Directory. Set by
+      --  Prj.Nmsc.Language_Independent_Check.
 
       Display_Library_Src_Dir : Name_Id := No_Name;
       --  The name of the library source directory, for display purposes.
@@ -540,16 +624,16 @@ package Prj is
       --  Set by Prj.Nmsc.Language_Independent_Check.
 
       Lib_Internal_Name : Name_Id := No_Name;
-      --  If a library project, internal name store inside the library
-      --  Set by Prj.Nmsc.Language_Independent_Check.
+      --  If a library project, internal name store inside the library Set by
+      --  Prj.Nmsc.Language_Independent_Check.
 
       Standalone_Library : Boolean := False;
-      --  Indicate that this is a Standalone Library Project File.
-      --  Set by Prj.Nmsc.Ada_Check.
+      --  Indicate that this is a Standalone Library Project File. Set by
+      --  Prj.Nmsc.Check.
 
       Lib_Interface_ALIs : String_List_Id := Nil_String;
-      --  For Standalone Library Project Files, indicate the list
-      --  of Interface ALI files. Set by Prj.Nmsc.Ada_Check.
+      --  For Standalone Library Project Files, indicate the list of Interface
+      --  ALI files. Set by Prj.Nmsc.Check.
 
       Lib_Auto_Init : Boolean := False;
       --  For non static Standalone Library Project Files, indicate if
@@ -610,38 +694,47 @@ package Prj is
       --  Object_Directory. Set by Prj.Nmsc.Language_Independent_Check.
 
       Display_Exec_Dir : Name_Id := No_Name;
-      --  The name of the exec directory, for display purposes.
-      --  May be different from Exec_Directory for platforms where the file
-      --  names are case-insensitive.
+      --  The name of the exec directory, for display purposes. May be
+      --  different from Exec_Directory for platforms where the file names are
+      --  case-insensitive.
 
       Extends : Project_Id := No_Project;
-      --  The reference of the project file, if any, that this
-      --  project file extends. Set by Prj.Proc.Process.
+      --  The reference of the project file, if any, that this project file
+      --  extends. Set by Prj.Proc.Process.
 
       Extended_By : Project_Id := No_Project;
-      --  The reference of the project file, if any, that
-      --  extends this project file. Set by Prj.Proc.Process.
+      --  The reference of the project file, if any, that extends this project
+      --  file. Set by Prj.Proc.Process.
 
       Naming : Naming_Data := Standard_Naming_Data;
       --  The naming scheme of this project file.
       --  Set by Prj.Nmsc.Check_Naming_Scheme.
 
+      First_Language_Processing : First_Language_Processing_Data :=
+        Default_First_Language_Processing_Data;
+
+      Supp_Language_Processing      : Supp_Language_Index :=
+                                       No_Supp_Language_Index;
+
+      Default_Linker                : Name_Id := No_Name;
+      Default_Linker_Path           : Name_Id := No_Name;
+
       Decl : Declarations := No_Declarations;
       --  The declarations (variables, attributes and packages) of this
       --  project file. Set by Prj.Proc.Process.
 
       Imported_Projects : Project_List := Empty_Project_List;
-      --  The list of all directly imported projects, if any.
-      --  Set by Prj.Proc.Process.
+      --  The list of all directly imported projects, if any. Set by
+      --  Prj.Proc.Process.
 
       Ada_Include_Path : String_Access := null;
-      --  The cached value of ADA_INCLUDE_PATH for this project file.
-      --  Do not use this field directly outside of the compiler, use
+      --  The cached value of ADA_INCLUDE_PATH for this project file. Do not
+      --  use this field directly outside of the compiler, use
       --  Prj.Env.Ada_Include_Path instead. Set by Prj.Env.Ada_Include_Path.
 
       Ada_Objects_Path : String_Access := null;
-      --  The cached value of ADA_OBJECTS_PATH for this project file.
-      --  Do not use this field directly outside of the compiler, use
+      --  The cached value of ADA_OBJECTS_PATH for this project file. Do not
+      --  use this field directly outside of the compiler, use
       --  Prj.Env.Ada_Objects_Path instead. Set by Prj.Env.Ada_Objects_Path
 
       Include_Path_File : Name_Id := No_Name;
@@ -672,7 +765,7 @@ package Prj is
       Language_Independent_Checked : Boolean := False;
       --  A flag that indicates that the project file has been checked
       --  for language independent features: Object_Directory,
-      --  Source_Directories, Library, non empty Naming Suffixs.
+      --  Source_Directories, Library, non empty Naming Suffixes.
 
       Checked : Boolean := False;
       --  A flag to avoid checking repetitively the naming scheme of
@@ -696,40 +789,127 @@ package Prj is
 
    end record;
 
-   function Empty_Project return Project_Data;
-   --  Return the representation of an empty project
+   function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
+   --  Return the representation of an empty project in project Tree tree.
+   --  The project tree Tree must have been Initialized and/or Reset.
+
+   Project_Error : exception;
+   --  Raised by some subprograms in Prj.Attr
 
-   package Projects is new Table.Table (
+   package Project_Table is new GNAT.Dynamic_Tables (
      Table_Component_Type => Project_Data,
      Table_Index_Type     => Project_Id,
      Table_Low_Bound      => 1,
      Table_Initial        => 100,
-     Table_Increment      => 100,
-     Table_Name           => "Prj.Projects");
+     Table_Increment      => 100);
    --  The set of all project files
 
+   type Spec_Or_Body is
+     (Specification, Body_Part);
+
+   type File_Name_Data is record
+      Name         : Name_Id := No_Name;
+      Index        : Int     := 0;
+      Display_Name : Name_Id := No_Name;
+      Path         : Name_Id := No_Name;
+      Display_Path : Name_Id := No_Name;
+      Project      : Project_Id := No_Project;
+      Needs_Pragma : Boolean := False;
+   end record;
+   --  File and Path name of a spec or body
+
+   type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
+
+   type Unit_Id is new Nat;
+   No_Unit : constant Unit_Id := 0;
+   type Unit_Data is record
+      Name       : Name_Id    := No_Name;
+      File_Names : File_Names_Data;
+   end record;
+   --  Name and File and Path names of a unit, with a reference to its
+   --  GNAT Project File(s).
+
+   package Unit_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Unit_Data,
+      Table_Index_Type     => Unit_Id,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 100,
+      Table_Increment      => 100);
+   --  Table of all units in a project tree
+
+   package Units_Htable is new Simple_HTable
+     (Header_Num => Header_Num,
+      Element    => Unit_Id,
+      No_Element => No_Unit,
+      Key        => Name_Id,
+      Hash       => Hash,
+      Equal      => "=");
+   --  Mapping of unit names to indexes in the Units table
+
+   type Unit_Project is record
+      Unit    : Unit_Id    := No_Unit;
+      Project : Project_Id := No_Project;
+   end record;
+
+   No_Unit_Project : constant Unit_Project := (No_Unit, No_Project);
+
+   package Files_Htable is new Simple_HTable
+     (Header_Num => Header_Num,
+      Element    => Unit_Project,
+      No_Element => No_Unit_Project,
+      Key        => Name_Id,
+      Hash       => Hash,
+      Equal      => "=");
+   --  Mapping of file names to indexes in the Units table
+
+   type Private_Project_Tree_Data is private;
+   --  Data for a project tree that is used only by the Project Manager
+
+   type Project_Tree_Data is
+      record
+         Present_Languages : Present_Language_Table.Instance;
+         Supp_Suffixes     : Supp_Suffix_Table.Instance;
+         Name_Lists        : Name_List_Table.Instance;
+         Supp_Languages    : Supp_Language_Table.Instance;
+         Other_Sources     : Other_Source_Table.Instance;
+         String_Elements   : String_Element_Table.Instance;
+         Variable_Elements : Variable_Element_Table.Instance;
+         Array_Elements    : Array_Element_Table.Instance;
+         Arrays            : Array_Table.Instance;
+         Packages          : Package_Table.Instance;
+         Project_Lists     : Project_List_Table.Instance;
+         Projects          : Project_Table.Instance;
+         Units             : Unit_Table.Instance;
+         Units_HT          : Units_Htable.Instance;
+         Files_HT          : Files_Htable.Instance;
+         Private_Part      : Private_Project_Tree_Data;
+      end record;
+   --  Data for a project tree
+
    type Put_Line_Access is access procedure
      (Line    : String;
-      Project : Project_Id);
+      Project : Project_Id;
+      In_Tree : Project_Tree_Ref);
    --  Use to customize error reporting in Prj.Proc and Prj.Nmsc
 
    procedure Expect (The_Token : Token_Type; Token_Image : String);
    --  Check that the current token is The_Token. If it is not, then
    --  output an error message.
 
-   procedure Initialize;
+   procedure Initialize (Tree : Project_Tree_Ref);
    --  This procedure must be called before using any services from the Prj
    --  hierarchy. Namet.Initialize must be called before Prj.Initialize.
 
-   procedure Reset;
+   procedure Reset (Tree : Project_Tree_Ref);
    --  This procedure resets all the tables that are used when processing a
    --  project file tree. Initialize must be called before the call to Reset.
 
    procedure Register_Default_Naming_Scheme
      (Language            : Name_Id;
       Default_Spec_Suffix : Name_Id;
-      Default_Body_Suffix : Name_Id);
-   --  Register the default suffixs for a given language. These extensions
+      Default_Body_Suffix : Name_Id;
+      In_Tree             : Project_Tree_Ref);
+   --  Register the default suffixes for a given language. These extensions
    --  will be ignored if the user has specified a new naming scheme in a
    --  project file.
    --
@@ -743,29 +923,132 @@ package Prj is
          With_State : in out State);
    procedure For_Every_Project_Imported
      (By         : Project_Id;
+      In_Tree    : Project_Tree_Ref;
       With_State : in out State);
    --  Call Action for each project imported directly or indirectly by project
    --  By. Action is called according to the order of importation: if A
    --  imports B, directly or indirectly, Action will be called for A before
-   --  it is called for B. With_State may be used by Action to choose a
-   --  behavior or to report some global result.
+   --  it is called for B. If two projects import each other directly or
+   --  indirectly (using at least one "limited with"), it is not specified
+   --  for which of these two projects Action will be called first. Projects
+   --  that are extended by other projects are not considered. With_State may
+   --  be used by Action to choose a behavior or to report some global result.
+
+   ----------------------------------------------------------
+   -- Other multi-language stuff that may be modified soon --
+   ----------------------------------------------------------
+
+   function Is_Present
+     (Language   : Language_Index;
+      In_Project : Project_Data;
+      In_Tree    : Project_Tree_Ref) return Boolean;
+   --  Return True when Language is one of the languages used in
+   --  project Project.
+
+   procedure Set
+     (Language   : Language_Index;
+      Present    : Boolean;
+      In_Project : in out Project_Data;
+      In_Tree    : Project_Tree_Ref);
+   --  Indicate if Language is or not a language used in project Project
+
+   function Language_Processing_Data_Of
+     (Language   : Language_Index;
+      In_Project : Project_Data;
+      In_Tree    : Project_Tree_Ref) return Language_Processing_Data;
+   --  Return the Language_Processing_Data for language Language in project
+   --  In_Project. Return the default when no Language_Processing_Data are
+   --  defined for the language.
+
+   procedure Set
+     (Language_Processing : Language_Processing_Data;
+      For_Language        : Language_Index;
+      In_Project          : in out Project_Data;
+      In_Tree             : Project_Tree_Ref);
+   --  Set the Language_Processing_Data for language Language in project
+   --  In_Project.
+
+   function Suffix_Of
+     (Language   : Language_Index;
+      In_Project : Project_Data;
+      In_Tree    : Project_Tree_Ref) return Name_Id;
+   --  Return the suffix for language Language in project In_Project. Return
+   --  No_Name when no suffix is defined for the language.
+
+   procedure Set
+     (Suffix       : Name_Id;
+      For_Language : Language_Index;
+      In_Project   : in out Project_Data;
+      In_Tree      : Project_Tree_Ref);
+   --  Set the suffix for language Language in project In_Project
 
 private
 
-   Initial_Buffer_Size : constant := 100;
-   --  Initial size for extensible buffer used below
+   All_Packages : constant String_List_Access := null;
+
+   No_Project_Tree : constant Project_Tree_Ref := null;
 
-   Buffer : String_Access := new String (1 .. Initial_Buffer_Size);
-   --  An extensible character buffer to store names. Used in Prj.Part and
-   --  Prj.Strt.
+   Ignored : constant Variable_Kind := Single;
+
+   Nil_Variable_Value : constant Variable_Value :=
+     (Project  => No_Project,
+      Kind     => Undefined,
+      Location => No_Location,
+      Default  => False);
 
-   Buffer_Last : Natural := 0;
-   --  The index of the last character in the Buffer
+   Virtual_Prefix : constant String := "v$";
+   --  The prefix for virtual extending projects. Because of the '$', which is
+   --  normally forbidden for project names, there cannot be any name clash.
 
-   Current_Packages_To_Check : String_List_Access := All_Packages;
-   --  Global variable, set by Prj.Part.Parse, used by Prj.Dect.
+   Empty_Name : Name_Id;
+   --  Name_Id for an empty name (no characters). Initialized by the call
+   --  to procedure Initialize.
 
-   procedure Add_To_Buffer (S : String);
+   procedure Add_To_Buffer
+     (S    : String;
+      To   : in out String_Access;
+      Last : in out Natural);
    --  Append a String to the Buffer
 
+   type Naming_Id is new Nat;
+
+   package Naming_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Naming_Data,
+      Table_Index_Type     => Naming_Id,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 5,
+      Table_Increment      => 100);
+
+   package Path_File_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Name_Id,
+      Table_Index_Type     => Natural,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 50,
+      Table_Increment      => 50);
+   --  Table storing all the temp path file names.
+   --  Used by Delete_All_Path_Files.
+
+   package Source_Path_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Name_Id,
+      Table_Index_Type     => Natural,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 50,
+      Table_Increment      => 50);
+   --  A table to store the source dirs before creating the source path file
+
+   package Object_Path_Table is new GNAT.Dynamic_Tables
+     (Table_Component_Type => Name_Id,
+      Table_Index_Type     => Natural,
+      Table_Low_Bound      => 1,
+      Table_Initial        => 50,
+      Table_Increment      => 50);
+   --  A table to store the object dirs, before creating the object path file
+
+   type Private_Project_Tree_Data is record
+      Namings           : Naming_Table.Instance;
+      Path_Files        : Path_File_Table.Instance;
+      Source_Paths      : Source_Path_Table.Instance;
+      Object_Paths      : Object_Path_Table.Instance;
+      Default_Naming    : Naming_Data;
+   end record;
 end Prj;