OSDN Git Service

New Language: Ada
[pf3gnuchains/gcc-fork.git] / gcc / ada / sinput.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               S I N P U T                                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.69 $
10 --                                                                          --
11 --          Copyright (C) 1992-2001 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 -- As a special exception,  if other files  instantiate  generics from this --
25 -- unit, or you link  this unit with other files  to produce an executable, --
26 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
27 -- covered  by the  GNU  General  Public  License.  This exception does not --
28 -- however invalidate  any other reasons why  the executable file  might be --
29 -- covered by the  GNU Public License.                                      --
30 --                                                                          --
31 -- GNAT was originally developed  by the GNAT team at  New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 --                                                                          --
34 ------------------------------------------------------------------------------
35
36 --  This package contains the input routines used for reading the
37 --  input source file. The actual I/O routines are in OS_Interface,
38 --  with this module containing only the system independent processing.
39
40 --  General Note: throughout the compiler, we use the term line or source
41 --  line to refer to a physical line in the source, terminated by the end of
42 --  physical line sequence. See Skip_Line_Terminators procedure for a full
43 --  description of the difference between logical and physical lines.
44
45 with Alloc;
46 with Casing; use Casing;
47 with Table;
48 with Types;  use Types;
49
50 package Sinput is
51
52    ----------------------------
53    -- Source License Control --
54    ----------------------------
55
56    --  The following type indicates the license state of a source if it
57    --  is known.
58
59    type License_Type is
60      (Unknown,
61       --  Licensing status of this source unit is unknown
62
63       Restricted,
64       --  This is a non-GPL'ed unit that is restricted from depending
65       --  on GPL'ed units (e.g. proprietary code is in this category)
66
67       GPL,
68       --  This file is licensed under the unmodified GPL. It is not allowed
69       --  to depend on Non_GPL units, and Non_GPL units may not depend on
70       --  this source unit.
71
72       Modified_GPL,
73       --  This file is licensed under the GNAT modified GPL (see header of
74       --  This file for wording of the modification). It may depend on other
75       --  Modified_GPL units or on unrestricted units.
76
77       Unrestricted);
78       --  The license on this file is permitted to depend on any other
79       --  units, or have other units depend on it, without violating the
80       --  license of this unit. Examples are public domain units, and
81       --  units defined in the RM).
82
83    --  The above license status is checked when the appropriate check is
84    --  activated and one source depends on another, and the licensing state
85    --  of both files is known:
86
87    --  The prohibited combinations are:
88
89    --    Restricted file may not depend on GPL file
90
91    --    GPL file may not depend on Restricted file
92
93    --    Modified GPL file may not depend on Restricted file
94    --    Modified_GPL file may not depend on GPL file
95
96    --  The reason for the last restriction here is that a client depending
97    --  on a modified GPL file must be sure that the license condition is
98    --  correct considered transitively.
99
100    --  The licensing status is determined either by the presence of a
101    --  specific pragma License, or by scanning the header for a predefined
102    --  file, or any file if compiling in -gnatg mode.
103
104    -----------------------
105    -- Source File Table --
106    -----------------------
107
108    --  The source file table has an entry for each source file read in for
109    --  this run of the compiler. This table is (default) initialized when
110    --  the compiler is loaded, and simply accumulates entries as compilation
111    --  proceeds and the Sinput.L.Load_Source_File procedure is called to load
112    --  required source files.
113
114    --  Virtual entries are also created for generic templates when they are
115    --  instantiated, as described in a separate section later on.
116
117    --  In the case where there are multiple main units (e.g. in the case of
118    --  the cross-reference tool), this table is not reset between these units,
119    --  so that a given source file is only read once if it is used by two
120    --  separate main units.
121
122    --  The entries in the table are accessed using a Source_File_Index that
123    --  ranges from 1 to Last_Source_File. Each entry has the following fields
124
125    --  Note that entry 1 is always for system.ads (see Targparm for details
126    --  of why we always read this source file first), and we have defined a
127    --  constant Types.System_Source_File_Index as 1 to reflect this fact.
128
129    --  File_Name : File_Name_Type
130    --    Name of the source file (simple name with no directory information).
131    --    Set by Sinput.L.Load_Source_File and cannot be subequently changed.
132
133    --  Full_File_Name : File_Name_Type
134    --    Full file name (full name with directory info), used for generation
135    --    of error messages, etc. Set by Sinput.L.Load_Source_File and cannot
136    --    be subsequently changed.
137
138    --  Reference_Name : File_Name_Type
139    --    Name to be used for source file references in error messages where
140    --    only the simple name of the file is required. Identical to File_Name
141    --    unless pragma Source_Reference is used to change it. Only processing
142    --    for the Source_Reference pragma circuit may set this field.
143
144    --  Full_Ref_Name : File_Name_Type
145    --    Name to be used for source file references in error messages where
146    --    the full name of the file is required. Identical to Full_File_Name
147    --    unless pragma Source_Reference is used to change it. Only processing
148    --    for the Source_Reference pragma may set this field.
149
150    --  Debug_Source_Name : File_Name_Type
151    --    Name to be used for source file references in debugging information
152    --    where only the simple name of the file is required. Identical to
153    --    Full_Ref_Name unless the -gnatD (debug source file) switch is used.
154    --    Only processing in Sprint that generates this file is permitted to
155    --    set this field.
156
157    --  License : License_Type;
158    --    License status of source file
159
160    --  Num_SRef_Pragmas : Nat;
161    --    Number of source reference pragmas present in source file
162
163    --  First_Mapped_Line : Logical_Line_Number;
164    --    This field stores logical line number of the first line in the
165    --    file that is not a Source_Reference pragma. If no source reference
166    --    pragmas are used, then the value is set to No_Line_Number.
167
168    --  Source_Text : Source_Buffer_Ptr
169    --    Text of source file. Note that every source file has a distinct set
170    --    of non-overlapping logical bounds, so it is possible to determine
171    --    which file is referenced from a given subscript (Source_Ptr) value.
172    --    Set by Sinput.L.Load_Source_File and cannot be subsequently changed.
173
174    --  Source_First : Source_Ptr;
175    --    Subscript of first character in Source_Text. Note that this cannot
176    --    be obtained as Source_Text'First, because we use virtual origin
177    --    addressing. Set by Sinput.L procedures when the entry is first
178    --    created and never subsequently changed.
179
180    --  Source_Last : Source_Ptr;
181    --    Subscript of last character in Source_Text. Note that this cannot
182    --    be obtained as Source_Text'Last, because we use virtual origin
183    --    addressing, so this value is always Source_Ptr'Last. Set by
184    --    Sinput.L procedures when the entry is first created and never
185    --    subsequently changed.
186
187    --  Time_Stamp : Time_Stamp_Type;
188    --    Time stamp of the source file. Set by Sinput.L.Load_Source_File,
189    --    and cannot be subsequently changed.
190
191    --  Source_Checksum : Word;
192    --    Computed checksum for contents of source file. See separate section
193    --    later on in this spec for a description of the checksum algorithm.
194
195    --  Last_Source_Line : Physical_Line_Number;
196    --    Physical line number of last source line. Whlie a file is being
197    --    read, this refers to the last line scanned. Once a file has been
198    --    completely scanned, it is the number of the last line in the file,
199    --    and hence also gives the number of source lines in the file.
200
201    --  Keyword_Casing : Casing_Type;
202    --    Casing style used in file for keyword casing. This is initialized
203    --    to Unknown, and then set from the first occurrence of a keyword.
204    --    This value is used only for formatting of error messages.
205
206    --  Identifier_Casing : Casing_Type;
207    --    Casing style used in file for identifier casing. This is initialized
208    --    to Unknown, and then set from an identifier in the program as soon as
209    --    one is found whose casing is sufficiently clear to make a decision.
210    --    This value is used for formatting of error messages, and also is used
211    --    in the detection of keywords misused as identifiers.
212
213    --  Instantiation : Source_Ptr;
214    --    Source file location of the instantiation if this source file entry
215    --    represents a generic instantiation. Set to No_Location for the case
216    --    of a normal non-instantiation entry. See section below for details.
217    --    This field is read-only for clients.
218
219    --  Template : Source_File_Index;
220    --    Source file index of the source file containing the template if this
221    --    is a generic instantiation. Set to No_Source_File for the normal case
222    --    of a non-instantiation entry. See Sinput-L for details. This field is
223    --    read-only for clients.
224
225    --  The source file table is accessed by clients using the following
226    --  subprogram interface:
227
228    subtype SFI is Source_File_Index;
229
230    function Debug_Source_Name (S : SFI) return File_Name_Type;
231    function File_Name         (S : SFI) return File_Name_Type;
232    function First_Mapped_Line (S : SFI) return Logical_Line_Number;
233    function Full_File_Name    (S : SFI) return File_Name_Type;
234    function Full_Ref_Name     (S : SFI) return File_Name_Type;
235    function Identifier_Casing (S : SFI) return Casing_Type;
236    function Instantiation     (S : SFI) return Source_Ptr;
237    function Keyword_Casing    (S : SFI) return Casing_Type;
238    function Last_Source_Line  (S : SFI) return Physical_Line_Number;
239    function License           (S : SFI) return License_Type;
240    function Num_SRef_Pragmas  (S : SFI) return Nat;
241    function Reference_Name    (S : SFI) return File_Name_Type;
242    function Source_Checksum   (S : SFI) return Word;
243    function Source_First      (S : SFI) return Source_Ptr;
244    function Source_Last       (S : SFI) return Source_Ptr;
245    function Source_Text       (S : SFI) return Source_Buffer_Ptr;
246    function Template          (S : SFI) return Source_File_Index;
247    function Time_Stamp        (S : SFI) return Time_Stamp_Type;
248
249    procedure Set_Keyword_Casing    (S : SFI; C : Casing_Type);
250    procedure Set_Identifier_Casing (S : SFI; C : Casing_Type);
251    procedure Set_License           (S : SFI; L : License_Type);
252
253    function Last_Source_File return Source_File_Index;
254    --  Index of last source file table entry
255
256    function Num_Source_Files return Nat;
257    --  Number of source file table entries
258
259    procedure Initialize;
260    --  Initialize internal tables
261
262    procedure Lock;
263    --  Lock internal tables
264
265    Main_Source_File : Source_File_Index;
266    --  This is set to the source file index of the main unit
267
268    -----------------------
269    -- Checksum Handling --
270    -----------------------
271
272    --  As a source file is scanned, a checksum is computed by taking all the
273    --  non-blank characters in the file, excluding comment characters, the
274    --  minus-minus sequence starting a comment, and all control characters
275    --  except ESC.
276
277    --  These characters are used to compute a 31-bit checksum which is stored
278    --  in the variable Scans.Checksum, as follows:
279
280    --    If a character, C, is not part of a wide character sequence, then
281    --    either the character itself, or its lower case equivalent if it
282    --    is a letter outside a string literal is used in the computation:
283
284    --      Checksum := Checksum + Checksum + Character'Pos (C);
285    --      if Checksum > 16#8000_0000# then
286    --         Checksum := (Checksum + 1) and 16#7FFF_FFFF#;
287    --      end if;
288
289    --    For a wide character sequence, the checksum is computed using the
290    --    corresponding character code value C, as follows:
291
292    --      Checksum := Checksum + Checksum + Char_Code'Pos (C);
293    --      if Checksum > 16#8000_0000# then
294    --         Checksum := (Checksum + 1) and 16#7FFF_FFFF#;
295    --      end if;
296
297    --  This algorithm ensures that the checksum includes all semantically
298    --  significant aspects of the program represented by the source file,
299    --  but is insensitive to layout, presence or contents of comments, wide
300    --  character representation method, or casing conventions outside strings.
301
302    --  Scans.Checksum is initialized to zero at the start of scanning a file,
303    --  and copied into the Source_Checksum field of the file table entry when
304    --  the end of file is encountered.
305
306    -------------------------------------
307    -- Handling Generic Instantiations --
308    -------------------------------------
309
310    --  As described in Sem_Ch12, a generic instantiation involves making a
311    --  copy of the tree of the generic template. The source locations in
312    --  this tree directly reference the source of the template. However it
313    --  is also possible to find the location of the instantiation.
314
315    --  This is achieved as follows. When an instantiation occurs, a new entry
316    --  is made in the source file table. This entry points to the same source
317    --  text, i.e. the file that contains the instantiation, but has a distinct
318    --  set of Source_Ptr index values. The separate range of Sloc values avoids
319    --  confusion, and means that the Sloc values can still be used to uniquely
320    --  identify the source file table entry. It is possible for both entries
321    --  to point to the same text, because of the virtual origin pointers used
322    --  in the source table.
323
324    --  The Instantiation field of this source file index entry, usually set
325    --  to No_Source_File, instead contains the Sloc of the instantiation. In
326    --  the case of nested instantiations, this Sloc may itself refer to an
327    --  instantiation, so the complete chain can be traced.
328
329    --  Two routines are used to build these special entries in the source
330    --  file table. Create_Instantiation_Source is first called to build
331    --  the virtual source table entry for the instantiation, and then the
332    --  Sloc values in the copy are adjusted using Adjust_Instantiation_Sloc.
333    --  See child unit Sinput.L for details on these two routines.
334
335    -----------------
336    -- Global Data --
337    -----------------
338
339    Current_Source_File : Source_File_Index;
340    --  Source_File table index of source file currently being scanned
341
342    Current_Source_Unit : Unit_Number_Type;
343    --  Unit number of source file currently being scanned. The special value
344    --  of No_Unit indicates that the configuration pragma file is currently
345    --  being scanned (this has no entry in the unit table).
346
347    Source_gnat_adc : Source_File_Index := No_Source_File;
348    --  This is set if a gnat.adc file is present to reference this file
349
350    Source : Source_Buffer_Ptr;
351    --  Current source (copy of Source_File.Table (Current_Source_Unit).Source)
352
353    Internal_Source : aliased Source_Buffer (1 .. 81);
354    --  This buffer is used internally in the compiler when the lexical analyzer
355    --  is used to scan a string from within the compiler. The procedure is to
356    --  establish Internal_Source_Ptr as the value of Source, set the string to
357    --  be scanned, appropriately terminated, in this buffer, and set Scan_Ptr
358    --  to point to the start of the buffer. It is a fatal error if the scanner
359    --  signals an error while scanning a token in this internal buffer.
360
361    Internal_Source_Ptr : constant Source_Buffer_Ptr :=
362                            Internal_Source'Unrestricted_Access;
363    --  Pointer to internal source buffer
364
365    -----------------
366    -- Subprograms --
367    -----------------
368
369    procedure Backup_Line (P : in out Source_Ptr);
370    --  Back up the argument pointer to the start of the previous line. On
371    --  entry, P points to the start of a physical line in the source buffer.
372    --  On return, P is updated to point to the start of the previous line.
373    --  The caller has checked that a Line_Terminator character precedes P so
374    --  that there definitely is a previous line in the source buffer.
375
376    procedure Build_Location_String (Loc : Source_Ptr);
377    --  This function builds a string literal of the form "name:line",
378    --  where name is the file name corresponding to Loc, and line is
379    --  the line number. In the event that instantiations are involved,
380    --  additional suffixes of the same form are appended after the
381    --  separating string " instantiated at ". The returned string is
382    --  stored in Name_Buffer, terminated by ASCII.Nul, with Name_Length
383    --  indicating the length not including the terminating Nul.
384
385    function Get_Column_Number (P : Source_Ptr) return Column_Number;
386    --  The ones-origin column number of the specified Source_Ptr value is
387    --  determined and returned. Tab characters if present are assumed to
388    --  represent the standard 1,9,17.. spacing pattern.
389
390    function Get_Logical_Line_Number
391      (P    : Source_Ptr)
392       return Logical_Line_Number;
393    --  The line number of the specified source position is obtained by
394    --  doing a binary search on the source positions in the lines table
395    --  for the unit containing the given source position. The returned
396    --  value is the logical line number, already adjusted for the effect
397    --  of source reference pragmas. If P refers to the line of a source
398    --  reference pragma itself, then No_Line is returned. If no source
399    --  reference pragmas have been encountered, the value returned is
400    --  the same as the physical line number.
401
402    function Get_Physical_Line_Number
403      (P    : Source_Ptr)
404       return Physical_Line_Number;
405    --  The line number of the specified source position is obtained by
406    --  doing a binary search on the source positions in the lines table
407    --  for the unit containing the given source position. The returned
408    --  value is the physical line number in the source being compiled.
409
410    function Get_Source_File_Index (S : Source_Ptr) return Source_File_Index;
411    --  Return file table index of file identified by given source pointer
412    --  value. This call must always succeed, since any valid source pointer
413    --  value belongs to some previously loaded source file.
414
415    function Instantiation_Depth (S : Source_Ptr) return Nat;
416    --  Determine instantiation depth for given Sloc value. A value of
417    --  zero means that the given Sloc is not in an instantiation.
418
419    function Line_Start (P : Source_Ptr) return Source_Ptr;
420    --  Finds the source position of the start of the line containing the
421    --  given source location.
422
423    function Line_Start
424      (L    : Physical_Line_Number;
425       S    : Source_File_Index)
426       return Source_Ptr;
427    --  Finds the source position of the start of the given line in the
428    --  given source file, using a physical line number to identify the line.
429
430    function Num_Source_Lines (S : Source_File_Index) return Nat;
431    --  Returns the number of source lines (this is equivalent to reading
432    --  the value of Last_Source_Line, but returns Nat rathern than a
433    --  physical line number.
434
435    procedure Register_Source_Ref_Pragma
436      (File_Name          : Name_Id;
437       Stripped_File_Name : Name_Id;
438       Mapped_Line        : Nat;
439       Line_After_Pragma  : Physical_Line_Number);
440    --  Register a source reference pragma, the parameter File_Name is the
441    --  file name from the pragma, and Stripped_File_Name is this name with
442    --  the directory information stripped. Both these parameters are set
443    --  to No_Name if no file name parameter was given in the pragma.
444    --  (which can only happen for the second and subsequent pragmas).
445    --  Mapped_Line is the line number parameter from the pragma, and
446    --  Line_After_Pragma is the physical line number of the line that
447    --  follows the line containing the Source_Reference pragma.
448
449    function Original_Location (S : Source_Ptr) return Source_Ptr;
450    --  Given a source pointer S, returns the corresponding source pointer
451    --  value ignoring instantiation copies. For locations that do not
452    --  correspond to instantiation copies of templates, the argument is
453    --  returned unchanged. For locations that do correspond to copies of
454    --  templates from instantiations, the location within the original
455    --  template is returned. This is useful in canonicalizing locations.
456
457    function Instantiation_Location (S : Source_Ptr) return Source_Ptr;
458    pragma Inline (Instantiation_Location);
459    --  Given a source pointer S, returns the corresponding source pointer
460    --  value of the instantiation if this location is within an instance.
461    --  If S is not within an instance, then this returns No_Location.
462
463    function Top_Level_Location (S : Source_Ptr) return Source_Ptr;
464    --  Given a source pointer S, returns the argument unchanged if it is
465    --  not in an instantiation. If S is in an instantiation, then it returns
466    --  the location of the top level instantiation, i.e. the outer level
467    --  instantiation in the nested case.
468
469    function Physical_To_Logical
470      (Line : Physical_Line_Number;
471       S    : Source_File_Index)
472       return Logical_Line_Number;
473    --  Given a physical line number in source file whose source index is S,
474    --  return the corresponding logical line number. If the physical line
475    --  number is one containing a Source_Reference pragma, the result will
476    --  be No_Line_Number.
477
478    procedure Skip_Line_Terminators
479      (P        : in out Source_Ptr;
480       Physical : out Boolean);
481    --  On entry, Source (P) points to the line terminator character that
482    --  terminates a line. The result set in P is the location of the first
483    --  character of the following line (after skipping the sequence of line
484    --  terminator characters terminating the current line). In addition, if
485    --  the terminator sequence ends a physical line (the definition of what
486    --  constitutes a physical line is embodied in the implementation of this
487    --  function), and it is the first time this sequence is encountered, then
488    --  an entry is made in the lines table to record the location for further
489    --  use by functions such as Get_Line_Number. Physical is set to True if
490    --  the line terminator was the end of a physical line.
491
492    function Source_Offset (S : Source_Ptr) return Nat;
493    --  Returns the zero-origin offset of the given source location from the
494    --  start of its corresponding unit. This is used for creating canonical
495    --  names in some situations.
496
497    procedure Write_Location (P : Source_Ptr);
498    --  Writes out a string of the form fff:nn:cc, where fff, nn, cc are the
499    --  file name, line number and column corresponding to the given source
500    --  location. No_Location and Standard_Location appear as the strings
501    --  <no location> and <standard location>. If the location is within an
502    --  instantiation, then the instance location is appended, enclosed in
503    --  square brackets (which can nest if necessary). Note that this routine
504    --  is used only for internal compiler debugging output purposes (which
505    --  is why the somewhat cryptic use of brackets is acceptable).
506
507    procedure wl (P : Source_Ptr);
508    --  Equivalent to Write_Location (P); Write_Eol; for calls from GDB
509
510    procedure Write_Time_Stamp (S : Source_File_Index);
511    --  Writes time stamp of specified file in YY-MM-DD HH:MM.SS format
512
513    procedure Tree_Write;
514    --  Writes out internal tables to current tree file using Tree_Write
515
516    procedure Tree_Read;
517    --  Initializes internal tables from current tree file using Tree_Read
518
519 private
520    pragma Inline (File_Name);
521    pragma Inline (First_Mapped_Line);
522    pragma Inline (Full_File_Name);
523    pragma Inline (Identifier_Casing);
524    pragma Inline (Instantiation);
525    pragma Inline (Keyword_Casing);
526    pragma Inline (Last_Source_Line);
527    pragma Inline (Last_Source_File);
528    pragma Inline (License);
529    pragma Inline (Num_SRef_Pragmas);
530    pragma Inline (Num_Source_Files);
531    pragma Inline (Num_Source_Lines);
532    pragma Inline (Reference_Name);
533    pragma Inline (Set_Keyword_Casing);
534    pragma Inline (Set_Identifier_Casing);
535    pragma Inline (Source_First);
536    pragma Inline (Source_Last);
537    pragma Inline (Source_Text);
538    pragma Inline (Template);
539    pragma Inline (Time_Stamp);
540
541    -------------------------
542    -- Source_Lines Tables --
543    -------------------------
544
545    type Lines_Table_Type is
546      array (Physical_Line_Number) of Source_Ptr;
547    --  Type used for lines table. The entries are indexed by physical line
548    --  numbers. The values are the starting Source_Ptr values for the start
549    --  of the corresponding physical line. Note that we make this a bogus
550    --  big array, sized as required, so that we avoid the use of fat pointers.
551
552    type Lines_Table_Ptr is access all Lines_Table_Type;
553    --  Type used for pointers to line tables
554
555    type Logical_Lines_Table_Type is
556      array (Physical_Line_Number) of Logical_Line_Number;
557    --  Type used for logical lines table. This table is used if a source
558    --  reference pragma is present. It is indexed by physical line numbers,
559    --  and contains the corresponding logical line numbers. An entry that
560    --  corresponds to a source reference pragma is set to No_Line_Number.
561    --  Note that we make this a bogus big array, sized as required, so that
562    --  we avoid the use of fat pointers.
563
564    type Logical_Lines_Table_Ptr is access all Logical_Lines_Table_Type;
565    --  Type used for pointers to logical line tables.
566
567    -----------------------
568    -- Source_File Table --
569    -----------------------
570
571    --  See earlier descriptions for meanings of public fields
572
573    type Source_File_Record is record
574
575       File_Name         : File_Name_Type;
576       Reference_Name    : File_Name_Type;
577       Debug_Source_Name : File_Name_Type;
578       Full_File_Name    : File_Name_Type;
579       Full_Ref_Name     : File_Name_Type;
580       License           : License_Type;
581       Num_SRef_Pragmas  : Nat;
582       First_Mapped_Line : Logical_Line_Number;
583       Source_Text       : Source_Buffer_Ptr;
584       Source_First      : Source_Ptr;
585       Source_Last       : Source_Ptr;
586       Time_Stamp        : Time_Stamp_Type;
587       Source_Checksum   : Word;
588       Last_Source_Line  : Physical_Line_Number;
589       Keyword_Casing    : Casing_Type;
590       Identifier_Casing : Casing_Type;
591       Instantiation     : Source_Ptr;
592       Template          : Source_File_Index;
593
594       --  The following fields are for internal use only (i.e. only in the
595       --  body of Sinput or its children, with no direct access by clients).
596
597       Sloc_Adjust : Source_Ptr;
598       --  A value to be added to Sloc values for this file to reference the
599       --  corresponding lines table. This is zero for the non-instantiation
600       --  case, and set so that the adition references the ultimate template
601       --  for the instantiation case. See Sinput-L for further details.
602
603       Lines_Table : Lines_Table_Ptr;
604       --  Pointer to lines table for this source. Updated as additional
605       --  lines are accessed using the Skip_Line_Terminators procedure.
606       --  Note: the lines table for an instantiation entry refers to the
607       --  original line numbers of the template see Sinput-L for details.
608
609       Logical_Lines_Table : Logical_Lines_Table_Ptr;
610       --  Pointer to logical lines table for this source. Non-null only if
611       --  a source reference pragma has been processed. Updated as lines
612       --  are accessed using the Skip_Line_Terminators procedure.
613
614       Lines_Table_Max : Physical_Line_Number;
615       --  Maximum subscript values for currently allocated Lines_Table
616       --  and (if present) the allocated Logical_Lines_Table. The value
617       --  Max_Source_Line gives the maximum used value, this gives the
618       --  maximum allocated value.
619
620    end record;
621
622    package Source_File is new Table.Table (
623      Table_Component_Type => Source_File_Record,
624      Table_Index_Type     => Source_File_Index,
625      Table_Low_Bound      => 1,
626      Table_Initial        => Alloc.Source_File_Initial,
627      Table_Increment      => Alloc.Source_File_Increment,
628      Table_Name           => "Source_File");
629
630    -----------------
631    -- Subprograms --
632    -----------------
633
634    procedure Alloc_Line_Tables
635      (S       : in out Source_File_Record;
636       New_Max : Nat);
637    --  Allocate or reallocate the lines table for the given source file so
638    --  that it can accomodate at least New_Max lines. Also allocates or
639    --  reallocates logical lines table if source ref pragmas are present.
640
641    procedure Add_Line_Tables_Entry
642      (S : in out Source_File_Record;
643       P : Source_Ptr);
644    --  Increment line table size by one (reallocating the lines table if
645    --  needed) and set the new entry to contain the value P. Also bumps
646    --  the Source_Line_Count field. If source reference pragmas are
647    --  present, also increments logical lines table size by one, and
648    --  sets new entry.
649
650 end Sinput;