OSDN Git Service

* sysdep.c: Problem discovered during IA64 VMS port.
[pf3gnuchains/gcc-fork.git] / gcc / ada / sinput-p.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             S I N P U T . P                              --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2002 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,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, 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 ------------------------------------------------------------------------------
26
27 with Prj;         use Prj;
28 with Prj.Err;
29 with Sinput.C;
30
31 package body Sinput.P is
32
33    First : Boolean := True;
34    --  Flag used when Load_Project_File is called the first time,
35    --  to set Main_Source_File.
36    --  The flag is reset to False at the first call to Load_Project_File
37
38    -----------------------
39    -- Load_Project_File --
40    -----------------------
41
42    function Load_Project_File (Path : String) return Source_File_Index is
43       X    : Source_File_Index;
44
45    begin
46       X := Sinput.C.Load_File (Path);
47
48       if First then
49          Main_Source_File := X;
50          First := False;
51       end if;
52
53       return X;
54    end Load_Project_File;
55
56    --------------------------------
57    -- Restore_Project_Scan_State --
58    --------------------------------
59
60    procedure Restore_Project_Scan_State
61      (Saved_State : in Saved_Project_Scan_State)
62    is
63    begin
64       Restore_Scan_State (Saved_State.Scan_State);
65       Source              := Saved_State.Source;
66       Current_Source_File := Saved_State.Current_Source_File;
67    end Restore_Project_Scan_State;
68
69    -----------------------------
70    -- Save_Project_Scan_State --
71    -----------------------------
72
73    procedure Save_Project_Scan_State
74      (Saved_State : out Saved_Project_Scan_State)
75    is
76    begin
77       Save_Scan_State (Saved_State.Scan_State);
78       Saved_State.Source              := Source;
79       Saved_State.Current_Source_File := Current_Source_File;
80    end Save_Project_Scan_State;
81
82    ----------------------------
83    -- Source_File_Is_Subunit --
84    ----------------------------
85
86    function Source_File_Is_Subunit (X : Source_File_Index) return Boolean is
87    begin
88       Prj.Err.Scanner.Initialize_Scanner (No_Unit, X);
89
90       --  We scan past junk to the first interesting compilation unit
91       --  token, to see if it is SEPARATE. We ignore WITH keywords during
92       --  this and also PRIVATE. The reason for ignoring PRIVATE is that
93       --  it handles some error situations, and also it is possible that
94       --  a PRIVATE WITH feature might be approved some time in the future.
95
96       while Token = Tok_With
97         or else Token = Tok_Private
98         or else (Token not in Token_Class_Cunit and then Token /= Tok_EOF)
99       loop
100          Scan;
101       end loop;
102
103       return Token = Tok_Separate;
104    end Source_File_Is_Subunit;
105
106 end Sinput.P;