/usr/share/ada/adainclude/asis/asis-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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . E X T E N S I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2014, 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 3, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception distributed with GNAT; see --
-- the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- 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). --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Declarations; use Asis.Declarations;
with Asis.Definitions; use Asis.Definitions;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Expressions; use Asis.Expressions;
with Asis.Statements; use Asis.Statements;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.A_Opt; use A4G.A_Opt;
with A4G.A_Sem; use A4G.A_Sem;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.Contt; use A4G.Contt;
with A4G.Contt.TT; use A4G.Contt.TT;
with A4G.Contt.UT; use A4G.Contt.UT;
with A4G.DDA_Aux; use A4G.DDA_Aux;
with A4G.Decl_Sem; use A4G.Decl_Sem;
with A4G.Asis_Tables; use A4G.Asis_Tables;
with A4G.Expr_Sem; use A4G.Expr_Sem;
with A4G.GNAT_Int; use A4G.GNAT_Int;
with A4G.Mapping; use A4G.Mapping;
with A4G.Queries; use A4G.Queries;
with A4G.Vcheck; use A4G.Vcheck;
with Atree; use Atree;
with Einfo; use Einfo;
with Elists; use Elists;
with Namet; use Namet;
with Nlists; use Nlists;
with Output; use Output;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
with Uintp; use Uintp;
with Urealp; use Urealp;
package body Asis.Extensions is
Package_Name : constant String := "Asis.Extensions.";
-----------------------
-- Local subprograms --
-----------------------
function Is_Typeless_Subaggregate (Aggr : Node_Id) return Boolean;
-- Checks if Aggr represents an inner typeless subaggregate of
-- multi-dimensional array aggregate. A caller is responsible for providing
-- only nodes that represents components of array aggregates as actuals.
function Is_Expanded_Subprogram (N : Node_Id) return Boolean;
-- Checks if N corresponds to the spec of an expanded generic
-- subprogram. Is needed because Comes_From_Source in this case is
-- set OFF (opposite to expanded packages)
function Is_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean;
-- Checks if Op_Decl declares an operator function having a parameter
-- or a result of the type Type_Decl (Type_Decl is supposed to be a type
-- declaration name). Returns False for a function body if the body has
-- the separate spec
function Overrides_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean;
-- Provided that Is_Type_Operator (Op_Decl, Type_Decl) is True (note,
-- that this function does not check this, it should be checked by the
-- caller), checks if Op_Decl overrides a predefined or inherited
-- operator function that exists for Type_Decl
function Is_From_Import_Procedure_Pragma (N : Node_Id) return Boolean;
-- Checks a specific situation for an identifier specific to a pragma for
-- GNAT-specific pragmas Import_Procedure and Import_Valued_Procedure -
-- for components of MECHANISM_NAME having the form of A (B).
function Get_LF_From_Ureal (U : Ureal) return Long_Long_Float;
-- Converts universal real into Long_Float. This is a quick-and-dirty
-- solution for extending Static_Expression_Value_Image for real image,
-- it may blow up in case if numerator or denominator is too big. The
-- conversion does some arbitrary rounding (I believe this rounding is
-- reasonable, but I have no proof of this)
pragma Unreferenced (Get_LF_From_Ureal);
function Get_Implemented_Op
(Op_Decl : Asis.Element;
Type_Def : Asis.Element)
return Asis.Element;
pragma Unreferenced (Get_Implemented_Op);
-- Op_Decl is supposed to be a declaration of a dispatching operation for
-- that Is_Overriding_Operation is true. Type_Def is supposed to be an
-- interface type definition for some interface type that is included in
-- the interface list of the definition of the type that is the type
-- of dispatching operand(s) of Op_Decl. This function checks if Op_Decl
-- may implement some operation of this interface, and if it may returns
-- the declaration of this interface operation as a result, otherwise it
-- returns Nil_Element.
function Is_Procedure (Decl : Asis.Element) return Boolean;
pragma Unreferenced (Is_Procedure);
-- Checks that Decl declares a procedure
------------------
-- Acts_As_Spec --
------------------
function Acts_As_Spec (Declaration : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
Name_Node : Node_Id;
Spec_Node : Node_Id;
Arg_Ekind : Entity_Kind;
Result : Boolean := False;
begin
Check_Validity (Declaration, Package_Name & "Acts_As_Spec");
Arg_Node := Node (Declaration);
case Arg_Kind is
when A_Procedure_Body_Declaration |
A_Function_Body_Declaration =>
Result := Acts_As_Spec (Arg_Node);
-- The problem here is that for some subprogram bodies the
-- front-end creates artificial specs and sets OFF the
-- Acts_As_Spec flag for the body. At the moment we have detected
-- two such situations (and we exclude the case of expanded
-- subprogram body not to mix up with the similar situation in
-- the tree, see :
if not Result
and then
Special_Case (Declaration) /= Expanded_Subprogram_Instantiation
then
-- (1) Bodies declared immediately within protected bodies
if Nkind (Parent (Arg_Node)) = N_Protected_Body then
Spec_Node := Corresponding_Spec (Arg_Node);
if Is_Artificial_Protected_Op_Item_Spec (Spec_Node) then
Result := True;
end if;
else
-- (2) child subprogram bodies with no separate spec
Name_Node := Defining_Unit_Name (Specification (Arg_Node));
if Nkind (Name_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Corresponding_Spec (Arg_Node);
if Present (Arg_Node) then
while not
(Nkind (Arg_Node) = N_Subprogram_Declaration or else
Nkind (Arg_Node) = N_Generic_Subprogram_Declaration)
loop
Arg_Node := Parent (Arg_Node);
end loop;
Result := not Comes_From_Source (Arg_Node);
end if;
end if;
end if;
end if;
when A_Procedure_Body_Stub |
A_Function_Body_Stub =>
Arg_Ekind := Ekind (Defining_Unit_Name (Specification (Arg_Node)));
Result := Arg_Ekind = E_Function
or else Arg_Ekind = E_Procedure;
when An_Expression_Function_Declaration =>
if Is_Part_Of_Inherited (Declaration) then
Result := True;
else
Result :=
Nkind (R_Node (Declaration)) = N_Subprogram_Declaration;
end if;
when others => null;
end case;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Acts_As_Spec");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Acts_As_Spec",
Ex => Ex,
Arg_Element => Declaration);
end Acts_As_Spec;
------------------------------
-- Compilation_Dependencies --
------------------------------
function Compilation_Dependencies
(Main_Unit : Asis.Compilation_Unit)
return Asis.Compilation_Unit_List
is
Arg_Kind : constant Asis.Unit_Kinds := Kind (Main_Unit);
Arg_Unit_Id : Unit_Id;
Res_Cont_Id : Context_Id;
begin
Check_Validity (Main_Unit, Package_Name & "Compilation_Dependencies");
if Arg_Kind not in A_Procedure .. A_Protected_Body_Subunit then
Raise_ASIS_Inappropriate_Compilation_Unit
(Diagnosis => Package_Name & "Compilation_Dependencies");
end if;
Res_Cont_Id := Encl_Cont_Id (Main_Unit);
Reset_Context (Res_Cont_Id);
Arg_Unit_Id := Get_Unit_Id (Main_Unit);
declare
Result_Id_List : constant Unit_Id_List :=
GNAT_Compilation_Dependencies (Arg_Unit_Id);
Result_List : constant Compilation_Unit_List :=
Get_Comp_Unit_List (Result_Id_List, Res_Cont_Id);
begin
if Is_Nil (Result_List) then
Raise_ASIS_Inappropriate_Compilation_Unit
(Diagnosis => Package_Name & "Compilation_Dependencies");
else
return Result_List;
end if;
end;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Compilation_Dependencies");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Compilation_Dependencies",
Ex => Ex,
Arg_CU => Main_Unit);
end Compilation_Dependencies;
-------------
-- Compile --
-------------
procedure Compile
(Source_File : String_Access;
Args : Argument_List;
Success : out Boolean;
GCC : String_Access := null;
Use_GNATMAKE : Boolean := False;
Use_Temp_Prj : Boolean := False;
Compiler_Out : String := "";
All_Warnings_Off : Boolean := True;
Display_Call : Boolean := False)
is
Comp_Args : Argument_List (Args'First .. Args'Last + 12 + 1);
First_Idx : constant Integer := Comp_Args'First;
Last_Idx : Integer := First_Idx;
Obj_Name : String_Access;
Dot_Idx : Natural := 0;
Is_GNAAMP_Call : Boolean := False;
-- In case of the call to GNAAMP we should not set '-x ada' flags
Is_GNATMAKE_Call : Boolean := Use_GNATMAKE;
begin
if Is_GNATMAKE_Call and then GCC = null then
-- We can not set gnatmake-specific parameters in this case
Is_GNATMAKE_Call := False;
end if;
if GCC /= null then
Is_GNAAMP_Call :=
Index (To_Lower (Base_Name (GCC.all)), "gnaamp") /= 0;
end if;
Comp_Args (Last_Idx) := Comp_Flag;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNAT_Flag_ct;
Last_Idx := Last_Idx + 1;
if Is_GNATMAKE_Call then
Comp_Args (Last_Idx) := GNATMAKE_Flag_u;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNATMAKE_Flag_f;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNATMAKE_Flag_q;
Last_Idx := Last_Idx + 1;
elsif not Is_GNAAMP_Call then
Comp_Args (Last_Idx) := GCC_Flag_X;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GCC_Par_Ada;
Last_Idx := Last_Idx + 1;
end if;
for J in Args'Range loop
Comp_Args (Last_Idx) := Args (J);
Last_Idx := Last_Idx + 1;
end loop;
if All_Warnings_Off then
Comp_Args (Last_Idx) := GNAT_Flag_ws;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNAT_Flag_yN;
Last_Idx := Last_Idx + 1;
end if;
Comp_Args (Last_Idx) := Source_File;
if Is_GNATMAKE_Call
and then
not Use_Temp_Prj
then
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNATMAKE_Flag_cargs;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GCC_Flag_o;
Last_Idx := Last_Idx + 1;
Obj_Name := new String'(Base_Name (Source_File.all));
Dot_Idx := Index (Obj_Name.all, ".", Backward);
if Dot_Idx /= 0 then
Dot_Idx := Dot_Idx - 1;
else
Dot_Idx := Obj_Name'Last;
end if;
Comp_Args (Last_Idx) := new String'
(Get_Current_Dir &
Directory_Separator &
Obj_Name (Obj_Name'First .. Dot_Idx) &
".o");
end if;
Success :=
Execute
(GCC, Comp_Args (Args'First .. Last_Idx), Compiler_Out,
Display_Call => Display_Call);
end Compile;
----------------
-- Components --
----------------
function Components (E : Asis.Element) return Asis.Element_List is
Child_Access : constant Func_Elem_Array := Appropriate_Queries (E);
Result_Length : Integer := 0;
begin
Check_Validity (E, Package_Name & "Components");
if Is_Nil (E) then
return Nil_Element_List;
end if;
-- first, we compute the result's length:
for Each_Query in Child_Access'Range loop
case Child_Access (Each_Query).Query_Kind is
when Bug | Boolean_Query | CU_Query_Kinds =>
null;
when Single_Element_Query =>
if not Is_Nil (Child_Access (Each_Query).Func_Simple (E)) then
Result_Length := Result_Length + 1;
end if;
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (E);
begin
Result_Length := Result_Length + Child_List'Length;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(E, Child_Access (Each_Query).Bool);
begin
Result_Length := Result_Length + Child_List'Length;
end;
end case;
end loop;
-- and now, we define the result element list of Result_Length
-- length and fill it in by repeating the same loop. This is
-- not effective, and this will have to be revised.
if Result_Length = 0 then
return Nil_Element_List;
end if;
declare
Result_List : Asis.Element_List (1 .. Result_Length);
Next_Element : Integer := 1;
begin
for Each_Query in Child_Access'Range loop
case Child_Access (Each_Query).Query_Kind is
when Bug | Boolean_Query | CU_Query_Kinds =>
null;
when Single_Element_Query =>
if not Is_Nil
(Child_Access (Each_Query).Func_Simple (E))
then
Result_List (Next_Element) :=
Child_Access (Each_Query).Func_Simple (E);
Next_Element := Next_Element + 1;
end if;
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (E);
begin
for I in Child_List'First .. Child_List'Last loop
Result_List (Next_Element) := Child_List (I);
Next_Element := Next_Element + 1;
end loop;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(E, Child_Access (Each_Query).Bool);
begin
for I in Child_List'First .. Child_List'Last loop
Result_List (Next_Element) := Child_List (I);
Next_Element := Next_Element + 1;
end loop;
end;
end case;
end loop;
return Result_List;
end;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => E,
Outer_Call => Package_Name & "Components");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Components",
Ex => Ex,
Arg_Element => E);
end Components;
----------------------------
-- Controlling_Parameters --
----------------------------
function Controlling_Parameters
(Declaration : Asis.Declaration)
return Asis.Element_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
begin
Check_Validity
(Declaration,
Package_Name & "Controlling_Parameters");
if Arg_Kind not in
A_Procedure_Declaration |
A_Function_Declaration |
An_Expression_Function_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration |
A_Null_Procedure_Declaration |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Procedure_Body_Stub |
A_Function_Body_Stub
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Controlling_Parameters",
Wrong_Kind => Arg_Kind);
end if;
declare
Params : constant Asis.Element_List :=
Parameter_Profile (Declaration);
Result : Asis.Element_List (1 .. Params'Length);
Last : Natural := 0;
Par_Name : Asis.Element;
Par_Entity : Entity_Id;
begin
for Par in Params'Range loop
Par_Name := First_Name (Params (Par));
Par_Entity := R_Node (Par_Name);
if Is_Controlling_Formal (Par_Entity) then
Last := Last + 1;
Result (Last) := Params (Par);
end if;
end loop;
return Result (1 .. Last);
end;
end Controlling_Parameters;
-----------------------------------------------
-- Corresponding_Body_Parameter_Definition --
-----------------------------------------------
function Corresponding_Body_Parameter_Definition
(Defining_Name : Asis.Defining_Name)
return Asis.Defining_Name
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Defining_Name);
Encl_Constr : Asis.Element;
Encl_Constr_Kind : Internal_Element_Kinds;
Result : Asis.Element := Nil_Element;
begin
Check_Validity
(Defining_Name,
Package_Name & "Corresponding_Body_Parameter_Definition");
if Arg_Kind /= A_Defining_Identifier then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Body_Parameter_Definition",
Wrong_Kind => Arg_Kind);
end if;
Encl_Constr := Enclosing_Element (Defining_Name);
if Declaration_Kind (Encl_Constr) not in A_Formal_Declaration then
Encl_Constr := (Enclosing_Element (Encl_Constr));
end if;
Encl_Constr_Kind := Int_Kind (Encl_Constr);
case Encl_Constr_Kind is
when A_Procedure_Body_Declaration |
A_Function_Body_Declaration =>
Result := Defining_Name;
when A_Procedure_Body_Stub |
A_Function_Body_Stub =>
Encl_Constr := Corresponding_Subunit (Encl_Constr);
when A_Procedure_Declaration |
A_Function_Declaration |
A_Generic_Function_Declaration |
A_Generic_Procedure_Declaration =>
Encl_Constr := Corresponding_Body (Encl_Constr);
Encl_Constr_Kind := Int_Kind (Encl_Constr);
if Encl_Constr_Kind = A_Procedure_Body_Stub or else
Encl_Constr_Kind = A_Function_Body_Stub
then
Encl_Constr := Corresponding_Subunit (Encl_Constr);
elsif Encl_Constr_Kind = An_Import_Pragma then
Encl_Constr := Nil_Element;
end if;
when others =>
-- For all the other situations we can not return a parameter
-- definition in the body
Encl_Constr := Nil_Element;
end case;
if not Is_Nil (Result)
or else
Is_Nil (Encl_Constr)
or else
Declaration_Kind (Encl_Constr) = Not_A_Declaration
then
return Result;
end if;
Process_Parameter_Specifications : declare
Def_Name_Image : constant String
:= To_Lower (To_String (Defining_Name_Image (Defining_Name)));
Param_Specs : constant Asis.Element_List
:= Parameter_Profile (Encl_Constr);
begin
Through_Parameter_Specs : for I in Param_Specs'Range loop
Process_Parameter_Names : declare
Par_Names : constant Asis.Element_List :=
Names (Param_Specs (I));
begin
Through_Parameter_Names : for J in Par_Names'Range loop
if Def_Name_Image =
To_Lower (To_String (Defining_Name_Image
(Par_Names (J))))
then
Result := Par_Names (J);
exit Through_Parameter_Specs;
end if;
end loop Through_Parameter_Names;
end Process_Parameter_Names;
end loop Through_Parameter_Specs;
end Process_Parameter_Specifications;
pragma Assert (not Is_Nil (Result));
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Defining_Name,
Outer_Call => Package_Name &
"Corresponding_Body_Parameter_Definition");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Body_Parameter_Definition",
Ex => Ex,
Arg_Element => Defining_Name);
end Corresponding_Body_Parameter_Definition;
-----------------------------------------
-- Corresponding_Called_Entity_Unwound --
-----------------------------------------
function Corresponding_Called_Entity_Unwound
(Statement : Asis.Statement)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Arg_Node_Kind : Node_Kind;
Result_Node : Node_Id;
Result_Unit : Compilation_Unit;
Res_Spec_Case : Special_Cases := Not_A_Special_Case;
begin
Check_Validity
(Statement, Package_Name & "Corresponding_Called_Entity_Unwound");
if not (Arg_Kind = An_Entry_Call_Statement or else
Arg_Kind = A_Procedure_Call_Statement)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Called_Entity_Unwound",
Wrong_Kind => Arg_Kind);
end if;
-- the implementation approach is similar to the approach taken for
-- Asis.Expressions.Corresponding_Called_Function
Arg_Node := R_Node (Statement);
-- To be on the safe side, we use R_Node instead of Node, but it looks
-- like in this case R_Node and Node should be the same
Arg_Node_Kind := Nkind (Arg_Node);
case Arg_Node_Kind is
when N_Attribute_Reference =>
return Nil_Element;
-- call to a procedure-attribute
when N_Entry_Call_Statement | N_Procedure_Call_Statement =>
-- here we have to filter out the case when Nil_Element
-- should be returned for a call through access-to-function:
if Nkind (Sinfo.Name (Arg_Node)) = N_Explicit_Dereference then
return Nil_Element;
end if;
-- ??? <tree problem 4>
-- this fragment should be revised when the problem is fixed (as it should)
if Arg_Node_Kind = N_Entry_Call_Statement then
Result_Node := Sinfo.Name (Arg_Node);
-- Result_Node points to the name of the called entry
if Nkind (Result_Node) = N_Indexed_Component then
-- this is the case for a call to an entry from an
-- entry family
Result_Node := Prefix (Result_Node);
end if;
Result_Node := Entity (Selector_Name (Result_Node));
else
Result_Node := Entity (Sinfo.Name (Arg_Node));
-- only this assignment is needed if tree problem 4 is
-- fixed
end if;
-- ??? <tree problem 4> - end
when others =>
pragma Assert (False);
null;
end case;
Result_Node := Unwind_Renaming (Result_Node);
if No (Result_Node) then
-- renaming of a procedure-attribute
return Nil_Element;
end if;
if not Comes_From_Source (Result_Node) then
return Nil_Element;
end if;
Result_Unit := Enclosing_Unit (Encl_Cont_Id (Statement), Result_Node);
-- if not Is_Consistent (Result_Unit, Encl_Unit (Statement)) then
-- return Nil_Element;
-- end if;
-- And now - from a defining name to a declaration itself
Result_Node := Parent (Result_Node);
if Nkind (Result_Node) in N_Subprogram_Specification then
Result_Node := Parent (Result_Node);
end if;
if Is_Expanded_Subprogram (Result_Node) then
Res_Spec_Case := Expanded_Subprogram_Instantiation;
end if;
return Node_To_Element_New
(Node => Result_Node,
Spec_Case => Res_Spec_Case,
In_Unit => Result_Unit);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name &
"Corresponding_Called_Entity_Unwound");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Called_Entity_Unwound",
Ex => Ex,
Arg_Element => Statement);
end Corresponding_Called_Entity_Unwound;
-------------------------------------------
-- Corresponding_Called_Function_Unwound --
-------------------------------------------
function Corresponding_Called_Function_Unwound
(Expression : Asis.Expression)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Expression);
Arg_Node : Node_Id;
Arg_Node_Kind : Node_Kind;
Result_Node : Node_Id;
Result_Unit : Compilation_Unit;
Res_Spec_Case : Special_Cases := Not_A_Special_Case;
begin
Check_Validity
(Expression, Package_Name & "Corresponding_Called_Function_Unwound");
if not (Arg_Kind = A_Function_Call) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Called_Function_Unwound",
Wrong_Kind => Arg_Kind);
end if;
-- first, we have to filter out the cases when a Nil_Element
-- should be returned. For now, these cases include:
--
-- - calls to functions-attributes;
-- - all forms of calls to predefined operators;
-- - all forms of calls to inherited functions
--
-- We hope to implement the last case in future...
-- First, we try the simplest approach, and then we will add patches
-- if needed:
Arg_Node := R_Node (Expression);
Arg_Node_Kind := Nkind (Arg_Node);
-- Rewritten node should know everything. But if this node is the
-- result of compile-time optimization, we have to work with
-- original node only:
if Arg_Node_Kind = N_String_Literal or else
Arg_Node_Kind = N_Integer_Literal or else
Arg_Node_Kind = N_Real_Literal or else
Arg_Node_Kind = N_Character_Literal or else
Arg_Node_Kind = N_Raise_Constraint_Error or else
Arg_Node_Kind = N_Identifier
then
Arg_Node := Node (Expression);
Arg_Node_Kind := Nkind (Arg_Node);
elsif Arg_Node_Kind = N_Explicit_Dereference then
-- See F727-023
Arg_Node := Sinfo.Prefix (Arg_Node);
Arg_Node_Kind := Nkind (Arg_Node);
end if;
case Arg_Node_Kind is
when N_Attribute_Reference =>
return Nil_Element;
when N_Function_Call |
N_Procedure_Call_Statement =>
-- The second choice here corresponds to a procedure that is an
-- argument of Debug pragma
-- here we have to filter out the case when Nil_Element
-- should be returned for a call through access-to-function:
if Nkind (Sinfo.Name (Arg_Node)) = N_Explicit_Dereference then
return Nil_Element;
else
Result_Node := Entity (Sinfo.Name (Arg_Node));
end if;
when N_Op =>
-- all the predefined operations (??)
Result_Node := Entity (Arg_Node);
when others =>
pragma Assert (False);
null;
end case;
-- here we have Result_Node pointed to the defining occurrence of
-- the corresponding called function. Three things should be done:
-- 1. If Result_Node is defined in a renaming definition, we have
-- to unwind all the renamings till the defining occurrence of
-- the corresponding callable entity will be reached;
-- 2. If a given callable entity is implicitly defined, Nil_Element
-- should be returned;
-- 3. We have to come from a defining name to the corresponding
-- declaration and then we should return the Element
-- corresponding to this declaration
Result_Node := Unwind_Renaming (Result_Node);
if No (Result_Node) then
-- renaming of a function-attribute
return Nil_Element;
end if;
-- here we have Result_Node pointing to the defining occurrence of the
-- name of the corresponding called function. First, we have to
-- filter out implicitly declared functions:
if not Comes_From_Source (Result_Node) then
return Nil_Element;
end if;
Result_Unit := Enclosing_Unit (Encl_Cont_Id (Expression), Result_Node);
Result_Node := Parent (Result_Node);
if Nkind (Result_Node) = N_Defining_Program_Unit_Name then
Result_Node := Parent (Result_Node);
end if;
Result_Node := Parent (Result_Node);
-- to go from a defining name to a declaration itself
if Is_Expanded_Subprogram (Result_Node) then
Res_Spec_Case := Expanded_Subprogram_Instantiation;
end if;
return Node_To_Element_New
(Node => Result_Node,
Spec_Case => Res_Spec_Case,
In_Unit => Result_Unit);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name &
"Corresponding_Called_Function_Unwound");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Called_Function_Unwound",
Ex => Ex,
Arg_Element => Expression);
end Corresponding_Called_Function_Unwound;
------------------------------------
-- Corresponding_First_Definition --
------------------------------------
function Corresponding_First_Definition
(Defining_Name : Asis.Defining_Name)
return Asis.Defining_Name
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Defining_Name);
Is_Parameter : Boolean := False;
Encl_Constr : Asis.Element;
Encl_Constr_Kind : Internal_Element_Kinds;
First_Declaration : Asis.Element := Nil_Element;
Discr_Part : Asis.Element := Nil_Element;
Tmp : Asis.Element;
Result : Asis.Element := Nil_Element;
begin
Check_Validity
(Defining_Name, Package_Name & "Corresponding_First_Definition");
if Arg_Kind not in Internal_Defining_Name_Kinds then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_First_Definition",
Wrong_Kind => Arg_Kind);
end if;
Encl_Constr := Enclosing_Element (Defining_Name);
if Int_Kind (Encl_Constr) = A_Parameter_Specification then
Encl_Constr := Enclosing_Element (Encl_Constr);
Is_Parameter := True;
end if;
if Is_Subunit (Encl_Constr) then
Encl_Constr := Corresponding_Body_Stub (Encl_Constr);
end if;
Encl_Constr_Kind := Int_Kind (Encl_Constr);
case Encl_Constr_Kind is
when A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Function_Renaming_Declaration |
A_Procedure_Renaming_Declaration |
A_Procedure_Body_Stub |
A_Function_Body_Stub =>
if ((Encl_Constr_Kind = A_Procedure_Body_Declaration or else
Encl_Constr_Kind = A_Function_Body_Declaration or else
Encl_Constr_Kind = A_Procedure_Body_Stub or else
Encl_Constr_Kind = A_Function_Body_Stub)
and then (not (Acts_As_Spec (Encl_Constr))))
or else
((Encl_Constr_Kind = A_Function_Renaming_Declaration or else
Encl_Constr_Kind = A_Procedure_Renaming_Declaration)
and then Is_Renaming_As_Body (Encl_Constr))
then
-- there should be a corresponding spec where the first
-- definition should be:
if Is_Subunit (Encl_Constr) then
Encl_Constr := Corresponding_Body_Stub (Encl_Constr);
end if;
First_Declaration := Corresponding_Declaration (Encl_Constr);
if not Is_Parameter then
-- just returning a defining name from a declaration,
-- otherwise Result will remain nil, and we will have
-- to process the case of a formal parameter after this
-- case statement
Result := Names (First_Declaration) (1);
end if;
else
Result := Defining_Name;
end if;
when A_Package_Body_Declaration |
A_Task_Body_Declaration |
A_Protected_Body_Declaration |
A_Package_Body_Stub |
A_Task_Body_Stub |
A_Protected_Body_Stub |
An_Entry_Body_Declaration =>
First_Declaration := Corresponding_Declaration (Encl_Constr);
if not Is_Parameter then
Result := Names (First_Declaration) (1);
end if;
when An_Accept_Statement =>
First_Declaration := Corresponding_Entry (Encl_Constr);
when An_Ordinary_Type_Declaration =>
-- If it's internally-generated type, there is no other definition
if Is_Itype (R_Node (Defining_Name)) or else
Is_Internal (R_Node (Defining_Name))
then
Result := Defining_Name;
else
Result := Corresponding_Type_Declaration (Encl_Constr);
if Is_Nil (Result) then
-- Encl_Constr is not a completion of an incomplete or
-- private type declaration
Result := Defining_Name;
else
Result := Names (Result) (1);
end if;
end if;
when A_Discriminant_Specification =>
Encl_Constr := Enclosing_Element (Encl_Constr);
Encl_Constr := Enclosing_Element (Encl_Constr);
case Declaration_Kind (Encl_Constr) is
when A_Task_Type_Declaration |
A_Protected_Type_Declaration |
A_Private_Type_Declaration |
A_Private_Extension_Declaration =>
First_Declaration :=
Corresponding_Type_Partial_View (Encl_Constr);
if not Is_Nil (First_Declaration) then
Discr_Part := Discriminant_Part (First_Declaration);
if Definition_Kind (Discr_Part) /=
A_Known_Discriminant_Part
then
First_Declaration := Nil_Element;
end if;
end if;
when An_Ordinary_Type_Declaration =>
First_Declaration :=
Corresponding_Type_Partial_View (Encl_Constr);
if not Is_Nil (First_Declaration) then
Discr_Part := Discriminant_Part (First_Declaration);
if Definition_Kind (Discr_Part) /=
A_Known_Discriminant_Part
then
First_Declaration := Nil_Element;
end if;
if not Is_Nil (First_Declaration)
and then
Declaration_Kind (First_Declaration) not in
An_Incomplete_Type_Declaration ..
A_Tagged_Incomplete_Type_Declaration
and then
not Is_Nil (Corresponding_Type_Partial_View
(First_Declaration))
then
Tmp :=
Corresponding_Type_Partial_View (First_Declaration);
if Definition_Kind (Discriminant_Part (Tmp)) =
A_Known_Discriminant_Part
then
First_Declaration := Tmp;
Discr_Part := Discriminant_Part (Tmp);
end if;
end if;
end if;
when others =>
Result := Defining_Name;
end case;
if Is_Nil (Result)
and then
Is_Nil (First_Declaration)
then
Result := Defining_Name;
end if;
if Is_Nil (Result) then
-- We have to traverse the doscriminant part of
-- First_Declaration to locate the corresponding discriminant
Process_Discriminant_Specifications : declare
Def_Name_Image : constant String :=
To_Lower (To_String (Defining_Name_Image (Defining_Name)));
Discr_Specs : constant Asis.Element_List :=
Discriminants (Discr_Part);
begin
Through_Discriminant_Specs : for J in Discr_Specs'Range loop
Process_Discriminant_Names : declare
Discr_Names : constant Asis.Element_List :=
Names (Discr_Specs (J));
begin
Through_Discr_Names : for J in Discr_Names'Range loop
if Def_Name_Image =
To_Lower (To_String (Defining_Name_Image
(Discr_Names (J))))
then
Result := Discr_Names (J);
exit Through_Discriminant_Specs;
end if;
end loop Through_Discr_Names;
end Process_Discriminant_Names;
end loop Through_Discriminant_Specs;
end Process_Discriminant_Specifications;
end if;
when others =>
Result := Defining_Name;
end case;
if Is_Nil (Result) then
-- here we have to compute the first definition of the formal
-- parameter in a subprogram spec/entry declaration
Process_Parameter_Specifications : declare
Def_Name_Image : constant String
:= To_Lower (To_String (Defining_Name_Image (Defining_Name)));
Param_Specs : constant Asis.Element_List
:= Parameter_Profile (First_Declaration);
begin
Through_Parameter_Specs : for I in Param_Specs'Range loop
Process_Parameter_Names : declare
Par_Names : constant Asis.Element_List :=
Names (Param_Specs (I));
begin
Through_Parameter_Names : for J in Par_Names'Range loop
if Def_Name_Image =
To_Lower (To_String (Defining_Name_Image
(Par_Names (J))))
then
Result := Par_Names (J);
exit Through_Parameter_Specs;
end if;
end loop Through_Parameter_Names;
end Process_Parameter_Names;
end loop Through_Parameter_Specs;
end Process_Parameter_Specifications;
end if;
pragma Assert (not Is_Nil (Result));
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Defining_Name,
Outer_Call => Package_Name & "Corresponding_First_Definition");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Corresponding_First_Definition",
Ex => Ex,
Arg_Element => Defining_Name);
end Corresponding_First_Definition;
----------------------------------------
-- Corresponding_Overridden_Operation --
----------------------------------------
function Corresponding_Overridden_Operation
(Declaration : Asis.Declaration)
return Asis.Declaration
is
Result : Asis.Element := Nil_Element;
Result_Unit : Compilation_Unit;
Result_Node : Node_Id;
Inherited : Boolean := False;
Association_Type : Node_Id;
begin
Check_Validity (Declaration,
Package_Name & "Corresponding_Overridden_Operation");
case Declaration_Kind (Declaration) is
when A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Instantiation |
A_Function_Instantiation |
A_Procedure_Body_Declaration |
A_Null_Procedure_Declaration |
A_Function_Body_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration =>
null;
when others =>
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name &
"Corresponding_Overridden_Operation",
Wrong_Kind => Int_Kind (Declaration));
end case;
if Is_Overriding_Operation (Declaration) then
if Declaration_Kind (Declaration) in
A_Procedure_Instantiation .. A_Function_Instantiation
then
Result_Node := Specification (Instance_Spec (Node (Declaration)));
Result_Node :=
Related_Instance (Defining_Unit_Name (Result_Node));
else
Result_Node :=
Defining_Unit_Name (Specification (Node (Declaration)));
end if;
Result_Node := Overridden_Operation (Result_Node);
Inherited := not Comes_From_Source (Result_Node);
if Inherited then
Association_Type := Result_Node;
Result_Node := Explicit_Parent_Subprogram (Result_Node);
Result_Unit :=
Enclosing_Unit (Encl_Cont_Id (Declaration), Association_Type);
Result := Node_To_Element_New (Node => Result_Node,
Node_Field_1 => Association_Type,
Inherited => True,
In_Unit => Result_Unit);
if Is_From_Instance (Association_Type) then
Set_From_Instance (Result, True);
else
Set_From_Instance (Result, False);
end if;
else
Result_Unit :=
Enclosing_Unit (Encl_Cont_Id (Declaration), Result_Node);
Result := Node_To_Element_New (Node => Result_Node,
In_Unit => Result_Unit);
end if;
Result := Enclosing_Element (Result);
if Special_Case (Result) = Expanded_Subprogram_Instantiation then
Result := Enclosing_Element (Result);
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name &
"Corresponding_Overridden_Operation");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Overridden_Operation",
Ex => Ex,
Arg_Element => Declaration);
end Corresponding_Overridden_Operation;
-----------------------------------------
-- Corresponding_Overridden_Operations --
-----------------------------------------
-- UNDER CONSTRUCTION!!!
pragma Warnings (Off);
function Corresponding_Overridden_Operations
(Declaration : Asis.Declaration)
return Asis.Element_List
is
Type_Def : Asis.Element;
Tmp_El : Asis.Element;
Result : Asis.Element := Nil_Element;
Arg_Node : Entity_Id;
Prim_Elmt : Elmt_Id;
Prim_Node : Entity_Id;
Res_Node : Node_Id;
begin
Check_Validity (Declaration,
Package_Name & "Corresponding_Overridden_Operations");
case Declaration_Kind (Declaration) is
when A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Instantiation |
A_Function_Instantiation |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Null_Procedure_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration =>
null;
when others =>
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name &
"Corresponding_Overridden_Operations",
Wrong_Kind => Int_Kind (Declaration));
end case;
if not Is_Overriding_Operation (Declaration) then
return Nil_Element_List;
end if;
-- Simple case: single inheritance:
Type_Def := Primitive_Owner (Declaration);
if Is_Nil (Definition_Interface_List (Type_Def)) then
return (1 => Corresponding_Overridden_Operation (Declaration));
end if;
-- General case - multiple inheritance
Asis_Element_Table.Init;
Tmp_El := First_Name (Declaration);
Arg_Node := R_Node (Tmp_El);
Tmp_El := First_Name (Enclosing_Element (Type_Def));
Prim_Elmt := First_Elmt (Primitive_Operations (R_Node (Tmp_El)));
Prim_Node := Node (Prim_Elmt);
while Present (Prim_Elmt) loop
-- Check if Prim_Node corresponds to overridden primitive:
if Present (Interface_Alias (Prim_Node))
and then
Alias (Prim_Node) = Arg_Node
then
Res_Node := Interface_Alias (Prim_Node);
-- ???
-- !!! Here we have to form the element representing overridden
-- subprogram and to add it to Asis_Element_Table
end if;
Prim_Elmt := Next_Elmt (Prim_Elmt);
Prim_Node := Node (Prim_Elmt);
end loop;
-- ???
Asis_Element_Table.Append
(Corresponding_Overridden_Operation (Declaration));
return Asis.Declaration_List
(Asis_Element_Table.Table (1 .. Asis_Element_Table.Last));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name &
"Corresponding_Overridden_Operations");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Overridden_Operations",
Ex => Ex,
Arg_Element => Declaration);
end Corresponding_Overridden_Operations;
pragma Warnings (On);
-- function Corresponding_Overridden_Operations
-- (Declaration : Asis.Declaration)
-- return Asis.Element_List
-- is
-- Type_Def : Asis.Element;
-- Result : Asis.Element := Nil_Element;
-- begin
-- Check_Validity (Declaration,
-- Package_Name & "Corresponding_Overridden_Operations");
-- case Declaration_Kind (Declaration) is
-- when A_Procedure_Declaration |
-- A_Function_Declaration |
-- A_Procedure_Instantiation |
-- A_Function_Instantiation |
-- A_Procedure_Body_Declaration |
-- A_Function_Body_Declaration |
-- A_Procedure_Renaming_Declaration |
-- A_Function_Renaming_Declaration =>
-- null;
-- when others =>
-- Raise_ASIS_Inappropriate_Element
-- (Diagnosis => Package_Name &
-- "Corresponding_Overridden_Operations");
-- end case;
-- if not Is_Overriding_Operation (Declaration) then
-- return Nil_Element_List;
-- end if;
-- -- Simple case: single inheritance:
-- Type_Def := Primitive_Owner (Declaration);
-- if Is_Nil (Definition_Interface_List (Type_Def)) then
-- return (1 => Corresponding_Overridden_Operation (Declaration));
-- end if;
-- -- General case - multiple inheritance
-- declare
-- Interfaces : Asis.Element_List :=
-- Definition_Interface_List (Type_Def);
-- Start_From : Positive := Interfaces'First;
-- begin
-- Asis_Element_Table.Init;
-- Result := Corresponding_Overridden_Operation (Declaration);
-- Asis_Element_Table.Append (Result);
-- Type_Def := Primitive_Owner (Declaration);
-- -- First, replace each interface name in Interfaces with the
-- -- corresponding type definition and check if we may start further
-- -- processing not from the first interface in the list
-- for J in Interfaces'Range loop
-- Interfaces (J) :=
-- Type_Declaration_View
-- (Corresponding_Name_Definition
-- (Normalize_Reference (Interfaces (J))));
-- if Is_Equal (Interfaces (J), Type_Def) then
-- Start_From := J + 1;
-- end if;
-- end loop;
-- for J in Start_From .. Interfaces'Last loop
-- Result := Get_Implemented_Op (Declaration, Interfaces (J));
-- if not Is_Nil (Result) then
-- Asis_Element_Table.Append (Result);
-- end if;
-- end loop;
-- return Asis.Declaration_List
-- (Asis_Element_Table.Table (1 .. Asis_Element_Table.Last));
-- end;
-- exception
-- when ASIS_Inappropriate_Element =>
-- raise;
-- when ASIS_Failed =>
-- if Status_Indicator = Unhandled_Exception_Error then
-- Add_Call_Information
-- (Argument => Declaration,
-- Outer_Call => Package_Name &
-- "Corresponding_Overridden_Operations");
-- end if;
-- raise;
-- when Ex : others =>
-- Report_ASIS_Bug
-- (Query_Name => Package_Name &
-- "Corresponding_Overridden_Operations",
-- Ex => Ex,
-- Arg_Element => Declaration);
-- end Corresponding_Overridden_Operations;
----------------------------------------------
-- Corresponding_Parent_Subtype_Unwind_Base --
----------------------------------------------
function Corresponding_Parent_Subtype_Unwind_Base
(Type_Definition : Asis.Type_Definition)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition);
Arg_Elem : Asis.Element := Type_Definition;
Result : Asis.Element := Nil_Element;
begin
Check_Validity (Type_Definition,
Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base");
if not (Arg_Kind = A_Derived_Type_Definition or else
Arg_Kind = A_Derived_Record_Extension_Definition)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base",
Wrong_Kind => Arg_Kind);
end if;
Result := Corresponding_Parent_Subtype (Arg_Elem);
if Is_Nil (Result) then
-- The only possible case for this - we have a 'Base attribute
-- reference as a parent subtype mark
Arg_Elem := Parent_Subtype_Indication (Arg_Elem);
Arg_Elem := Asis.Definitions.Subtype_Mark (Arg_Elem);
while Attribute_Kind (Arg_Elem) = A_Base_Attribute loop
Arg_Elem := Prefix (Arg_Elem);
end loop;
if Expression_Kind (Arg_Elem) = A_Selected_Component then
Arg_Elem := Selector (Arg_Elem);
end if;
Arg_Elem := Corresponding_Name_Declaration (Arg_Elem);
if Declaration_Kind (Result) = A_Subtype_Declaration then
Result := Corresponding_First_Subtype (Arg_Elem);
else
Result := Arg_Elem;
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Type_Definition,
Outer_Call => Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base",
Ex => Ex,
Arg_Element => Type_Definition);
end Corresponding_Parent_Subtype_Unwind_Base;
----------------------
-- CU_Requires_Body --
----------------------
function CU_Requires_Body (Right : Asis.Compilation_Unit) return Boolean is
Unit_Kind : constant Asis.Unit_Kinds := Kind (Right);
Result : Boolean := False;
begin
Check_Validity (Right, Package_Name & "CU_Requires_Body");
Reset_Context (Encl_Cont_Id (Right));
case Unit_Kind is
when A_Generic_Procedure |
A_Generic_Function |
A_Procedure |
A_Function |
A_Package |
A_Generic_Package =>
Result := Asis.Set_Get.Is_Body_Required (Right);
when others =>
null;
end case;
return Result;
end CU_Requires_Body;
---------------------------
-- Elements_Hash_Wrapper --
---------------------------
function Elements_Hash_Wrapper
(E : Asis.Element)
return Ada.Containers.Hash_Type
is
use Ada.Containers;
Asis_Hash : constant Asis.ASIS_Integer := abs Asis.Elements.Hash (E);
Result : Ada.Containers.Hash_Type;
begin
Result := Ada.Containers.Hash_Type (Asis_Hash);
return Result;
exception
when Constraint_Error =>
return 0;
end Elements_Hash_Wrapper;
-------------------------------
-- Element_Image_In_Template --
-------------------------------
function Element_Image_In_Template
(Element : Asis.Element)
return Program_Text
is
Tmp_Element : Asis.Element := Element;
begin
Check_Validity (Element, Package_Name & "Element_Image_In_Template");
if Is_Part_Of_Implicit (Element) or else
not Is_Part_Of_Instance (Element)
then
return "";
else
-- What we are doing is tricky, but it gives the fast and
-- easy-to-maintain solution: we consider the argument as if it is
-- NOT from the expanded template, and we use the normal ASIS
-- Element_Span function for it. The idea is to use Sloc fields
-- from the element node which point to the corresponding positions
-- in the template.
Set_From_Instance (Tmp_Element, False);
return Element_Image (Tmp_Element);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Element_Image_In_Template");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Element_Image_In_Template",
Ex => Ex,
Arg_Element => Element);
end Element_Image_In_Template;
------------------------------
-- Element_Span_In_Template --
------------------------------
function Element_Span_In_Template
(Element : Asis.Element)
return Asis.Text.Span
is
Tmp_Element : Asis.Element := Element;
begin
Check_Validity (Element, Package_Name & "Element_Span_In_Template");
if Is_Part_Of_Implicit (Element) or else
not Is_Part_Of_Instance (Element)
then
return Nil_Span;
else
-- What we are doing is tricky, but it gives the fast and
-- easy-to-maintain solution: we consider the argument as if it is
-- NOT from the expanded template, and we use the normal ASIS
-- Element_Span function for it. The idea is to use Sloc fields
-- from the element node which point to the corresponding positions
-- in the template.
Set_From_Instance (Tmp_Element, False);
return Element_Span (Tmp_Element);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Element_Span_In_Template");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Element_Span_In_Template",
Ex => Ex,
Arg_Element => Element);
end Element_Span_In_Template;
-----------------------------
-- Explicit_Type_Operators --
-----------------------------
function Explicit_Type_Operators
(Type_Definition : Asis.Type_Definition)
return Asis.Declaration_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition);
Parent_El : Asis.Element;
-- The construct where the argument type is defined
Type_Decl : Asis.Element;
-- Declaration of the argument type
In_Package_Spec : Boolean;
-- If the argument type is declared not in a package spec, but it is
-- a derived type, we have to count all the explicit overridings of
-- inherited operators, but if we are in the package spec, we just
-- collect all the explicitly declared type operators
Is_Formal_Type : Boolean;
begin
Check_Validity (Type_Definition,
Package_Name & "Explicit_Type_Operators");
if not (Arg_Kind in Internal_Type_Kinds or else
Arg_Kind in Internal_Formal_Type_Kinds or else
Arg_Kind in A_Private_Type_Definition ..
A_Protected_Definition)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Explicit_Type_Operators",
Wrong_Kind => Arg_Kind);
end if;
Type_Decl := Enclosing_Element (Type_Definition);
Parent_El := Enclosing_Element (Type_Decl);
Is_Formal_Type := Arg_Kind in Internal_Formal_Type_Kinds;
In_Package_Spec :=
Declaration_Kind (Parent_El) = A_Package_Declaration or else
(not Is_Formal_Type and then
Declaration_Kind (Parent_El) = A_Formal_Package_Declaration);
declare
All_Comp : constant Asis.Element_List := Components (Parent_El);
Start_From : Natural;
Result : Asis.Element_List (All_Comp'Range);
Res_First : constant Natural := Result'First;
Res_Last : Natural := Res_First - 1;
begin
for J in All_Comp'Range loop
if Is_Equal (Type_Decl, All_Comp (J)) then
Start_From := J + 1;
exit;
end if;
end loop;
for J in Start_From .. All_Comp'Last loop
if Is_Formal_Type
and then
Declaration_Kind (All_Comp (J)) not in A_Formal_Declaration
then
exit;
end if;
if Is_Type_Operator (All_Comp (J), Type_Decl)
and then
(In_Package_Spec
or else
Overrides_Type_Operator (All_Comp (J), Type_Decl))
then
Res_Last := Res_Last + 1;
Result (Res_Last) := All_Comp (J);
if Is_Bool_Eq_Declaration (All_Comp (J)) then
Res_Last := Res_Last + 1;
Result (Res_Last) :=
Corresponding_Equality_Operator (All_Comp (J));
end if;
end if;
end loop;
return Result (Res_First .. Res_Last);
end;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Type_Definition,
Outer_Call => Package_Name & "Explicit_Type_Operators");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Explicit_Type_Operators",
Ex => Ex,
Arg_Element => Type_Definition);
end Explicit_Type_Operators;
----------------
-- First_Name --
----------------
function First_Name (Dcl : Asis.Element) return Asis.Element is
Name_List : constant Asis.Element_List := Names (Dcl);
begin
return Name_List (Name_List'First);
end First_Name;
-------------------------------
-- Formal_Subprogram_Default --
-------------------------------
function Formal_Subprogram_Default
(Declaration : Asis.Generic_Formal_Parameter)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
begin
Arg_Node := Node (Declaration);
Check_Validity (Declaration, Package_Name & "Formal_Subprogram_Default");
if not (Arg_Kind = A_Formal_Procedure_Declaration or else
Arg_Kind = A_Formal_Function_Declaration)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Formal_Subprogram_Default",
Wrong_Kind => Arg_Kind);
end if;
if not Present (Default_Name (Arg_Node)) then
return Nil_Element;
end if;
return Node_To_Element_New (Node => Default_Name (Arg_Node),
Starting_Element => Declaration);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Formal_Subprogram_Default");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Formal_Subprogram_Default",
Ex => Ex,
Arg_Element => Declaration);
end Formal_Subprogram_Default;
---------------------
-- Full_Name_Image --
---------------------
function Full_Name_Image
(Expression : Asis.Expression)
return Program_Text
is
begin
case Expression_Kind (Expression) is
when An_Identifier .. An_Enumeration_Literal =>
return Asis.Expressions.Name_Image (Expression);
when A_Selected_Component =>
return Full_Name_Image (Prefix (Expression)) & '.' &
Asis.Expressions.Name_Image (Selector (Expression));
when others =>
Raise_ASIS_Inappropriate_Element
(Package_Name & "Full_Name_Image",
Wrong_Kind => Int_Kind (Expression));
end case;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name & "Full_Name_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Full_Name_Image",
Ex => Ex,
Arg_Element => Expression);
end Full_Name_Image;
-------------------------
-- Get_Call_Parameters --
-------------------------
package body Generic_Enum_Conversion is
type Table_Type is array (From) of To;
function Slow_Convert (X : From) return To;
function Init_Table return Table_Type;
----------------
-- Init_Table --
----------------
function Init_Table return Table_Type is
begin
return Result : Table_Type do
for F in From loop
Result (F) := Slow_Convert (F);
end loop;
end return;
end Init_Table;
------------------
-- Slow_Convert --
------------------
function Slow_Convert (X : From) return To is
begin
return To'Value (From'Image (X));
exception
when Constraint_Error =>
return Default;
end Slow_Convert;
-------------
-- Convert --
-------------
Table : constant Table_Type := Init_Table;
function Convert (X : From) return To is
begin
return Table (X);
end Convert;
end Generic_Enum_Conversion;
-------------------------
-- Get_Call_Parameters --
-------------------------
function Get_Call_Parameters
(Call : Asis.Element;
Normalized : Boolean := False)
return Asis.Element_List
is
begin
if Expression_Kind (Call) = A_Function_Call then
return Function_Call_Parameters (Call, Normalized);
else
return Call_Statement_Parameters (Call, Normalized);
end if;
end Get_Call_Parameters;
------------------------
-- Get_Implemented_Op --
------------------------
-- Under construction!
function Get_Implemented_Op
(Op_Decl : Asis.Element;
Type_Def : Asis.Element)
return Asis.Element
is
pragma Unreferenced (Op_Decl, Type_Def);
begin
return Nil_Element;
end Get_Implemented_Op;
-- function Get_Implemented_Op
-- (Op_Decl : Asis.Element;
-- Type_Def : Asis.Element)
-- return Asis.Element
-- is
-- Result : Asis.Element := Nil_Element;
-- Look_For_Proc : constant Boolean := Is_Procedure (Op_Decl);
-- Primitives : constant Asis.Element_List := Get_Primitives (Type_Def);
-- Arg_Chars : Name_Id;
-- Res_Chars : Name_Id;
-- Tmp_Node : Node_Id;
-- Tmp_El1 : Asis.Element;
-- Tmp_El2 : Asis.Element;
-- Success : Boolean;
-- Is_Controlling : Boolean;
-- Arg_Params : constant Asis.Element_List := Parameter_Profile (Op_Decl);
-- begin
-- Tmp_El := First_Name (Decl);
-- Arg_Chars := Chars (R_Node (Tmp_El));
-- Scan_Primitives : for J in Primitives'Range loop
-- if Look_For_Proc xor Is_Procedure (Primitives (J)) then
-- Res_Chars := Chars (R_Node (First_Name (Primitives (J))));
-- if Res_Chars = Arg_Chars
-- and then
-- Arg_Params'Length = Parameter_Profile (Primitives (J))'Length
-- then
-- -- Check parameter profiles:
-- Success := True;
-- if not Look_For_Proc then
-- -- Check for the result type
-- Tmp_El1 := First_Name (Op_Decl);
-- Tmp_El2 := First_Name (Primitives (J));
-- if Has_Controlling_Result (R_Node (Tmp_El1)) xor
-- Has_Controlling_Result (R_Node (Tmp_El2))
-- then
-- Success := False;
-- else
-- Is_Controlling :=
-- Has_Controlling_Result (R_Node (Tmp_El1));
-- Tmp_El1 := Result_Profile (Op_Decl);
-- Tmp_El2 := Result_Profile (Primitives (J));
-- if Definition_Kind (Tmp_El1) = An_Access_Definition
-- xor
-- Definition_Kind (Tmp_El2) = An_Access_Definition
-- then
-- Success := False;
-- elsif not Is_Controlling then
-- Succes := Are_Type_Conforming (Tmp_El1, Tmp_El2);
-- end if;
-- end if;
-- end if;
-- end if;
-- if Success then
-- declare
-- Res_Params : constant Asis.Element_List :=
-- Parameter_Profile (Primitives (J));
-- begin
-- Scan_Params : for P in Arg_Params'Range loop
-- if not Are_Conformant
-- (Arg_Params (P), Res_Params (P))
-- then
-- Success := False;
-- exit Scan_Params;
-- end if;
-- end loop;
-- end;
-- end if;
-- if Success then
-- Result := Primitives (J)
-- exit Scan_Primitives;
-- end if;
-- end if;
-- end if;
-- end loop Scan_Primitives;
-- return Result;
-- end Get_Implemented_Op;
------------------------
-- Get_Last_Component --
------------------------
function Get_Last_Component (E : Asis.Element) return Asis.Element is
Child_Access : constant Func_Elem_Array := Appropriate_Queries (E);
Child : Asis.Element := Asis.Nil_Element;
begin
Check_Validity (E, Package_Name & "Get_Last_Component");
if Is_Nil (E) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Get_Last_Component",
Wrong_Kind => Not_An_Element);
end if;
if Debug_Flag_X then
Write_Str (" Get_Last_Component - called for ");
Write_Str (Internal_Element_Kinds'Image (Int_Kind (E)));
Write_Eol;
end if;
for Each_Query in reverse Child_Access'Range loop
case Child_Access (Each_Query).Query_Kind is
when Bug | Boolean_Query | CU_Query_Kinds =>
null;
when Single_Element_Query =>
Child := Child_Access (Each_Query).Func_Simple (E);
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (E);
begin
if not Is_Nil (Child_List) then
Child := Child_List (Child_List'Last);
end if;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(E, Child_Access (Each_Query).Bool);
begin
if not Is_Nil (Child_List) then
Child := Child_List (Child_List'Last);
end if;
end;
end case;
exit when not Is_Nil (Child);
end loop;
if Debug_Flag_X then
Write_Str (" Get_Last_Component - returns ");
Write_Str (Internal_Element_Kinds'Image (Int_Kind (Child)));
Write_Eol;
end if;
return Child;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => E,
Outer_Call => Package_Name & "Get_Last_Component");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Get_Last_Component",
Ex => Ex,
Arg_Element => E);
end Get_Last_Component;
-----------------------
-- Get_LF_From_Ureal --
-----------------------
function Get_LF_From_Ureal (U : Ureal) return Long_Long_Float is
Result : Long_Long_Float;
Base : constant Nat := Rbase (U);
U_Num : constant Uint := Numerator (U);
U_Denum : constant Uint := Denominator (U);
Num : Long_Long_Integer;
Denum : Long_Long_Integer;
begin
UI_Image (U_Num, Format => Decimal);
Num := Long_Long_Integer'Value (UI_Image_Buffer (1 .. UI_Image_Length));
UI_Image (U_Denum, Format => Decimal);
Denum :=
Long_Long_Integer'Value (UI_Image_Buffer (1 .. UI_Image_Length));
if Base /= 0 then
Denum := Long_Long_Integer (2 ** Natural (Denum));
end if;
Result := Long_Long_Float (Num) / Long_Long_Float (Denum);
if UR_Is_Negative (U) then
Result := -Result;
end if;
return Result;
end Get_LF_From_Ureal;
----------------------------
-- Has_Controlling_Result --
----------------------------
function Has_Controlling_Result
(Declaration : Asis.Declaration)
return Boolean
is
Entity : Entity_Id;
Result : Boolean := False;
begin
Check_Validity
(Declaration,
Package_Name & "Has_Controlling_Result");
if Is_Dispatching_Operation (Declaration) then
Entity := Defining_Unit_Name (Specification (Node (Declaration)));
if Ekind (Entity) = E_Function then
Result := Has_Controlling_Result (Entity);
end if;
end if;
return Result;
end Has_Controlling_Result;
--------------------------
-- Has_Enumeration_Type --
--------------------------
function Has_Enumeration_Type
(Expression : Asis.Expression)
return Boolean
is
Result : Boolean := False;
begin
Check_Validity (Expression, Package_Name & "Has_Enumeration_Type");
if Ekind (Etype (R_Node (Expression))) in Enumeration_Kind then
Result := True;
end if;
return Result;
end Has_Enumeration_Type;
----------------------
-- Has_Integer_Type --
----------------------
function Has_Integer_Type (Expression : Asis.Expression) return Boolean is
Result : Boolean := False;
begin
Check_Validity (Expression, Package_Name & "Has_Integer_Type");
if Ekind (Etype (R_Node (Expression))) in Integer_Kind then
Result := True;
end if;
return Result;
end Has_Integer_Type;
------------------------------
-- Inherited_Type_Operators --
------------------------------
function Inherited_Type_Operators
(Type_Definition : Asis.Type_Definition)
return Asis.Declaration_List
is
Arg_Kind : constant Internal_Element_Kinds :=
Int_Kind (Type_Definition);
Type_Decl : Asis.Element;
begin
Check_Validity (Type_Definition,
Package_Name & "Inherited_Type_Operators");
if not (Arg_Kind in Internal_Type_Kinds or else
Arg_Kind in Internal_Formal_Type_Kinds or else
Arg_Kind in A_Private_Type_Definition ..
A_Protected_Definition)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Inherited_Type_Operators",
Wrong_Kind => Arg_Kind);
end if;
if not (Arg_Kind = A_Private_Extension_Definition or else
Arg_Kind = A_Derived_Type_Definition or else
Arg_Kind = A_Derived_Record_Extension_Definition or else
Arg_Kind = A_Formal_Derived_Type_Definition)
then
return Nil_Element_List;
end if;
declare
All_Inherited_Ops : constant Asis.Declaration_List :=
Implicit_Inherited_Subprograms (Type_Definition);
Result : Asis.Declaration_List (All_Inherited_Ops'Range);
Res_First : constant Natural := Result'First;
Res_Last : Natural := Res_First - 1;
begin
Type_Decl := Enclosing_Element (Type_Definition);
for J in All_Inherited_Ops'Range loop
if Is_Type_Operator (All_Inherited_Ops (J), Type_Decl) then
Res_Last := Res_Last + 1;
Result (Res_Last) := All_Inherited_Ops (J);
end if;
end loop;
return Result (Res_First .. Res_Last);
end;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Type_Definition,
Outer_Call => Package_Name & "Inherited_Type_Operators");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Inherited_Type_Operators",
Ex => Ex,
Arg_Element => Type_Definition);
end Inherited_Type_Operators;
--------------------
-- Is_Aspect_Mark --
--------------------
function Is_Aspect_Mark (Element : Asis.Element) return Boolean is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Expression_Kind (Element) = An_Identifier or else
Attribute_Kind (Element) = A_Class_Attribute
then
Tmp := R_Node (Element);
Result := Nkind (Parent (Tmp)) = N_Aspect_Specification and then
Tmp = Sinfo.Identifier (Parent (Tmp));
end if;
return Result;
end Is_Aspect_Mark;
-----------------------------------
-- Is_Aspect_Specific_Identifier --
-----------------------------------
function Is_Aspect_Specific_Identifier
(Element : Asis.Element)
return Boolean
is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Expression_Kind (Element) = An_Identifier then
Tmp := R_Node (Element);
if Nkind (Tmp) = N_Identifier
and then
not Present (Entity (Tmp))
then
Tmp := Parent (Tmp);
if Present (Tmp) then
case Nkind (Tmp) is
when N_Component_Association =>
if Nkind (Parent (Parent (Tmp))) =
N_Aspect_Specification
then
Result := True;
end if;
when N_Aspect_Specification =>
Result := R_Node (Element) /= Sinfo.Identifier (Tmp);
-- ... to be continued...
when others =>
null;
end case;
end if;
end if;
end if;
return Result;
end Is_Aspect_Specific_Identifier;
----------------------------
-- Is_Bool_Eq_Declaration --
----------------------------
function Is_Bool_Eq_Declaration
(Declaration : Asis.Element)
return Boolean
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Result : Boolean := False;
Op_Node : Node_Id;
Op_Etype : Node_Id;
begin
Check_Validity (Declaration, Package_Name & "Is_Bool_Eq_Declaration");
if Special_Case (Declaration) /= Is_From_Imp_Neq_Declaration
and then
(Arg_Kind = A_Function_Declaration
or else
(Arg_Kind = A_Function_Body_Declaration
and then
Acts_As_Spec (Declaration))
or else
(Arg_Kind = A_Function_Renaming_Declaration
and then
not Is_Renaming_As_Body (Declaration)))
then
Op_Node := Defining_Unit_Name (Specification (Node (Declaration)));
if Nkind (Op_Node) = N_Defining_Program_Unit_Name then
Op_Node := Defining_Identifier (Op_Node);
end if;
Op_Etype := Etype (Op_Node);
if Is_Generic_Instance (Op_Node) then
Op_Node :=
Defining_Unit_Name (Node (Enclosing_Element (Declaration)));
end if;
if Nkind (Op_Node) = N_Defining_Program_Unit_Name then
Op_Node := Defining_Identifier (Op_Node);
end if;
if Nkind (Op_Node) = N_Defining_Operator_Symbol
and then
Chars (Op_Node) = Name_Op_Eq
and then
Op_Etype = Standard_Boolean
then
Result := True;
end if;
end if;
return Result;
end Is_Bool_Eq_Declaration;
-------------------
-- Is_Class_Wide --
-------------------
function Is_Class_Wide
(Declaration : Asis.Declaration)
return Boolean
is
Result : Boolean := False;
Subtype_Entity : Entity_Id;
begin
if Declaration_Kind (Declaration) = A_Subtype_Declaration then
Subtype_Entity := R_Node (Declaration);
Subtype_Entity := Defining_Identifier (Subtype_Entity);
Result := Ekind (Subtype_Entity) = E_Class_Wide_Subtype;
end if;
return Result;
end Is_Class_Wide;
------------------
-- Is_Completed --
------------------
function Is_Completed (Declaration : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Declaration, Package_Name & "Is_Completed");
-- JUNK IMPLEMENTATION!!!
if not (Arg_Kind = A_Procedure_Declaration or else
Arg_Kind = A_Function_Declaration)
or else
Is_Part_Of_Inherited (Declaration)
then
return False;
end if;
Arg_Node := Defining_Unit_Name (Specification (Node (Declaration)));
Result := Has_Completion (Arg_Node);
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Is_Completed");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Completed",
Ex => Ex,
Arg_Element => Declaration);
end Is_Completed;
-----------------------------------
-- Is_Default_For_Null_Procedure --
-----------------------------------
function Is_Default_For_Null_Procedure
(Reference : Asis.Element)
return Boolean
is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Expression_Kind (Reference) = An_Identifier
and then
Is_Part_Of_Instance (Reference)
then
Tmp := R_Node (Reference);
if Nkind (Tmp) in N_Has_Entity then
Tmp := Entity (Tmp);
if Present (Tmp) and then Ekind (Tmp) = E_Procedure then
Tmp := Parent (Parent (Tmp));
Result :=
Nkind (Tmp) = N_Subprogram_Body
and then
Nkind (Parent (Tmp)) = N_Package_Specification;
end if;
end if;
end if;
return Result;
end Is_Default_For_Null_Procedure;
----------------------------
-- Is_Expanded_Subprogram --
----------------------------
function Is_Expanded_Subprogram (N : Node_Id) return Boolean is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Nkind (N) = N_Subprogram_Declaration then
Tmp := Defining_Unit_Name (Specification (N));
if Nkind (Tmp) = N_Defining_Program_Unit_Name then
Tmp := Defining_Identifier (Tmp);
end if;
if Is_Generic_Instance (Tmp) then
Result := True;
end if;
end if;
return Result;
end Is_Expanded_Subprogram;
-----------------
-- Is_Exported --
-----------------
function Is_Exported (Defining_Name : Asis.Defining_Name) return Boolean is
Arg_Node : Node_Id;
Tmp : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Defining_Name, Package_Name & "Is_Exported");
if Int_Kind (Defining_Name) not in Internal_Defining_Name_Kinds then
return False;
end if;
Arg_Node := R_Node (Defining_Name);
if Nkind (Arg_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Defining_Identifier (Arg_Node);
end if;
if Ekind (Arg_Node) = E_Subprogram_Body then
-- Go to the corresponding spec entity
Tmp := Parent (Arg_Node);
while Nkind (Tmp) not in N_Subprogram_Specification loop
Tmp := Parent (Tmp);
end loop;
Tmp := Parent (Tmp);
Tmp := Corresponding_Decl_Node (Tmp);
Arg_Node := Defining_Unit_Name (Specification (Tmp));
if Nkind (Arg_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Defining_Identifier (Arg_Node);
end if;
end if;
Result := Is_Exported (Arg_Node);
return Result;
end Is_Exported;
-------------------------------------
-- Is_From_Import_Procedure_Pragma --
-------------------------------------
function Is_From_Import_Procedure_Pragma (N : Node_Id) return Boolean is
Tmp : Node_Id := Parent (N);
Result : Boolean := False;
begin
if Nkind (Tmp) = N_Indexed_Component then
Tmp := Parent (Tmp);
if Nkind (Tmp) = N_Aggregate then
Tmp := Parent (Tmp);
if Nkind (Tmp) = N_Pragma_Argument_Association then
Tmp := Pragma_Identifier (Parent (Tmp));
Result := Chars (Tmp) = Name_Import_Procedure
or else
Chars (Tmp) = Name_Import_Valued_Procedure;
end if;
end if;
end if;
return Result;
end Is_From_Import_Procedure_Pragma;
--------------------------
-- Is_From_SPARK_Aspect --
--------------------------
function Is_From_SPARK_Aspect (E : Asis.Element) return Boolean is
Result : Boolean := False;
N : Node_Id;
begin
-- If and when we get a flag in the tree that marks SPARK-specific
-- aspects, this code should be replaced with the use of this flag!
if not Is_Nil (E) then
N := R_Node (E);
loop
exit when No (N) or else
Nkind (N) in
N_Pragma | N_Aspect_Specification |
N_Statement_Other_Than_Procedure_Call |
N_Procedure_Call_Statement | N_Declaration;
N := Parent (N);
end loop;
if Nkind (N) = N_Pragma
and then
Present (Corresponding_Aspect (N))
then
N := Corresponding_Aspect (N);
end if;
if Nkind (N) = N_Aspect_Specification then
N := Sinfo.Identifier (N);
Result := Chars (N) in Name_Abstract_State |
Name_Depends |
Name_Global |
Name_Initial_Condition |
Name_Initializes |
Name_Refined_Depends |
Name_Refined_Global |
Name_Refined_Post |
Name_Refined_State;
end if;
end if;
return Result;
end Is_From_SPARK_Aspect;
-----------------------------------------------
-- Is_Sub_Package_Implemented_As_Child_Unit --
-----------------------------------------------
function Is_Sub_Package_Implemented_As_Child_Unit
(Compilation_Unit : Asis.Compilation_Unit)
return Boolean
is
Nam : Node_Id;
Prf : Node_Id;
Sel : Node_Id;
Result : Boolean := False;
begin
-- See Rtsfind.Is_Text_IO_Kludge_Unit
if Unit_Class (Compilation_Unit) in
A_Private_Declaration | A_Private_Body
and then
(Unit_Kind (Compilation_Unit) = A_Generic_Package
or else
(Unit_Kind (Compilation_Unit) = A_Package_Body
and then
Unit_Kind (Corresponding_Declaration (Compilation_Unit)) =
A_Generic_Package))
then
Nam := Unit (Top (Compilation_Unit));
if Nkind (Nam) = N_Generic_Package_Declaration then
Nam := Specification (Nam);
end if;
Nam := Defining_Unit_Name (Nam);
if Nkind (Nam) = N_Defining_Program_Unit_Name then
Prf := Sinfo.Name (Nam);
Sel := Defining_Identifier (Nam);
if Nkind (Sel) = N_Defining_Identifier
and then
Nkind (Prf) = N_Expanded_Name
and then
Chars (Sel) in Text_IO_Package_Name
then
Sel := Selector_Name (Prf);
Prf := Prefix (Prf);
Result :=
Nkind (Prf) = N_Identifier
and then
Chars (Prf) = Name_Ada
and then
Nkind (Sel) = N_Identifier
and then
Chars (Sel) in
Name_Text_IO | Name_Wide_Text_IO | Name_Wide_Wide_Text_IO;
end if;
end if;
end if;
return Result;
end Is_Sub_Package_Implemented_As_Child_Unit;
---------------------------------
-- Is_Implicit_Neq_Declaration --
---------------------------------
function Is_Implicit_Neq_Declaration
(Declaration : Asis.Element)
return Boolean
is
begin
return
Declaration_Kind (Declaration) = A_Function_Declaration
and then
Special_Case (Declaration) = Is_From_Imp_Neq_Declaration;
end Is_Implicit_Neq_Declaration;
--------------
-- Is_Label --
--------------
function Is_Label (Defining_Name : Asis.Defining_Name) return Boolean is
N : constant Node_Id := Node (Defining_Name);
Result : Boolean := False;
begin
if Int_Kind (Defining_Name) = A_Defining_Identifier then
if Nkind (N) = N_Label then
Result := True;
elsif Nkind (N) = N_Identifier
and then
Nkind (Parent (N)) = N_Loop_Statement
and then
Nkind (Original_Node (Parent (N))) = N_Goto_Statement
then
-- An infinite loop is implemented with goto statement
Result := True;
end if;
end if;
return Result;
end Is_Label;
--------------------------
-- Is_Main_Unit_In_Tree --
--------------------------
function Is_Main_Unit_In_Tree
(Right : Asis.Compilation_Unit)
return Boolean
is
Arg_Kind : constant Unit_Kinds := Kind (Right);
Arg_Unit_Id : Unit_Id;
Arg_Cont_Id : Context_Id;
begin
Check_Validity (Right, Package_Name & "Is_Main_Unit_In_Tree");
Arg_Cont_Id := Encl_Cont_Id (Right);
Reset_Context (Arg_Cont_Id);
Arg_Unit_Id := Get_Unit_Id (Right);
if Arg_Kind in A_Procedure .. A_Protected_Body_Subunit then
return GNAT_Compilation_Dependencies (Arg_Unit_Id) /=
Nil_Unit_Id_List;
else
return False;
end if;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Is_Main_Unit_In_Tree");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Main_Unit_In_Tree",
Ex => Ex,
Arg_CU => Right);
end Is_Main_Unit_In_Tree;
-----------------
-- Is_Obsolete --
-----------------
function Is_Obsolete (Right : Asis.Compilation_Unit) return Boolean is
Arg_Kind : constant Unit_Kinds := Kind (Right);
Arg_Id : Unit_Id;
Result : Boolean := True;
begin
Check_Validity (Right, Package_Name & "Is_Obsolete");
case Arg_Kind is
when Not_A_Unit |
A_Nonexistent_Declaration |
A_Nonexistent_Body |
An_Unknown_Unit =>
null;
when others =>
Arg_Id := Get_Unit_Id (Right);
if Arg_Id = Standard_Id then
Result := False;
else
Result := not (Source_Status (Right) = Up_To_Date);
end if;
end case;
return Result;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Is_Obsolete");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Obsolete",
Ex => Ex,
Arg_CU => Right);
end Is_Obsolete;
-----------------------------
-- Is_Overriding_Operation --
-----------------------------
function Is_Overriding_Operation
(Declaration : Asis.Element)
return Boolean
is
Result : Boolean := False;
Entity_N : Entity_Id := Empty;
begin
case Declaration_Kind (Declaration) is
when A_Procedure_Instantiation |
A_Function_Instantiation =>
Entity_N := Specification (Instance_Spec (Node (Declaration)));
Entity_N := Related_Instance (Defining_Unit_Name (Entity_N));
when A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Null_Procedure_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration =>
if not Is_Part_Of_Implicit (Declaration) then
Entity_N := Specification (Node (Declaration));
Entity_N := Defining_Unit_Name (Entity_N);
end if;
when others =>
null;
end case;
if Present (Entity_N)
and then
Nkind (Entity_N) in
N_Defining_Identifier | N_Defining_Operator_Symbol
then
Result := Present (Overridden_Operation (Entity_N));
end if;
return Result;
end Is_Overriding_Operation;
----------------------------
-- Is_Predefined_Operator --
----------------------------
function Is_Predefined_Operator
(Operator : Asis.Element)
return Boolean
is
Result : Boolean := False;
Entity_N : Entity_Id;
begin
if Expression_Kind (Operator) = An_Operator_Symbol then
Entity_N := Entity (Node (Operator));
Result := Present (Entity_N) and then Is_Predefined (Entity_N);
end if;
return Result;
end Is_Predefined_Operator;
----------------
-- Is_Private --
----------------
function Is_Private (Declaration : Asis.Element) return Boolean is
Arg_Element : Element := Declaration;
Result : Boolean := False;
Next_Node : Node_Id;
Enclosing_List : List_Id;
Enclosing_Node : Node_Id;
begin
Check_Validity (Declaration, Package_Name & "Is_Private");
if Declaration_Kind (Declaration) = Not_A_Declaration or else
Declaration_Kind (Declaration) in
A_Loop_Parameter_Specification .. An_Element_Iterator_Specification
then
return False;
end if;
-- In case of an implicit Element we go to the "enclosing" explicit
-- Element to get the node stored in R_Node field which can safely be
-- used for tree traversal (for implicit Elements R_Node may be of
-- special use and it may have the Parent field set to Empty
while Is_Part_Of_Implicit (Arg_Element)
and then
Special_Case (Arg_Element) /= From_Limited_View
loop
Arg_Element := Enclosing_Element (Arg_Element);
end loop;
Next_Node := R_Node (Arg_Element);
while Nkind (Next_Node) /= N_Compilation_Unit and then
not Is_List_Member (Next_Node)
loop
Next_Node := Parent (Next_Node);
end loop;
while Nkind (Next_Node) /= N_Compilation_Unit loop
-- If we are here, we have Next_Node being a list member
Enclosing_List := List_Containing (Next_Node);
Enclosing_Node := Parent (Enclosing_List);
case Nkind (Enclosing_Node) is
when N_Statement_Other_Than_Procedure_Call =>
-- We can not be in any private part
exit;
when N_Package_Specification |
N_Task_Definition |
N_Protected_Definition =>
if Enclosing_List = Private_Declarations (Enclosing_Node) then
Result := True;
exit;
end if;
when others =>
null;
end case;
Next_Node := Parent (Next_Node);
while Nkind (Next_Node) /= N_Compilation_Unit and then
not Is_List_Member (Next_Node)
loop
Next_Node := Parent (Next_Node);
end loop;
end loop;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Is_Private");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Private",
Ex => Ex,
Arg_Element => Declaration);
end Is_Private;
------------------
-- Is_Procedure --
------------------
function Is_Procedure (Decl : Asis.Element) return Boolean is
Result : Boolean := False;
begin
case Declaration_Kind (Decl) is
when A_Procedure_Declaration |
A_Procedure_Instantiation |
A_Procedure_Body_Declaration |
A_Null_Procedure_Declaration |
A_Procedure_Renaming_Declaration =>
Result := True;
when others =>
null;
end case;
return Result;
end Is_Procedure;
-----------------
-- Is_RCI_Unit --
-----------------
function Is_RCI_Unit (C : Asis.Compilation_Unit) return Boolean is
Arg_Node : Node_Id;
Result : Boolean := False;
begin
if Is_Standard (C) then
return False;
end if;
case Unit_Kind (C) is
when A_Package |
A_Procedure_Body |
A_Function_Body |
A_Generic_Package =>
Arg_Node := Unit (Top (C));
Arg_Node := Defining_Unit_Name (Specification (Arg_Node));
if Nkind (Arg_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Defining_Identifier (Arg_Node);
end if;
Result := Is_Remote_Call_Interface (Arg_Node);
when others => null;
end case;
return Result;
end Is_RCI_Unit;
-------------------------
-- Is_Renaming_As_Body --
-------------------------
function Is_Renaming_As_Body (Declaration : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Declaration, Package_Name & "Is_Renaming_As_Body");
if Arg_Kind = A_Procedure_Renaming_Declaration or else
Arg_Kind = A_Function_Renaming_Declaration
then
Arg_Node := R_Node (Declaration);
if Nkind (Arg_Node) /= N_Subprogram_Declaration then
Result := Present (Corresponding_Spec (Arg_Node));
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Is_Renaming_As_Body");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Renaming_As_Body",
Ex => Ex,
Arg_Element => Declaration);
end Is_Renaming_As_Body;
---------------
-- Is_Static --
---------------
function Is_Static (Element : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Element);
Arg_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Element, Package_Name & "Is_Static");
if Arg_Kind in Internal_Expression_Kinds and then
Is_True_Expression (Element)
then
Result := Sinfo.Is_Static_Expression (R_Node (Element));
elsif Arg_Kind = A_Range_Attribute_Reference or else
Arg_Kind =
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
or else
Arg_Kind = A_Discrete_Range_Attribute_Reference
then
Arg_Node := R_Node (Element);
if Nkind (Arg_Node) = N_Range_Constraint then
Arg_Node := Range_Expression (Arg_Node);
end if;
if Nkind (Arg_Node) = N_Range and then
Is_Static_Expression (Low_Bound (Arg_Node)) and then
Is_Static_Expression (High_Bound (Arg_Node))
then
Result := True;
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Is_Static");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Static",
Ex => Ex,
Arg_Element => Element);
end Is_Static;
-----------------------
-- Is_Tagged_Type_Eq --
-----------------------
function Is_Tagged_Type_Eq
(Declaration : Asis.Element)
return Boolean
is
Entity : Entity_Id;
Result : Boolean := False;
begin
if Is_Bool_Eq_Declaration (Declaration)
or else
Is_Implicit_Neq_Declaration (Declaration)
then
Entity := Node (Declaration);
Entity := Defining_Unit_Name (Specification (Entity));
Result := Is_Dispatching_Operation (Entity);
end if;
return Result;
end Is_Tagged_Type_Eq;
------------------------
-- Is_True_Expression --
------------------------
function Is_True_Expression
(Expression : Asis.Expression)
return Boolean
is
Arg_Node : Node_Id;
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Expression);
Expr_Chars : Name_Id;
Entity_Node : Entity_Id;
Result : Boolean := True;
-- the idea of the implementation is to find out the cases when
-- Expression is NOT a true exception, so we initialize Result
-- as True
begin
Check_Validity (Expression, Package_Name & "Is_True_Expression");
if Is_From_SPARK_Aspect (Expression)
and then
Arg_Kind = A_Positional_Array_Aggregate
and then
Etype (Node (Expression)) = Any_Composite
then
return False;
end if;
-- A special case of an aggregate that is a component of 'Update
-- attribute
if Arg_Kind in A_Record_Aggregate | A_Named_Array_Aggregate then
Arg_Node := Node (Expression);
Arg_Node := Parent (Arg_Node);
if Nkind (Arg_Node) = N_Attribute_Reference
and then
Attribute_Name (Arg_Node) = Name_Update
then
return False;
end if;
end if;
Arg_Node := Node (Expression);
if Arg_Kind = A_Selected_Component
and then
Nkind (Arg_Node) = N_Function_Call
and then
Nkind (R_Node (Expression)) = N_Expanded_Name
then
-- In some cases (in particular when this expanded name is a
-- parameter of an infix call to predefined "=") a reference to an
-- overloaded enumeration literal in the form of an expanded name is
-- transformed into a function call, and the right structure can be
-- found in the rewritten node only.
Arg_Node := R_Node (Expression);
end if;
if Arg_Kind not in Internal_Expression_Kinds then
return False;
end if;
if Nkind (Arg_Node) = N_Identifier and then
Nkind (Parent (Arg_Node)) = N_Expanded_Name and then
Arg_Node = Selector_Name (Parent (Arg_Node))
then
-- selector in an expanded name - all the semantic fields
-- are set for the whole name, but not for this selector.
-- So:
Arg_Node := Parent (Arg_Node);
end if;
if Nkind (Arg_Node) not in N_Has_Etype or else
No (Etype (Arg_Node)) or else
Is_Anonymous (Ekind (Etype (Arg_Node))) or else
Ekind (Etype (Arg_Node)) = E_Subprogram_Type
then
-- Expression may be a true expression, but it may have a type which
-- cannot be represented in ASIS (such as an anonymous access type),
-- in such cases we also classify it as being not true expression
Result := False;
else
-- in some cases more detailed analysis is required.
-- ??? This part may require some more analysis - it may be
-- somewhat redundant
case Arg_Kind is
when An_Identifier | A_Selected_Component =>
-- and here we have to investigate whether or not this
-- Expression is a "naming expression"
if Special_Case (Expression) = Rewritten_Named_Number then
return True;
end if;
-- ??? <tree problem 1>
-- this fragment should be revised when the problem is fixed (as it should)
if Nkind (Arg_Node) = N_Selected_Component and then
Etype (Arg_Node) = Any_Type
-- for now (GNAT 3.05) this means, that Expression is an
-- expanded name of the character literal of ether a
-- predefined character type or of the type derived from a
-- predefined character type; the problem is that the
-- Entity field is not set for such a node
then
return True;
end if;
-- ??? <tree problem 1> - end
-- now taking the Entity field (if any) and looking,
-- what we have:
if Nkind (Arg_Node) = N_Selected_Component then
Entity_Node := Entity (Selector_Name (Arg_Node));
elsif Nkind (Arg_Node) = N_Attribute_Definition_Clause then
-- the attribute designator in an attribute definition
-- clause
Entity_Node := Empty;
else
Entity_Node := Entity (Arg_Node);
end if;
if No (Entity_Node) then
Result := False;
elsif Ekind (Entity_Node) = E_Enumeration_Literal then
null;
else
case Ekind (Entity_Node) is
-- the first choice in this case statement should
-- filter in entities which *ARE* expressions in Ada
-- sense
when E_Variable =>
-- tasks and protected objects declared by _single_
-- task/protected declarations do not have
-- corresponding type declarations which can be
-- represented in ASIS
Result := Comes_From_Source (Parent (Entity_Node));
when E_Component |
E_Constant |
E_Discriminant |
E_Loop_Parameter |
E_In_Out_Parameter |
E_In_Parameter |
E_Out_Parameter |
E_Generic_In_Out_Parameter |
E_Generic_In_Parameter |
E_Named_Integer |
E_Named_Real |
E_Enumeration_Literal |
-- ??? (see elsif path)
-- enumeration literals are not treated as
-- functions in ASIS
E_Entry_Index_Parameter |
E_Protected_Object =>
null;
-- simply keeping the initialization of Result
when others =>
Result := False;
end case;
end if;
when Internal_Operator_Symbol_Kinds =>
Result := False;
when Internal_Attribute_Reference_Kinds =>
case Internal_Attribute_Reference_Kinds (Arg_Kind) is
when An_Adjacent_Attribute |
A_Base_Attribute |
A_Ceiling_Attribute |
A_Class_Attribute |
A_Compose_Attribute |
A_Copy_Sign_Attribute |
An_Exponent_Attribute |
A_Floor_Attribute |
A_Fraction_Attribute |
An_Image_Attribute |
An_Input_Attribute |
A_Leading_Part_Attribute |
A_Machine_Attribute |
A_Max_Attribute |
A_Min_Attribute |
A_Model_Attribute |
An_Output_Attribute |
A_Pos_Attribute |
A_Pred_Attribute |
A_Range_Attribute |
A_Read_Attribute |
A_Remainder_Attribute |
A_Round_Attribute |
A_Rounding_Attribute |
A_Scaling_Attribute |
A_Succ_Attribute |
A_Truncation_Attribute |
An_Unbiased_Rounding_Attribute |
A_Val_Attribute |
A_Value_Attribute |
A_Wide_Image_Attribute |
A_Wide_Value_Attribute |
A_Write_Attribute =>
Result := False;
when An_Implementation_Defined_Attribute =>
Expr_Chars := Attribute_Name (Arg_Node);
if Expr_Chars = Name_Abort_Signal or else
Expr_Chars = Name_Elab_Body or else
Expr_Chars = Name_Elab_Spec
then
Result := False;
end if;
when others =>
null;
end case;
when A_Positional_Array_Aggregate | A_Named_Array_Aggregate =>
if Nkind (Parent (Arg_Node)) =
N_Enumeration_Representation_Clause
or else
Is_Typeless_Subaggregate (Arg_Node)
then
Result := False;
end if;
when others =>
null;
end case;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name & "Is_True_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_True_Expression",
Ex => Ex,
Arg_Element => Expression);
end Is_True_Expression;
----------------------
-- Is_Type_Operator --
----------------------
function Is_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Op_Decl);
Result : Boolean := False;
Next_Type : Asis.Element;
begin
if (Arg_Kind = A_Function_Declaration
or else
((Arg_Kind = A_Function_Body_Declaration
or else
Arg_Kind = A_Function_Body_Stub
or else
Arg_Kind = A_Function_Renaming_Declaration)
and then
not (Is_Equal (Corresponding_Declaration (Op_Decl), Op_Decl)))
or else
Arg_Kind = A_Function_Instantiation
or else
Arg_Kind = A_Formal_Function_Declaration)
and then
Int_Kind (Names (Op_Decl) (1)) in Internal_Defining_Operator_Kinds
then
-- First, check the result type
Next_Type := Result_Profile (Op_Decl);
if Int_Kind (Next_Type) = A_Selected_Component then
Next_Type := Selector (Next_Type);
end if;
if Int_Kind (Next_Type) = An_Identifier then
Next_Type := Corresponding_Name_Declaration (Next_Type);
Next_Type := Corresponding_First_Subtype (Next_Type);
if Is_Equal (Next_Type, Type_Decl) then
Result := True;
end if;
end if;
if not Result then
-- check parameter types
declare
Params : constant Asis.Element_List :=
Parameter_Profile (Op_Decl);
begin
for J in Params'Range loop
Next_Type := Object_Declaration_View (Params (J));
if Int_Kind (Next_Type) = A_Selected_Component then
Next_Type := Selector (Next_Type);
end if;
if Int_Kind (Next_Type) = An_Identifier then
Next_Type := Corresponding_Name_Declaration (Next_Type);
Next_Type := Corresponding_First_Subtype (Next_Type);
if Is_Equal (Next_Type, Type_Decl) then
Result := True;
exit;
end if;
end if;
end loop;
end;
end if;
end if;
return Result;
end Is_Type_Operator;
------------------------------
-- Is_Typeless_Subaggregate --
------------------------------
function Is_Typeless_Subaggregate (Aggr : Node_Id) return Boolean is
Parent_Node : Node_Id := Parent (Aggr);
Result : Boolean := False;
Arg_Type : Entity_Id;
Parent_Type : Entity_Id;
begin
if Nkind (Parent_Node) = N_Component_Association then
Parent_Node := Parent (Parent_Node);
end if;
if Nkind (Parent_Node) = N_Aggregate then
Arg_Type := Etype (Aggr);
while Present (Arg_Type) and then Etype (Arg_Type) /= Arg_Type loop
Arg_Type := Etype (Arg_Type);
end loop;
Parent_Type := Etype (Parent_Node);
while Present (Parent_Type)
and then Etype (Parent_Type) /= Parent_Type
loop
Parent_Type := Etype (Parent_Type);
end loop;
Result := Arg_Type = Parent_Type;
end if;
return Result;
end Is_Typeless_Subaggregate;
-------------------------
-- Is_Uniquely_Defined --
-------------------------
function Is_Uniquely_Defined (Reference : Asis.Expression) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Reference);
Arg_Node : Node_Id;
Arg_R_Node : Node_Id;
Context_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Reference, Package_Name & "Is_Uniquely_Defined");
if Special_Case (Reference) = End_Label then
return False;
end if;
if Arg_Kind = An_Identifier
and then
Nkind (Node (Reference)) = N_Defining_Identifier
and then
Normalization_Case (Reference) =
Is_Normalized_Defaulted_Null_Procedure
then
-- A special case of an actual parameter in a normalized generic
-- association when the defult for null procedure is used
return True;
end if;
if Arg_Kind = An_Identifier or else
Arg_Kind in Internal_Operator_Symbol_Kinds or else
Arg_Kind = A_Character_Literal or else
Arg_Kind = An_Enumeration_Literal
then
if Special_Case (Reference) = Rewritten_Named_Number then
-- argument does not have an Entity field at all!!
return True;
end if;
Result := True;
-- We suppose, that in general case we have a unique declaration,
-- and now let's try to detect if we have a special case:
-- Aspect marks and aspect-specific identifiers do not have a
-- declaration
if Is_Aspect_Mark (Reference) or else
Is_Aspect_Specific_Identifier (Reference)
then
Result := False;
end if;
-- A part of SPARK-specific aspect
if Is_From_SPARK_Aspect (Reference) then
Arg_R_Node := R_Node (Reference);
if Nkind (Parent (Arg_R_Node)) = N_Expanded_Name
and then
Arg_R_Node = Selector_Name (Parent (Arg_R_Node))
then
Arg_R_Node := Parent (Arg_R_Node);
Arg_Node := Arg_R_Node;
else
Arg_Node := Node (Reference);
end if;
if not ((Nkind (Arg_Node) in N_Has_Entity
and then
Present (Entity (Arg_Node)))
or else
(Nkind (Arg_R_Node) in N_Has_Entity
and then
Present (Entity (Arg_R_Node))))
then
return False;
end if;
if Nkind (Arg_Node) in N_Has_Entity then
Arg_Node := Entity (Arg_Node);
if Present (Arg_Node)
and then
Nkind (Arg_Node) in N_Entity -- check is needed for SPARK!
and then
Ekind (Arg_Node) = E_Abstract_State
then
return False;
end if;
end if;
-- A special case of notation like '... => + null'
if Nkind (Node (Reference)) in N_Op
and then
Nkind (R_Node (Reference)) = N_Identifier
then
return False;
end if;
end if;
Arg_Node := Node (Reference);
-- first, the situation when "passed a portion of a pragma that
-- was "ignored" by the compiler", it relates to pragma arguments
-- only, but not to pragma element identifiers:
-- GNAT rewrites the tree structure for non-recognized pragma as
-- if it is a null statement, so:
if Result and then
Nkind (Parent (Parent (Arg_Node))) = N_Null_Statement
then
Result := False;
end if;
if Result and then Arg_Kind = An_Identifier then
-- There are three checks specific to arguments of An_Identifier
-- kind only: a pragma_argument_identifier, an identifier specific
-- to a pragma and a reference to an attribute_designator:
if Nkind (Arg_Node) = N_Pragma_Argument_Association
-- a reference to a pragma_argument_identifier
or else
(Nkind (Arg_Node) in N_Has_Entity
and then
No (Entity (Arg_Node))
and then
(Nkind (Parent (Arg_Node)) = N_Pragma_Argument_Association
or else
Is_From_Import_Procedure_Pragma (Arg_Node)))
-- an identifier specific to a pragma, we make a guess that
-- any identifier on the place of a pragma argument is
-- specific to the pragma, if the Entity field is not set
-- for this identifier. Is it really true???
or else
Nkind (Arg_Node) = N_Attribute_Reference
or else
Special_Case (Reference) = Dummy_Class_Attribute_Designator
-- a reference to an attribute_designator
or else
Nkind (Arg_Node) = N_Attribute_Definition_Clause
-- attribute designator from an attribute definition clause
then
Result := False;
end if;
end if;
-- One more check for pragma argument. It corresponds to the
-- situation when the identifier is specific for a pragma, but in
-- the same time it is a part of other expression. This check is
-- specific to extended Import and Export pragmas applying to
-- subprograms.
if Result and then
Special_Case (Reference) = Not_A_Special_Case and then
Arg_Kind = An_Identifier and then
No (Entity (Arg_Node))
then
-- The first possibility:
--
-- pragma Import_Function (Internal => Unix_Code_Mappings,
-- External => "unix_code_mappings",
-- Result_Type => Integer,
-- Mechanism => (Value));
--
-- Value is rewritten into N_Aggregate
--
-- The second possibility:
--
-- pragma Import_Procedure (Internal => Ignore_Signal,
-- External => "ignore_signal",
-- Mechanism => (Value, Value));
--
-- Value is not rewritten and it is represented as a "normal"
-- aggregate component
--
-- And the third possibility:
--
-- pragma Export_Procedure
-- (Internal => Reset,
-- External => "",
-- Parameter_Types => (File_Type, File_Mode),
-- Mechanism => (File => Reference));
--
-- Here we have an aggregate with named associations:
if (Nkind (R_Node (Reference)) = N_Aggregate and then
(Nkind (Parent (R_Node (Reference)))) =
N_Pragma_Argument_Association)
or else
(Nkind (R_Node (Reference)) = N_Identifier
and then
not (Is_Rewrite_Substitution (R_Node (Reference)))
and then
((Nkind (Parent (R_Node (Reference))) = N_Aggregate
and then
Nkind (Parent (Parent (R_Node (Reference)))) =
N_Pragma_Argument_Association)
or else
(Nkind (Parent (R_Node (Reference))) =
N_Component_Association
and then
Nkind (Parent (Parent (R_Node (Reference)))) =
N_Aggregate
and then
Nkind (Parent (Parent (Parent ((R_Node (Reference)))))) =
N_Pragma_Argument_Association)
)
)
then
Result := False;
end if;
end if;
-- Case of a component of VMS-specific IMPORT_VALUED_PROCEDURE
-- pragma (SHORT_DESCRIPTOR, DESCRIPTOR etc.)
if Result
and then
No (Entity (Arg_Node))
then
Context_Node := Arg_Node;
while Present (Context_Node) loop
if Is_List_Member (Context_Node) then
case Nkind (Parent (Context_Node)) is
when N_Aggregate =>
Context_Node := Parent (Context_Node);
exit;
when N_Function_Call =>
null;
when others =>
exit;
end case;
end if;
Context_Node := Parent (Context_Node);
end loop;
if Present (Context_Node)
and then
Nkind (Parent (Context_Node)) = N_Pragma_Argument_Association
and then
No (Corresponding_Aspect (Parent (Parent ((Context_Node)))))
then
Result := False;
end if;
end if;
-- Then check for the situation when if passed a portion of a pragma
-- that may be an ambiguous reference to more than one entity.
if Result and then
Nkind (Parent (Arg_Node)) = N_Pragma_Argument_Association and then
Needs_List (Reference)
then
declare
Res_List : constant Asis.Element_List :=
Corresponding_Name_Definition_List (Reference);
begin
if Res_List'Length /= 1 then
Result := False;
end if;
end;
end if;
end if;
-- Case when the argument is a parameter of Source_File_Name pragma or
-- component thereof
if Result then
while not Is_List_Member (Arg_Node) and then
Present (Arg_Node)
loop
Arg_Node := Parent (Arg_Node);
end loop;
if Nkind (Arg_Node) = N_Pragma_Argument_Association
and then
Pragma_Name (Parent (Arg_Node)) = Name_Source_File_Name
then
Result := False;
end if;
end if;
-- Case when the argument is the (component of the) prefix of the
-- GNAT-specific attribute 'Elab_Body or 'Elab_Spec
if Result then
Arg_Node := Parent (R_Node (Reference));
while Nkind (Arg_Node) = N_Selected_Component loop
Arg_Node := Parent (Arg_Node);
end loop;
if Nkind (Arg_Node) = N_Attribute_Reference
and then
Attribute_Name (Arg_Node) in Name_Elab_Body .. Name_Elab_Spec
then
Result := False;
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Reference,
Outer_Call => Package_Name & "Is_Uniquely_Defined");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Uniquely_Defined",
Ex => Ex,
Arg_Element => Reference);
end Is_Uniquely_Defined;
-------------------------------
-- Main_Unit_In_Current_Tree --
-------------------------------
function Main_Unit_In_Current_Tree
(The_Context : Asis.Context)
return Asis.Compilation_Unit
is
Curr_Tree_Id : Tree_Id;
Curr_Cont_Id : Context_Id;
Res_Unit_Id : Unit_Id := Nil_Unit;
begin
Check_Validity (The_Context, Package_Name & "Main_Unit_In_Current_Tree");
Curr_Cont_Id := Get_Current_Cont;
Curr_Tree_Id := Get_Current_Tree;
if Tree_Processing_Mode (Get_Cont_Id (The_Context)) = GNSA then
-- Note, that for GNSA Context no check is made! This works correctly
-- only for -GNSA -C1 Context and if only this Context Is_Open
-- at the moment
Res_Unit_Id := Config_Comp_Id + 1; -- ???
-- Not a good approach!!!
elsif Get_Cont_Id (The_Context) = Curr_Cont_Id and then
Curr_Cont_Id /= Nil_Context_Id and then
Present (Curr_Tree_Id)
then
Res_Unit_Id := Main_Unit_Id;
elsif Get_Cont_Id (The_Context) /= Nil_Context_Id then
Reset_Context (Get_Cont_Id (The_Context));
if Tree_Processing_Mode (Get_Cont_Id (The_Context)) = GNSA then
-- Note, that for GNSA Context no check is made! This works
-- correctly only for -GNSA -C1 Context and if only this Context
-- Is_Open at the moment
Res_Unit_Id := Config_Comp_Id + 1; -- ???
-- Not a good approach!!!
elsif Last_Tree (Get_Cont_Id (The_Context)) >= First_Tree_Id then
Res_Unit_Id := Main_Unit_Id (First_Tree_Id);
end if;
end if;
if Present (Res_Unit_Id) then
return Get_Comp_Unit (Res_Unit_Id, Get_Cont_Id (The_Context));
else
return Nil_Compilation_Unit;
end if;
exception
when ASIS_Inappropriate_Context =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Main_Unit_In_Current_Tree");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Main_Unit_In_Current_Tree",
Ex => Ex);
end Main_Unit_In_Current_Tree;
-------------------
-- Needed_Checks --
-------------------
function Needed_Checks
(Element : Asis.Element)
return Run_Time_Check_Set
is
Result : Run_Time_Check_Set := Empty_Check_Set;
Arg_Node : constant Node_Id := R_Node (Element);
Tmp : Asis.Element;
begin
Check_Validity (Element, Package_Name & "Needed_Checks");
if Is_Nil (Element) then
return Result;
end if;
-- Infix call to a predefined operator: we do not want to report checks
-- twice - for the call and for the operator:
if Expression_Kind (Element) = An_Operator_Symbol then
Tmp := Enclosing_Element (Element);
if Expression_Kind (Tmp) = A_Function_Call
and then
not Is_Prefix_Call (Tmp)
and then
Is_Predefined_Operator (Element)
then
return Result;
end if;
end if;
-- Do_Accessibility_Check
if Nkind (Arg_Node) = N_Parameter_Specification
and then
Do_Accessibility_Check (Arg_Node)
then
Result (Do_Accessibility_Check) := True;
end if;
-- Do_Discriminant_Check
if Nkind (Arg_Node) = N_Selected_Component
and then
Do_Discriminant_Check (Arg_Node)
then
Result (Do_Discriminant_Check) := True;
end if;
-- Do_Division_Check
if Nkind (Arg_Node) in N_Op_Divide | N_Op_Mod | N_Op_Rem
and then
Do_Division_Check (Arg_Node)
then
Result (Do_Division_Check) := True;
end if;
-- Do_Length_Check
if Nkind (Arg_Node) in
N_Assignment_Statement | N_Op_And | N_Op_Or | N_Op_Xor |
N_Type_Conversion
and then
Do_Length_Check (Arg_Node)
then
Result (Do_Length_Check) := True;
end if;
-- Do_Overflow_Check
if Nkind (Arg_Node) in
N_Op | N_Attribute_Reference | N_Case_Expression |
N_If_Expression | N_Type_Conversion
and then
Do_Overflow_Check (Arg_Node)
then
Result (Do_Overflow_Check) := True;
end if;
-- Do_Range_Check
if Nkind (Arg_Node) in N_Subexpr
and then
Do_Range_Check (Arg_Node)
then
Result (Do_Range_Check) := True;
end if;
-- Do_Storage_Check
if Nkind (Arg_Node) in N_Allocator | N_Subprogram_Body
and then
Do_Storage_Check (Arg_Node)
then
Result (Do_Storage_Check) := True;
end if;
-- Do_Tag_Check
if Nkind (Arg_Node) in
N_Assignment_Statement | N_Extended_Return_Statement |
N_Function_Call | N_Procedure_Call_Statement |
N_Simple_Return_Statement | N_Type_Conversion
and then
Do_Tag_Check (Arg_Node)
then
Result (Do_Tag_Check) := True;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Needed_Checks");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Needed_Checks",
Ex => Ex,
Arg_Element => Element);
end Needed_Checks;
-----------
-- No_Op --
-----------
procedure No_Op
(Element : Asis.Element;
Control : in out Traverse_Control;
State : in out No_State)
is
begin
pragma Unreferenced (Element);
pragma Unreferenced (Control);
pragma Unreferenced (State);
null;
end No_Op;
-------------------------
-- Normalize_Reference --
-------------------------
function Normalize_Reference (Ref : Asis.Element) return Asis.Element is
Result : Asis.Element := Ref;
begin
case Expression_Kind (Ref) is
when A_Selected_Component =>
Result := Selector (Ref);
when An_Attribute_Reference =>
Result := Normalize_Reference (Prefix (Ref));
when others =>
null;
end case;
return Result;
end Normalize_Reference;
--------------------------
-- Original_Line_Number --
--------------------------
function Original_Line_Number
(Element : Asis.Element;
Compiled_Line : Line_Number_Positive)
return Line_Number
is
SFI : Source_File_Index;
Result : Line_Number := 0;
begin
Check_Validity (Element, Package_Name & "Original_Line_Number");
if Is_Text_Available (Element) then
if Compiled_Line > Line_Number (Number_Of_Lines (Element)) then
Raise_ASIS_Inappropriate_Line_Number
(Package_Name & "Original_Line_Number");
end if;
SFI := Get_Source_File_Index (Location (Element));
Result :=
Line_Number (Sinput.Physical_To_Logical
(Physical_Line_Number (Compiled_Line), SFI));
end if;
return Result;
exception
when ASIS_Inappropriate_Element | ASIS_Inappropriate_Line_Number =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Original_Line_Number");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Original_Line_Number",
Ex => Ex,
Arg_Element => Element);
end Original_Line_Number;
------------------------
-- Original_Text_Name --
------------------------
function Original_Text_Name
(Compilation_Unit : Asis.Compilation_Unit)
return Wide_String
is
begin
Check_Validity (Compilation_Unit, Package_Name & "Original_Text_Name");
if not Exists (Compilation_Unit) then
return Nil_Asis_Wide_String;
else
-- Exists resets the Context!
return To_Program_Text (Ref_File (Compilation_Unit));
end if;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Original_Text_Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Original_Text_Name",
Ex => Ex,
Arg_CU => Compilation_Unit);
end Original_Text_Name;
-----------------------------
-- Overrides_Type_Operator --
-----------------------------
function Overrides_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean
is
pragma Unreferenced (Type_Decl);
Op_Entity : Entity_Id;
Result : Boolean := False;
begin
-- We assume that Is_Type_Operator (Op_Decl, Type_Decl) is True
-- !!! The implementation is incomplete!!!
Op_Entity := Node (Names (Op_Decl) (1));
if Present (Overridden_Operation (Op_Entity)) then
Result := True;
end if;
return Result;
end Overrides_Type_Operator;
-------------------
-- Pragmas_After --
-------------------
function Pragmas_After
(Compilation_Unit : Asis.Compilation_Unit;
Include_Pragmas : Boolean := True)
return Asis.Pragma_Element_List is
pragma Assert (Include_Pragmas);
-- This flag is only present so the profile matches what A4g.Queries
-- expects.
Program_Unit : constant Asis.Element :=
Unit_Declaration (Compilation_Unit);
Unit_Span : constant Asis.Text.Span := Element_Span (Program_Unit);
Comp_Pragmas : constant Asis.Element_List :=
Asis.Elements.Compilation_Pragmas (Compilation_Unit);
First : Asis.List_Index := Comp_Pragmas'First;
function Span_Before (X, Y : Asis.Text.Span) return Boolean is
(X.Last_Line < Y.First_Line or else
(X.Last_Line = Y.First_Line and then
X.Last_Column < Y.First_Column));
-- True if X is before Y in the source code
begin
-- Find the first pragma that occurs after the program unit, as
-- indicated by its Span. Skip configuration file pragmas, which must
-- come first. It makes no sense to compare against the Span of a
-- configuration file pragma, because they come from a different source
-- file.
while First <= Comp_Pragmas'Last and then
(Comp_Pragmas (First).Special_Case = Configuration_File_Pragma or else
not Span_Before (Unit_Span, Element_Span (Comp_Pragmas (First))))
loop
First := First + 1;
end loop;
declare
Result : Asis.Pragma_Element_List renames
Comp_Pragmas (First .. Comp_Pragmas'Last);
subtype Slide is Asis.Pragma_Element_List (1 .. Result'Length);
begin
for J in Result'Range loop
pragma Assert
(Result (J).Special_Case /= Configuration_File_Pragma);
end loop;
return Slide (Result); -- Make sure the result is 1-based
end;
end Pragmas_After;
---------------------
-- Primitive_Owner --
---------------------
function Primitive_Owner
(Declaration : Asis.Declaration)
return Asis.Type_Definition
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id := Empty;
Par_Node : Node_Id := Empty;
Res_Node : Node_Id := Empty;
Result : Element := Nil_Element;
Res_Kind : Internal_Element_Kinds := Not_An_Element;
begin
Check_Validity (Declaration, Package_Name & "Primitive_Owner");
if not (Arg_Kind = A_Procedure_Declaration or else
Arg_Kind = A_Null_Procedure_Declaration or else
Arg_Kind = A_Function_Declaration or else
Arg_Kind = An_Expression_Function_Declaration or else
Arg_Kind = A_Procedure_Renaming_Declaration or else
Arg_Kind = A_Function_Renaming_Declaration or else
Arg_Kind = A_Procedure_Body_Declaration or else
Arg_Kind = A_Function_Body_Declaration or else
Arg_Kind = A_Procedure_Body_Stub or else
Arg_Kind = A_Function_Body_Stub)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Primitive_Owner",
Wrong_Kind => Arg_Kind);
end if;
if not Is_From_Implicit (Declaration) and then
Asis.Declarations.Is_Dispatching_Operation (Declaration)
then
Arg_Node := Specification (Node (Declaration));
if Nkind (Arg_Node) = N_Function_Specification then
if Has_Controlling_Result (Defining_Unit_Name (Arg_Node)) then
Res_Node := Defining_Unit_Name (Arg_Node);
Res_Node := Parent (Res_Node);
Res_Node := Sinfo.Result_Definition (Res_Node);
if Nkind (Res_Node) = N_Access_Definition then
Res_Node := Sinfo.Subtype_Mark (Res_Node);
end if;
Res_Node := Entity (Res_Node);
end if;
end if;
if No (Res_Node) then
-- This means that we do not have a function with controlling
-- result, so we have to go through the formal parameter list,
-- and it can not be No_List or empty
Par_Node := First (Parameter_Specifications (Arg_Node));
while Present (Par_Node) loop
if Is_Controlling_Formal
(Defining_Identifier (Par_Node))
then
if Nkind (Parameter_Type (Par_Node)) =
N_Access_Definition
then
Res_Node :=
Sinfo.Subtype_Mark (Parameter_Type (Par_Node));
else
Res_Node := Defining_Identifier (Par_Node);
end if;
Res_Node := Etype (Res_Node);
exit;
end if;
Par_Node := Next (Par_Node);
end loop;
end if;
pragma Assert (Present (Res_Node));
if Nkind (Original_Node (Parent (Res_Node))) =
N_Subtype_Declaration
then
Res_Node := Etype (Res_Node);
end if;
if Ekind (Res_Node) = E_Incomplete_Type
and then
Present (Full_View (Res_Node))
then
Res_Node := Full_View (Res_Node);
end if;
Res_Node := Original_Node (Parent (Res_Node));
case Nkind (Res_Node) is
when N_Private_Type_Declaration =>
if Tagged_Present (Res_Node) then
Res_Kind := A_Tagged_Private_Type_Definition;
else
-- It can be non-tagged, if the full view is tagged
Res_Kind := A_Private_Type_Definition;
end if;
when N_Private_Extension_Declaration =>
Res_Kind := A_Private_Extension_Definition;
when N_Full_Type_Declaration =>
Res_Node := Sinfo.Type_Definition (Res_Node);
when N_Task_Type_Declaration =>
Res_Node := Sinfo.Task_Definition (Res_Node);
when N_Protected_Type_Declaration =>
Res_Node := Sinfo.Protected_Definition (Res_Node);
when others =>
pragma Assert (False);
null;
end case;
Result := Node_To_Element_New (Node => Res_Node,
Internal_Kind => Res_Kind,
Starting_Element => Declaration);
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Primitive_Owner");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Primitive_Owner",
Ex => Ex,
Arg_Element => Declaration);
end Primitive_Owner;
------------------------
-- Source_File_Status --
------------------------
function Source_File_Status
(Right : Asis.Compilation_Unit)
return Source_File_Statuses
is
Arg_Kind : constant Unit_Kinds := Kind (Right);
Result : Source_File_Statuses;
begin
Check_Validity (Right, Package_Name & "Source_File_Status");
case Arg_Kind is
when Not_A_Unit |
A_Nonexistent_Declaration |
A_Nonexistent_Body |
An_Unknown_Unit =>
Result := Absent;
when others =>
Result := Source_Status (Right);
end case;
return Result;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Source_File_Status");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Source_File_Status",
Ex => Ex,
Arg_CU => Right);
end Source_File_Status;
-----------------------------------
-- Static_Expression_Value_Image --
-----------------------------------
function Static_Expression_Value_Image
(Expression : Asis.Expression)
return Wide_String
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Expression);
Arg_Node : Node_Id := Empty;
Result : Uint;
Tmp_El : Asis.Element;
begin
Check_Validity
(Expression, Package_Name & "Static_Expression_Value_Image");
if Arg_Kind not in Internal_Expression_Kinds then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Static_Expression_Value_Image",
Wrong_Kind => Arg_Kind);
end if;
if not (Is_True_Expression (Expression) and then
Is_Static (Expression))
then
return "";
end if;
Arg_Node := R_Node (Expression);
if Nkind (Arg_Node) = N_String_Literal then
String_To_Name_Buffer (Strval (Arg_Node));
return To_Wide_String (Name_Buffer (1 .. Name_Len));
-- elsif Nkind (Arg_Node) = N_Real_Literal then
-- begin
-- return Long_Long_Float'Wide_Image
-- (Get_LF_From_Ureal (Realval (Arg_Node)));
-- exception
-- when others => return "";
-- end;
elsif Has_Enumeration_Type (Expression) or else
Has_Integer_Type (Expression)
then
Result := Eval_Scalar_Node (Arg_Node);
UI_Image (Result, Format => Decimal);
return To_Wide_String (UI_Image_Buffer (1 .. UI_Image_Length));
else
if Expression_Kind (Expression) = A_Selected_Component then
Tmp_El := Selector (Expression);
else
Tmp_El := Expression;
end if;
if Expression_Kind (Tmp_El) = An_Identifier then
begin
Tmp_El := Corresponding_Name_Declaration (Tmp_El);
exception
when ASIS_Inappropriate_Element =>
Tmp_El := Nil_Element;
end;
if Declaration_Kind (Tmp_El) = A_Constant_Declaration then
Tmp_El := Initialization_Expression (Tmp_El);
return Static_Expression_Value_Image (Tmp_El);
end if;
end if;
end if;
return "";
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name & "Static_Expression_Value_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Static_Expression_Value_Image",
Ex => Ex,
Arg_Element => Expression);
end Static_Expression_Value_Image;
-----------------------------------------
-- Static_Range_High_Bound_Value_Image --
-----------------------------------------
function Static_Range_High_Bound_Value_Image
(Range_Element : Asis.Range_Constraint)
return Wide_String
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Range_Element);
Arg_Node : Node_Id := Empty;
Arg_Ekind : Entity_Kind;
Result : Uint;
begin
Check_Validity
(Range_Element, Package_Name & "Static_Range_High_Bound_Value_Image");
if not (Arg_Kind = A_Range_Attribute_Reference or else
Arg_Kind =
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
or else
Arg_Kind = A_Discrete_Range_Attribute_Reference)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Static_Range_High_Bound_Value_Image",
Wrong_Kind => Arg_Kind);
end if;
if not (Is_Static (Range_Element)) then
return "";
end if;
Arg_Node := R_Node (Range_Element);
if Nkind (Arg_Node) = N_Range_Constraint then
Arg_Node := Range_Expression (Arg_Node);
end if;
Arg_Ekind := Ekind (Etype (Arg_Node));
if not (Arg_Ekind in Discrete_Kind) then
-- Implementation limitation!!!
return "";
end if;
Result := Eval_Scalar_Node (High_Bound (Arg_Node));
UI_Image (Result, Format => Decimal);
return To_Wide_String (UI_Image_Buffer (1 .. UI_Image_Length));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Range_Element,
Outer_Call => Package_Name &
"Static_Range_High_Bound_Value_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Static_Range_High_Bound_Value_Image",
Ex => Ex,
Arg_Element => Range_Element);
end Static_Range_High_Bound_Value_Image;
----------------------------------------
-- Static_Range_Low_Bound_Value_Image --
----------------------------------------
function Static_Range_Low_Bound_Value_Image
(Range_Element : Asis.Range_Constraint)
return Wide_String
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Range_Element);
Arg_Node : Node_Id := Empty;
Arg_Ekind : Entity_Kind;
Result : Uint;
begin
Check_Validity
(Range_Element, Package_Name & "Static_Range_Low_Bound_Value_Image");
if not (Arg_Kind = A_Range_Attribute_Reference or else
Arg_Kind =
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
or else
Arg_Kind = A_Discrete_Range_Attribute_Reference)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Static_Range_Low_Bound_Value_Image",
Wrong_Kind => Arg_Kind);
end if;
if not (Is_Static (Range_Element)) then
return "";
end if;
Arg_Node := R_Node (Range_Element);
if Nkind (Arg_Node) = N_Range_Constraint then
Arg_Node := Range_Expression (Arg_Node);
end if;
Arg_Ekind := Ekind (Etype (Arg_Node));
if not (Arg_Ekind in Discrete_Kind) then
-- Implementation limitation!!!
return "";
end if;
Result := Eval_Scalar_Node (Low_Bound (Arg_Node));
UI_Image (Result, Format => Decimal);
return To_Wide_String (UI_Image_Buffer (1 .. UI_Image_Length));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Range_Element,
Outer_Call => Package_Name &
"Static_Range_Low_Bound_Value_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Static_Range_Low_Bound_Value_Image",
Ex => Ex,
Arg_Element => Range_Element);
end Static_Range_Low_Bound_Value_Image;
end Asis.Extensions;
|