OSDN Git Service

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