annotate gcc/ada/xref_lib.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- X R E F _ L I B --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1998-2015, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- Miscellaneous utilities for the cross-referencing tool
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 with Hostparm;
kono
parents:
diff changeset
29 with Xr_Tabls; use Xr_Tabls;
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
kono
parents:
diff changeset
32 with GNAT.OS_Lib; use GNAT.OS_Lib;
kono
parents:
diff changeset
33 with GNAT.Dynamic_Tables;
kono
parents:
diff changeset
34 with GNAT.Regexp; use GNAT.Regexp;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 package Xref_Lib is
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 subtype File_Name_String is String (1 .. Hostparm.Max_Name_Length);
kono
parents:
diff changeset
39 subtype Line_String is String (1 .. Hostparm.Max_Line_Length);
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 type ALI_File is limited private;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 ---------------------
kono
parents:
diff changeset
44 -- Directory Input --
kono
parents:
diff changeset
45 ---------------------
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 type Rec_DIR is limited private;
kono
parents:
diff changeset
48 -- This one is used for recursive search of .ali files
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure Find_ALI_Files;
kono
parents:
diff changeset
51 -- Find all the ali files that we will have to parse, and have them to
kono
parents:
diff changeset
52 -- the file list
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 ---------------------
kono
parents:
diff changeset
55 -- Search patterns --
kono
parents:
diff changeset
56 ---------------------
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 type Search_Pattern is private;
kono
parents:
diff changeset
59 type Search_Pattern_Ptr is access all Search_Pattern;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 procedure Add_Entity
kono
parents:
diff changeset
62 (Pattern : in out Search_Pattern;
kono
parents:
diff changeset
63 Entity : String;
kono
parents:
diff changeset
64 Glob : Boolean := False);
kono
parents:
diff changeset
65 -- Add a new entity to the search pattern (the entity should have the
kono
parents:
diff changeset
66 -- form pattern[:file[:line[:column]]], and it is parsed entirely in
kono
parents:
diff changeset
67 -- this procedure. Glob indicates if we should use the 'globbing
kono
parents:
diff changeset
68 -- patterns' (True) or the full regular expressions (False)
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 procedure Add_Xref_File (File : String);
kono
parents:
diff changeset
71 -- Add a new file in the list of files to search for references. File
kono
parents:
diff changeset
72 -- is interpreted as a globbing regular expression, which is expanded.
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 Invalid_Argument : exception;
kono
parents:
diff changeset
75 -- Exception raised when there is a syntax error in the command line
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 -----------------------
kono
parents:
diff changeset
78 -- Output Algorithms --
kono
parents:
diff changeset
79 -----------------------
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 procedure Print_Gnatfind
kono
parents:
diff changeset
82 (References : Boolean;
kono
parents:
diff changeset
83 Full_Path_Name : Boolean);
kono
parents:
diff changeset
84 procedure Print_Unused (Full_Path_Name : Boolean);
kono
parents:
diff changeset
85 procedure Print_Vi (Full_Path_Name : Boolean);
kono
parents:
diff changeset
86 procedure Print_Xref (Full_Path_Name : Boolean);
kono
parents:
diff changeset
87 -- The actual print procedures. These functions step through the symbol
kono
parents:
diff changeset
88 -- table and print all the symbols if they match the files given on the
kono
parents:
diff changeset
89 -- command line (they already match the entities if they are in the
kono
parents:
diff changeset
90 -- symbol table)
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 ------------------------
kono
parents:
diff changeset
93 -- General Algorithms --
kono
parents:
diff changeset
94 ------------------------
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 function Default_Project_File (Dir_Name : String) return String;
kono
parents:
diff changeset
97 -- Returns the default Project file name for the directory Dir_Name
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 procedure Search
kono
parents:
diff changeset
100 (Pattern : Search_Pattern;
kono
parents:
diff changeset
101 Local_Symbols : Boolean;
kono
parents:
diff changeset
102 Wide_Search : Boolean;
kono
parents:
diff changeset
103 Read_Only : Boolean;
kono
parents:
diff changeset
104 Der_Info : Boolean;
kono
parents:
diff changeset
105 Type_Tree : Boolean);
kono
parents:
diff changeset
106 -- Search every ALI file for entities matching Pattern, and add
kono
parents:
diff changeset
107 -- these entities to the internal symbol tables.
kono
parents:
diff changeset
108 --
kono
parents:
diff changeset
109 -- If Wide_Search is True, all ALI files found in the object path
kono
parents:
diff changeset
110 -- are searched.
kono
parents:
diff changeset
111 --
kono
parents:
diff changeset
112 -- If Read_Only is True, read-only ALI files will also be parsed,
kono
parents:
diff changeset
113 -- similar to gnatmake -a.
kono
parents:
diff changeset
114 --
kono
parents:
diff changeset
115 -- If Der_Info is true, then the derived type information will be
kono
parents:
diff changeset
116 -- processed.
kono
parents:
diff changeset
117 --
kono
parents:
diff changeset
118 -- If Type_Tree is true, then the type hierarchy will be searched
kono
parents:
diff changeset
119 -- going from the pattern to the parent type.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 procedure Search_Xref
kono
parents:
diff changeset
122 (Local_Symbols : Boolean;
kono
parents:
diff changeset
123 Read_Only : Boolean;
kono
parents:
diff changeset
124 Der_Info : Boolean);
kono
parents:
diff changeset
125 -- Search every ali file given in the command line and all their
kono
parents:
diff changeset
126 -- dependencies. If Read_Only is True, we parse the read-only ali
kono
parents:
diff changeset
127 -- files too. If Der_Mode is true then the derived type information will
kono
parents:
diff changeset
128 -- be processed
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 private
kono
parents:
diff changeset
131 type Rec_DIR is limited record
kono
parents:
diff changeset
132 Dir : GNAT.Directory_Operations.Dir_Type;
kono
parents:
diff changeset
133 end record;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 package Dependencies_Tables is new GNAT.Dynamic_Tables
kono
parents:
diff changeset
136 (Table_Component_Type => Xr_Tabls.File_Reference,
kono
parents:
diff changeset
137 Table_Index_Type => Natural,
kono
parents:
diff changeset
138 Table_Low_Bound => 1,
kono
parents:
diff changeset
139 Table_Initial => 400,
kono
parents:
diff changeset
140 Table_Increment => 100);
kono
parents:
diff changeset
141 use Dependencies_Tables;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 type Dependencies is new Dependencies_Tables.Instance;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 type ALI_File is limited record
kono
parents:
diff changeset
146 Buffer : String_Access := null;
kono
parents:
diff changeset
147 -- Buffer used to read the whole file at once
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 Current_Line : Positive;
kono
parents:
diff changeset
150 -- Start of the current line in Buffer
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 Xref_Line : Positive;
kono
parents:
diff changeset
153 -- Start of the xref lines in Buffer
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 X_File : Xr_Tabls.File_Reference;
kono
parents:
diff changeset
156 -- Stores the cross-referencing file-name ("X..." lines), as an
kono
parents:
diff changeset
157 -- index into the dependencies table
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 Dep : Dependencies;
kono
parents:
diff changeset
160 -- Store file name associated with each number ("D..." lines)
kono
parents:
diff changeset
161 end record;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 -- The following record type stores all the patterns that are searched for
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 type Search_Pattern is record
kono
parents:
diff changeset
166 Entity : GNAT.Regexp.Regexp;
kono
parents:
diff changeset
167 -- A regular expression matching the entities we are looking for.
kono
parents:
diff changeset
168 -- File is a list of the places where the declaration of the entities
kono
parents:
diff changeset
169 -- has to be. When the user enters a file:line:column on the command
kono
parents:
diff changeset
170 -- line, it is stored as "Entity_Name Declaration_File:line:column"
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 File_Ref : Xr_Tabls.File_Reference;
kono
parents:
diff changeset
173 -- A reference to the source file, if any
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 Initialized : Boolean := False;
kono
parents:
diff changeset
176 -- Set to True when Entity has been initialized
kono
parents:
diff changeset
177 end record;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 end Xref_Lib;