| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- F N A M E . U F -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1992-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 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 3, 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 COPYING3. If not, go to -- |
| 19 |
-- http://www.gnu.org/licenses for a complete copy of the license. -- |
| 20 |
-- -- |
| 21 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 22 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 23 |
-- -- |
| 24 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
-- This child package contains the routines to translate a unit name to |
| 27 |
-- a file name taking into account Source_File_Name pragmas. It also |
| 28 |
-- contains the auxiliary routines used to record data from the pragmas. |
| 29 |
|
| 30 |
-- Note: the reason we split this into a child unit is that the routines |
| 31 |
-- for unit name translation have a significant number of additional |
| 32 |
-- dependencies, including osint, and hence sdefault. There are a number |
| 33 |
-- of tools that use utility subprograms in the Fname parent, but do not |
| 34 |
-- need the functionality in this child package (and certainly do not want |
| 35 |
-- to deal with the extra dependencies). |
| 36 |
|
| 37 |
with Casing; use Casing; |
| 38 |
with Types; use Types; |
| 39 |
|
| 40 |
package Fname.UF is |
| 41 |
|
| 42 |
----------------- |
| 43 |
-- Subprograms -- |
| 44 |
----------------- |
| 45 |
|
| 46 |
type Expected_Unit_Type is (Expect_Body, Expect_Spec, Unknown); |
| 47 |
-- Return value from Get_Expected_Unit_Type |
| 48 |
|
| 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. |
| 55 |
|
| 56 |
function Get_Default_File_Name (Uname : Unit_Name_Type) return String; |
| 57 |
-- Returns the file name of Uname under the default GNAT naming scheme. |
| 58 |
|
| 59 |
function Get_File_Name |
| 60 |
(Uname : Unit_Name_Type; |
| 61 |
Subunit : Boolean; |
| 62 |
May_Fail : Boolean := False) return File_Name_Type; |
| 63 |
-- This function returns the file name that corresponds to a given unit |
| 64 |
-- name, Uname. The Subunit parameter is set True for subunits, and false |
| 65 |
-- for all other kinds of units. The caller must ensure that the unit name |
| 66 |
-- meets the requirements given in package Uname. |
| 67 |
-- |
| 68 |
-- When May_Fail is True, if the file cannot be found, this function |
| 69 |
-- returns No_File. When it is False, if the file cannot be found, |
| 70 |
-- a file name compatible with one pattern Source_File_Name pragma is |
| 71 |
-- returned. |
| 72 |
|
| 73 |
function Get_Unit_Index (Uname : Unit_Name_Type) return Nat; |
| 74 |
-- If there is a specific Source_File_Name pragma for this unit, then |
| 75 |
-- return the corresponding unit index value. Return 0 if no index given. |
| 76 |
|
| 77 |
procedure Initialize; |
| 78 |
-- Initialize internal tables. This is called automatically when the |
| 79 |
-- package body is elaborated, so an explicit call to Initialize is |
| 80 |
-- only required if it is necessary to reinitialize the source file |
| 81 |
-- name pragma tables. |
| 82 |
|
| 83 |
procedure Lock; |
| 84 |
-- Lock tables before calling back end |
| 85 |
|
| 86 |
function File_Name_Of_Spec (Name : Name_Id) return File_Name_Type; |
| 87 |
-- Returns the file name that corresponds to the spec of a given unit |
| 88 |
-- name. The unit name here is not encoded as a Unit_Name_Type, but is |
| 89 |
-- rather just a normal form name in lower case, e.g. "xyz.def". |
| 90 |
|
| 91 |
function File_Name_Of_Body (Name : Name_Id) return File_Name_Type; |
| 92 |
-- Returns the file name that corresponds to the body of a given unit |
| 93 |
-- name. The unit name here is not encoded as a Unit_Name_Type, but is |
| 94 |
-- rather just a normal form name in lower case, e.g. "xyz.def". |
| 95 |
|
| 96 |
procedure Set_File_Name |
| 97 |
(U : Unit_Name_Type; |
| 98 |
F : File_Name_Type; |
| 99 |
Index : Nat); |
| 100 |
-- Make association between given unit name, U, and the given file name, |
| 101 |
-- F. This is the routine called to process a Source_File_Name pragma. |
| 102 |
-- Index is the value from the index parameter of the pragma if present |
| 103 |
-- and zero if no index parameter is present. |
| 104 |
|
| 105 |
procedure Set_File_Name_Pattern |
| 106 |
(Pat : String_Ptr; |
| 107 |
Typ : Character; |
| 108 |
Dot : String_Ptr; |
| 109 |
Cas : Casing_Type); |
| 110 |
-- This is called to process a Source_File_Name pragma whose first |
| 111 |
-- argument is a file name pattern string. Pat is this pattern string, |
| 112 |
-- which contains an asterisk to correspond to the unit. Typ is one of |
| 113 |
-- 'b'/'s'/'u' for body/spec/subunit, Dot is the separator string |
| 114 |
-- for child/subunit names, and Cas is one of Lower/Upper/Mixed |
| 115 |
-- indicating the required case for the file name. |
| 116 |
|
| 117 |
end Fname.UF; |