2005-12-29 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / ada / sinput-l.ads
blob7a4dda8f4de32b658fcaae97bd3587e17ec73534
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S I N P U T . L --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2005, 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 -- This child package contains the routines used to actually load a source
28 -- file and create entries in the source file table. It also contains the
29 -- routines to create virtual entries for instantiations. This is separated
30 -- off into a child package to avoid a dependence of Sinput on Osint which
31 -- would cause trouble in the tree read/write routines.
33 package Sinput.L is
35 ------------------------------------------
36 -- Subprograms for Loading Source Files --
37 ------------------------------------------
39 function Load_Source_File (N : File_Name_Type) return Source_File_Index;
40 -- Given a source file name, returns the index of the corresponding entry
41 -- in the source file table. If the file is not currently loaded, then
42 -- this is the call that causes the source file to be read and an entry
43 -- made in the table. A new entry in the table has the file name and time
44 -- stamp entries set and the Casing entries set to Unknown. Version is set
45 -- to all blanks, and the lines table is initialized but only the first
46 -- entry is set (and Last_Line is set to 1). If the given source file
47 -- cannot be opened, then the value returned is No_Source_File.
49 function Load_Config_File (N : File_Name_Type) return Source_File_Index;
50 -- Similar to Load_Source_File, except that the file name is always
51 -- interpreted in the context of the current working directory.
52 -- The file is never preprocessed.
54 function Load_Definition_File
55 (N : File_Name_Type) return Source_File_Index;
56 -- Loads preprocessing definition file. Similar to Load_Source_File
57 -- except that this file is not itself preprocessed.
59 function Load_Preprocessing_Data_File
60 (N : File_Name_Type) return Source_File_Index;
61 -- Loads preprocessing data file. Similar to Load_Source_File except
62 -- that this file is not itself preprocessed.
64 procedure Complete_Source_File_Entry;
65 -- Called on completing the parsing of a source file. This call completes
66 -- the source file table entry for the current source file.
68 function Source_File_Is_Subunit (X : Source_File_Index) return Boolean;
69 -- This function determines if a source file represents a subunit. It
70 -- works by scanning for the first compilation unit token, and returning
71 -- True if it is the token SEPARATE. It will return False otherwise,
72 -- meaning that the file cannot possibly be a legal subunit. This
73 -- function does NOT do a complete parse of the file, or build a
74 -- tree. It is used in the main driver in the check for bad bodies.
76 -------------------------------------------------
77 -- Subprograms for Dealing With Instantiations --
78 -------------------------------------------------
80 type Sloc_Adjustment is private;
81 -- Type returned by Create_Instantiation_Source for use in subsequent
82 -- calls to Adjust_Instantiation_Sloc.
84 procedure Create_Instantiation_Source
85 (Inst_Node : Entity_Id;
86 Template_Id : Entity_Id;
87 Inlined_Body : Boolean;
88 A : out Sloc_Adjustment);
89 -- This procedure creates the source table entry for an instantiation.
90 -- Inst_Node is the instantiation node, and Template_Id is the defining
91 -- identifier of the generic declaration or body unit as appropriate.
92 -- A is set to an adjustment factor to be used in subsequent calls to
93 -- Adjust_Instantiation_Sloc. The instantiation mechnaism is also used
94 -- for inlined function and procedure calls. The parameter Inlined_Body
95 -- is set to True in such cases, and False for a generic instantiation.
96 -- This is used for generating error messages that distinguish these
97 -- two cases, otherwise the two cases are handled identically.
99 procedure Adjust_Instantiation_Sloc (N : Node_Id; A : Sloc_Adjustment);
100 -- The instantiation tree is created by copying the tree of the generic
101 -- template (including the original Sloc values), and then applying
102 -- Adjust_Instantiation_Sloc to each copied node to adjust the Sloc
103 -- to reference the source entry for the instantiation.
105 private
107 type Sloc_Adjustment is record
108 Adjust : Source_Ptr;
109 -- Adjustment factor. To be added to source location values in the
110 -- source table entry for the template to get corresponding sloc
111 -- values for the instantiation image of the template. This is not
112 -- really a Source_Ptr value, but rather an offset, but it is more
113 -- convenient to represent it as a Source_Ptr value and this is a
114 -- private type anyway.
116 Lo, Hi : Source_Ptr;
117 -- Lo and hi values to which adjustment factor can legitimately
118 -- be applied, used to ensure that no incorrect adjustments are
119 -- made. Really it is a bug if anyone ever tries to adjust outside
120 -- this range, but since we are only doing this anyway for getting
121 -- better error messages, it is not critical
123 end record;
125 end Sinput.L;