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
|
//===--- ModuleFormat.h - The internals of serialized modules ---*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Contains various constants and helper types to deal with serialized
/// modules.
///
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SERIALIZATION_MODULEFORMAT_H
#define SWIFT_SERIALIZATION_MODULEFORMAT_H
#include "swift/AST/Decl.h"
#include "swift/AST/FineGrainedDependencyFormat.h"
#include "swift/AST/Types.h"
#include "llvm/ADT/PointerEmbeddedInt.h"
#include "llvm/Bitcode/BitcodeConvenience.h"
#include "llvm/Bitstream/BitCodes.h"
namespace swift {
class ModuleFile;
class TypeDeserializer;
namespace serialization {
using llvm::PointerEmbeddedInt;
using llvm::BCArray;
using llvm::BCBlob;
using llvm::BCFixed;
using llvm::BCGenericRecordLayout;
using llvm::BCRecordLayout;
using llvm::BCVBR;
/// Magic number for serialized module files.
const unsigned char SWIFTMODULE_SIGNATURE[] = { 0xE2, 0x9C, 0xA8, 0x0E };
/// Alignment of each serialized modules inside a .swift_ast section.
const unsigned char SWIFTMODULE_ALIGNMENT = 4;
/// Serialized module format major version number.
///
/// Always 0 for Swift 1.x - 4.x.
const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// Serialized module format minor version number.
///
/// When the format changes IN ANY WAY, this number should be incremented.
/// To ensure that two separate changes don't silently get merged into one
/// in source control, you should also update the comment to briefly
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 871; // SIL function thunk kind
/// A standard hash seed used for all string hashes in a serialized module.
///
/// This is the same as the default used by llvm::djbHash, just provided
/// explicitly here to note that it's part of the format.
const uint32_t SWIFTMODULE_HASH_SEED = 5381;
using DeclIDField = BCFixed<31>;
// TypeID must be the same as DeclID because it is stored in the same way.
using TypeID = DeclID;
using TypeIDField = DeclIDField;
using TypeIDWithBitField = BCFixed<32>;
// ClangTypeID must be the same as DeclID because it is stored in the same way.
using ClangTypeID = TypeID;
using ClangTypeIDField = TypeIDField;
// IdentifierID must be the same as DeclID because it is stored in the same way.
using IdentifierID = DeclID;
using IdentifierIDField = DeclIDField;
// LocalDeclContextID must be the same as DeclID because it is stored in the
// same way.
using LocalDeclContextID = DeclID;
using LocalDeclContextIDField = DeclIDField;
/// Stores either a DeclID or a LocalDeclContextID, using 32 bits.
class DeclContextID {
int32_t rawValue;
explicit DeclContextID(int32_t rawValue) : rawValue(rawValue) {}
public:
DeclContextID() : DeclContextID(0) {}
static DeclContextID forDecl(DeclID value) {
assert(value && "should encode null using DeclContextID()");
assert(llvm::isUInt<31>(value) && "too many DeclIDs");
return DeclContextID(static_cast<int32_t>(value));
}
static DeclContextID forLocalDeclContext(LocalDeclContextID value) {
assert(value && "should encode null using DeclContextID()");
assert(llvm::isUInt<31>(value) && "too many LocalDeclContextIDs");
return DeclContextID(-static_cast<int32_t>(value));
}
explicit operator bool() const {
return rawValue != 0;
}
std::optional<DeclID> getAsDeclID() const {
if (rawValue > 0)
return DeclID(rawValue);
return std::nullopt;
}
std::optional<LocalDeclContextID> getAsLocalDeclContextID() const {
if (rawValue < 0)
return LocalDeclContextID(-rawValue);
return std::nullopt;
}
static DeclContextID getFromOpaqueValue(uint32_t opaqueValue) {
return DeclContextID(opaqueValue);
}
uint32_t getOpaqueValue() const { return rawValue; }
};
class DeclContextIDField : public BCFixed<32> {
public:
static DeclContextID convert(uint64_t rawValue) {
assert(llvm::isUInt<32>(rawValue));
return DeclContextID::getFromOpaqueValue(rawValue);
}
};
// ProtocolConformanceID must be the same as DeclID because it is stored
// in the same way.
using ProtocolConformanceID = DeclID;
using ProtocolConformanceIDField = DeclIDField;
// The low two bits of the ProtocolConformanceID determine the kind:
// 00 -- abstract conformance
// 01 -- concrete conformance
// 10 -- pack conformance
struct SerializedProtocolConformanceKind {
enum {
Abstract = 0,
Concrete = 1,
Pack = 2,
Shift = 2,
Mask = 3
};
};
// GenericSignatureID must be the same as DeclID because it is stored in the
// same way.
using GenericSignatureID = DeclID;
using GenericSignatureIDField = DeclIDField;
using GenericEnvironmentID = unsigned;
using GenericEnvironmentIDField = BCFixed<32>;
// SubstitutionMapID must be the same as DeclID because it is stored in the
// same way.
using SubstitutionMapID = DeclID;
using SubstitutionMapIDField = DeclIDField;
// ModuleID must be the same as IdentifierID because it is stored the same way.
using ModuleID = IdentifierID;
using ModuleIDField = IdentifierIDField;
// SILLayoutID must be the same as DeclID because it is stored in the same way.
using SILLayoutID = DeclID;
using SILLayoutIDField = DeclIDField;
using BitOffset = PointerEmbeddedInt<unsigned, 31>;
using BitOffsetField = BCFixed<31>;
// CharOffset must be the same as BitOffset because it is stored in the
// same way.
using CharOffset = BitOffset;
using CharOffsetField = BitOffsetField;
using FileSizeField = BCVBR<16>;
using FileModTimeOrContentHashField = BCVBR<16>;
using FileHashField = BCVBR<16>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class OpaqueReadOwnership : uint8_t {
Owned,
Borrowed,
OwnedOrBorrowed,
};
using OpaqueReadOwnershipField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ReadImplKind : uint8_t {
Stored = 0,
Get,
Inherited,
Address,
Read,
};
using ReadImplKindField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class WriteImplKind : uint8_t {
Immutable = 0,
Stored,
StoredWithObservers,
InheritedWithObservers,
Set,
MutableAddress,
Modify,
};
using WriteImplKindField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ReadWriteImplKind : uint8_t {
Immutable = 0,
Stored,
MutableAddress,
MaterializeToTemporary,
Modify,
StoredWithDidSet,
InheritedWithDidSet,
};
using ReadWriteImplKindField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class StaticSpellingKind : uint8_t {
None = 0,
KeywordStatic,
KeywordClass,
};
using StaticSpellingKindField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class FunctionTypeRepresentation : uint8_t {
Swift = 0,
Block,
Thin,
CFunctionPointer,
};
using FunctionTypeRepresentationField = BCFixed<4>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class DifferentiabilityKind : uint8_t {
NonDifferentiable = 0,
Forward,
Reverse,
Normal,
Linear,
};
using DifferentiabilityKindField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing the
// module version.
enum class AutoDiffDerivativeFunctionKind : uint8_t {
JVP = 0,
VJP
};
using AutoDiffDerivativeFunctionKindField = BCFixed<1>;
enum class ForeignErrorConventionKind : uint8_t {
ZeroResult,
NonZeroResult,
ZeroPreservedResult,
NilResult,
NonNilError,
};
using ForeignErrorConventionKindField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class SILFunctionTypeRepresentation : uint8_t {
Thick = 0,
Block,
Thin,
CFunctionPointer,
FirstSIL = 8,
Method = FirstSIL,
ObjCMethod,
WitnessMethod,
Closure,
CXXMethod,
KeyPathAccessorGetter,
KeyPathAccessorSetter,
KeyPathAccessorEquals,
KeyPathAccessorHash,
};
using SILFunctionTypeRepresentationField = BCFixed<5>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class SILCoroutineKind : uint8_t {
None = 0,
YieldOnce = 1,
YieldMany = 2,
};
using SILCoroutineKindField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum OperatorKind : uint8_t {
Infix = 0,
Prefix,
Postfix,
PrecedenceGroup, // only for cross references
};
// This is currently required to have the same width as AccessorKindField.
using OperatorKindField = BCFixed<4>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum AccessorKind : uint8_t {
Get = 0,
Set,
WillSet,
DidSet,
Address,
MutableAddress,
Read,
Modify,
Init,
DistributedGet,
};
using AccessorKindField = BCFixed<4>;
using AccessorCountField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum CtorInitializerKind : uint8_t {
Designated = 0,
Convenience = 1,
Factory = 2,
ConvenienceFactory = 3,
};
using CtorInitializerKindField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ParamDeclSpecifier : uint8_t {
Default = 0,
InOut = 1,
Borrowing = 2,
Consuming = 3,
LegacyShared = 4,
LegacyOwned = 5,
ImplicitlyCopyableConsuming = 6,
};
using ParamDeclSpecifierField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class VarDeclIntroducer : uint8_t {
Let = 0,
Var = 1,
InOut = 2,
Borrowing = 3,
};
using VarDeclIntroducerField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ParameterConvention : uint8_t {
Indirect_In,
Indirect_Inout,
Indirect_InoutAliasable,
Direct_Owned,
Direct_Unowned,
Direct_Guaranteed,
Indirect_In_Guaranteed,
Indirect_In_Constant,
Pack_Owned,
Pack_Inout,
Pack_Guaranteed,
};
using ParameterConventionField = BCFixed<4>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class SILParameterDifferentiability : uint8_t {
DifferentiableOrNotApplicable = 0,
NotDifferentiable,
};
/// These IDs must \em not be renumbered or reordered without incrementing the
/// module version.
enum class SILParameterInfoFlags : uint8_t {
NotDifferentiable = 0x1,
Isolated = 0x2,
Sending = 0x4,
};
using SILParameterInfoOptions = OptionSet<SILParameterInfoFlags>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ResultConvention : uint8_t {
Indirect,
Owned,
Unowned,
UnownedInnerPointer,
Autoreleased,
Pack,
};
using ResultConventionField = BCFixed<3>;
/// These IDs must \em not be renumbered or reordered without incrementing the
/// module version.
enum class SILResultInfoFlags : uint8_t {
NotDifferentiable = 0x1,
IsSending = 0x2,
};
using SILResultInfoOptions = OptionSet<SILResultInfoFlags>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum MetatypeRepresentation : uint8_t {
MR_None, MR_Thin, MR_Thick, MR_ObjC
};
using MetatypeRepresentationField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class SelfAccessKind : uint8_t {
NonMutating = 0,
Mutating,
LegacyConsuming,
Consuming,
Borrowing,
};
using SelfAccessKindField = BCFixed<3>;
/// Translates an operator decl fixity to a Serialization fixity, whose values
/// are guaranteed to be stable.
static inline OperatorKind getStableFixity(OperatorFixity fixity) {
switch (fixity) {
case OperatorFixity::Prefix:
return Prefix;
case OperatorFixity::Postfix:
return Postfix;
case OperatorFixity::Infix:
return Infix;
}
llvm_unreachable("Unhandled case in switch");
}
/// Translates a stable Serialization fixity back to an AST operator fixity.
static inline OperatorFixity getASTOperatorFixity(OperatorKind fixity) {
switch (fixity) {
case Prefix:
return OperatorFixity::Prefix;
case Postfix:
return OperatorFixity::Postfix;
case Infix:
return OperatorFixity::Infix;
case PrecedenceGroup:
llvm_unreachable("Not an operator kind");
}
llvm_unreachable("Unhandled case in switch");
}
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum GenericRequirementKind : uint8_t {
SameShape = 0,
Conformance = 1,
SameType = 2,
Superclass = 3,
Layout = 4,
};
using GenericRequirementKindField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum LayoutRequirementKind : uint8_t {
UnknownLayout = 0,
TrivialOfExactSize = 1,
TrivialOfAtMostSize = 2,
Trivial = 3,
RefCountedObject = 4,
NativeRefCountedObject = 5,
Class = 6,
NativeClass = 7,
BridgeObject = 8,
TrivialStride = 9,
};
using LayoutRequirementKindField = BCFixed<4>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum Associativity : uint8_t {
NonAssociative = 0,
LeftAssociative,
RightAssociative
};
using AssociativityField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum ReferenceOwnership : uint8_t {
Strong = 0,
Weak,
Unowned,
Unmanaged,
};
using ReferenceOwnershipField = BCFixed<2>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class DefaultArgumentKind : uint8_t {
None = 0,
Normal,
FileID,
FileIDSpelledAsFile,
FilePath,
FilePathSpelledAsFile,
Line,
Column,
Function,
Inherited,
DSOHandle,
NilLiteral,
EmptyArray,
EmptyDictionary,
StoredProperty,
ExpressionMacro,
};
using DefaultArgumentField = BCFixed<4>;
/// These IDs must \em not be renumbered or reordered without incrementing
/// the module version.
enum class ActorIsolation : uint8_t {
Unspecified = 0,
ActorInstance,
Nonisolated,
NonisolatedUnsafe,
GlobalActor,
GlobalActorUnsafe,
Erased,
};
using ActorIsolationField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum LibraryKind : uint8_t {
Library = 0,
Framework
};
using LibraryKindField = BCFixed<1>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class AccessLevel : uint8_t {
Private = 0,
FilePrivate,
Internal,
Package,
Public,
Open,
};
using AccessLevelField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class DeclNameKind: uint8_t {
Normal,
Subscript,
Constructor,
Destructor
};
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum SpecialIdentifierID : uint8_t {
/// Special IdentifierID value for the Builtin module.
BUILTIN_MODULE_ID = 0,
/// Special IdentifierID value for the current module.
CURRENT_MODULE_ID,
/// Special value for the module for imported Objective-C headers.
OBJC_HEADER_MODULE_ID,
/// Special value for the special subscript name
SUBSCRIPT_ID,
/// Special value for the special constructor name
CONSTRUCTOR_ID,
/// Special value for the special destructor name
DESTRUCTOR_ID,
/// The number of special Identifier IDs. This value should never be encoded;
/// it should only be used to count the number of names above. As such, it
/// is correct and necessary to add new values above this one.
NUM_SPECIAL_IDS
};
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class EnumElementRawValueKind : uint8_t {
/// No raw value serialized.
None = 0,
/// Integer literal.
IntegerLiteral,
/// TODO: Float, string, char, etc.
};
using EnumElementRawValueKindField = BCFixed<4>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ResilienceExpansion : uint8_t {
Minimal = 0,
Maximal,
};
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ImportControl : uint8_t {
/// `import FooKit`
Normal = 0,
/// `@_exported import FooKit`
Exported,
/// `@_implementationOnly import FooKit`
ImplementationOnly,
/// `internal import FooKit` or more restrictive.
InternalOrBelow,
/// `package import FooKit`
PackageOnly,
};
using ImportControlField = BCFixed<3>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class ClangDeclPathComponentKind : uint8_t {
Record = 0,
Enum,
Namespace,
Typedef,
TypedefAnonDecl,
ObjCInterface,
ObjCProtocol,
};
enum class GenericEnvironmentKind : uint8_t {
OpenedExistential,
OpenedElement
};
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class MacroRole : uint8_t {
#define MACRO_ROLE(Name, Description) Name,
#include "swift/Basic/MacroRoles.def"
};
using MacroRoleField = BCFixed<4>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class MacroIntroducedDeclNameKind : uint8_t {
Named = 0,
Overloaded,
Accessors,
Prefixed,
Suffixed,
Arbitrary,
};
using MacroIntroducedDeclNameKindField = BCFixed<4>;
// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class PluginSearchOptionKind : uint8_t {
PluginPath,
ExternalPluginPath,
LoadPluginLibrary,
LoadPluginExecutable,
};
using PluginSearchOptionKindField = BCFixed<3>;
enum class FunctionTypeIsolation : uint8_t {
NonIsolated,
Parameter,
Erased,
GlobalActorOffset, // Add this to the global actor type ID
};
using FunctionTypeIsolationField = TypeIDField;
// Encodes a VersionTuple:
//
// Major
// Minor
// Subminor
// HasMinor
// HasSubminor
#define BC_AVAIL_TUPLE\
BCVBR<5>,\
BCVBR<5>,\
BCVBR<4>,\
BCFixed<1>,\
BCFixed<1>
#define LIST_VER_TUPLE_PIECES(X)\
X##_Major, X##_Minor, X##_Subminor, X##_HasMinor, X##_HasSubminor
#define DEF_VER_TUPLE_PIECES(X) unsigned LIST_VER_TUPLE_PIECES(X)
#define DECODE_VER_TUPLE(X)\
if (X##_HasMinor) {\
if (X##_HasSubminor)\
X = llvm::VersionTuple(X##_Major, X##_Minor, X##_Subminor);\
else\
X = llvm::VersionTuple(X##_Major, X##_Minor);\
}\
else X = llvm::VersionTuple(X##_Major);
#define ENCODE_VER_TUPLE(X, X_Expr)\
unsigned X##_Major = 0, X##_Minor = 0, X##_Subminor = 0,\
X##_HasMinor = 0, X##_HasSubminor = 0;\
const auto &X##_Val = X_Expr;\
if (X##_Val.has_value()) {\
const auto &Y = X##_Val.value();\
X##_Major = Y.getMajor();\
X##_Minor = Y.getMinor().value_or(0);\
X##_Subminor = Y.getSubminor().value_or(0);\
X##_HasMinor = Y.getMinor().has_value();\
X##_HasSubminor = Y.getSubminor().has_value();\
}
/// The various types of blocks that can occur within a serialized Swift
/// module.
///
/// Some of these are shared with the swiftdoc format, which is a stable format.
/// Be very very careful when renumbering them.
enum BlockID {
/// The module block, which contains all of the other blocks (and in theory
/// allows a single file to contain multiple modules).
MODULE_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID,
/// The control block, which contains all of the information that needs to
/// be validated prior to committing to loading the serialized module.
///
/// This is part of a stable format and must not be renumbered!
///
/// \sa control_block
CONTROL_BLOCK_ID,
/// The input block, which contains all the files this module depends on.
///
/// \sa input_block
INPUT_BLOCK_ID,
/// The "decls-and-types" block, which contains all of the declarations that
/// come from this module.
///
/// Types are also stored here, so that types that just wrap a Decl don't need
/// a separate entry in the file.
///
/// \sa decls_block
DECLS_AND_TYPES_BLOCK_ID,
/// The identifier block, which contains all of the strings used in
/// identifiers in the module.
///
/// Unlike other blocks in the file, all data within this block is completely
/// opaque. Offsets into this block should point directly into the blob at a
/// null-terminated UTF-8 string.
IDENTIFIER_DATA_BLOCK_ID,
/// The index block, which contains cross-referencing information for the
/// module.
///
/// \sa index_block
INDEX_BLOCK_ID,
/// The block for SIL functions.
///
/// \sa sil_block
SIL_BLOCK_ID,
/// The index block for SIL functions.
///
/// \sa sil_index_block
SIL_INDEX_BLOCK_ID,
/// A sub-block of the control block that contains configuration options
/// needed to successfully load this module.
///
/// \sa options_block
OPTIONS_BLOCK_ID,
/// The declaration member-tables index block, a sub-block of the index block.
///
/// \sa decl_member_tables_block
DECL_MEMBER_TABLES_BLOCK_ID,
/// The module documentation container block, which contains all other
/// documentation blocks.
///
/// This is part of a stable format and must not be renumbered!
MODULE_DOC_BLOCK_ID = 96,
/// The comment block, which contains documentation comments.
///
/// This is part of a stable format and must not be renumbered!
///
/// \sa comment_block
COMMENT_BLOCK_ID,
/// The module source location container block, which contains all other
/// source location blocks.
///
/// This is part of a stable format and should not be renumbered.
///
/// Though we strive to keep the format stable, breaking the format of
/// .swiftsourceinfo doesn't have consequences as serious as breaking the
/// format of .swiftdoc because .swiftsourceinfo file is for local development
/// use only.
MODULE_SOURCEINFO_BLOCK_ID = 192,
/// The source location block, which contains decl locations.
///
/// This is part of a stable format and should not be renumbered.
///
/// Though we strive to keep the format stable, breaking the format of
/// .swiftsourceinfo doesn't have consequences as serious as breaking the
/// format
/// of .swiftdoc because .swiftsourceinfo file is for local development use
/// only.
///
/// \sa decl_locs_block
DECL_LOCS_BLOCK_ID,
/// The incremental dependency information block.
///
/// This is part of a stable format and should not be renumbered.
INCREMENTAL_INFORMATION_BLOCK_ID =
fine_grained_dependencies::INCREMENTAL_INFORMATION_BLOCK_ID,
};
/// The record types within the control block.
///
/// Be VERY VERY careful when changing this block; it is also used by the
/// swiftdoc format, which \e must \e remain \e stable. Adding new records is
/// okay---they will be ignored---but modifying existing ones must be done
/// carefully. You may need to update the swiftdoc version in DocFormat.h.
///
/// \sa CONTROL_BLOCK_ID
namespace control_block {
enum {
METADATA = 1,
MODULE_NAME,
TARGET,
SDK_NAME,
REVISION,
CHANNEL,
IS_OSSA,
ALLOWABLE_CLIENT_NAME,
};
using MetadataLayout = BCRecordLayout<
METADATA, // ID
BCFixed<16>, // Module format major version
BCFixed<16>, // Module format minor version
BCVBR<8>, // length of "short version string" in the blob
BCVBR<8>, // length of "short compatibility version string" in the blob
BCVBR<17>, // User module format major version
BCVBR<17>, // User module format minor version
BCVBR<17>, // User module format sub-minor version
BCVBR<17>, // User module format build version
BCBlob // misc. version information
>;
using ModuleNameLayout = BCRecordLayout<
MODULE_NAME,
BCBlob
>;
using TargetLayout = BCRecordLayout<
TARGET,
BCBlob // LLVM triple
>;
using SDKNameLayout = BCRecordLayout<
SDK_NAME,
BCBlob
>;
using RevisionLayout = BCRecordLayout<
REVISION,
BCBlob
>;
using ChannelLayout = BCRecordLayout<
CHANNEL,
BCBlob
>;
using IsOSSALayout = BCRecordLayout<
IS_OSSA,
BCFixed<1>
>;
using AllowableClientLayout = BCRecordLayout<
ALLOWABLE_CLIENT_NAME,
BCBlob
>;
}
/// The record types within the options block (a sub-block of the control
/// block).
///
/// \sa OPTIONS_BLOCK_ID
namespace options_block {
enum {
SDK_PATH = 1,
XCC,
IS_SIB,
IS_STATIC_LIBRARY,
HAS_HERMETIC_SEAL_AT_LINK,
IS_EMBEDDED_SWIFT_MODULE,
IS_TESTABLE,
RESILIENCE_STRATEGY,
ARE_PRIVATE_IMPORTS_ENABLED,
IS_IMPLICIT_DYNAMIC_ENABLED,
IS_BUILT_FROM_INTERFACE,
IS_ALLOW_MODULE_WITH_COMPILER_ERRORS_ENABLED,
MODULE_ABI_NAME,
IS_CONCURRENCY_CHECKED,
MODULE_PACKAGE_NAME,
MODULE_EXPORT_AS_NAME,
PLUGIN_SEARCH_OPTION,
HAS_CXX_INTEROPERABILITY_ENABLED,
ALLOW_NON_RESILIENT_ACCESS,
SERIALIZE_PACKAGE_ENABLED,
};
using SDKPathLayout = BCRecordLayout<
SDK_PATH,
BCBlob // path
>;
using XCCLayout = BCRecordLayout<
XCC,
BCBlob // -Xcc flag, as string
>;
using PluginSearchOptionLayout = BCRecordLayout<
PLUGIN_SEARCH_OPTION,
PluginSearchOptionKindField, // kind
BCBlob // option value string
>;
using IsSIBLayout = BCRecordLayout<
IS_SIB,
BCFixed<1> // Is this an intermediate file?
>;
using IsStaticLibraryLayout = BCRecordLayout<
IS_STATIC_LIBRARY
>;
using HasHermeticSealAtLinkLayout = BCRecordLayout<
HAS_HERMETIC_SEAL_AT_LINK
>;
using IsEmbeddedSwiftModuleLayout = BCRecordLayout<
IS_EMBEDDED_SWIFT_MODULE
>;
using IsTestableLayout = BCRecordLayout<
IS_TESTABLE
>;
using ArePrivateImportsEnabledLayout = BCRecordLayout<
ARE_PRIVATE_IMPORTS_ENABLED
>;
using IsImplicitDynamicEnabledLayout = BCRecordLayout<
IS_IMPLICIT_DYNAMIC_ENABLED
>;
using ResilienceStrategyLayout = BCRecordLayout<
RESILIENCE_STRATEGY,
BCFixed<2>
>;
using IsBuiltFromInterfaceLayout = BCRecordLayout<
IS_BUILT_FROM_INTERFACE
>;
using IsAllowModuleWithCompilerErrorsEnabledLayout = BCRecordLayout<
IS_ALLOW_MODULE_WITH_COMPILER_ERRORS_ENABLED
>;
using ModuleABINameLayout = BCRecordLayout<
MODULE_ABI_NAME,
BCBlob
>;
using IsConcurrencyCheckedLayout = BCRecordLayout<
IS_CONCURRENCY_CHECKED
>;
using ModulePackageNameLayout = BCRecordLayout<
MODULE_PACKAGE_NAME,
BCBlob
>;
using ModuleExportAsNameLayout = BCRecordLayout<
MODULE_EXPORT_AS_NAME,
BCBlob
>;
using HasCxxInteroperabilityEnabledLayout = BCRecordLayout<
HAS_CXX_INTEROPERABILITY_ENABLED
>;
using AllowNonResilientAccess = BCRecordLayout<
ALLOW_NON_RESILIENT_ACCESS
>;
using SerializePackageEnabled = BCRecordLayout<
SERIALIZE_PACKAGE_ENABLED
>;
}
/// The record types within the input block.
///
/// \sa INPUT_BLOCK_ID
namespace input_block {
enum {
IMPORTED_MODULE = 1,
LINK_LIBRARY,
IMPORTED_HEADER,
IMPORTED_HEADER_CONTENTS,
MODULE_FLAGS, // [unused]
SEARCH_PATH,
FILE_DEPENDENCY,
DEPENDENCY_DIRECTORY,
MODULE_INTERFACE_PATH,
IMPORTED_MODULE_SPIS,
};
using ImportedModuleLayout = BCRecordLayout<
IMPORTED_MODULE,
ImportControlField, // import kind
BCFixed<1>, // scoped?
BCFixed<1>, // has spis?
BCBlob // module name, with submodule path pieces separated by \0s.
// If the 'scoped' flag is set, the final path piece is an access
// path within the module.
>;
using ImportedModuleLayoutSPI = BCRecordLayout<
IMPORTED_MODULE_SPIS,
BCBlob // SPI names, separated by \0s
>;
using LinkLibraryLayout = BCRecordLayout<
LINK_LIBRARY,
LibraryKindField, // kind
BCFixed<1>, // forced?
BCBlob // library name
>;
using ImportedHeaderLayout = BCRecordLayout<
IMPORTED_HEADER,
BCFixed<1>, // exported?
FileSizeField, // file size (for validation)
FileHashField, // file hash (for validation)
BCBlob // file path
>;
using ImportedHeaderContentsLayout = BCRecordLayout<
IMPORTED_HEADER_CONTENTS,
BCBlob
>;
using SearchPathLayout = BCRecordLayout<
SEARCH_PATH,
BCFixed<1>, // framework?
BCFixed<1>, // system?
BCBlob // path
>;
using FileDependencyLayout = BCRecordLayout<
FILE_DEPENDENCY,
FileSizeField, // file size (for validation)
FileModTimeOrContentHashField, // mtime or content hash (for validation)
BCFixed<1>, // are we reading mtime (0) or hash (1)?
BCFixed<1>, // SDK-relative?
BCVBR<8>, // subpath-relative index (0=none)
BCBlob // path
>;
using DependencyDirectoryLayout = BCRecordLayout<
DEPENDENCY_DIRECTORY,
BCBlob
>;
using ModuleInterfaceLayout = BCRecordLayout<
MODULE_INTERFACE_PATH,
BCBlob // file path
>;
}
/// The record types within the "decls-and-types" block.
///
/// \sa DECLS_AND_TYPES_BLOCK_ID
namespace decls_block {
enum RecordKind : uint16_t {
#define RECORD(Id) Id,
#define RECORD_VAL(Id, Value) Id = Value,
#include "DeclTypeRecordNodes.def"
};
namespace detail {
enum TypeRecords : uint16_t {
#define TYPE(Id) Id##_TYPE = decls_block::RecordKind::Id##_TYPE,
#include "DeclTypeRecordNodes.def"
};
template <TypeRecords Record>
class TypeRecordDispatch {};
template <TypeRecords RecordCode, typename ...Ts>
struct code { public: constexpr static TypeRecords value = RecordCode; };
struct function_deserializer {
static llvm::Expected<Type>
deserialize(ModuleFile &MF, SmallVectorImpl<uint64_t> &scratch,
StringRef blobData, bool isGeneric);
};
#define TYPE_LAYOUT_IMPL(LAYOUT, ...) \
using LAYOUT = BCRecordLayout<__VA_ARGS__>; \
template <> \
class detail::TypeRecordDispatch< \
detail::code<detail::TypeRecords::__VA_ARGS__>::value> { \
friend class swift::ModuleFile; \
static llvm::Expected<Type> \
deserialize(ModuleFile &MF, \
llvm::SmallVectorImpl<uint64_t> &scratch, \
StringRef blobData); \
}
} // namespace detail
/// This \c TYPE_LAYOUT(...) macro replaces the usual \c BCRecordLayout coding
/// structures below by enforcing structural checks for the definition of
/// deserialization members. If you forget to define a \c TYPE_LAYOUT(...) for a
/// \c TYPE(...) there will be a gnarly SFINAE error pointing at it in
/// DeclTypeRecordNodes.def.
///
/// This macro pairs with \c DESERIALIZE_TYPE(...) in Deserialization.cpp such
/// that if you forget \c DESERIALIZE_TYPE(...) you will come up
/// with a linker error.
#define TYPE_LAYOUT(LAYOUT, ...) TYPE_LAYOUT_IMPL(LAYOUT, __VA_ARGS__)
using ClangTypeLayout = BCRecordLayout<
CLANG_TYPE,
BCArray<BCVBR<6>>
>;
/// A flag to mark a decl as being invalid
using ErrorFlagLayout = BCRecordLayout<
ERROR_FLAG
>;
/// A placeholder for invalid types
TYPE_LAYOUT(ErrorTypeLayout,
ERROR_TYPE,
TypeIDField // original type (if any)
);
TYPE_LAYOUT(BuiltinAliasTypeLayout,
BUILTIN_ALIAS_TYPE,
DeclIDField, // typealias decl
TypeIDField // canonical type (a fallback)
);
TYPE_LAYOUT(TypeAliasTypeLayout,
NAME_ALIAS_TYPE,
DeclIDField, // typealias decl
TypeIDField, // parent type
TypeIDField, // underlying type
TypeIDField, // substituted type
SubstitutionMapIDField // substitution map
);
TYPE_LAYOUT(GenericTypeParamTypeLayout,
GENERIC_TYPE_PARAM_TYPE,
BCFixed<1>, // parameter pack?
DeclIDField, // generic type parameter decl or depth
BCVBR<4> // index + 1, or zero if we have a generic type
// parameter decl
);
TYPE_LAYOUT(DependentMemberTypeLayout,
DEPENDENT_MEMBER_TYPE,
TypeIDField, // base type
DeclIDField // associated type decl
);
TYPE_LAYOUT(NominalTypeLayout,
NOMINAL_TYPE,
DeclIDField, // decl
TypeIDField // parent
);
TYPE_LAYOUT(ParenTypeLayout,
PAREN_TYPE,
TypeIDField // inner type
);
TYPE_LAYOUT(TupleTypeLayout,
TUPLE_TYPE
);
using TupleTypeEltLayout = BCRecordLayout<
TUPLE_TYPE_ELT,
IdentifierIDField, // name
TypeIDField // type
>;
TYPE_LAYOUT(FunctionTypeLayout,
FUNCTION_TYPE,
TypeIDField, // output
FunctionTypeRepresentationField, // representation
ClangTypeIDField, // type
BCFixed<1>, // noescape?
BCFixed<1>, // concurrent?
BCFixed<1>, // async?
BCFixed<1>, // throws?
TypeIDField, // thrown error
DifferentiabilityKindField, // differentiability kind
FunctionTypeIsolationField, // isolation
BCFixed<1> // has sending result
// trailed by parameters
// Optionally lifetime dependence info
);
using FunctionParamLayout =
BCRecordLayout<FUNCTION_PARAM,
IdentifierIDField, // name
IdentifierIDField, // internal label
TypeIDField, // type
BCFixed<1>, // vararg?
BCFixed<1>, // autoclosure?
BCFixed<1>, // non-ephemeral?
ParamDeclSpecifierField, // inout, shared or owned?
BCFixed<1>, // isolated
BCFixed<1>, // noDerivative?
BCFixed<1>, // compileTimeConst
BCFixed<1>, // _resultDependsOn
BCFixed<1> // sending
>;
TYPE_LAYOUT(MetatypeTypeLayout,
METATYPE_TYPE,
TypeIDField, // instance type
MetatypeRepresentationField // representation
);
TYPE_LAYOUT(ExistentialMetatypeTypeLayout,
EXISTENTIAL_METATYPE_TYPE,
TypeIDField, // instance type
MetatypeRepresentationField // representation
);
TYPE_LAYOUT(PrimaryArchetypeTypeLayout,
PRIMARY_ARCHETYPE_TYPE,
GenericSignatureIDField, // generic environment
TypeIDField // interface type
);
TYPE_LAYOUT(OpenedArchetypeTypeLayout,
OPENED_ARCHETYPE_TYPE,
TypeIDField, // the interface type
GenericEnvironmentIDField // generic environment ID
);
TYPE_LAYOUT(OpaqueArchetypeTypeLayout,
OPAQUE_ARCHETYPE_TYPE,
DeclIDField, // the opaque type decl
TypeIDField, // the interface type
SubstitutionMapIDField // the arguments
);
TYPE_LAYOUT(PackArchetypeTypeLayout,
PACK_ARCHETYPE_TYPE,
GenericSignatureIDField, // generic environment
TypeIDField // interface type
);
TYPE_LAYOUT(ElementArchetypeTypeLayout,
ELEMENT_ARCHETYPE_TYPE,
TypeIDField, // the interface type
GenericEnvironmentIDField // generic environment ID
);
TYPE_LAYOUT(DynamicSelfTypeLayout,
DYNAMIC_SELF_TYPE,
TypeIDField // self type
);
TYPE_LAYOUT(ProtocolCompositionTypeLayout,
PROTOCOL_COMPOSITION_TYPE,
BCFixed<1>, // has AnyObject constraint
BCFixed<1>, // has ~Copyable constraint
BCFixed<1>, // has ~Escapable constraint
BCArray<TypeIDField> // protocols
);
TYPE_LAYOUT(ParameterizedProtocolTypeLayout,
PARAMETERIZED_PROTOCOL_TYPE,
TypeIDField, // base
BCArray<TypeIDField> // arguments
);
TYPE_LAYOUT(BoundGenericTypeLayout,
BOUND_GENERIC_TYPE,
DeclIDField, // generic decl
TypeIDField, // parent
BCArray<TypeIDField> // generic arguments
);
TYPE_LAYOUT(GenericFunctionTypeLayout,
GENERIC_FUNCTION_TYPE,
TypeIDField, // output
FunctionTypeRepresentationField, // representation
BCFixed<1>, // concurrent?
BCFixed<1>, // async?
BCFixed<1>, // throws?
TypeIDField, // thrown error
DifferentiabilityKindField, // differentiability kind
FunctionTypeIsolationField, // isolation
BCFixed<1>, // has sending result
GenericSignatureIDField // generic signature
// trailed by parameters
// Optionally lifetime dependence info
);
TYPE_LAYOUT(SILFunctionTypeLayout,
SIL_FUNCTION_TYPE,
BCFixed<1>, // concurrent?
BCFixed<1>, // async?
SILCoroutineKindField, // coroutine kind
ParameterConventionField, // callee convention
SILFunctionTypeRepresentationField, // representation
BCFixed<1>, // pseudogeneric?
BCFixed<1>, // noescape?
BCFixed<1>, // unimplementable?
BCFixed<1>, // erased isolation?
DifferentiabilityKindField, // differentiability kind
BCFixed<1>, // error result?
BCVBR<6>, // number of parameters
BCVBR<5>, // number of yields
BCVBR<5>, // number of results
GenericSignatureIDField, // invocation generic signature
SubstitutionMapIDField, // invocation substitutions
SubstitutionMapIDField, // pattern substitutions
ClangTypeIDField, // clang function type, for foreign conventions
BCArray<TypeIDField> // parameter types/conventions, alternating
// followed by result types/conventions, alternating
// followed by error result type/convention
// Optionally a protocol conformance (for witness_methods)
// Optionally a substitution map (for substituted function types)
// Optionally lifetime dependence info
);
TYPE_LAYOUT(SILBlockStorageTypeLayout,
SIL_BLOCK_STORAGE_TYPE,
TypeIDField // capture type
);
TYPE_LAYOUT(SILMoveOnlyWrappedTypeLayout,
SIL_MOVE_ONLY_TYPE,
TypeIDField // inner type
);
using SILLayoutLayout = BCRecordLayout<
SIL_LAYOUT,
GenericSignatureIDField, // generic signature
BCFixed<1>, // captures generic env
BCVBR<8>, // number of fields
BCArray<TypeIDWithBitField> // field types with mutability
>;
TYPE_LAYOUT(SILBoxTypeLayout,
SIL_BOX_TYPE,
SILLayoutIDField, // layout
SubstitutionMapIDField // substitutions
);
#define SYNTAX_SUGAR_TYPE_LAYOUT(LAYOUT, CODE) \
TYPE_LAYOUT(LAYOUT, CODE, TypeIDField)
SYNTAX_SUGAR_TYPE_LAYOUT(ArraySliceTypeLayout, ARRAY_SLICE_TYPE);
SYNTAX_SUGAR_TYPE_LAYOUT(OptionalTypeLayout, OPTIONAL_TYPE);
SYNTAX_SUGAR_TYPE_LAYOUT(VariadicSequenceTypeLayout, VARIADIC_SEQUENCE_TYPE);
SYNTAX_SUGAR_TYPE_LAYOUT(ExistentialTypeLayout, EXISTENTIAL_TYPE);
TYPE_LAYOUT(DictionaryTypeLayout,
DICTIONARY_TYPE,
TypeIDField, // key type
TypeIDField // value type
);
TYPE_LAYOUT(ReferenceStorageTypeLayout,
REFERENCE_STORAGE_TYPE,
ReferenceOwnershipField, // ownership
TypeIDField // implementation type
);
TYPE_LAYOUT(UnboundGenericTypeLayout,
UNBOUND_GENERIC_TYPE,
DeclIDField, // generic decl
TypeIDField // parent
);
TYPE_LAYOUT(PackExpansionTypeLayout,
PACK_EXPANSION_TYPE,
TypeIDField, // pattern type
TypeIDField // count type
);
TYPE_LAYOUT(PackElementTypeLayout,
PACK_ELEMENT_TYPE,
TypeIDField, // pack type
BCFixed<32> // level
);
TYPE_LAYOUT(PackTypeLayout,
PACK_TYPE,
BCArray<TypeIDField> // component types
);
TYPE_LAYOUT(SILPackTypeLayout,
SIL_PACK_TYPE,
BCFixed<1>, // is address
BCArray<TypeIDField>// component types
);
using TypeAliasLayout = BCRecordLayout<
TYPE_ALIAS_DECL,
IdentifierIDField, // name
DeclContextIDField,// context decl
TypeIDField, // underlying type
TypeIDField, // interface type (no longer used)
BCFixed<1>, // implicit flag
GenericSignatureIDField, // generic environment
AccessLevelField, // access level
BCArray<TypeIDField> // dependency types
// Trailed by generic parameters (if any).
>;
using GenericTypeParamDeclLayout = BCRecordLayout<GENERIC_TYPE_PARAM_DECL,
IdentifierIDField, // name
BCFixed<1>, // implicit flag
BCFixed<1>, // parameter pack?
BCVBR<4>, // depth
BCVBR<4>, // index
BCFixed<1> // opaque type?
>;
using AssociatedTypeDeclLayout = BCRecordLayout<
ASSOCIATED_TYPE_DECL,
IdentifierIDField, // name
DeclContextIDField, // context decl
TypeIDField, // default definition
BCFixed<1>, // implicit flag
BCArray<DeclIDField> // overridden associated types
>;
using StructLayout = BCRecordLayout<
STRUCT_DECL,
IdentifierIDField, // name
DeclContextIDField, // context decl
BCFixed<1>, // implicit flag
BCFixed<1>, // isObjC
GenericSignatureIDField, // generic environment
AccessLevelField, // access level
BCVBR<4>, // number of conformances
BCVBR<4>, // number of inherited types
BCArray<TypeIDField> // inherited types, followed by dependency types
// Trailed by the generic parameters (if any), the members record, and
// finally conformance info (if any).
>;
using EnumLayout = BCRecordLayout<
ENUM_DECL,
IdentifierIDField, // name
DeclContextIDField, // context decl
BCFixed<1>, // implicit flag
BCFixed<1>, // isObjC
GenericSignatureIDField, // generic environment
TypeIDField, // raw type
AccessLevelField, // access level
BCVBR<4>, // number of conformances
BCVBR<4>, // number of inherited types
BCArray<TypeIDField> // inherited types, followed by dependency types
// Trailed by the generic parameters (if any), the members record, and
// finally conformance info (if any).
>;
using ClassLayout = BCRecordLayout<
CLASS_DECL,
IdentifierIDField, // name
DeclContextIDField, // context decl
BCFixed<1>, // implicit?
BCFixed<1>, // explicitly objc?
BCFixed<1>, // Explicitly actor?
BCFixed<1>, // inherits convenience initializers from its superclass?
BCFixed<1>, // has missing designated initializers?
GenericSignatureIDField, // generic environment
TypeIDField, // superclass
AccessLevelField, // access level
BCVBR<4>, // number of conformances
BCVBR<4>, // number of inherited types
BCArray<TypeIDField> // inherited types, followed by dependency types
// Trailed by the generic parameters (if any), the members record, and
// finally conformance info (if any).
>;
using ProtocolLayout = BCRecordLayout<
PROTOCOL_DECL,
IdentifierIDField, // name
DeclContextIDField, // context decl
BCFixed<1>, // implicit flag
BCFixed<1>, // class-bounded?
BCFixed<1>, // objc?
BCFixed<1>, // existential-type-supported?
DeclIDField, // superclass decl
AccessLevelField, // access level
BCArray<TypeIDField> // dependency types
// Trailed by the inherited protocols, the generic parameters (if any),
// the generic signature, the members record, and the default witness table record
>;
/// A default witness table for a protocol.
using InheritedProtocolsLayout = BCRecordLayout<
INHERITED_PROTOCOLS,
BCArray<DeclIDField>
// An array of inherited protocol declarations
>;
/// A default witness table for a protocol.
using DefaultWitnessTableLayout = BCRecordLayout<
DEFAULT_WITNESS_TABLE,
BCArray<DeclIDField>
// An array of requirement / witness pairs
>;
using ConstructorLayout = BCRecordLayout<
CONSTRUCTOR_DECL,
DeclContextIDField, // context decl
BCFixed<1>, // failable?
BCFixed<1>, // IUO result?
BCFixed<1>, // implicit?
BCFixed<1>, // objc?
BCFixed<1>, // stub implementation?
BCFixed<1>, // async?
BCFixed<1>, // throws?
TypeIDField, // thrown error
CtorInitializerKindField, // initializer kind
GenericSignatureIDField, // generic environment
DeclIDField, // overridden decl
BCFixed<1>, // whether the overridden decl affects ABI
AccessLevelField, // access level
BCFixed<1>, // requires a new vtable/witness table slot
BCFixed<1>, // 'required' but overridden is not (used for recovery)
BCVBR<5>, // number of parameter name components
BCArray<IdentifierIDField> // name components,
// followed by TypeID dependencies
// This record is trailed by:
// - its generic parameters, if any
// - its parameter patterns,
// - the foreign error convention, if any
// - inlinable body text, if any
>;
using VarLayout = BCRecordLayout<
VAR_DECL,
IdentifierIDField, // name
DeclContextIDField, // context decl
BCFixed<1>, // implicit?
BCFixed<1>, // explicitly objc?
BCFixed<1>, // static?
VarDeclIntroducerField, // introducer
BCFixed<1>, // is getter mutating?
BCFixed<1>, // is setter mutating?
BCFixed<1>, // is this the backing storage for a lazy property?
BCFixed<1>, // top level global?
DeclIDField, // if this is a lazy property, this is the backing storage
OpaqueReadOwnershipField, // opaque read ownership
ReadImplKindField, // read implementation
WriteImplKindField, // write implementation
ReadWriteImplKindField, // read-write implementation
AccessorCountField, // number of accessors
TypeIDField, // interface type
BCFixed<1>, // IUO value?
DeclIDField, // overridden decl
AccessLevelField, // access level
AccessLevelField, // setter access, if applicable
DeclIDField, // opaque return type decl
BCFixed<2>, // # of property wrapper backing properties
BCVBR<4>, // total number of vtable/witness table entries introduced by all accessors
BCArray<TypeIDField> // accessors, backing properties, and dependencies
>;
using ParamLayout = BCRecordLayout<
PARAM_DECL,
IdentifierIDField, // argument name
IdentifierIDField, // parameter name
DeclContextIDField, // context decl
ParamDeclSpecifierField, // specifier
TypeIDField, // interface type
BCFixed<1>, // isIUO?
BCFixed<1>, // isVariadic?
BCFixed<1>, // isAutoClosure?
BCFixed<1>, // isIsolated?
BCFixed<1>, // isCompileTimeConst?
BCFixed<1>, // isSending?
DefaultArgumentField, // default argument kind
TypeIDField, // default argument type
ActorIsolationField, // default argument isolation
TypeIDField, // global actor isolation
BCBlob // default argument text
>;
using FuncLayout = BCRecordLayout<
FUNC_DECL,
DeclContextIDField, // context decl
BCFixed<1>, // implicit?
BCFixed<1>, // is 'static' or 'class'?
StaticSpellingKindField, // spelling of 'static' or 'class'
BCFixed<1>, // isObjC?
SelfAccessKindField, // self access kind
BCFixed<1>, // has forced static dispatch?
BCFixed<1>, // async?
BCFixed<1>, // throws?
TypeIDField, // thrown error
GenericSignatureIDField, // generic environment
TypeIDField, // result interface type
BCFixed<1>, // IUO result?
DeclIDField, // operator decl
DeclIDField, // overridden function
BCFixed<1>, // whether the overridden decl affects ABI
BCVBR<5>, // 0 for a simple name, otherwise the number of parameter name
// components plus one
AccessLevelField, // access level
BCFixed<1>, // requires a new vtable/witness table slot
DeclIDField, // opaque result type decl
BCFixed<1>, // isUserAccessible?
BCFixed<1>, // is distributed thunk
BCFixed<1>, // has sending result
BCArray<IdentifierIDField> // name components,
// followed by TypeID dependencies
// The record is trailed by:
// - its _silgen_name, if any
// - its generic parameters, if any
// - body parameter patterns
// - the foreign error convention, if any
// - inlinable body text, if any
>;
using ConditionalSubstitutionConditionLayout = BCRecordLayout<
CONDITIONAL_SUBSTITUTION_COND,
BCFixed<1>, // is unavailable?
BC_AVAIL_TUPLE // the OS version triple.
>;
using ConditionalSubstitutionLayout = BCRecordLayout<
CONDITIONAL_SUBSTITUTION,
SubstitutionMapIDField
// Trailed by N conditions that include a version and
// unavailability indicator.
>;
using OpaqueTypeLayout = BCRecordLayout<
OPAQUE_TYPE_DECL,
DeclContextIDField, // decl context
DeclIDField, // naming decl
GenericSignatureIDField, // interface generic signature
TypeIDField, // interface type for opaque type
GenericSignatureIDField, // generic environment
SubstitutionMapIDField, // optional substitution map for underlying type
AccessLevelField, // access level
BCFixed<1> // export underlying type details
// trailed by generic parameters
// trailed by conditional substitutions
>;
// TODO: remove the unnecessary FuncDecl components here
using AccessorLayout = BCRecordLayout<
ACCESSOR_DECL,
DeclContextIDField, // context decl
BCFixed<1>, // implicit?
BCFixed<1>, // is 'static' or 'class'?
StaticSpellingKindField, // spelling of 'static' or 'class'
BCFixed<1>, // isObjC?
SelfAccessKindField, // self access kind
BCFixed<1>, // has forced static dispatch?
BCFixed<1>, // async?
BCFixed<1>, // throws?
TypeIDField, // thrown error
GenericSignatureIDField, // generic environment
TypeIDField, // result interface type
BCFixed<1>, // IUO result?
DeclIDField, // overridden function
BCFixed<1>, // whether the overridden decl affects ABI
DeclIDField, // AccessorStorageDecl
AccessorKindField, // accessor kind
AccessLevelField, // access level
BCFixed<1>, // requires a new vtable/witness table slot
BCFixed<1>, // is transparent
BCFixed<1>, // is distributed thunk
BCArray<IdentifierIDField> // name components,
// followed by TypeID dependencies
// The record is trailed by:
// - its _silgen_name, if any
// - its generic parameters, if any
// - body parameter patterns
// - the foreign error convention, if any
// - inlinable body text, if any
>;
using PatternBindingLayout = BCRecordLayout<
PATTERN_BINDING_DECL,
DeclContextIDField, // context decl
BCFixed<1>, // implicit flag
BCFixed<1>, // static?
StaticSpellingKindField, // spelling of 'static' or 'class'
BCVBR<3>, // numpatterns
BCArray<DeclContextIDField> // init contexts
// The patterns trail the record.
>;
template <unsigned Code>
using UnaryOperatorLayout = BCRecordLayout<
Code, // ID field
IdentifierIDField, // name
DeclContextIDField // context decl
>;
using PrefixOperatorLayout = UnaryOperatorLayout<PREFIX_OPERATOR_DECL>;
using PostfixOperatorLayout = UnaryOperatorLayout<POSTFIX_OPERATOR_DECL>;
using InfixOperatorLayout = BCRecordLayout<
INFIX_OPERATOR_DECL,
IdentifierIDField, // name
DeclContextIDField,// context decl
DeclIDField // precedence group
>;
using PrecedenceGroupLayout = BCRecordLayout<
PRECEDENCE_GROUP_DECL,
IdentifierIDField, // name
DeclContextIDField,// context decl
AssociativityField,// associativity
BCFixed<1>, // assignment
BCVBR<2>, // numHigherThan
BCArray<DeclIDField> // higherThan, followed by lowerThan
>;
using EnumElementLayout = BCRecordLayout<
ENUM_ELEMENT_DECL,
DeclContextIDField,// context decl
BCFixed<1>, // implicit?
BCFixed<1>, // has payload?
EnumElementRawValueKindField, // raw value kind
BCFixed<1>, // implicit raw value?
BCFixed<1>, // negative raw value?
IdentifierIDField, // raw value
BCVBR<5>, // number of parameter name components
BCArray<IdentifierIDField> // name components,
// The record is trailed by:
// - its argument parameters, if any
>;
using SubscriptLayout = BCRecordLayout<
SUBSCRIPT_DECL,
DeclContextIDField, // context decl
BCFixed<1>, // implicit?
BCFixed<1>, // objc?
BCFixed<1>, // is getter mutating?
BCFixed<1>, // is setter mutating?
OpaqueReadOwnershipField, // opaque read ownership
ReadImplKindField, // read implementation
WriteImplKindField, // write implementation
ReadWriteImplKindField, // read-write implementation
AccessorCountField, // number of accessors
GenericSignatureIDField, // generic environment
TypeIDField, // element interface type
BCFixed<1>, // IUO element?
DeclIDField, // overridden decl
AccessLevelField, // access level
AccessLevelField, // setter access, if applicable
StaticSpellingKindField, // is subscript static?
BCVBR<5>, // number of parameter name components
DeclIDField, // opaque return type decl
BCVBR<4>, // total number of vtable/witness table entries introduced by all accessors
BCArray<IdentifierIDField> // name components,
// followed by DeclID accessors,
// followed by TypeID dependencies
// Trailed by:
// - generic parameters, if any
// - the indices pattern
>;
using ExtensionLayout = BCRecordLayout<
EXTENSION_DECL,
TypeIDField, // extended type
DeclIDField, // extended nominal
DeclContextIDField, // context decl
BCFixed<1>, // implicit flag
GenericSignatureIDField, // generic environment
BCVBR<4>, // # of protocol conformances
BCVBR<4>, // number of inherited types
BCArray<TypeIDField> // inherited types, followed by TypeID dependencies
// Trailed by the generic parameter lists, members record, and then
// conformance info (if any).
>;
using DestructorLayout = BCRecordLayout<
DESTRUCTOR_DECL,
DeclContextIDField, // context decl
BCFixed<1>, // implicit?
BCFixed<1>, // objc?
GenericSignatureIDField // generic environment
// This record is trailed by its inlinable body text
>;
using MacroLayout = BCRecordLayout<
MACRO_DECL,
DeclContextIDField, // context decl
BCFixed<1>, // implicit?
GenericSignatureIDField, // generic environment
BCFixed<1>, // whether there is a parameter list
TypeIDField, // result interface type
AccessLevelField, // access level
BCVBR<5>, // number of parameter name components
BCVBR<3>, // builtin macro definition ID
BCFixed<1>, // whether it has an expanded macro definition
IdentifierIDField, // external module name, for external macros
IdentifierIDField, // external type name, for external macros
BCArray<IdentifierIDField> // name components,
// followed by TypeID dependencies
// The record is trailed by:
// - its generic parameters, if any
// - parameter list, if present
// - expanded macro definition, if needed.
>;
/// The expanded macro definition text.
using ExpandedMacroDefinitionLayout = BCRecordLayout<
EXPANDED_MACRO_DEFINITION,
BCFixed<1>, // whether it has replacements
BCBlob // expansion text
// potentially trailed by the expanded macro replacements
>;
/// The replacements to be performed for an expanded macro definition.
using ExpandedMacroReplacementsLayout = BCRecordLayout<
EXPANDED_MACRO_REPLACEMENTS,
BCArray<BCVBR<6>> // a set of replacement triples (start offset,
// end offset, parameter index)
>;
using InlinableBodyTextLayout = BCRecordLayout<
INLINABLE_BODY_TEXT,
BCBlob // body text
>;
using ParameterListLayout = BCRecordLayout<
PARAMETERLIST,
BCArray<DeclIDField> // params
>;
using ParenPatternLayout = BCRecordLayout<
PAREN_PATTERN
// The sub-pattern trails the record.
>;
using TuplePatternLayout = BCRecordLayout<
TUPLE_PATTERN,
TypeIDField, // type
BCVBR<5> // arity
// The elements trail the record.
>;
using TuplePatternEltLayout = BCRecordLayout<
TUPLE_PATTERN_ELT,
IdentifierIDField // label
// The element pattern trails the record.
>;
using NamedPatternLayout = BCRecordLayout<
NAMED_PATTERN,
DeclIDField, // associated VarDecl
TypeIDField // type
>;
using AnyPatternLayout = BCRecordLayout<
ANY_PATTERN,
TypeIDField, // type
BCFixed<1> // isAsyncLet
// FIXME: is the type necessary?
>;
using TypedPatternLayout = BCRecordLayout<
TYPED_PATTERN,
TypeIDField // associated type
// The sub-pattern trails the record.
>;
using BindingPatternLayout = BCRecordLayout<
VAR_PATTERN,
BCFixed<2> // introducer (var, let, etc.)
// The sub-pattern trails the record.
>;
using GenericParamListLayout = BCRecordLayout<
GENERIC_PARAM_LIST,
BCArray<DeclIDField> // the GenericTypeParamDecls
>;
using GenericSignatureLayout = BCRecordLayout<
GENERIC_SIGNATURE,
BCArray<TypeIDField> // generic parameter types
>;
using GenericEnvironmentLayout = BCRecordLayout<
GENERIC_ENVIRONMENT,
BCFixed<1>, // GenericEnvironmentKind
TypeIDField, // existential type or shape class
GenericSignatureIDField, // parent signature
SubstitutionMapIDField // substitution map
>;
using SubstitutionMapLayout = BCRecordLayout<
SUBSTITUTION_MAP,
GenericSignatureIDField, // generic signature
BCVBR<5>, // # of replacement types
BCArray<TypeIDField> // replacement types and conformances
>;
using SILGenericSignatureLayout = BCRecordLayout<
SIL_GENERIC_SIGNATURE,
BCArray<TypeIDField> // (generic parameter name, sugared interface
// type) pairs
>;
using RequirementSignatureLayout = BCRecordLayout<
REQUIREMENT_SIGNATURE,
BCArray<BCVBR<6>> // requirements and protocol type aliases
>;
using AssociatedTypeLayout = BCRecordLayout<
ASSOCIATED_TYPE,
DeclIDField // associated type decl
>;
using PrimaryAssociatedTypeLayout = BCRecordLayout<
PRIMARY_ASSOCIATED_TYPE,
DeclIDField // associated type decl
>;
/// Specifies the private discriminator string for a private declaration. This
/// identifies the declaration's original source file in some opaque way.
using PrivateDiscriminatorLayout = BCRecordLayout<
PRIVATE_DISCRIMINATOR,
IdentifierIDField // discriminator string, as an identifier
>;
using LocalDiscriminatorLayout = BCRecordLayout<
LOCAL_DISCRIMINATOR,
BCVBR<2> // context-scoped discriminator counter
>;
using FilenameForPrivateLayout = BCRecordLayout<
FILENAME_FOR_PRIVATE,
IdentifierIDField // the file name, as an identifier
>;
using DeserializationSafetyLayout = BCRecordLayout<
DESERIALIZATION_SAFETY,
IdentifierIDField // name to debug access to unsafe decl
>;
using NormalProtocolConformanceLayout = BCRecordLayout<
NORMAL_PROTOCOL_CONFORMANCE,
DeclIDField, // the protocol
DeclContextIDField, // the decl that provided this conformance
BCVBR<5>, // type mapping count
BCVBR<5>, // value mapping count
BCVBR<5>, // requirement signature conformance count
BCFixed<1>, // unchecked
BCFixed<1>, // preconcurrency
BCArray<DeclIDField>
// The array contains requirement signature conformances, then
// type witnesses, then value witnesses.
>;
using SelfProtocolConformanceLayout = BCRecordLayout<
SELF_PROTOCOL_CONFORMANCE,
DeclIDField // the protocol
>;
using SpecializedProtocolConformanceLayout = BCRecordLayout<
SPECIALIZED_PROTOCOL_CONFORMANCE,
ProtocolConformanceIDField, // underlying conformance
TypeIDField, // conforming type
SubstitutionMapIDField // substitution map
>;
using InheritedProtocolConformanceLayout = BCRecordLayout<
INHERITED_PROTOCOL_CONFORMANCE,
ProtocolConformanceIDField, // underlying conformance
TypeIDField // the conforming type
>;
using BuiltinProtocolConformanceLayout = BCRecordLayout<
BUILTIN_PROTOCOL_CONFORMANCE,
TypeIDField, // the conforming type
DeclIDField, // the protocol
BCFixed<2> // the builtin conformance kind
>;
using PackConformanceLayout = BCRecordLayout<
PACK_CONFORMANCE,
TypeIDField, // pattern type
DeclIDField, // the protocol
BCArray<ProtocolConformanceIDField> // pattern conformances
>;
using ProtocolConformanceXrefLayout = BCRecordLayout<
PROTOCOL_CONFORMANCE_XREF,
DeclIDField, // the protocol being conformed to
DeclIDField, // the nominal type of the conformance
ModuleIDField // the module in which the conformance can be found
>;
using MembersLayout = BCRecordLayout<
MEMBERS,
BCArray<DeclIDField>
>;
using XRefLayout = BCRecordLayout<
XREF,
ModuleIDField, // base module ID
BCVBR<4> // xref path length (cannot be 0)
>;
using XRefTypePathPieceLayout = BCRecordLayout<
XREF_TYPE_PATH_PIECE,
IdentifierIDField, // name
IdentifierIDField, // private discriminator
BCFixed<1>, // restrict to protocol extension
BCFixed<1> // imported from Clang?
>;
using XRefOpaqueReturnTypePathPieceLayout = BCRecordLayout<
XREF_OPAQUE_RETURN_TYPE_PATH_PIECE,
IdentifierIDField // mangled name of defining decl
>;
using XRefValuePathPieceLayout = BCRecordLayout<
XREF_VALUE_PATH_PIECE,
TypeIDField, // type
IdentifierIDField, // name
BCFixed<1>, // restrict to protocol extension
BCFixed<1>, // imported from Clang?
BCFixed<1> // static?
>;
using XRefInitializerPathPieceLayout = BCRecordLayout<
XREF_INITIALIZER_PATH_PIECE,
TypeIDField, // type
BCFixed<1>, // restrict to protocol extension
BCFixed<1>, // imported from Clang?
CtorInitializerKindField // initializer kind
>;
using XRefExtensionPathPieceLayout = BCRecordLayout<
XREF_EXTENSION_PATH_PIECE,
ModuleIDField, // module ID
GenericSignatureIDField // for a constrained extension,
// the generic signature
>;
using XRefOperatorOrAccessorPathPieceLayout = BCRecordLayout<
XREF_OPERATOR_OR_ACCESSOR_PATH_PIECE,
IdentifierIDField, // name
AccessorKindField // accessor kind OR operator fixity
>;
static_assert(std::is_same<AccessorKindField, OperatorKindField>::value,
"accessor kinds and operator kinds are not compatible");
using XRefGenericParamPathPieceLayout = BCRecordLayout<
XREF_GENERIC_PARAM_PATH_PIECE,
BCVBR<5>, // depth
BCVBR<5> // index
>;
using SILGenNameDeclAttrLayout = BCRecordLayout<
SILGenName_DECL_ATTR,
BCFixed<1>, // implicit flag
BCBlob // _silgen_name
>;
using SectionDeclAttrLayout = BCRecordLayout<
Section_DECL_ATTR,
BCFixed<1>, // implicit flag
BCBlob // _section
>;
using CDeclDeclAttrLayout = BCRecordLayout<
CDecl_DECL_ATTR,
BCFixed<1>, // implicit flag
BCBlob // _silgen_name
>;
using ImplementsDeclAttrLayout = BCRecordLayout<
Implements_DECL_ATTR,
BCFixed<1>, // implicit flag
DeclContextIDField,// context decl
DeclIDField, // protocol
BCVBR<5>, // 0 for a simple name, otherwise the number of parameter name
// components plus one
BCArray<IdentifierIDField> // name components
>;
using SPIAccessControlDeclAttrLayout = BCRecordLayout<
SPIAccessControl_DECL_ATTR,
BCArray<IdentifierIDField> // SPI names
>;
using AlignmentDeclAttrLayout = BCRecordLayout<
Alignment_DECL_ATTR,
BCFixed<1>, // implicit flag
BCVBR<8> // alignment
>;
using RawLayoutDeclAttrLayout = BCRecordLayout<
RawLayout_DECL_ATTR,
BCFixed<1>, // implicit
TypeIDField, // like type
BCVBR<32>, // size
BCVBR<8>, // alignment
BCFixed<1> // movesAsLike
>;
using SwiftNativeObjCRuntimeBaseDeclAttrLayout = BCRecordLayout<
SwiftNativeObjCRuntimeBase_DECL_ATTR,
BCFixed<1>, // implicit flag
IdentifierIDField // name
>;
using MainTypeDeclAttrLayout = BCRecordLayout<
MainType_DECL_ATTR,
BCFixed<1> // implicit flag
>;
using SemanticsDeclAttrLayout = BCRecordLayout<
Semantics_DECL_ATTR,
BCFixed<1>, // implicit flag
BCBlob // semantics value
>;
using EffectsDeclAttrLayout = BCRecordLayout<
Effects_DECL_ATTR,
BCFixed<3>, // EffectKind
DeclIDField // Custom effect string or 0.
>;
using ForeignErrorConventionLayout = BCRecordLayout<
FOREIGN_ERROR_CONVENTION,
ForeignErrorConventionKindField, // kind
BCFixed<1>, // owned
BCFixed<1>, // replaced
BCVBR<4>, // error parameter index
TypeIDField, // error parameter type
TypeIDField // result type
>;
using ForeignAsyncConventionLayout = BCRecordLayout<
FOREIGN_ASYNC_CONVENTION,
TypeIDField, // completion handler type
BCVBR<4>, // completion handler parameter index
BCVBR<4>, // completion handler error parameter index (+1)
BCVBR<4>, // completion handler error flag parameter index (+1)
BCFixed<1> // completion handler error flag polarity
>;
using LifetimeDependenceLayout =
BCRecordLayout<LIFETIME_DEPENDENCE,
BCFixed<1>, // hasInheritLifetimeParamIndices
BCFixed<1>, // hasScopeLifetimeParamIndices
BCArray<BCFixed<1>> // concatenated param indices
>;
using AbstractClosureExprLayout = BCRecordLayout<
ABSTRACT_CLOSURE_EXPR_CONTEXT,
TypeIDField, // type
BCFixed<1>, // implicit
BCVBR<4>, // discriminator
DeclContextIDField // parent context decl
>;
using TopLevelCodeDeclContextLayout = BCRecordLayout<
TOP_LEVEL_CODE_DECL_CONTEXT,
DeclContextIDField // parent context decl
>;
using PatternBindingInitializerLayout = BCRecordLayout<
PATTERN_BINDING_INITIALIZER_CONTEXT,
DeclIDField, // parent pattern binding decl
BCVBR<3>, // binding index in the pattern binding decl
BCBlob // initializer text, if present
>;
using DefaultArgumentInitializerLayout = BCRecordLayout<
DEFAULT_ARGUMENT_INITIALIZER_CONTEXT,
DeclContextIDField, // parent context decl
BCVBR<3> // parameter index
>;
// Stub layouts, unused.
using ReferenceOwnershipDeclAttrLayout
= BCRecordLayout<ReferenceOwnership_DECL_ATTR>;
using RawDocCommentDeclAttrLayout = BCRecordLayout<RawDocComment_DECL_ATTR>;
using AccessControlDeclAttrLayout = BCRecordLayout<AccessControl_DECL_ATTR>;
using SetterAccessDeclAttrLayout = BCRecordLayout<SetterAccess_DECL_ATTR>;
using ObjCBridgedDeclAttrLayout = BCRecordLayout<ObjCBridged_DECL_ATTR>;
using SynthesizedProtocolDeclAttrLayout
= BCRecordLayout<SynthesizedProtocol_DECL_ATTR>;
using ObjCRuntimeNameDeclAttrLayout
= BCRecordLayout<ObjCRuntimeName_DECL_ATTR>;
using RestatedObjCConformanceDeclAttrLayout
= BCRecordLayout<RestatedObjCConformance_DECL_ATTR>;
using ClangImporterSynthesizedTypeDeclAttrLayout
= BCRecordLayout<ClangImporterSynthesizedType_DECL_ATTR>;
using PrivateImportDeclAttrLayout = BCRecordLayout<PrivateImport_DECL_ATTR>;
using AllowFeatureSuppressionDeclAttrLayout =
BCRecordLayout<AllowFeatureSuppression_DECL_ATTR>;
using ProjectedValuePropertyDeclAttrLayout = BCRecordLayout<
ProjectedValueProperty_DECL_ATTR,
BCFixed<1>, // isImplicit
IdentifierIDField // name
>;
using InlineDeclAttrLayout = BCRecordLayout<
Inline_DECL_ATTR,
BCFixed<2> // inline value
>;
using NonSendableDeclAttrLayout = BCRecordLayout<
NonSendable_DECL_ATTR,
BCFixed<1> // non-sendable kind
>;
using OptimizeDeclAttrLayout = BCRecordLayout<
Optimize_DECL_ATTR,
BCFixed<2> // optimize value
>;
using ExclusivityDeclAttrLayout = BCRecordLayout<
Optimize_DECL_ATTR,
BCFixed<2> // exclusivity mode
>;
using AvailableDeclAttrLayout = BCRecordLayout<
Available_DECL_ATTR,
BCFixed<1>, // implicit flag
BCFixed<1>, // is unconditionally unavailable?
BCFixed<1>, // is unconditionally deprecated?
BCFixed<1>, // is unavailable from async?
BCFixed<1>, // is this PackageDescription version-specific kind?
BCFixed<1>, // is SPI?
BC_AVAIL_TUPLE, // Introduced
BC_AVAIL_TUPLE, // Deprecated
BC_AVAIL_TUPLE, // Obsoleted
BCVBR<5>, // platform
DeclIDField, // rename declaration (if any)
BCVBR<5>, // number of bytes in message string
BCVBR<5>, // number of bytes in rename string
BCBlob // message, followed by rename
>;
using OriginallyDefinedInDeclAttrLayout = BCRecordLayout<
OriginallyDefinedIn_DECL_ATTR,
BCFixed<1>, // implicit flag
BC_AVAIL_TUPLE, // moved OS version
BCVBR<5>, // platform
BCBlob // original module name
>;
using ObjCDeclAttrLayout = BCRecordLayout<
ObjC_DECL_ATTR,
BCFixed<1>, // implicit flag
BCFixed<1>, // implicit name flag
BCVBR<4>, // # of arguments (+1) or zero if no name
BCArray<IdentifierIDField>
>;
using ObjCImplementationDeclAttrLayout = BCRecordLayout<
ObjCImplementation_DECL_ATTR,
BCFixed<1>, // implicit flag
BCFixed<1>, // category name invalid
BCFixed<1>, // is early adopter
IdentifierIDField // category name
>;
using SpecializeDeclAttrLayout = BCRecordLayout<
Specialize_DECL_ATTR,
BCFixed<1>, // exported flag
BCFixed<1>, // specialization kind
GenericSignatureIDField, // specialized signature
DeclIDField, // target function
BCVBR<4>, // # of arguments (+1) or 1 if simple decl name, 0 if no target
BCVBR<4>, // # of SPI groups
BCVBR<4>, // # of availability attributes
BCVBR<4>, // # of type erased parameters
BCArray<IdentifierIDField> // target function pieces, spi groups, type erased params
>;
using StorageRestrictionsDeclAttrLayout = BCRecordLayout<
StorageRestrictions_DECL_ATTR,
BCVBR<16>, // num "initializes" properties
BCArray<IdentifierIDField> // properties
>;
using DifferentiableDeclAttrLayout = BCRecordLayout<
Differentiable_DECL_ATTR,
BCFixed<1>, // Implicit flag.
DifferentiabilityKindField, // Differentiability kind.
GenericSignatureIDField, // Derivative generic signature.
BCArray<BCFixed<1>> // Differentiation parameter indices' bitvector.
>;
using DerivativeDeclAttrLayout = BCRecordLayout<
Derivative_DECL_ATTR,
BCFixed<1>, // Implicit flag.
IdentifierIDField, // Original name.
BCFixed<1>, // Has original accessor kind?
AccessorKindField, // Original accessor kind.
DeclIDField, // Original function declaration.
AutoDiffDerivativeFunctionKindField, // Derivative function kind.
BCArray<BCFixed<1>> // Differentiation parameter indices' bitvector.
>;
using TransposeDeclAttrLayout = BCRecordLayout<
Transpose_DECL_ATTR,
BCFixed<1>, // Implicit flag.
IdentifierIDField, // Original name.
DeclIDField, // Original function declaration.
BCArray<BCFixed<1>> // Transposed parameter indices' bitvector.
>;
#define SIMPLE_DECL_ATTR(X, CLASS, ...) \
using CLASS##DeclAttrLayout = BCRecordLayout< \
CLASS##_DECL_ATTR, \
BCFixed<1> /* implicit flag */ \
>;
#include "swift/AST/DeclAttr.def"
using DynamicReplacementDeclAttrLayout = BCRecordLayout<
DynamicReplacement_DECL_ATTR,
BCFixed<1>, // implicit flag
DeclIDField, // replaced function
BCVBR<4>, // # of arguments (+1) or zero if no name
BCArray<IdentifierIDField>
>;
using TypeEraserDeclAttrLayout = BCRecordLayout<
TypeEraser_DECL_ATTR,
BCFixed<1>, // implicit flag
TypeIDField // type eraser type
>;
using CustomDeclAttrLayout = BCRecordLayout<
Custom_DECL_ATTR,
BCFixed<1>, // implicit flag
TypeIDField, // type referenced by this custom attribute
BCFixed<1> // is the argument (unsafe)
>;
using UnavailableFromAsyncDeclAttrLayout = BCRecordLayout<
UnavailableFromAsync_DECL_ATTR,
BCFixed<1>, // Implicit flag
BCBlob // Message
>;
using BackDeployedDeclAttrLayout = BCRecordLayout<
BackDeployed_DECL_ATTR,
BCFixed<1>, // implicit flag
BC_AVAIL_TUPLE, // OS version
BCVBR<5> // platform
>;
using ExposeDeclAttrLayout = BCRecordLayout<Expose_DECL_ATTR,
BCFixed<1>, // exposure kind
BCFixed<1>, // implicit flag
BCBlob // declaration name
>;
using ExternDeclAttrLayout = BCRecordLayout<Extern_DECL_ATTR,
BCFixed<1>, // implicit flag
BCFixed<1>, // extern kind
BCVBR<4>, // number of bytes in module name
BCVBR<4>, // number of bytes in name
BCBlob // module name and declaration name
>;
using DocumentationDeclAttrLayout = BCRecordLayout<
Documentation_DECL_ATTR,
BCFixed<1>, // implicit flag
IdentifierIDField, // metadata text
BCFixed<1>, // has visibility
AccessLevelField // visibility
>;
using NonisolatedDeclAttrLayout =
BCRecordLayout<Nonisolated_DECL_ATTR,
BCFixed<1>, // is the argument (unsafe)
BCFixed<1> // implicit flag
>;
using MacroRoleDeclAttrLayout = BCRecordLayout<
MacroRole_DECL_ATTR,
BCFixed<1>, // implicit flag
BCFixed<1>, // macro syntax
MacroRoleField, // macro role
BCVBR<5>, // number of names
BCVBR<5>, // number of conformances
BCArray<IdentifierIDField> // introduced names, where each is encoded as
// - introduced kind
// - base name
// - # of argument labels + 1 (or 0 if none)
// - argument labels
// trialed by introduced conformances
>;
#undef SYNTAX_SUGAR_TYPE_LAYOUT
#undef TYPE_LAYOUT
#undef TYPE_LAYOUT_IMPL
}
/// Returns the encoding kind for the given decl.
///
/// Note that this does not work for all encodable decls, only those designed
/// to be stored in a hash table.
static inline decls_block::RecordKind getKindForTable(const Decl *D) {
using namespace decls_block;
switch (D->getKind()) {
case DeclKind::TypeAlias:
return decls_block::TYPE_ALIAS_DECL;
case DeclKind::Enum:
return decls_block::ENUM_DECL;
case DeclKind::Struct:
return decls_block::STRUCT_DECL;
case DeclKind::Class:
return decls_block::CLASS_DECL;
case DeclKind::Protocol:
return decls_block::PROTOCOL_DECL;
case DeclKind::Func:
return decls_block::FUNC_DECL;
case DeclKind::Var:
return decls_block::VAR_DECL;
case DeclKind::Param:
return decls_block::PARAM_DECL;
case DeclKind::Subscript:
return decls_block::SUBSCRIPT_DECL;
case DeclKind::Constructor:
return decls_block::CONSTRUCTOR_DECL;
case DeclKind::Destructor:
return decls_block::DESTRUCTOR_DECL;
case DeclKind::Macro:
return decls_block::MACRO_DECL;
default:
llvm_unreachable("cannot store this kind of decl in a hash table");
}
}
/// The record types within the identifier block.
///
/// \sa IDENTIFIER_BLOCK_ID
namespace identifier_block {
enum {
IDENTIFIER_DATA = 1
};
using IdentifierDataLayout = BCRecordLayout<IDENTIFIER_DATA, BCBlob>;
}
/// The record types within the index block.
///
/// \sa INDEX_BLOCK_ID
namespace index_block {
enum RecordKind {
TYPE_OFFSETS = 1,
DECL_OFFSETS,
IDENTIFIER_OFFSETS,
TOP_LEVEL_DECLS,
OPERATORS,
EXTENSIONS,
CLASS_MEMBERS_FOR_DYNAMIC_LOOKUP,
OPERATOR_METHODS,
/// The Objective-C method index, which contains a mapping from
/// Objective-C selectors to the methods/initializers/properties/etc. that
/// produce Objective-C methods.
OBJC_METHODS,
/// The derivative function configuration table, which maps original
/// function declaration names to derivative function configurations.
DERIVATIVE_FUNCTION_CONFIGURATIONS,
ENTRY_POINT,
LOCAL_DECL_CONTEXT_OFFSETS,
LOCAL_TYPE_DECLS,
OPAQUE_RETURN_TYPE_DECLS,
GENERIC_SIGNATURE_OFFSETS,
GENERIC_ENVIRONMENT_OFFSETS,
PROTOCOL_CONFORMANCE_OFFSETS,
PACK_CONFORMANCE_OFFSETS,
SIL_LAYOUT_OFFSETS,
PRECEDENCE_GROUPS,
NESTED_TYPE_DECLS,
DECL_MEMBER_NAMES,
DECL_FINGERPRINTS,
ORDERED_TOP_LEVEL_DECLS,
SUBSTITUTION_MAP_OFFSETS,
CLANG_TYPE_OFFSETS,
EXPORTED_PRESPECIALIZATION_DECLS,
LastRecordKind = EXPORTED_PRESPECIALIZATION_DECLS,
};
constexpr const unsigned RecordIDFieldWidth = 5;
static_assert(LastRecordKind < (1 << RecordIDFieldWidth),
"not enough bits for all record kinds");
using RecordIDField = BCFixed<RecordIDFieldWidth>;
using OffsetsLayout = BCGenericRecordLayout<
RecordIDField, // record ID
BCArray<BitOffsetField>
>;
using DeclListLayout = BCGenericRecordLayout<
RecordIDField, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // map from identifier strings to decl kinds / decl IDs
>;
using GroupNamesLayout = BCGenericRecordLayout<
RecordIDField, // record ID
BCBlob // actual names
>;
using ExtensionTableLayout = BCRecordLayout<
EXTENSIONS, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // map from identifier strings to decl kinds / decl IDs
>;
using ObjCMethodTableLayout = BCRecordLayout<
OBJC_METHODS, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // map from Objective-C selectors to methods with that selector
>;
using NestedTypeDeclsLayout = BCRecordLayout<
NESTED_TYPE_DECLS, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // map from identifier strings to decl kinds / decl IDs
>;
using DeclMemberNamesLayout = BCRecordLayout<
DECL_MEMBER_NAMES, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // map from member DeclBaseNames to offsets of DECL_MEMBERS records
>;
using DerivativeFunctionConfigTableLayout = BCRecordLayout<
DERIVATIVE_FUNCTION_CONFIGURATIONS, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // map from original declaration names to derivative configs
>;
using EntryPointLayout = BCRecordLayout<
ENTRY_POINT,
DeclIDField // the ID of the main class; 0 if there was a main source file
>;
using OrderedDeclsLayout = BCGenericRecordLayout<
RecordIDField, // record ID
BCArray<DeclIDField> // list of decls by ID
>;
using DeclFingerprintsLayout = BCRecordLayout<
DECL_FINGERPRINTS, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // map from member DeclIDs to strings
>;
}
/// \sa DECL_MEMBER_TABLES_BLOCK_ID
namespace decl_member_tables_block {
enum RecordKind {
DECL_MEMBERS = 1,
};
using DeclMembersLayout = BCRecordLayout<
DECL_MEMBERS, // record ID
BCVBR<16>, // table offset within the blob (see below)
BCBlob // maps from DeclIDs to DeclID vectors
>;
}
} // end namespace serialization
} // end namespace swift
#endif
|