summaryrefslogtreecommitdiff
path: root/tests/preprocessor/special-macro-complex.slang.expected
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-08-28 22:29:33 -0700
committerGitHub <noreply@github.com>2024-08-28 22:29:33 -0700
commitb85792f0f0525fe29e1ab38877a2abf412b4415c (patch)
tree0b1715719eb7a70735c9778fb17fc4f9668eec35 /tests/preprocessor/special-macro-complex.slang.expected
parent7893b4534a1034a001fd7670f3a2ad6d1db66bad (diff)
Add structured binding propsoal. (#4953)
Diffstat (limited to 'tests/preprocessor/special-macro-complex.slang.expected')
0 files changed, 0 insertions, 0 deletions
4' href='#n114'>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
#ifndef SLANG_COMPILER_H_INCLUDED
#define SLANG_COMPILER_H_INCLUDED

#include "../core/slang-basic.h"
#include "../core/slang-shared-library.h"
#include "../core/slang-crypto.h"

#include "../compiler-core/slang-downstream-compiler.h"
#include "../compiler-core/slang-downstream-compiler-util.h"

#include "../compiler-core/slang-name.h"
#include "../compiler-core/slang-include-system.h"
#include "../compiler-core/slang-command-line-args.h"

#include "../compiler-core/slang-source-embed-util.h"

#include "../compiler-core/slang-spirv-core-grammar.h"

#include "../core/slang-std-writers.h"
#include "../core/slang-command-options.h"

#include "../core/slang-file-system.h"

#include "../../slang-com-ptr.h"

#include "slang-capability.h"
#include "slang-diagnostics.h"
#include "slang-preprocessor.h"
#include "slang-profile.h"
#include "slang-syntax.h"
#include "slang-content-assist-info.h"
#include "slang-hlsl-to-vulkan-layout-options.h"
#include "slang-compiler-options.h"
#include "slang-serialize-ir-types.h"

#include "../compiler-core/slang-artifact-representation-impl.h"

#include "../../slang.h"

namespace Slang
{
    struct PathInfo;
    struct IncludeHandler;
    class ProgramLayout;
    class PtrType;
    class TargetProgram;
    class TargetRequest;
    class TypeLayout;
    class Artifact;

    enum class CompilerMode
    {
        ProduceLibrary,
        ProduceShader,
        GenerateChoice
    };

    enum class StageTarget 
    {
        Unknown,
        VertexShader,
        HullShader,
        DomainShader,
        GeometryShader,
        FragmentShader,
        ComputeShader,
    };

    enum class CodeGenTarget : SlangCompileTargetIntegral
    {
        Unknown             = SLANG_TARGET_UNKNOWN,
        None                = SLANG_TARGET_NONE,
        GLSL                = SLANG_GLSL,
        GLSL_Vulkan         = SLANG_GLSL_VULKAN,
        GLSL_Vulkan_OneDesc = SLANG_GLSL_VULKAN_ONE_DESC,
        HLSL                = SLANG_HLSL,
        SPIRV               = SLANG_SPIRV,
        SPIRVAssembly       = SLANG_SPIRV_ASM,
        DXBytecode          = SLANG_DXBC,
        DXBytecodeAssembly  = SLANG_DXBC_ASM,
        DXIL                = SLANG_DXIL,
        DXILAssembly        = SLANG_DXIL_ASM,
        CSource             = SLANG_C_SOURCE,
        CPPSource           = SLANG_CPP_SOURCE,
        PyTorchCppBinding   = SLANG_CPP_PYTORCH_BINDING,
        HostCPPSource       = SLANG_HOST_CPP_SOURCE,
        HostExecutable      = SLANG_HOST_EXECUTABLE,
        ShaderSharedLibrary = SLANG_SHADER_SHARED_LIBRARY,
        ShaderHostCallable  = SLANG_SHADER_HOST_CALLABLE,
        CUDASource          = SLANG_CUDA_SOURCE,
        PTX                 = SLANG_PTX,
        CUDAObjectCode      = SLANG_CUDA_OBJECT_CODE,
        ObjectCode          = SLANG_OBJECT_CODE,
        HostHostCallable    = SLANG_HOST_HOST_CALLABLE,
        Metal               = SLANG_METAL,
        CountOf             = SLANG_TARGET_COUNT_OF,
    };

    bool isHeterogeneousTarget(CodeGenTarget target);

    void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val);

    enum class ContainerFormat : SlangContainerFormatIntegral
    {
        None            = SLANG_CONTAINER_FORMAT_NONE,
        SlangModule     = SLANG_CONTAINER_FORMAT_SLANG_MODULE,
    };

    enum class LineDirectiveMode : SlangLineDirectiveModeIntegral
    {
        Default     = SLANG_LINE_DIRECTIVE_MODE_DEFAULT,
        None        = SLANG_LINE_DIRECTIVE_MODE_NONE,
        Standard    = SLANG_LINE_DIRECTIVE_MODE_STANDARD,
        GLSL        = SLANG_LINE_DIRECTIVE_MODE_GLSL,
        SourceMap   = SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP,
    };

    enum class ResultFormat
    {
        None,
        Text,
        Binary,
    };

    // When storing the layout for a matrix-type
    // value, we need to know whether it has been
    // laid out with row-major or column-major
    // storage.
    //
    enum MatrixLayoutMode : SlangMatrixLayoutModeIntegral
    {
        kMatrixLayoutMode_RowMajor      = SLANG_MATRIX_LAYOUT_ROW_MAJOR,
        kMatrixLayoutMode_ColumnMajor   = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR,
    };

    enum class DebugInfoLevel : SlangDebugInfoLevelIntegral
    {
        None        = SLANG_DEBUG_INFO_LEVEL_NONE,
        Minimal     = SLANG_DEBUG_INFO_LEVEL_MINIMAL,
        Standard    = SLANG_DEBUG_INFO_LEVEL_STANDARD,
        Maximal     = SLANG_DEBUG_INFO_LEVEL_MAXIMAL,
    };

    enum class DebugInfoFormat : SlangDebugInfoFormatIntegral
    {
        Default     = SLANG_DEBUG_INFO_FORMAT_DEFAULT,
        C7          = SLANG_DEBUG_INFO_FORMAT_C7,
        Pdb         = SLANG_DEBUG_INFO_FORMAT_PDB,

        Stabs       = SLANG_DEBUG_INFO_FORMAT_STABS,
        Coff        = SLANG_DEBUG_INFO_FORMAT_COFF,
        Dwarf       = SLANG_DEBUG_INFO_FORMAT_DWARF,

        CountOf     = SLANG_DEBUG_INFO_FORMAT_COUNT_OF,
    };

    enum class OptimizationLevel : SlangOptimizationLevelIntegral
    {
        None    = SLANG_OPTIMIZATION_LEVEL_NONE,
        Default = SLANG_OPTIMIZATION_LEVEL_DEFAULT,
        High    = SLANG_OPTIMIZATION_LEVEL_HIGH,
        Maximal = SLANG_OPTIMIZATION_LEVEL_MAXIMAL,
    };

    struct CodeGenContext;
    class EndToEndCompileRequest;
    class FrontEndCompileRequest;
    class Linkage;
    class Module;
    class TranslationUnitRequest;

        /// Information collected about global or entry-point shader parameters
    struct ShaderParamInfo
    {
        DeclRef<VarDeclBase>    paramDeclRef;
        Int                     firstSpecializationParamIndex = 0;
        Int                     specializationParamCount = 0;
    };

        /// A request for the front-end to find and validate an entry-point function
    struct FrontEndEntryPointRequest : RefObject
    {
    public:
            /// Create a request for an entry point.
        FrontEndEntryPointRequest(
            FrontEndCompileRequest* compileRequest,
            int                     translationUnitIndex,
            Name*                   name,
            Profile                 profile);

            /// Get the parent front-end compile request.
        FrontEndCompileRequest* getCompileRequest() { return m_compileRequest; }

            /// Get the translation unit that contains the entry point.
        TranslationUnitRequest* getTranslationUnit();

            /// Get the name of the entry point to find.
        Name* getName() { return m_name; }

            /// Get the stage that the entry point is to be compiled for
        Stage getStage() { return m_profile.getStage(); }

            /// Get the profile that the entry point is to be compiled for
        Profile getProfile() { return m_profile; }

            /// Get the index to the translation unit
        int getTranslationUnitIndex() const { return m_translationUnitIndex; }

    private:
        // The parent compile request
        FrontEndCompileRequest* m_compileRequest;

        // The index of the translation unit that will hold the entry point
        int                     m_translationUnitIndex;

        // The name of the entry point function to look for
        Name*                   m_name;

        // The profile to compile for (including stage)
        Profile                 m_profile;
    };

        /// Tracks an ordered list of modules that something depends on.
        /// TODO: Shader caching currently relies on this being in well defined order.
    struct ModuleDependencyList
    {
    public:
            /// Get the list of modules that are depended on.
        List<Module*> const& getModuleList() { return m_moduleList; }

            /// Add a module and everything it depends on to the list.
        void addDependency(Module* module);

            /// Add a module to the list, but not the modules it depends on.
        void addLeafDependency(Module* module);

    private:
        void _addDependency(Module* module);

        List<Module*>       m_moduleList;
        HashSet<Module*>    m_moduleSet;
    };

        /// Tracks an unordered list of source files that something depends on
        /// TODO: Shader caching currently relies on this being in well defined order.
    struct FileDependencyList
    {
    public:
            /// Get the list of files that are depended on.
        List<SourceFile*> const& getFileList() { return m_fileList; }

            /// Add a file to the list, if it is not already present
        void addDependency(SourceFile* sourceFile);

            /// Add all of the paths that `module` depends on to the list
        void addDependency(Module* module);

        void clear()
        {
            m_fileList.clear();
            m_fileSet.clear();
        }

    private:

        // TODO: We are using a `HashSet` here to deduplicate
        // the paths so that we don't return the same path
        // multiple times from `getFilePathList`, but because
        // order isn't important, we could potentially do better
        // in terms of memory (at some cost in performance) by
        // just sorting the `m_fileList` every once in
        // a while and then deduplicating.

        List<SourceFile*>    m_fileList;
        HashSet<SourceFile*> m_fileSet;
    };

    class EntryPoint;

    class ComponentType;
    class ComponentTypeVisitor;

        /// Base class for "component types" that represent the pieces a final
        /// shader program gets linked together from.
        ///
    class ComponentType : public RefObject, public slang::IComponentType
    {
    public:
        //
        // ISlangUnknown interface
        //

        SLANG_REF_OBJECT_IUNKNOWN_ALL;
        ISlangUnknown* getInterface(Guid const& guid);

        //
        // slang::IComponentType interface
        //

        SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() SLANG_OVERRIDE;
        SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout(
            SlangInt        targetIndex,
            slang::IBlob**  outDiagnostics) SLANG_OVERRIDE;
        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
            SlangInt        entryPointIndex,
            SlangInt        targetIndex,
            slang::IBlob**  outCode,
            slang::IBlob**  outDiagnostics) SLANG_OVERRIDE;

        SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
            SlangInt    entryPointIndex,
            SlangInt    targetIndex,
            ISlangMutableFileSystem** outFileSystem) SLANG_OVERRIDE;

        SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
            slang::SpecializationArg const* specializationArgs,
            SlangInt                        specializationArgCount,
            slang::IComponentType**         outSpecializedComponentType,
            ISlangBlob**                    outDiagnostics) SLANG_OVERRIDE;
        SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
            const char* newName,
            slang::IComponentType** outEntryPoint) SLANG_OVERRIDE;
        SLANG_NO_THROW SlangResult SLANG_MCALL link(
            slang::IComponentType** outLinkedComponentType,
            ISlangBlob**            outDiagnostics) SLANG_OVERRIDE;
        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
            int                     entryPointIndex,
            int                     targetIndex,
            ISlangSharedLibrary**   outSharedLibrary,
            slang::IBlob**          outDiagnostics) SLANG_OVERRIDE;

            /// ComponentType is the only class inheriting from IComponentType that provides a
            /// meaningful implementation for this function. All others should forward these and
            /// implement `buildHash`.
        SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
            SlangInt entryPointIndex,
            SlangInt targetIndex,
            slang::IBlob** outHash) SLANG_OVERRIDE;

        SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
            slang::IComponentType** outLinkedComponentType,
            uint32_t count,
            slang::CompilerOptionEntry* entries,
            ISlangBlob** outDiagnostics) override;

        CompilerOptionSet& getOptionSet() { return m_optionSet; }

            /// Get the linkage (aka "session" in the public API) for this component type.
        Linkage* getLinkage() { return m_linkage; }

            /// Get the target-specific version of this program for the given `target`.
            ///
            /// The `target` must be a target on the `Linkage` that was used to create this program.
        TargetProgram* getTargetProgram(TargetRequest* target);

            /// Update the hash builder with the dependencies for this component type. 
        virtual void buildHash(DigestBuilder<SHA1>& builder) = 0;

            /// Get the number of entry points linked into this component type.
        virtual Index getEntryPointCount() = 0;

            /// Get one of the entry points linked into this component type.
        virtual RefPtr<EntryPoint> getEntryPoint(Index index) = 0;

            /// Get the mangled name of one of the entry points linked into this component type.
        virtual String getEntryPointMangledName(Index index) = 0;

            /// Get the name override of one of the entry points linked into this component type.
        virtual String getEntryPointNameOverride(Index index) = 0;

            /// Get the number of global shader parameters linked into this component type.
        virtual Index getShaderParamCount() = 0;

            /// Get one of the global shader parametesr linked into this component type.
        virtual ShaderParamInfo getShaderParam(Index index) = 0;

            /// Get the specialization parameter at `index`.
        virtual SpecializationParam const& getSpecializationParam(Index index) = 0;

            /// Get the number of "requirements" that this component type has.
            ///
            /// A requirement represents another component type that this component
            /// needs in order to function correctly. For example, the dependency
            /// of one module on another module that it `import`s is represented
            /// as a requirement, as is the dependency of an entry point on the
            /// module that defines it.
            ///
        virtual Index getRequirementCount() = 0;

            /// Get the requirement at `index`.
        virtual RefPtr<ComponentType> getRequirement(Index index) = 0;

            /// Parse a type from a string, in the context of this component type.
            ///
            /// Any names in the string will be resolved using the modules
            /// referenced by the program.
            ///
            /// On an error, returns null and reports diagnostic messages
            /// to the provided `sink`.
            ///
            /// TODO: This function shouldn't be on the base class, since
            /// it only really makes sense on `Module`.
            ///
        Type* getTypeFromString(
            String const&   typeStr,
            DiagnosticSink* sink);

        Dictionary<String, IntVal*>& getMangledNameToIntValMap();
        ConstantIntVal* tryFoldIntVal(IntVal* intVal);

            /// Get a list of modules that this component type depends on.
            ///
        virtual List<Module*> const& getModuleDependencies() = 0;

            /// Get the full list of source files this component type depends on.
            ///
        virtual List<SourceFile*> const& getFileDependencies() = 0;

            /// Callback for use with `enumerateIRModules`
        typedef void (*EnumerateIRModulesCallback)(IRModule* irModule, void* userData);

            /// Invoke `callback` on all the IR modules that are (transitively) linked into this component type.
        void enumerateIRModules(EnumerateIRModulesCallback callback, void* userData);

            /// Invoke `callback` on all the IR modules that are (transitively) linked into this component type.
        template<typename F>
        void enumerateIRModules(F const& callback)
        {
            struct Helper
            {
                static void helper(IRModule* irModule, void* userData)
                {
                    (*(F*)userData)(irModule);
                }
            };
            enumerateIRModules(&Helper::helper, (void*)&callback);
        }

            /// Callback for use with `enumerateModules`
        typedef void (*EnumerateModulesCallback)(Module* module, void* userData);

            /// Invoke `callback` on all the modules that are (transitively) linked into this component type.
        void enumerateModules(EnumerateModulesCallback callback, void* userData);

            /// Invoke `callback` on all the modules that are (transitively) linked into this component type.
        template<typename F>
        void enumerateModules(F const& callback)
        {
            struct Helper
            {
                static void helper(Module* module, void* userData)
                {
                    (*(F*)userData)(module);
                }
            };
            enumerateModules(&Helper::helper, (void*)&callback);
        }

            /// Side-band information generated when specializing this component type.
            ///
            /// Difference subclasses of `ComponentType` are expected to create their
            /// own subclass of `SpecializationInfo` as the output of `_validateSpecializationArgs`.
            /// Later, whenever we want to use a specialized component type we will
            /// also have the `SpecializationInfo` available and will expect it to
            /// have the correct (subclass-specific) type.
            ///
        class SpecializationInfo : public RefObject
        {
        };

            /// Validate the given specialization `args` and compute any side-band specialization info.
            ///
            /// Any errors will be reported to `sink`, which can thus be used to test
            /// if the operation was successful.
            ///
            /// A null return value is allowed, since not all subclasses require
            /// custom side-band specialization information.
            ///
            /// This function is an implementation detail of `specialize()`.
            ///
        virtual RefPtr<SpecializationInfo> _validateSpecializationArgsImpl(
            SpecializationArg const*    args,
            Index                       argCount,
            DiagnosticSink*             sink) = 0;

            /// Validate the given specialization `args` and compute any side-band specialization info.
            ///
            /// Any errors will be reported to `sink`, which can thus be used to test
            /// if the operation was successful.
            ///
            /// A null return value is allowed, since not all subclasses require
            /// custom side-band specialization information.
            ///
            /// This function is an implementation detail of `specialize()`.
            ///
        RefPtr<SpecializationInfo> _validateSpecializationArgs(
            SpecializationArg const*    args,
            Index                       argCount,
            DiagnosticSink*             sink)
        {
            if(argCount == 0) return nullptr;
            return _validateSpecializationArgsImpl(args, argCount, sink);
        }

            /// Specialize this component type given `specializationArgs`
            ///
            /// Any diagnostics will be reported to `sink`, which can be used
            /// to determine if the operation was successful. It is allowed
            /// for this operation to have a non-null return even when an
            /// error is ecnountered.
            ///
        RefPtr<ComponentType> specialize(
            SpecializationArg const*    specializationArgs,
            SlangInt                    specializationArgCount,
            DiagnosticSink*             sink);

            /// Invoke `visitor` on this component type, using the appropriate dynamic type.
            ///
            /// This function implements the "visitor pattern" for `ComponentType`.
            ///
            /// If the `specializationInfo` argument is non-null, it must be specialization
            /// information generated for this specific component type by `_validateSpecializationArgs`.
            /// In that case, appropriately-typed specialization information will be passed
            /// when invoking the `visitor`.
            ///
        virtual void acceptVisitor(ComponentTypeVisitor* visitor, SpecializationInfo* specializationInfo) = 0;

            /// Create a scope suitable for looking up names or parsing specialization arguments.
            ///
            /// This facility is only needed to support legacy APIs for string-based lookup
            /// and parsing via Slang reflection, and is not recommended for future APIs to use.
            ///
        Scope* _getOrCreateScopeForLegacyLookup(ASTBuilder* astBuilder);

    protected:
        ComponentType(Linkage* linkage);

    protected:
        Linkage* m_linkage;
        
        CompilerOptionSet m_optionSet;

        // Cache of target-specific programs for each target.
        Dictionary<TargetRequest*, RefPtr<TargetProgram>> m_targetPrograms;

        // Any types looked up dynamically using `getTypeFromString`
        //
        // TODO: Remove this. Type lookup should only be supported on `Module`s.
        //
        Dictionary<String, Type*> m_types;

        Scope* m_lookupScope = nullptr;
        std::unique_ptr<Dictionary<String, IntVal*>> m_mapMangledNameToIntVal;
    };

        /// A component type built up from other component types.
    class CompositeComponentType : public ComponentType
    {
    public:
        static RefPtr<ComponentType> create(
            Linkage*                            linkage,
            List<RefPtr<ComponentType>> const&  childComponents);

        virtual void buildHash(DigestBuilder<SHA1>& builder) SLANG_OVERRIDE;

        List<RefPtr<ComponentType>> const& getChildComponents() { return m_childComponents; };
        Index getChildComponentCount() { return m_childComponents.getCount(); }
        RefPtr<ComponentType> getChildComponent(Index index) { return m_childComponents[index]; }

        Index getEntryPointCount() SLANG_OVERRIDE;
        RefPtr<EntryPoint> getEntryPoint(Index index) SLANG_OVERRIDE;
        String getEntryPointMangledName(Index index) SLANG_OVERRIDE;
        String getEntryPointNameOverride(Index index) SLANG_OVERRIDE;

        Index getShaderParamCount() SLANG_OVERRIDE;
        ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE;

        SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE;
        SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE;

        Index getRequirementCount() SLANG_OVERRIDE;
        RefPtr<ComponentType> getRequirement(Index index) SLANG_OVERRIDE;

        List<Module*> const& getModuleDependencies() SLANG_OVERRIDE;
        List<SourceFile*> const& getFileDependencies() SLANG_OVERRIDE;

        class CompositeSpecializationInfo : public SpecializationInfo
        {
        public:
            List<RefPtr<SpecializationInfo>> childInfos;
        };

    protected:
        void acceptVisitor(ComponentTypeVisitor* visitor, SpecializationInfo* specializationInfo) SLANG_OVERRIDE;


        RefPtr<SpecializationInfo> _validateSpecializationArgsImpl(
            SpecializationArg const*    args,
            Index                       argCount,
            DiagnosticSink*             sink) SLANG_OVERRIDE;

    private:
        CompositeComponentType(
            Linkage*                            linkage,
            List<RefPtr<ComponentType>> const&  childComponents);

        List<RefPtr<ComponentType>> m_childComponents;

        // The following arrays hold the concatenated entry points, parameters,
        // etc. from the child components. This approach allows for reasonably
        // fast (constant time) access through operations like `getShaderParam`,
        // but means that the memory usage of a composite is proportional to
        // the sum of the memory usage of the children, rather than being fixed
        // by the number of children (as it would be if we just stored 
        // `m_childComponents`).
        //
        // TODO: We could conceivably build some O(numChildren) arrays that
        // support binary-search to provide logarithmic-time access to entry
        // points, parameters, etc. while giving a better overall memory usage.
        //
        List<EntryPoint*> m_entryPoints;
        List<String> m_entryPointMangledNames;
        List<String> m_entryPointNameOverrides;
        List<ShaderParamInfo> m_shaderParams;
        List<SpecializationParam> m_specializationParams;
        List<ComponentType*> m_requirements;

        ModuleDependencyList m_moduleDependencyList;
        FileDependencyList m_fileDependencyList;
    };

        /// A component type created by specializing another component type.
    class SpecializedComponentType : public ComponentType
    {
    public:
        SpecializedComponentType(
            ComponentType*                  base,
            SpecializationInfo*             specializationInfo,
            List<SpecializationArg> const&  specializationArgs,
            DiagnosticSink*                 sink);

        virtual void buildHash(DigestBuilder<SHA1>& builer) SLANG_OVERRIDE;

            /// Get the base (unspecialized) component type that is being specialized.
        RefPtr<ComponentType> getBaseComponentType() { return m_base; }

        RefPtr<SpecializationInfo> getSpecializationInfo() { return m_specializationInfo; }

            /// Get the number of arguments supplied for existential type parameters.
            ///
            /// Note that the number of arguments may not match the number of parameters.
            /// In particular, an unspecialized entry point may have many parameters, but zero arguments.
        Index getSpecializationArgCount() { return m_specializationArgs.getCount(); }

            /// Get the existential type argument (type and witness table) at `index`.
        SpecializationArg const& getSpecializationArg(Index index) { return m_specializationArgs[index]; }

            /// Get an array of all existential type arguments.
        SpecializationArg const* getSpecializationArgs() { return m_specializationArgs.getBuffer(); }

        Index getEntryPointCount() SLANG_OVERRIDE { return m_base->getEntryPointCount(); }
        RefPtr<EntryPoint> getEntryPoint(Index index) SLANG_OVERRIDE { return m_base->getEntryPoint(index); }
        String getEntryPointMangledName(Index index) SLANG_OVERRIDE;
        String getEntryPointNameOverride(Index index) SLANG_OVERRIDE;

        Index getShaderParamCount() SLANG_OVERRIDE { return m_base->getShaderParamCount(); }
        ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE { return m_base->getShaderParam(index); }

        SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE { return 0; }
        SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); static SpecializationParam dummy; return dummy; }

        Index getRequirementCount() SLANG_OVERRIDE;
        RefPtr<ComponentType> getRequirement(Index index) SLANG_OVERRIDE;

        List<Module*> const& getModuleDependencies() SLANG_OVERRIDE { return m_moduleDependencies; }
        List<SourceFile*> const& getFileDependencies() SLANG_OVERRIDE { return m_fileDependencies; }

        RefPtr<IRModule> getIRModule() { return m_irModule; }

        void acceptVisitor(ComponentTypeVisitor* visitor, SpecializationInfo* specializationInfo) SLANG_OVERRIDE;

    protected:

        RefPtr<SpecializationInfo> _validateSpecializationArgsImpl(
            SpecializationArg const*    args,
            Index                       argCount,
            DiagnosticSink*             sink) SLANG_OVERRIDE
        {
            SLANG_UNUSED(args);
            SLANG_UNUSED(argCount);
            SLANG_UNUSED(sink);
            return nullptr;
        }

    private:
        RefPtr<ComponentType> m_base;
        RefPtr<SpecializationInfo> m_specializationInfo;
        SpecializationArgs m_specializationArgs;
        RefPtr<IRModule> m_irModule;

        List<String> m_entryPointMangledNames;
        List<String> m_entryPointNameOverrides;

        List<Module*> m_moduleDependencies;
        List<SourceFile*> m_fileDependencies;
        List<RefPtr<ComponentType>> m_requirements;
    };

    class RenamedEntryPointComponentType : public ComponentType
    {
    public:
        using Super = ComponentType;

        RenamedEntryPointComponentType(ComponentType* base, String newName);

        ComponentType* getBase() { return m_base.Ptr(); }

        // Forward `IComponentType` methods

        SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() SLANG_OVERRIDE
        {
            return Super::getSession();
        }

        SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL
            getLayout(SlangInt targetIndex, slang::IBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getLayout(targetIndex, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
            SlangInt entryPointIndex,
            SlangInt targetIndex,
            slang::IBlob** outCode,
            slang::IBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
            slang::SpecializationArg const* specializationArgs,
            SlangInt specializationArgCount,
            slang::IComponentType** outSpecializedComponentType,
            ISlangBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::specialize(
                specializationArgs,
                specializationArgCount,
                outSpecializedComponentType,
                outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
            const char* newName, slang::IComponentType** outEntryPoint) SLANG_OVERRIDE
        {
            return Super::renameEntryPoint(newName, outEntryPoint);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL link(
            slang::IComponentType** outLinkedComponentType,
            ISlangBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::link(outLinkedComponentType, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
            int entryPointIndex,
            int targetIndex,
            ISlangSharedLibrary** outSharedLibrary,
            slang::IBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointHostCallable(
                entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
        }

        List<Module*> const& getModuleDependencies() SLANG_OVERRIDE
        {
            return m_base->getModuleDependencies();
        }
        List<SourceFile*> const& getFileDependencies() SLANG_OVERRIDE
        {
            return m_base->getFileDependencies();
        }

        SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE
        {
            return m_base->getSpecializationParamCount();
        }

        SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE
        {
            return m_base->getSpecializationParam(index);
        }

        Index getRequirementCount() SLANG_OVERRIDE { return m_base->getRequirementCount(); }
        RefPtr<ComponentType> getRequirement(Index index) SLANG_OVERRIDE
        {
            return m_base->getRequirement(index);
        }
        Index getEntryPointCount() SLANG_OVERRIDE { return m_base->getEntryPointCount(); }
        RefPtr<EntryPoint> getEntryPoint(Index index) SLANG_OVERRIDE
        {
            return m_base->getEntryPoint(index);
        }
        String getEntryPointMangledName(Index index) SLANG_OVERRIDE { return m_base->getEntryPointMangledName(index); }
        String getEntryPointNameOverride(Index index) SLANG_OVERRIDE
        {
            SLANG_UNUSED(index);
            SLANG_ASSERT(index == 0);
            return m_entryPointNameOverride;
        }

        Index getShaderParamCount() SLANG_OVERRIDE { return m_base->getShaderParamCount(); }
        ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE
        {
            return m_base->getShaderParam(index);
        }

        void acceptVisitor(ComponentTypeVisitor* visitor, SpecializationInfo* specializationInfo)
            SLANG_OVERRIDE;

        virtual void buildHash(DigestBuilder<SHA1>& builder) SLANG_OVERRIDE;

    private:
        RefPtr<ComponentType> m_base;
        String m_entryPointNameOverride;

    protected:
        RefPtr<SpecializationInfo> _validateSpecializationArgsImpl(
            SpecializationArg const* args, Index argCount, DiagnosticSink* sink) SLANG_OVERRIDE
        {
            return m_base->_validateSpecializationArgsImpl(args, argCount, sink);
        }
    };

        /// Describes an entry point for the purposes of layout and code generation.
        ///
        /// This class also tracks any generic arguments to the entry point,
        /// in the case that it is a specialization of a generic entry point.
        ///
        /// There is also a provision for creating a "dummy" entry point for
        /// the purposes of pass-through compilation modes. Only the
        /// `getName()` and `getProfile()` methods should be expected to
        /// return useful data on pass-through entry points.
        ///
    class EntryPoint : public ComponentType, public slang::IEntryPoint
    {
        typedef ComponentType Super;

    public:
        SLANG_REF_OBJECT_IUNKNOWN_ALL

        ISlangUnknown* getInterface(const Guid& guid);


        // Forward `IComponentType` methods

        SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() SLANG_OVERRIDE
        {
            return Super::getSession();
        }

        SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout(
            SlangInt        targetIndex,
            slang::IBlob**  outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getLayout(targetIndex, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
            SlangInt        entryPointIndex,
            SlangInt        targetIndex,
            slang::IBlob**  outCode,
            slang::IBlob**  outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
            SlangInt        entryPointIndex,
            SlangInt        targetIndex,
            ISlangMutableFileSystem** outFileSystem)  SLANG_OVERRIDE
        {
            return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
            slang::SpecializationArg const* specializationArgs,
            SlangInt                        specializationArgCount,
            slang::IComponentType**         outSpecializedComponentType,
            ISlangBlob**                    outDiagnostics) SLANG_OVERRIDE
        {
            return Super::specialize(
                specializationArgs,
                specializationArgCount,
                outSpecializedComponentType,
                outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
            const char* newName, slang::IComponentType** outEntryPoint) SLANG_OVERRIDE
        {
            return Super::renameEntryPoint(newName, outEntryPoint);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL link(
            slang::IComponentType**         outLinkedComponentType,
            ISlangBlob**                    outDiagnostics) SLANG_OVERRIDE
        {
            return Super::link(
                outLinkedComponentType,
                outDiagnostics);
        }

        virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
            slang::IComponentType** outLinkedComponentType,
            uint32_t count,
            slang::CompilerOptionEntry* entries,
            ISlangBlob** outDiagnostics) override
        {
            return Super::linkWithOptions(outLinkedComponentType, count, entries, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
            int                     entryPointIndex,
            int                     targetIndex,
            ISlangSharedLibrary**   outSharedLibrary,
            slang::IBlob**          outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
        }

        SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
            SlangInt entryPointIndex,
            SlangInt targetIndex,
            slang::IBlob** outHash) SLANG_OVERRIDE
        {
            return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash);
        }

        virtual void buildHash(DigestBuilder<SHA1>& builder) SLANG_OVERRIDE;

            /// Create an entry point that refers to the given function.
        static RefPtr<EntryPoint> create(
            Linkage*            linkage,
            DeclRef<FuncDecl>   funcDeclRef,
            Profile             profile);

            /// Get the function decl-ref, including any generic arguments.
        DeclRef<FuncDecl> getFuncDeclRef() { return m_funcDeclRef; }

            /// Get the function declaration (without generic arguments).
        FuncDecl* getFuncDecl() { return m_funcDeclRef.getDecl(); }

            /// Get the name of the entry point
        Name* getName() { return m_name; }

            /// Get the profile associated with the entry point
            ///
            /// Note: only the stage part of the profile is expected
            /// to contain useful data, but certain legacy code paths
            /// allow for "shader model" information to come via this path.
            ///
        Profile getProfile() { return m_profile; }

            /// Get the stage that the entry point is for.
        Stage getStage() { return m_profile.getStage(); }

            /// Get the module that contains the entry point.
        Module* getModule();

            /// Get a list of modules that this entry point depends on.
            ///
            /// This will include the module that defines the entry point (see `getModule()`),
            /// but may also include modules that are required by its generic type arguments.
            ///
        List<Module*> const& getModuleDependencies() SLANG_OVERRIDE; // { return getModule()->getModuleDependencies(); }
        List<SourceFile*> const& getFileDependencies() SLANG_OVERRIDE; // { return getModule()->getFileDependencies(); }

            /// Create a dummy `EntryPoint` that is only usable for pass-through compilation.
        static RefPtr<EntryPoint> createDummyForPassThrough(
            Linkage*    linkage,
            Name*       name,
            Profile     profile);

            /// Create a dummy `EntryPoint` that stands in for a serialized entry point
        static RefPtr<EntryPoint> createDummyForDeserialize(
            Linkage*    linkage,
            Name*       name,
            Profile     profile,
            String      mangledName);

            /// Get the number of existential type parameters for the entry point.
        SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE;

            /// Get the existential type parameter at `index`.
        SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE;

        Index getRequirementCount() SLANG_OVERRIDE;
        RefPtr<ComponentType> getRequirement(Index index) SLANG_OVERRIDE;

        SpecializationParams const& getExistentialSpecializationParams() { return m_existentialSpecializationParams; }

        Index getGenericSpecializationParamCount() { return m_genericSpecializationParams.getCount(); }
        Index getExistentialSpecializationParamCount() { return m_existentialSpecializationParams.getCount(); }

            /// Get an array of all entry-point shader parameters.
        List<ShaderParamInfo> const& getShaderParams() { return m_shaderParams; }

        Index getEntryPointCount() SLANG_OVERRIDE { return 1; };
        RefPtr<EntryPoint> getEntryPoint(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); return this; }
        String getEntryPointMangledName(Index index) SLANG_OVERRIDE;
        String getEntryPointNameOverride(Index index) SLANG_OVERRIDE;

        Index getShaderParamCount() SLANG_OVERRIDE { return 0; }
        ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); return ShaderParamInfo(); }
        
        class EntryPointSpecializationInfo : public SpecializationInfo
        {
        public:
            DeclRef<FuncDecl> specializedFuncDeclRef;
            List<ExpandedSpecializationArg> existentialSpecializationArgs;
        };

    protected:
        void acceptVisitor(ComponentTypeVisitor* visitor, SpecializationInfo* specializationInfo) SLANG_OVERRIDE;

        RefPtr<SpecializationInfo> _validateSpecializationArgsImpl(
            SpecializationArg const*    args,
            Index                       argCount,
            DiagnosticSink*             sink) SLANG_OVERRIDE;

    private:
        EntryPoint(
            Linkage*            linkage,
            Name*               name,
            Profile             profile,
            DeclRef<FuncDecl>   funcDeclRef);

        void _collectGenericSpecializationParamsRec(Decl* decl);
        void _collectShaderParams();

        // The name of the entry point function (e.g., `main`)
        //
        Name* m_name = nullptr;

        // The declaration of the entry-point function itself.
        //
        DeclRef<FuncDecl> m_funcDeclRef;

            /// The mangled name of the entry point function
        String m_mangledName;

        SpecializationParams m_genericSpecializationParams;
        SpecializationParams m_existentialSpecializationParams;

            /// Information about entry-point parameters
        List<ShaderParamInfo> m_shaderParams;

        // The profile that the entry point will be compiled for
        // (this is a combination of the target stage, and also
        // a feature level that sets capabilities)
        //
        // Note: the profile-version part of this should probably
        // be moving towards deprecation, in favor of the version
        // information (e.g., "Shader Model 5.1") always coming
        // from the target, while the stage part is all that is
        // intrinsic to the entry point.
        //
        Profile m_profile;
    };

    class TypeConformance
        : public ComponentType
        , public slang::ITypeConformance
    {
        typedef ComponentType Super;

    public:
        SLANG_REF_OBJECT_IUNKNOWN_ALL

        ISlangUnknown* getInterface(const Guid& guid);

        TypeConformance(
            Linkage* linkage,
            SubtypeWitness* witness,
            Int confomrmanceIdOverride,
            DiagnosticSink* sink);

        // Forward `IComponentType` methods

        SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() SLANG_OVERRIDE
        {
            return Super::getSession();
        }

        SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL
            getLayout(SlangInt targetIndex, slang::IBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getLayout(targetIndex, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
            SlangInt entryPointIndex,
            SlangInt targetIndex,
            slang::IBlob** outCode,
            slang::IBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
            SlangInt        entryPointIndex,
            SlangInt        targetIndex,
            ISlangMutableFileSystem** outFileSystem)  SLANG_OVERRIDE
        {
            return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
            slang::SpecializationArg const* specializationArgs,
            SlangInt specializationArgCount,
            slang::IComponentType** outSpecializedComponentType,
            ISlangBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::specialize(
                specializationArgs,
                specializationArgCount,
                outSpecializedComponentType,
                outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
            const char* newName, slang::IComponentType** outEntryPoint) SLANG_OVERRIDE
        {
            return Super::renameEntryPoint(newName, outEntryPoint);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL link(
            slang::IComponentType** outLinkedComponentType,
            ISlangBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::link(outLinkedComponentType, outDiagnostics);
        }

        virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
            slang::IComponentType** outLinkedComponentType,
            uint32_t count,
            slang::CompilerOptionEntry* entries,
            ISlangBlob** outDiagnostics) override
        {
            return Super::linkWithOptions(outLinkedComponentType, count, entries, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
            int entryPointIndex,
            int targetIndex,
            ISlangSharedLibrary** outSharedLibrary,
            slang::IBlob** outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointHostCallable(
                entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
        }

        SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
            SlangInt entryPointIndex,
            SlangInt targetIndex,
            slang::IBlob** outHash) SLANG_OVERRIDE
        {
            return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash);
        }

        virtual void buildHash(DigestBuilder<SHA1>& builder) SLANG_OVERRIDE;

        List<Module*> const& getModuleDependencies() SLANG_OVERRIDE;
        List<SourceFile*> const& getFileDependencies() SLANG_OVERRIDE;

        SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE { return 0; }

        /// Get the existential type parameter at `index`.
        SpecializationParam const& getSpecializationParam(Index /*index*/) SLANG_OVERRIDE
        {
            static SpecializationParam emptyParam;
            return emptyParam;
        }

        Index getRequirementCount() SLANG_OVERRIDE;
        RefPtr<ComponentType> getRequirement(Index index) SLANG_OVERRIDE;
        Index getEntryPointCount() SLANG_OVERRIDE { return 0; };
        RefPtr<EntryPoint> getEntryPoint(Index index) SLANG_OVERRIDE
        {
            SLANG_UNUSED(index);
            return nullptr;
        }
        String getEntryPointMangledName(Index /*index*/) SLANG_OVERRIDE { return ""; }
        String getEntryPointNameOverride(Index /*index*/) SLANG_OVERRIDE { return ""; }

        Index getShaderParamCount() SLANG_OVERRIDE { return 0; }
        ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE
        {
            SLANG_UNUSED(index);
            return ShaderParamInfo();
        }

        SubtypeWitness* getSubtypeWitness() { return m_subtypeWitness; }
        IRModule* getIRModule() { return m_irModule.Ptr(); }
    protected:
        void acceptVisitor(ComponentTypeVisitor* visitor, SpecializationInfo* specializationInfo)
            SLANG_OVERRIDE;

        RefPtr<SpecializationInfo> _validateSpecializationArgsImpl(
            SpecializationArg const* args,
            Index argCount,
            DiagnosticSink* sink) SLANG_OVERRIDE;
    private:
        SubtypeWitness* m_subtypeWitness;
        ModuleDependencyList m_moduleDependencyList;
        FileDependencyList m_fileDependencyList;
        List<RefPtr<Module>> m_requirements;
        HashSet<Module*> m_requirementSet;
        RefPtr<IRModule> m_irModule;
        Int m_conformanceIdOverride;
        void addDepedencyFromWitness(SubtypeWitness* witness);
    };

    enum class PassThroughMode : SlangPassThroughIntegral
    {
        None = SLANG_PASS_THROUGH_NONE,                     ///< don't pass through: use Slang compiler
        Fxc = SLANG_PASS_THROUGH_FXC,                       ///< pass through HLSL to `D3DCompile` API
        Dxc = SLANG_PASS_THROUGH_DXC,                       ///< pass through HLSL to `IDxcCompiler` API
        Glslang = SLANG_PASS_THROUGH_GLSLANG,               ///< pass through GLSL to `glslang` library
        SpirvDis = SLANG_PASS_THROUGH_SPIRV_DIS,            ///< pass through spirv-dis
        Clang = SLANG_PASS_THROUGH_CLANG,                   ///< Pass through clang compiler
        VisualStudio = SLANG_PASS_THROUGH_VISUAL_STUDIO,    ///< Visual studio compiler
        Gcc = SLANG_PASS_THROUGH_GCC,                       ///< Gcc compiler
        GenericCCpp = SLANG_PASS_THROUGH_GENERIC_C_CPP,     ///< Generic C/C++ compiler
        NVRTC = SLANG_PASS_THROUGH_NVRTC,                   ///< NVRTC CUDA compiler
        LLVM = SLANG_PASS_THROUGH_LLVM,                     ///< LLVM 'compiler'
        SpirvOpt = SLANG_PASS_THROUGH_SPIRV_OPT,            ///< pass thorugh spirv to spirv-opt
        MetalC = SLANG_PASS_THROUGH_METAL,
        CountOf = SLANG_PASS_THROUGH_COUNT_OF,              
    };
    void printDiagnosticArg(StringBuilder& sb, PassThroughMode val);

    class SourceFile;

        /// A module of code that has been compiled through the front-end
        ///
        /// A module comprises all the code from one translation unit (which
        /// may span multiple Slang source files), and provides access
        /// to both the AST and IR representations of that code.
        ///
    class Module : public ComponentType, public slang::IModule
    {
        typedef ComponentType Super;

    public:
        SLANG_REF_OBJECT_IUNKNOWN_ALL

        ISlangUnknown* getInterface(const Guid& guid);


        // Forward `IComponentType` methods

        SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() SLANG_OVERRIDE
        {
            return Super::getSession();
        }

        SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout(
            SlangInt        targetIndex,
            slang::IBlob**  outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getLayout(targetIndex, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
            SlangInt        entryPointIndex,
            SlangInt        targetIndex,
            slang::IBlob**  outCode,
            slang::IBlob**  outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
            SlangInt        entryPointIndex,
            SlangInt        targetIndex,
            ISlangMutableFileSystem** outFileSystem)  SLANG_OVERRIDE
        {
            return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
            slang::SpecializationArg const* specializationArgs,
            SlangInt                        specializationArgCount,
            slang::IComponentType**         outSpecializedComponentType,
            ISlangBlob**                    outDiagnostics) SLANG_OVERRIDE
        {
            return Super::specialize(
                specializationArgs,
                specializationArgCount,
                outSpecializedComponentType,
                outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
            const char* newName, slang::IComponentType** outEntryPoint) SLANG_OVERRIDE
        {
            return Super::renameEntryPoint(newName, outEntryPoint);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL link(
            slang::IComponentType**         outLinkedComponentType,
            ISlangBlob**                    outDiagnostics) SLANG_OVERRIDE
        {
            return Super::link(
                outLinkedComponentType,
                outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
            int                     entryPointIndex,
            int                     targetIndex,
            ISlangSharedLibrary**   outSharedLibrary,
            slang::IBlob**          outDiagnostics) SLANG_OVERRIDE
        {
            return Super::getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
        }

        SLANG_NO_THROW SlangResult SLANG_MCALL findEntryPointByName(
            char const*             name,
            slang::IEntryPoint**     outEntryPoint) SLANG_OVERRIDE
        {
            ComPtr<slang::IEntryPoint> entryPoint(findEntryPointByName(UnownedStringSlice(name)));
            if((!entryPoint))
                return SLANG_FAIL;

            *outEntryPoint = entryPoint.detach();
            return SLANG_OK;
        }

        virtual SLANG_NO_THROW SlangResult SLANG_MCALL findAndCheckEntryPoint(
            char const* name,
            SlangStage stage,
            slang::IEntryPoint** outEntryPoint,
            ISlangBlob** outDiagnostics)
        {
            ComPtr<slang::IEntryPoint> entryPoint(findAndCheckEntryPoint(UnownedStringSlice(name), stage, outDiagnostics));
            if ((!entryPoint))
                return SLANG_FAIL;

            *outEntryPoint = entryPoint.detach();
            return SLANG_OK;
        }

        virtual SlangInt32 SLANG_MCALL getDefinedEntryPointCount() override
        {
            return (SlangInt32)m_entryPoints.getCount();
        }

        virtual SlangResult SLANG_MCALL getDefinedEntryPoint(SlangInt32 index, slang::IEntryPoint** outEntryPoint) override
        {
            if (index < 0 || index >= m_entryPoints.getCount())
                return SLANG_E_INVALID_ARG;

            ComPtr<slang::IEntryPoint> entryPoint(m_entryPoints[index].Ptr());
            *outEntryPoint = entryPoint.detach();
            return SLANG_OK;
        }

        virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
            slang::IComponentType** outLinkedComponentType,
            uint32_t count,
            slang::CompilerOptionEntry* entries,
            ISlangBlob** outDiagnostics) override
        {
            return Super::linkWithOptions(outLinkedComponentType, count, entries, outDiagnostics);
        }
        //

        SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
            SlangInt entryPointIndex,
            SlangInt targetIndex,
            slang::IBlob** outHash) SLANG_OVERRIDE
        {
            return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash);
        }

        /// Get a serialized representation of the checked module.
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL serialize(ISlangBlob** outSerializedBlob) override;

        /// Write the serialized representation of this module to a file.
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL writeToFile(char const* fileName) override;

        /// Get the name of the module.
        virtual SLANG_NO_THROW const char* SLANG_MCALL getName() override;

        /// Get the path of the module.
        virtual SLANG_NO_THROW const char* SLANG_MCALL getFilePath() override;

        /// Get the unique identity of the module.
        virtual SLANG_NO_THROW const char* SLANG_MCALL getUniqueIdentity() override;


        virtual void buildHash(DigestBuilder<SHA1>& builder) SLANG_OVERRIDE;

        void setDigest(SHA1::Digest const& digest) { m_digest = digest; }
        SHA1::Digest computeDigest();

            /// Create a module (initially empty).
        Module(Linkage* linkage, ASTBuilder* astBuilder = nullptr);

            /// Get the AST for the module (if it has been parsed)
        ModuleDecl* getModuleDecl() { return m_moduleDecl; }

            /// The the IR for the module (if it has been generated)
        IRModule* getIRModule() { return m_irModule; }

            /// Get the list of other modules this module depends on
        List<Module*> const& getModuleDependencyList() { return m_moduleDependencyList.getModuleList(); }

            /// Get the list of files this module depends on
        List<SourceFile*> const& getFileDependencyList() { return m_fileDependencyList.getFileList(); }

            /// Register a module that this module depends on
        void addModuleDependency(Module* module);

            /// Register a source file that this module depends on
        void addFileDependency(SourceFile* sourceFile);

        void clearFileDependency() { m_fileDependencyList.clear(); }
            /// Set the AST for this module.
            ///
            /// This should only be called once, during creation of the module.
            ///
        void setModuleDecl(ModuleDecl* moduleDecl);// { m_moduleDecl = moduleDecl; }

        void setName(String name);
        void setName(Name* name) { m_name = name; }
        void setPathInfo(PathInfo pathInfo) { m_pathInfo = pathInfo; }

            /// Set the IR for this module.
            ///
            /// This should only be called once, during creation of the module.
            ///
        void setIRModule(IRModule* irModule) { m_irModule = irModule; }

        Index getEntryPointCount() SLANG_OVERRIDE { return 0; }
        RefPtr<EntryPoint> getEntryPoint(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); return nullptr; }
        String getEntryPointMangledName(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); return String(); }
        String getEntryPointNameOverride(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); return String(); }

        Index getShaderParamCount() SLANG_OVERRIDE { return m_shaderParams.getCount(); }
        ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE { return m_shaderParams[index]; }

        SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE { return m_specializationParams.getCount(); }
        SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE { return m_specializationParams[index]; }

        Index getRequirementCount() SLANG_OVERRIDE;
        RefPtr<ComponentType> getRequirement(Index index) SLANG_OVERRIDE;

        List<Module*> const& getModuleDependencies() SLANG_OVERRIDE { return m_moduleDependencyList.getModuleList(); }
        List<SourceFile*> const& getFileDependencies() SLANG_OVERRIDE { return m_fileDependencyList.getFileList(); }

            /// Given a mangled name finds the exported NodeBase associated with this module.
            /// If not found returns nullptr.
        NodeBase* findExportFromMangledName(const UnownedStringSlice& slice);

            /// Get the ASTBuilder
        ASTBuilder* getASTBuilder() { return m_astBuilder; }

            /// Collect information on the shader parameters of the module.
            ///
            /// This method should only be called once, after the core
            /// structured of the module (its AST and IR) have been created,
            /// and before any of the `ComponentType` APIs are used.
            ///
            /// TODO: We might eventually consider a non-stateful approach
            /// to constructing a `Module`.
            ///
        void _collectShaderParams();

        void _discoverEntryPoints(DiagnosticSink* sink);

        class ModuleSpecializationInfo : public SpecializationInfo
        {
        public:
            struct GenericArgInfo
            {
                Decl* paramDecl = nullptr;
                Val* argVal = nullptr;
            };

            List<GenericArgInfo> genericArgs;
            List<ExpandedSpecializationArg> existentialArgs;
        };

        RefPtr<EntryPoint> findEntryPointByName(UnownedStringSlice const& name);
        RefPtr<EntryPoint> findAndCheckEntryPoint(UnownedStringSlice const& name, SlangStage stage, ISlangBlob** outDiagnostics);

        List<RefPtr<EntryPoint>>& getEntryPoints() { return m_entryPoints; }
        void _addEntryPoint(EntryPoint* entryPoint);
        void _processFindDeclsExportSymbolsRec(Decl* decl);

        // Gets the files that has been included into the module.
        Dictionary<SourceFile*, FileDecl*>& getIncludedSourceFileMap() { return m_mapSourceFileToFileDecl; }

    protected:
        void acceptVisitor(ComponentTypeVisitor* visitor, SpecializationInfo* specializationInfo) SLANG_OVERRIDE;

        RefPtr<SpecializationInfo> _validateSpecializationArgsImpl(
            SpecializationArg const*    args,
            Index                       argCount,
            DiagnosticSink*             sink) SLANG_OVERRIDE;

    private:
        Name* m_name = nullptr;
        PathInfo m_pathInfo;

        // The AST for the module
        ModuleDecl*  m_moduleDecl = nullptr;

        // The IR for the module
        RefPtr<IRModule> m_irModule = nullptr;

        List<ShaderParamInfo> m_shaderParams;
        SpecializationParams m_specializationParams;

        List<Module*> m_requirements;

        // A digest that uniquely identifies the contents of the module.
        SHA1::Digest m_digest;

        // List of modules this module depends on
        ModuleDependencyList m_moduleDependencyList;

        // List of source files this module depends on
        FileDependencyList m_fileDependencyList;

        // Entry points that were defined in thsi module
        //
        // Note: the entry point defined in the module are *not*
        // part of the memory image/layout of the module when
        // it is considered as an IComponentType. This can be
        // a bit confusing, but if all the entry points in the
        // module were automatically linked into the component
        // type, we'd need a way to access just the global
        // scope of the module without the entry points, in
        // case we wanted to link a single entry point against
        // the global scope. The `Module` type provides exactly
        // that "module without its entry points" unit of
        // granularity for linking.
        //
        // This list only exists for lookup purposes, so that
        // the user can find an existing entry-point function
        // that was defined as part of the module.
        //
        List<RefPtr<EntryPoint>> m_entryPoints;

        // The builder that owns all of the AST nodes from parsing the source of
        // this module. 
        RefPtr<ASTBuilder> m_astBuilder;

        // Holds map of exported mangled names to symbols. m_mangledExportPool maps names to indices,
        // and m_mangledExportSymbols holds the NodeBase* values for each index. 
        StringSlicePool m_mangledExportPool;
        List<NodeBase*> m_mangledExportSymbols;

        // Source files that have been pulled into the module with `__include`.
        Dictionary<SourceFile*, FileDecl*> m_mapSourceFileToFileDecl;
    };
    typedef Module LoadedModule;

        /// A request for the front-end to compile a translation unit.
    class TranslationUnitRequest : public RefObject
    {
    public:
        TranslationUnitRequest(
            FrontEndCompileRequest* compileRequest);
        TranslationUnitRequest(
            FrontEndCompileRequest* compileRequest, Module* m);

        // The parent compile request
        FrontEndCompileRequest* compileRequest = nullptr;

            // The language in which the source file(s)
            // are assumed to be written
        SourceLanguage sourceLanguage = SourceLanguage::Unknown;

            /// Makes any source artifact available as a SourceFile.
            /// If successful any of the source artifacts will be represented by the same index 
            /// of sourceArtifacts
        SlangResult requireSourceFiles();

            /// Get the source files. 
            /// Since lazily evaluated requires calling requireSourceFiles to know it's in sync
            /// with sourceArtifacts.
        List<SourceFile*> const& getSourceFiles();
        
            /// Get the source artifacts associated 
        const List<ComPtr<IArtifact>>& getSourceArtifacts() const { return m_sourceArtifacts; }

            /// Clear all of the source
        void clearSource() { m_sourceArtifacts.clear(); m_sourceFiles.clear(); }

            /// Add a source artifact
        void addSourceArtifact(IArtifact* sourceArtifact);

            /// Add both the artifact and the sourceFile. 
        void addSource(IArtifact* sourceArtifact, SourceFile* sourceFile);

            // The entry points associated with this translation unit
        List<RefPtr<EntryPoint>> const& getEntryPoints() { return module->getEntryPoints(); }

        void _addEntryPoint(EntryPoint* entryPoint) { module->_addEntryPoint(entryPoint); }

        // Preprocessor definitions to use for this translation unit only
        // (whereas the ones on `compileRequest` will be shared)
        Dictionary<String, String> preprocessorDefinitions;

            /// The name that will be used for the module this translation unit produces.
        Name* moduleName = nullptr;

            /// Result of compiling this translation unit (a module)
        RefPtr<Module> module;

        bool isChecked = false;

        Module* getModule() { return module; }
        ModuleDecl* getModuleDecl() { return module->getModuleDecl(); }

        Session* getSession();
        NamePool* getNamePool();
        SourceManager* getSourceManager();

        Scope* getLanguageScope();

        Dictionary<String, String> getCombinedPreprocessorDefinitions();

        void setModuleName(Name* name)
        {
            moduleName = name;
            if (module)
                module->setName(name);
        }

    protected:
        void _addSourceFile(SourceFile* sourceFile);
        /* Given an artifact, find a PathInfo. 
        If no PathInfo can be found will return an unknown PathInfo */
        PathInfo _findSourcePathInfo(IArtifact* artifact);

        List<ComPtr<IArtifact>> m_sourceArtifacts;
        // The source file(s) that will be compiled to form this translation unit
        //
        // Usually, for HLSL or GLSL there will be only one file.
        // NOTE! This member is generated lazily from m_sourceArtifacts
        // it is *necessary* to call requireSourceFiles to ensure it's in sync.
        List<SourceFile*> m_sourceFiles;
    };

    enum class FloatingPointMode : SlangFloatingPointModeIntegral
    {
        Default = SLANG_FLOATING_POINT_MODE_DEFAULT,
        Fast = SLANG_FLOATING_POINT_MODE_FAST,
        Precise = SLANG_FLOATING_POINT_MODE_PRECISE,
    };

    enum class WriterChannel : SlangWriterChannelIntegral
    {
        Diagnostic = SLANG_WRITER_CHANNEL_DIAGNOSTIC,
        StdOutput = SLANG_WRITER_CHANNEL_STD_OUTPUT,
        StdError = SLANG_WRITER_CHANNEL_STD_ERROR,
        CountOf = SLANG_WRITER_CHANNEL_COUNT_OF,
    };

    enum class WriterMode : SlangWriterModeIntegral
    {
        Text = SLANG_WRITER_MODE_TEXT,
        Binary = SLANG_WRITER_MODE_BINARY,
    };

    class TargetRequest;

    /// Are we generating code for a D3D API?
    bool isD3DTarget(TargetRequest* targetReq);

    /// Are we generating code for a Khronos API (OpenGL or Vulkan)?
    bool isKhronosTarget(TargetRequest* targetReq);

    /// Are we generating code for a CUDA API (CUDA / OptiX)?
    bool isCUDATarget(TargetRequest* targetReq);


        /// A request to generate output in some target format.
    class TargetRequest : public RefObject
    {
    public:
        TargetRequest(Linkage* linkage, CodeGenTarget format);

        TargetRequest(const TargetRequest& other);

        Linkage* getLinkage() { return linkage; }
       
        Session* getSession();

        CodeGenTarget getTarget() { return optionSet.getEnumOption<CodeGenTarget>(CompilerOptionName::Target); }

        // TypeLayouts created on the fly by reflection API
        Dictionary<Type*, RefPtr<TypeLayout>> typeLayouts;

        Dictionary<Type*, RefPtr<TypeLayout>>& getTypeLayouts() { return typeLayouts; }

        TypeLayout* getTypeLayout(Type* type);

        CompilerOptionSet& getOptionSet() { return optionSet; }

        CapabilitySet getTargetCaps();

        HLSLToVulkanLayoutOptions* getHLSLToVulkanLayoutOptions();

    private:
        Linkage*                linkage = nullptr;
        CompilerOptionSet       optionSet;
        CapabilitySet           cookedCapabilities;
        RefPtr<HLSLToVulkanLayoutOptions> hlslToVulkanOptions;
    };

        /// Given a target request returns which (if any) intermediate source language is required
        /// to produce it.
        ///
        /// If no intermediate source language is required, will return SourceLanguage::Unknown
    SourceLanguage getIntermediateSourceLanguageForTarget(TargetProgram* req);

        /// Are resource types "bindless" (implemented as ordinary data) on the given `target`?
    bool areResourceTypesBindlessOnTarget(TargetRequest* target);

    // Compute the "effective" profile to use when outputting the given entry point
    // for the chosen code-generation target.
    //
    // The stage of the effective profile will always come from the entry point, while
    // the profile version (aka "shader model") will be computed as follows:
    //
    // - If the entry point and target belong to the same profile family, then take
    //   the latest version between the two (e.g., if the entry point specified `ps_5_1`
    //   and the target specifies `sm_5_0` then use `sm_5_1` as the version).
    //
    // - If the entry point and target disagree on the profile family, always use the
    //   profile family and version from the target.
    //
    Profile getEffectiveProfile(EntryPoint* entryPoint, TargetRequest* target);


        /// Given a target returns the required downstream compiler
    PassThroughMode getDownstreamCompilerRequiredForTarget(CodeGenTarget target);
        /// Given a target returns a downstream compiler the prelude should be taken from.
    SourceLanguage getDefaultSourceLanguageForDownstreamCompiler(PassThroughMode compiler);

        /// Get the build tag string
    const char* getBuildTagString();

    struct TypeCheckingCache;

    struct ContainerTypeKey
    {
        slang::TypeReflection* elementType;
        slang::ContainerType containerType;
        bool operator==(ContainerTypeKey other) const
        {
            return elementType == other.elementType && containerType == other.containerType;
        }
        Slang::HashCode getHashCode() const
        {
            return Slang::combineHash(
                Slang::getHashCode(elementType), Slang::getHashCode(containerType));
        }
    };

        /// A dictionary of currently loaded modules. Used by `findOrImportModule` to
        /// lookup additional loaded modules.
    typedef Dictionary<Name*, Module*> LoadedModuleDictionary;

    enum ModuleBlobType
    {
        Source, IR
    };

    struct SerialContainerDataModule;

        /// A context for loading and re-using code modules.
    class Linkage : public RefObject, public slang::ISession
    {
    public:
        SLANG_REF_OBJECT_IUNKNOWN_ALL

        CompilerOptionSet m_optionSet;

        ISlangUnknown* getInterface(const Guid& guid);

        SLANG_NO_THROW slang::IGlobalSession* SLANG_MCALL getGlobalSession() override;
        SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModule(
            const char* moduleName,
            slang::IBlob**     outDiagnostics = nullptr) override;
        slang::IModule* loadModuleFromBlob(
            const char* moduleName,
            const char* path,
            slang::IBlob* source,
            ModuleBlobType blobType,
            slang::IBlob** outDiagnostics = nullptr);
        SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModuleFromIRBlob(
            const char* moduleName,
            const char* path,
            slang::IBlob* source,
            slang::IBlob** outDiagnostics = nullptr) override;
        SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModuleFromSource(
            const char* moduleName,
            const char* path,
            slang::IBlob* source,
            slang::IBlob** outDiagnostics = nullptr) override;
        SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModuleFromSourceString(
            const char* moduleName,
            const char* path,
            const char* string,
            slang::IBlob** outDiagnostics = nullptr) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL createCompositeComponentType(
            slang::IComponentType* const*   componentTypes,
            SlangInt                        componentTypeCount,
            slang::IComponentType**         outCompositeComponentType,
            ISlangBlob**                    outDiagnostics = nullptr) override;
        SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL specializeType(
            slang::TypeReflection*          type,
            slang::SpecializationArg const* specializationArgs,
            SlangInt                        specializationArgCount,
            ISlangBlob**                    outDiagnostics = nullptr) override;
        SLANG_NO_THROW slang::TypeLayoutReflection* SLANG_MCALL getTypeLayout(
            slang::TypeReflection* type,
            SlangInt               targetIndex = 0,
            slang::LayoutRules     rules = slang::LayoutRules::Default,
            ISlangBlob**    outDiagnostics = nullptr) override;
        SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL getContainerType(
            slang::TypeReflection* elementType,
            slang::ContainerType containerType,
            ISlangBlob** outDiagnostics = nullptr) override;
        SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL getDynamicType() override;
        SLANG_NO_THROW SlangResult SLANG_MCALL getTypeRTTIMangledName(
            slang::TypeReflection* type,
            ISlangBlob** outNameBlob) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL getTypeConformanceWitnessMangledName(
            slang::TypeReflection* type,
            slang::TypeReflection* interfaceType,
            ISlangBlob** outNameBlob) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL getTypeConformanceWitnessSequentialID(
            slang::TypeReflection* type,
            slang::TypeReflection* interfaceType,
            uint32_t*              outId) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL createTypeConformanceComponentType(
            slang::TypeReflection* type,
            slang::TypeReflection* interfaceType,
            slang::ITypeConformance** outConformance,
            SlangInt conformanceIdOverride,
            ISlangBlob** outDiagnostics) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL createCompileRequest(
            SlangCompileRequest**   outCompileRequest) override;
        virtual SLANG_NO_THROW SlangInt SLANG_MCALL getLoadedModuleCount() override;
        virtual SLANG_NO_THROW slang::IModule* SLANG_MCALL getLoadedModule(SlangInt index) override;
        virtual SLANG_NO_THROW bool SLANG_MCALL isBinaryModuleUpToDate(const char* modulePath, slang::IBlob* binaryModuleBlob) override;

        // Updates the supplied builder with linkage-related information, which includes preprocessor
        // defines, the compiler version, and other compiler options. This is then merged with the hash
        // produced for the program to produce a key that can be used with the shader cache.
        void buildHash(DigestBuilder<SHA1>& builder, SlangInt targetIndex = -1);

        void addTarget(
            slang::TargetDesc const& desc);
        SlangResult addSearchPath(
            char const* path);
        SlangResult addPreprocessorDefine(
            char const* name,
            char const* value);
        SlangResult setMatrixLayoutMode(
            SlangMatrixLayoutMode mode);
            /// Create an initially-empty linkage
        Linkage(Session* session, ASTBuilder* astBuilder, Linkage* builtinLinkage);

            /// Dtor
        ~Linkage();

        bool isInLanguageServer() { return contentAssistInfo.checkingMode != ContentAssistCheckingMode::None; }

            /// Get the parent session for this linkage
        Session* getSessionImpl() { return m_session; }

        // Information on the targets we are being asked to
        // generate code for.
        List<RefPtr<TargetRequest>> targets;

        // Directories to search for `#include` files or `import`ed modules
        SearchDirectoryList& getSearchDirectories();

        // Source manager to help track files loaded
        SourceManager m_defaultSourceManager;
        SourceManager* m_sourceManager = nullptr;
        RefPtr<CommandLineContext> m_cmdLineContext;

        // Name pool for looking up names
        NamePool namePool;

        NamePool* getNamePool() { return &namePool; }

        ASTBuilder* getASTBuilder() { return m_astBuilder; }

        RefPtr<ASTBuilder> m_astBuilder;

        // Cache for container types.
        Dictionary<ContainerTypeKey, Type*> m_containerTypes;

            // cache used by type checking, implemented in check.cpp
        TypeCheckingCache* getTypeCheckingCache();
        void destroyTypeCheckingCache();

        TypeCheckingCache* m_typeCheckingCache = nullptr;

        // Modules that have been dynamically loaded via `import`
        //
        // This is a list of unique modules loaded, in the order they were encountered.
        List<RefPtr<LoadedModule> > loadedModulesList;

        // Map from the path (or uniqueIdentity if available) of a module file to its definition
        Dictionary<String, RefPtr<LoadedModule>> mapPathToLoadedModule;

        // Map from the logical name of a module to its definition
        Dictionary<Name*, RefPtr<LoadedModule>> mapNameToLoadedModules;

        // Map from the mangled name of RTTI objects to sequential IDs
        // used by `switch`-based dynamic dispatch.
        Dictionary<String, uint32_t> mapMangledNameToRTTIObjectIndex;

        // Counters for allocating sequential IDs to witness tables conforming to each interface type.
        Dictionary<String, uint32_t> mapInterfaceMangledNameToSequentialIDCounters;

        SearchDirectoryList searchDirectoryCache;

        // The resulting specialized IR module for each entry point request
        List<RefPtr<IRModule>> compiledModules;

        ContentAssistInfo contentAssistInfo;
        
        /// File system implementation to use when loading files from disk.
        ///
        /// If this member is `null`, a default implementation that tries
        /// to use the native OS filesystem will be used instead.
        ///
        ComPtr<ISlangFileSystem> m_fileSystem;

        /// The extended file system implementation. Will be set to a default implementation
        /// if fileSystem is nullptr. Otherwise it will either be fileSystem's interface, 
        /// or a wrapped impl that makes fileSystem operate as fileSystemExt
        ComPtr<ISlangFileSystemExt> m_fileSystemExt;
  
        /// Get the currenly set file system
        ISlangFileSystemExt* getFileSystemExt() { return m_fileSystemExt; }
      
        /// Load a file into memory using the configured file system.
        ///
        /// @param path The path to attempt to load from
        /// @param outBlob A destination pointer to receive the loaded blob
        /// @returns A `SlangResult` to indicate success or failure.
        ///
        SlangResult loadFile(String const& path, PathInfo& outPathInfo, ISlangBlob** outBlob);

        Expr* parseTermString(String str, Scope* scope);

        Type* specializeType(
            Type*           unspecializedType,
            Int             argCount,
            Type* const*    args,
            DiagnosticSink* sink);

            /// Add a new target and return its index.
        UInt addTarget(
            CodeGenTarget   target);

        RefPtr<Module> loadModule(
            Name*               name,
            const PathInfo&     filePathInfo,
            ISlangBlob*         fileContentsBlob,
            SourceLoc const&    loc,
            DiagnosticSink*     sink,
            const LoadedModuleDictionary* additionalLoadedModules,
            ModuleBlobType      blobType);

        RefPtr<Module> loadModuleFromIRBlobImpl(
            Name* name,
            const PathInfo& filePathInfo,
            ISlangBlob* fileContentsBlob,
            SourceLoc const& loc,
            DiagnosticSink* sink,
            const LoadedModuleDictionary* additionalLoadedModules);
        RefPtr<Module> loadDeserializedModule(
            Name* name,
            const PathInfo& filePathInfo,
            SerialContainerDataModule& m,
            DiagnosticSink* sink);

        SourceFile* loadSourceFile(String pathFrom, String path);

        void loadParsedModule(
            RefPtr<FrontEndCompileRequest>  compileRequest,
            RefPtr<TranslationUnitRequest>  translationUnit,
            Name*                           name,
            PathInfo const&                 pathInfo);

            /// Load a module of the given name.
        Module* loadModule(String const& name);

        bool isBinaryModuleUpToDate(String fromPath, RiffContainer* container);

        RefPtr<Module> findOrImportModule(
            Name*               name,
            SourceLoc const&    loc,
            DiagnosticSink*     sink,
            const LoadedModuleDictionary* loadedModules = nullptr);

        void prepareDeserializedModule(SerialContainerDataModule& moduleEntry, const PathInfo& pathInfo, Module* module, DiagnosticSink* sink);

        SourceFile* findFile(Name* name, SourceLoc loc, IncludeSystem& outIncludeSystem);
        struct IncludeResult
        {
            FileDecl* fileDecl;
            bool isNew;
        };
        IncludeResult findAndIncludeFile(Module* module, TranslationUnitRequest* translationUnit, Name* name, SourceLoc const& loc, DiagnosticSink* sink);

        SourceManager* getSourceManager()
        {
            return m_sourceManager;
        }

            /// Override the source manager for the linkage.
            ///
            /// This is only used to install a temporary override when
            /// parsing stuff from strings (where we don't want to retain
            /// full source files for the parsed result).
            ///
            /// TODO: We should remove the need for this hack.
            ///
        void setSourceManager(SourceManager* sourceManager)
        {
            m_sourceManager = sourceManager;
        }

        void setRequireCacheFileSystem(bool requireCacheFileSystem);

        void setFileSystem(ISlangFileSystem* fileSystem);

        DiagnosticSink::Flags diagnosticSinkFlags = 0;

        bool m_requireCacheFileSystem = false;

        // Modules that have been read in with the -r option
        List<ComPtr<IArtifact>> m_libModules;

        void _stopRetainingParentSession()
        {
            m_retainedSession = nullptr;
        }

    private:
            /// The global Slang library session that this linkage is a child of
        Session* m_session = nullptr;

        RefPtr<Session> m_retainedSession;

            /// Tracks state of modules currently being loaded.
            ///
            /// This information is used to diagnose cases where
            /// a user tries to recursively import the same module
            /// (possibly along a transitive chain of `import`s).
            ///
        struct ModuleBeingImportedRAII
        {
        public:
            ModuleBeingImportedRAII(
                Linkage*            linkage,
                Module*             module,
                Name*               name,
                SourceLoc const&    importLoc)
                : linkage(linkage)
                , module(module)
                , name(name)
                , importLoc(importLoc)
            {
                next = linkage->m_modulesBeingImported;
                linkage->m_modulesBeingImported = this;
            }

            ~ModuleBeingImportedRAII()
            {
                linkage->m_modulesBeingImported = next;
            }

            Linkage* linkage;
            Module* module;
            Name* name;
            SourceLoc importLoc;
            ModuleBeingImportedRAII* next;
        };

        // Any modules currently being imported will be listed here
        ModuleBeingImportedRAII*m_modulesBeingImported = nullptr;

            /// Is the given module in the middle of being imported?
        bool isBeingImported(Module* module);

            /// Diagnose that an error occured in the process of importing a module
        void _diagnoseErrorInImportedModule(
            DiagnosticSink*     sink);

        List<Type*> m_specializedTypes;

    };

        /// Shared functionality between front- and back-end compile requests.
        ///
        /// This is the base class for both `FrontEndCompileRequest` and
        /// `BackEndCompileRequest`, and allows a small number of parts of
        /// the compiler to be easily invocable from either front-end or
        /// back-end work.
        ///
    class CompileRequestBase : public RefObject
    {
        // TODO: We really shouldn't need this type in the long run.
        // The few places that rely on it should be refactored to just
        // depend on the underlying information (a linkage and a diagnostic
        // sink) directly.
        //
        // The flags to control dumping and validation of IR should be
        // moved to some kind of shared settings/options `struct` that
        // both front-end and back-end requests can store.

    public:
        Session* getSession();
        Linkage* getLinkage() { return m_linkage; }
        DiagnosticSink* getSink() { return m_sink; }
        SourceManager* getSourceManager() { return getLinkage()->getSourceManager(); }
        NamePool* getNamePool() { return getLinkage()->getNamePool(); }
        ISlangFileSystemExt* getFileSystemExt() { return getLinkage()->getFileSystemExt(); }
        SlangResult loadFile(String const& path, PathInfo& outPathInfo, ISlangBlob** outBlob) { return getLinkage()->loadFile(path, outPathInfo, outBlob); }

    protected:
        CompileRequestBase(
            Linkage*        linkage,
            DiagnosticSink* sink);

    private:
        Linkage* m_linkage = nullptr;
        DiagnosticSink* m_sink = nullptr;
    };

        /// A request to compile source code to an AST + IR.
    class FrontEndCompileRequest : public CompileRequestBase
    {
    public:
            /// Note that writers can be parsed as nullptr to disable output,
            /// and individual channels set to null to disable them
        FrontEndCompileRequest(
            Linkage*        linkage,
            StdWriters*     writers, 
            DiagnosticSink* sink);

        int addEntryPoint(
            int                     translationUnitIndex,
            String const&           name,
            Profile                 entryPointProfile);

        // Translation units we are being asked to compile
        List<RefPtr<TranslationUnitRequest> > translationUnits;

        // Additional modules that needs to be made visible to `import` while checking.
        const LoadedModuleDictionary* additionalLoadedModules = nullptr;

        RefPtr<TranslationUnitRequest> getTranslationUnit(UInt index) { return translationUnits[index]; }

        // If true then generateIR will serialize out IR, and serialize back in again. Making 
        // serialization a bottleneck or firewall between the front end and the backend
        bool useSerialIRBottleneck = false; 

        // If true will serialize and de-serialize with debug information
        bool verifyDebugSerialization = false;

        CompilerOptionSet optionSet;

        List<RefPtr<FrontEndEntryPointRequest>> m_entryPointReqs;

        List<RefPtr<FrontEndEntryPointRequest>> const& getEntryPointReqs() { return m_entryPointReqs; }
        UInt getEntryPointReqCount() { return m_entryPointReqs.getCount(); }
        FrontEndEntryPointRequest* getEntryPointReq(UInt index) { return m_entryPointReqs[index]; }

        void parseTranslationUnit(
            TranslationUnitRequest* translationUnit);

        // Perform primary semantic checking on all
        // of the translation units in the program
        void checkAllTranslationUnits();

        void checkEntryPoints();

        void generateIR();

        SlangResult executeActionsInner();

            /// Add a translation unit to be compiled.
            ///
            /// @param language The source language that the translation unit will use (e.g., `SourceLanguage::Slang`
            /// @param moduleName The name that will be used for the module compile from the translation unit. 
            ///
            /// If moduleName is passed as nullptr a module name is generated.
            /// If all translation units in a compile request use automatically generated
            /// module names, then they are guaranteed not to conflict with one another.
            /// 
            /// @return The zero-based index of the translation unit in this compile request.
        int addTranslationUnit(SourceLanguage language, Name* moduleName);

        int addTranslationUnit(TranslationUnitRequest* translationUnit);

        void addTranslationUnitSourceArtifact(
            int             translationUnitIndex,
            IArtifact*      sourceArtifact);

        void addTranslationUnitSourceBlob(
            int             translationUnitIndex,
            String const&   path,
            ISlangBlob*     sourceBlob);

        void addTranslationUnitSourceFile(
            int             translationUnitIndex,
            String const&   path);

            /// Get a component type that represents the global scope of the compile request.
        ComponentType* getGlobalComponentType()  { return m_globalComponentType; }

            /// Get a component type that represents the global scope of the compile request, plus the requested entry points.
        ComponentType* getGlobalAndEntryPointsComponentType() { return m_globalAndEntryPointsComponentType; }

        List<RefPtr<ComponentType>> const& getUnspecializedEntryPoints() { return m_unspecializedEntryPoints; }

            /// Does the code we are compiling represent part of the Slang standard library?
        bool m_isStandardLibraryCode = false;

        Name* m_defaultModuleName = nullptr;

            /// The irDumpOptions
        IRDumpOptions m_irDumpOptions;

            /// An "extra" entry point that was added via a library reference
        struct ExtraEntryPointInfo
        {
            Name*   name;
            Profile profile;
            String  mangledName;
        };

            /// A list of "extra" entry points added via a library reference
        List<ExtraEntryPointInfo> m_extraEntryPoints;

    private:
            /// A component type that includes only the global scopes of the translation unit(s) that were compiled.
        RefPtr<ComponentType> m_globalComponentType;

            /// A component type that extends the global scopes with all of the entry points that were specified.
        RefPtr<ComponentType> m_globalAndEntryPointsComponentType;

        List<RefPtr<ComponentType>> m_unspecializedEntryPoints;

        RefPtr<StdWriters> m_writers;
    };

        /// A visitor for use with `ComponentType`s, allowing dispatch over the concrete subclasses.
    class ComponentTypeVisitor
    {
    public:
        // The following methods should be overriden in a concrete subclass
        // to customize how it acts on each of the concrete types of component.
        //
        // In cases where the application wants to simply "recurse" on a
        // composite, specialized, or legacy component type it can use
        // the `visitChildren` methods below.
        //
        virtual void visitEntryPoint(EntryPoint* entryPoint, EntryPoint::EntryPointSpecializationInfo* specializationInfo) = 0;
        virtual void visitModule(Module* module, Module::ModuleSpecializationInfo* specializationInfo) = 0;
        virtual void visitComposite(CompositeComponentType* composite, CompositeComponentType::CompositeSpecializationInfo* specializationInfo) = 0;
        virtual void visitSpecialized(SpecializedComponentType* specialized) = 0;
        virtual void visitTypeConformance(TypeConformance* conformance) = 0;
        virtual void visitRenamedEntryPoint(
            RenamedEntryPointComponentType* renamedEntryPoint,
            EntryPoint::EntryPointSpecializationInfo* specializationInfo) = 0;

    protected:
        // These helpers can be used to recurse into the logical children of a
        // component type, and are useful for the common case where a visitor
        // only cares about a few leaf cases.
        //
        void visitChildren(CompositeComponentType* composite, CompositeComponentType::CompositeSpecializationInfo* specializationInfo);
        void visitChildren(SpecializedComponentType* specialized);
    };

        /// A `TargetProgram` represents a `ComponentType` specialized for a particular `TargetRequest`
        ///
        /// TODO: This should probably be renamed to `TargetComponentType`.
        ///
        /// By binding a component type to a specific target, a `TargetProgram` allows
        /// for things like layout to be computed, that fundamentally depend on
        /// the choice of target.
        ///
        /// A `TargetProgram` handles request for compiled kernel code for
        /// entry point functions. In practice, kernel code can only be
        /// correctly generated when the underlying `ComponentType` is "fully linked"
        /// (has no remaining unsatisfied requirements).
        ///
    class TargetProgram : public RefObject
    {
    public:
        TargetProgram(
            ComponentType*  componentType,
            TargetRequest*  targetReq);

            /// Get the underlying program
        ComponentType* getProgram() { return m_program; }

            /// Get the underlying target
        TargetRequest* getTargetReq() { return m_targetReq; }

            /// Get the layout for the program on the target.
            ///
            /// If this is the first time the layout has been
            /// requested, report any errors that arise during
            /// layout to the given `sink`.
            ///
        ProgramLayout* getOrCreateLayout(DiagnosticSink* sink);

            /// Get the layout for the program on the target.
            ///
            /// This routine assumes that `getOrCreateLayout`
            /// has already been called previously.
            ///
        ProgramLayout* getExistingLayout()
        {
            SLANG_ASSERT(m_layout);
            return m_layout;
        }

            /// Get the compiled code for an entry point on the target.
            ///
            /// If this is the first time that code generation has
            /// been requested, report any errors that arise during
            /// code generation to the given `sink`.
            ///
        IArtifact* getOrCreateEntryPointResult(Int entryPointIndex, DiagnosticSink* sink);
        IArtifact* getOrCreateWholeProgramResult(DiagnosticSink* sink);

        IArtifact* getExistingWholeProgramResult()
        {
            return m_wholeProgramResult;
        }
            /// Get the compiled code for an entry point on the target.
            ///
            /// This routine assumes that `getOrCreateEntryPointResult`
            /// has already been called previously.
            ///
        IArtifact* getExistingEntryPointResult(Int entryPointIndex)
        {
            return m_entryPointResults[entryPointIndex];
        }

        IArtifact* _createWholeProgramResult(
            DiagnosticSink*         sink,
            EndToEndCompileRequest* endToEndReq = nullptr);

            /// Internal helper for `getOrCreateEntryPointResult`.
            ///
            /// This is used so that command-line and API-based
            /// requests for code can bottleneck through the same place.
            ///
            /// Shouldn't be called directly by most code.
            ///
        IArtifact* _createEntryPointResult(
            Int                     entryPointIndex,
            DiagnosticSink*         sink,
            EndToEndCompileRequest* endToEndReq = nullptr);

        RefPtr<IRModule> getOrCreateIRModuleForLayout(DiagnosticSink* sink);

        RefPtr<IRModule> getExistingIRModuleForLayout()
        {
            return m_irModuleForLayout;
        }

        CompilerOptionSet& getOptionSet() { return m_optionSet; }

        HLSLToVulkanLayoutOptions* getHLSLToVulkanLayoutOptions() { return m_targetReq->getHLSLToVulkanLayoutOptions(); }

    private:
        RefPtr<IRModule> createIRModuleForLayout(DiagnosticSink* sink);

        // The program being compiled or laid out
        ComponentType* m_program;

        // The target that code/layout will be generated for
        TargetRequest* m_targetReq;

        // The computed layout, if it has been generated yet
        RefPtr<ProgramLayout> m_layout;

        CompilerOptionSet m_optionSet;

        // Generated compile results for each entry point
        // in the parent `Program` (indexing matches
        // the order they are given in the `Program`)
        ComPtr<IArtifact> m_wholeProgramResult;
        List<ComPtr<IArtifact>> m_entryPointResults;

        RefPtr<IRModule> m_irModuleForLayout;
    };

        /// A back-end-specific object to track optional feaures/capabilities/extensions
        /// that are discovered to be used by a program/kernel as part of code generation.
    class ExtensionTracker : public RefObject
    {
        // TODO: The existence of this type is evidence of a design/architecture problem.
        //
        // A better formulation of things requires a few key changes:
        //
        // 1. All optional capabilities need to be enumerated as part of the `CapabilitySet`
        //  system, so that they can be reasoned about uniformly across different targets
        //  and different layers of the compiler.
        //
        // 2. The front-end should be responsible for either or both of:
        //
        //   * Checking that `public` or otherwise externally-visible items (declarations/definitions)
        //     explicitly declare the capabilities they require, and that they only ever
        //     make use of items that are comatible with those required capabilities.
        //
        //   * Inferring the capabilities required by items that are not externally visible,
        //     and attaching those capabilities explicit as a modifier or other synthesized AST node.
        //
        // 3. The capabilities required by a given `ComponentType` and its entry points should be
        // explicitly know-able, and they should be something we can compare to the capabilities
        // of a code generation target *before* back-end code generation is started. We should be
        // able to issue error messages around lacking capabilities in a way the user can understand,
        // in terms of the high-level-language entities.

    public:
    };

        /// A context for code generation in the compiler back-end
    struct CodeGenContext
    {
    public:
        typedef List<Index> EntryPointIndices;

        struct Shared
        {
        public:
            Shared(
                TargetProgram*              targetProgram,
                EntryPointIndices const&    entryPointIndices,
                DiagnosticSink*             sink,
                EndToEndCompileRequest*     endToEndReq)
                : targetProgram(targetProgram)
                , entryPointIndices(entryPointIndices)
                , sink(sink)
                , endToEndReq(endToEndReq)
            {}

//            Shared(
//                TargetProgram*              targetProgram,
//                EndToEndCompileRequest*     endToEndReq);

            TargetProgram*          targetProgram = nullptr;
            EntryPointIndices       entryPointIndices;
            DiagnosticSink*         sink = nullptr;
            EndToEndCompileRequest* endToEndReq = nullptr;
        };

        CodeGenContext(
            Shared* shared)
            : m_shared(shared)
            , m_targetFormat(shared->targetProgram->getTargetReq()->getTarget())
        {}

        CodeGenContext(
            CodeGenContext*     base,
            CodeGenTarget       targetFormat,
            ExtensionTracker*   extensionTracker = nullptr)
            : m_shared(base->m_shared)
            , m_targetFormat(targetFormat)
            , m_extensionTracker(extensionTracker)
        {}

            /// Get the diagnostic sink
        DiagnosticSink* getSink()
        {
            return m_shared->sink;
        }

        TargetProgram* getTargetProgram()
        {
            return m_shared->targetProgram;
        }

        EntryPointIndices const& getEntryPointIndices()
        {
            return m_shared->entryPointIndices;
        }

        CodeGenTarget getTargetFormat()
        {
            return m_targetFormat;
        }

        ExtensionTracker* getExtensionTracker()
        {
            return m_extensionTracker;
        }

        TargetRequest* getTargetReq()
        {
            return getTargetProgram()->getTargetReq();
        }

        CapabilitySet getTargetCaps()
        {
            return getTargetReq()->getTargetCaps();
        }

        CodeGenTarget getFinalTargetFormat()
        {
            return getTargetReq()->getTarget();
        }

        ComponentType* getProgram()
        {
            return getTargetProgram()->getProgram();
        }

        Linkage* getLinkage()
        {
            return getProgram()->getLinkage();
        }

        Session* getSession()
        {
            return getLinkage()->getSessionImpl();
        }

            /// Get the source manager
        SourceManager* getSourceManager()
        {
            return getLinkage()->getSourceManager();
        }

        ISlangFileSystemExt* getFileSystemExt()
        {
            return getLinkage()->getFileSystemExt();
        }

        EndToEndCompileRequest* isEndToEndCompile()
        {
            return m_shared->endToEndReq;
        }

        EndToEndCompileRequest* isPassThroughEnabled();

        Count getEntryPointCount()
        {
            return getEntryPointIndices().getCount();
        }

        EntryPoint* getEntryPoint(Index index)
        {
            return getProgram()->getEntryPoint(index);
        }

        Index getSingleEntryPointIndex()
        {
            SLANG_ASSERT(getEntryPointCount() == 1);
            return getEntryPointIndices()[0];
        }

        //

        IRDumpOptions getIRDumpOptions();

        bool shouldValidateIR();
        bool shouldDumpIR();

        bool shouldTrackLiveness();

        bool shouldDumpIntermediates();
        String getIntermediateDumpPrefix();

        bool getUseUnknownImageFormatAsDefault();

        bool isSpecializationDisabled();

        bool shouldSkipSPIRVValidation();

        SlangResult requireTranslationUnitSourceFiles();

        //

        SlangResult emitEntryPoints(ComPtr<IArtifact>& outArtifact);

        void maybeDumpIntermediate(IArtifact* artifact);

    protected:
        CodeGenTarget m_targetFormat = CodeGenTarget::Unknown;
        ExtensionTracker* m_extensionTracker = nullptr;

            /// Will output assembly as well as the artifact if appropriate for the artifact type for assembly output
            /// and conversion is possible
        void _dumpIntermediateMaybeWithAssembly(IArtifact* artifact);

        void _dumpIntermediate(IArtifact* artifact);
        void _dumpIntermediate(
            const ArtifactDesc& desc,
            void const* data,
            size_t      size);

        /* Emits entry point source taking into account if a pass-through or not. Uses 'targetFormat' to determine
        the target (not targetReq) */
        SlangResult emitEntryPointsSource(ComPtr<IArtifact>& outArtifact);

        SlangResult emitEntryPointsSourceFromIR(ComPtr<IArtifact>& outArtifact);
            
        SlangResult emitWithDownstreamForEntryPoints(ComPtr<IArtifact>& outArtifact);

        /* Determines a suitable filename to identify the input for a given entry point being compiled.
        If the end-to-end compile is a pass-through case, will attempt to find the (unique) source file
        pathname for the translation unit containing the entry point at `entryPointIndex.
        If the compilation is not in a pass-through case, then always returns `"slang-generated"`.
        @param endToEndReq The end-to-end compile request which might be using pass-through compilation
        @param entryPointIndex The index of the entry point to compute a filename for.
        @return the appropriate source filename */
        String calcSourcePathForEntryPoints();

        TranslationUnitRequest* findPassThroughTranslationUnit(
            Int                     entryPointIndex);


        SlangResult _emitEntryPoints(ComPtr<IArtifact>& outArtifact);

    private:
        Shared* m_shared = nullptr;
    };

        /// A compile request that spans the front and back ends of the compiler
        ///
        /// This is what the command-line `slangc` uses, as well as the legacy
        /// C API. It ties together the functionality of `Linkage`,
        /// `FrontEndCompileRequest`, and `BackEndCompileRequest`, plus a small
        /// number of additional features that primarily make sense for
        /// command-line usage.
        ///
    class EndToEndCompileRequest : public RefObject, public slang::ICompileRequest
    {
    public:
        SLANG_CLASS_GUID(0xce6d2383, 0xee1b, 0x4fd7, { 0xa0, 0xf, 0xb8, 0xb6, 0x33, 0x12, 0x95, 0xc8 })

        // ISlangUnknown
        SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface(SlangUUID const& uuid, void** outObject) SLANG_OVERRIDE;
        SLANG_REF_OBJECT_IUNKNOWN_ADD_REF
        SLANG_REF_OBJECT_IUNKNOWN_RELEASE

        // slang::ICompileRequest
        virtual SLANG_NO_THROW void SLANG_MCALL setFileSystem(ISlangFileSystem* fileSystem) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setCompileFlags(SlangCompileFlags flags) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangCompileFlags SLANG_MCALL getCompileFlags() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setDumpIntermediates(int  enable) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setDumpIntermediatePrefix(const char* prefix) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setEnableEffectAnnotations(bool value) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setLineDirectiveMode(SlangLineDirectiveMode  mode) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setCodeGenTarget(SlangCompileTarget target) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW int SLANG_MCALL addCodeGenTarget(SlangCompileTarget target) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setTargetProfile(int targetIndex, SlangProfileID profile) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setTargetFlags(int targetIndex, SlangTargetFlags flags) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setTargetFloatingPointMode(int targetIndex, SlangFloatingPointMode mode) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setTargetMatrixLayoutMode(int targetIndex, SlangMatrixLayoutMode mode) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setTargetForceGLSLScalarBufferLayout(int targetIndex, bool value) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setMatrixLayoutMode(SlangMatrixLayoutMode mode) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setDebugInfoLevel(SlangDebugInfoLevel level) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setOptimizationLevel(SlangOptimizationLevel level) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setOutputContainerFormat(SlangContainerFormat format) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setPassThrough(SlangPassThrough passThrough) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setDiagnosticCallback(SlangDiagnosticCallback callback, void const* userData) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setWriter(SlangWriterChannel channel, ISlangWriter* writer) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW ISlangWriter* SLANG_MCALL getWriter(SlangWriterChannel channel) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL addSearchPath(const char* searchDir) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL addPreprocessorDefine(const char* key, const char* value) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL processCommandLineArguments(char const* const* args, int argCount) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW int SLANG_MCALL addTranslationUnit(SlangSourceLanguage language, char const* name) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setDefaultModuleName(const char* defaultModuleName) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL addTranslationUnitPreprocessorDefine(int translationUnitIndex, const char* key, const char* value) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL addTranslationUnitSourceFile(int translationUnitIndex, char const* path) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL addTranslationUnitSourceString(int translationUnitIndex, char const* path, char const* source) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL addLibraryReference(const char* basePath, const void* libData, size_t libDataSize) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL addTranslationUnitSourceStringSpan(int translationUnitIndex, char const* path, char const* sourceBegin, char const* sourceEnd) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL addTranslationUnitSourceBlob(int translationUnitIndex, char const* path, ISlangBlob* sourceBlob) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW int SLANG_MCALL addEntryPoint(int translationUnitIndex, char const* name, SlangStage stage) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW int SLANG_MCALL addEntryPointEx(int translationUnitIndex, char const* name, SlangStage stage, int genericArgCount, char const** genericArgs) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL setGlobalGenericArgs(int genericArgCount, char const** genericArgs) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL setTypeNameForGlobalExistentialTypeParam(int slotIndex, char const* typeName) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL setTypeNameForEntryPointExistentialTypeParam(int entryPointIndex, int slotIndex, char const* typeName) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setAllowGLSLInput(bool value) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL compile() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW char const* SLANG_MCALL getDiagnosticOutput() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getDiagnosticOutputBlob(ISlangBlob** outBlob) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW int SLANG_MCALL getDependencyFileCount() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW char const* SLANG_MCALL getDependencyFilePath(int index) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW int SLANG_MCALL getTranslationUnitCount() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW char const* SLANG_MCALL getEntryPointSource(int entryPointIndex) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void const* SLANG_MCALL getEntryPointCode(int entryPointIndex, size_t* outSize) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCodeBlob(int entryPointIndex, int targetIndex, ISlangBlob** outBlob) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(int entryPointIndex, int targetIndex, ISlangSharedLibrary**   outSharedLibrary) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCodeBlob(int targetIndex, ISlangBlob** outBlob) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetHostCallable(int targetIndex, ISlangSharedLibrary** outSharedLibrary) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void const* SLANG_MCALL getCompileRequestCode(size_t* outSize) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW ISlangMutableFileSystem* SLANG_MCALL getCompileRequestResultAsFileSystem() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getContainerCode(ISlangBlob** outBlob) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadRepro(ISlangFileSystem* fileSystem, const void* data, size_t size) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL saveRepro(ISlangBlob** outBlob) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL enableReproCapture() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getProgram(slang::IComponentType** outProgram) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPoint(SlangInt entryPointIndex, slang::IComponentType** outEntryPoint) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getModule(SlangInt translationUnitIndex, slang::IModule** outModule) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getSession(slang::ISession** outSession) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangReflection* SLANG_MCALL getReflection() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setCommandLineCompilerMode() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL addTargetCapability(SlangInt targetIndex, SlangCapabilityID capability) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL getProgramWithEntryPoints(slang::IComponentType** outProgram) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangResult SLANG_MCALL isParameterLocationUsed(SlangInt entryPointIndex, SlangInt targetIndex, SlangParameterCategory category, SlangUInt spaceIndex, SlangUInt registerIndex, bool& outUsed) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setTargetLineDirectiveMode(
            SlangInt targetIndex,
            SlangLineDirectiveMode mode) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL overrideDiagnosticSeverity(
            SlangInt messageID,
            SlangSeverity overrideSeverity) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW SlangDiagnosticFlags SLANG_MCALL getDiagnosticFlags() SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setDiagnosticFlags(SlangDiagnosticFlags flags) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setDebugInfoFormat(SlangDebugInfoFormat format) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setReportDownstreamTime(bool value) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setReportPerfBenchmark(bool value) SLANG_OVERRIDE;
        virtual SLANG_NO_THROW void SLANG_MCALL setSkipSPIRVValidation(bool value) SLANG_OVERRIDE;

        void setTrackLiveness(bool v);

        EndToEndCompileRequest(
            Session* session);

        EndToEndCompileRequest(
            Linkage* linkage);

        ~EndToEndCompileRequest();

            // If enabled will emit IR 
        bool m_emitIr = false;

            // What container format are we being asked to generate?
            // If it's set to a format, the container blob will be calculated during compile
        ContainerFormat m_containerFormat = ContainerFormat::None;

            /// Where the container is stored. This is calculated as part of compile if m_containerFormat is set to
            /// a supported format. 
        ComPtr<IArtifact> m_containerArtifact;
            /// Holds the container as a file system
        ComPtr<ISlangMutableFileSystem> m_containerFileSystem;

            /// File system used by repro system if a file couldn't be found within the repro (or associated directory)
        ComPtr<ISlangFileSystem> m_reproFallbackFileSystem = ComPtr<ISlangFileSystem>(OSFileSystem::getExtSingleton());

            // Path to output container to
        String m_containerOutputPath;

        // Should we just pass the input to another compiler?
        PassThroughMode m_passThrough = PassThroughMode::None;

            /// If output should be source embedded, define the style of the embedding
        SourceEmbedUtil::Style m_sourceEmbedStyle = SourceEmbedUtil::Style::None;
            /// The language to be used for source embedding
        SourceLanguage m_sourceEmbedLanguage = SourceLanguage::C;
            /// Source embed variable name. Note may be used as a basis for names if multiple items written
        String m_sourceEmbedName;
        
            /// Source code for the specialization arguments to use for the global specialization parameters of the program.
        List<String> m_globalSpecializationArgStrings;

        // Are we being driven by the command-line `slangc`, and should act accordingly?
        bool m_isCommandLineCompile = false;
        
        String m_diagnosticOutput;

            /// A blob holding the diagnostic output
        ComPtr<ISlangBlob> m_diagnosticOutputBlob;

            /// Per-entry-point information not tracked by other compile requests
        class EntryPointInfo : public RefObject
        {
        public:
                /// Source code for the specialization arguments to use for the specialization parameters of the entry point.
            List<String> specializationArgStrings;
        };
        List<EntryPointInfo> m_entryPoints;

            /// Per-target information only needed for command-line compiles
        class TargetInfo : public RefObject
        {
        public:
            // Requested output paths for each entry point.
            // An empty string indices no output desired for
            // the given entry point.
            Dictionary<Int, String> entryPointOutputPaths;
            String wholeTargetOutputPath;
            CompilerOptionSet targetOptions;
        };
        Dictionary<TargetRequest*, RefPtr<TargetInfo>> m_targetInfos;

        CompilerOptionSet& getTargetOptionSet(TargetRequest* req);

        CompilerOptionSet& getTargetOptionSet(Index targetIndex);

        String m_dependencyOutputPath;

            /// Writes the modules in a container to the stream
        SlangResult writeContainerToStream(Stream* stream);
        
            /// If a container format has been specified produce a container (stored in m_containerBlob)
        SlangResult maybeCreateContainer();
            /// If a container has been constructed and the filename/path has contents will try to write
            /// the container contents to the file
        SlangResult maybeWriteContainer(const String& fileName);

        Linkage* getLinkage() { return m_linkage; }

        int addEntryPoint(
            int                     translationUnitIndex,
            String const&           name,
            Profile                 profile,
            List<String> const &    genericTypeNames);

        void setWriter(WriterChannel chan, ISlangWriter* writer);
        ISlangWriter* getWriter(WriterChannel chan) const { return m_writers->getWriter(SlangWriterChannel(chan)); }

            /// The end to end request can be passed as nullptr, if not driven by one
        SlangResult executeActionsInner();
        SlangResult executeActions();

        Session* getSession() { return m_session; }
        DiagnosticSink* getSink() { return &m_sink; }
        NamePool* getNamePool() { return getLinkage()->getNamePool(); }

        FrontEndCompileRequest* getFrontEndReq() { return m_frontEndReq; }

        ComponentType* getUnspecializedGlobalComponentType() { return getFrontEndReq()->getGlobalComponentType(); }
        ComponentType* getUnspecializedGlobalAndEntryPointsComponentType()
        {
            return getFrontEndReq()->getGlobalAndEntryPointsComponentType();
        }

        ComponentType* getSpecializedGlobalComponentType() { return m_specializedGlobalComponentType; }
        ComponentType* getSpecializedGlobalAndEntryPointsComponentType() { return m_specializedGlobalAndEntryPointsComponentType; }

        ComponentType* getSpecializedEntryPointComponentType(Index index)
        {
            return m_specializedEntryPoints[index];
        }
        
        void writeArtifactToStandardOutput(IArtifact* artifact, DiagnosticSink* sink);

        void generateOutput();

        CompilerOptionSet& getOptionSet() { return m_linkage->m_optionSet; }
    private:
        
        String _getWholeProgramPath(TargetRequest* targetReq);
        String _getEntryPointPath(TargetRequest* targetReq, Index entryPointIndex);

            /// Maybe write the artifact to the path (if set), or stdout (if there is no container or path)
        SlangResult _maybeWriteArtifact(const String& path, IArtifact* artifact);
        SlangResult _writeArtifact(const String& path, IArtifact* artifact);

            /// Adds any extra settings to complete a targetRequest
        void _completeTargetRequest(UInt targetIndex);
        
        ISlangUnknown* getInterface(const Guid& guid);

        void generateOutput(ComponentType* program);
        void generateOutput(TargetProgram* targetProgram);

        void init();

        Session*                        m_session = nullptr;
        RefPtr<Linkage>                 m_linkage;
        DiagnosticSink                  m_sink;
        RefPtr<FrontEndCompileRequest>  m_frontEndReq;
        RefPtr<ComponentType>           m_specializedGlobalComponentType;
        RefPtr<ComponentType>           m_specializedGlobalAndEntryPointsComponentType;
        List<RefPtr<ComponentType>>     m_specializedEntryPoints;
        
        // For output

        RefPtr<StdWriters> m_writers;
    };

    /* Returns SLANG_OK if pass through support is available */
    SlangResult checkExternalCompilerSupport(Session* session, PassThroughMode passThrough);
    /* Report an error appearing from external compiler to the diagnostic sink error to the diagnostic sink.
    @param compilerName The name of the compiler the error came for (or nullptr if not known)
    @param res Result associated with the error. The error code will be reported. (Can take HRESULT - and will expand to string if known)
    @param diagnostic The diagnostic string associated with the compile failure
    @param sink The diagnostic sink to report to */
    void reportExternalCompileError(const char* compilerName, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink);

    //

    // Information about BaseType that's useful for checking literals 
    struct BaseTypeInfo
    {
        typedef uint8_t Flags;
        struct Flag 
        {
            enum Enum : Flags
            {
                Signed = 0x1,
                FloatingPoint = 0x2,
                Integer = 0x4,
            };
        };

        SLANG_FORCE_INLINE static const BaseTypeInfo& getInfo(BaseType baseType) { return s_info[Index(baseType)]; }

        static UnownedStringSlice asText(BaseType baseType);

        uint8_t sizeInBytes;               ///< Size of type in bytes
        Flags flags;
        uint8_t baseType;

        static bool check();

    private:
        static const BaseTypeInfo s_info[Index(BaseType::CountOf)];
    };

    class CodeGenTransitionMap
    {
    public:
        struct Pair
        {
            typedef Pair ThisType;
            SLANG_FORCE_INLINE bool operator==(const ThisType& rhs) const { return source == rhs.source && target == rhs.target; }
            SLANG_FORCE_INLINE bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }

            SLANG_FORCE_INLINE HashCode getHashCode() const { return combineHash(HashCode(source), HashCode(target)); }

            CodeGenTarget source;
            CodeGenTarget target;
        };

        void removeTransition(CodeGenTarget source, CodeGenTarget target)
        {
            m_map.remove(Pair{ source, target });
        }
        void addTransition(CodeGenTarget source, CodeGenTarget target, PassThroughMode compiler)
        {
            SLANG_ASSERT(source != target);
            m_map.set(Pair{ source, target }, compiler);
        }
        bool hasTransition(CodeGenTarget source, CodeGenTarget target) const
        {
            return m_map.containsKey(Pair{ source, target });
        }
        PassThroughMode getTransition(CodeGenTarget source, CodeGenTarget target) const
        {
            const Pair pair{ source, target };
            auto value = m_map.tryGetValue(pair);
            return value ? *value : PassThroughMode::None;
        }

    protected:
        Dictionary<Pair, PassThroughMode> m_map;
    };

    class Session : public RefObject, public slang::IGlobalSession
    {
    public:
        SLANG_REF_OBJECT_IUNKNOWN_ALL

        ISlangUnknown* getInterface(const Guid& guid);

        // slang::IGlobalSession 
        SLANG_NO_THROW SlangResult SLANG_MCALL createSession(slang::SessionDesc const&  desc, slang::ISession** outSession) override;
        SLANG_NO_THROW SlangProfileID SLANG_MCALL findProfile(char const* name) override;
        SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerPath(SlangPassThrough passThrough, char const* path) override;
        SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerPrelude(SlangPassThrough inPassThrough, char const* prelude) override;
        SLANG_NO_THROW void SLANG_MCALL getDownstreamCompilerPrelude(SlangPassThrough inPassThrough, ISlangBlob** outPrelude) override;
        SLANG_NO_THROW const char* SLANG_MCALL getBuildTagString() override;
        SLANG_NO_THROW SlangResult SLANG_MCALL setDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler) override;
        SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage) override;

        SLANG_NO_THROW void SLANG_MCALL setLanguagePrelude(SlangSourceLanguage inSourceLanguage, char const* prelude) override;
        SLANG_NO_THROW void SLANG_MCALL getLanguagePrelude(SlangSourceLanguage inSourceLanguage, ISlangBlob** outPrelude) override;

        SLANG_NO_THROW SlangResult SLANG_MCALL createCompileRequest(slang::ICompileRequest** outCompileRequest) override;
        
        SLANG_NO_THROW void SLANG_MCALL addBuiltins(char const* sourcePath, char const* sourceString) override;
        SLANG_NO_THROW void SLANG_MCALL setSharedLibraryLoader(ISlangSharedLibraryLoader* loader) override;
        SLANG_NO_THROW ISlangSharedLibraryLoader* SLANG_MCALL getSharedLibraryLoader() override;
        SLANG_NO_THROW SlangResult SLANG_MCALL checkCompileTargetSupport(SlangCompileTarget target) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL checkPassThroughSupport(SlangPassThrough passThrough) override;

        SLANG_NO_THROW SlangResult SLANG_MCALL compileStdLib(slang::CompileStdLibFlags flags) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) override;
        SLANG_NO_THROW SlangResult SLANG_MCALL saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) override;

        SLANG_NO_THROW SlangCapabilityID SLANG_MCALL findCapability(char const* name) override;

        SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) override;
        SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target) override;
        SLANG_NO_THROW void SLANG_MCALL getCompilerElapsedTime(double* outTotalTime, double* outDownstreamTime) override
        {
            *outDownstreamTime = m_downstreamCompileTime;
            *outTotalTime = m_totalCompileTime;
        }