(extendsfdf2): Add pattern accidentally deleted when cirrus instructions were
[official-gcc.git] / gcc / ada / ali-util.ads
blobe786a0f31bd2e06f27a8a0e3a8eb0b9616698c19
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I . U T I L --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 -- --
26 ------------------------------------------------------------------------------
28 -- This child unit provides utility data structures and procedures used
29 -- for manipulation of ALI data by the gnatbind and gnatmake.
31 package ALI.Util is
33 -----------------------
34 -- Source File Table --
35 -----------------------
37 -- A source file table entry is built for every source file that is
38 -- in the source dependency table of any of the ALI files that make
39 -- up the current program.
41 No_Source_Id : constant Source_Id := Source_Id'First;
42 -- Special value indicating no Source table entry
44 First_Source_Entry : constant Source_Id := No_Source_Id + 1;
45 -- Id of first actual entry in table
47 type Source_Record is record
49 Sfile : File_Name_Type;
50 -- Name of source file
52 Stamp : Time_Stamp_Type;
53 -- Time stamp value. If Check_Source_Files is set and the source
54 -- file is located, then Stamp is set from the source file. Otherwise
55 -- Stamp is set from the latest stamp value found in any of the
56 -- ALI files for the current program.
58 Source_Found : Boolean;
59 -- This flag is set to True if the corresponding source file was
60 -- located and the Stamp value was set from the actual source file.
61 -- It is always false if Check_Source_Files is not set.
63 All_Timestamps_Match : Boolean;
64 -- This flag is set only if all files referencing this source file
65 -- have a matching time stamp, and also, if Source_Found is True,
66 -- then the stamp of the source file also matches. If this flag is
67 -- True, then checksums for this file are never referenced. We only
68 -- use checksums if there are time stamp mismatches.
70 All_Checksums_Match : Boolean;
71 -- This flag is set only if all files referencing this source file
72 -- have checksums, and if all these checksums match. If this flag
73 -- is set to True, then the binder will ignore a timestamp mismatch.
74 -- An absent checksum causes this flag to be set False, and a mismatch
75 -- of checksums also causes it to be set False. The checksum of the
76 -- actual source file (if Source_Found is True) is included only if
77 -- All_Timestamps_Match is False (since checksums are only interesting
78 -- if we have time stamp mismatches, and we want to avoid computing the
79 -- checksum of the source file if it is not needed.)
81 Checksum : Word;
82 -- If no dependency line has a checksum for this source file (i.e. the
83 -- corresponding entries in the source dependency records all have the
84 -- Checksum_Present flag set False), then this field is undefined. If
85 -- at least one dependency entry has a checksum present, then this
86 -- field contains one of the possible checksum values that has been
87 -- seen. This is used to set All_Checksums_Match properly.
89 end record;
91 package Source is new Table.Table (
92 Table_Component_Type => Source_Record,
93 Table_Index_Type => Source_Id,
94 Table_Low_Bound => First_Source_Entry,
95 Table_Initial => 1000,
96 Table_Increment => 200,
97 Table_Name => "Source");
99 procedure Initialize_ALI_Source;
100 -- Initialize Source table
102 --------------------------------------------------
103 -- Subprograms for Manipulating ALI Information --
104 --------------------------------------------------
106 procedure Read_ALI (Id : ALI_Id);
107 -- Process an ALI file which has been read and scanned by looping
108 -- through all withed units in the ALI file; checking if they have
109 -- been processed; and for each that hasn't, reading, scanning, and
110 -- recursively processing.
112 procedure Set_Source_Table (A : ALI_Id);
113 -- Build source table entry corresponding to the ALI file whose id is A.
115 procedure Set_Source_Table;
116 -- Build the entire source table.
118 function Time_Stamp_Mismatch (A : ALI_Id) return File_Name_Type;
119 -- Looks in the Source_Table and checks time stamp mismatches between
120 -- the sources there and the sources in the Sdep section of ali file whose
121 -- id is A. If no time stamp mismatches are found No_File is returned.
122 -- Otherwise return the first file for which there is a mismatch.
123 -- Note that in check source files mode (Check_Source_Files = True), the
124 -- time stamp in the Source_Table should be the actual time stamp of the
125 -- source files. In minimal recompilation mode (Minimal_Recompilation set
126 -- to True, no mismatch is found if the file's timestamp has not changed.
128 --------------------------------------------
129 -- Subprograms for manipulating checksums --
130 --------------------------------------------
132 Checksum_Error : constant Word := 16#FFFF_FFFF#;
133 -- This value is used to indicate an error in computing the checksum.
134 -- When comparing checksums for smart recompilation, the CRC_Error
135 -- value is never considered to match. This could possibly result
136 -- in a false negative, but that is never harmful, it just means
137 -- that in unusual cases an unnecessary recompilation occurs.
139 function Get_File_Checksum (Fname : Name_Id) return Word;
140 -- Compute checksum for the given file. As far as possible, this circuit
141 -- computes exactly the same value computed by the compiler, but it does
142 -- not matter if it gets it wrong in marginal cases, since the only result
143 -- is to miss some smart recompilation cases, correct functioning is not
144 -- affected by a miscomputation. Returns Checksum_Error if the file is
145 -- missing or has an error.
147 function Checksums_Match (Checksum1, Checksum2 : Word) return Boolean;
148 pragma Inline (Checksums_Match);
149 -- Returns True if Checksum1 and Checksum2 have the same value and are
150 -- not equal to Checksum_Error, returns False in all other cases. This
151 -- routine must always be used to compare for checksum equality, to
152 -- ensure that the case of Checksum_Error is handled properly.
154 end ALI.Util;