-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2004 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- --
-- Set when the entry is created by a call to Lib.Load and then cannot
-- be changed.
+ -- Munit_Index
+ -- The index of the unit within the file for multiple unit per file
+ -- mode. Set to zero in normal single unit per file mode.
+
-- Error_Location
-- This is copied from the Sloc field of the Enode argument passed
-- to Load_Unit. It refers to the enclosing construct which caused
-- then called to reflect the contributions of any unit on which this
-- unit is semantically dependent.
- -- Dependent_Unit
- -- This is a Boolean flag, which is set True to indicate that this
- -- entry is for a semantically dependent unit. This flag is nearly
- -- always set True, the only exception is for a unit that is loaded
- -- by an Rtsfind request in No_Run_Time mode, where the entity that
- -- is obtained by Rtsfind.RTE is for an inlined subprogram or other
- -- entity for which a dependency need not be created.
-
-- The units table is reset to empty at the start of the compilation of
-- each main unit by Lib.Initialize. Entries are then added by calls to
-- the Lib.Load procedure. The following subprograms are used to access
function Cunit (U : Unit_Number_Type) return Node_Id;
function Cunit_Entity (U : Unit_Number_Type) return Entity_Id;
- function Dependent_Unit (U : Unit_Number_Type) return Boolean;
function Dependency_Num (U : Unit_Number_Type) return Nat;
function Dynamic_Elab (U : Unit_Number_Type) return Boolean;
function Error_Location (U : Unit_Number_Type) return Source_Ptr;
function Has_RACW (U : Unit_Number_Type) return Boolean;
function Loading (U : Unit_Number_Type) return Boolean;
function Main_Priority (U : Unit_Number_Type) return Int;
+ function Munit_Index (U : Unit_Number_Type) return Nat;
function Source_Index (U : Unit_Number_Type) return Source_File_Index;
function Unit_File_Name (U : Unit_Number_Type) return File_Name_Type;
function Unit_Name (U : Unit_Number_Type) return Unit_Name_Type;
function Num_Units return Nat;
-- Number of units currently in unit table
+ procedure Remove_Unit (U : Unit_Number_Type);
+ -- Remove unit U from unit table. Currently this is effective only
+ -- if U is the last unit currently stored in the unit table.
+
function Entity_Is_In_Main_Unit (E : Entity_Id) return Boolean;
-- Returns True if the entity E is declared in the main unit, or, in
-- its corresponding spec, or one of its subunits. Entities declared
-- same value for each argument.
function In_Same_Code_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean;
- pragma Inline (In_Same_Source_Unit);
+ pragma Inline (In_Same_Code_Unit);
-- Determines if the two nodes or entities N1 and N2 are in the same
-- code unit, the criterion being that Get_Code_Unit yields the same
-- value for each argument.
+ function In_Same_Extended_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean;
+ pragma Inline (In_Same_Extended_Unit);
+ -- Determines if two nodes or entities N1 and N2 are in the same
+ -- extended unit, where an extended unit is defined as a unit and all
+ -- its subunits (considered recursively, i.e. subunits of subunits are
+ -- included). Returns true if S1 and S2 are in the same extended unit
+ -- and False otherwise.
+
function In_Same_Extended_Unit (S1, S2 : Source_Ptr) return Boolean;
+ pragma Inline (In_Same_Extended_Unit);
-- Determines if the two source locations S1 and S2 are in the same
-- extended unit, where an extended unit is defined as a unit and all
- -- its subunits (considered recursively, i.e. subunits or subunits are
+ -- its subunits (considered recursively, i.e. subunits of subunits are
-- included). Returns true if S1 and S2 are in the same extended unit
-- and False otherwise.
function In_Extended_Main_Code_Unit
- (N : Node_Or_Entity_Id)
- return Boolean;
+ (N : Node_Or_Entity_Id) return Boolean;
-- Return True if the node is in the generated code of the extended main
-- unit, defined as the main unit, its specification (if any), and all
-- its subunits (considered recursively). Units for which this enquiry
-- If the main unit is itself a subunit, then the extended main unit
-- includes its parent unit, and the parent unit spec if it is separate.
+ function In_Extended_Main_Code_Unit (Loc : Source_Ptr) return Boolean;
+ -- Same function as above, but argument is a source pointer rather
+ -- than a node.
+
function In_Extended_Main_Source_Unit
- (N : Node_Or_Entity_Id)
- return Boolean;
+ (N : Node_Or_Entity_Id) return Boolean;
-- Return True if the node is in the source text of the extended main
-- unit, defined as the main unit, its specification (if any), and all
-- its subunits (considered recursively). Units for which this enquiry
-- a subunit, then the extended main unit includes its parent unit,
-- and the parent unit spec if it is separate.
+ function In_Extended_Main_Source_Unit (Loc : Source_Ptr) return Boolean;
+ -- Same function as above, but argument is a source pointer rather
+ -- than a node.
+
function Earlier_In_Extended_Unit (S1, S2 : Source_Ptr) return Boolean;
-- Given two Sloc values for which In_Same_Extended_Unit is true,
-- determine if S1 appears before S2. Returns True if S1 appears before
-- could not have been built without making a unit table entry.
function Get_Cunit_Entity_Unit_Number
- (E : Entity_Id)
- return Unit_Number_Type;
+ (E : Entity_Id) return Unit_Number_Type;
-- Return unit number of the unit whose compilation unit spec entity is
-- the one passed as an argument. This must always succeed since the
-- entity could not have been built without making a unit table entry.
-- Increment Serial_Number field for current unit, and return the
-- incremented value.
+ procedure Synchronize_Serial_Number;
+ -- This function increments the Serial_Number field for the current
+ -- unit but does not return the incremented value. This is used when
+ -- there is a situation where one path of control increments a serial
+ -- number (using Increment_Serial_Number), and the other path does not
+ -- and it is important to keep the serial numbers synchronized in the
+ -- two cases (e.g. when the references in a package and a client must
+ -- be kept consistent).
+
procedure Replace_Linker_Option_String
- (S : String_Id; Match_String : String);
+ (S : String_Id;
+ Match_String : String);
-- Replace an existing Linker_Option if the prefix Match_String
-- matches, otherwise call Store_Linker_Option_String.
-- Called to register a compilation switch, either front-end or
-- back-end, which may influence the generated output file(s).
+ procedure Disable_Switch_Storing;
+ -- Disable the registration of compilation switches with
+ -- Store_Compilation_Switch. This is used to not register switches added
+ -- automatically by the gcc driver.
+
procedure Store_Linker_Option_String (S : String_Id);
-- This procedure is called to register the string from a pragma
-- Linker_Option. The argument is the Id of the string to register.
procedure Lock;
-- Lock internal tables before calling back end
- procedure Tree_Write;
- -- Writes out internal tables to current tree file using Tree_Write
-
procedure Tree_Read;
- -- Initializes internal tables from current tree file using Tree_Read
+ -- Initializes internal tables from current tree file using the relevant
+ -- Table.Tree_Read routines.
+
+ procedure Tree_Write;
+ -- Writes out internal tables to current tree file using the relevant
+ -- Table.Tree_Write routines.
function Is_Loaded (Uname : Unit_Name_Type) return Boolean;
-- Determines if unit with given name is already loaded, i.e. there is
-- restricts the list to exclude any predefined files.
function Generic_Separately_Compiled (E : Entity_Id) return Boolean;
+ -- This is the old version of tbe documentation of this function:
+ --
-- Most generic units must be separately compiled. Since we always use
-- macro substitution for generics, the resulting object file is a dummy
-- one with no code, but the ali file has the normal form, and we need
-- compiler itself. The only such generics are predefined ones. This
-- function returns True if the given generic unit entity E is for a
-- generic unit that should be separately compiled, and false otherwise.
+ --
+ -- Now GNAT can compile any generic unit including predefined ones, but
+ -- because of the backward compatibility (to keep the ability to use old
+ -- compiler versions to build GNAT) compiling library generics is an
+ -- option. That is, now GNAT compiles a library generic as an ordinary
+ -- unit, but it also can build an exeutable in case if its library
+ -- contains some (or all) predefined generics non compiled. See 9628-002
+ -- for the description of changes to be done to get rid of a special
+ -- processing of library generic.
+ --
+ -- So now this function returns TRUE if a generic MUST be separately
+ -- compiled with the current approach.
+
+ function Generic_Separately_Compiled
+ (Sfile : File_Name_Type) return Boolean;
+ -- Same as the previous function, but works directly on a unit file name.
private
pragma Inline (Cunit);
pragma Inline (Cunit_Entity);
pragma Inline (Dependency_Num);
- pragma Inline (Dependent_Unit);
pragma Inline (Fatal_Error);
pragma Inline (Generate_Code);
pragma Inline (Has_RACW);
pragma Inline (Increment_Serial_Number);
pragma Inline (Loading);
pragma Inline (Main_Priority);
+ pragma Inline (Munit_Index);
pragma Inline (Set_Cunit);
pragma Inline (Set_Cunit_Entity);
pragma Inline (Set_Fatal_Error);
type Unit_Record is record
Unit_File_Name : File_Name_Type;
Unit_Name : Unit_Name_Type;
+ Munit_Index : Nat;
Expected_Unit : Unit_Name_Type;
Source_Index : Source_File_Index;
Cunit : Node_Id;
Cunit_Entity : Entity_Id;
Dependency_Num : Int;
- Dependent_Unit : Boolean;
Fatal_Error : Boolean;
Generate_Code : Boolean;
Has_RACW : Boolean;