awa_2.4.0_59135a52/dynamo/src/asis/asis-implementation.adb

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
------------------------------------------------------------------------------
--                                                                          --
--                 ASIS-for-GNAT IMPLEMENTATION COMPONENTS                  --
--                                                                          --
--                  A S I S . I M P L E M E N T A T I O N                   --
--                                                                          --
--            Copyright (C) 1995-2007, Free Software Foundation, Inc.       --
--                                                                          --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software Foundation;  either version 2,  or  (at your option)  any later --
-- version. ASIS-for-GNAT is distributed  in the hope  that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General --
-- Public License for more details.  You should have received a copy of the --
-- GNU  General  Public License  distributed with ASIS-for-GNAT; see   file --
-- COPYING.  If not,  write  to the  Free Software Foundation,  51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA.                         --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
-- ASIS-for-GNAT was originally developed  by the ASIS-for-GNAT team at the --
-- Software  Engineering  Laboratory  of  the Swiss  Federal  Institute  of --
-- Technology (LGL-EPFL) in Lausanne,  Switzerland, in cooperation with the --
-- Scientific  Research  Computer  Center of  Moscow State University (SRCC --
-- MSU), Russia,  with funding partially provided  by grants from the Swiss --
-- National  Science  Foundation  and  the  Swiss  Academy  of  Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore                     --
-- (http://www.adaccore.com).                                               --
--                                                                          --
------------------------------------------------------------------------------

with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings;             use Ada.Strings;
with Ada.Strings.Fixed;       use Ada.Strings.Fixed;

with Asis.Errors;             use Asis.Errors;
with Asis.Exceptions;         use Asis.Exceptions;

with A4G.A_Debug;             use A4G.A_Debug;
with A4G.A_Opt;               use A4G.A_Opt;
with A4G.Contt;               use A4G.Contt;
with A4G.Defaults;
with A4G.Vcheck;              use A4G.Vcheck;

with A4G.A_Osint;             use A4G.A_Osint;

with Gnatvsn;
with Opt;

package body Asis.Implementation is

   Package_Name : constant String := "Asis.Implementation.";

   ----------------------
   -- Asis_Implementor --
   ----------------------

   function ASIS_Implementor return Wide_String is
   begin
      return "AdaCore (http://www.adacore.com)";
   end ASIS_Implementor;

   ----------------------------------
   -- ASIS_Implementor_Information --
   ----------------------------------

   function ASIS_Implementor_Information return Wide_String is
   begin
      return
        "Copyright (C) 1995-"                 &
        To_Wide_String (Gnatvsn.Current_Year) &
        ", Free Software Foundation";
   end ASIS_Implementor_Information;

   ------------------------------
   -- ASIS_Implementor_Version --
   ------------------------------

   function ASIS_Implementor_Version return Wide_String is
      GNAT_Version   : constant String   := Gnatvsn.Gnat_Version_String;
      First_Idx      : constant Positive := GNAT_Version'First;
      Last_Idx       :          Positive := GNAT_Version'Last;
      Minus_Detected : Boolean           := False;
   begin

      for J in reverse GNAT_Version'Range loop

         if GNAT_Version (J) = '-' then
            Last_Idx       := J - 1;
            Minus_Detected := True;
            exit;
         end if;

      end loop;

      if Minus_Detected then
         return ASIS_Version & " for GNAT " &
            To_Wide_String (GNAT_Version (First_Idx .. Last_Idx)) & ")";
      else
         return ASIS_Version & " for GNAT " &
            To_Wide_String (GNAT_Version (First_Idx .. Last_Idx));
      end if;

   end ASIS_Implementor_Version;

   ------------------
   -- ASIS_Version --
   ------------------

   function ASIS_Version return Wide_String is
   begin
      return "ASIS 2.0.R";
   end ASIS_Version;

   ---------------
   -- Diagnosis --
   ---------------

   function Diagnosis return Wide_String is
   begin
      --  The ASIS Diagnosis string uses only the first 256 values of
      --  Wide_Character type
      return To_Wide_String (Diagnosis_Buffer (1 .. Diagnosis_Len));
   end Diagnosis;

   --------------
   -- Finalize --
   --------------

   procedure Finalize (Parameters : Wide_String := "") is
      S_Parameters : constant String := Trim (To_String (Parameters), Both);
      --  all the valid actuals for Parametes should contain  only
      --  characters from the first 256 values of Wide_Character type
   begin

      if not A4G.A_Opt.Is_Initialized then
         return;
      end if;

      if Debug_Flag_C    or else
         Debug_Lib_Model or else
         Debug_Mode
      then
         Print_Context_Info;
      end if;

      if S_Parameters'Length > 0 then
         Process_Finalization_Parameters (S_Parameters);
      end if;

      A4G.Contt.Finalize;
      A4G.A_Opt.Set_Off;
      A4G.A_Debug.Set_Off;

      A4G.A_Opt.Is_Initialized := False;

   exception
      when ASIS_Failed =>

         A4G.A_Opt.Set_Off;
         A4G.A_Debug.Set_Off;

         A4G.A_Opt.Is_Initialized := False;

         if Status_Indicator = Unhandled_Exception_Error then
            Add_Call_Information (Outer_Call =>
              Package_Name & "Finalize");
         end if;

         raise;

      when Ex : others =>

         A4G.A_Opt.Set_Off;
         A4G.A_Debug.Set_Off;

         A4G.A_Opt.Is_Initialized := False;

         Report_ASIS_Bug
           (Query_Name  => Package_Name & "Finalize",
            Ex          => Ex);
   end Finalize;

   ----------------
   -- Initialize --
   ----------------

   procedure Initialize (Parameters : Wide_String := "") is
      S_Parameters : constant String := Trim (To_String (Parameters), Both);
      --  all the valid actuals for Parametes should contain  only
      --  characters from the first 256 values of Wide_Character type
   begin
      if A4G.A_Opt.Is_Initialized then
         return;
      end if;

      if not A4G.A_Opt.Was_Initialized_At_Least_Once then
         Opt.Maximum_File_Name_Length := Get_Max_File_Name_Length;
         A4G.A_Opt.Was_Initialized_At_Least_Once := True;
      end if;

      if S_Parameters'Length > 0 then
         Process_Initialization_Parameters (S_Parameters);
      end if;

      A4G.Contt.Initialize;
      A4G.Defaults.Initialize;
      A4G.A_Opt.Is_Initialized := True;

   exception
      when ASIS_Failed =>

         A4G.A_Opt.Set_Off;
         A4G.A_Debug.Set_Off;

         A4G.A_Opt.Is_Initialized := False;

         if Status_Indicator = Unhandled_Exception_Error then
            Add_Call_Information (Outer_Call =>
              Package_Name & "Initialize");
         end if;

         raise;

      when Ex : others =>

         A4G.A_Opt.Set_Off;
         A4G.A_Debug.Set_Off;

         A4G.A_Opt.Is_Initialized := False;

         Report_ASIS_Bug
           (Query_Name  => Package_Name & "Initialize",
            Ex          => Ex);
   end Initialize;

   ------------------
   -- Is_Finalized --
   ------------------

   function Is_Finalized return Boolean is
   begin
      return not A4G.A_Opt.Is_Initialized;
   end Is_Finalized;

   --------------------
   -- Is_Initialized --
   --------------------

   function Is_Initialized return Boolean  is
   begin
      return A4G.A_Opt.Is_Initialized;
   end Is_Initialized;

   ----------------
   -- Set_Status --
   ----------------

   procedure Set_Status
     (Status    : Asis.Errors.Error_Kinds := Asis.Errors.Not_An_Error;
      Diagnosis : Wide_String             := "")
   is
   begin
      A4G.Vcheck.Set_Error_Status (Status    => Status,
                                   Diagnosis => To_String (Diagnosis));
   end Set_Status;

   ------------
   -- Status --
   ------------

   function Status return Asis.Errors.Error_Kinds is
   begin
      return Status_Indicator;
   end Status;

end Asis.Implementation;