1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This child package contains the routines to translate a unit name to
28 -- a file name taking into account Source_File_Name pragmas. It also
29 -- contains the auxiliary routines used to record data from the pragmas.
31 -- Note: the reason we split this into a child unit is that the routines
32 -- for unit name translation have a significant number of additional
33 -- dependencies, including osint, and hence sdefault. There are a number
34 -- of tools that use utility subprograms in the Fname parent, but do not
35 -- need the functionality in this child package (and certainly do not want
36 -- to deal with the extra dependencies).
38 with Casing
; use Casing
;
46 type Expected_Unit_Type
is (Expect_Body
, Expect_Spec
, Unknown
);
47 -- Return value from Get_Expected_Unit_Type
49 function Get_Expected_Unit_Type
50 (Fname
: File_Name_Type
) return Expected_Unit_Type
;
51 -- If possible, determine whether the given file name corresponds to a unit
52 -- that is a spec or body (e.g. by examining the extension). If this cannot
53 -- be determined with the file naming conventions in use, then the returned
54 -- value is set to Unknown.
56 function Get_File_Name
57 (Uname
: Unit_Name_Type
;
59 May_Fail
: Boolean := False) return File_Name_Type
;
60 -- This function returns the file name that corresponds to a given unit
61 -- name, Uname. The Subunit parameter is set True for subunits, and
62 -- false for all other kinds of units. The caller is responsible for
63 -- ensuring that the unit name meets the requirements given in package
64 -- Uname and described above.
66 -- When May_Fail is True, if the file cannot be found, this function
67 -- returns No_File. When it is False, if the file cannot be found,
68 -- a file name compatible with one pattern Source_File_Name pragma is
71 function Get_Unit_Index
(Uname
: Unit_Name_Type
) return Nat
;
72 -- If there is a specific Source_File_Name pragma for this unit, then
73 -- return the corresponding unit index value. Return 0 if no index given.
76 -- Initialize internal tables. This is called automatically when the
77 -- package body is elaborated, so an explicit call to Initialize is
78 -- only required if it is necessary to reinitialize the source file
79 -- name pragma tables.
82 -- Lock tables before calling back end
84 function File_Name_Of_Spec
(Name
: Name_Id
) return File_Name_Type
;
85 -- Returns the file name that corresponds to the spec of a given unit
86 -- name. The unit name here is not encoded as a Unit_Name_Type, but is
87 -- rather just a normal form name in lower case, e.g. "xyz.def".
89 function File_Name_Of_Body
(Name
: Name_Id
) return File_Name_Type
;
90 -- Returns the file name that corresponds to the body of a given unit
91 -- name. The unit name here is not encoded as a Unit_Name_Type, but is
92 -- rather just a normal form name in lower case, e.g. "xyz.def".
94 procedure Set_File_Name
98 -- Make association between given unit name, U, and the given file name,
99 -- F. This is the routine called to process a Source_File_Name pragma.
100 -- Index is the value from the index parameter of the pragma if present
101 -- and zero if no index parameter is present.
103 procedure Set_File_Name_Pattern
108 -- This is called to process a Source_File_Name pragma whose first
109 -- argument is a file name pattern string. Pat is this pattern string,
110 -- which contains an asterisk to correspond to the unit. Typ is one of
111 -- 'b'/'s'/'u' for body/spec/subunit, Dot is the separator string
112 -- for child/subunit names, and Cas is one of Lower/Upper/Mixed
113 -- indicating the required case for the file name.