1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2002, 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
35 with Hostparm
; use Hostparm
;
36 with Namet
; use Namet
;
41 -----------------------------
42 -- Dummy Table Definitions --
43 -----------------------------
45 -- The following table was used in old versions of the compiler. We retain
46 -- the declarations here for compatibility with old tree files. The new
47 -- version of the compiler does not use this table, and will write out a
48 -- dummy empty table for Tree_Write.
50 type SFN_Entry
is record
55 package SFN_Table
is new Table
.Table
(
56 Table_Component_Type
=> SFN_Entry
,
57 Table_Index_Type
=> Int
,
59 Table_Initial
=> Alloc
.SFN_Table_Initial
,
60 Table_Increment
=> Alloc
.SFN_Table_Increment
,
61 Table_Name
=> "Fname_Dummy_Table");
62 ----------------------------
63 -- Get_Expected_Unit_Type --
64 ----------------------------
66 -- We assume that a file name whose last character is a lower case b is
67 -- a body and a file name whose last character is a lower case s is a
68 -- spec. If any other character is found (e.g. when we are in syntax
69 -- checking only mode, where the file name conventions are not set),
70 -- then we return Unknown.
72 function Get_Expected_Unit_Type
73 (Fname
: File_Name_Type
)
74 return Expected_Unit_Type
77 Get_Name_String
(Fname
);
79 if Name_Buffer
(Name_Len
) = 'b' then
81 elsif Name_Buffer
(Name_Len
) = 's' then
86 end Get_Expected_Unit_Type
;
88 ---------------------------
89 -- Is_Internal_File_Name --
90 ---------------------------
92 function Is_Internal_File_Name
93 (Fname
: File_Name_Type
;
94 Renamings_Included
: Boolean := True)
98 if Is_Predefined_File_Name
(Fname
, Renamings_Included
) then
101 -- Once Is_Predefined_File_Name has been called and returns False,
102 -- Name_Buffer contains Fname and Name_Len is set to 8.
104 elsif Name_Buffer
(1 .. 2) = "g-"
105 or else Name_Buffer
(1 .. 8) = "gnat "
111 (Name_Buffer
(1 .. 4) = "dec-"
112 or else Name_Buffer
(1 .. 8) = "dec ")
119 end Is_Internal_File_Name
;
121 -----------------------------
122 -- Is_Predefined_File_Name --
123 -----------------------------
125 -- This should really be a test of unit name, given the possibility of
126 -- pragma Source_File_Name setting arbitrary file names for any files???
128 -- Once Is_Predefined_File_Name has been called and returns False,
129 -- Name_Buffer contains Fname and Name_Len is set to 8. This is used
130 -- only by Is_Internal_File_Name, and is not part of the official
131 -- external interface of this function.
133 function Is_Predefined_File_Name
134 (Fname
: File_Name_Type
;
135 Renamings_Included
: Boolean := True)
138 subtype Str8
is String (1 .. 8);
140 Predef_Names
: constant array (1 .. 11) of Str8
:=
142 "calendar", -- Calendar
143 "interfac", -- Interfaces
145 "machcode", -- Machine_Code
146 "unchconv", -- Unchecked_Conversion
147 "unchdeal", -- Unchecked_Deallocation
149 -- Remaining entries are only considered if Renamings_Included true
151 "directio", -- Direct_IO
152 "ioexcept", -- IO_Exceptions
153 "sequenio", -- Sequential_IO
154 "text_io "); -- Text_IO
156 Num_Entries
: constant Natural :=
157 7 + 4 * Boolean'Pos (Renamings_Included
);
160 -- Get file name, removing the extension (if any)
162 Get_Name_String
(Fname
);
164 if Name_Len
> 4 and then Name_Buffer
(Name_Len
- 3) = '.' then
165 Name_Len
:= Name_Len
- 4;
168 -- Definitely false if longer than 12 characters (8.3)
173 -- Definitely predefined if prefix is a- i- or s-
176 and then Name_Buffer
(2) = '-'
177 and then (Name_Buffer
(1) = 'a' or else
178 Name_Buffer
(1) = 'i' or else
179 Name_Buffer
(1) = 's')
184 -- Otherwise check against special list, first padding to 8 characters
186 while Name_Len
< 8 loop
187 Name_Len
:= Name_Len
+ 1;
188 Name_Buffer
(Name_Len
) := ' ';
191 for J
in 1 .. Num_Entries
loop
192 if Name_Buffer
(1 .. 8) = Predef_Names
(J
) then
197 -- Note: when we return False here, the Name_Buffer contains the
198 -- padded file name. This is not defined for clients of the package,
199 -- but is used by Is_Internal_File_Name.
202 end Is_Predefined_File_Name
;
208 procedure Tree_Read
is
217 procedure Tree_Write
is
219 SFN_Table
.Tree_Write
;