/usr/share/ada/adainclude/asis/a4g-encl_el.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 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . E N C L _ E L --
-- --
-- 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 Asis; use Asis;
with Asis.Declarations; use Asis.Declarations;
with Asis.Elements; use Asis.Elements;
with Asis.Extensions;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Sem; use A4G.A_Sem;
with A4G.A_Types; use A4G.A_Types;
with A4G.EE_Cache; use A4G.EE_Cache;
with A4G.Int_Knds; use A4G.Int_Knds;
with A4G.Mapping; use A4G.Mapping;
with A4G.Queries; use A4G.Queries;
with A4G.A_Opt;
with A4G.Vcheck; use A4G.Vcheck;
with Atree; use Atree;
with Einfo; use Einfo;
with Namet; use Namet;
with Nlists; use Nlists;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Snames;
with Stand; use Stand;
with Types; use Types;
package body A4G.Encl_El is
------------------------------------------------
-- The general approach to the implementation --
-- of the Enclosing_Element query --
------------------------------------------------
-- There are important differences in the ways how an Enclosing_Element
-- is retrieved for explicit and implicit Elements, and for the elements
-- from expanded generics. For explicit Elements, the general way to get
-- the enclosing Element is to do the necessary bottom-up tree traversing,
-- for most of the cases all what we need if one step up the front-end
-- tree, but sometimes the differences between front-end and ASIS trees
-- require some non-trivial traversing.
--
-- For implicit Elements, there is a semantic link between a top Element
-- of an ASIS implicit sub-hierarchy and some explicit Element that
-- "generates" this subhierarchy. For example, an implicit declaration of
-- an inherited supprogram is "generated" by some derived type definition,
-- so inside the implicit subhierarchy we use the same approach for
-- retrieving the enclosing Element as for explicit Elements, but the
-- enclosing Element for subhierarchy is the construct that "generates" the
-- subhierarchy, and to get to this construct, the link stored as a part
-- of implicit elements structure is used.
--
-- For Elements from generic instantiations, we do bottom-up traversing of
-- the ASIS/front-end tree structure corresponding to the expanded code
-- in the same way as for explicit Elements, but when we are at the top of
-- an expanded spec or body, the next Enclosing_Element step should go
-- to the corresponding instantiation, so here we also do something
-- different that bottom-up tree traversing
--
-- But for most of the cases the way to get the enclosing Element is to
-- map the bottom-up traversing of the compiler tree onto the ASIS Elements
-- hierarchy. This is performed by Enclosing_Element_For_Explicit function,
-- and all the other routines defined in this package detect and process
-- various special cases. For implicit Elements and for Elements that are
-- components of expanded generic structure the first thing is to check if
-- this Element can be processed as if it is a usual explicit Element, and
-- then correct result, if needed.
---------------------------------------------------------------------
-- Mapping the bottom-up traversing of the compiler tree onto ASIS --
---------------------------------------------------------------------
-- Each ASIS Element contains the reference to the tree node it has been
-- built from. In many cases the enclosing Element should be built on
-- the parent node. In some cases the enclosing Element may be built on the
-- same node. And there are some cases when we have to do some traversing
-- that is specific to this particular Element to get to the compiler tree
-- node corresponding to its enclosing Element.
-- The way of getting the enclosing Element is implemented on the base of
-- two look-up tables (switches). The first table defines if for the given
-- element (that is, for the given Element kind, and the internal flat
-- Element classification is used here) some regular way of constructing
-- enclosing Element should be used, or some non-trivial traversing is
-- needed. This non-trivial traversing is specific to the Element kind, and
-- the corresponding routine is defined by the second look-up table.
-------------------------------------------------
-- The general structure of this package body --
-------------------------------------------------
-- The rest of this package body has the following structure:
--
-- Section 1 - definition of the first Enclosing_Element switch (makes
-- the difference between trivial and non-trivial cases of
-- mapping the bottom up compiler tree traversing onto ASIS
--
-- Section 2 - declarations of routines implementing various cases of
-- non-trivial bottom up compiler tree traversing
--
-- Section 3 - definition of the second Enclosing_Element switch (maps
-- Element kind requiring non-trivial actions onto
-- corresponding routines
--
-- Section 4 - (general-purpose) local subprograms
--
-- Section 5 - bodies of the routines declared in Section 2
--
-- Section 6 - bodies of the routines declared in the package spec
---------------------------------------------------------------------
-- Section 1 - Enclosing_Element first switch, separating trivial --
-- and non-trivial cases --
---------------------------------------------------------------------
-- This switch maps each value of the Internal_Element_Kinds onto one
-- of the following values of the same type, and this mapping has the
-- following meaning:
-- Not_An_Element => Asis.Nil_Element should be returned as
-- Enclosed Element;
--
-- Trivial_Mapping => A standard Enclosing_Element constructor should
-- be used, it is implemented by General_Encl_Elem
-- function
--
-- No_Mapping => is set for the special values added to the
-- Internal_Element_Kinds literals to organize the
-- Node_to_Element and Enclosing Element switches.
--
-- Non_Trivial_Mapping => a special function is needed for this Element
-- kind to get the Enclosing Element. This function
-- is selected by second switch,
--
-- Not_Implemented_Mapping => it means what is sounds
--
-- any the other value => the Enclosing Element for the Element of the
-- corresponding kind is based on the same node, but
-- is of the specified kind
Enclosing_Element_For_Explicits_First_Switch : constant
array (Internal_Element_Kinds) of Internal_Element_Kinds :=
(
-- type Internal_Element_Kinds is (
--
Not_An_Element => Not_An_Element,
-- Asis.Nil_Element should be returned as the
-- Enclosing for the Asis.Nil_Element, should not it???
--
------------------------------------------------------------------------------
--
-- -- A_Pragma, -- Asis.Elements
--
------------------------------------------------------------------------------
--
An_All_Calls_Remote_Pragma ..
-- An_Asynchronous_Pragma,
-- An_Atomic_Pragma,
-- An_Atomic_Components_Pragma,
-- An_Attach_Handler_Pragma,
-- A_Controlled_Pragma,
-- A_Convention_Pragma,
-- A_Discard_Names_Pragma,
-- An_Elaborate_Pragma,
-- An_Elaborate_All_Pragma,
-- An_Elaborate_Body_Pragma,
-- An_Export_Pragma,
-- An_Import_Pragma,
-- An_Inline_Pragma,
-- An_Inspection_Point_Pragma,
-- An_Interrupt_Handler_Pragma,
-- An_Interrupt_Priority_Pragma,
-- A_Linker_Options_Pragma
-- A_List_Pragma,
-- A_Locking_Policy_Pragma,
-- A_Normalize_Scalars_Pragma,
-- An_Optimize_Pragma,
-- A_Pack_Pragma,
-- A_Page_Pragma,
-- A_Preelaborate_Pragma,
-- A_Priority_Pragma,
-- A_Pure_Pragma,
-- A_Queuing_Policy_Pragma,
-- A_Remote_Call_Interface_Pragma,
-- A_Remote_Types_Pragma,
-- A_Restrictions_Pragma,
-- A_Reviewable_Pragma,
-- A_Shared_Passive_Pragma,
-- A_Storage_Size_Pragma,
-- A_Suppress_Pragma,
-- A_Task_Dispatching_Policy_Pragma,
-- A_Volatile_Pragma,
-- A_Volatile_Components_Pragma,
--
-- An_Implementation_Defined_Pragma,
--
An_Unknown_Pragma => Non_Trivial_Mapping,
--
------------------------------------------------------------------------------
--
-- -- A_Defining_Name, -- Asis.Declarations
--
------------------------------------------------------------------------------
--
A_Defining_Identifier => Non_Trivial_Mapping,
A_Defining_Character_Literal => An_Enumeration_Literal_Specification,
A_Defining_Enumeration_Literal => An_Enumeration_Literal_Specification,
--
-- -- A_Defining_Operator_Symbol => Non_Trivial_Mapping
--
A_Defining_And_Operator ..
-- A_Defining_Or_Operator,
-- A_Defining_Xor_Operator,
-- A_Defining_Equal_Operator,
-- A_Defining_Not_Equal_Operator,
-- A_Defining_Less_Than_Operator,
-- A_Defining_Less_Than_Or_Equal_Operator,
-- A_Defining_Greater_Than_Operator,
-- A_Defining_Greater_Than_Or_Equal_Operator,
-- A_Defining_Plus_Operator,
-- A_Defining_Minus_Operator,
-- A_Defining_Concatenate_Operator,
-- A_Defining_Unary_Plus_Operator,
-- A_Defining_Unary_Minus_Operator,
-- A_Defining_Multiply_Operator,
-- A_Defining_Divide_Operator,
-- A_Defining_Mod_Operator,
-- A_Defining_Rem_Operator,
-- A_Defining_Exponentiate_Operator,
-- A_Defining_Abs_Operator,
A_Defining_Not_Operator => Non_Trivial_Mapping,
A_Defining_Expanded_Name => Non_Trivial_Mapping,
--
------------------------------------------------------------------------------
--
-- -- A_Declaration, -- Asis.Declarations
--
------------------------------------------------------------------------------
--
An_Ordinary_Type_Declaration ..
-- A_Task_Type_Declaration,
-- A_Protected_Type_Declaration,
-- An_Incomplete_Type_Declaration,
-- A_Private_Type_Declaration,
-- A_Private_Extension_Declaration,
-- A_Subtype_Declaration,
A_Variable_Declaration => Trivial_Mapping,
A_Constant_Declaration => Trivial_Mapping,
A_Deferred_Constant_Declaration ..
-- A_Single_Task_Declaration,
-- A_Single_Protected_Declaration,
--
-- An_Integer_Number_Declaration,
A_Real_Number_Declaration => Trivial_Mapping,
--
An_Enumeration_Literal_Specification => Non_Trivial_Mapping,
-- is it really so?
--
A_Discriminant_Specification => Non_Trivial_Mapping,
A_Component_Declaration => Non_Trivial_Mapping,
A_Loop_Parameter_Specification ..
-- A_Generalized_Iterator_Specification,
An_Element_Iterator_Specification => Non_Trivial_Mapping,
A_Procedure_Declaration => Non_Trivial_Mapping,
A_Function_Declaration => Non_Trivial_Mapping,
--
A_Parameter_Specification => Non_Trivial_Mapping,
--
A_Procedure_Body_Declaration => Non_Trivial_Mapping,
A_Function_Body_Declaration => Non_Trivial_Mapping,
A_Return_Variable_Specification => Trivial_Mapping,
A_Return_Constant_Specification => Trivial_Mapping,
A_Null_Procedure_Declaration => Trivial_Mapping,
An_Expression_Function_Declaration => Trivial_Mapping,
A_Package_Declaration => Non_Trivial_Mapping,
A_Package_Body_Declaration => Non_Trivial_Mapping,
An_Object_Renaming_Declaration => Trivial_Mapping,
An_Exception_Renaming_Declaration => Trivial_Mapping,
A_Package_Renaming_Declaration => Non_Trivial_Mapping,
A_Procedure_Renaming_Declaration => Non_Trivial_Mapping,
A_Function_Renaming_Declaration => Non_Trivial_Mapping,
A_Generic_Package_Renaming_Declaration => Non_Trivial_Mapping,
A_Generic_Procedure_Renaming_Declaration => Non_Trivial_Mapping,
A_Generic_Function_Renaming_Declaration => Non_Trivial_Mapping,
A_Task_Body_Declaration => Non_Trivial_Mapping,
A_Protected_Body_Declaration => Non_Trivial_Mapping,
An_Entry_Declaration => Non_Trivial_Mapping,
An_Entry_Body_Declaration => Trivial_Mapping,
An_Entry_Index_Specification => Trivial_Mapping,
A_Procedure_Body_Stub => Trivial_Mapping,
A_Function_Body_Stub => Trivial_Mapping,
A_Package_Body_Stub => Trivial_Mapping,
A_Task_Body_Stub => Trivial_Mapping,
A_Protected_Body_Stub => Trivial_Mapping,
An_Exception_Declaration => Trivial_Mapping,
A_Choice_Parameter_Specification => Trivial_Mapping,
--
A_Generic_Procedure_Declaration => Non_Trivial_Mapping,
A_Generic_Function_Declaration => Non_Trivial_Mapping,
A_Generic_Package_Declaration => Non_Trivial_Mapping,
A_Package_Instantiation => Non_Trivial_Mapping,
A_Procedure_Instantiation => Non_Trivial_Mapping,
A_Function_Instantiation => Non_Trivial_Mapping,
A_Formal_Object_Declaration => Trivial_Mapping,
A_Formal_Type_Declaration => Trivial_Mapping,
A_Formal_Incomplete_Type_Declaration => Trivial_Mapping,
A_Formal_Procedure_Declaration => Trivial_Mapping,
A_Formal_Function_Declaration => Trivial_Mapping,
A_Formal_Package_Declaration => Trivial_Mapping,
A_Formal_Package_Declaration_With_Box => Trivial_Mapping,
------------------------------------------------------------------------------
--
-- -- A_Definition, -- Asis.Definitions
--
------------------------------------------------------------------------------
--
-- -- A_Type_Definition,
--
A_Derived_Type_Definition => Trivial_Mapping,
A_Derived_Record_Extension_Definition => Trivial_Mapping,
--
An_Enumeration_Type_Definition => Non_Trivial_Mapping,
--
A_Signed_Integer_Type_Definition => Trivial_Mapping,
A_Modular_Type_Definition => Trivial_Mapping,
--
-- -- A_Root_Type_Definition, ----- #########
--
-- A_Root_Integer_Definition, ----- #########
-- A_Root_Real_Definition, ----- #########
-- A_Root_Fixed_Definition, ----- #########
--
-- A_Universal_Integer_Definition, ----- #########
-- A_Universal_Real_Definition, ----- #########
-- A_Universal_Fixed_Definition, ----- #########
--
--
A_Floating_Point_Definition => Trivial_Mapping,
--
An_Ordinary_Fixed_Point_Definition => Trivial_Mapping,
A_Decimal_Fixed_Point_Definition => Trivial_Mapping,
--
An_Unconstrained_Array_Definition => Trivial_Mapping,
A_Constrained_Array_Definition => Trivial_Mapping,
--
A_Record_Type_Definition => Trivial_Mapping, -- ???
A_Tagged_Record_Type_Definition => Trivial_Mapping, -- ???
-- --|A2005 start
-- An_Interface_Type_Definition,
An_Ordinary_Interface ..
-- A_Limited_Interface,
-- A_Task_Interface,
-- A_Protected_Interface,
A_Synchronized_Interface => Trivial_Mapping,
-- --|A2005 end
-- -- An_Access_Type_Definition,
--
A_Pool_Specific_Access_To_Variable => Trivial_Mapping,
An_Access_To_Variable => Trivial_Mapping,
An_Access_To_Constant => Trivial_Mapping,
--
An_Access_To_Procedure => Trivial_Mapping,
An_Access_To_Protected_Procedure => Trivial_Mapping,
An_Access_To_Function => Trivial_Mapping,
An_Access_To_Protected_Function => Trivial_Mapping,
--
--
A_Subtype_Indication => Non_Trivial_Mapping,
--
-- -- A_Constraint,
--
A_Range_Attribute_Reference => Non_Trivial_Mapping, -- ???
A_Simple_Expression_Range => Non_Trivial_Mapping,
A_Digits_Constraint => Trivial_Mapping,
A_Delta_Constraint => Trivial_Mapping,
An_Index_Constraint => Non_Trivial_Mapping,
A_Discriminant_Constraint => Non_Trivial_Mapping,
--
A_Component_Definition => Trivial_Mapping,
--
-- -- A_Discrete_Subtype_Definition,
--
A_Discrete_Subtype_Indication_As_Subtype_Definition => Trivial_Mapping,
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition => Trivial_Mapping,
A_Discrete_Simple_Expression_Range_As_Subtype_Definition => Trivial_Mapping,
--
-- -- A_Discrete_Range,
--
A_Discrete_Subtype_Indication => Non_Trivial_Mapping,
A_Discrete_Range_Attribute_Reference => Non_Trivial_Mapping,
A_Discrete_Simple_Expression_Range => Non_Trivial_Mapping,
--
--
An_Unknown_Discriminant_Part => Non_Trivial_Mapping,
A_Known_Discriminant_Part => Non_Trivial_Mapping,
--
A_Record_Definition => Non_Trivial_Mapping,
A_Null_Record_Definition => Non_Trivial_Mapping,
--
A_Null_Component => Non_Trivial_Mapping,
A_Variant_Part => Non_Trivial_Mapping,
A_Variant => Trivial_Mapping,
An_Others_Choice => Non_Trivial_Mapping,
-- --|A2005 start
An_Anonymous_Access_To_Variable ..
-- An_Anonymous_Access_To_Constant
-- An_Anonymous_Access_To_Procedure
-- An_Anonymous_Access_To_Protected_Procedure
-- An_Anonymous_Access_To_Function
An_Anonymous_Access_To_Protected_Function => Trivial_Mapping,
-- --|A2005 end
A_Private_Type_Definition => A_Private_Type_Declaration,
A_Tagged_Private_Type_Definition => A_Private_Type_Declaration,
A_Private_Extension_Definition => A_Private_Extension_Declaration,
--
A_Task_Definition => Trivial_Mapping,
A_Protected_Definition => Non_Trivial_Mapping,
--
-- -- A_Formal_Type_Definition,
--
A_Formal_Private_Type_Definition ..
-- A_Formal_Tagged_Private_Type_Definition,
--
-- A_Formal_Derived_Type_Definition,
--
-- A_Formal_Discrete_Type_Definition,
--
-- A_Formal_Signed_Integer_Type_Definition,
-- A_Formal_Modular_Type_Definition,
--
-- A_Formal_Floating_Point_Definition,
--
-- A_Formal_Ordinary_Fixed_Point_Definition,
-- A_Formal_Decimal_Fixed_Point_Definition,
--
-- A_Formal_Unconstrained_Array_Definition,
-- A_Formal_Constrained_Array_Definition,
--
-- -- A_Formal_Access_Type_Definition,
--
-- A_Formal_Pool_Specific_Access_To_Variable,
-- A_Formal_Access_To_Variable,
-- A_Formal_Access_To_Constant,
--
-- A_Formal_Access_To_Procedure,
-- A_Formal_Access_To_Protected_Procedure,
-- A_Formal_Access_To_Function,
-- A_Formal_Access_To_Protected_Function
An_Aspect_Specification => Trivial_Mapping,
--
------------------------------------------------------------------------------
--
-- -- An_Expression, -- Asis.Expressions --##########
--
------------------------------------------------------------------------------
--
An_Integer_Literal => Non_Trivial_Mapping,
A_Box_Expression => Non_Trivial_Mapping,
A_Real_Literal => Non_Trivial_Mapping,
A_String_Literal => Non_Trivial_Mapping,
An_Identifier => Non_Trivial_Mapping,
--
-- -- An_Operator_Symbol,
--
An_And_Operator ..
-- An_Or_Operator,
-- An_Xor_Operator,
-- An_Equal_Operator,
-- A_Not_Equal_Operator,
-- A_Less_Than_Operator,
-- A_Less_Than_Or_Equal_Operator,
-- A_Greater_Than_Operator,
-- A_Greater_Than_Or_Equal_Operator,
-- A_Plus_Operator,
-- A_Minus_Operator,
-- A_Concatenate_Operator,
-- A_Unary_Plus_Operator,
-- A_Unary_Minus_Operator,
-- A_Multiply_Operator,
-- A_Divide_Operator,
-- A_Mod_Operator,
-- A_Rem_Operator,
-- An_Exponentiate_Operator,
-- An_Abs_Operator,
-- A_Not_Operator => A_Function_Call,
A_Not_Operator => Non_Trivial_Mapping,
--
-- A_Character_Literal ..
-- -- An_Enumeration_Literal,
-- An_Explicit_Dereference => Trivial_Mapping,
--
-- A_Function_Call => Non_Trivial_Mapping,
-- --
-- An_Indexed_Component ..
-- A_Slice => Trivial_Mapping,
-- A_Selected_Component => Non_Trivial_Mapping,
-- --
-- -- -- ??? Not_An_Attribute,
-- -- -- An_Attribute_Reference => Non_Trivial_Mapping,
-- --
-- An_Access_Attribute ..
-- -- An_Address_Attribute,
-- -- An_Adjacent_Attribute,
-- -- An_Aft_Attribute,
-- -- An_Alignment_Attribute,
-- -- A_Base_Attribute,
-- -- A_Bit_Order_Attribute,
-- -- A_Body_Version_Attribute,
-- -- A_Callable_Attribute,
-- -- A_Caller_Attribute,
-- -- A_Ceiling_Attribute,
-- -- A_Class_Attribute,
-- -- A_Component_Size_Attribute,
-- -- A_Compose_Attribute,
-- -- A_Constrained_Attribute,
-- -- A_Copy_Sign_Attribute,
-- -- A_Count_Attribute,
-- -- A_Definite_Attribute,
-- -- A_Delta_Attribute,
-- -- A_Denorm_Attribute,
-- -- A_Digits_Attribute,
-- -- An_Exponent_Attribute,
-- -- An_External_Tag_Attribute,
-- -- A_First_Attribute,
-- -- A_First_Bit_Attribute,
-- -- A_Floor_Attribute,
-- -- A_Fore_Attribute,
-- -- A_Fraction_Attribute,
-- -- An_Identity_Attribute,
-- -- An_Image_Attribute,
-- -- An_Input_Attribute,
-- -- A_Last_Attribute,
-- -- A_Last_Bit_Attribute,
-- -- A_Leading_Part_Attribute,
-- -- A_Length_Attribute,
-- -- A_Machine_Attribute,
-- -- A_Machine_Emax_Attribute,
-- -- A_Machine_Emin_Attribute,
-- -- A_Machine_Mantissa_Attribute,
-- -- A_Machine_Overflows_Attribute,
-- -- A_Machine_Radix_Attribute,
-- -- A_Machine_Rounds_Attribute,
-- -- A_Max_Attribute,
-- -- A_Max_Size_In_Storage_Elements_Attribute,
-- -- A_Min_Attribute,
-- -- A_Model_Attribute,
-- -- A_Model_Emin_Attribute,
-- -- A_Model_Epsilon_Attribute,
-- -- A_Model_Mantissa_Attribute,
-- -- A_Model_Small_Attribute,
-- -- A_Modulus_Attribute,
-- -- An_Output_Attribute,
-- -- A_Partition_ID_Attribute,
-- -- A_Pos_Attribute,
-- -- A_Position_Attribute,
-- -- A_Pred_Attribute,
-- -- A_Range_Attribute,
-- -- A_Read_Attribute,
-- -- A_Remainder_Attribute,
-- -- A_Round_Attribute,
-- -- A_Rounding_Attribute,
-- -- A_Safe_First_Attribute,
-- -- A_Safe_Last_Attribute,
-- -- A_Scale_Attribute,
-- -- A_Scaling_Attribute,
-- -- A_Signed_Zeros_Attribute,
-- -- A_Size_Attribute,
-- -- A_Small_Attribute,
-- -- A_Storage_Pool_Attribute,
-- -- A_Storage_Size_Attribute,
-- --
-- -- A_Succ_Attribute,
-- -- A_Tag_Attribute,
-- -- A_Terminated_Attribute,
-- -- A_Truncation_Attribute,
-- -- An_Unbiased_Rounding_Attribute,
-- -- An_Unchecked_Access_Attribute,
-- -- A_Val_Attribute,
-- -- A_Valid_Attribute,
-- -- A_Value_Attribute,
-- -- A_Version_Attribute,
-- -- A_Wide_Image_Attribute,
-- -- A_Wide_Value_Attribute,
-- -- A_Wide_Width_Attribute,
-- -- A_Width_Attribute,
-- -- A_Write_Attribute,
-- --
-- -- An_Implementation_Defined_Attribute, -- Vendor Annex M
-- An_Unknown_Attribute => Non_Trivial_Mapping,
--
-- -- A_Record_Aggregate,
-- -- An_Extension_Aggregate,
-- -- A_Positional_Array_Aggregate,
-- -- A_Named_Array_Aggregate,
-- --
-- -- An_And_Then_Short_Circuit,
-- -- An_Or_Else_Short_Circuit,
-- --
-- -- An_In_Membership_Test
-- -- A_Not_In_Membership_Test
-- --
-- -- A_Null_Literal,
-- -- A_Parenthesized_Expression,
-- --
-- -- A_Type_Conversion,
-- -- A_Qualified_Expression,
-- --
-- -- An_Allocation_From_Subtype,
-- An_Allocation_From_Qualified_Expression,
-- A_Case_Expression, -- Ada 2012
-- An_If_Expression, -- Ada 2012
-- A_For_All_Quantified_Expression, -- Ada 2012
-- A_For_Some_Quantified_Expression); -- Ada 2012
A_Character_Literal ..
A_For_Some_Quantified_Expression => Non_Trivial_Mapping,
--
------------------------------------------------------------------------------
--
-- -- An_Association, -- Asis.Expressions
--
------------------------------------------------------------------------------
--
A_Pragma_Argument_Association => Trivial_Mapping,
A_Discriminant_Association => Non_Trivial_Mapping,
A_Record_Component_Association => Non_Trivial_Mapping,
An_Array_Component_Association => Non_Trivial_Mapping,
A_Parameter_Association => Non_Trivial_Mapping,
A_Generic_Association => Non_Trivial_Mapping,
--
------------------------------------------------------------------------------
--
-- -- A_Statement, -- Asis.Statements
--
-- All subordinates of A_Statement kind require non trivial processing,
-- this processing is the same for all of them except
-- A_Terminate_Alternative_Statement
------------------------------------------------------------------------------
--
A_Null_Statement ..
-- An_Assignment_Statement,
-- An_If_Statement,
-- A_Case_Statement,
--
-- A_Loop_Statement,
-- A_While_Loop_Statement,
-- A_For_Loop_Statement,
--
-- A_Block_Statement,
-- An_Exit_Statement,
-- A_Goto_Statement,
--
-- A_Procedure_Call_Statement,
-- A_Return_Statement,
--
-- An_Accept_Statement,
-- An_Entry_Call_Statement,
--
-- A_Requeue_Statement,
-- A_Requeue_Statement_With_Abort,
--
-- A_Delay_Until_Statement,
-- A_Delay_Relative_Statement,
--
-- A_Terminate_Alternative_Statement,
-- A_Selective_Accept_Statement,
-- A_Timed_Entry_Call_Statement,
-- A_Conditional_Entry_Call_Statement,
-- An_Asynchronous_Select_Statement,
--
-- An_Abort_Statement,
-- A_Raise_Statement,
A_Code_Statement => Non_Trivial_Mapping,
--
------------------------------------------------------------------------------
-- Path_Kinds
-- Literals -- Ada RM 95
--
-- Detailed classification for
-- ASIS_Element_Kinds.Element_Kinds(A_Path) literal
-- corresponds to subtype Internal_Path_Kinds
------------------------------------------------------------------------------
An_If_Path => An_If_Statement,
An_Elsif_Path => Trivial_Mapping,
An_Else_Path => Non_Trivial_Mapping,
A_Case_Path => Trivial_Mapping,
A_Select_Path => Trivial_Mapping,
An_Or_Path => Trivial_Mapping,
A_Then_Abort_Path => Trivial_Mapping,
--
------------------------------------------------------------
-- An_Expression_Path, -- Asis.Expressions Ada 2015
-- Detailed classification for Asis.Element_Kinds (An_Expression_Path)
-- literal corresponds to subtype Internal_Expression_Path_Kinds
------------------------------------------------------------
An_If_Expression_Path ..
-- An_Elsif_Expression_Path,
An_Else_Expression_Path => Non_Trivial_Mapping,
------------------------------------------------------------------------
--
-- -- A_Clause, -- Asis.Clauses
--
------------------------------------------------------------------------------
--
A_Use_Package_Clause => Non_Trivial_Mapping,
A_Use_Type_Clause => Non_Trivial_Mapping,
A_Use_All_Type_Clause => Non_Trivial_Mapping,
A_With_Clause => Not_An_Element,
--
-- -- A_Representation_Clause,
--
An_Attribute_Definition_Clause => Non_Trivial_Mapping,
An_Enumeration_Representation_Clause => Trivial_Mapping,
A_Record_Representation_Clause => Trivial_Mapping,
An_At_Clause => Trivial_Mapping,
--
--
A_Component_Clause => Trivial_Mapping,
--
------------------------------------------------------------------------------
--
An_Exception_Handler => Non_Trivial_Mapping,
--
------------------------------------------------------------------------------
-- Special values added for Node -> Element and
-- Element -> Enclosing Element switching,
------------------------------------------------------------------------------
Non_Trivial_Mapping => No_Mapping,
Not_Implemented_Mapping => No_Mapping,
Trivial_Mapping => No_Mapping,
No_Mapping => No_Mapping,
others => Not_Implemented_Mapping
);
-------------------------------------------------------------------------
-- Section 2 - declarations of routines implementing various cases of --
-- non-trivial bottom up compiler tree traversing and --
-- accessed though the second switch --
-------------------------------------------------------------------------
function Not_Implemented_Enclosing_Element_Construction
(Element : Asis.Element) return Asis.Element;
-- Placeholders for "others" choice
-- The functions below computes Enclosing_Elememnt for specific Element
-- kinds; the corresponding situations cannot be covered by
-- General_Encl_Elem
function A_Pragma_Enclosing (Element : Asis.Element) return Asis.Element;
function A_Defining_Expanded_Name_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Defining_Identifier_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Defining_Operator_Symbol_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Constant_Declaration_Enclosing
(Element : Asis.Element)
return Asis.Element;
function An_Enumeration_Literal_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Discriminant_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Loop_Parameter_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Parameter_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element;
function An_Enumeration_Type_Definition_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Subtype_Indication_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Range_Attribute_Reference_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Simple_Expression_Range_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Discrete_Range_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Discriminant_Part_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Record_Component_Association_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Record_Definition_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Null_Component_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Variant_Part_Enclosing
(Element : Asis.Element)
return Asis.Element;
function An_Others_Choice_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Box_Expression_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Statement_Enclosing
(Element : Asis.Element)
return Asis.Element;
function A_Terminate_Alternative_Statement_Enclosing
(Element : Asis.Element)
return Asis.Element;
function An_Else_Path_Enclosing
(Element : Asis.Element)
return Asis.Element;
function An_Attribute_Definition_Clause_Enclosing
(Element : Asis.Element)
return Asis.Element;
function An_Exception_Handler_Enclosing
(Element : Asis.Element)
return Asis.Element;
function Possible_C_U_Enclosing
(Element : Asis.Element)
return Asis.Element;
-- Called in a situation when Enclosing_Element may have to be Nil_Element,
-- because we may reach the very top of the Element hierarchy of an ASIS
-- Compilation_Unit, so logically the next step up should be from Elements
-- into enclosing unit.
function An_Association_Enclosing
(Element : Asis.Element)
return Asis.Element;
-- Computes the Enclosing Element for parameter associations. The main
-- difference with An_Expression_Enclosing is that here we may have to deal
-- with normalized associations
function An_Expression_Enclosing
(Element : Asis.Element)
return Asis.Element;
-- This function implements the part of the semantic of the
-- Asis.Elements.Enclosing_Element function corresponding to the
-- enclosing element retrieving for elements representing Ada explicit
-- constructs. It deals only with expressions - the hardest part
-- for Enclosing_Element.
--------------------------------------------------------------------
-- Section 3 - definition of the second Enclosing_Element switch --
-- (maps Element kind requiring non-trivial actions --
-- onto corresponding routines --
--------------------------------------------------------------------
type Enclosing_Element_Construction_For_Explicits_Items is access
function (Element : Asis.Element) return Asis.Element;
-- access to the local items of the constructing the Enclosing Elements
-- for Explicit constructs
Enclosing_Element_For_Explicits_Second_Switch : constant
array (Internal_Element_Kinds)
of Enclosing_Element_Construction_For_Explicits_Items :=
(
-- type Internal_Element_Kinds is (
--
-- Not_An_Element, -- Asis.Nil_Element
--
------------------------------------------------------------------------------
-- A_Pragma, -- Asis.Elements
------------------------------------------------------------------------------
An_All_Calls_Remote_Pragma ..
-- An_Asynchronous_Pragma,
-- An_Atomic_Pragma,
-- An_Atomic_Components_Pragma,
-- An_Attach_Handler_Pragma,
-- A_Controlled_Pragma,
-- A_Convention_Pragma,
-- A_Discard_Names_Pragma,
-- An_Elaborate_Pragma,
-- An_Elaborate_All_Pragma,
-- An_Elaborate_Body_Pragma,
-- An_Export_Pragma,
-- An_Import_Pragma,
-- An_Inline_Pragma,
-- An_Inspection_Point_Pragma,
-- An_Interrupt_Handler_Pragma,
-- An_Interrupt_Priority_Pragma,
-- A_Linker_Options_Pragma
-- A_List_Pragma,
-- A_Locking_Policy_Pragma,
-- A_Normalize_Scalars_Pragma,
-- An_Optimize_Pragma,
-- A_Pack_Pragma,
-- A_Page_Pragma,
-- A_Preelaborate_Pragma,
-- A_Priority_Pragma,
-- A_Pure_Pragma,
-- A_Queuing_Policy_Pragma,
-- A_Remote_Call_Interface_Pragma,
-- A_Remote_Types_Pragma,
-- A_Restrictions_Pragma,
-- A_Reviewable_Pragma,
-- A_Shared_Passive_Pragma,
-- A_Storage_Size_Pragma,
-- A_Suppress_Pragma,
-- A_Task_Dispatching_Policy_Pragma,
-- A_Volatile_Pragma,
-- A_Volatile_Components_Pragma,
--
-- An_Implementation_Defined_Pragma,
--
An_Unknown_Pragma => A_Pragma_Enclosing'Access,
------------------------------------------------------------------------------
-- A_Defining_Name, -- Asis.Declarations
------------------------------------------------------------------------------
A_Defining_Identifier => A_Defining_Identifier_Enclosing'Access,
-- A_Defining_Character_Literal, -- an Enclosing Element is based
-- A_Defining_Enumeration_Literal, -- on the same Node
--
-- -- A_Defining_Operator_Symbol
--
A_Defining_And_Operator ..
-- A_Defining_Or_Operator,
-- A_Defining_Xor_Operator,
-- A_Defining_Equal_Operator,
-- A_Defining_Not_Equal_Operator,
-- A_Defining_Less_Than_Operator,
-- A_Defining_Less_Than_Or_Equal_Operator,
-- A_Defining_Greater_Than_Operator,
-- A_Defining_Greater_Than_Or_Equal_Operator,
-- A_Defining_Plus_Operator,
-- A_Defining_Minus_Operator,
-- A_Defining_Concatenate_Operator,
-- A_Defining_Unary_Plus_Operator,
-- A_Defining_Unary_Minus_Operator,
-- A_Defining_Multiply_Operator,
-- A_Defining_Divide_Operator,
-- A_Defining_Mod_Operator,
-- A_Defining_Rem_Operator,
-- A_Defining_Exponentiate_Operator,
-- A_Defining_Abs_Operator,
A_Defining_Not_Operator => A_Defining_Operator_Symbol_Enclosing'Access,
A_Defining_Expanded_Name => A_Defining_Expanded_Name_Enclosing'Access,
--
-------------------------------------------------------------------------------
--
-- -- A_Declaration, -- Asis.Declarations
--
-------------------------------------------------------------------------------
--
-- An_Ordinary_Type_Declaration, -- 3.2.1
-- A_Task_Type_Declaration, -- 3.2.1
-- A_Protected_Type_Declaration, -- 3.2.1
-- An_Incomplete_Type_Declaration, -- 3.2.1
-- A_Private_Type_Declaration, -- 3.2.1
-- A_Private_Extension_Declaration, -- 3.2.1
--
-- A_Subtype_Declaration, -- 3.2.2
--
-- A_Variable_Declaration, -- 3.3.1 -> Trait_Kinds
A_Constant_Declaration => A_Constant_Declaration_Enclosing'Access,
-- This is turned off, see G416-009
-- A_Deferred_Constant_Declaration, -- 3.3.1 -> Trait_Kinds
-- A_Single_Task_Declaration, -- 3.3.1
-- A_Single_Protected_Declaration, -- 3.3.1
--
-- An_Integer_Number_Declaration, -- 3.3.2
-- A_Real_Number_Declaration, -- 3.3.2
--
An_Enumeration_Literal_Specification =>
An_Enumeration_Literal_Specification_Enclosing'Access,
--
A_Discriminant_Specification => A_Discriminant_Specification_Enclosing'Access,
--
-- A_Component_Declaration => A_Component_Declaration_Enclosing'Access,
A_Component_Declaration => An_Expression_Enclosing'Access,
--
A_Loop_Parameter_Specification =>
A_Loop_Parameter_Specification_Enclosing'Access,
A_Generalized_Iterator_Specification ..
An_Element_Iterator_Specification =>
A_Loop_Parameter_Specification_Enclosing'Access,
--
A_Procedure_Declaration => Possible_C_U_Enclosing'Access,
A_Function_Declaration => Possible_C_U_Enclosing'Access,
--
A_Parameter_Specification => A_Parameter_Specification_Enclosing'Access,
A_Procedure_Body_Declaration => Possible_C_U_Enclosing'Access,
A_Function_Body_Declaration => Possible_C_U_Enclosing'Access,
--
A_Package_Declaration => Possible_C_U_Enclosing'Access,
A_Package_Body_Declaration => Possible_C_U_Enclosing'Access,
--
-- An_Object_Renaming_Declaration, -- 8.5.1
-- An_Exception_Renaming_Declaration, -- 8.5.2
A_Package_Renaming_Declaration => Possible_C_U_Enclosing'Access,
A_Procedure_Renaming_Declaration => Possible_C_U_Enclosing'Access,
A_Function_Renaming_Declaration => Possible_C_U_Enclosing'Access,
A_Generic_Package_Renaming_Declaration => Possible_C_U_Enclosing'Access,
A_Generic_Procedure_Renaming_Declaration => Possible_C_U_Enclosing'Access,
A_Generic_Function_Renaming_Declaration => Possible_C_U_Enclosing'Access,
A_Task_Body_Declaration => Possible_C_U_Enclosing'Access,
A_Protected_Body_Declaration => Possible_C_U_Enclosing'Access,
--
An_Entry_Declaration => An_Expression_Enclosing'Access,
-- for entry declarations, the problem is for single task declarations
-- rewritten as anonymous task type declaration and task object declaration,
-- that's why we have to use An_Expression_Enclosing
-- An_Entry_Body_Declaration, -- 9.5.2
-- An_Entry_Index_Specification, -- 9.5.2
--
-- A_Procedure_Body_Stub, -- 10.1.3
-- A_Function_Body_Stub, -- 10.1.3
-- A_Package_Body_Stub, -- 10.1.3
-- A_Task_Body_Stub, -- 10.1.3
-- A_Protected_Body_Stub, -- 10.1.3
--
-- An_Exception_Declaration, -- 11.1
-- A_Choice_Parameter_Specification, -- 11.2
--
A_Generic_Procedure_Declaration => Possible_C_U_Enclosing'Access,
A_Generic_Function_Declaration => Possible_C_U_Enclosing'Access,
A_Generic_Package_Declaration => Possible_C_U_Enclosing'Access,
A_Package_Instantiation => Possible_C_U_Enclosing'Access,
A_Procedure_Instantiation => Possible_C_U_Enclosing'Access,
A_Function_Instantiation => Possible_C_U_Enclosing'Access,
--
-- A_Formal_Object_Declaration, -- 12.4 -> Mode_Kinds
--
-- A_Formal_Type_Declaration, -- 12.5
-- A_Formal_Procedure_Declaration, -- 12.6 -> Default_Kinds
--
-- A_Formal_Function_Declaration, -- 12.6 -> Default_Kinds
--
-- A_Formal_Package_Declaration, -- 12.7
-- A_Formal_Package_Declaration_With_Box, -- 12.7
--
-------------------------------------------------------------------------------
--
-- -- A_Definition, -- Asis.Definitions
--
-------------------------------------------------------------------------------
--
-- -- A_Type_Definition, -- 3.2.1 -> Type_Kinds
--
-- A_Derived_Type_Definition, -- 3.4 -> Trait_Kinds
-- A_Derived_Record_Extension_Definition, -- 3.4 -> Trait_Kinds
--
An_Enumeration_Type_Definition =>
An_Enumeration_Type_Definition_Enclosing'Access,
--
-- A_Signed_Integer_Type_Definition, -- 3.5.4
-- A_Modular_Type_Definition, -- 3.5.4
--
-- -- A_Root_Type_Definition, -- 3.5.4(10), 3.5.6(4)
-- -- -> Root_Type_Kinds
-- A_Root_Integer_Definition, -- 3.5.4(9)
-- A_Root_Real_Definition, -- 3.5.6(2)
-- A_Root_Fixed_Definition, -- 3.5.6(2)
--
-- A_Universal_Integer_Definition, -- 3.5.4(10)
-- A_Universal_Real_Definition, -- 3.5.6(4)
-- A_Universal_Fixed_Definition, -- 3.5.6(4)
--
--
-- A_Floating_Point_Definition, -- 3.5.7
--
-- An_Ordinary_Fixed_Point_Definition, -- 3.5.9
-- A_Decimal_Fixed_Point_Definition, -- 3.5.9
--
-- An_Unconstrained_Array_Definition, -- 3.6
-- A_Constrained_Array_Definition, -- 3.6
--
-- A_Record_Type_Definition, -- 3.8 -> Trait_Kinds
-- A_Tagged_Record_Type_Definition, -- 3.8 -> Trait_Kinds
--
-- -- An_Access_Type_Definition, -- 3.10 -> Access_Type_Kinds
--
-- A_Pool_Specific_Access_To_Variable,
-- An_Access_To_Variable,
-- An_Access_To_Constant,
--
-- An_Access_To_Procedure,
-- An_Access_To_Protected_Procedure,
-- An_Access_To_Function,
-- An_Access_To_Protected_Function,
--
--
A_Subtype_Indication => A_Subtype_Indication_Enclosing'Access,
--
-- -- A_Constraint, -- 3.2.2 -> Constraint_Kinds
--
A_Range_Attribute_Reference => A_Range_Attribute_Reference_Enclosing'Access,
A_Simple_Expression_Range => A_Simple_Expression_Range_Enclosing'Access,
-- A_Digits_Constraint, -- 3.2.2, 3.5.9
-- A_Delta_Constraint, -- 3.2.2, N.3
-- An_Index_Constraint => An_Index_Constraint_Enclosing'Access,
An_Index_Constraint => An_Expression_Enclosing'Access,
A_Discriminant_Constraint => An_Expression_Enclosing'Access,
--
-- A_Component_Definition, -- 3.6
--
-- -- A_Discrete_Subtype_Definition, -- 3.6 -> Discrete_Range_Kinds
--
-- A_Discrete_Subtype_Indication_As_Subtype_Definition,
-- A_Discrete_Range_Attribute_Reference_As_Subtype_Definition,
-- A_Discrete_Simple_Expression_Range_As_Subtype_Definition,
--
-- -- A_Discrete_Range, -- 3.6.1 -> Discrete_Range_Kinds
--
A_Discrete_Subtype_Indication => A_Discrete_Range_Enclosing'Access,
A_Discrete_Range_Attribute_Reference => A_Discrete_Range_Enclosing'Access,
A_Discrete_Simple_Expression_Range => A_Discrete_Range_Enclosing'Access,
--
--
An_Unknown_Discriminant_Part => A_Discriminant_Part_Enclosing'Access,
A_Known_Discriminant_Part => A_Discriminant_Part_Enclosing'Access,
--
A_Record_Definition => A_Record_Definition_Enclosing'Access,
A_Null_Record_Definition => A_Record_Definition_Enclosing'Access,
--
A_Null_Component => A_Null_Component_Enclosing'Access,
A_Variant_Part => A_Variant_Part_Enclosing'Access,
-- A_Variant, -- 3.8
--
An_Others_Choice => An_Others_Choice_Enclosing'Access,
-- A_Private_Type_Definition, -- 7.3 -> Trait_Kinds
-- A_Tagged_Private_Type_Definition, -- 7.3 -> Trait_Kinds
-- A_Private_Extension_Definition, -- 7.3 -> Trait_Kinds
--
-- A_Task_Definition, -- 9.1
A_Protected_Definition => An_Expression_Enclosing'Access,
--
-- -- A_Formal_Type_Definition, -- 12.5 -> Formal_Type_Kinds
--
-- A_Formal_Private_Type_Definition, -- 12.5.1 -> Trait_Kinds
-- A_Formal_Tagged_Private_Type_Definition, -- 12.5.1 -> Trait_Kinds
--
-- A_Formal_Derived_Type_Definition, -- 12.5.1 -> Trait_Kinds
--
-- A_Formal_Discrete_Type_Definition, -- 12.5.2
--
-- A_Formal_Signed_Integer_Type_Definition, -- 12.5.2
-- A_Formal_Modular_Type_Definition, -- 12.5.2
--
-- A_Formal_Floating_Point_Definition, -- 12.5.2
--
-- A_Formal_Ordinary_Fixed_Point_Definition, -- 12.5.2
-- A_Formal_Decimal_Fixed_Point_Definition, -- 12.5.2
--
-- A_Formal_Unconstrained_Array_Definition, -- 12.5.3
-- A_Formal_Constrained_Array_Definition, -- 12.5.3
--
-- -- A_Formal_Access_Type_Definition,
--
-- A_Formal_Pool_Specific_Access_To_Variable,
-- A_Formal_Access_To_Variable,
-- A_Formal_Access_To_Constant,
--
-- A_Formal_Access_To_Procedure,
-- A_Formal_Access_To_Protected_Procedure,
-- A_Formal_Access_To_Function,
-- A_Formal_Access_To_Protected_Function,
--
-------------------------------------------------------------------------------
--
-- -- An_Expression, -- Asis.Expressions
--
-------------------------------------------------------------------------------
-- --
A_Box_Expression => A_Box_Expression_Enclosing'Access,
An_Integer_Literal ..
-- -- A_Real_Literal, -- 2.4.1
-- A_String_Literal => A_Literal_Enclosing'Access,
-- --
An_Identifier => An_Expression_Enclosing'Access,
-- An_Identifier => An_Identifier_Enclosing'Access,
-- --
-- ---- An_Operator_Symbol, -- 4.1
-- --
An_And_Operator ..
-- -- An_Or_Operator, -- or
-- -- An_Xor_Operator, -- xor
-- -- An_Equal_Operator, -- =
-- -- A_Not_Equal_Operator, -- /=
-- -- A_Less_Than_Operator, -- <
-- -- A_Less_Than_Or_Equal_Operator, -- <=
-- -- A_Greater_Than_Operator, -- >
-- -- A_Greater_Than_Or_Equal_Operator, -- >=
-- -- A_Plus_Operator, -- +
-- -- A_Minus_Operator, -- -
-- -- A_Concatenate_Operator, -- &
-- -- A_Unary_Plus_Operator, -- +
-- -- A_Unary_Minus_Operator, -- -
-- -- A_Multiply_Operator, -- *
-- -- A_Divide_Operator, -- /
-- -- A_Mod_Operator, -- mod
-- -- A_Rem_Operator, -- rem
-- -- An_Exponentiate_Operator, -- **
-- -- An_Abs_Operator, -- abs
-- A_Not_Operator => An_Operator_Symbol_Enclosing'Access,
-- ??? Do we need An_Operator_Symbol_Enclosing???
A_Not_Operator => An_Expression_Enclosing'Access,
-- --
A_Character_Literal ..
-- -- An_Enumeration_Literal, -- 4.1
-- -- An_Explicit_Dereference, -- 4.1
--
-- A_Function_Call => A_Function_Call_Enclosing'Access,
-- --
-- -- An_Indexed_Component, -- 4.1.1
-- -- A_Slice, -- 4.1.2
-- A_Selected_Component => An_Identifier_Enclosing'Access,
-- --
-- -- An_Attribute_Reference, -- 4.1.4 -> Attribute_Kinds
-- --
-- An_Access_Attribute ..
-- -- An_Address_Attribute,
-- -- An_Adjacent_Attribute,
-- -- An_Aft_Attribute,
-- -- An_Alignment_Attribute,
-- -- A_Base_Attribute,
-- -- A_Bit_Order_Attribute,
-- -- A_Body_Version_Attribute,
-- -- A_Callable_Attribute,
-- -- A_Caller_Attribute,
-- -- A_Ceiling_Attribute,
-- -- A_Class_Attribute,
-- -- A_Component_Size_Attribute,
-- -- A_Compose_Attribute,
-- -- A_Constrained_Attribute,
-- -- A_Copy_Sign_Attribute,
-- -- A_Count_Attribute,
-- -- A_Definite_Attribute,
-- -- A_Delta_Attribute,
-- -- A_Denorm_Attribute,
-- -- A_Digits_Attribute,
-- -- An_Exponent_Attribute,
-- -- An_External_Tag_Attribute,
-- -- A_First_Attribute,
-- -- A_First_Bit_Attribute,
-- -- A_Floor_Attribute,
-- -- A_Fore_Attribute,
-- -- A_Fraction_Attribute,
-- -- An_Identity_Attribute,
-- -- An_Image_Attribute,
-- -- An_Input_Attribute,
-- -- A_Last_Attribute,
-- -- A_Last_Bit_Attribute,
-- -- A_Leading_Part_Attribute,
-- -- A_Length_Attribute,
-- -- A_Machine_Attribute,
-- -- A_Machine_Emax_Attribute,
-- -- A_Machine_Emin_Attribute,
-- -- A_Machine_Mantissa_Attribute,
-- -- A_Machine_Overflows_Attribute,
-- -- A_Machine_Radix_Attribute,
-- -- A_Machine_Rounds_Attribute,
-- -- A_Max_Attribute,
-- -- A_Max_Size_In_Storage_Elements_Attribute,
-- -- A_Min_Attribute,
-- -- A_Model_Attribute,
-- -- A_Model_Emin_Attribute,
-- -- A_Model_Epsilon_Attribute,
-- -- A_Model_Mantissa_Attribute,
-- -- A_Model_Small_Attribute,
-- -- A_Modulus_Attribute,
-- -- An_Output_Attribute,
-- -- A_Partition_ID_Attribute,
-- -- A_Pos_Attribute,
-- -- A_Position_Attribute,
-- A_Pred_Attribute => An_Attribute_Reference_Enclosing'Access,
--
-- A_Range_Attribute => A_Range_Attribute_Enclosing'Access,
--
-- A_Read_Attribute ..
-- -- A_Remainder_Attribute,
-- -- A_Round_Attribute,
-- -- A_Rounding_Attribute,
-- -- A_Safe_First_Attribute,
-- -- A_Safe_Last_Attribute,
-- -- A_Scale_Attribute,
-- -- A_Scaling_Attribute,
-- -- A_Signed_Zeros_Attribute,
-- -- A_Size_Attribute,
-- -- A_Small_Attribute,
-- -- A_Storage_Pool_Attribute,
-- -- A_Storage_Size_Attribute,
-- --
-- -- A_Succ_Attribute,
-- -- A_Tag_Attribute,
-- -- A_Terminated_Attribute,
-- -- A_Truncation_Attribute,
-- -- An_Unbiased_Rounding_Attribute,
-- -- An_Unchecked_Access_Attribute,
-- -- A_Val_Attribute,
-- -- A_Valid_Attribute,
-- -- A_Value_Attribute,
-- -- A_Version_Attribute,
-- -- A_Wide_Image_Attribute,
-- -- A_Wide_Value_Attribute,
-- -- A_Wide_Width_Attribute,
-- -- A_Width_Attribute,
-- -- A_Write_Attribute,
-- --
-- -- An_Implementation_Defined_Attribute, -- Vendor Annex M
-- An_Unknown_Attribute => An_Attribute_Reference_Enclosing'Access,
-- --
-- -- A_Record_Aggregate, -- 4.3
-- -- An_Extension_Aggregate, -- 4.3
-- -- A_Positional_Array_Aggregate, -- 4.3
-- -- A_Named_Array_Aggregate, -- 4.3
-- --
-- -- An_And_Then_Short_Circuit, -- 4.4
-- -- An_Or_Else_Short_Circuit, -- 4.4
-- --
-- -- An_In_Membership_Test, -- 4.4 Ada 2012
-- -- A_Not_In_Membership_Test -- 4.4 Ada 2012
-- --
-- -- A_Null_Literal, -- 4.4
-- -- A_Parenthesized_Expression, -- 4.4
-- --
-- -- A_Type_Conversion, -- 4.6
-- -- A_Qualified_Expression, -- 4.7
-- --
-- -- An_Allocation_From_Subtype, -- 4.8
-- -- An_Allocation_From_Qualified_Expression, -- 4.8
-- A_Case_Expression, -- Ada 2012
-- An_If_Expression, -- Ada 2012
-- A_For_All_Quantified_Expression, -- Ada 2012
-- A_For_Some_Quantified_Expression); -- Ada 2012
A_For_Some_Quantified_Expression => An_Expression_Enclosing'Access,
-------------------------------------------------------------------------------
--
-- -- An_Association, -- Asis.Expressions
--
-------------------------------------------------------------------------------
--
-- A_Pragma_Argument_Association, -- 2.8
A_Discriminant_Association => An_Expression_Enclosing'Access,
A_Record_Component_Association =>
A_Record_Component_Association_Enclosing'Access,
An_Array_Component_Association => An_Expression_Enclosing'Access,
A_Parameter_Association .. A_Generic_Association =>
An_Association_Enclosing'Access,
--
-------------------------------------------------------------------------------
--
-- -- A_Statement, -- Asis.Statements
--
-------------------------------------------------------------------------------
--
A_Null_Statement ..
-- An_Assignment_Statement, -- 5.2
-- An_If_Statement, -- 5.3
-- A_Case_Statement, -- 5.4
--
-- A_Loop_Statement, -- 5.5
-- A_While_Loop_Statement, -- 5.5
-- A_For_Loop_Statement, -- 5.5
--
-- A_Block_Statement, -- 5.6
-- An_Exit_Statement, -- 5.7
-- A_Goto_Statement, -- 5.8
--
-- A_Procedure_Call_Statement, -- 6.4
-- A_Return_Statement, -- 6.5
--
-- An_Accept_Statement, -- 9.5.2
-- An_Entry_Call_Statement, -- 9.5.3
--
-- A_Requeue_Statement, -- 9.5.4
-- A_Requeue_Statement_With_Abort, -- 9.5.4
--
-- A_Delay_Until_Statement, -- 9.6
A_Delay_Relative_Statement => A_Statement_Enclosing'Access,
--
A_Terminate_Alternative_Statement =>
A_Terminate_Alternative_Statement_Enclosing'Access,
--
A_Selective_Accept_Statement ..
-- A_Timed_Entry_Call_Statement, -- 9.7.3
-- A_Conditional_Entry_Call_Statement, -- 9.7.3
-- An_Asynchronous_Select_Statement, -- 9.7.4
--
-- An_Abort_Statement, -- 9.8
-- A_Raise_Statement, -- 11.3
A_Code_Statement => A_Statement_Enclosing'Access,
--
-------------------------------------------------------------------------------
-- Path_Kinds
-- Literals -- RM 95
------------------------------------------------------------------------------
--
-- An_If_Path,
-- An_Elsif_Path,
--
An_Else_Path => An_Else_Path_Enclosing'Access,
--
-- A_Case_Path,
-- -- when discrete_choice_list =>
-- -- sequence_of_statements
--
-- A_Select_Path,
-- -- select [guard] select_alternative
-- -- 9.7.2, 9.7.3:
-- -- select entry_call_alternative
-- -- 9.7.4:
-- -- select triggering_alternative
--
-- An_Or_Path,
-- -- or [guard] select_alternative 9.7.2:
-- -- or delay_alternative
--
-- A_Then_Abort_Path, -- 9.7.4
-- -- then abort sequence_of_statements
--
--
------------------------------------------------------------
-- An_Expression_Path, -- Asis.Expressions Ada 2015
------------------------------------------------------------
An_If_Expression_Path ..
-- An_Elsif_Expression_Path,
An_Else_Expression_Path => An_Expression_Enclosing'Access,
-------------------------------------------------------------------------------
--
-- -- A_Clause, -- Asis.Clauses
--
-------------------------------------------------------------------------------
--
A_Use_Package_Clause => Possible_C_U_Enclosing'Access, -- 8.4
A_Use_Type_Clause => Possible_C_U_Enclosing'Access, -- 8.4
A_Use_All_Type_Clause => Possible_C_U_Enclosing'Access, -- 8.4 Ada 2012
--
-- A_With_Clause, -- 10.1.2
--
-- -- A_Representation_Clause, -- 13.1 -> Representation_Clause_Kinds
--
An_Attribute_Definition_Clause =>
An_Attribute_Definition_Clause_Enclosing'Access,
-- An_Enumeration_Representation_Clause, -- 13.4
-- A_Record_Representation_Clause, -- 13.5.3
-- An_At_Clause, -- N.7
--
--
-- A_Component_Clause, -- 13.5.3
--
-------------------------------------------------------------------------------
--
An_Exception_Handler => An_Exception_Handler_Enclosing'Access,
--
-------------------------------------------------------------------------------
-- -- Special values added for Node -> Element switching,
-- -- see Asis_Vendor_Primitives.GNAT_to_Asis_Mapping body for
-- -- more details
-------------------------------------------------------------------------------
--
-- Non_Trivial_Mapping,
-- Not_Implemented_Mapping,
-- No_Mapping
--
others => Not_Implemented_Enclosing_Element_Construction'Access);
------------------------------------------------------
-- Section 4 - (general-purpose) local subprograms --
------------------------------------------------------
procedure Skip_Implicit_Subtype (Constr : in out Node_Id);
-- Supposing that Constr is a constraint, this procedure checks if the
-- parent node for it points to implicit subtype created in case if
-- this constraint is used directly in object declaration, and if
-- so, resets Constr to point to the constraint from the object
-- declaration
function Parent (Node : Node_Id) return Node_Id;
-- this function is the modification of Atree.Parent. It is able
-- to deal in the "ASIS mode" with the sequences of one-identifier
-- declarations/with clauses resulting from the normalization of
-- multi-name declarations/with clauses which is done by the
-- compiler
function General_Encl_Elem (Element : Asis.Element) return Asis.Element;
-- Computes Enclosing_Element for most common cases
procedure No_Enclosing_Element (Element_Kind : Internal_Element_Kinds);
-- Should be called only in erroneous situations, when no Enclosing_Element
-- can correspond to a given Element. Raises ASIS_Failed with the
-- corresponding Diagnosis
procedure Not_Implemented_Enclosing_Element_Construction
(Element : Asis.Element);
-- Generates Element-specific diagnosis about non-implemented case
function Is_Top_Of_Expanded_Generic (N : Node_Id) return Boolean;
-- Checks if N is the top node of the tree structure corresponding to
-- expanded generic spec or body
function Get_Rough_Enclosing_Node (Element : Asis.Element) return Node_Id;
-- This function finds the node, which is the base for a "rough"
-- enclosing element for the argument Element. Starting from the
-- argument R_Node, we go up through the chain of Parent nodes
-- till the first node, which is a member of some Node_List or to the node
-- representing the unit declaration in a compilation unit
function Get_Enclosing
(Approximation : Asis.Element;
Element : Asis.Element)
return Asis.Element;
-- This function finds the Enclosing Element for Element by traversing
-- Approximation which is considered as a rough estimation for
-- enclosing element.
procedure Skip_Normalized_Declarations_Back (Node : in out Node_Id);
-- this procedure is applied in case when the compiler may normalize a
-- multi-identifier declaration (or multi-name with clause) in a set of
-- equivalent one-identifier (one-name) declarations (clauses). It is
-- intended to be called for Node representing any declaration
-- (clause) in this normalized sequence, and it resets its parameter
-- to point to the first declaration (clause) in this sequence
--
-- There is no harm to call this procedure for Node which does not
-- represent a normalized declaration (or even which does not represent
-- any declaration at all), or for Node which represents the first
-- declaration in a normalized chain - the procedure simply leaves
-- its parameter intact.
--
-- (In some sense this procedure may be considered as an "inversion
-- of the local procedure Skip_Normalized_Declarations defined in
-- the body of the A4G.Mapping package)
---------------------------------------------------------------
-- Section 5 - bodies of the routines declared in Section 2 --
---------------------------------------------------------------
--------------------------------
-- A_Box_Expression_Enclosing --
--------------------------------
function A_Box_Expression_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Res_Kind : Internal_Element_Kinds;
Par_Node : Node_Id := Parent (R_Node (Element));
Result : Asis.Element := Element;
begin
case Nkind (Par_Node) is
when N_Aggregate =>
Par_Node := Etype (Par_Node);
if Ekind (Par_Node) in Record_Kind then
Res_Kind := A_Record_Component_Association;
else
Res_Kind := An_Array_Component_Association;
end if;
when N_Extension_Aggregate =>
Res_Kind := A_Record_Component_Association;
when N_Package_Declaration =>
Res_Kind := A_Generic_Association;
when others =>
pragma Assert (False);
null;
end case;
Set_Int_Kind (Result, Res_Kind);
return Result;
end A_Box_Expression_Enclosing;
--------------------------------------
-- A_Constant_Declaration_Enclosing --
--------------------------------------
function A_Constant_Declaration_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result : Asis.Element := General_Encl_Elem (Element);
Res_Node : Node_Id;
begin
-- The problem with constant declarations exists for a declarations
-- created by the front-end to pass the actual expressions for generic
-- IN parameters, see EC16-004 and EC22-007
Res_Node := Node (Element);
if Present (Corresponding_Generic_Association (Res_Node)) then
Res_Node := Parent (Res_Node);
if No (Generic_Parent (Res_Node)) then
-- This IF statement prevents us from doing this special
-- processing for expanded package declarations, we have to do it
-- only for wrapper packages created for subprogram instantiation
Res_Node := Parent (Res_Node);
Res_Node := Corresponding_Body (Res_Node);
Res_Node := Parent (Res_Node);
Res_Node := First (Sinfo.Declarations (Res_Node));
while Nkind (Res_Node) /= N_Subprogram_Body loop
Res_Node := Next (Res_Node);
end loop;
Result := Node_To_Element_New (Node => Res_Node,
Starting_Element => Element);
end if;
end if;
return Result;
end A_Constant_Declaration_Enclosing;
----------------------------------------
-- A_Defining_Expanded_Name_Enclosing --
---------------------------------------
function A_Defining_Expanded_Name_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : Node_Id := Parent (R_Node (Element));
Parent_Node_Kind : constant Node_Kind := Nkind (Parent_Node);
begin
if Parent_Node_Kind = N_Function_Specification or else
Parent_Node_Kind = N_Procedure_Specification or else
Parent_Node_Kind = N_Package_Specification
then -- one more step up required
Parent_Node := Parent (Parent_Node);
end if;
return Node_To_Element_New (Node => Parent_Node,
Starting_Element => Element);
end A_Defining_Expanded_Name_Enclosing;
-------------------------------------
-- A_Defining_Identifier_Enclosing --
-------------------------------------
function A_Defining_Identifier_Enclosing
(Element : Asis.Element)
return Asis.Element
is
-- A_Defining_Identifier may be processed just in the same way as
-- A_Defining_Expanded_Name, except the following cases:
-- - A_Defining_Identifier obtained as the child of
-- A_Choice_Parameter_Specification element (by means of Names
-- query) - both these elements are based on the same
-- N_Defining_Identifier node
--
-- - A_Defining_Identifier representing a statement label, it is
-- obtained by means of Label_Names query, and it is based on
-- N_Label node which is the member of the node list representing
-- the corresponding statement sequence (or it can be based on
-- N_Identifier node in case if the front-end rewrites a sequence of
-- statement implementing the infinite loop by goto into
-- N_Loop_Statement node. The Enclosing_Element of such
-- A_Defining_Name element will be the statement labeled by it, see
-- Asis_Statements.Label_Names.
--
-- - A_Defining_Identifier representing a statement identifier, it is
-- obtained by means of Statement_Identifier query, and it is based
-- on N_Identifier node. The Enclosing_Element of the name is the
-- named statement, see Asis_Statements.Statement_Identifier. But
-- there is no difference in computing the Enclosing Element
-- (compared to A_Defining_Expanded_Name) in this case.
--
-- - A special processing is needed for a formal package defining name
--
-- - A_Defining_Identifier is from a single task/protected declaration
Parent_Node : Node_Id := Parent (R_Node (Element));
Parent_Node_Kind : constant Node_Kind := Nkind (Parent_Node);
Result_Kind : Internal_Element_Kinds := Not_An_Element;
begin
if Nkind (Node (Element)) = N_Label then
Parent_Node := Next (R_Node (Element));
-- R_Node (Element) definitely is a list member
while not Is_Statement (Parent_Node) loop
Parent_Node := Next (Parent_Node);
end loop;
elsif Nkind (Node (Element)) = N_Identifier
and then
Parent_Node_Kind = N_Loop_Statement
and then
Is_Rewrite_Substitution (Parent_Node)
and then
Nkind (Original_Node (Parent_Node)) = N_Goto_Statement
then
if Is_Empty_List (Sinfo.Statements (Parent_Node)) then
-- Pathological case of
--
-- <<Target>> goto target;
Result_Kind := A_Goto_Statement;
else
Parent_Node := First (Sinfo.Statements (Parent_Node));
end if;
elsif Parent_Node_Kind = N_Exception_Handler then
Parent_Node := R_Node (Element);
Result_Kind := A_Choice_Parameter_Specification;
elsif Nkind (Parent_Node) = N_Generic_Package_Declaration
and then
Nkind (Original_Node (Parent_Node)) = N_Formal_Package_Declaration
and then
R_Node (Element) =
Defining_Identifier (Original_Node (Parent_Node))
then
-- A formal package with a box (but not its expanded spec!)
Result_Kind := A_Formal_Package_Declaration_With_Box;
elsif not Comes_From_Source (Parent_Node)
and then
Nkind (Parent_Node) = N_Object_Declaration
and then
Present (Etype (R_Node (Element)))
and then
Ekind (Etype (R_Node (Element))) in Concurrent_Kind
then
-- The case of a single task/protected definition - the problem here
-- is that Parent field of the argument node points into artificial
-- object declaration, see G214-005
Parent_Node := Etype (R_Node (Element));
if Ekind (Parent_Node) = E_Protected_Type then
Result_Kind := A_Single_Protected_Declaration;
else
Result_Kind := A_Single_Task_Declaration;
end if;
Parent_Node := Parent (Parent_Node);
else
return A_Defining_Expanded_Name_Enclosing (Element);
end if;
return Node_To_Element_New (Node => Parent_Node,
Internal_Kind => Result_Kind,
Starting_Element => Element);
end A_Defining_Identifier_Enclosing;
------------------------------------------
-- A_Defining_Operator_Symbol_Enclosing --
------------------------------------------
function A_Defining_Operator_Symbol_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : Node_Id := Parent (R_Node (Element));
Parent_Node_Kind : constant Node_Kind := Nkind (Parent_Node);
begin
if Parent_Node_Kind = N_Function_Specification
then -- one more step up required
Parent_Node := Parent (Parent_Node);
end if;
return Node_To_Element_New (Node => Parent_Node,
Starting_Element => Element);
end A_Defining_Operator_Symbol_Enclosing;
--------------------------------
-- A_Discrete_Range_Enclosing --
--------------------------------
function A_Discrete_Range_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : Node_Id := Parent (R_Node (Element));
Result_Node_Kind : constant Node_Kind := Nkind (Result_Node);
Result_Elem_Kind : Internal_Element_Kinds := Not_An_Element;
begin
if not Comes_From_Source (Result_Node) or else
not Comes_From_Source (Parent (Result_Node))
then
return An_Expression_Enclosing (Element);
end if;
if Nkind (Node (Element)) = N_Component_Clause then
Result_Node := R_Node (Element);
Result_Elem_Kind := A_Component_Clause;
elsif Result_Node_Kind = N_Component_Association then
Result_Elem_Kind := An_Array_Component_Association;
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Internal_Kind => Result_Elem_Kind,
Considering_Parent_Count => False);
end A_Discrete_Range_Enclosing;
-----------------------------------
-- A_Discriminant_Part_Enclosing --
-----------------------------------
function A_Discriminant_Part_Enclosing
(Element : Asis.Element)
return Asis.Element
is
begin
return Node_To_Element_New (Node => R_Node (Element),
Starting_Element => Element);
end A_Discriminant_Part_Enclosing;
--------------------------------------------
-- A_Discriminant_Specification_Enclosing --
--------------------------------------------
function A_Discriminant_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element
is
begin
return Node_To_Element_New (
Node => Parent (R_Node (Element)),
Internal_Kind => A_Known_Discriminant_Part,
Starting_Element => Element);
end A_Discriminant_Specification_Enclosing;
----------------------------------------------
-- A_Loop_Parameter_Specification_Enclosing --
----------------------------------------------
function A_Loop_Parameter_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : Node_Id;
Tmp : Node_Id;
Result : Asis.Element;
begin
Result_Node := Parent (R_Node (Element));
if Nkind (Original_Node (Result_Node)) /= N_Quantified_Expression then
-- We have got to N_Ineration_Sceme node only
Result_Node := Parent (Result_Node);
end if;
if Declaration_Kind (Element) in
A_Generalized_Iterator_Specification ..
An_Element_Iterator_Specification
then
-- Here we may have to get to an artificial block statement the
-- needed loop node is rewritten into
Tmp := Parent (Parent (Result_Node));
if Nkind (Tmp) = N_Block_Statement
and then
Is_Rewrite_Substitution (Tmp)
and then
Nkind (Original_Node (Tmp)) = N_Loop_Statement
then
Result_Node := Tmp;
end if;
end if;
Result := Node_To_Element_New (Node => Result_Node,
Starting_Element => Element);
if Int_Kind (Result) = A_Parenthesized_Expression then
-- This is the case when an iteration scheme is used in a
-- conditional or quantified expression. We go in bottom-up
-- direction, so we can have A_Parenthesized_Expression only as the
-- next enclosing Element
Result := An_Expression_Enclosing (Element);
end if;
return Result;
end A_Loop_Parameter_Specification_Enclosing;
--------------------------------
-- A_Null_Component_Enclosing --
--------------------------------
function A_Null_Component_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : constant Node_Id := Node (Element);
Parent_Internal_Kind : Internal_Element_Kinds;
begin
if Nkind (Parent_Node) = N_Record_Definition then
Parent_Internal_Kind := A_Record_Definition;
else
Parent_Internal_Kind := A_Variant;
end if;
return Node_To_Element_New (Node => Parent_Node,
Internal_Kind => Parent_Internal_Kind,
Starting_Element => Element);
end A_Null_Component_Enclosing;
-----------------------------------------
-- A_Parameter_Specification_Enclosing --
-----------------------------------------
function A_Parameter_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : Node_Id := Parent (R_Node (Element));
Result_Node_Kind : constant Node_Kind := Nkind (Result_Node);
begin
if not (Result_Node_Kind = N_Entry_Declaration or else
Result_Node_Kind = N_Access_Function_Definition or else
Result_Node_Kind = N_Access_Procedure_Definition or else
Result_Node_Kind = N_Accept_Statement)
-- --|A2005 start
or else
(Nkind (Parent (Result_Node)) = N_Identifier
and then
Is_Rewrite_Substitution (Parent (Result_Node))
and then
Nkind (Original_Node (Parent (Result_Node))) = N_Access_Definition)
or else
Nkind (Parent (Result_Node)) = N_Access_Definition
-- --|A2005 end
then
Result_Node := Parent (Result_Node);
-- the first Parent gives N_Function/Procedure_Specification only
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Considering_Parent_Count => False);
end A_Parameter_Specification_Enclosing;
------------------------
-- A_Pragma_Enclosing --
------------------------
function A_Pragma_Enclosing (Element : Asis.Element) return Asis.Element is
Parent_Node : Node_Id := Atree.Parent (R_Node (Element));
Parent_Node_Kind : Node_Kind := Nkind (Parent_Node);
Parent_Internal_Kind : Internal_Element_Kinds;
begin
if Parent_Node_Kind = N_Loop_Statement
and then
Is_Rewrite_Substitution (Parent_Node)
and then
Nkind (Original_Node (Parent_Node)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- is rewritten into N_Loop_Statement
Parent_Node := Parent (Parent_Node);
Parent_Node_Kind := Nkind (Parent_Node);
end if;
-- filtering out compilation pragmas and correcting Parent_Node,
-- if necessary
case Parent_Node_Kind is
when N_Handled_Sequence_Of_Statements
| N_Package_Specification
| N_Component_List =>
Parent_Node := Atree.Parent (Parent_Node);
Parent_Node_Kind := Nkind (Parent_Node);
when N_Compilation_Unit | N_Compilation_Unit_Aux =>
return Asis.Nil_Element;
when N_Protected_Definition =>
Parent_Node := Parent (Parent_Node);
Parent_Node := Protected_Definition (Original_Node (Parent_Node));
Parent_Node_Kind := Nkind (Parent_Node);
when N_Task_Definition =>
Parent_Node := Parent (Parent_Node);
Parent_Node := Task_Definition (Original_Node (Parent_Node));
Parent_Node_Kind := Nkind (Parent_Node);
when others =>
null;
end case;
-- special processing for Nodes requiring by-hand Enclosing Element
-- kind determination and returning the result for all other Nodes
case Parent_Node_Kind is
when N_If_Statement =>
if List_Containing (R_Node (Element)) =
Then_Statements (Parent_Node)
then
Parent_Internal_Kind := An_If_Path;
else
Parent_Internal_Kind := An_Else_Path;
end if;
-- ??? List_Containing (Node (Element)) ??
-- ??? or List_Containing (R_Node (Element)) ??
when N_Conditional_Entry_Call
| N_Selective_Accept =>
Parent_Internal_Kind := An_Else_Path;
when N_Record_Definition =>
Parent_Internal_Kind := A_Record_Definition;
when others => -- auto determination of the Enclosing Element kind:
return Node_To_Element_New (Node => Parent_Node,
Starting_Element => Element);
end case;
-- returning the Enclosing Element with the by-hand-defined kind:
return Node_To_Element_New (Node => Parent_Node,
Internal_Kind => Parent_Internal_Kind,
Starting_Element => Element);
end A_Pragma_Enclosing;
-------------------------------------------
-- A_Range_Attribute_Reference_Enclosing --
-------------------------------------------
function A_Range_Attribute_Reference_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : Node_Id := Parent (R_Node (Element));
Tmp : Node_Id := Parent (Result_Node);
begin
if Nkind (Result_Node) = N_Subtype_Indication and then
Nkind (Tmp) = N_Subtype_Declaration and then
not Comes_From_Source (Tmp)
then
-- This N_Subtype_Declaration is from the tree structure created
-- for an artificial subtype declaration, see C208-003
Tmp := Next (Tmp);
Result_Node := Object_Definition (Tmp);
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Considering_Parent_Count => False);
end A_Range_Attribute_Reference_Enclosing;
----------------------------------------------
-- A_Record_Component_Association_Enclosing --
----------------------------------------------
function A_Record_Component_Association_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Res_Node : Node_Id := Parent (R_Node (Element));
Tmp : Node_Id := Parent (Res_Node);
begin
if Nkind (Tmp) = N_Pragma_Argument_Association then
Tmp := Parent (Tmp);
if From_Aspect_Specification (Tmp) then
Tmp := Corresponding_Aspect (Tmp);
Res_Node := Sinfo.Expression (Tmp);
pragma Assert (Nkind (Res_Node) = N_Aggregate);
end if;
end if;
return Node_To_Element_New (Node => Res_Node,
Starting_Element => Element);
end A_Record_Component_Association_Enclosing;
-----------------------------------
-- A_Record_Definition_Enclosing --
-----------------------------------
function A_Record_Definition_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : Node_Id;
Parent_Internal_Kind : Internal_Element_Kinds;
begin
if Nkind (Parent (R_Node (Element))) = N_Derived_Type_Definition then
Parent_Node := Parent (R_Node (Element));
Parent_Internal_Kind := A_Derived_Record_Extension_Definition;
else
Parent_Node := Node (Element);
if Tagged_Present (Parent_Node) then
Parent_Internal_Kind := A_Tagged_Record_Type_Definition;
else
Parent_Internal_Kind := A_Record_Type_Definition;
end if;
end if;
return Node_To_Element_New (Node => Parent_Node,
Internal_Kind => Parent_Internal_Kind,
Starting_Element => Element);
end A_Record_Definition_Enclosing;
-----------------------------------------
-- A_Simple_Expression_Range_Enclosing --
----------------------------------------
function A_Simple_Expression_Range_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Enclosing_Node : Node_Id := Node (Element);
Enclosing_Node_Kind : Node_Kind := Nkind (Enclosing_Node);
Context : Node_Id;
Context_Kind : Node_Kind;
Enclosing_Element_Kind : Internal_Element_Kinds;
begin
if Enclosing_Node_Kind = N_Signed_Integer_Type_Definition then
-- back from Integer_Constraint
return Node_To_Element_New
(Starting_Element => Element,
Node => R_Node (Element),
Internal_Kind => A_Signed_Integer_Type_Definition,
Considering_Parent_Count => False);
else -- one step up
Enclosing_Node := Parent (R_Node (Element));
Enclosing_Node_Kind := Nkind (Enclosing_Node);
-- possible values of corresponding kinds of
-- Enclosing_Node_Kind: Enclosing Element:
--
-- N_Floating_Point_Definition A_Floating_Point_Definition (*)
-- N_Ordinary_Fixed_Point_Definition An_Ordinary_Fixed_Point_Definition (*)
-- N_Decimal_Fixed_Point_Definition A_Decimal_Fixed_Point_Definition (*)
--
-- A_Constraint
-- N_Digits_Constraint A_Digits_Constraint (*)
-- N_Delta_Constraint A_Delta_Constraint (*)
--
--
-- A_Subtype_Indication
-- N_Subtype_Indication A_Discrete_Subtype_Indication
-- (_As_Subtype_Definition)
-- A_Subtype_Indication
--
-- A_Discrete_Range
-- N_Subtype_Indication A_Discrete_Subtype_Indication
--
--
--
-- N_In An_In_Membership_Test (*)
-- N_Not_In A_Not_In_Membership_Test (*)
--
-- (*) means that the Enclosing Element can be obtained by Node_To_Elemen
-- constructor with auto determination of the Element kind
if Enclosing_Node_Kind /= N_Subtype_Indication then
return Node_To_Element_New
(Starting_Element => Element,
Node => Enclosing_Node,
Considering_Parent_Count => False);
else
-- A_Discrete_Subtype_Indication or
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- or A_Subtype_Indication?
-- First, we have to skip implicit subtype created for
-- constraint directly included in object declaration,
-- if any
Skip_Implicit_Subtype (Enclosing_Node);
Context := Parent (Enclosing_Node);
Context_Kind := Nkind (Context);
if Context_Kind = N_Subtype_Indication then
-- it's impossible to make a decision on the base
-- of this node, we shall go one more step up
Context := Parent (Context);
Context_Kind := Nkind (Context);
end if;
if Context_Kind = N_Subtype_Declaration or else
((Context_Kind = N_Constrained_Array_Definition or else
Context_Kind = N_Unconstrained_Array_Definition)
and then
Enclosing_Node = Sinfo.Component_Definition (Context))
or else
-- is it enough or should we add:
-- and then Enclosing_Node = Subtype_Indication (Context)?
Context_Kind = N_Derived_Type_Definition or else
Context_Kind = N_Access_To_Object_Definition
then
Enclosing_Element_Kind := A_Subtype_Indication;
elsif Context_Kind = N_Constrained_Array_Definition or else
Context_Kind = N_Entry_Declaration or else
Context_Kind = N_Entry_Index_Specification or else
Context_Kind = N_Loop_Parameter_Specification
then
Enclosing_Element_Kind :=
A_Discrete_Subtype_Indication_As_Subtype_Definition;
elsif Context_Kind = N_Component_Declaration or else
Context_Kind = N_Object_Declaration or else
Context_Kind = N_Component_Definition
then
Enclosing_Element_Kind := A_Subtype_Indication;
else
Enclosing_Element_Kind :=
A_Discrete_Subtype_Indication;
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Enclosing_Node,
Internal_Kind => Enclosing_Element_Kind,
Considering_Parent_Count => False);
end if;
end if;
end A_Simple_Expression_Range_Enclosing;
---------------------------
-- A_Statement_Enclosing --
---------------------------
function A_Statement_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : Node_Id := Parent (R_Node (Element));
Parent_Node_Kind : Node_Kind := Nkind (Parent_Node);
Parent_Internal_Kind : Internal_Element_Kinds;
begin
if Parent_Node_Kind = N_Loop_Statement
and then
Is_Rewrite_Substitution (Parent_Node)
and then
Nkind (Original_Node (Parent_Node)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- is rewritten into N_Loop_Statement
Parent_Node := Parent (Parent_Node);
Parent_Node_Kind := Nkind (Parent_Node);
end if;
if Parent_Node_Kind = N_If_Statement then
if List_Containing (R_Node (Element)) =
Then_Statements (Parent_Node)
then
Parent_Internal_Kind := An_If_Path;
else
Parent_Internal_Kind := An_Else_Path;
end if;
-- ??? List_Containing (Node (Element)) ??
-- ?? or List_Containing (R_Node (Element)) ??
elsif Parent_Node_Kind = N_Conditional_Entry_Call or else
Parent_Node_Kind = N_Selective_Accept
then
Parent_Internal_Kind := An_Else_Path;
else
if Parent_Node_Kind = N_Handled_Sequence_Of_Statements then
-- to go to N_Block_Statement, N_Accept_Statement,
-- N_Subprogram_Body, N_Package_Body, N_Task_Body or
-- N_Entry_Body node
Parent_Node := Parent (Parent_Node);
end if;
return Node_To_Element_New (Node => Parent_Node,
Starting_Element => Element);
end if;
return Node_To_Element_New (Node => Parent_Node,
Internal_Kind => Parent_Internal_Kind,
Starting_Element => Element);
end A_Statement_Enclosing;
------------------------------------
-- A_Subtype_Indication_Enclosing --
------------------------------------
function A_Subtype_Indication_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : Node_Id := Parent (R_Node (Element));
Result_Node : Node_Id := R_Node (Element);
Parent_Node_Kind : constant Node_Kind := Nkind (Parent_Node);
Result_Kind : Internal_Element_Kinds;
begin
if Parent_Node_Kind = N_Component_Definition then
Parent_Node := Parent (Parent_Node);
-- This skips the normalized component declarations back!
Parent_Node := Sinfo.Component_Definition (Parent_Node);
end if;
if Parent_Node_Kind = N_Allocator and then
Nkind (Parent (Parent_Node)) = N_Component_Association and then
not Comes_From_Source (Parent (Parent_Node))
then
return An_Expression_Enclosing (Element);
end if;
if Parent_Node_Kind = N_Unconstrained_Array_Definition or else
Parent_Node_Kind = N_Constrained_Array_Definition or else
Parent_Node_Kind = N_Component_Declaration
then
Result_Kind := A_Component_Definition;
elsif Parent_Node_Kind = N_Private_Extension_Declaration then
Result_Kind := A_Private_Extension_Definition;
Result_Node := Parent_Node;
-- elsif Parent_Node_Kind = N_Subtype_Declaration
-- and then
-- not Comes_From_Source (Parent_Node)
-- and then
-- Ekind (Defining_Identifier (Parent_Node)) = E_Protected_Subtype
-- then
else
return Node_To_Element_New
(Starting_Element => Element,
Node => Parent_Node,
Considering_Parent_Count => False);
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Internal_Kind => Result_Kind,
Considering_Parent_Count => False);
end A_Subtype_Indication_Enclosing;
-------------------------------------------------
-- A_Terminate_Alternative_Statement_Enclosing --
-------------------------------------------------
function A_Terminate_Alternative_Statement_Enclosing
(Element : Asis.Element)
return Asis.Element
is
begin
return Node_To_Element_New (Node => R_Node (Element),
Starting_Element => Element);
end A_Terminate_Alternative_Statement_Enclosing;
------------------------------
-- A_Variant_Part_Enclosing --
------------------------------
function A_Variant_Part_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : constant Node_Id := Parent (Parent (R_Node (Element)));
Result_Kind : Internal_Element_Kinds;
begin
if Nkind (Result_Node) = N_Record_Definition then
Result_Kind := A_Record_Definition;
else
Result_Kind := A_Variant;
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Internal_Kind => Result_Kind,
Considering_Parent_Count => False);
end A_Variant_Part_Enclosing;
------------------------------
-- An_Association_Enclosing --
------------------------------
function An_Association_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result : Asis.Element;
begin
if Normalization_Case (Element) = Is_Not_Normalized then
Result := An_Expression_Enclosing (Element);
else
Result := Node_To_Element_New
(Node => R_Node (Element),
Starting_Element => Element);
Set_From_Implicit (Result, False);
end if;
return Result;
end An_Association_Enclosing;
----------------------------------------------
-- An_Attribute_Definition_Clause_Enclosing --
----------------------------------------------
function An_Attribute_Definition_Clause_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : Node_Id := Parent (R_Node (Element));
Result_Node_Kind : Node_Kind := Nkind (Result_Node);
Result_Kind : Internal_Element_Kinds := Not_An_Element;
begin
if Result_Node_Kind = N_Component_List or else
Result_Node_Kind = N_Package_Specification
then
Result_Node := Parent (Result_Node);
Result_Node_Kind := Nkind (Result_Node);
end if;
if Result_Node_Kind = N_Record_Definition then
Result_Kind := A_Record_Definition;
elsif Result_Node_Kind = N_Variant then
Result_Kind := A_Variant;
end if;
if Result_Node_Kind = N_Task_Definition then
Result_Node := Parent (Result_Node);
Result_Node := Task_Definition (Original_Node (Result_Node));
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Internal_Kind => Result_Kind,
Considering_Parent_Count => False);
end An_Attribute_Definition_Clause_Enclosing;
----------------------------
-- An_Else_Path_Enclosing --
----------------------------
function An_Else_Path_Enclosing
(Element : Asis.Element)
return Asis.Element
is
begin
return Node_To_Element_New (Node => R_Node (Element),
Starting_Element => Element);
end An_Else_Path_Enclosing;
----------------------------------------------------
-- An_Enumeration_Literal_Specification_Enclosing --
----------------------------------------------------
function An_Enumeration_Literal_Specification_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : Node_Id;
Start_Elem : Asis.Element := Element;
begin
if Special_Case (Element) = Stand_Char_Literal then
Result_Node := R_Node (Element);
Set_Character_Code (Start_Elem, 0);
Set_Special_Case (Start_Elem, Explicit_From_Standard);
else
Result_Node := Parent (R_Node (Element));
end if;
return Node_To_Element_New
(Starting_Element => Start_Elem,
Node => Result_Node,
Internal_Kind => An_Enumeration_Type_Definition);
end An_Enumeration_Literal_Specification_Enclosing;
----------------------------------------------
-- An_Enumeration_Type_Definition_Enclosing --
----------------------------------------------
function An_Enumeration_Type_Definition_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Result_Node : Node_Id;
begin
if Special_Case (Element) = Stand_Char_Literal then
Result_Node := R_Node (Element);
if Nkind (Result_Node) = N_Defining_Identifier then
-- we are in the definition of Standard.Boolean:
Result_Node := Parent (Etype (Result_Node));
end if;
else
Result_Node := Parent (R_Node (Element));
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Internal_Kind => An_Ordinary_Type_Declaration);
end An_Enumeration_Type_Definition_Enclosing;
------------------------------------
-- An_Exception_Handler_Enclosing --
------------------------------------
function An_Exception_Handler_Enclosing
(Element : Asis.Element)
return Asis.Element
is
begin
return Node_To_Element_New
(Node => Parent (Parent (R_Node (Element))),
Starting_Element => Element);
end An_Exception_Handler_Enclosing;
-----------------------------
-- An_Expression_Enclosing --
-----------------------------
function An_Expression_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Start_Elem : Asis.Element := Element;
Rough_Result_Node : Node_Id;
Res_Entity : Entity_Id;
Rough_Result_Element : Asis.Element;
Rough_Res_Spec_Case : Special_Cases;
Result_Element : Asis.Element;
Success : Boolean;
begin
if A4G.A_Opt.Cache_EE_Results then
Result_Element := Get_Enclosing_Element (Element, Success);
if Success then
return Result_Element;
end if;
end if;
Rough_Result_Node := Get_Rough_Enclosing_Node (Element);
if not (Sloc (Node (Start_Elem)) <= Standard_Location or else
Special_Case (Start_Elem) = Configuration_File_Pragma)
then
Set_Special_Case (Start_Elem, Not_A_Special_Case);
end if;
Rough_Result_Element := Node_To_Element_New
(Node => Rough_Result_Node,
Starting_Element => Start_Elem);
if Is_Top_Of_Expanded_Generic (Rough_Result_Node)
and then
Is_From_Instance (Element)
and then
(Nkind (Original_Node (Rough_Result_Node)) /=
N_Formal_Package_Declaration
or else
Instantiation_Depth (Sloc (R_Node (Element))) >
Instantiation_Depth (Sloc (Rough_Result_Node)))
then
-- ??? The content of this if statement is just a slightly edited
-- ??? fragment of Enclosing_For_Explicit_Instance_Component
if Nkind (Rough_Result_Node) = N_Package_Declaration or else
Nkind (Rough_Result_Node) = N_Package_Body
then
Rough_Res_Spec_Case := Expanded_Package_Instantiation;
-- and here we have to correct the result:
Set_Node (Rough_Result_Element, R_Node (Rough_Result_Element));
if Nkind (Rough_Result_Node) = N_Package_Declaration then
Set_Int_Kind (Rough_Result_Element, A_Package_Declaration);
else
Set_Int_Kind (Rough_Result_Element, A_Package_Body_Declaration);
end if;
else
Rough_Res_Spec_Case := Expanded_Subprogram_Instantiation;
end if;
Set_Special_Case (Rough_Result_Element, Rough_Res_Spec_Case);
end if;
if Special_Case (Element) = Is_From_Gen_Association
and then
Is_Top_Of_Expanded_Generic (Node (Rough_Result_Element))
and then
Instantiation_Depth (Sloc (Node (Rough_Result_Element))) =
Instantiation_Depth (Sloc (Node (Element)))
then
Rough_Result_Element := Enclosing_Element (Rough_Result_Element);
end if;
if Nkind (Rough_Result_Node) = N_Subprogram_Declaration
and then
not Comes_From_Source (Rough_Result_Node)
then
Res_Entity := Defining_Unit_Name (Specification (Rough_Result_Node));
if (Ekind (Res_Entity) = E_Function
and then not Comes_From_Source (Res_Entity)
and then Chars (Res_Entity) = Snames.Name_Op_Ne)
and then Present (Corresponding_Equality (Res_Entity))
then
Set_Special_Case
(Rough_Result_Element, Is_From_Imp_Neq_Declaration);
end if;
end if;
Result_Element := Get_Enclosing
(Approximation => Rough_Result_Element,
Element => Element);
return Result_Element;
end An_Expression_Enclosing;
--------------------------------
-- An_Others_Choice_Enclosing --
--------------------------------
function An_Others_Choice_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : constant Node_Id := Parent (Parent (R_Node (Element)));
Result_Node : Node_Id := Parent (R_Node (Element));
Result_Kind : Internal_Element_Kinds := Not_An_Element;
begin
if Nkind (Result_Node) = N_Component_Association then
-- we have to find out, is it record or array component
-- association. Parent_Node points to the enclosing aggregate
if No (Etype (Parent_Node)) or else
Is_Array_Type (Etype (Parent_Node))
then
-- the first condition in 'or else' is true for multi-dimensional
-- array aggregates
Result_Kind := An_Array_Component_Association;
else
Result_Kind := A_Record_Component_Association;
end if;
elsif Nkind (Result_Node) = N_Package_Declaration
and then
Nkind (Original_Node (Result_Node)) = N_Formal_Package_Declaration
then
Result_Node :=
Last_Non_Pragma
(Generic_Associations (Original_Node (Result_Node)));
Result_Kind := A_Generic_Association;
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Internal_Kind => Result_Kind,
Considering_Parent_Count => False);
end An_Others_Choice_Enclosing;
----------------------------------------------------
-- Not_Implemented_Enclosing_Element_Construction --
----------------------------------------------------
function Not_Implemented_Enclosing_Element_Construction
(Element : Asis.Element) return Asis.Element is
begin
Not_Implemented_Yet (Diagnosis =>
"Enclosing Element retrieval for the explicit Element "
& "of the " & Internal_Element_Kinds'Image
(Int_Kind (Element)) & " kind "
& "has not been implemented yet");
return Asis.Nil_Element; -- to make the code syntactically correct;
end Not_Implemented_Enclosing_Element_Construction;
----------------------------
-- Possible_C_U_Enclosing --
----------------------------
function Possible_C_U_Enclosing
(Element : Asis.Element)
return Asis.Element
is
Parent_Node : Node_Id := Parent (R_Node (Element));
Parent_Node_Kind : constant Node_Kind := Nkind (Parent_Node);
begin
if Parent_Node_Kind = N_Compilation_Unit or else
Parent_Node_Kind = N_Subunit
then
return Asis.Nil_Element;
elsif Parent_Node_Kind = N_Package_Specification then
Parent_Node := Parent (Parent_Node);
elsif Parent_Node_Kind = N_Protected_Definition then
Parent_Node := Parent (Parent_Node);
Parent_Node := Protected_Definition (Original_Node (Parent_Node));
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Parent_Node);
end Possible_C_U_Enclosing;
-----------------------------------------------------------------
-- Section 6 - bodies for the routines defined in the package --
-- spec and local subprograms --
-----------------------------------------------------------------
---------------------------------
-- Corresponding_Instantiation --
---------------------------------
function Corresponding_Instantiation
(Element : Asis.Element)
return Asis.Element
is
Argument_Node : Node_Id := R_Node (Element);
Argument_Kind : constant Internal_Element_Kinds := Int_Kind (Element);
Result_Node : Node_Id := Argument_Node;
Result_Kind : Internal_Element_Kinds;
Result_Unit : constant Asis.Compilation_Unit := Encl_Unit (Element);
begin
if Argument_Kind = A_Package_Declaration or else
Argument_Kind = A_Package_Body_Declaration
then
-- A formal package with box needs a special processing - it is
-- based on the same node as the argument
if Nkind (Original_Node (Argument_Node)) =
N_Formal_Package_Declaration
and then
Box_Present (Original_Node (Argument_Node))
then
Result_Kind := A_Formal_Package_Declaration_With_Box;
else
Argument_Node := Parent (Argument_Node);
if Nkind (Argument_Node) in N_Generic_Declaration and then
Is_List_Member (Result_Node) and then
List_Containing (Result_Node) =
Generic_Formal_Declarations (Argument_Node)
then
Result_Kind := A_Formal_Package_Declaration;
else
Result_Kind := A_Package_Instantiation;
end if;
end if;
else
if Argument_Kind = A_Procedure_Declaration or else
Argument_Kind = A_Procedure_Body_Declaration
then
Result_Kind := A_Procedure_Instantiation;
else
Result_Kind := A_Function_Instantiation;
end if;
-- we have to go the N_Package_Decalaration node of an
-- artificial package created by the compiler for a subprogram
-- instantiation - two steps up the tree are needed:
Result_Node := Parent (Result_Node);
if Argument_Kind = A_Procedure_Declaration or else
Argument_Kind = A_Function_Declaration
then
Result_Node := Parent (Result_Node);
end if;
end if;
if Nkind (Parent (Result_Node)) = N_Compilation_Unit then
-- For library-level subprogram instantiations we may have a
-- problem in the tree created for the instantiation itself.
if Nkind (Result_Node) = N_Package_Declaration and then
not Is_Rewrite_Substitution (Result_Node)
then
Result_Node := Parent (Corresponding_Body (Result_Node));
if Nkind (Result_Node) = N_Defining_Program_Unit_Name then
Result_Node := Parent (Result_Node);
end if;
end if;
elsif Nkind (Original_Node (Result_Node)) /=
N_Formal_Package_Declaration
then
-- "local" instantiation, therefore - one or two steps down the
-- declaration list to get in the instantiation node, a formal
-- package with a box is an exception:
Result_Node := Next_Non_Pragma (Result_Node);
if Nkind (Result_Node) = N_Package_Body then
-- This is an expanded generic body
Result_Node := Next_Non_Pragma (Result_Node);
end if;
end if;
if Is_Rewrite_Substitution (Result_Node) and then
Is_Rewrite_Substitution (Original_Node (Result_Node))
then
Result_Node := Original_Node (Result_Node);
end if;
return Node_To_Element_New
(Node => Result_Node,
Internal_Kind => Result_Kind,
In_Unit => Result_Unit);
end Corresponding_Instantiation;
------------------------------------
-- Enclosing_Element_For_Explicit --
------------------------------------
function Enclosing_Element_For_Explicit
(Element : Asis.Element)
return Asis.Element
is
Enclosing_Construction_Case : Internal_Element_Kinds;
Element_Internal_Kind : Internal_Element_Kinds;
Result_Element : Asis.Element;
Res_Node : Node_Id := Standard_Package_Node;
Res_Kind : Internal_Element_Kinds := Not_An_Element;
Res_Spec_Case : Special_Cases;
begin
Element_Internal_Kind := Int_Kind (Element);
-- A special case of fake Numeric_Error renaming is handled
-- separately (see B712-0050)
case Special_Case (Element) is
when Numeric_Error_Renaming =>
Res_Node := Standard_Package_Node;
case Element_Internal_Kind is
when An_Exception_Renaming_Declaration =>
Res_Kind := A_Package_Declaration;
Res_Spec_Case := Explicit_From_Standard;
when A_Defining_Identifier |
An_Identifier =>
Res_Kind := An_Exception_Renaming_Declaration;
Res_Spec_Case := Numeric_Error_Renaming;
when others =>
null;
end case;
Result_Element := Node_To_Element_New
(Starting_Element => Element,
Node => Res_Node,
Internal_Kind => Res_Kind,
Spec_Case => Res_Spec_Case);
return Result_Element;
when End_Label =>
Res_Node := Parent (Node (Element));
if Nkind (Res_Node) in N_Package_Specification |
N_Task_Definition |
N_Protected_Definition |
N_Handled_Sequence_Of_Statements
then
Res_Node := Parent (Res_Node);
end if;
Result_Element := Node_To_Element_New
(Starting_Element => Element,
Node => Res_Node);
if Element_Kind (Result_Element) /= An_Expression then
Set_Special_Case (Result_Element, Not_A_Special_Case);
end if;
return Result_Element;
when others => null;
end case;
-- A special case of a configuration pragma is handled separately
-- (BA07-013)
if Element_Internal_Kind in Internal_Pragma_Kinds and then
Special_Case (Element) = Configuration_File_Pragma
then
return Asis.Nil_Element;
end if;
Enclosing_Construction_Case :=
Enclosing_Element_For_Explicits_First_Switch (Element_Internal_Kind);
case Enclosing_Construction_Case is
when Not_An_Element =>
return Asis.Nil_Element;
when Trivial_Mapping =>
Result_Element := General_Encl_Elem (Element);
when Non_Trivial_Mapping =>
Result_Element :=
Enclosing_Element_For_Explicits_Second_Switch
(Element_Internal_Kind) (Element);
when No_Mapping =>
No_Enclosing_Element (Element_Kind => Element_Internal_Kind);
return Asis.Nil_Element; -- to avoid GNAT warning
when Not_Implemented_Mapping =>
Not_Implemented_Enclosing_Element_Construction
(Element => Element);
when others =>
-- others means here that the Enclosing Element should
-- based on the same node.
Result_Element := Node_To_Element_New
(Starting_Element => Element,
Node => R_Node (Element),
Internal_Kind => Enclosing_Construction_Case,
Considering_Parent_Count => False);
if Element_Internal_Kind = A_Defining_Character_Literal then
Set_Character_Code (Result_Element, Character_Code (Element));
end if;
end case;
if Is_From_Implicit (Element)
and then
Statement_Kind (Element) = A_Null_Statement
then
-- Case of an implicit NULL statement needed for 'floating' labels,
-- Ada 2012
Set_From_Implicit (Result_Element, False);
end if;
return Result_Element;
end Enclosing_Element_For_Explicit;
-----------------------------------------------
-- Enclosing_For_Explicit_Instance_Component --
-----------------------------------------------
function Enclosing_For_Explicit_Instance_Component
(Element : Asis.Element)
return Asis.Element
is
Result_Element : Asis.Element;
Result_Node : Node_Id;
Tmp_Node : Node_Id;
Res_Spec_Case : Special_Cases;
function Is_Top_Exp_Form_Pack_With_Box
(Potential_Enclosing_Element : Asis.Element;
Arg_Element : Asis.Element)
return Boolean;
-- Checks if Potential_Enclosing_Element is the top expanded spec
-- (??? what about body???) for a formal package declaration with box.
-- The problem here is that when going up the tree, we can get into this
-- argument both from components of the formal package declaration with
-- box and from the corresponding expanded spec. So we have to check
-- if Potential_Enclosing_Element and Arg_Element are the same level
-- of instantiating (nested instances may be a pain! The function needs
-- more testing ???)
-- See the discussion in E425-007
function Is_Top_Exp_Form_Pack_With_Box
(Potential_Enclosing_Element : Asis.Element;
Arg_Element : Asis.Element)
return Boolean
is
EE_Inst_Level : Natural := 0;
Arg_Inst_Level : Natural := 0;
Src : Source_Ptr :=
Instantiation
(Get_Source_File_Index
(Sloc (R_Node (Potential_Enclosing_Element))));
function May_Be_Exp_Pack_Def_Name
(N_Pack : Node_Id;
N_Name : Node_Id)
return Boolean;
-- In case of the defining name of an expanded package created for a
-- formal package with the box, we have the instantiation chain one
-- link shorter then the rest of the expanded package, so we have
-- to detect this situation.
function May_Be_Nested_FP_Instantiation
(N_Pack : Node_Id;
N_Name : Node_Id)
return Boolean;
-- See E430-A01. We try to detect the situation when we go out of
-- a chain of nested instantiations created by formal packages with
-- the box
function May_Be_Exp_Pack_Def_Name
(N_Pack : Node_Id;
N_Name : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N_Name) = N_Defining_Identifier
and then
Nkind (Original_Node (N_Pack)) = N_Formal_Package_Declaration
and then
Box_Present (Original_Node (N_Pack))
then
Result := N_Name = Defining_Unit_Name (Specification (N_Pack));
end if;
return Result;
end May_Be_Exp_Pack_Def_Name;
function May_Be_Nested_FP_Instantiation
(N_Pack : Node_Id;
N_Name : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N_Pack) = N_Generic_Package_Declaration
and then
Nkind (Original_Node (N_Pack)) = N_Formal_Package_Declaration
and then
Box_Present (Original_Node (N_Pack))
and then
Nkind (N_Name) = N_Generic_Package_Declaration
and then
Nkind (Original_Node (N_Name)) = N_Formal_Package_Declaration
and then
Box_Present (Original_Node (N_Name))
then
Result := True;
end if;
return Result;
end May_Be_Nested_FP_Instantiation;
begin
if not (Nkind (Node (Potential_Enclosing_Element)) =
N_Formal_Package_Declaration
and then
Nkind (R_Node (Potential_Enclosing_Element)) =
N_Generic_Package_Declaration)
or else
(Int_Kind (Potential_Enclosing_Element) =
A_Formal_Package_Declaration_With_Box
and then
Node (Arg_Element) =
Defining_Identifier (Node (Potential_Enclosing_Element)))
then
return False;
end if;
while Src /= No_Location loop
EE_Inst_Level := EE_Inst_Level + 1;
Src := Instantiation (Get_Source_File_Index (Src));
end loop;
Src :=
Instantiation (Get_Source_File_Index (Sloc (R_Node (Arg_Element))));
while Src /= No_Location loop
Arg_Inst_Level := Arg_Inst_Level + 1;
Src := Instantiation (Get_Source_File_Index (Src));
end loop;
return (May_Be_Exp_Pack_Def_Name
(R_Node (Potential_Enclosing_Element),
R_Node (Arg_Element))
and then
EE_Inst_Level = Arg_Inst_Level + 1)
or else
(May_Be_Nested_FP_Instantiation
(R_Node (Potential_Enclosing_Element),
R_Node (Arg_Element))
and then
EE_Inst_Level + 1 = Arg_Inst_Level)
or else
EE_Inst_Level = Arg_Inst_Level;
end Is_Top_Exp_Form_Pack_With_Box;
begin
Result_Element := Enclosing_Element_For_Explicit (Element);
if Is_Nil (Result_Element) then
-- There is a special case corresponding to the defining name in an
-- artificial subtype declaration that is a means to pass an actual
-- type in the expanded instantiation (see K811-006). Under some
-- conditions the corresponding node in the tree is an Itype node,
-- and it does not have a Parent reference set.
Tmp_Node := Node (Element);
if Nkind (Tmp_Node) = N_Defining_Identifier and then
Is_Itype (Tmp_Node)
then
Tmp_Node := Associated_Node_For_Itype (Tmp_Node);
Result_Element :=
Node_To_Element_New
(Node => Tmp_Node,
Starting_Element => Element,
Internal_Kind => A_Subtype_Declaration);
end if;
end if;
if Is_Top_Of_Expanded_Generic (R_Node (Result_Element))
and then
Nkind (R_Node (Result_Element)) = N_Package_Body
then
-- There is a special case of a library-level package (what about
-- library-level subprogram instantiations???) that are withed
-- by another unit and we are in the tree created for this another
-- unit. In some cases the instantiation node is rewritten twice:
-- first as a package node node and then the body node is rewritten
-- as a package declaration node. So, if we go up from the defining
-- name of an expanded *spec* with the general approach of computing
-- enclosing element we will unwind rewritting and get into expanded
-- body, not in the expanded spec
Tmp_Node := R_Node (Element);
while Nkind (Tmp_Node) not in
N_Package_Body | N_Package_Declaration
loop
Tmp_Node := Parent (Tmp_Node);
end loop;
if Nkind (Tmp_Node) = N_Package_Declaration then
Set_Int_Kind (Result_Element, A_Package_Declaration);
Set_Node (Result_Element, Tmp_Node);
Set_Special_Case (Result_Element, Expanded_Package_Instantiation);
return Result_Element;
end if;
end if;
-- In case if the result argument is an artificial declaration
-- used to pass an actual into expanded subprogram, we are
-- in the spec of the artificial wrapper package. So we have to get
-- to the expanded subprogram declaration (see G416-009)
if Is_Top_Of_Expanded_Generic (R_Node (Result_Element)) then
Tmp_Node := (R_Node (Result_Element));
if Nkind (Tmp_Node) = N_Package_Declaration
and then
No (Generic_Parent (Specification (Tmp_Node)))
then
-- This IF statement prevents us from doing this special
-- processing for expanded package declarations, we have to do
-- it only for wrapper packages created for subprogram
-- instantiation
Tmp_Node :=
Last (Visible_Declarations (Specification (Tmp_Node)));
Result_Element :=
Node_To_Element_New
(Node => Tmp_Node,
Spec_Case => Expanded_Subprogram_Instantiation,
Starting_Element => Element);
end if;
end if;
-- and now we have to check if we are in the whole expanded
-- declaration
Result_Node := R_Node (Result_Element);
if not (Is_Rewrite_Substitution (Result_Node)
and then
Nkind (Original_Node (Result_Node)) =
N_Formal_Package_Declaration
and then
(Node (Element) =
Defining_Identifier (Original_Node (Result_Node))
or else
(Node (Element) /=
Defining_Unit_Name (Specification (Result_Node))
and then
Instantiation_Depth (Sloc (R_Node (Element))) =
Instantiation_Depth (Sloc (Result_Node)))))
and then
Is_Top_Of_Expanded_Generic (Result_Node)
then
-- this is an artificial package or subprogram declaration
-- created by the compiler as an expanded generic declaration
if Nkind (Result_Node) = N_Package_Declaration or else
Nkind (Result_Node) = N_Package_Body
then
Res_Spec_Case := Expanded_Package_Instantiation;
-- and here we have to correct the result:
Set_Node (Result_Element, R_Node (Result_Element));
if Nkind (Result_Node) = N_Package_Declaration then
Set_Int_Kind (Result_Element, A_Package_Declaration);
else
Set_Int_Kind (Result_Element, A_Package_Body_Declaration);
end if;
else
Res_Spec_Case := Expanded_Subprogram_Instantiation;
end if;
Set_Special_Case (Result_Element, Res_Spec_Case);
elsif Is_Top_Exp_Form_Pack_With_Box (Result_Element, Element) then
-- This case is somewhat special - we have not a package, but a
-- generic package declaration as expanded code here
Set_Int_Kind (Result_Element, A_Package_Declaration);
Set_Special_Case (Result_Element, Expanded_Package_Instantiation);
-- ??? What about expanded bodies for formal packages with a box?
end if;
-- and we have to correct Is_Part_Of_Instance field of the result -
-- just in case. May be, it will not be necessary, if (and when)
-- Enclosing_Element_For_Explicit takes the corresponding fields
-- from its argument
if not Is_Nil (Result_Element) then
Set_From_Instance (Result_Element, True);
end if;
return Result_Element;
end Enclosing_For_Explicit_Instance_Component;
------------------------------------
-- Enclosing_Element_For_Implicit --
------------------------------------
function Enclosing_Element_For_Implicit
(Element : Asis.Element)
return Asis.Element
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Element);
Result_Node : Node_Id := Empty;
Result_Element : Asis.Element;
Result_Kind : Internal_Element_Kinds := Not_An_Element;
Res_Spec_Case : Special_Cases := Not_A_Special_Case;
Tmp : Node_Id;
begin
-- Special treatment for the declaration of implicit "/=", see F903-002:
if Asis.Extensions.Is_Implicit_Neq_Declaration (Element) then
Result_Element :=
Enclosing_Element
(Asis.Declarations.Corresponding_Equality_Operator (Element));
else
case Arg_Kind is
when A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration |
A_Discriminant_Specification |
A_Component_Declaration =>
Result_Node := Original_Node (Node_Field_1 (Element));
if Nkind (Result_Node) in N_Entity
and then
(Arg_Kind in A_Procedure_Declaration ..
A_Function_Declaration
or else
Arg_Kind in A_Procedure_Body_Declaration ..
A_Function_Body_Declaration
or else
Arg_Kind in A_Procedure_Renaming_Declaration ..
A_Function_Renaming_Declaration)
then
Result_Node :=
Original_Node (Parent (Node_Field_1 (Element)));
end if;
case Nkind (Result_Node) is
when N_Private_Extension_Declaration =>
Result_Kind := A_Private_Extension_Definition;
when N_Formal_Type_Declaration =>
Result_Node := Sinfo.Formal_Type_Definition (Result_Node);
when N_Full_Type_Declaration =>
Result_Node := Sinfo.Type_Definition (Result_Node);
when others =>
null;
end case;
Result_Element := Node_To_Element_New (
Node => Result_Node,
Starting_Element => Element,
Internal_Kind => Result_Kind);
Set_From_Implicit (Result_Element, False);
Set_From_Inherited (Result_Element, False);
Set_Node_Field_1 (Result_Element, Empty);
when Internal_Root_Type_Kinds =>
Result_Element := Element;
Set_Int_Kind (Result_Element, An_Ordinary_Type_Declaration);
when An_Ordinary_Type_Declaration =>
-- The only possible case is the declaration of a root or
-- universal numeric type
Result_Node := Standard_Package_Node;
Res_Spec_Case := Explicit_From_Standard;
Result_Kind := A_Package_Declaration;
Result_Element :=
Node_To_Element_New (Node => Result_Node,
Spec_Case => Res_Spec_Case,
In_Unit => Encl_Unit (Element));
when An_Enumeration_Literal_Specification |
An_Entry_Declaration =>
Result_Node :=
Sinfo.Type_Definition
(Original_Node (Node_Field_1 (Element)));
Result_Kind := A_Derived_Type_Definition;
Result_Element := Node_To_Element_New (
Node => Result_Node,
Starting_Element => Element,
Internal_Kind => Result_Kind);
Set_From_Implicit (Result_Element, False);
Set_From_Inherited (Result_Element, False);
Set_Node_Field_1 (Result_Element, Empty);
when A_Generic_Association =>
Result_Element :=
Node_To_Element_New (Node => R_Node (Element),
In_Unit => Encl_Unit (Element));
when others =>
if Normalization_Case (Element) =
Is_Normalized_Defaulted_For_Box
then
Result_Node := Parent (Parent (Parent (Node (Element))));
while not (Nkind (Result_Node) in N_Generic_Instantiation
or else
Nkind (Original_Node (Result_Node)) =
N_Formal_Package_Declaration)
loop
if Nkind (Parent (Result_Node)) = N_Compilation_Unit then
-- Library level instantiation
if Is_Rewrite_Substitution (Result_Node) then
-- Package instantiation, the package does not have
-- a body
exit;
else
Result_Node := Corresponding_Body (Result_Node);
while Nkind (Result_Node) /= N_Package_Body loop
Result_Node := Parent (Result_Node);
end loop;
end if;
exit;
else
Result_Node := Next (Result_Node);
end if;
end loop;
Result_Element := Node_To_Element_New
(Node => Result_Node,
In_Unit => Encl_Unit (Element));
else
Result_Element := Enclosing_Element_For_Explicit (Element);
end if;
end case;
end if;
if Int_Kind (Result_Element) = A_Function_Renaming_Declaration then
-- See C125-002
Set_Int_Kind (Result_Element, A_Function_Declaration);
elsif Int_Kind (Result_Element) = A_Procedure_Renaming_Declaration then
Set_Int_Kind (Result_Element, A_Procedure_Declaration);
end if;
-- Special case of an implicit null procedure used in expanded generic
-- as a default actual for a formal procedure with null default
if Is_Implicit_Null_Procedure (Node (Result_Element)) then
Set_Int_Kind (Result_Element, A_Null_Procedure_Declaration);
elsif Int_Kind (Result_Element) = A_Package_Declaration
and then
Is_Implicit_Null_Procedure (Node (Element))
then
Set_From_Implicit (Result_Element, False);
Tmp := Node (Result_Element);
Tmp := Next (Tmp);
if Nkind (Tmp) = N_Package_Body then
Tmp := Next (Tmp);
end if;
case Nkind (Tmp) is
when N_Package_Instantiation =>
Set_Special_Case
(Result_Element, Expanded_Package_Instantiation);
when N_Function_Instantiation |
N_Procedure_Instantiation =>
Tmp := Node (Result_Element);
Tmp := Specification (Tmp);
Tmp := Last (Visible_Declarations (Tmp));
Result_Element :=
Node_To_Element_New (Node => Tmp,
Starting_Element => Element);
Set_From_Implicit (Result_Element, False);
Set_Special_Case
(Result_Element, Expanded_Subprogram_Instantiation);
when others =>
pragma Assert (False);
null;
end case;
end if;
if Is_Part_Of_Inherited (Result_Element)
and then
Declaration_Kind (Result_Element) = A_Null_Procedure_Declaration
then
Set_Int_Kind (Result_Element, A_Procedure_Declaration);
end if;
return Result_Element;
end Enclosing_Element_For_Implicit;
----------------------------------------
-- Enclosing_Element_For_Limited_View --
----------------------------------------
function Enclosing_Element_For_Limited_View
(Element : Asis.Element)
return Asis.Element
is
Result : Asis.Element := Enclosing_Element_For_Explicit (Element);
begin
if not Is_Nil (Result) then
Set_Special_Case (Result, From_Limited_View);
Set_From_Implicit (Result, True);
Set_Int_Kind (Result, Limited_View_Kind (Result));
end if;
return Result;
end Enclosing_Element_For_Limited_View;
-----------------------
-- General_Encl_Elem --
-----------------------
function General_Encl_Elem (Element : Asis.Element) return Asis.Element is
Result_Node : Node_Id;
Result_Nkind : Node_Kind;
begin
Result_Node := Parent (R_Node (Element));
Result_Nkind := Nkind (Result_Node);
-- and now - special processing for some node kinds to skip nodes which
-- are of no use in ASIS
if Result_Nkind = N_Package_Specification or else
Result_Nkind = N_Function_Specification or else
Result_Nkind = N_Procedure_Specification or else
Result_Nkind = N_Entry_Body_Formal_Part
then
Result_Node := Parent (Result_Node);
end if;
return Node_To_Element_New
(Starting_Element => Element,
Node => Result_Node,
Considering_Parent_Count => False);
end General_Encl_Elem;
-------------------
-- Get_Enclosing --
-------------------
function Get_Enclosing
(Approximation : Asis.Element;
Element : Asis.Element)
return Asis.Element
is
-- we need two-level traversing for searching for Enclosing Element:
-- first, we go through the direct children of an approximate
-- result, and none of them Is_Identical to Element, we repeat
-- the search process for each direct child. We may implement
-- this on top of Traverse_Element, but we prefer to code
-- it manually on top of A4G.Queries
Result_Element : Asis.Element;
Result_Found : Boolean := False;
-- needed to simulate the effect of Terminate_Immediatelly
procedure Check_Possible_Enclosing (Appr_Enclosing : Asis.Element);
-- implements the first level of the search. Appr_Enclosing is
-- the "approximate" Enclosing Element, and this procedure
-- checks if some of its components Is_Identical to Element
-- (Element here is the parameter of Get_Enclosing function,
-- as a global constant value inside Get_Enclosing, it is the
-- same for all the (recursive) calls of Check_Possible_Enclosing
------------------------------
-- Check_Possible_Enclosing --
-------------------------------
procedure Check_Possible_Enclosing (Appr_Enclosing : Asis.Element) is
Child_Access : constant Func_Elem_Array :=
Appropriate_Queries (Appr_Enclosing);
-- this is the way to traverse the direct children
Next_Child : Asis.Element;
procedure Check_List (L : Asis.Element_List);
-- checks if L contains a component which Is_Identical
-- to (global) Element. Sets Result_Found ON if such a
-- component is found
procedure Check_List_Down (L : Asis.Element_List);
-- calls Get_Enclosing for every component of L, by
-- this the recursion and the second level of the search
-- is implemented
procedure Check_List (L : Asis.Element_List) is
begin
for L_El_Index in L'Range loop
if Is_Identical (Element, L (L_El_Index)) then
Result_Found := True;
return;
end if;
end loop;
end Check_List;
procedure Check_List_Down (L : Asis.Element_List) is
begin
if Result_Found then
return;
-- it seems that we do not need this if... ???
end if;
for L_El_Index in L'Range loop
Check_Possible_Enclosing (L (L_El_Index));
if Result_Found then
return;
end if;
end loop;
end Check_List_Down;
begin -- Check_Possible_Enclosing
if Result_Found then
return;
-- now the only goal is to not disturb the setting of the
-- global variable Result_Element to be returned as a result
end if;
-- first, setting the (global for this procedure) Result_Element:
Result_Element := Appr_Enclosing;
-- the first level of the search - checking all the direct
-- children:
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 =>
Next_Child :=
Child_Access (Each_Query).Func_Simple (Appr_Enclosing);
if Is_Identical (Element, Next_Child) then
Result_Found := True;
return;
end if;
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (Appr_Enclosing);
begin
Check_List (Child_List);
if Result_Found then
return;
end if;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(Appr_Enclosing, Child_Access (Each_Query).Bool);
begin
Check_List (Child_List);
if Result_Found then
return;
end if;
end;
end case;
end loop;
-- if we are here, we have hot found Element among the direct
-- children of Appr_Enclosing. So we have to traverse the direct
-- children again, but this time we have to go one step down,
-- so here we have the second level of the search:
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 =>
Next_Child :=
Child_Access (Each_Query).Func_Simple (Appr_Enclosing);
-- and here - recursively one step down
if not Is_Nil (Next_Child) then
Check_Possible_Enclosing (Next_Child);
if Result_Found then
return;
end if;
end if;
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (Appr_Enclosing);
begin
-- and here - recursively one step down
Check_List_Down (Child_List);
if Result_Found then
return;
end if;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(Appr_Enclosing, Child_Access (Each_Query).Bool);
begin
-- and here - recursively one step down
Check_List_Down (Child_List);
if Result_Found then
return;
end if;
end;
end case;
end loop;
end Check_Possible_Enclosing;
begin -- Get_Enclosing
Check_Possible_Enclosing (Approximation);
pragma Assert (Result_Found);
return Result_Element;
end Get_Enclosing;
------------------------------
-- Get_Rough_Enclosing_Node --
------------------------------
function Get_Rough_Enclosing_Node (Element : Asis.Element) return Node_Id
is
Arg_Node : constant Node_Id := R_Node (Element);
Result_Node : Node_Id;
Res_Nkind : Node_Kind;
function Is_Acceptable_As_Rough_Enclosing_Node
(N : Node_Id)
return Boolean;
-- this function encapsulates the condition for choosing
-- the rough enclosing node
function Is_Acceptable_Impl_Neq_Decl (N : Node_Id) return Boolean;
-- Implements a special check for Is_Acceptable_As_Rough_Enclosing_Node:
-- in case if Element is a subcomponenet of an implicit declaration of
-- "/=", checks that N represents the whole declaration of this "/="
-------------------------------------------
-- Is_Acceptable_As_Rough_Enclosing_Node --
-------------------------------------------
function Is_Acceptable_As_Rough_Enclosing_Node
(N : Node_Id)
return Boolean
is
N_K : constant Node_Kind := Nkind (N);
Result : Boolean := True;
begin
if not (Is_Acceptable_Impl_Neq_Decl (N)
or else
Is_List_Member (N)
or else
(Nkind (Parent (N)) = N_Compilation_Unit or else
Nkind (Parent (N)) = N_Subunit))
or else
(Nkind (N) in N_Subexpr
and then Nkind (N) /=
N_Procedure_Call_Statement)
or else
Nkind (N) = N_Parameter_Association
then
Result := False;
elsif N_K = N_Range or else
-- N_K = N_Component_Association or else
N_K = N_Subtype_Indication
then
Result := False;
elsif N_K = N_Component_Association then
if Special_Case (Element) = Is_From_Gen_Association
or else
Is_From_Rewritten_Aggregate (N)
then
Result := False;
end if;
elsif N_K = N_Procedure_Call_Statement and then
Nkind (Parent (N)) = N_Pragma
then
Result := False;
elsif not Comes_From_Source (N)
and then
Sloc (N) > Standard_Location
and then
not Is_Acceptable_Impl_Neq_Decl (N)
then
if not (Is_From_Instance (Element)
and then
Is_Top_Of_Expanded_Generic (N))
then
Result := False;
end if;
end if;
return Result;
end Is_Acceptable_As_Rough_Enclosing_Node;
---------------------------------
-- Is_Acceptable_Impl_Neq_Decl --
---------------------------------
function Is_Acceptable_Impl_Neq_Decl (N : Node_Id) return Boolean is
Result : Boolean := False;
begin
if Special_Case (Element) = Is_From_Imp_Neq_Declaration
and then
Nkind (N) = N_Subprogram_Declaration
and then
not Comes_From_Source (N)
and then
Present (Corresponding_Equality
(Defining_Unit_Name (Specification (N))))
then
Result := True;
end if;
return Result;
end Is_Acceptable_Impl_Neq_Decl;
begin -- Get_Rough_Enclosing_Node
Result_Node := Parent (Arg_Node);
if Nkind (Result_Node) = N_Object_Renaming_Declaration
and then
Special_Case (Element) = Is_From_Gen_Association
and then
Present (Corresponding_Generic_Association (Result_Node))
then
Result_Node := Corresponding_Generic_Association (Result_Node);
elsif (Nkind (Result_Node) = N_Attribute_Definition_Clause
or else
Nkind (Result_Node) = N_Pragma)
and then
From_Aspect_Specification (Result_Node)
then
Result_Node := Corresponding_Aspect (Result_Node);
end if;
while Present (Result_Node) and then
not Is_Acceptable_As_Rough_Enclosing_Node (Result_Node)
loop
Result_Node := Parent (Result_Node);
case Nkind (Result_Node) is
when N_Object_Renaming_Declaration =>
if Special_Case (Element) = Is_From_Gen_Association
and then
Present (Corresponding_Generic_Association (Result_Node))
then
Result_Node :=
Corresponding_Generic_Association (Result_Node);
end if;
when N_Attribute_Definition_Clause |
N_Pragma =>
if From_Aspect_Specification (Result_Node) then
Result_Node := Corresponding_Aspect (Result_Node);
end if;
when N_Freeze_Entity =>
Result_Node := Entity (Result_Node);
Result_Node := Parent (Result_Node);
when others => null;
end case;
if Nkind (Result_Node) = N_Compilation_Unit then
-- this means that there is no node list on the way up
-- the tree, and we have to go back to the node
-- for the unit declaration:
if Is_Standard (Encl_Unit (Element)) then
Result_Node := Standard_Package_Node;
else
Result_Node := Unit (Result_Node);
end if;
if Nkind (Result_Node) = N_Subunit then
Result_Node := Proper_Body (Result_Node);
end if;
exit;
end if;
end loop;
-- and here we have to take into account possible normalization
-- of multi-identifier declarations:
Res_Nkind := Nkind (Result_Node);
if Res_Nkind = N_Object_Declaration or else
Res_Nkind = N_Number_Declaration or else
Res_Nkind = N_Discriminant_Specification or else
Res_Nkind = N_Component_Declaration or else
Res_Nkind = N_Parameter_Specification or else
Res_Nkind = N_Exception_Declaration or else
Res_Nkind = N_Formal_Object_Declaration or else
Res_Nkind = N_With_Clause
then
Skip_Normalized_Declarations_Back (Result_Node);
end if;
-- If we've got Result_Node pointing to the artificial package
-- declaration created for library-level generic instantiation,
-- we have to the body for which we have this instantiation as
-- the original node
if Nkind (Result_Node) = N_Package_Declaration and then
not Comes_From_Source (Result_Node) and then
Nkind (Parent (Result_Node)) = N_Compilation_Unit and then
not Is_From_Instance (Element) and then
not Is_Rewrite_Substitution (Result_Node)
then
Result_Node := Corresponding_Body (Result_Node);
while Nkind (Result_Node) /= N_Package_Body loop
Result_Node := Parent (Result_Node);
end loop;
end if;
-- Below is the patch for 8706-003. It is needed when we are looking
-- for the enclosing element for actual parameter in subprogram
-- instantiation. In this case Result_Node points to the spec of a
-- wrapper package, so we have to go to the instantiation.
if Special_Case (Element) = Is_From_Gen_Association
and then
Nkind (Result_Node) = N_Package_Declaration
and then
not (Nkind (Original_Node (Result_Node)) = N_Package_Instantiation
or else
Nkind (Original_Node (Result_Node)) = N_Package_Body
or else
(Present (Generic_Parent (Specification (Result_Node)))
and then
Ekind (Generic_Parent (Specification (Result_Node))) =
E_Generic_Package))
and then
not Comes_From_Source (Result_Node)
and then
(Nkind (Parent (Arg_Node)) = N_Subprogram_Renaming_Declaration
and then
not Comes_From_Source (Parent (Arg_Node)))
and then
Instantiation_Depth (Sloc (Result_Node)) =
Instantiation_Depth (Sloc (Arg_Node))
then
if Is_Rewrite_Substitution (Result_Node)
and then
Nkind (Original_Node (Result_Node)) in N_Generic_Instantiation
then
Result_Node := Original_Node (Result_Node);
else
while not Comes_From_Source (Result_Node) loop
Result_Node := Next_Non_Pragma (Result_Node);
end loop;
end if;
end if;
return Result_Node;
end Get_Rough_Enclosing_Node;
--------------------------------
-- Is_Top_Of_Expanded_Generic --
--------------------------------
function Is_Top_Of_Expanded_Generic (N : Node_Id) return Boolean is
N_Kind : constant Node_Kind := Nkind (N);
Result : Boolean := False;
begin
Result :=
((not Comes_From_Source (N) or else
Is_Rewrite_Insertion (N))
and then
(N_Kind = N_Package_Declaration or else
N_Kind = N_Package_Body or else
N_Kind = N_Subprogram_Declaration or else
N_Kind = N_Subprogram_Body)
and then
Nkind (Original_Node (N)) not in N_Renaming_Declaration)
or else
(Nkind (Parent (N)) = N_Package_Body and then
not Comes_From_Source (Parent (N)))
or else
(Is_Rewrite_Substitution (N) and then
Nkind (Original_Node (N)) = N_Package_Instantiation);
-- Library-level package instantiation
return Result;
end Is_Top_Of_Expanded_Generic;
--------------------------
-- No_Enclosing_Element --
--------------------------
procedure No_Enclosing_Element (Element_Kind : Internal_Element_Kinds) is
begin
Raise_ASIS_Failed
("No Enclosing Element can correspond " &
"to the Element with Internal_Element_Kinds value of " &
Internal_Element_Kinds'Image (Element_Kind));
end No_Enclosing_Element;
----------------------------------------------------
-- Not_Implemented_Enclosing_Element_Construction --
----------------------------------------------------
procedure Not_Implemented_Enclosing_Element_Construction
(Element : Asis.Element)
is
begin
Not_Implemented_Yet (Diagnosis =>
"Enclosing Element retrieval for the explicit Element "
& "of the " & Internal_Element_Kinds'Image
(Int_Kind (Element)) & " kind "
& "has not been implemented yet");
end Not_Implemented_Enclosing_Element_Construction;
------------
-- Parent --
------------
function Parent (Node : Node_Id) return Node_Id is
Result_Node : Node_Id;
begin
Result_Node := Atree.Parent (Node);
Skip_Normalized_Declarations_Back (Result_Node);
return Result_Node;
end Parent;
---------------------------
-- Skip_Implicit_Subtype --
---------------------------
procedure Skip_Implicit_Subtype (Constr : in out Node_Id) is
begin
if not Comes_From_Source (Parent (Constr)) then
Constr := Parent (Constr);
while Nkind (Constr) /= N_Object_Declaration loop
Constr := Next_Non_Pragma (Constr);
end loop;
Constr := Object_Definition (Constr);
end if;
end Skip_Implicit_Subtype;
---------------------------------------
-- Skip_Normalized_Declarations_Back --
---------------------------------------
procedure Skip_Normalized_Declarations_Back (Node : in out Node_Id) is
Arg_Kind : constant Node_Kind := Nkind (Node);
begin
loop
if Arg_Kind = N_Object_Declaration or else
Arg_Kind = N_Number_Declaration or else
Arg_Kind = N_Discriminant_Specification or else
Arg_Kind = N_Component_Declaration or else
Arg_Kind = N_Parameter_Specification or else
Arg_Kind = N_Exception_Declaration or else
Arg_Kind = N_Formal_Object_Declaration
then
if Prev_Ids (Node) then
Node := Prev (Node);
while Nkind (Node) /= Arg_Kind loop
-- some implicit subtype declarations may be inserted by
-- the compiler in between the normalized declarations, so:
Node := Prev (Node);
end loop;
else
return;
end if;
elsif Arg_Kind = N_With_Clause then
if First_Name (Node) then
return;
else
Node := Prev (Node);
end if;
else
return;
-- nothing to do!
end if;
end loop;
end Skip_Normalized_Declarations_Back;
end A4G.Encl_El;
|