File: asis_ul-source_table-processing-asis_processing.adb

package info (click to toggle)
asis 2014-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,064 kB
  • ctags: 37
  • sloc: ada: 146,541; makefile: 364; sh: 50; xml: 48; csh: 10
file content (82 lines) | stat: -rw-r--r-- 3,775 bytes parent folder | download | duplicates (2)
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
------------------------------------------------------------------------------
--                                                                          --
--                            GNATPP COMPONENTS                             --
--                                                                          --
--     A S I S _ U L . S O U R C E _ T A B L E . P R O C E S S I N G .      --
--                      A S I S _ P R O C E S S I N G                       --
--                                                                          --
--              (adapted for gnatpp from ASIS Utility Library)              --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--                    Copyright (C) 2013-2014, AdaCore                      --
--                                                                          --
-- GNATPP is free software; you can redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion.  GNATPP is  distributed in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABI- --
-- LITY 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 GNAT; see file COPYING. If not, --
-- write to the Free Software Foundation,  51 Franklin Street, Fifth Floor, --
-- Boston,                                                                  --
--                                                                          --
-- GNATPP is maintained by AdaCore (http://www.adacore.com)                 --
--                                                                          --
------------------------------------------------------------------------------

pragma Ada_2012;

with Ada.Directories;       use Ada.Directories;
with Ada.Text_IO;           use Ada.Text_IO;

with Gnat2xml.Xml;          use Gnat2xml;

separate (ASIS_UL.Source_Table.Processing)
procedure ASIS_Processing (CU : Asis.Compilation_Unit; SF : SF_Id) is

   procedure Process (XML_File : File_Access);
   --  Helper routine that does all the work once the output file is opened

   procedure Process (XML_File : File_Access) is
      The_Node_Information : constant Xml.Info_Node :=
        (XML_File  => XML_File,
         Krunch    => False,
         Xml_Style => False,
         Verbose   => Verbose_Mode);
   begin
      Xml.Start_Representation (The_Node_Information);
      Xml.Process_Unit (CU, The_Node_Information);
   end Process;

--  Start of processing for ASIS_Processing

begin
   Set_Current_SF (SF);

   if Out_Dir = null then
      Process (Standard_Output); -- pipe output to standard output
   else
      declare
         XML_Name : constant String :=
           Compose
             (Containing_Directory => Out_Dir.all,
              Name                 => Short_Source_Name (SF),
              Extension            => "xml");
         XML_Out_File : aliased File_Type;
      begin
         if Verbose_Mode then
            Put_Line ("creating " & XML_Name);
         elsif Debug_Flag_V then
            Put_Line ("creating " & Short_Source_Name (SF) & ".xml");
         end if;

         Create (XML_Out_File, Out_File, Name => XML_Name);
         Process (XML_Out_File'Unchecked_Access);
         Close (XML_Out_File);
      end;
   end if;

   Set_Source_Status (SF, Processed);
end ASIS_Processing;