1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- This child package contains the routines used to actually load a source
29 -- file and create entries in the source file table. It also contains the
30 -- routines to create virtual entries for instantiations. This is separated
31 -- off into a child package to avoid a dependence of Sinput on Osint which
32 -- would cause trouble in the tree read/write routines.
34 with Types
; use Types
;
38 -------------------------------------------
39 -- Subprograms for Loading Source Files --
40 -------------------------------------------
42 function Load_Source_File
(N
: File_Name_Type
) return Source_File_Index
;
43 -- Given a source file name, returns the index of the corresponding entry
44 -- in the source file table. If the file is not currently loaded, then
45 -- this is the call that causes the source file to be read and an entry
46 -- made in the table. A new entry in the table has the file name and time
47 -- stamp entries set and the Casing entries set to Unknown. Version is set
48 -- to all blanks, and the lines table is initialized but only the first
49 -- entry is set (and Last_Line is set to 1). If the given source file
50 -- cannot be opened, then the value returned is No_Source_File.
52 function Load_Config_File
(N
: File_Name_Type
) return Source_File_Index
;
53 -- Similar to Load_Source_File, except that the file name is always
54 -- interpreted in the context of the current working directory.
56 procedure Complete_Source_File_Entry
;
57 -- Called on completing the parsing of a source file. This call completes
58 -- the source file table entry for the current source file.
60 function Source_File_Is_Subunit
(X
: Source_File_Index
) return Boolean;
61 -- This function determines if a source file represents a subunit. It
62 -- works by scanning for the first compilation unit token, and returning
63 -- True if it is the token SEPARATE. It will return False otherwise,
64 -- meaning that the file cannot possibly be a legal subunit. This
65 -- function does NOT do a complete parse of the file, or build a
66 -- tree. It is used in the main driver in the check for bad bodies.
68 -------------------------------------------------
69 -- Subprograms for Dealing With Instantiations --
70 -------------------------------------------------
72 type Sloc_Adjustment
is private;
73 -- Type returned by Create_Instantiation_Source for use in subsequent
74 -- calls to Adjust_Instantiation_Sloc.
76 procedure Create_Instantiation_Source
77 (Inst_Node
: Entity_Id
;
78 Template_Id
: Entity_Id
;
79 A
: out Sloc_Adjustment
);
80 -- This procedure creates the source table entry for an instantiation.
81 -- Inst_Node is the instantiation node, and Template_Id is the defining
82 -- identifier of the generic declaration or body unit as appropriate.
83 -- A is set to an adjustment factor to be used in subsequent calls to
84 -- Adjust_Instantiation_Sloc.
86 procedure Adjust_Instantiation_Sloc
(N
: Node_Id
; A
: Sloc_Adjustment
);
87 -- The instantiation tree is created by copying the tree of the generic
88 -- template (including the original Sloc values), and then applying
89 -- Adjust_Instantiation_Sloc to each copied node to adjust the Sloc
90 -- to reference the source entry for the instantiation.
94 type Sloc_Adjustment
is record
96 -- Adjustment factor. To be added to source location values in the
97 -- source table entry for the template to get corresponding sloc
98 -- values for the instantiation image of the template. This is not
99 -- really a Source_Ptr value, but rather an offset, but it is more
100 -- convenient to represent it as a Source_Ptr value and this is a
101 -- private type anyway.
104 -- Lo and hi values to which adjustment factor can legitimately
105 -- be applied, used to ensure that no incorrect adjustments are
106 -- made. Really it is a bug if anyone ever tries to adjust outside
107 -- this range, but since we are only doing this anyway for getting
108 -- better error messages, it is not critical