/usr/share/ada/adainclude/asis/asis-data_decomposition-extensions.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 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . D A T A _ D E C O M P O S I T I O N . E X T E N S I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2013, 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, 59 Temple Place --
-- - Suite 330, Boston, MA 02111-1307, 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.adacore.com). --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with System; use System;
with Asis.Data_Decomposition.Vcheck; use Asis.Data_Decomposition.Vcheck;
with Asis.Data_Decomposition.Set_Get; use Asis.Data_Decomposition.Set_Get;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.DDA_Aux; use A4G.DDA_Aux;
with A4G.Vcheck; use A4G.Vcheck;
with Einfo; use Einfo;
with Namet; use Namet;
with Uintp; use Uintp;
with Urealp; use Urealp;
package body Asis.Data_Decomposition.Extensions is
Package_Name : constant String := "Asis.Data_Decomposition.Extensions.";
-----------------------
-- Local subprograms --
-----------------------
procedure Write_Real_To_Buffer (U : Ureal);
-- Puts nnn/ddd to Name_Buffer, where nnn and ddd are integer values of
-- the normalized numerator and denominator of the given real value.
-- This procedure is supposed to be used to output images of positive
-- real values only, so it assumes, that nnn is always positive.
procedure Add_Uint_To_Buffer (U : Uint);
-- Add image of universal integer to Name_Buffer, updating Name_Len
-- (This procedure is the simplified version of the local procedure
-- Exp_Dbug.Add_Uint_To_Buffer - it always consider its argument
-- being positive)
------------------------
-- Add_Uint_To_Buffer --
------------------------
procedure Add_Uint_To_Buffer (U : Uint) is
begin
UI_Image (U, Decimal);
Add_Str_To_Name_Buffer (UI_Image_Buffer (1 .. UI_Image_Length));
end Add_Uint_To_Buffer;
-------------------------------
-- Component_Name_Definition --
-------------------------------
function Component_Name_Definition
(Component : Record_Component)
return Asis.Declaration
is
Result : Asis.Element;
begin
Check_Validity (Component, Package_Name & "Component_Name_Definition");
if Is_Nil (Component) then
Raise_ASIS_Inappropriate_Component
(Diagnosis => Package_Name & "Component_Name_Definition",
Component_Kind => Rec);
end if;
Result := Component_Name (Component);
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Component_Name_Definition");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Component_Name_Definition",
Ex => Ex);
end Component_Name_Definition;
--------------------------
-- Delta_Value (String) --
--------------------------
function Delta_Value
(Fixed_Point_Subtype : Asis.Element)
return String
is
Arg_Node : Node_Id;
Res_Ureal : Ureal;
begin
Check_Validity
(Fixed_Point_Subtype, Package_Name & "Delta_Value (String)");
Arg_Node := R_Node (Fixed_Point_Subtype);
if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then
Is_Fixed_Point_Type (Arg_Node))
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Delta_Value (String)",
Wrong_Kind => Int_Kind (Fixed_Point_Subtype));
end if;
Res_Ureal := Einfo.Delta_Value (Arg_Node);
Write_Real_To_Buffer (Res_Ureal);
return Namet.Name_Buffer (1 .. Namet.Name_Len);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Delta_Value (String)",
Argument => Fixed_Point_Subtype);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Delta_Value (String)",
Ex => Ex,
Arg_Element => Fixed_Point_Subtype);
end Delta_Value;
----------------------------
-- Delta_Value (Fraction) --
----------------------------
function Delta_Value
(Fixed_Point_Subtype : Asis.Element)
return Fraction
is
Arg_Node : Node_Id;
Res_Ureal : Ureal;
Result : Fraction;
begin
Check_Validity
(Fixed_Point_Subtype, Package_Name & "Delta_Value (Fraction)");
Arg_Node := R_Node (Fixed_Point_Subtype);
if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then
Is_Fixed_Point_Type (Arg_Node))
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Delta_Value (Fraction)",
Wrong_Kind => Int_Kind (Fixed_Point_Subtype));
end if;
Res_Ureal := Einfo.Delta_Value (Arg_Node);
Result.Num := UI_To_Aint (Norm_Num (Res_Ureal));
Result.Denum := UI_To_Aint (Norm_Den (Res_Ureal));
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Delta_Value (Fraction)",
Argument => Fixed_Point_Subtype);
end if;
raise;
when Invalid_Data =>
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Delta_Value (Fraction)",
Wrong_Kind => Int_Kind (Fixed_Point_Subtype),
Status => Data_Error);
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Delta_Value (Fraction)",
Ex => Ex,
Arg_Element => Fixed_Point_Subtype);
end Delta_Value;
------------------
-- Digits_Value --
------------------
function Digits_Value
(Floating_Point_Subtype : Asis.Element)
return ASIS_Natural
is
Arg_Node : Node_Id;
begin
Check_Validity (Floating_Point_Subtype, Package_Name & "Digits_Value");
Arg_Node := R_Node (Floating_Point_Subtype);
if not (Int_Kind (Floating_Point_Subtype) = A_Defining_Identifier
and then
(Is_Decimal_Fixed_Point_Type (Arg_Node) or else
Is_Floating_Point_Type (Arg_Node)))
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Digits_Value",
Wrong_Kind => Int_Kind (Floating_Point_Subtype));
end if;
return ASIS_Natural (UI_To_Int (Einfo.Digits_Value (Arg_Node)));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Digits_Value",
Argument => Floating_Point_Subtype);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Digits_Value",
Ex => Ex,
Arg_Element => Floating_Point_Subtype);
end Digits_Value;
--------------------------
-- Portable_Data_Value --
--------------------------
function Portable_Data_Value
(Value : Constrained_Subtype)
return Portable_Data
is
Local_Value : aliased constant Constrained_Subtype := Value;
for Local_Value'Alignment use Standard'Maximum_Alignment;
-- We force the maximum alignment for Local_Value to make it
-- compatible with maximum alignment set for Portable_Data
-- in the spec of Asis.Data_Decomposition
subtype Result_Portable_Data is
Portable_Data (1 .. (Constrained_Subtype'Object_Size + 7) / 8);
type Result_Portable_Data_Access is access Result_Portable_Data;
function To_Result_Portable_Data_Access is new
Ada.Unchecked_Conversion (Address, Result_Portable_Data_Access);
Result : constant Result_Portable_Data_Access :=
To_Result_Portable_Data_Access (Local_Value'Address);
begin
return Result.all;
exception
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Portable_Data_Value");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Portable_Data_Value",
Ex => Ex);
end Portable_Data_Value;
-----------------
-- Scale_Value --
-----------------
function Scale_Value
(Desimal_Fixed_Point_Subtype : Asis.Element)
return ASIS_Natural
is
Arg_Node : Node_Id;
begin
Check_Validity
(Desimal_Fixed_Point_Subtype, Package_Name & "Scale_Value");
Arg_Node := R_Node (Desimal_Fixed_Point_Subtype);
if not (Int_Kind (Desimal_Fixed_Point_Subtype) = A_Defining_Identifier
and then
Is_Decimal_Fixed_Point_Type (Arg_Node))
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Scale_Value",
Wrong_Kind => Int_Kind (Desimal_Fixed_Point_Subtype));
end if;
return ASIS_Natural (UI_To_Int (Einfo.Scale_Value (Arg_Node)));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Scale_Value",
Argument => Desimal_Fixed_Point_Subtype);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Scale_Value",
Ex => Ex,
Arg_Element => Desimal_Fixed_Point_Subtype);
end Scale_Value;
--------------------------
-- Small_Value (String) --
--------------------------
function Small_Value
(Fixed_Point_Subtype : Asis.Element)
return String
is
Arg_Node : Node_Id;
Res_Ureal : Ureal;
begin
Check_Validity
(Fixed_Point_Subtype, Package_Name & "Small_Value (String)");
Arg_Node := R_Node (Fixed_Point_Subtype);
if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then
Is_Fixed_Point_Type (Arg_Node))
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Small_Value (String)",
Wrong_Kind => Int_Kind (Fixed_Point_Subtype));
end if;
Res_Ureal := Einfo.Small_Value (Arg_Node);
Write_Real_To_Buffer (Res_Ureal);
return Namet.Name_Buffer (1 .. Namet.Name_Len);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Small_Value (String)",
Argument => Fixed_Point_Subtype);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Small_Value (String)",
Ex => Ex,
Arg_Element => Fixed_Point_Subtype);
end Small_Value;
----------------------------
-- Small_Value (Fraction) --
----------------------------
function Small_Value
(Fixed_Point_Subtype : Asis.Element)
return Fraction
is
Arg_Node : Node_Id;
Res_Ureal : Ureal;
Result : Fraction;
begin
Check_Validity
(Fixed_Point_Subtype, Package_Name & "Small_Value (Fraction)");
Arg_Node := R_Node (Fixed_Point_Subtype);
if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then
Is_Fixed_Point_Type (Arg_Node))
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Small_Value (Fraction)",
Wrong_Kind => Int_Kind (Fixed_Point_Subtype));
end if;
Res_Ureal := Einfo.Small_Value (Arg_Node);
Result.Num := UI_To_Aint (Norm_Num (Res_Ureal));
Result.Denum := UI_To_Aint (Norm_Den (Res_Ureal));
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Small_Value (Fraction)",
Argument => Fixed_Point_Subtype);
end if;
raise;
when Invalid_Data =>
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Small_Value (Fraction)",
Wrong_Kind => Int_Kind (Fixed_Point_Subtype),
Status => Data_Error);
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Small_Value (Fraction)",
Ex => Ex,
Arg_Element => Fixed_Point_Subtype);
end Small_Value;
--------------------------
-- Write_Real_To_Buffer --
--------------------------
procedure Write_Real_To_Buffer (U : Ureal) is
begin
Namet.Name_Len := 0;
Add_Uint_To_Buffer (Norm_Num (U));
Add_Str_To_Name_Buffer ("/");
Add_Uint_To_Buffer (Norm_Den (U));
end Write_Real_To_Buffer;
end Asis.Data_Decomposition.Extensions;
|