1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- B I N D O . G R A P H S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2019-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- For full architecture, see unit Bindo.
-- The following unit defines the various graphs used in determining the
-- elaboration order of units.
with Types; use Types;
with Bindo.Units; use Bindo.Units;
with GNAT; use GNAT;
with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
with GNAT.Graphs; use GNAT.Graphs;
with GNAT.Lists; use GNAT.Lists;
with GNAT.Sets; use GNAT.Sets;
package Bindo.Graphs is
---------------------------
-- Invocation graph edge --
---------------------------
-- The following type denotes an invocation graph edge handle
type Invocation_Graph_Edge_Id is new Natural;
No_Invocation_Graph_Edge : constant Invocation_Graph_Edge_Id :=
Invocation_Graph_Edge_Id'First;
First_Invocation_Graph_Edge : constant Invocation_Graph_Edge_Id :=
No_Invocation_Graph_Edge + 1;
procedure Destroy_Invocation_Graph_Edge
(Edge : in out Invocation_Graph_Edge_Id);
pragma Inline (Destroy_Invocation_Graph_Edge);
-- Destroy invocation graph edge Edge
function Hash_Invocation_Graph_Edge
(Edge : Invocation_Graph_Edge_Id) return Bucket_Range_Type;
pragma Inline (Hash_Invocation_Graph_Edge);
-- Obtain the hash value of key Edge
function Present (Edge : Invocation_Graph_Edge_Id) return Boolean;
pragma Inline (Present);
-- Determine whether invocation graph edge Edge exists
package IGE_Lists is new Doubly_Linked_Lists
(Element_Type => Invocation_Graph_Edge_Id,
"=" => "=",
Destroy_Element => Destroy_Invocation_Graph_Edge);
------------------------------
-- Invocation graph vertex --
------------------------------
-- The following type denotes an invocation graph vertex handle
type Invocation_Graph_Vertex_Id is new Natural;
No_Invocation_Graph_Vertex : constant Invocation_Graph_Vertex_Id :=
Invocation_Graph_Vertex_Id'First;
First_Invocation_Graph_Vertex : constant Invocation_Graph_Vertex_Id :=
No_Invocation_Graph_Vertex + 1;
function Hash_Invocation_Graph_Vertex
(Vertex : Invocation_Graph_Vertex_Id) return Bucket_Range_Type;
pragma Inline (Hash_Invocation_Graph_Vertex);
-- Obtain the hash value of key Vertex
function Present (Vertex : Invocation_Graph_Vertex_Id) return Boolean;
pragma Inline (Present);
-- Determine whether invocation graph vertex Vertex exists
package IGV_Sets is new Membership_Sets
(Element_Type => Invocation_Graph_Vertex_Id,
"=" => "=",
Hash => Hash_Invocation_Graph_Vertex);
-------------------------
-- Library graph cycle --
-------------------------
type Library_Graph_Cycle_Id is new Natural;
No_Library_Graph_Cycle : constant Library_Graph_Cycle_Id :=
Library_Graph_Cycle_Id'First;
First_Library_Graph_Cycle : constant Library_Graph_Cycle_Id :=
No_Library_Graph_Cycle + 1;
procedure Destroy_Library_Graph_Cycle
(Cycle : in out Library_Graph_Cycle_Id);
pragma Inline (Destroy_Library_Graph_Cycle);
-- Destroy library graph cycle Cycle
function Hash_Library_Graph_Cycle
(Cycle : Library_Graph_Cycle_Id) return Bucket_Range_Type;
pragma Inline (Hash_Library_Graph_Cycle);
-- Obtain the hash value of key Cycle
function Present (Cycle : Library_Graph_Cycle_Id) return Boolean;
pragma Inline (Present);
-- Determine whether library graph cycle Cycle exists
package LGC_Lists is new Doubly_Linked_Lists
(Element_Type => Library_Graph_Cycle_Id,
"=" => "=",
Destroy_Element => Destroy_Library_Graph_Cycle);
------------------------
-- Library graph edge --
------------------------
-- The following type denotes a library graph edge handle
type Library_Graph_Edge_Id is new Natural;
No_Library_Graph_Edge : constant Library_Graph_Edge_Id :=
Library_Graph_Edge_Id'First;
First_Library_Graph_Edge : constant Library_Graph_Edge_Id :=
No_Library_Graph_Edge + 1;
procedure Destroy_Library_Graph_Edge
(Edge : in out Library_Graph_Edge_Id);
pragma Inline (Destroy_Library_Graph_Edge);
-- Destroy library graph edge Edge
function Hash_Library_Graph_Edge
(Edge : Library_Graph_Edge_Id) return Bucket_Range_Type;
pragma Inline (Hash_Library_Graph_Edge);
-- Obtain the hash value of key Edge
function Present (Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Present);
-- Determine whether library graph edge Edge exists
package LGE_Lists is new Doubly_Linked_Lists
(Element_Type => Library_Graph_Edge_Id,
"=" => "=",
Destroy_Element => Destroy_Library_Graph_Edge);
package LGE_Sets is new Membership_Sets
(Element_Type => Library_Graph_Edge_Id,
"=" => "=",
Hash => Hash_Library_Graph_Edge);
--------------------------
-- Library graph vertex --
--------------------------
-- The following type denotes a library graph vertex handle
type Library_Graph_Vertex_Id is new Natural;
No_Library_Graph_Vertex : constant Library_Graph_Vertex_Id :=
Library_Graph_Vertex_Id'First;
First_Library_Graph_Vertex : constant Library_Graph_Vertex_Id :=
No_Library_Graph_Vertex + 1;
procedure Destroy_Library_Graph_Vertex
(Vertex : in out Library_Graph_Vertex_Id);
pragma Inline (Destroy_Library_Graph_Vertex);
-- Destroy library graph vertex Vertex
function Hash_Library_Graph_Vertex
(Vertex : Library_Graph_Vertex_Id) return Bucket_Range_Type;
pragma Inline (Hash_Library_Graph_Vertex);
-- Obtain the hash value of key Vertex
function Present (Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Present);
-- Determine whether library graph vertex Vertex exists
package LGV_Lists is new Doubly_Linked_Lists
(Element_Type => Library_Graph_Vertex_Id,
"=" => "=",
Destroy_Element => Destroy_Library_Graph_Vertex);
package LGV_Sets is new Membership_Sets
(Element_Type => Library_Graph_Vertex_Id,
"=" => "=",
Hash => Hash_Library_Graph_Vertex);
--------------------
-- Library_Graphs --
--------------------
package Library_Graphs is
-- The following type represents the various kinds of library graph
-- cycles. The ordering of kinds is significant, where a literal with
-- lower ordinal has a higher precedence than one with higher ordinal.
type Library_Graph_Cycle_Kind is
(Elaborate_Body_Cycle,
-- A cycle that involves at least one spec-body pair, where the
-- spec is subject to pragma Elaborate_Body. This is the highest
-- precedence cycle.
Elaborate_Cycle,
-- A cycle that involves at least one Elaborate edge
Elaborate_All_Cycle,
-- A cycle that involves at least one Elaborate_All edge
Forced_Cycle,
-- A cycle that involves at least one edge which is a byproduct of
-- the forced-elaboration-order file.
Invocation_Cycle,
-- A cycle that involves at least one invocation edge. This is the
-- lowest precedence cycle.
No_Cycle_Kind);
-- The following type represents the various kinds of library edges. The
-- order is important here, and corresponds to the order in which edges
-- are added to the graph. See Add_Edge_Kind_Check for details. If
-- changes are made such that new edge kinds are added or similar, we
-- need to make sure this type matches the code in Add_Edge_Kind_Check,
-- and Add_Edge_Kind_Check matches the order of edge adding. Likewise,
-- if the edge-adding order changes, we need consistency between this
-- enumeration type, the edge-adding order, and Add_Edge_Kind_Check.
type Library_Graph_Edge_Kind is
(Spec_Before_Body_Edge,
-- Successor denotes a body, Predecessor denotes a spec
Elaborate_Edge,
-- Successor withs Predecessor, and has pragma Elaborate for it
Elaborate_All_Edge,
-- Successor withs Predecessor, and has pragma Elaborate_All for it
With_Edge,
-- Successor withs Predecessor
Forced_Edge,
-- Successor is forced to with Predecessor by virtue of an existing
-- elaboration order provided in a file.
Invocation_Edge,
-- An invocation construct in unit Successor invokes a target in unit
-- Predecessor.
Body_Before_Spec_Edge,
-- Successor denotes spec, Predecessor denotes a body. This is a
-- special edge kind used only during the discovery of components.
-- Note that a body can never be elaborated before its spec.
No_Edge);
-----------
-- Graph --
-----------
-- The following type denotes a library graph handle. Each instance must
-- be created using routine Create.
type Library_Graph is private;
Nil : constant Library_Graph;
type LGE_Predicate_Ptr is access function
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
type LGV_Comparator_Ptr is access function
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Compared_To : Library_Graph_Vertex_Id) return Precedence_Kind;
type LGV_Predicate_Ptr is access function
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
----------------------
-- Graph operations --
----------------------
procedure Add_Edge
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id;
Kind : Library_Graph_Edge_Kind;
Activates_Task : Boolean);
pragma Inline (Add_Edge);
-- Create a new edge in library graph G with source vertex Pred and
-- destination vertex Succ. Kind denotes the nature of the edge. Flag
-- Activates_Task should be set when the edge involves task activation.
procedure Add_Vertex
(G : Library_Graph;
U_Id : Unit_Id);
pragma Inline (Add_Vertex);
-- Create a new vertex in library graph G. U_Id is the unit the vertex
-- describes.
function Create
(Initial_Vertices : Positive;
Initial_Edges : Positive) return Library_Graph;
pragma Inline (Create);
-- Create a new empty graph with vertex capacity Initial_Vertices and
-- edge capacity Initial_Edges.
procedure Destroy (G : in out Library_Graph);
pragma Inline (Destroy);
-- Destroy the contents of library graph G, rendering it unusable
procedure Find_Components (G : Library_Graph);
pragma Inline (Find_Components);
-- Find all components in library graph G
procedure Find_Cycles (G : Library_Graph);
pragma Inline (Find_Cycles);
-- Find all cycles in library graph G
function Highest_Precedence_Cycle
(G : Library_Graph) return Library_Graph_Cycle_Id;
pragma Inline (Highest_Precedence_Cycle);
-- Obtain the cycle with highest precedence among all other cycles of
-- library graph G.
function Present (G : Library_Graph) return Boolean;
pragma Inline (Present);
-- Determine whether library graph G exists
-----------------------
-- Vertex attributes --
-----------------------
function Component
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Component_Id;
pragma Inline (Component);
-- Obtain the component where vertex Vertex of library graph G resides
function Corresponding_Item
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Library_Graph_Vertex_Id;
pragma Inline (Corresponding_Item);
-- Obtain the complementary vertex which represents the corresponding
-- spec or body of vertex Vertex of library graph G.
function Corresponding_Vertex
(G : Library_Graph;
U_Id : Unit_Id) return Library_Graph_Vertex_Id;
pragma Inline (Corresponding_Vertex);
-- Obtain the corresponding vertex of library graph G which represents
-- unit U_Id.
procedure Decrement_Pending_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Edge : Library_Graph_Edge_Id);
pragma Inline (Decrement_Pending_Predecessors);
-- Decrease the number of pending predecessors vertex Vertex which was
-- reached via edge Edge of library graph G must wait until it can be
-- elaborated.
function File_Name
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return File_Name_Type;
pragma Inline (File_Name);
-- Obtain the name of the file where vertex Vertex of library graph G
-- resides.
function In_Elaboration_Order
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (In_Elaboration_Order);
-- Determine whether vertex Vertex of library graph G is already in some
-- elaboration order.
function Invocation_Graph_Encoding
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id)
return Invocation_Graph_Encoding_Kind;
pragma Inline (Invocation_Graph_Encoding);
-- Obtain the encoding format used to capture information related to
-- invocation vertices and edges that reside within vertex Vertex of
-- library graph G.
function Name
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Unit_Name_Type;
pragma Inline (Name);
-- Obtain the name of the unit which vertex Vertex of library graph G
-- represents.
procedure Pending_Predecessors_For_Elaboration
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Strong_Preds : out Natural;
Weak_Preds : out Natural);
pragma Inline (Pending_Predecessors_For_Elaboration);
-- Obtain the number of pending strong and weak predecessors of vertex
-- Vertex of library graph G, taking into account Elaborate_Body pairs.
-- Strong predecessors are returned in Strong_Preds. Weak predecessors
-- are returned in Weak_Preds.
function Pending_Strong_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Natural;
pragma Inline (Pending_Strong_Predecessors);
-- Obtain the number of pending strong predecessors vertex Vertex of
-- library graph G must wait on until it can be elaborated.
function Pending_Weak_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Natural;
pragma Inline (Pending_Weak_Predecessors);
-- Obtain the number of pending weak predecessors vertex Vertex of
-- library graph G must wait on until it can be elaborated.
procedure Set_Corresponding_Item
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Val : Library_Graph_Vertex_Id);
pragma Inline (Set_Corresponding_Item);
-- Set the complementary vertex which represents the corresponding
-- spec or body of vertex Vertex of library graph G to value Val.
procedure Set_In_Elaboration_Order
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Val : Boolean := True);
pragma Inline (Set_In_Elaboration_Order);
-- Mark vertex Vertex of library graph G as included in some elaboration
-- order depending on value Val.
function Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Unit_Id;
pragma Inline (Unit);
-- Obtain the unit vertex Vertex of library graph G represents
---------------------
-- Edge attributes --
---------------------
function Activates_Task
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Activates_Task);
-- Determine whether edge Edge of library graph G activates a task
function Kind
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Edge_Kind;
pragma Inline (Kind);
-- Obtain the nature of edge Edge of library graph G
function Predecessor
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Vertex_Id;
pragma Inline (Predecessor);
-- Obtain the predecessor vertex of edge Edge of library graph G
function Successor
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Vertex_Id;
pragma Inline (Successor);
-- Obtain the successor vertex of edge Edge of library graph G
--------------------------
-- Component attributes --
--------------------------
procedure Decrement_Pending_Predecessors
(G : Library_Graph;
Comp : Component_Id;
Edge : Library_Graph_Edge_Id);
pragma Inline (Decrement_Pending_Predecessors);
-- Decrease the number of pending predecessors component Comp which was
-- reached via edge Edge of library graph G must wait on until it can be
-- elaborated.
function Pending_Strong_Predecessors
(G : Library_Graph;
Comp : Component_Id) return Natural;
pragma Inline (Pending_Strong_Predecessors);
-- Obtain the number of pending strong predecessors component Comp of
-- library graph G must wait on until it can be elaborated.
function Pending_Weak_Predecessors
(G : Library_Graph;
Comp : Component_Id) return Natural;
pragma Inline (Pending_Weak_Predecessors);
-- Obtain the number of pending weak predecessors component Comp of
-- library graph G must wait on until it can be elaborated.
----------------------
-- Cycle attributes --
----------------------
function Invocation_Edge_Count
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Natural;
pragma Inline (Invocation_Edge_Count);
-- Obtain the number of invocation edges in cycle Cycle of library
-- graph G.
function Kind
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Library_Graph_Cycle_Kind;
pragma Inline (Kind);
-- Obtain the nature of cycle Cycle of library graph G
function Length
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Natural;
pragma Inline (Length);
-- Obtain the length of cycle Cycle of library graph G
---------------
-- Semantics --
---------------
function Complementary_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Force_Complement : Boolean) return Library_Graph_Vertex_Id;
pragma Inline (Complementary_Vertex);
-- Obtain the complementary vertex of vertex Vertex of library graph G
-- as follows:
--
-- * If Vertex is the spec of an Elaborate_Body pair, return the body
-- * If Vertex is the body of an Elaborate_Body pair, return the spec
--
-- This behavior can be forced by setting flag Force_Complement to True.
function Contains_Elaborate_All_Edge
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Boolean;
pragma Inline (Contains_Elaborate_All_Edge);
-- Determine whether cycle Cycle of library graph G contains an
-- Elaborate_All edge.
function Contains_Static_Successor_Edge
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Boolean;
pragma Inline (Contains_Static_Successor_Edge);
-- Determine whether cycle Cycle of library graph G contains an edge
-- where the successor was compiled using the static model.
function Contains_Task_Activation
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Boolean;
pragma Inline (Contains_Task_Activation);
-- Determine whether cycle Cycle of library graph G contains an
-- invocation edge where the path it represents involves a task
-- activation.
function Has_Elaborate_All_Cycle (G : Library_Graph) return Boolean;
pragma Inline (Has_Elaborate_All_Cycle);
-- Determine whether library graph G contains a cycle involving pragma
-- Elaborate_All.
function Has_No_Elaboration_Code
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Has_No_Elaboration_Code);
-- Determine whether vertex Vertex of library graph G represents a unit
-- that lacks elaboration code.
function In_Same_Component
(G : Library_Graph;
Left : Library_Graph_Vertex_Id;
Right : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (In_Same_Component);
-- Determine whether vertices Left and Right of library graph G reside
-- in the same component.
function Is_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Body);
-- Determine whether vertex Vertex of library graph G denotes a body
function Is_Body_Of_Spec_With_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Body_Of_Spec_With_Elaborate_Body);
-- Determine whether vertex Vertex of library graph G denotes a body
-- with a corresponding spec, and the spec has pragma Elaborate_Body.
function Is_Body_With_Spec
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Body_With_Spec);
-- Determine whether vertex Vertex of library graph G denotes a body
-- with a corresponding spec.
function Is_Dynamically_Elaborated
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Dynamically_Elaborated);
-- Determine whether vertex Vertex of library graph G was compiled
-- using the dynamic model.
function Is_Elaborable_Component
(G : Library_Graph;
Comp : Component_Id) return Boolean;
pragma Inline (Is_Elaborable_Component);
-- Determine whether component Comp of library graph G is not waiting on
-- any predecessors, and can thus be elaborated.
function Is_Elaborable_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Elaborable_Vertex);
-- Determine whether vertex Vertex of library graph G is not waiting on
-- any predecessors, and can thus be elaborated.
function Is_Elaborate_All_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Elaborate_All_Edge);
-- Determine whether edge Edge of library graph G is an edge whose
-- predecessor is subject to pragma Elaborate_All.
function Is_Elaborate_Body_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Elaborate_Body_Edge);
-- Determine whether edge Edge of library graph G has a successor
-- that is either a spec subject to pragma Elaborate_Body, or a body
-- that completes such a spec.
function Is_Elaborate_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Elaborate_Edge);
-- Determine whether edge Edge of library graph G is an edge whose
-- predecessor is subject to pragma Elaborate.
function Is_Elaborate_Body_Pair
(G : Library_Graph;
Spec_Vertex : Library_Graph_Vertex_Id;
Body_Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Elaborate_Body_Pair);
-- Determine whether vertices Spec_Vertex and Body_Vertex of library
-- graph G denote a spec subject to Elaborate_Body and its completing
-- body.
function Is_Forced_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Forced_Edge);
-- Determine whether edge Edge of library graph G is a byproduct of the
-- forced-elaboration-order file.
function Is_Internal_Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Internal_Unit);
-- Determine whether vertex Vertex of library graph G denotes an
-- internal unit.
function Is_Invocation_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Invocation_Edge);
-- Determine whether edge Edge of library graph G came from the
-- traversal of the invocation graph.
function Is_Predefined_Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Predefined_Unit);
-- Determine whether vertex Vertex of library graph G denotes a
-- predefined unit.
function Is_Preelaborated_Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Preelaborated_Unit);
-- Determine whether vertex Vertex of library graph G denotes a unit
-- subject to pragma Pure or Preelaborable.
function Is_Spec
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Spec);
-- Determine whether vertex Vertex of library graph G denotes a spec
function Is_Spec_Before_Body_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Spec_Before_Body_Edge);
-- Determine whether edge Edge of library graph G links a predecessor
-- spec and a successor body belonging to the same unit.
function Is_Spec_With_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Spec_With_Body);
-- Determine whether vertex Vertex of library graph G denotes a spec
-- with a corresponding body.
function Is_Spec_With_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Spec_With_Elaborate_Body);
-- Determine whether vertex Vertex of library graph G denotes a spec
-- with a corresponding body, and is subject to pragma Elaborate_Body.
function Is_Weakly_Elaborable_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Weakly_Elaborable_Vertex);
-- Determine whether vertex Vertex of library graph G is waiting on
-- weak predecessors only, in which case it can be elaborated assuming
-- that the weak edges will not be exercised at elaboration time.
function Is_With_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_With_Edge);
-- Determine whether edge Edge of library graph G is the result of a
-- with dependency between its successor and predecessor.
function Needs_Elaboration
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Needs_Elaboration);
-- Determine whether vertex Vertex of library graph G represents a unit
-- that needs to be elaborated.
function Proper_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Library_Graph_Vertex_Id;
pragma Inline (Proper_Body);
-- Obtain the body of vertex Vertex of library graph G
function Proper_Spec
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Library_Graph_Vertex_Id;
pragma Inline (Proper_Spec);
-- Obtain the spec of vertex Vertex of library graph G
----------------
-- Statistics --
----------------
function Library_Graph_Edge_Count
(G : Library_Graph;
Kind : Library_Graph_Edge_Kind) return Natural;
pragma Inline (Library_Graph_Edge_Count);
-- Obtain the total number of edges of kind Kind in library graph G
function Number_Of_Component_Vertices
(G : Library_Graph;
Comp : Component_Id) return Natural;
pragma Inline (Number_Of_Component_Vertices);
-- Obtain the total number of vertices component Comp of library graph
-- contains.
function Number_Of_Components (G : Library_Graph) return Natural;
pragma Inline (Number_Of_Components);
-- Obtain the total number of components in library graph G
function Number_Of_Cycles (G : Library_Graph) return Natural;
pragma Inline (Number_Of_Cycles);
-- Obtain the total number of cycles in library graph G
function Number_Of_Edges (G : Library_Graph) return Natural;
pragma Inline (Number_Of_Edges);
-- Obtain the total number of edges in library graph G
function Number_Of_Edges_To_Successors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Natural;
pragma Inline (Number_Of_Edges_To_Successors);
-- Obtain the total number of edges to successors vertex Vertex of
-- library graph G has.
function Number_Of_Vertices (G : Library_Graph) return Natural;
pragma Inline (Number_Of_Vertices);
-- Obtain the total number of vertices in library graph G
---------------
-- Iterators --
---------------
-- The following type represents an iterator over all cycles of a
-- library graph.
type All_Cycle_Iterator is private;
function Has_Next (Iter : All_Cycle_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more cycles to examine
function Iterate_All_Cycles
(G : Library_Graph) return All_Cycle_Iterator;
pragma Inline (Iterate_All_Cycles);
-- Obtain an iterator over all cycles of library graph G
procedure Next
(Iter : in out All_Cycle_Iterator;
Cycle : out Library_Graph_Cycle_Id);
pragma Inline (Next);
-- Return the current cycle referenced by iterator Iter and advance to
-- the next available cycle.
-- The following type represents an iterator over all edges of a library
-- graph.
type All_Edge_Iterator is private;
function Has_Next (Iter : All_Edge_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more edges to examine
function Iterate_All_Edges (G : Library_Graph) return All_Edge_Iterator;
pragma Inline (Iterate_All_Edges);
-- Obtain an iterator over all edges of library graph G
procedure Next
(Iter : in out All_Edge_Iterator;
Edge : out Library_Graph_Edge_Id);
pragma Inline (Next);
-- Return the current edge referenced by iterator Iter and advance to
-- the next available edge.
-- The following type represents an iterator over all vertices of a
-- library graph.
type All_Vertex_Iterator is private;
function Has_Next (Iter : All_Vertex_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more vertices to examine
function Iterate_All_Vertices
(G : Library_Graph) return All_Vertex_Iterator;
pragma Inline (Iterate_All_Vertices);
-- Obtain an iterator over all vertices of library graph G
procedure Next
(Iter : in out All_Vertex_Iterator;
Vertex : out Library_Graph_Vertex_Id);
pragma Inline (Next);
-- Return the current vertex referenced by iterator Iter and advance
-- to the next available vertex.
-- The following type represents an iterator over all components of a
-- library graph.
type Component_Iterator is private;
function Has_Next (Iter : Component_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more components to examine
function Iterate_Components
(G : Library_Graph) return Component_Iterator;
pragma Inline (Iterate_Components);
-- Obtain an iterator over all components of library graph G
procedure Next
(Iter : in out Component_Iterator;
Comp : out Component_Id);
pragma Inline (Next);
-- Return the current component referenced by iterator Iter and advance
-- to the next available component.
-- The following type represents an iterator over all vertices of a
-- component.
type Component_Vertex_Iterator is private;
function Has_Next (Iter : Component_Vertex_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more vertices to examine
function Iterate_Component_Vertices
(G : Library_Graph;
Comp : Component_Id) return Component_Vertex_Iterator;
pragma Inline (Iterate_Component_Vertices);
-- Obtain an iterator over all vertices of component Comp of library
-- graph G.
procedure Next
(Iter : in out Component_Vertex_Iterator;
Vertex : out Library_Graph_Vertex_Id);
pragma Inline (Next);
-- Return the current vertex referenced by iterator Iter and advance
-- to the next available vertex.
-- The following type represents an iterator over all edges that form a
-- cycle.
type Edges_Of_Cycle_Iterator is private;
function Has_Next (Iter : Edges_Of_Cycle_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more edges to examine
function Iterate_Edges_Of_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Edges_Of_Cycle_Iterator;
pragma Inline (Iterate_Edges_Of_Cycle);
-- Obtain an iterator over all edges that form cycle Cycle of library
-- graph G.
procedure Next
(Iter : in out Edges_Of_Cycle_Iterator;
Edge : out Library_Graph_Edge_Id);
pragma Inline (Next);
-- Return the current edge referenced by iterator Iter and advance to
-- the next available edge.
-- The following type represents an iterator over all edges that reach
-- successors starting from a particular predecessor vertex.
type Edges_To_Successors_Iterator is private;
function Has_Next (Iter : Edges_To_Successors_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more edges to examine
function Iterate_Edges_To_Successors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Edges_To_Successors_Iterator;
pragma Inline (Iterate_Edges_To_Successors);
-- Obtain an iterator over all edges to successors with predecessor
-- vertex Vertex of library graph G.
procedure Next
(Iter : in out Edges_To_Successors_Iterator;
Edge : out Library_Graph_Edge_Id);
pragma Inline (Next);
-- Return the current edge referenced by iterator Iter and advance to
-- the next available edge.
private
--------------
-- Vertices --
--------------
-- The following type represents the attributes of a library graph
-- vertex.
type Library_Graph_Vertex_Attributes is record
Corresponding_Item : Library_Graph_Vertex_Id :=
No_Library_Graph_Vertex;
-- The reference to the corresponding spec or body. This attribute is
-- set as follows:
--
-- * If predicate Is_Body_With_Spec is True, the reference denotes
-- the corresponding spec.
--
-- * If predicate Is_Spec_With_Body is True, the reference denotes
-- the corresponding body.
--
-- * Otherwise the attribute remains empty.
In_Elaboration_Order : Boolean := False;
-- Set when this vertex is elaborated
Pending_Strong_Predecessors : Natural := 0;
-- The number of pending strong predecessor vertices this vertex must
-- wait on before it can be elaborated.
Pending_Weak_Predecessors : Natural := 0;
-- The number of weak predecessor vertices this vertex must wait on
-- before it can be elaborated.
Unit : Unit_Id := No_Unit_Id;
-- The reference to unit this vertex represents
end record;
No_Library_Graph_Vertex_Attributes :
constant Library_Graph_Vertex_Attributes :=
(Corresponding_Item => No_Library_Graph_Vertex,
In_Elaboration_Order => False,
Pending_Strong_Predecessors => 0,
Pending_Weak_Predecessors => 0,
Unit => No_Unit_Id);
procedure Destroy_Library_Graph_Vertex_Attributes
(Attrs : in out Library_Graph_Vertex_Attributes);
pragma Inline (Destroy_Library_Graph_Vertex_Attributes);
-- Destroy the contents of attributes Attrs
package LGV_Tables is new Dynamic_Hash_Tables
(Key_Type => Library_Graph_Vertex_Id,
Value_Type => Library_Graph_Vertex_Attributes,
No_Value => No_Library_Graph_Vertex_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Library_Graph_Vertex_Attributes,
Hash => Hash_Library_Graph_Vertex);
-----------
-- Edges --
-----------
-- The following type represents the attributes of a library graph edge
type Library_Graph_Edge_Attributes is record
Activates_Task : Boolean := False;
-- Set for an invocation edge, where at least one of the paths the
-- edge represents activates a task.
Kind : Library_Graph_Edge_Kind := No_Edge;
-- The nature of the library graph edge
end record;
No_Library_Graph_Edge_Attributes :
constant Library_Graph_Edge_Attributes :=
(Activates_Task => False,
Kind => No_Edge);
procedure Destroy_Library_Graph_Edge_Attributes
(Attrs : in out Library_Graph_Edge_Attributes);
pragma Inline (Destroy_Library_Graph_Edge_Attributes);
-- Destroy the contents of attributes Attrs
package LGE_Tables is new Dynamic_Hash_Tables
(Key_Type => Library_Graph_Edge_Id,
Value_Type => Library_Graph_Edge_Attributes,
No_Value => No_Library_Graph_Edge_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Library_Graph_Edge_Attributes,
Hash => Hash_Library_Graph_Edge);
----------------
-- Components --
----------------
-- The following type represents the attributes of a component
type Component_Attributes is record
Pending_Strong_Predecessors : Natural := 0;
-- The number of pending strong predecessor components this component
-- must wait on before it can be elaborated.
Pending_Weak_Predecessors : Natural := 0;
-- The number of pending weak predecessor components this component
-- must wait on before it can be elaborated.
end record;
No_Component_Attributes : constant Component_Attributes :=
(Pending_Strong_Predecessors => 0,
Pending_Weak_Predecessors => 0);
procedure Destroy_Component_Attributes
(Attrs : in out Component_Attributes);
pragma Inline (Destroy_Component_Attributes);
-- Destroy the contents of attributes Attrs
package Component_Tables is new Dynamic_Hash_Tables
(Key_Type => Component_Id,
Value_Type => Component_Attributes,
No_Value => No_Component_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Component_Attributes,
Hash => Hash_Component);
------------
-- Cycles --
------------
-- The following type represents the attributes of a cycle
type Library_Graph_Cycle_Attributes is record
Invocation_Edge_Count : Natural := 0;
-- The number of invocation edges within the cycle
Kind : Library_Graph_Cycle_Kind := No_Cycle_Kind;
-- The nature of the cycle
Path : LGE_Lists.Doubly_Linked_List := LGE_Lists.Nil;
-- The path of edges that form the cycle
end record;
No_Library_Graph_Cycle_Attributes :
constant Library_Graph_Cycle_Attributes :=
(Invocation_Edge_Count => 0,
Kind => No_Cycle_Kind,
Path => LGE_Lists.Nil);
procedure Destroy_Library_Graph_Cycle_Attributes
(Attrs : in out Library_Graph_Cycle_Attributes);
pragma Inline (Destroy_Library_Graph_Cycle_Attributes);
-- Destroy the contents of attributes Attrs
function Hash_Library_Graph_Cycle_Attributes
(Attrs : Library_Graph_Cycle_Attributes) return Bucket_Range_Type;
pragma Inline (Hash_Library_Graph_Cycle_Attributes);
-- Obtain the hash of key Attrs
function Same_Library_Graph_Cycle_Attributes
(Left : Library_Graph_Cycle_Attributes;
Right : Library_Graph_Cycle_Attributes) return Boolean;
pragma Inline (Same_Library_Graph_Cycle_Attributes);
-- Determine whether cycle attributes Left and Right are the same
package LGC_Tables is new Dynamic_Hash_Tables
(Key_Type => Library_Graph_Cycle_Id,
Value_Type => Library_Graph_Cycle_Attributes,
No_Value => No_Library_Graph_Cycle_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Library_Graph_Cycle_Attributes,
Hash => Hash_Library_Graph_Cycle);
--------------------
-- Recorded edges --
--------------------
-- The following type represents a relation between a predecessor and
-- successor vertices.
type Predecessor_Successor_Relation is record
Predecessor : Library_Graph_Vertex_Id := No_Library_Graph_Vertex;
-- The source vertex
Successor : Library_Graph_Vertex_Id := No_Library_Graph_Vertex;
-- The destination vertex
end record;
No_Predecessor_Successor_Relation :
constant Predecessor_Successor_Relation :=
(Predecessor => No_Library_Graph_Vertex,
Successor => No_Library_Graph_Vertex);
function Hash_Predecessor_Successor_Relation
(Rel : Predecessor_Successor_Relation) return Bucket_Range_Type;
pragma Inline (Hash_Predecessor_Successor_Relation);
-- Obtain the hash value of key Rel
package RE_Sets is new Membership_Sets
(Element_Type => Predecessor_Successor_Relation,
"=" => "=",
Hash => Hash_Predecessor_Successor_Relation);
----------------
-- Statistics --
----------------
type Library_Graph_Edge_Counts is
array (Library_Graph_Edge_Kind) of Natural;
-----------
-- Units --
-----------
package Unit_Tables is new Dynamic_Hash_Tables
(Key_Type => Unit_Id,
Value_Type => Library_Graph_Vertex_Id,
No_Value => No_Library_Graph_Vertex,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Library_Graph_Vertex,
Hash => Hash_Unit);
-----------
-- Graph --
-----------
package DG is new Directed_Graphs
(Vertex_Id => Library_Graph_Vertex_Id,
No_Vertex => No_Library_Graph_Vertex,
Hash_Vertex => Hash_Library_Graph_Vertex,
Same_Vertex => "=",
Edge_Id => Library_Graph_Edge_Id,
No_Edge => No_Library_Graph_Edge,
Hash_Edge => Hash_Library_Graph_Edge,
Same_Edge => "=");
-- The following type represents the attributes of a library graph
type Library_Graph_Attributes is record
Component_Attributes : Component_Tables.Dynamic_Hash_Table :=
Component_Tables.Nil;
-- The map of component -> component attributes for all components in
-- the graph.
Counts : Library_Graph_Edge_Counts := (others => 0);
-- Edge statistics
Cycle_Attributes : LGC_Tables.Dynamic_Hash_Table := LGC_Tables.Nil;
-- The map of cycle -> cycle attributes for all cycles in the graph
Cycles : LGC_Lists.Doubly_Linked_List := LGC_Lists.Nil;
-- The list of all cycles in the graph, sorted based on precedence
Edge_Attributes : LGE_Tables.Dynamic_Hash_Table := LGE_Tables.Nil;
-- The map of edge -> edge attributes for all edges in the graph
Graph : DG.Directed_Graph := DG.Nil;
-- The underlying graph describing the relations between edges and
-- vertices.
Recorded_Edges : RE_Sets.Membership_Set := RE_Sets.Nil;
-- The set of recorded edges, used to prevent duplicate edges in the
-- graph.
Unit_To_Vertex : Unit_Tables.Dynamic_Hash_Table := Unit_Tables.Nil;
-- The map of unit -> vertex
Vertex_Attributes : LGV_Tables.Dynamic_Hash_Table := LGV_Tables.Nil;
-- The map of vertex -> vertex attributes for all vertices in the
-- graph.
end record;
type Library_Graph is access Library_Graph_Attributes;
Nil : constant Library_Graph := null;
---------------
-- Iterators --
---------------
type All_Cycle_Iterator is new LGC_Lists.Iterator;
type All_Edge_Iterator is new DG.All_Edge_Iterator;
type All_Vertex_Iterator is new DG.All_Vertex_Iterator;
type Component_Iterator is new DG.Component_Iterator;
type Component_Vertex_Iterator is new DG.Component_Vertex_Iterator;
type Edges_Of_Cycle_Iterator is new LGE_Lists.Iterator;
type Edges_To_Successors_Iterator is new DG.Outgoing_Edge_Iterator;
end Library_Graphs;
-----------------------
-- Invocation_Graphs --
-----------------------
package Invocation_Graphs is
-----------
-- Graph --
-----------
-- The following type denotes an invocation graph handle. Each instance
-- must be created using routine Create.
type Invocation_Graph is private;
Nil : constant Invocation_Graph;
----------------------
-- Graph operations --
----------------------
procedure Add_Edge
(G : Invocation_Graph;
Source : Invocation_Graph_Vertex_Id;
Target : Invocation_Graph_Vertex_Id;
IR_Id : Invocation_Relation_Id);
pragma Inline (Add_Edge);
-- Create a new edge in invocation graph G with source vertex Source and
-- destination vertex Target. IR_Id is the invocation relation the edge
-- describes.
procedure Add_Vertex
(G : Invocation_Graph;
IC_Id : Invocation_Construct_Id;
Body_Vertex : Library_Graph_Vertex_Id;
Spec_Vertex : Library_Graph_Vertex_Id);
pragma Inline (Add_Vertex);
-- Create a new vertex in invocation graph G. IC_Id is the invocation
-- construct the vertex describes. Body_Vertex denotes the library graph
-- vertex where the invocation construct's body is declared. Spec_Vertex
-- is the library graph vertex where the invocation construct's spec is
-- declared.
function Create
(Initial_Vertices : Positive;
Initial_Edges : Positive;
Lib_Graph : Library_Graphs.Library_Graph)
return Invocation_Graph;
pragma Inline (Create);
-- Create a new empty graph with vertex capacity Initial_Vertices
-- and edge capacity Initial_Edges. Lib_Graph is the library graph
-- corresponding to this invocation graph.
function Get_Lib_Graph
(G : Invocation_Graph) return Library_Graphs.Library_Graph;
pragma Inline (Get_Lib_Graph);
-- Return the library graph corresponding to this invocation graph
procedure Destroy (G : in out Invocation_Graph);
pragma Inline (Destroy);
-- Destroy the contents of invocation graph G, rendering it unusable
function Present (G : Invocation_Graph) return Boolean;
pragma Inline (Present);
-- Determine whether invocation graph G exists
-----------------------
-- Vertex attributes --
-----------------------
function Body_Vertex
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Library_Graph_Vertex_Id;
pragma Inline (Body_Vertex);
-- Obtain the library graph vertex where the body of the invocation
-- construct represented by vertex Vertex of invocation graph G is
-- declared.
function Column
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Nat;
pragma Inline (Column);
-- Obtain the column number where the invocation construct vertex Vertex
-- of invocation graph G describes.
function Construct
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Invocation_Construct_Id;
pragma Inline (Construct);
-- Obtain the invocation construct vertex Vertex of invocation graph G
-- describes.
function Corresponding_Vertex
(G : Invocation_Graph;
IS_Id : Invocation_Signature_Id) return Invocation_Graph_Vertex_Id;
pragma Inline (Corresponding_Vertex);
-- Obtain the vertex of invocation graph G that corresponds to signature
-- IS_Id.
function Line
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Nat;
pragma Inline (Line);
-- Obtain the line number where the invocation construct vertex Vertex
-- of invocation graph G describes.
function Name
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Name_Id;
pragma Inline (Name);
-- Obtain the name of the construct vertex Vertex of invocation graph G
-- describes.
function Spec_Vertex
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Library_Graph_Vertex_Id;
pragma Inline (Spec_Vertex);
-- Obtain the library graph vertex where the spec of the invocation
-- construct represented by vertex Vertex of invocation graph G is
-- declared.
---------------------
-- Edge attributes --
---------------------
function Extra
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Name_Id;
pragma Inline (Extra);
-- Obtain the extra name used in error diagnostics of edge Edge of
-- invocation graph G.
function Kind
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Invocation_Kind;
pragma Inline (Kind);
-- Obtain the nature of edge Edge of invocation graph G
function Relation
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Invocation_Relation_Id;
pragma Inline (Relation);
-- Obtain the relation edge Edge of invocation graph G describes
function Target
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Invocation_Graph_Vertex_Id;
pragma Inline (Target);
-- Obtain the target vertex edge Edge of invocation graph G designates
----------------
-- Statistics --
----------------
function Invocation_Graph_Edge_Count
(G : Invocation_Graph;
Kind : Invocation_Kind) return Natural;
pragma Inline (Invocation_Graph_Edge_Count);
-- Obtain the total number of edges of kind Kind in invocation graph G
function Number_Of_Edges (G : Invocation_Graph) return Natural;
pragma Inline (Number_Of_Edges);
-- Obtain the total number of edges in invocation graph G
function Number_Of_Edges_To_Targets
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Natural;
pragma Inline (Number_Of_Edges_To_Targets);
-- Obtain the total number of edges to targets vertex Vertex of
-- invocation graph G has.
function Number_Of_Elaboration_Roots
(G : Invocation_Graph) return Natural;
pragma Inline (Number_Of_Elaboration_Roots);
-- Obtain the total number of elaboration roots in invocation graph G
function Number_Of_Vertices (G : Invocation_Graph) return Natural;
pragma Inline (Number_Of_Vertices);
-- Obtain the total number of vertices in invocation graph G
---------------
-- Iterators --
---------------
-- The following type represents an iterator over all edges of an
-- invocation graph.
type All_Edge_Iterator is private;
function Has_Next (Iter : All_Edge_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more edges to examine
function Iterate_All_Edges
(G : Invocation_Graph) return All_Edge_Iterator;
pragma Inline (Iterate_All_Edges);
-- Obtain an iterator over all edges of invocation graph G
procedure Next
(Iter : in out All_Edge_Iterator;
Edge : out Invocation_Graph_Edge_Id);
pragma Inline (Next);
-- Return the current edge referenced by iterator Iter and advance to
-- the next available edge.
-- The following type represents an iterator over all vertices of an
-- invocation graph.
type All_Vertex_Iterator is private;
function Has_Next (Iter : All_Vertex_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more vertices to examine
function Iterate_All_Vertices
(G : Invocation_Graph) return All_Vertex_Iterator;
pragma Inline (Iterate_All_Vertices);
-- Obtain an iterator over all vertices of invocation graph G
procedure Next
(Iter : in out All_Vertex_Iterator;
Vertex : out Invocation_Graph_Vertex_Id);
pragma Inline (Next);
-- Return the current vertex referenced by iterator Iter and advance
-- to the next available vertex.
-- The following type represents an iterator over all edges that reach
-- targets starting from a particular source vertex.
type Edges_To_Targets_Iterator is private;
function Has_Next (Iter : Edges_To_Targets_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more edges to examine
function Iterate_Edges_To_Targets
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Edges_To_Targets_Iterator;
pragma Inline (Iterate_Edges_To_Targets);
-- Obtain an iterator over all edges to targets with source vertex
-- Vertex of invocation graph G.
procedure Next
(Iter : in out Edges_To_Targets_Iterator;
Edge : out Invocation_Graph_Edge_Id);
pragma Inline (Next);
-- Return the current edge referenced by iterator Iter and advance to
-- the next available edge.
-- The following type represents an iterator over all vertices of an
-- invocation graph that denote the elaboration procedure or a spec or
-- a body, referred to as elaboration root.
type Elaboration_Root_Iterator is private;
function Has_Next (Iter : Elaboration_Root_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more elaboration roots to examine
function Iterate_Elaboration_Roots
(G : Invocation_Graph) return Elaboration_Root_Iterator;
pragma Inline (Iterate_Elaboration_Roots);
-- Obtain an iterator over all elaboration roots of invocation graph G
procedure Next
(Iter : in out Elaboration_Root_Iterator;
Root : out Invocation_Graph_Vertex_Id);
pragma Inline (Next);
-- Return the current elaboration root referenced by iterator Iter and
-- advance to the next available elaboration root.
private
--------------
-- Vertices --
--------------
procedure Destroy_Invocation_Graph_Vertex
(Vertex : in out Invocation_Graph_Vertex_Id);
pragma Inline (Destroy_Invocation_Graph_Vertex);
-- Destroy invocation graph vertex Vertex
-- The following type represents the attributes of an invocation graph
-- vertex.
type Invocation_Graph_Vertex_Attributes is record
Body_Vertex : Library_Graph_Vertex_Id := No_Library_Graph_Vertex;
-- Reference to the library graph vertex where the body of this
-- vertex resides.
Construct : Invocation_Construct_Id := No_Invocation_Construct;
-- Reference to the invocation construct this vertex represents
Spec_Vertex : Library_Graph_Vertex_Id := No_Library_Graph_Vertex;
-- Reference to the library graph vertex where the spec of this
-- vertex resides.
end record;
No_Invocation_Graph_Vertex_Attributes :
constant Invocation_Graph_Vertex_Attributes :=
(Body_Vertex => No_Library_Graph_Vertex,
Construct => No_Invocation_Construct,
Spec_Vertex => No_Library_Graph_Vertex);
procedure Destroy_Invocation_Graph_Vertex_Attributes
(Attrs : in out Invocation_Graph_Vertex_Attributes);
pragma Inline (Destroy_Invocation_Graph_Vertex_Attributes);
-- Destroy the contents of attributes Attrs
package IGV_Tables is new Dynamic_Hash_Tables
(Key_Type => Invocation_Graph_Vertex_Id,
Value_Type => Invocation_Graph_Vertex_Attributes,
No_Value => No_Invocation_Graph_Vertex_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Invocation_Graph_Vertex_Attributes,
Hash => Hash_Invocation_Graph_Vertex);
-----------
-- Edges --
-----------
procedure Destroy_Invocation_Graph_Edge
(Edge : in out Invocation_Graph_Edge_Id);
pragma Inline (Destroy_Invocation_Graph_Edge);
-- Destroy invocation graph edge Edge
-- The following type represents the attributes of an invocation graph
-- edge.
type Invocation_Graph_Edge_Attributes is record
Relation : Invocation_Relation_Id := No_Invocation_Relation;
-- Reference to the invocation relation this edge represents
end record;
No_Invocation_Graph_Edge_Attributes :
constant Invocation_Graph_Edge_Attributes :=
(Relation => No_Invocation_Relation);
procedure Destroy_Invocation_Graph_Edge_Attributes
(Attrs : in out Invocation_Graph_Edge_Attributes);
pragma Inline (Destroy_Invocation_Graph_Edge_Attributes);
-- Destroy the contents of attributes Attrs
package IGE_Tables is new Dynamic_Hash_Tables
(Key_Type => Invocation_Graph_Edge_Id,
Value_Type => Invocation_Graph_Edge_Attributes,
No_Value => No_Invocation_Graph_Edge_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Invocation_Graph_Edge_Attributes,
Hash => Hash_Invocation_Graph_Edge);
---------------
-- Relations --
---------------
-- The following type represents a relation between a source and target
-- vertices.
type Source_Target_Relation is record
Source : Invocation_Graph_Vertex_Id := No_Invocation_Graph_Vertex;
-- The source vertex
Target : Invocation_Graph_Vertex_Id := No_Invocation_Graph_Vertex;
-- The destination vertex
end record;
No_Source_Target_Relation :
constant Source_Target_Relation :=
(Source => No_Invocation_Graph_Vertex,
Target => No_Invocation_Graph_Vertex);
function Hash_Source_Target_Relation
(Rel : Source_Target_Relation) return Bucket_Range_Type;
pragma Inline (Hash_Source_Target_Relation);
-- Obtain the hash value of key Rel
package Relation_Sets is new Membership_Sets
(Element_Type => Source_Target_Relation,
"=" => "=",
Hash => Hash_Source_Target_Relation);
----------------
-- Statistics --
----------------
type Invocation_Graph_Edge_Counts is array (Invocation_Kind) of Natural;
----------------
-- Signatures --
----------------
function Hash_Invocation_Signature
(IS_Id : Invocation_Signature_Id) return Bucket_Range_Type;
pragma Inline (Hash_Invocation_Signature);
-- Obtain the hash value of key IS_Id
package Signature_Tables is new Dynamic_Hash_Tables
(Key_Type => Invocation_Signature_Id,
Value_Type => Invocation_Graph_Vertex_Id,
No_Value => No_Invocation_Graph_Vertex,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Invocation_Graph_Vertex,
Hash => Hash_Invocation_Signature);
-----------------------
-- Elaboration roots --
-----------------------
package IGV_Sets is new Membership_Sets
(Element_Type => Invocation_Graph_Vertex_Id,
"=" => "=",
Hash => Hash_Invocation_Graph_Vertex);
-----------
-- Graph --
-----------
package DG is new Directed_Graphs
(Vertex_Id => Invocation_Graph_Vertex_Id,
No_Vertex => No_Invocation_Graph_Vertex,
Hash_Vertex => Hash_Invocation_Graph_Vertex,
Same_Vertex => "=",
Edge_id => Invocation_Graph_Edge_Id,
No_Edge => No_Invocation_Graph_Edge,
Hash_Edge => Hash_Invocation_Graph_Edge,
Same_Edge => "=");
-- The following type represents the attributes of an invocation graph
type Invocation_Graph_Attributes is record
Counts : Invocation_Graph_Edge_Counts := (others => 0);
-- Edge statistics
Edge_Attributes : IGE_Tables.Dynamic_Hash_Table := IGE_Tables.Nil;
-- The map of edge -> edge attributes for all edges in the graph
Graph : DG.Directed_Graph := DG.Nil;
-- The underlying graph describing the relations between edges and
-- vertices.
Relations : Relation_Sets.Membership_Set := Relation_Sets.Nil;
-- The set of relations between source and targets, used to prevent
-- duplicate edges in the graph.
Roots : IGV_Sets.Membership_Set := IGV_Sets.Nil;
-- The set of elaboration root vertices
Signature_To_Vertex : Signature_Tables.Dynamic_Hash_Table :=
Signature_Tables.Nil;
-- The map of signature -> vertex
Vertex_Attributes : IGV_Tables.Dynamic_Hash_Table := IGV_Tables.Nil;
-- The map of vertex -> vertex attributes for all vertices in the
-- graph.
Lib_Graph : Library_Graphs.Library_Graph;
end record;
type Invocation_Graph is access Invocation_Graph_Attributes;
Nil : constant Invocation_Graph := null;
---------------
-- Iterators --
---------------
type All_Edge_Iterator is new DG.All_Edge_Iterator;
type All_Vertex_Iterator is new DG.All_Vertex_Iterator;
type Edges_To_Targets_Iterator is new DG.Outgoing_Edge_Iterator;
type Elaboration_Root_Iterator is new IGV_Sets.Iterator;
end Invocation_Graphs;
end Bindo.Graphs;
|