* Make-lang.in (cp/pt.o): Depend on vecprim.h.
[official-gcc.git] / gcc / ada / xref_lib.ads
blob8494a9b3d723e3a707d643ad57156876bbf0a61c
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- X R E F _ L I B --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1998-2006, 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 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- Miscellaneous utilities for the cross-referencing tool
29 with Hostparm;
30 with Xr_Tabls; use Xr_Tabls;
32 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
33 with GNAT.OS_Lib; use GNAT.OS_Lib;
34 with GNAT.Dynamic_Tables;
35 with GNAT.Regexp; use GNAT.Regexp;
37 package Xref_Lib is
39 subtype File_Name_String is String (1 .. Hostparm.Max_Name_Length);
40 subtype Line_String is String (1 .. Hostparm.Max_Line_Length);
42 type ALI_File is limited private;
44 ---------------------
45 -- Directory Input --
46 ---------------------
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_Xref_File (File : String);
72 -- Add a new file in the list of files to search for references. File
73 -- is interpreted as a globbing regular expression, which is expanded.
75 Invalid_Argument : exception;
76 -- Exception raised when there is a syntax error in the command line
78 -----------------------
79 -- Output Algorithms --
80 -----------------------
82 procedure Print_Gnatfind
83 (References : Boolean;
84 Full_Path_Name : Boolean);
85 procedure Print_Unused (Full_Path_Name : Boolean);
86 procedure Print_Vi (Full_Path_Name : Boolean);
87 procedure Print_Xref (Full_Path_Name : Boolean);
88 -- The actual print procedures. These functions step through the symbol
89 -- table and print all the symbols if they match the files given on the
90 -- command line (they already match the entities if they are in the
91 -- symbol table)
93 ------------------------
94 -- General Algorithms --
95 ------------------------
97 function Default_Project_File (Dir_Name : String) return String;
98 -- Returns the default Project file name for the directory Dir_Name
100 procedure Search
101 (Pattern : Search_Pattern;
102 Local_Symbols : Boolean;
103 Wide_Search : Boolean;
104 Read_Only : Boolean;
105 Der_Info : Boolean;
106 Type_Tree : Boolean);
107 -- Search every ALI file for entities matching Pattern, and add
108 -- these entities to the internal symbol tables.
110 -- If Wide_Search is True, all ALI files found in the object path
111 -- are searched.
113 -- If Read_Only is True, read-only ALI files will also be parsed,
114 -- similar to gnatmake -a.
116 -- If Der_Info is true, then the derived type information will be
117 -- processed.
119 -- If Type_Tree is true, then the type hierarchy wil be searched
120 -- going from the pattern to the parent type.
122 procedure Search_Xref
123 (Local_Symbols : Boolean;
124 Read_Only : Boolean;
125 Der_Info : Boolean);
126 -- Search every ali file given in the command line and all their
127 -- dependencies. If Read_Only is True, we parse the read-only ali
128 -- files too. If Der_Mode is true then the derived type information will
129 -- be processed
131 private
132 type Rec_DIR is limited record
133 Dir : GNAT.Directory_Operations.Dir_Type;
134 end record;
136 package Dependencies_Tables is new GNAT.Dynamic_Tables
137 (Table_Component_Type => Xr_Tabls.File_Reference,
138 Table_Index_Type => Positive,
139 Table_Low_Bound => 1,
140 Table_Initial => 400,
141 Table_Increment => 100);
142 use Dependencies_Tables;
144 type Dependencies is new Dependencies_Tables.Instance;
146 type ALI_File is limited record
147 Buffer : String_Access := null;
148 -- Buffer used to read the whole file at once
150 Current_Line : Positive;
151 -- Start of the current line in Buffer
153 Xref_Line : Positive;
154 -- Start of the xref lines in Buffer
156 X_File : Xr_Tabls.File_Reference;
157 -- Stores the cross-referencing file-name ("X..." lines), as an
158 -- index into the dependencies table
160 Dep : Dependencies;
161 -- Store file name associated with each number ("D..." lines)
162 end record;
164 -- The following record type stores all the patterns that are searched for
166 type Search_Pattern is record
167 Entity : GNAT.Regexp.Regexp;
168 -- A regular expression matching the entities we are looking for.
169 -- File is a list of the places where the declaration of the entities
170 -- has to be. When the user enters a file:line:column on the command
171 -- line, it is stored as "Entity_Name Declaration_File:line:column"
173 File_Ref : Xr_Tabls.File_Reference;
174 -- A reference to the source file, if any
176 Initialized : Boolean := False;
177 -- Set to True when Entity has been initialized
178 end record;
180 end Xref_Lib;