* c-decl.c (duplicate_decls): Conditionalize DECL_SAVED_TREE copy.
[official-gcc.git] / gcc / ada / xref_lib.ads
blob1282ad142dcb6289156c6ad59032e0bd7cf25aab
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- X R E F _ L I B --
6 -- --
7 -- S p e c --
8 -- --
9 -- $Revision: 1.20 $
10 -- --
11 -- Copyright (C) 1998-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 is maintained by Ada Core Technologies Inc (http://www.gnat.com). --
25 -- --
26 ------------------------------------------------------------------------------
28 with Hostparm;
29 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
30 with GNAT.OS_Lib; use GNAT.OS_Lib;
31 with GNAT.Dynamic_Tables;
33 with Xr_Tabls; use Xr_Tabls;
34 with GNAT.Regexp; use GNAT.Regexp;
36 -- Misc. utilities for the cross-referencing tool
38 package Xref_Lib is
40 subtype File_Name_String is String (1 .. Hostparm.Max_Name_Length);
41 subtype Line_String is String (1 .. Hostparm.Max_Line_Length);
43 type ALI_File is limited private;
45 ---------------------
46 -- Directory Input --
47 ---------------------
48 type Rec_DIR is limited private;
49 -- This one is used for recursive search of .ali files
51 procedure Find_ALI_Files;
52 -- Find all the ali files that we will have to parse, and have them to
53 -- the file list
55 ---------------------
56 -- Search patterns --
57 ---------------------
59 type Search_Pattern is private;
60 type Search_Pattern_Ptr is access all Search_Pattern;
62 procedure Add_Entity
63 (Pattern : in out Search_Pattern;
64 Entity : String;
65 Glob : Boolean := False);
66 -- Add a new entity to the search pattern (the entity should have the
67 -- form pattern[:file[:line[:column]]], and it is parsed entirely in
68 -- this procedure. Glob indicates if we should use the 'globbing
69 -- patterns' (True) or the full regular expressions (False)
71 procedure Add_File (File : String);
72 -- Add a new file in the list of files to search for references.
73 -- File is considered to be a globbing regular expression, which is thus
74 -- expanded
76 Invalid_Argument : exception;
77 -- Exception raised when there is a syntax error in the command line
79 function Match
80 (Pattern : Search_Pattern;
81 Symbol : String)
82 return Boolean;
83 -- Returns true if Symbol matches one of the entities in the command line
85 -----------------------
86 -- Output Algorithms --
87 -----------------------
89 procedure Print_Gnatfind
90 (References : in Boolean;
91 Full_Path_Name : in Boolean);
92 procedure Print_Unused (Full_Path_Name : in Boolean);
93 procedure Print_Vi (Full_Path_Name : in Boolean);
94 procedure Print_Xref (Full_Path_Name : in Boolean);
95 -- The actual print procedures. These functions step through the symbol
96 -- table and print all the symbols if they match the files given on the
97 -- command line (they already match the entities if they are in the
98 -- symbol table)
100 ------------------------
101 -- General Algorithms --
102 ------------------------
103 function Default_Project_File (Dir_Name : in String) return String;
104 -- Returns the default Project file name
106 procedure Search
107 (Pattern : Search_Pattern;
108 Local_Symbols : Boolean;
109 Wide_Search : Boolean;
110 Read_Only : Boolean;
111 Der_Info : Boolean;
112 Type_Tree : Boolean);
113 -- Search every ali file (following the Readdir rule above), for
114 -- each line matching Pattern, and executes Process on these
115 -- lines. If World is True, Search will look into every .ali file
116 -- in the object search path. If Read_Only is True, we parse the
117 -- read-only ali files too. If Der_Mode is true then the derived type
118 -- information will be processed. If Type_Tree is true then the type
119 -- hierarchy will be search going from pattern to the parent type
121 procedure Search_Xref
122 (Local_Symbols : Boolean;
123 Read_Only : Boolean;
124 Der_Info : Boolean);
125 -- Search every ali file given in the command line and all their
126 -- dependencies. If Read_Only is True, we parse the read-only ali
127 -- files too. If Der_Mode is true then the derived type information will
128 -- be processed
130 ---------------
131 -- ALI files --
132 ---------------
134 function Current_Xref_File
135 (File : ALI_File)
136 return Xr_Tabls.File_Reference;
137 -- Returns the name of the file in which the last identifier
138 -- is declared
140 function File_Name
141 (File : ALI_File;
142 Num : Positive)
143 return Xr_Tabls.File_Reference;
144 -- Returns the dependency file name number Num
146 function Get_Full_Type (Abbrev : Character) return String;
147 -- Returns the full type corresponding to a type letter as found in
148 -- the .ali files.
150 procedure Open
151 (Name : in String;
152 File : out ALI_File;
153 Dependencies : in Boolean := False);
154 -- Open a new ALI file
155 -- if Dependencies is True, the insert every library file 'with'ed in
156 -- the files database (used for gnatxref)
159 private
160 type Rec_DIR is limited record
161 Dir : GNAT.Directory_Operations.Dir_Type;
162 end record;
164 package Dependencies_Tables is new GNAT.Dynamic_Tables
165 (Table_Component_Type => Xr_Tabls.File_Reference,
166 Table_Index_Type => Positive,
167 Table_Low_Bound => 1,
168 Table_Initial => 400,
169 Table_Increment => 100);
170 use Dependencies_Tables;
172 type Dependencies is new Dependencies_Tables.Instance;
174 type ALI_File is limited record
175 Buffer : String_Access := null;
176 -- Buffer used to read the whole file at once
178 Current_Line : Positive;
179 -- Start of the current line in Buffer
181 Xref_Line : Positive;
182 -- Start of the xref lines in Buffer
184 X_File : Xr_Tabls.File_Reference;
185 -- Stores the cross-referencing file-name ("X..." lines), as an
186 -- index into the dependencies table
188 Dep : Dependencies;
189 -- Store file name associated with each number ("D..." lines)
190 end record;
192 -- The following record type stores all the patterns that are searched for
194 type Search_Pattern is record
195 Entity : GNAT.Regexp.Regexp;
196 -- A regular expression matching the entities we are looking for.
197 -- File is a list of the places where the declaration of the entities
198 -- has to be. When the user enters a file:line:column on the command
199 -- line, it is stored as "Entity_Name Declaration_File:line:column"
201 Initialized : Boolean := False;
202 -- Set to True when Entity has been initialized.
203 end record;
204 -- Stores all the pattern that are search for.
205 end Xref_Lib;