OSDN Git Service

* function.h (incomming_args): Break out of struct function.
[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-2007, 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 3,  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 COPYING3.  If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license.          --
20 --                                                                          --
21 -- GNAT was originally developed  by the GNAT team at  New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
23 --                                                                          --
24 ------------------------------------------------------------------------------
25
26 with Prj.Err;
27 with Sinput.C;
28
29 package body Sinput.P is
30
31    First : Boolean := True;
32    --  Flag used when Load_Project_File is called the first time,
33    --  to set Main_Source_File.
34    --  The flag is reset to False at the first call to Load_Project_File.
35    --  Calling Reset_First sets it back to True.
36
37    -----------------------
38    -- Load_Project_File --
39    -----------------------
40
41    function Load_Project_File (Path : String) return Source_File_Index is
42       X    : Source_File_Index;
43
44    begin
45       X := Sinput.C.Load_File (Path);
46
47       if First then
48          Main_Source_File := X;
49          First := False;
50       end if;
51
52       return X;
53    end Load_Project_File;
54
55    -----------------
56    -- Reset_First --
57    -----------------
58
59    procedure Reset_First is
60    begin
61       First := True;
62    end Reset_First;
63
64    --------------------------------
65    -- Restore_Project_Scan_State --
66    --------------------------------
67
68    procedure Restore_Project_Scan_State
69      (Saved_State : Saved_Project_Scan_State)
70    is
71    begin
72       Restore_Scan_State (Saved_State.Scan_State);
73       Source              := Saved_State.Source;
74       Current_Source_File := Saved_State.Current_Source_File;
75    end Restore_Project_Scan_State;
76
77    -----------------------------
78    -- Save_Project_Scan_State --
79    -----------------------------
80
81    procedure Save_Project_Scan_State
82      (Saved_State : out Saved_Project_Scan_State)
83    is
84    begin
85       Save_Scan_State (Saved_State.Scan_State);
86       Saved_State.Source              := Source;
87       Saved_State.Current_Source_File := Current_Source_File;
88    end Save_Project_Scan_State;
89
90    ----------------------------
91    -- Source_File_Is_Subunit --
92    ----------------------------
93
94    function Source_File_Is_Subunit (X : Source_File_Index) return Boolean is
95    begin
96       Prj.Err.Scanner.Initialize_Scanner (X);
97
98       --  We scan past junk to the first interesting compilation unit
99       --  token, to see if it is SEPARATE. We ignore WITH keywords during
100       --  this and also PRIVATE. The reason for ignoring PRIVATE is that
101       --  it handles some error situations, and also to handle PRIVATE WITH
102       --  in Ada 2005 mode.
103
104       while Token = Tok_With
105         or else Token = Tok_Private
106         or else (Token not in Token_Class_Cunit and then Token /= Tok_EOF)
107       loop
108          Prj.Err.Scanner.Scan;
109       end loop;
110
111       return Token = Tok_Separate;
112    end Source_File_Is_Subunit;
113
114 end Sinput.P;