/usr/share/ada/adainclude/asis/asis-ada_environments-containers.adb is in libasis2014-dev 2014-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- --
-- A S I S . A D A _ E N V I R O N M E N T S . C O N T A I N E R S --
-- --
-- B o d y --
-- --
-- Copyright (c) 1995-2006, 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 Asis.Exceptions; use Asis.Exceptions;
with Asis.Errors; use Asis.Errors;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.Contt; use A4G.Contt;
with A4G.Vcheck; use A4G.Vcheck;
package body Asis.Ada_Environments.Containers is
Package_Name : constant String := "Asis.Ada_Environments.Containers.";
-- At the moment, we implement the Container abstraction in a simplest
-- possible way pointed out in section 9.1: any Context is mapped to
-- a list of one Container
--
-- We think that the definition of the Container abstraction in ASIS
-- contains a hole. The Container remains valid only till the Context
-- from which it has been obtained remains opened (the same rule as for
-- other ASIS abstractions - Compilation_Unit, Element, Line,
-- Record_Component, Array_Component). We failed to find the corresponding
-- rule in the ASIS Standard.
-----------------------
-- Local subprograms --
-----------------------
-- We can not put the access and update routines for the components of the
-- Container type in Asis.Set_Get package where the access/update routines
-- for other ASIS abstractions are defined, because the Container
-- abstraction is defined not in Asis, but in
-- Asis.Ada_Environments.Containers. If we decide to implement Containers
-- in some non-trivial way, we may need to put low-level routines
-- operating on Containers in some separate package
function Set_Container
(Cntnr : Container_Id;
Cntxt : Context_Id)
return Container;
-- Creates the new value of the Container type, the Obtained field is set
-- equal to the current ASIS OS time
function Cntnr_Id (The_Container : Container) return Container_Id;
function Encl_Cont_Id (The_Container : Container) return Context_Id;
function Obtained (The_Container : Container) return ASIS_OS_Time;
-- These functions return components of the internal Contaier structure
procedure Check_Validity
(The_Container : Container;
Query : String);
-- Checks if the argument does not belong to the closed (and possibly then
-- reopened) Context. If this check fails, raises
-- ASIS_Inappropriate_Container with Value_Error error status and forms
-- the corresponding Diagnosis string
function Is_Nil (The_Container : Container) return Boolean;
-- Returns True if the container is a Nil_Container.
-- This is really strange that we do not have this function in the spec.
-- And the whole notion of Nil_Container seems to be ill-defined and
-- as a result - useless.
------------------------------
-- Local subprograms bodies --
------------------------------
--------------------
-- Check_Validity --
--------------------
procedure Check_Validity
(The_Container : Container;
Query : String)
is
begin
if not Is_Nil (The_Container) then
if not Is_Opened (Encl_Cont_Id (The_Container)) or else
not Later
(Opened_At (Encl_Cont_Id (The_Container)),
Obtained (The_Container))
then
Set_Error_Status
(Status => Value_Error,
Diagnosis => "Invalid Container value in " & Query);
raise ASIS_Inappropriate_Container;
end if;
end if;
end Check_Validity;
--------------
-- Cntnr_Id --
--------------
function Cntnr_Id (The_Container : Container) return Container_Id is
begin
return The_Container.Id;
end Cntnr_Id;
------------------
-- Encl_Cont_Id --
------------------
function Encl_Cont_Id (The_Container : Container) return Context_Id is
begin
return The_Container.Cont_Id;
end Encl_Cont_Id;
------------
-- Is_Nil --
------------
function Is_Nil (The_Container : Container) return Boolean is
begin
return Cntnr_Id (The_Container) = Nil_Container_Id;
end Is_Nil;
--------------
-- Obtained --
--------------
function Obtained (The_Container : Container) return ASIS_OS_Time is
begin
return The_Container.Obtained;
end Obtained;
-------------------
-- Set_Container --
-------------------
function Set_Container
(Cntnr : Container_Id;
Cntxt : Context_Id)
return Container
is
Result_Container : Container := Nil_Container;
begin
if Cntnr /= Nil_Container_Id then
Result_Container :=
(Id => Cntnr,
Cont_Id => Cntxt,
Obtained => A_OS_Time);
end if;
return Result_Container;
end Set_Container;
-----------------------------------------
-- End of the local subprograms bodies --
-----------------------------------------
-----------------------
-- Compilation_Units --
-----------------------
function Compilation_Units
(The_Container : Container)
return Asis.Compilation_Unit_List
is
begin
Check_Validity (The_Container, Package_Name & "Compilation_Units");
if Is_Nil (The_Container) then
return Nil_Compilation_Unit_List;
end if;
return Compilation_Units (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Compilation_Units");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Compilation_Units",
Ex => Ex);
end Compilation_Units;
-----------------------------
-- Compilation_Unit_Bodies --
-----------------------------
function Compilation_Unit_Bodies
(The_Container : Container)
return Asis.Compilation_Unit_List
is
begin
Check_Validity (The_Container, Package_Name & "Compilation_Unit_Bodies");
if Is_Nil (The_Container) then
return Nil_Compilation_Unit_List;
end if;
return Compilation_Unit_Bodies (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Compilation_Unit_Bodies");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Compilation_Unit_Bodies",
Ex => Ex);
end Compilation_Unit_Bodies;
-------------------------
-- Defining_Containers --
-------------------------
function Defining_Containers
(The_Context : Asis.Context)
return Container_List
is
begin
Check_Validity (The_Context, Package_Name & "Defining_Containers");
return
(1 => Set_Container (First_Container_Id, Get_Cont_Id (The_Context)));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Defining_Containers");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Defining_Containers",
Ex => Ex);
end Defining_Containers;
-----------------------
-- Enclosing_Context --
-----------------------
function Enclosing_Context
(The_Container : Container)
return Asis.Context
is
begin
Check_Validity (The_Container, Package_Name & "Enclosing_Context");
if Is_Nil (The_Container) then
Set_Error_Status (Status => Value_Error,
Diagnosis => "Nil_Contaier in " & Package_Name
& "Enclosing_Context");
raise ASIS_Inappropriate_Container;
end if;
return Get_Cont (Encl_Cont_Id (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Enclosing_Context");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Enclosing_Context",
Ex => Ex);
end Enclosing_Context;
--------------
-- Is_Equal --
--------------
function Is_Equal
(Left : Container;
Right : Container)
return Boolean
is
begin
Check_Validity (Left, Package_Name & "Is_Equal");
Check_Validity (Right, Package_Name & "Is_Equal");
return Is_Equal (Enclosing_Context (Left), Enclosing_Context (Right));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => Package_Name & "Is_Equal");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Equal",
Ex => Ex);
end Is_Equal;
------------------
-- Is_Identical --
------------------
function Is_Identical
(Left : Container;
Right : Container)
return Boolean
is
begin
Check_Validity (Left, Package_Name & "Is_Identical");
Check_Validity (Right, Package_Name & "Is_Identical");
return Is_Equal (Left, Right) and then
Is_Equal (Enclosing_Context (Left), Enclosing_Context (Right));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => Package_Name & "Is_Identical");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Identical",
Ex => Ex);
end Is_Identical;
-------------------------------
-- Library_Unit_Declarations --
-------------------------------
function Library_Unit_Declarations
(The_Container : Container)
return Asis.Compilation_Unit_List
is
begin
Check_Validity
(The_Container, Package_Name & "Library_Unit_Declarations");
if Is_Nil (The_Container) then
return Nil_Compilation_Unit_List;
end if;
return Library_Unit_Declarations (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Library_Unit_Declarations");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Library_Unit_Declarations",
Ex => Ex);
end Library_Unit_Declarations;
----------
-- Name --
----------
function Name
(The_Container : Container)
return Wide_String
is
begin
Check_Validity (The_Container, Package_Name & "Name");
if Is_Nil (The_Container) then
return Nil_Asis_Wide_String;
end if;
return Name (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => Package_Name & "Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Name",
Ex => Ex);
end Name;
end Asis.Ada_Environments.Containers;
|