OSDN Git Service

2009-07-22 Eric Botcazou <ebotcazou@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / put_scos.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             P U T _ S C O S                               --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --             Copyright (C) 2009, 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 SCOs; use SCOs;
27
28 procedure Put_SCOs is
29 begin
30    --  Loop through entries in SCO_Unit_Table
31
32    for U in 1 .. SCO_Unit_Table.Last loop
33       declare
34          SUT : SCO_Unit_Table_Entry renames SCO_Unit_Table.Table (U);
35
36          Start : Nat;
37          Stop  : Nat;
38
39       begin
40          Write_Info_Initiate ('C');
41          Write_Info_Char (' ');
42          Write_Info_Nat (SUT.Dep_Num);
43          Write_Info_Char (' ');
44
45          for N in SUT.File_Name'Range loop
46             Write_Info_Char (SUT.File_Name (N));
47          end loop;
48
49          Write_Info_Terminate;
50
51          --  Loop through SCO entries for this unit
52
53          Start := SUT.From;
54          Stop  := SUT.To;
55          loop
56             exit when Start = Stop + 1;
57             pragma Assert (Start <= Stop);
58
59             Output_SCO_Line : declare
60                T : SCO_Table_Entry renames SCO_Table.Table (Start);
61
62                procedure Output_Range (T : SCO_Table_Entry);
63                --  Outputs T.From and T.To in line:col-line:col format
64
65                ------------------
66                -- Output_Range --
67                ------------------
68
69                procedure Output_Range (T : SCO_Table_Entry) is
70                begin
71                   Write_Info_Nat  (Nat (T.From.Line));
72                   Write_Info_Char (':');
73                   Write_Info_Nat  (Nat (T.From.Col));
74                   Write_Info_Char ('-');
75                   Write_Info_Nat  (Nat (T.To.Line));
76                   Write_Info_Char (':');
77                   Write_Info_Nat  (Nat (T.To.Col));
78                end Output_Range;
79
80             --  Start of processing for Output_SCO_Line
81
82             begin
83                Write_Info_Initiate ('C');
84                Write_Info_Char (T.C1);
85
86                case T.C1 is
87
88                   --  Statements, exit
89
90                   when 'S' | 'T' =>
91                      Write_Info_Char (' ');
92                      Output_Range (T);
93
94                      --  Decision
95
96                   when 'I' | 'E' | 'W' | 'X' =>
97                      if T.C2 = ' ' then
98                         Start := Start + 1;
99                      end if;
100
101                      --  Loop through table entries for this decision
102
103                      loop
104                         declare
105                            T : SCO_Table_Entry renames SCO_Table.Table (Start);
106
107                         begin
108                            Write_Info_Char (' ');
109
110                            if T.C1 = '!' or else
111                               T.C1 = '^' or else
112                               T.C1 = '&' or else
113                               T.C1 = '|'
114                            then
115                               Write_Info_Char (T.C1);
116
117                            else
118                               Write_Info_Char (T.C2);
119                               Output_Range (T);
120                            end if;
121
122                            exit when T.Last;
123                            Start := Start + 1;
124                         end;
125                      end loop;
126
127                   when others =>
128                      raise Program_Error;
129                end case;
130
131                Write_Info_Terminate;
132             end Output_SCO_Line;
133
134             Start := Start + 1;
135          end loop;
136       end;
137    end loop;
138 end Put_SCOs;