File: asistant-add_ons.adb

package info (click to toggle)
asis 2008-5
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 9,724 kB
  • ctags: 615
  • sloc: ada: 95,867; makefile: 259; xml: 19
file content (209 lines) | stat: -rw-r--r-- 7,615 bytes parent folder | download | duplicates (3)
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
------------------------------------------------------------------------------
--                                                                          --
--             ASIS Tester And iNTerpreter (ASIStant) COMPONENTS            --
--                                                                          --
--                      A S I S T A N T . A D D _ O N S                     --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--          Copyright (c) 1997-2006, Free Software Foundation, Inc.         --
--                                                                          --
-- ASIStant  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.  ASIStant is  distributed  in the hope  that it will be useful, --
-- 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 GNAT;  see file COPYING. If --
-- not,  write to the  Free Software Foundation,  51 Franklin Street, Fifth --
-- Floor, Boston, MA 02110-1301, USA.                                       --
--                                                                          --
-- ASIStant  is an evolution of  ASIStint tool that was created by  Vasiliy --
-- Fofanov  as  part  of  a  collaboration  between  Software   Engineering --
-- Laboratory  of the  Swiss  Federal Institute of Technology in  Lausanne, --
-- Switzerland,  and the Scientific Research Computer Center of the  Moscow --
-- University, Russia,  supported by the  Swiss National Science Foundation --
-- grant #7SUPJ048247, "Development of ASIS for GNAT with industry quality" --
--                                                                          --
-- ASIStant  is  distributed as a part of the  ASIS implementation for GNAT --
-- (ASIS-for-GNAT) and is maintained by AdaCore (http://www.adacore.com).   --
------------------------------------------------------------------------------

with ASIStant.Common, ASIStant.Table;
use  ASIStant.Common, ASIStant.Table;

package body ASIStant.Add_Ons is

------------------------------------------------------------------------------
--  Additional queries
------------------------------------------------------------------------------

   ---------------------------------------------------------------------------
   --   Nil_*** queries
   ---------------------------------------------------------------------------

   function Nil_Compilation_Unit return Asis.Compilation_Unit is
   begin
      return Asis.Nil_Compilation_Unit;
   end Nil_Compilation_Unit;

   function Nil_Compilation_Unit_List return Asis.Compilation_Unit_List is
   begin
      return Asis.Nil_Compilation_Unit_List;
   end Nil_Compilation_Unit_List;

   function Nil_Element return Asis.Element is
   begin
      return Asis.Nil_Element;
   end Nil_Element;

   function Nil_Element_List return Asis.Element_List is
   begin
      return Asis.Nil_Element_List;
   end Nil_Element_List;

   function Nil_Relationship
      return Asis.Compilation_Units.Relations.Relationship is
   begin
      return Asis.Compilation_Units.Relations.Nil_Relationship;
   end Nil_Relationship;

   ---------------------------------------------------------------------------
   --  Queries to access Span fields
   ---------------------------------------------------------------------------

   function First_Line   (Sp : Asis.Text.Span) return Integer is
   begin
      return Sp.First_Line;
   end First_Line;

   function First_Column (Sp : Asis.Text.Span) return Integer is
   begin
      return Sp.First_Column;
   end First_Column;

   function Last_Line    (Sp : Asis.Text.Span) return Integer is
   begin
      return Sp.Last_Line;
   end Last_Line;

   function Last_Column  (Sp : Asis.Text.Span) return Integer is
   begin
      return Sp.Last_Column;
   end Last_Column;

   ---------------------------------------------------------------------------
   --  Queries to access Relationship fields
   ---------------------------------------------------------------------------

   function Consistent   (R : Asis.Compilation_Units.Relations.Relationship)
      return Asis.Compilation_Unit_List is
   begin
      return R.Consistent;
   end Consistent;

   function Inconsistent (R : Asis.Compilation_Units.Relations.Relationship)
      return Asis.Compilation_Unit_List is
   begin
      return R.Inconsistent;
   end Inconsistent;

   function Missing      (R : Asis.Compilation_Units.Relations.Relationship)
      return Asis.Compilation_Unit_List is
   begin
      return R.Missing;
   end Missing;

   function Circular     (R : Asis.Compilation_Units.Relations.Relationship)
      return Asis.Compilation_Unit_List is
   begin
      return R.Circular;
   end Circular;

------------------------------------------------------------------------------
--  Service queries
------------------------------------------------------------------------------

   ---------------------------------------------------------------------------
   --  List handling
   ---------------------------------------------------------------------------

   function Length (Q : Query_Result) return Integer is
      I : Integer;
   begin
      case Q.RType is
         when Par_CUnitList =>
            I := Q.CL.all'Length;
         when Par_ElemList =>
            I := Q.EL.all'Length;
         when Par_Line =>
            I := Asis.Text.Length (Q.L);
         when Par_Line_List =>
            I := Q.LL.all'Length;
         when Par_String =>
            I := Q.S.all'Length;
         when Par_DDA_Array_Component_List =>
            I := Q.ACL.all'Length;
         when Par_DDA_Record_Component_List =>
            I := Q.RCL.all'Length;
         when others =>
            Error (ERR_UNKNOWNSYNTAX, "Length");
      end case;
      return I;
   end Length;

   ---------------------------------------------------------------------------
   --  Wide_String handling
   ---------------------------------------------------------------------------

   function Concat (S1, S2 : Wide_String) return Wide_String is
   begin
      return S1 & S2;
   end Concat;

   function Eq     (S1, S2 : Wide_String) return Boolean is
   begin
      return S1 = S2;
   end Eq;

   function Lt     (S1, S2 : Wide_String) return Boolean is
   begin
      return S1 < S2;
   end Lt;

   function Gt     (S1, S2 : Wide_String) return Boolean is
   begin
      return S1 > S2;
   end Gt;

   ---------------------------------------------------------------------------
   --  Integer handling
   ---------------------------------------------------------------------------

   function Add (I1, I2 : Integer) return Integer is
   begin
      return I1 + I2;
   end Add;

   function Sub (I1, I2 : Integer) return Integer is
   begin
      return I1 - I2;
   end Sub;

   function Eq  (I1, I2 : Integer) return Boolean is
   begin
      return I1 = I2;
   end Eq;

   function Lt  (I1, I2 : Integer) return Boolean is
   begin
      return I1 < I2;
   end Lt;

   function Gt  (I1, I2 : Integer) return Boolean is
   begin
      return I1 > I2;
   end Gt;

end ASIStant.Add_Ons;