Compare commits
1702 Commits
Author | SHA1 | Date |
---|---|---|
Vítor Santos Costa | 6d018bbf2c | |
Vítor Santos Costa | 92181e534e | |
Vítor Santos Costa | d76fa9ca3d | |
Vitor Santos Costa | e6ffe9c2a0 | |
Vitor Santos Costa | ef8e9a2ea3 | |
Vitor Santos Costa | 07cd79ccb7 | |
Vitor Santos Costa | 8f8da92603 | |
Vitor Santos Costa | 60adbb9a75 | |
Vítor Santos Costa | ee12fea7cd | |
Vitor Santos Costa | e96aea3340 | |
Vítor Santos Costa | db7047249c | |
Vitor Santos Costa | 0036e3632e | |
Vitor Santos Costa | 402e6cab55 | |
Vítor Santos Costa | 1a6e97655b | |
Vitor Santos Costa | e7535dd2ee | |
Vitor Santos Costa | 8c3c3f921c | |
Vitor Santos Costa | 52da71cee7 | |
Vitor Santos Costa | 69dc2a963c | |
Vítor Santos Costa | 0e47ddc802 | |
Vítor Santos Costa | c3a254e44d | |
Vitor Santos Costa | 0949f6b494 | |
Vítor Santos Costa | 552cefbcd0 | |
Vitor Santos Costa | ef226da706 | |
Vitor Santos Costa | 5382d4739c | |
Vítor Santos Costa | d3e3515a5f | |
Vítor Santos Costa | 920b63c6bc | |
Vitor Santos Costa | ef3d435dec | |
Vítor Santos Costa | 60890fbf0b | |
Vítor Santos Costa | fb73f42d26 | |
Vítor Santos Costa | 203c064b03 | |
Vitor Santos Costa | babf3dd77d | |
Vitor Santos Costa | 46b9b46bca | |
Vítor Santos Costa | 4d395761a4 | |
Vitor Santos Costa | e23055d4f0 | |
Vitor Santos Costa | adf6ffd2a6 | |
Vítor Santos Costa | 937189ab9e | |
Vítor Santos Costa | 008c091e3c | |
Vitor Santos Costa | 874f621477 | |
Vitor Santos Costa | 91a79d778b | |
Vitor Santos Costa | 644606d8bb | |
Vitor Santos Costa | 86d6751c98 | |
Vitor Santos Costa | c91faf8bc3 | |
Vitor Santos Costa | 7c16af4edf | |
Vitor Santos Costa | 54a222e5df | |
Vitor Santos Costa | 984cf8a07c | |
Vitor Santos Costa | dc5b90a643 | |
Vitor Santos Costa | 5f819fd7b4 | |
Vitor Santos Costa | b97338f84d | |
Vitor Santos Costa | a87654b0b0 | |
Vitor Santos Costa | 71fc7238ff | |
Vitor Santos Costa | b1b6afe801 | |
Vitor Santos Costa | 16015bd8e6 | |
Vitor Santos Costa | 73b6dd4fac | |
Vitor Santos Costa | 6a65977b0f | |
Vitor Santos Costa | 1f7835c5ef | |
Vitor Santos Costa | 9101620974 | |
Vitor Santos Costa | d8b4d1c878 | |
Vítor Santos Costa | 7d85bbfa27 | |
Vitor Santos Costa | 9172f2994b | |
Vitor Santos Costa | 8070e65354 | |
Vitor Santos Costa | e7a2195af6 | |
Vítor Santos Costa | 8da14e339a | |
Vítor Santos Costa | 1739529c8b | |
Vitor Santos Costa | fda10395b8 | |
Vitor Santos Costa | 9ea395c031 | |
Vitor Santos Costa | 1cde9d0eed | |
Vitor Santos Costa | 31743139b0 | |
Vitor Santos Costa | cab11f5205 | |
Vitor Santos Costa | 0f1eaa827a | |
Vitor Santos Costa | 186c156a4a | |
Vitor Santos Costa | 30a332b671 | |
Vítor Santos Costa | 3bfaee9226 | |
Vítor Santos Costa | 0b5a5a33bb | |
Vitor Santos Costa | d306a1bf0c | |
Vítor Santos Costa | 07c8c6d7b1 | |
Vítor Santos Costa | d72770a18c | |
Vítor Santos Costa | ead29987d6 | |
Vitor Santos Costa | c840e9cabb | |
Vitor Santos Costa | 13982dcc94 | |
Vítor Santos Costa | 299a1edf8b | |
Vítor Santos Costa | a237596736 | |
Vitor Santos Costa | b5205f1193 | |
Vitor Santos Costa | 57cc6ab170 | |
Vitor Santos Costa | c04298c1d7 | |
Vítor Santos Costa | 134288da68 | |
Vítor Santos Costa | 03232f53ce | |
Vitor Santos Costa | 10307c27fe | |
Vitor Santos Costa | f54989e03e | |
Vitor Santos Costa | 644a9ad852 | |
Vítor Santos Costa | 63a514cad5 | |
Vitor Santos Costa | 9156b90b66 | |
Vitor Santos Costa | b24df86cb0 | |
Vitor Santos Costa | 2f1eb61cf9 | |
Vitor Santos Costa | 0112ad9c20 | |
Vitor Santos Costa | 4926067be9 | |
Vitor Santos Costa | 4dff2ad2ec | |
Vítor Santos Costa | 3f9e57fc48 | |
Vitor Santos Costa | 2af4dae017 | |
Vitor Santos Costa | de153bd479 | |
Vitor Santos Costa | c50367325e | |
Vitor Santos Costa | 78473ddd2c | |
Vitor Santos Costa | 7383ff79cc | |
Vitor Santos Costa | b7cd534d80 | |
Vitor Santos Costa | c0f7dfe3c3 | |
Vitor Santos Costa | 69fcc9494c | |
Vitor Santos Costa | 953667db21 | |
Vitor Santos Costa | 25afc1477c | |
Vitor Santos Costa | 9980dd49a7 | |
Vitor Santos Costa | e626847e93 | |
Vítor Santos Costa | 044d455597 | |
Vitor Santos Costa | 96a40f1d50 | |
Vitor Santos Costa | 70a43ece1d | |
Vitor Santos Costa | e8d9e71a4e | |
Vitor Santos Costa | d10589d60f | |
Vitor Santos Costa | 044329d115 | |
Vítor Santos Costa | 6825c3e2ac | |
Vitor Santos Costa | e3c399af48 | |
Vitor Santos Costa | e5e38551e0 | |
Vítor Santos Costa | 47b13c3836 | |
Vitor Santos Costa | 4afbc4461c | |
Vítor Santos Costa | 56c4220cf6 | |
Vítor Santos Costa | 4d2b18908d | |
Vitor Santos Costa | ab56074bb1 | |
Vítor Santos Costa | 9378622d42 | |
Vitor Santos Costa | 32a5158c6b | |
Vitor Santos Costa | 21ff73dd70 | |
Vitor Santos Costa | 7ab1624401 | |
Vitor Santos Costa | ae426a3b27 | |
Vitor Santos Costa | 5ec424645d | |
Vitor Santos Costa | 3f4fd7d7a3 | |
Vitor Santos Costa | ff61ab9953 | |
Vitor Santos Costa | 908cfe3b77 | |
Vítor Santos Costa | 5ff09fbf26 | |
Vitor Santos Costa | 8d30742d8f | |
Vitor Santos Costa | facf7ae8cd | |
Vitor Santos Costa | 2d65d0463c | |
Vitor Santos Costa | 5d7c6378e7 | |
Vitor Santos Costa | ccfbe3f809 | |
Vítor Santos Costa | 7dca1f1390 | |
Vitor Santos Costa | 84721e1005 | |
Vitor Santos Costa | c248ef9ccf | |
Vitor Santos Costa | cb0f5ec4db | |
Vitor Santos Costa | f483838610 | |
Vitor Santos Costa | c792db26be | |
Vitor Santos Costa | 79d2330e71 | |
Vitor Santos Costa | 6a3c4bda79 | |
Vitor Santos Costa | 2c1565ac0e | |
Vitor Santos Costa | 5c41c509c0 | |
Vítor Santos Costa | 1ef3f738ee | |
Vitor Santos Costa | 1bd2f0338c | |
Vitor Santos Costa | 90f5720fb0 | |
Vítor Santos Costa | 244d04f90b | |
Vitor Santos Costa | 4b5ae9331f | |
Vítor Santos Costa | 593877f39d | |
Vitor Santos Costa | 302519868f | |
Vitor Santos Costa | 71940dec67 | |
Vitor Santos Costa | 394ecd4657 | |
Vítor Santos Costa | 76b4ddee9c | |
Vitor Santos Costa | c4b78e161b | |
Vitor Santos Costa | 2c80e33c6a | |
Vitor Santos Costa | ac60bee30d | |
Vitor Santos Costa | 3fdc260ee6 | |
Vitor Santos Costa | 24b6908225 | |
Vitor Santos Costa | d0f05d3578 | |
Vitor Santos Costa | 4678b2baee | |
Vitor Santos Costa | 933db5bc7e | |
Vitor Santos Costa | 4092003cd6 | |
Vitor Santos Costa | e5945b8e8b | |
Vitor Santos Costa | 4bc0292ad6 | |
Vítor Santos Costa | 3b8475f882 | |
Vitor Santos Costa | cb4d17cb4f | |
Vitor Santos Costa | d874dc5857 | |
Vitor Santos Costa | 7045b6ef36 | |
Vitor Santos Costa | 208438f0d0 | |
Vítor Santos Costa | 38610c0b0d | |
Vítor Santos Costa | fa96ffa932 | |
Vitor Santos Costa | ca2542c798 | |
Vitor Santos Costa | b382c060e3 | |
Vitor Santos Costa | f6b16ca505 | |
Vitor Santos Costa | b71b4f6fca | |
Vitor Santos Costa | c1dc6b7fb2 | |
Vitor Santos Costa | f7ed109d1c | |
Vitor Santos Costa | 847edfd432 | |
Vitor Santos Costa | 0507d80403 | |
Vítor Santos Costa | dfe0698f03 | |
Vitor Santos Costa | 55ea7d35a3 | |
Vitor Santos Costa | 09d8d07b7e | |
Vitor Santos Costa | 7f71184785 | |
Vitor Santos Costa | 36fedfa321 | |
Vitor Santos Costa | 13d764067f | |
Vitor Santos Costa | 5ec9e31eb9 | |
Vitor Santos Costa | b395177faa | |
Vitor Santos Costa | 700d6ae707 | |
Vitor Santos Costa | 650653cc64 | |
Vítor Santos Costa | bfe5fc2f49 | |
Vítor Santos Costa | 93bb39d5f7 | |
Vitor Santos Costa | a3dd1a1520 | |
Vitor Santos Costa | 92089074f1 | |
Vítor Santos Costa | e0467d95d4 | |
Vitor Santos Costa | 2a090f3484 | |
Vitor Santos Costa | a6d709dabf | |
Vitor Santos Costa | 8ce648422a | |
Vitor Santos Costa | c682058942 | |
Vitor Santos Costa | daa86e9c34 | |
Vitor Santos Costa | 17a75d79ff | |
Vitor Santos Costa | 1c4e272b1d | |
Vítor Santos Costa | 36b376d447 | |
Vítor Santos Costa | e83d1f9d43 | |
Vítor Santos Costa | 4aaad2b221 | |
Vitor Santos Costa | 86decdddde | |
Vitor Santos Costa | 8e2864c0cf | |
Vitor Santos Costa | 670bfd421d | |
Vítor Santos Costa | c21c0079dc | |
Vitor Santos Costa | 29c004d62a | |
Vitor Santos Costa | 6451328782 | |
Vitor Santos Costa | c2ebd2857c | |
Vitor Santos Costa | 9e1a2ad41e | |
Vitor Santos Costa | 3f1c2352f3 | |
Vitor Santos Costa | 3699a715ce | |
Vitor Santos Costa | d08c56fb56 | |
Vitor Santos Costa | 664c17f3b3 | |
Vitor Santos Costa | 7c1a6c9cef | |
Vitor Santos Costa | 92994fb0e4 | |
Vitor Santos Costa | 31423fcf90 | |
Vitor Santos Costa | f0a6018a00 | |
Vitor Santos Costa | 5b96e59311 | |
Vitor Santos Costa | 37d5dcedc1 | |
Vitor Santos Costa | 3fa4bfbcb2 | |
Vitor Santos Costa | 890f77d698 | |
Vitor Santos Costa | e66c3ab7cc | |
Vitor Santos Costa | 705cb09f8d | |
Vítor Santos Costa | 44be8cf600 | |
Vitor Santos Costa | 473132c3ec | |
Vitor Santos Costa | 7e84455117 | |
Vitor Santos Costa | afe5780fc1 | |
Vitor Santos Costa | 13a6cc8ece | |
Vitor Santos Costa | 18e437f038 | |
Vítor Santos Costa | ad57c3cad0 | |
Vítor Santos Costa | d0418167a1 | |
Vitor Santos Costa | 1797e5132e | |
Vítor Santos Costa | 45f388156c | |
Vitor Santos Costa | 6372151bf1 | |
Vitor Santos Costa | 000c9c0968 | |
Vitor Santos Costa | 87a568291b | |
Vitor Santos Costa | b73a1f05ba | |
Vitor Santos Costa | 3d8858954d | |
Vitor Santos Costa | 3a8738a7db | |
Vitor Santos Costa | 9dc86c735b | |
Vitor Santos Costa | 66167abba6 | |
Vitor Santos Costa | b87f0c79e9 | |
Vitor Santos Costa | 4f7a5809d5 | |
Vitor Santos Costa | 286432a849 | |
Vitor Santos Costa | 91a5f0d1c3 | |
Vítor Santos Costa | 81e37d5ce0 | |
Vitor Santos Costa | 0230ff35d1 | |
Vitor Santos Costa | 999de8df19 | |
Vitor Santos Costa | 9be6eb9132 | |
Vitor Santos Costa | 5fdd481d6c | |
Vitor Santos Costa | b7cdaa10ec | |
Vitor Santos Costa | 556fdefe83 | |
Vitor Santos Costa | e2863854a9 | |
Vitor Santos Costa | e528893b73 | |
Vitor Santos Costa | cb8c37ce56 | |
Vitor Santos Costa | 40633a3f83 | |
Vitor Santos Costa | 17411a7384 | |
Vitor Santos Costa | 9b31c93a46 | |
Vitor Santos Costa | e89bc55b9f | |
Vítor Santos Costa | 27227b75c7 | |
Vítor Santos Costa | 2df29817c8 | |
Vítor Santos Costa | 50e1d90085 | |
Vitor Santos Costa | fc65bd6924 | |
Vitor Santos Costa | 4fed99c0aa | |
Vitor Santos Costa | cb5dc1313a | |
Vitor Santos Costa | 337bf7b136 | |
Vitor Santos Costa | b1635505ef | |
Vítor Santos Costa | eb1dfc43b7 | |
Vítor Santos Costa | d297a8834e | |
Vítor Santos Costa | 8d226bbfde | |
Vítor Santos Costa | 54e16f6f19 | |
Vitor Santos Costa | 55ebeb7dd8 | |
Vitor Santos Costa | 76cfa609c2 | |
Vitor Santos Costa | a1f8631844 | |
Vitor Santos Costa | 0f313755cc | |
Vitor Santos Costa | 4a0dd26ecb | |
Vitor Santos Costa | a6090a61ab | |
Vítor Santos Costa | 52bb6a92f1 | |
Vítor Santos Costa | 8e1945ad63 | |
Vitor Santos Costa | 004bbef62b | |
Vitor Santos Costa | a491f71cb0 | |
Vitor Santos Costa | 0d8e28af3e | |
Vitor Santos Costa | 670c2cbf13 | |
Vitor Santos Costa | 5b21bc118f | |
Vitor Santos Costa | ebd4dffed3 | |
Vitor Santos Costa | 7381bf0d84 | |
Vitor Santos Costa | a7fe5683a8 | |
Vitor Santos Costa | 408c15f5eb | |
Vitor Santos Costa | 563b642672 | |
Vítor Santos Costa | e163ccb6c0 | |
Vítor Santos Costa | f0260d2978 | |
Vitor Santos Costa | 3df0110947 | |
Vitor Santos Costa | e1bec5454d | |
vscosta | e4dc9c2e9f | |
vscosta | 18dad4d7e9 | |
vscosta | da6bd115d8 | |
Vítor Santos Costa | 37d9810a99 | |
Vitor Santos Costa | 37212efc55 | |
Vitor Santos Costa | 4bbf6f0367 | |
Vitor Santos Costa | eed36e99a6 | |
Vítor Santos Costa | 0d47af2ad9 | |
Vitor Santos Costa | 5f989e58b2 | |
Vítor Santos Costa | fbcd45bdfe | |
Vítor Santos Costa | 7986e21d59 | |
Vitor Santos Costa | e117d51d98 | |
Vitor Santos Costa | ced5916aa8 | |
Vitor Santos Costa | 8fcf3eb008 | |
Vitor Santos Costa | 3786de19de | |
Vítor Santos Costa | b4bd6b4ba8 | |
Vitor Santos Costa | 45439b8b86 | |
Vitor Santos Costa | 868961ebb5 | |
Vitor Santos Costa | c59b01e53c | |
Vitor Santos Costa | 3fdbbc6a77 | |
Vitor Santos Costa | 68ce1fd045 | |
Vitor Santos Costa | b31493c777 | |
Vitor Santos Costa | 127ebb2523 | |
Vitor Santos Costa | b41986ee3c | |
Vitor Santos Costa | 70cb6ed01e | |
Vitor Santos Costa | a03aa3c27c | |
Vitor Santos Costa | de03a9da58 | |
Vitor Santos Costa | ac41673000 | |
Vitor Santos Costa | d4cdb52f2b | |
Vitor Santos Costa | 5d69b09688 | |
Vitor Santos Costa | 50fb5d21c0 | |
Vitor Santos Costa | 9dac6e9612 | |
Vitor Santos Costa | c386e9d9f6 | |
Vitor Santos Costa | e747b7f9c1 | |
Vitor Santos Costa | a33f2be18b | |
Vitor Santos Costa | 7772699ef7 | |
Vítor Santos Costa | 67cc23725f | |
Vítor Santos Costa | 6096c6407a | |
Vítor Santos Costa | 7666a005dc | |
Vitor Santos Costa | cb1c73c973 | |
Vítor Santos Costa | 32266a8b98 | |
Vitor Santos Costa | 9e3a768220 | |
Vítor Santos Costa | 48e398576f | |
Vitor Santos Costa | 50feadc341 | |
Vitor Santos Costa | be12fb92d6 | |
Vitor Santos Costa | 3d5303529f | |
Vitor Santos Costa | 6d0b702d1c | |
Vitor Santos Costa | ba6e0728ae | |
Vitor Santos Costa | 4f292cb521 | |
Vitor Santos Costa | 5ea98bcf53 | |
Vítor Santos Costa | d0ed3cfe25 | |
Vitor Santos Costa | 50b13a15a0 | |
Vitor Santos Costa | f57377a23a | |
Vitor Santos Costa | 724681dde8 | |
Vítor Santos Costa | cbc90a8293 | |
Vitor Santos Costa | 990a86512d | |
Vitor Santos Costa | a01ba3383b | |
Vitor Santos Costa | 87c6971bb6 | |
Vítor Santos Costa | 13d609867c | |
Vítor Santos Costa | f6ca094534 | |
Vítor Santos Costa | b6235d8ecd | |
Vítor Santos Costa | a6e578090c | |
Vítor Santos Costa | 7661b8581c | |
Vítor Santos Costa | a2d397976f | |
Vitor Santos Costa | bde725e016 | |
Vítor Santos Costa | 29f79473e5 | |
Vitor Santos Costa | 9ec1ffb2c7 | |
Vitor Santos Costa | 46a32fbd83 | |
Vitor Santos Costa | f8d0703983 | |
Vítor Santos Costa | 290ee932ed | |
Vítor Santos Costa | b64853fd1a | |
Vitor Santos Costa | a079139060 | |
Vítor Santos Costa | 46247bca56 | |
Vitor Santos Costa | 724dfee44a | |
Vitor Santos Costa | 059c406fd9 | |
Vitor Santos Costa | 81998122a8 | |
Vitor Santos Costa | 5c8f8457fa | |
Vítor Santos Costa | f6d8304fcf | |
Vitor Santos Costa | e0cc401381 | |
Vitor Santos Costa | f1066036ff | |
Vitor Santos Costa | 1e7ee487b6 | |
Vitor Santos Costa | 63e4b31787 | |
Vitor Santos Costa | d4eea0fbb4 | |
Vitor Santos Costa | 3344dcaf7d | |
Vitor Santos Costa | 244ee465c4 | |
Vitor Santos Costa | dc6a21dbc5 | |
Vitor Santos Costa | 208ed54b45 | |
Vitor Santos Costa | f329a715dd | |
Vitor Santos Costa | ecab37f72c | |
Vitor Santos Costa | d5c1ca716e | |
Vitor Santos Costa | af7584e1f3 | |
Vitor Santos Costa | 4a28e5861a | |
Vitor Santos Costa | 3b186a064a | |
Vitor Santos Costa | 015efac6df | |
Vítor Santos Costa | 1fbd0c49ba | |
Vítor Santos Costa | 4a048aad7d | |
Vitor Santos Costa | 1668763b19 | |
Vitor Santos Costa | 8196666cdc | |
Vitor Santos Costa | 6cdd35b6e1 | |
Vitor Santos Costa | 05733938c1 | |
Vitor Santos Costa | f6596da27d | |
Vitor Santos Costa | a36a0e2e45 | |
Vitor Santos Costa | 24014ded21 | |
Vitor Santos Costa | e455d6cc6a | |
Vitor Santos Costa | 8f5fd1ddc2 | |
Vitor Santos Costa | cfaedf5db4 | |
Vitor Santos Costa | 55b2325b2e | |
Vitor Santos Costa | 22cefb0b9c | |
Vitor Santos Costa | 828a5ec1e9 | |
Vitor Santos Costa | bf712034a9 | |
Vitor Santos Costa | 436f1c205a | |
Vitor Santos Costa | bac1b63080 | |
Vitor Santos Costa | b4201dd0f3 | |
Vitor Santos Costa | 0c950ce5b3 | |
Vitor Santos Costa | 562e9e5af3 | |
Vitor Santos Costa | abc11dcfaa | |
Vitor Santos Costa | e5748f3c9f | |
Vitor Santos Costa | 37992c77be | |
Vitor Santos Costa | 69e0c739e8 | |
Vitor Santos Costa | 52d69d3c06 | |
Vitor Santos Costa | 4b3aedccb5 | |
Vitor Santos Costa | 94621bf8f2 | |
Vitor Santos Costa | 2a1ec9c36b | |
Vitor Santos Costa | ec61b3907e | |
Vitor Santos Costa | 86c71b6da7 | |
Vítor Santos Costa | 04fa39126c | |
Vitor Santos Costa | 069fcc875c | |
Vitor Santos Costa | 6a70362a15 | |
Vítor Santos Costa | 3efb73f35d | |
Vítor Santos Costa | 4b474574d8 | |
Vitor Santos Costa | 4fff363436 | |
Vitor Santos Costa | 4de58e0fe4 | |
Vitor Santos Costa | 7b774ef5cd | |
Vitor Santos Costa | 101bdf0f6c | |
Vítor Santos Costa | c2e2ec8fcf | |
Vítor Santos Costa | aed15571ff | |
Vitor Santos Costa | 2e8dd92d89 | |
Vitor Santos Costa | 387d7cc3fb | |
Vitor Santos Costa | 064b84895e | |
Vitor Santos Costa | ba00e98ad8 | |
Vitor Santos Costa | c93944192e | |
Vitor Santos Costa | db9823d5ef | |
Vitor Santos Costa | fb13a127b0 | |
Vítor Santos Costa | 2905688c0f | |
Vítor Santos Costa | ae35c229e8 | |
Vitor Santos Costa | 260dcbe754 | |
Vitor Santos Costa | 8e43a02789 | |
Vitor Santos Costa | 75b7cebdaf | |
Vitor Santos Costa | 3bf897c503 | |
Vitor Santos Costa | 21a7a3ef44 | |
Vitor Santos Costa | 48540ccc78 | |
Vitor Santos Costa | 176dc4bfb5 | |
Vitor Santos Costa | e2a46cf423 | |
Vitor Santos Costa | fd492b5b16 | |
Vitor Santos Costa | 71aed8b870 | |
Vitor Santos Costa | 53de04c38f | |
Vitor Santos Costa | 5f96c07131 | |
Vitor Santos Costa | c5de0d647c | |
Vitor Santos Costa | 6c1d3d1a95 | |
Vitor Santos Costa | d3370ee141 | |
Vitor Santos Costa | af1fcdac19 | |
Vitor Santos Costa | 1caeb168e9 | |
Vitor Santos Costa | cdd892c012 | |
Vitor Santos Costa | f2d6c99c8a | |
Vitor Santos Costa | 0c946038d5 | |
Vitor Santos Costa | 8911fea5ae | |
Vitor Santos Costa | e97ea388f8 | |
Vitor Santos Costa | 0ca40875db | |
Vitor Santos Costa | 0bfc4d4525 | |
Vitor Santos Costa | f6c8e204c7 | |
Vitor Santos Costa | 510ba1b804 | |
Vitor Santos Costa | 1fcc88865b | |
Vitor Santos Costa | 4495bb2661 | |
Vitor Santos Costa | edc7d2ceb4 | |
Vitor Santos Costa | 81b165d3dc | |
Vitor Santos Costa | 52df4c02ac | |
Vitor Santos Costa | 25faa8f67c | |
Vitor Santos Costa | 58136ead22 | |
Vitor Santos Costa | 3e5cd4b4f1 | |
Vitor Santos Costa | 18c74933af | |
Vitor Santos Costa | d5b96ef518 | |
Vitor Santos Costa | eb43305a38 | |
Vitor Santos Costa | 41bea46575 | |
Vitor Santos Costa | ff2b867ec3 | |
Vitor Santos Costa | 7522e54a2e | |
Vitor Santos Costa | c092d0f62b | |
Vitor Santos Costa | fd4f53a899 | |
Vitor Santos Costa | 4fefb762f2 | |
Vitor Santos Costa | d92191874a | |
Vitor Santos Costa | 87f4092c19 | |
Vitor Santos Costa | 8ab005480f | |
Vitor Santos Costa | ca814eef07 | |
Vitor Santos Costa | f0343fc62c | |
Vitor Santos Costa | a4dd2efbe7 | |
Vitor Santos Costa | a6acc8e9e6 | |
Vitor Santos Costa | 521a5df611 | |
Vitor Santos Costa | d2024c1aed | |
Vitor Santos Costa | 59534a04f6 | |
Vitor Santos Costa | 54c6b8c041 | |
Vitor Santos Costa | 2d55f41ef6 | |
Vitor Santos Costa | 40096b3fdc | |
Vitor Santos Costa | 840eb3b0fd | |
Vitor Santos Costa | 1201357017 | |
Vitor Santos Costa | 72a703393f | |
Vitor Santos Costa | 19fef7d6ac | |
Vitor Santos Costa | 08ece03f4a | |
Vitor Santos Costa | 94a826efcc | |
Vitor Santos Costa | 725a0a692a | |
Vitor Santos Costa | 7325407d23 | |
Vitor Santos Costa | bbd0122fc3 | |
Vitor Santos Costa | 9afb5b07b2 | |
Vítor Santos Costa | 8cfeb53e77 | |
Vitor Santos Costa | e9274ef5d3 | |
Vitor Santos Costa | 2415a2e58c | |
Vitor Santos Costa | b59af58616 | |
Vitor Santos Costa | eeb8f7c6a1 | |
Vítor Santos Costa | 4fe08fd82a | |
Vitor Santos Costa | c4a0d5766b | |
Vítor Santos Costa | 8c3bea4bce | |
Vítor Santos Costa | 7c934d3f40 | |
Vitor Santos Costa | bb2d06fac9 | |
Vitor Santos Costa | ebe4ba266e | |
Vitor Santos Costa | 30a3b72d62 | |
Vitor Santos Costa | ce2185e162 | |
Vítor Santos Costa | 8607aee725 | |
Vitor Santos Costa | 9ea75834ff | |
Vitor Santos Costa | 27b540b72b | |
Vítor Santos Costa | 03d8a64543 | |
Vitor Santos Costa | b7a97a5b19 | |
Vitor Santos Costa | 518ce92bea | |
Vitor Santos Costa | 6e9882c369 | |
Vitor Santos Costa | bdf7088665 | |
Vitor Santos Costa | d7c4ac95e0 | |
Vítor Santos Costa | 67a88a196d | |
Vitor Santos Costa | 8a817a1dc4 | |
Vitor Santos Costa | 65fa980773 | |
Vitor Santos Costa | 3369e0085c | |
Vítor Santos Costa | 37b1e9043b | |
Vitor Santos Costa | 7c4014d15b | |
Vitor Santos Costa | 1206035805 | |
Vitor Santos Costa | 74222843e5 | |
Vítor Santos Costa | 6fe162025b | |
Vitor Santos Costa | 98dd9394b4 | |
Vitor Santos Costa | 69e68ff3cc | |
Vitor Santos Costa | ef04b30d66 | |
Vítor Santos Costa | 44ac70d3ab | |
Vitor Santos Costa | 1c293a9af4 | |
Vitor Santos Costa | af848f28aa | |
Vitor Santos Costa | 2c1d6910de | |
Vitor Santos Costa | f39619b3ef | |
Vítor Santos Costa | dfacbdcfd1 | |
Vítor Santos Costa | 9cfe3a4c7f | |
Vítor Santos Costa | c7995f276c | |
Vitor Santos Costa | 11dae5653e | |
Vítor Santos Costa | 1b27ef94bb | |
Vítor Santos Costa | 6095fe6e00 | |
Vitor Santos Costa | 8bfa835959 | |
Vitor Santos Costa | 4b1efa59b4 | |
Vítor Santos Costa | 7bfe8aedbe | |
Vitor Santos Costa | abb328abf0 | |
Vitor Santos Costa | df961cbd62 | |
Vitor Santos Costa | d172c9a0f7 | |
Vítor Santos Costa | 2c64eea060 | |
Vítor Santos Costa | 470323da5c | |
Vítor Santos Costa | fb5564f9d1 | |
Vitor Santos Costa | ec8eb89cc7 | |
Vitor Santos Costa | 04c38ecc29 | |
Vítor Santos Costa | 2d19db5fce | |
Vitor Santos Costa | 7ce963b63c | |
Vítor Santos Costa | bc3555dfbf | |
Vítor Santos Costa | 3d8ef251a5 | |
Vitor Santos Costa | c3b06ffdd1 | |
Vítor Santos Costa | d379034a96 | |
Vitor Santos Costa | 3a44eb657d | |
Vítor Santos Costa | c1d81ea7c6 | |
Vitor Santos Costa | 48bcffdce7 | |
Vitor Santos Costa | 508e10d0be | |
Vítor Santos Costa | e3ac349a0d | |
Vítor Santos Costa | 29af01c288 | |
Vítor Santos Costa | 3da111bd10 | |
Vítor Santos Costa | 51fa95505f | |
Vítor Santos Costa | 05356df347 | |
Vitor Santos Costa | e02884a94f | |
Vitor Santos Costa | 0b67a66533 | |
Vitor Santos Costa | 4dfad0a7fe | |
Vitor Santos Costa | 7e0611b526 | |
Vitor Santos Costa | 13cdd5124a | |
Vitor Santos Costa | 56e676ef65 | |
Vítor Santos Costa | 9b86a7869b | |
Vitor Santos Costa | c2f2490fee | |
Vítor Santos Costa | ff149367e8 | |
Vitor Santos Costa | 98d52ba347 | |
Vitor Santos Costa | 1b2aa6417c | |
Vitor Santos Costa | da68741b74 | |
Vitor Santos Costa | 1ff06fd2e0 | |
Vitor Santos Costa | 2e9be3d0d4 | |
Vitor Santos Costa | 927a43933c | |
Vitor Santos Costa | b54439d909 | |
Vitor Santos Costa | 8ab38125db | |
Vitor Santos Costa | 9194fda6cc | |
Vitor Santos Costa | 56f47acc49 | |
Vitor Santos Costa | 353690cc59 | |
Vítor Santos Costa | af610dc16d | |
Vitor Santos Costa | cc6eca6903 | |
Vitor Santos Costa | c33a0d72db | |
Vitor Santos Costa | 1a8c26b886 | |
Vitor Santos Costa | 31fd3eb344 | |
Vitor Santos Costa | 3a36285bb2 | |
Vitor Santos Costa | 530246688c | |
Vitor Santos Costa | a073b663ae | |
Vitor Santos Costa | 4db414a05a | |
Vitor Santos Costa | 82df9ce5b5 | |
Vitor Santos Costa | 921b5d497d | |
Vitor Santos Costa | d6aaa8a03e | |
Vitor Santos Costa | 1066ded7d9 | |
Vitor Santos Costa | f798372fb1 | |
Vitor Santos Costa | 54e3d48fb1 | |
Vitor Santos Costa | 21b017967f | |
Vitor Santos Costa | 207d0acb03 | |
Vitor Santos Costa | 81c7fc5d45 | |
Vitor Santos Costa | 1cdd8a482b | |
Vitor Santos Costa | 13f36c1f67 | |
Vitor Santos Costa | 1289899918 | |
Vitor Santos Costa | ca92d8631b | |
Vitor Santos Costa | bdc9e7005d | |
Vitor Santos Costa | 3e71d171e7 | |
Vitor Santos Costa | 7219992154 | |
Vitor Santos Costa | e93c01f8e0 | |
Vitor Santos Costa | 76d0d54a34 | |
Vitor Santos Costa | 311e1d697d | |
Vitor Santos Costa | fe496e840d | |
Vitor Santos Costa | 37f7eb3cf3 | |
Vitor Santos Costa | e7af316ad1 | |
Vitor Santos Costa | 608d87bafe | |
Vitor Santos Costa | ba69fbc955 | |
Vitor Santos Costa | 84aaa82dbe | |
Vitor Santos Costa | b057ac92e4 | |
Vitor Santos Costa | 0b742f3ae3 | |
Vitor Santos Costa | eee6760f96 | |
Vitor Santos Costa | 8d6654d4cf | |
Vitor Santos Costa | 34c6ace8be | |
Vitor Santos Costa | 50b2bae12a | |
Vitor Santos Costa | f037b2478c | |
Vitor Santos Costa | b02c775915 | |
Vitor Santos Costa | fadf853e96 | |
Vitor Santos Costa | 66db3d53f8 | |
Vitor Santos Costa | 5ea47853ac | |
Vitor Santos Costa | 24d895d100 | |
Vitor Santos Costa | 741c5a1e10 | |
Vitor Santos Costa | 1cafba0529 | |
Vitor Santos Costa | aaadd51309 | |
Vitor Santos Costa | eb9cc69bfb | |
Vitor Santos Costa | f3f524960c | |
Vitor Santos Costa | 63e8e89dab | |
Vitor Santos Costa | 9fce1e9ba2 | |
Vitor Santos Costa | fdf7bb516f | |
Vitor Santos Costa | 4c25aa21c5 | |
Vitor Santos Costa | 791484c132 | |
Vitor Santos Costa | 1cff18d1c0 | |
Vitor Santos Costa | 9c862c21bc | |
Vitor Santos Costa | 814aa2bd4c | |
Vitor Santos Costa | 4a5002091f | |
Vitor Santos Costa | 6b03c96a78 | |
Vitor Santos Costa | 85f444cc94 | |
Vitor Santos Costa | 237430afb4 | |
Vitor Santos Costa | 5be3fe4555 | |
Vitor Santos Costa | d348e8c563 | |
Vitor Santos Costa | 9a5681b2cb | |
Vitor Santos Costa | 65dd00be58 | |
Vitor Santos Costa | 3061844c95 | |
Vitor Santos Costa | 645b2c7d93 | |
Vitor Santos Costa | b645f60405 | |
Vitor Santos Costa | 55f4767621 | |
Vitor Santos Costa | 876e42d629 | |
Vitor Santos Costa | 76fb202d7e | |
Vitor Santos Costa | c281d73aef | |
Vitor Santos Costa | 4f366726c6 | |
Vitor Santos Costa | 2a93f1da99 | |
Vitor Santos Costa | 690f1d3830 | |
Vitor Santos Costa | 3688819ea2 | |
Vitor Santos Costa | 8feca162bf | |
Vitor Santos Costa | 06485f071a | |
Vitor Santos Costa | cdcb365a82 | |
Vitor Santos Costa | 9dab200c61 | |
Vitor Santos Costa | 484213efb6 | |
Vitor Santos Costa | bf78d70d66 | |
Vitor Santos Costa | 746a4b4ef8 | |
Vitor Santos Costa | b8f0a34833 | |
Vitor Santos Costa | ed2c85a56b | |
Vitor Santos Costa | 450d7a2bdd | |
Vitor Santos Costa | 5f9e0299ee | |
Vitor Santos Costa | bf67b8e609 | |
Vitor Santos Costa | 23565fc351 | |
Vitor Santos Costa | f7d6d70733 | |
Vitor Santos Costa | d23f7c149f | |
Vitor Santos Costa | 4271f3debe | |
Vitor Santos Costa | af233dbf36 | |
Vitor Santos Costa | 5c199984ed | |
Vitor Santos Costa | 3bb4570c55 | |
Vitor Santos Costa | 538cb4eb2c | |
Vitor Santos Costa | 9100e797f8 | |
Vitor Santos Costa | 7cd3fffe13 | |
Vitor Santos Costa | 2be6dcdbac | |
Vitor Santos Costa | e4fd6a153a | |
Vitor Santos Costa | 29f0f88025 | |
Vitor Santos Costa | 9a211ac1d4 | |
Vitor Santos Costa | 3789f69cf1 | |
Vitor Santos Costa | 978e8e9788 | |
Vitor Santos Costa | 407815e09a | |
Vitor Santos Costa | 2e6684b995 | |
Vitor Santos Costa | 75f5937e2b | |
Vitor Santos Costa | e3ade13cfe | |
Vitor Santos Costa | a83d97f998 | |
Vitor Santos Costa | 368cb492ef | |
Vitor Santos Costa | 73f05f2ed2 | |
Vitor Santos Costa | afd24bb8db | |
Vitor Santos Costa | 74e902c257 | |
Vitor Santos Costa | f12d98a38c | |
Vitor Santos Costa | 861f185ec6 | |
Vitor Santos Costa | 8baaa70cec | |
Vitor Santos Costa | 7dab812d64 | |
Vitor Santos Costa | af38546a0d | |
Vitor Santos Costa | 8437007716 | |
Vitor Santos Costa | d93134dcf6 | |
Vitor Santos Costa | 7a7a9f56ed | |
Vitor Santos Costa | 6b0478db00 | |
Vitor Santos Costa | da94db80cf | |
Vitor Santos Costa | dd48ba6f91 | |
Vitor Santos Costa | d05b1f4b2b | |
Vitor Santos Costa | 9f1ef65ff5 | |
Vitor Santos Costa | c06dd92761 | |
Vitor Santos Costa | 46d997713f | |
Vitor Santos Costa | a40fbe420f | |
Vitor Santos Costa | 70f4f7adcf | |
Vitor Santos Costa | 4d1c031051 | |
Vitor Santos Costa | 27fdeb81cc | |
Vitor Santos Costa | 98a5538f45 | |
Vitor Santos Costa | 53822922c8 | |
Vitor Santos Costa | b24dc4893d | |
Vitor Santos Costa | 717aeb162a | |
Vitor Santos Costa | c1d9a00a81 | |
Vitor Santos Costa | 95dd4890cc | |
Vitor Santos Costa | 5e761f7fd3 | |
Vitor Santos Costa | 00d1bf9af4 | |
Vitor Santos Costa | 35e12bd9c4 | |
Vitor Santos Costa | 65126b1b54 | |
Vitor Santos Costa | ea51f06783 | |
Vitor Santos Costa | 3fd8ccb06b | |
Vitor Santos Costa | a64059612f | |
Vitor Santos Costa | 81f5909095 | |
Vitor Santos Costa | b9c84ab7e9 | |
Vitor Santos Costa | 41dab59126 | |
Vitor Santos Costa | 02a2bb0b0b | |
Vitor Santos Costa | b5bfb638a3 | |
Vitor Santos Costa | e3ab36f091 | |
Vitor Santos Costa | af29600f09 | |
Vitor Santos Costa | abdc8a35f9 | |
Vitor Santos Costa | a115024aee | |
Vitor Santos Costa | 5448987ad0 | |
Vitor Santos Costa | 22c0cbeca3 | |
Vitor Santos Costa | b2a30b0a53 | |
vscosta | 11e81b457d | |
Vitor Santoss Costa | 675ce8c77b | |
vscosta | f255d629e9 | |
vscosta | 51d9637fc4 | |
vscosta | 70c25d37b6 | |
vscosta | 93577a7481 | |
vscosta | b032803616 | |
vscosta | d49a7387ef | |
Vitor Santos Costa | 2efedcb131 | |
Vitor Santos Costa | d2940c981c | |
Vitor Santos Costa | 6e6738b199 | |
Vitor Santos Costa | 3239778cf5 | |
Vitor Santos Costa | b1067dcc34 | |
Vitor Santos Costa | ec3995dd82 | |
Vitor Santos Costa | 2add5f2971 | |
Vitor Santos Costa | 063806f2f3 | |
Vitor Santos Costa | ce61f810c2 | |
Vitor Santos Costa | ccd7916d31 | |
Vitor Santos Costa | 3d6d3f092a | |
Vitor Santos Costa | 7ee2813f90 | |
Vitor Santos Costa | 4574cdb4df | |
Vitor Santos Costa | 51b99388e7 | |
Vitor Santos Costa | 8bf607aa65 | |
Vitor Santos Costa | de7ef115e7 | |
Vitor Santos Costa | ed346ccc65 | |
Vitor Santos Costa | ec518d7d36 | |
Vitor Santos Costa | b2c8b9a06e | |
Vitor Santos Costa | d2f87363ef | |
Vitor Santos Costa | 3e6c24cc0c | |
Vitor Santos Costa | 54234c7e1d | |
Vitor Santos Costa | f8f1d75ad6 | |
Vitor Santos Costa | a7bc4a3c71 | |
Vitor Santos Costa | 5b5e954dbc | |
Vitor Santos Costa | 8ad14f6765 | |
Vitor Santos Costa | f99d048cc2 | |
Vitor Santos Costa | a1b04dee3e | |
Vitor Santos Costa | dac6dc7c22 | |
Vitor Santos Costa | 3d191957db | |
Vitor Santos Costa | 75befc69f7 | |
Vitor Santos Costa | 963752fa9c | |
Vitor Santos Costa | 46468803b1 | |
Vitor Santos Costa | 63a1957d8e | |
Vitor Santos Costa | 023c254d03 | |
Vitor Santos Costa | 22837d498b | |
Vitor Santos Costa | 530d73c470 | |
Vitor Santoss Costa | d91b06bb6c | |
Vitor Santoss Costa | a601d3ebb3 | |
Vitor Santos Costa | 12f93e10d3 | |
Vitor Santos Costa | 1a78144190 | |
Vitor Santoss Costa | efaf86c675 | |
Vitor Santos Costa | 1dec8f5a55 | |
Vitor Santoss Costa | f00b3ccab2 | |
Vitor Santos Costa | c0cf2b0b83 | |
Vitor Santos Costa | ee9e596368 | |
Vitor Santos Costa | d0b2924322 | |
Vitor Santos Costa | 9272a1c7d5 | |
Vitor Santos Costa | d7e21c80df | |
Vitor Santos Costa | 6b545c8f71 | |
Vitor Santos Costa | 31f1c25ee7 | |
Vitor Santos Costa | 8ac3d980c2 | |
Vitor Santos Costa | 97aad19cd0 | |
Vitor Santoss Costa | 3a06d4fecb | |
vsc | e68630cd8a | |
Vitor Santos Costa | d06dd49dd0 | |
Vitor Santos Costa | bba62ea6eb | |
Vitor Santos Costa | ea099c83bb | |
Vitor Santos Costa | 0d96197ddf | |
vsc | c2f6d968c3 | |
vsc | 3938ed7150 | |
vsc | ebd6f0a0c2 | |
Vitor Santos Costa | 732adf9f43 | |
Vitor Santos Costa | f1ddb5822e | |
Vitor Santos Costa | 2ad3420fac | |
Vitor Santos Costa | 78768c354c | |
Vitor Santos Costa | 0c46c894d3 | |
Vitor Santos Costa | 25a2b68b15 | |
Vitor Santos Costa | 9560aa026e | |
Vitor Santos Costa | 6a2d74ac6e | |
Vitor Santos Costa | 18af47bdde | |
Vitor Santos Costa | 87851a68f4 | |
Vitor Santos Costa | a828f3f899 | |
Vitor Santos Costa | 3802a588f9 | |
Vitor Santos Costa | 386c88e372 | |
Vitor Santos Costa | 517667c1d5 | |
Vitor Santos Costa | 214daa5c40 | |
Vitor Santos Costa | 149a010e05 | |
Vitor Santos Costa | 3e3893ceff | |
Vitor Santos Costa | 48a2066f54 | |
Vitor Santos Costa | c2435673cd | |
Vitor Santos Costa | d1e39368f4 | |
Rui Afonso Pereira | 84e90d764f | |
Vitor Santos Costa | 6e7846e210 | |
Vitor Santos Costa | a6e6642eb2 | |
Vitor Santos Costa | b54dd37ef9 | |
Vitor Santos Costa | a21dce7801 | |
Vitor Santos Costa | 0320d8b49b | |
Vitor Santos Costa | 83b137f117 | |
Vitor Santos Costa | 3cb343479e | |
Vitor Santos Costa | 70232133cc | |
Vitor Santos Costa | 7063641a5b | |
Vitor Santos Costa | 4b350ccecc | |
Vitor Santos Costa | faf3c930c8 | |
Vitor Santos Costa | a9f02dddca | |
Vitor Santos Costa | af38d14ba7 | |
Vitor Santos Costa | 4180fd9737 | |
Vitor Santos Costa | 6741d961b3 | |
Vitor Santos Costa | 4deb28e4c6 | |
Vitor Santos Costa | 21ca8eccec | |
Vitor Santos Costa | 6e2260471a | |
Vitor Santos Costa | ad710f3a0c | |
vsc | 380132095a | |
vsc | f1372f72b5 | |
Vitor Santos Costa | fddb79895d | |
Vitor Santos Costa | f7efff157b | |
vsc | 9c004e5446 | |
vscosta | 34d3d7c176 | |
Vitor Santoss Costa | f3b0e962a7 | |
Vitor Santoss Costa | 477772e703 | |
Vitor Santoss Costa | fa88de5951 | |
vscosta | 6ec69aa3c8 | |
vsc | 272ddc0228 | |
Vitor Santos Costa | daffefe28d | |
Vitor Santos Costa | f426d25bef | |
Vitor Santos Costa | 65ff3ed471 | |
Vitor Santos Costa | 55879dbd6c | |
Vitor Santos Costa | 0ed4ea2aa1 | |
Vitor Santos Costa | 9e6e236ee1 | |
Vitor Santos Costa | cd776f4f70 | |
Vitor Santos Costa | b17f4967cb | |
Vitor Santos Costa | 5d6ff87d19 | |
Vitor Santos Costa | a53615ceaf | |
Vitor Santos Costa | 92e2d94186 | |
Vitor Santos Costa | a5e74eddae | |
Vitor Santos Costa | 7d230dac0f | |
Vitor Santos Costa | 8dc3503eb7 | |
Vitor Santos Costa | 53039d3785 | |
Vitor Santos Costa | c6a02d3fe4 | |
Vitor Santos Costa | 4db2a1fe7f | |
Vitor Santos Costa | 6778ea2975 | |
Vitor Santos Costa | 1e379e7635 | |
Vitor Santos Costa | 6aaa32363c | |
Vitor Santos Costa | 747b0e9501 | |
Vitor Santos Costa | 80cb881f3c | |
Vitor Santos Costa | 389a5a440d | |
Vitor Santos Costa | 436a4b4235 | |
Vitor Santos Costa | cacdd173b5 | |
Vitor Santos Costa | cd18a69561 | |
Vitor Santos Costa | 66bc426b09 | |
Vitor Santos Costa | a4bb9f6e0e | |
Vitor Santos Costa | f0740e1b8f | |
Vitor Santos Costa | 0a043720b1 | |
Vitor Santos Costa | c9309dce75 | |
Vitor Santos Costa | f98dfa6994 | |
Vitor Santos Costa | e6c021411b | |
Vitor Santos Costa | d9664b9ec4 | |
Vitor Santos Costa | b0fdea6f34 | |
Vitor Santos Costa | 82ad65a344 | |
Vitor Santos Costa | 45a54e2b04 | |
Vitor Santos Costa | 5526dc48bf | |
Vitor Santos Costa | cbb0d81ac4 | |
Vitor Santos Costa | 9f16487d0c | |
Vitor Santos Costa | d81e077cbe | |
Vitor Santos Costa | 6e2d2628c6 | |
Vitor Santos Costa | 70b11ab8f9 | |
Vitor Santos Costa | 474fa2fe14 | |
Vitor Santos Costa | ea72cd09e3 | |
Vitor Santos Costa | 4f423dc16a | |
Vitor Santos Costa | 6a4dbd91ec | |
Vitor Santos Costa | b07a35a993 | |
Vitor Santos Costa | 14e1b74572 | |
Vitor Santos Costa | 490a07ade2 | |
Vitor Santos Costa | 47b5de9bfc | |
Vitor Santos Costa | 44dab9ab33 | |
Vitor Santos Costa | d37e198c12 | |
Vitor Santos Costa | 6c96a8e35b | |
Vitor Santos Costa | f44ef18fed | |
Vitor Santos Costa | 8d1cc35a8a | |
Vitor Santos Costa | 56905d86ae | |
Vitor Santos Costa | cc7c0ebac8 | |
Vitor Santos Costa | da65d7bd3c | |
Vitor Santos Costa | 0be43c6525 | |
Vitor Santos Costa | c49165a7af | |
Vitor Santos Costa | 51359cb175 | |
Vitor Santos Costa | b03e0634c7 | |
Vitor Santos Costa | 46a9d52d2d | |
Vitor Santos Costa | 02e0e50915 | |
Vitor Santos Costa | 117584e817 | |
Vitor Santos Costa | c959ceeb1d | |
Vitor Santos Costa | d082af605d | |
Vitor Santos Costa | 8f72db3b56 | |
Fabrizio Riguzzi | e078156eb6 | |
Vitor Santos Costa | 8a6de8b157 | |
Vitor Santos Costa | ad5347257b | |
Vitor Santos Costa | 08dd1dcdb3 | |
Vitor Santos Costa | 4a5540e645 | |
Vitor Santos Costa | 558c3eb35b | |
Vitor Santos Costa | 3b124549e4 | |
Vitor Santos Costa | 5c33960535 | |
Vitor Santos Costa | 1c2880fd1b | |
Vitor Santos Costa | 4c01fe8fe3 | |
Vitor Santos Costa | df0ee8eaeb | |
Vitor Santos Costa | 43d3579c57 | |
Vitor Santos Costa | 41ccbf7367 | |
Vitor Santos Costa | ef38613229 | |
Vitor Santos Costa | 3f4fe6815f | |
Vitor Santos Costa | a1ee3b30d3 | |
Vitor Santos Costa | b0ce23f131 | |
Vitor Santos Costa | 51bf90908f | |
Vitor Santos Costa | 97350da9bd | |
Vitor Santos Costa | e39b1e0127 | |
Vitor Santos Costa | 6802e83d83 | |
Vitor Santos Costa | 94cde0bf18 | |
Vitor Santos Costa | bee39cb385 | |
Vitor Santos Costa | 298b287859 | |
Vitor Santos Costa | cd3b94c40c | |
Vitor Santos Costa | f9655cccb6 | |
Vitor Santos Costa | 2bbc3b9265 | |
Vitor Santos Costa | 09b7a5cbf9 | |
Vitor Santos Costa | 02dabe8e3a | |
Vitor Santos Costa | d273270c11 | |
Vitor Santos Costa | e70b7060d1 | |
Vitor Santos Costa | ea366ca22d | |
Vitor Santos Costa | 87c6f13976 | |
Vitor Santos Costa | 3fe4b70112 | |
Vitor Santos Costa | 48c1bed5f9 | |
Vitor Santos Costa | b5e1476a20 | |
Vitor Santos Costa | 368cfd99d5 | |
Vitor Santos Costa | ab9bff2ab5 | |
Vitor Santos Costa | b2156aad2d | |
Vitor Santos Costa | c58064bd0b | |
Vitor Santos Costa | 21324d7434 | |
Vitor Santos Costa | a478a83c27 | |
Vitor Santos Costa | f6d434e314 | |
Vitor Santos Costa | f35f0584eb | |
Vitor Santos Costa | db2aa5b5f2 | |
Vitor Santos Costa | 76b9946358 | |
Vitor Santos Costa | 868ecfe551 | |
Vitor Santos Costa | 350081a90d | |
Vitor Santos Costa | bbd9049111 | |
Vitor Santos Costa | 3845d4e67d | |
Vitor Santos Costa | 2f885bb6f3 | |
Vitor Santos Costa | 029d2836a2 | |
Vitor Santos Costa | df8b264751 | |
Vitor Santos Costa | 124b2e9069 | |
Vitor Santos Costa | 6043125221 | |
Vitor Santos Costa | 1219fb6b6a | |
Vitor Santos Costa | 7d66aa5d01 | |
Vitor Santos Costa | c78f3e085a | |
Vitor Santos Costa | e2f8430e00 | |
Vitor Santos Costa | c46228a03b | |
Vitor Santos Costa | 9bdfabc381 | |
Vitor Santos Costa | e4c82910a2 | |
Vitor Santos Costa | 1e118bee6d | |
Vitor Santos Costa | 06bbdfd553 | |
Vitor Santos Costa | 04ff54917e | |
Vitor Santos Costa | 110a23b209 | |
Vitor Santos Costa | 5fcf173d0a | |
Vitor Santos Costa | 269e7b8806 | |
Vitor Santos Costa | 1ead544a50 | |
Vitor Santos Costa | 15c6381579 | |
Vitor Santos Costa | 85a88feb6f | |
Vitor Santos Costa | 76638bb7d8 | |
Vitor Santos Costa | 1a878579fd | |
Vitor Santos Costa | a5c09f9187 | |
Vitor Santos Costa | aba60111cf | |
Vitor Santos Costa | 1bcbd5ce15 | |
Vitor Santos Costa | e157740bda | |
Vitor Santos Costa | f12349993b | |
Vitor Santos Costa | 79791604d9 | |
Vitor Santos Costa | 67b72f4958 | |
Vitor Santos Costa | f2c6c85c17 | |
Vitor Santos Costa | b378cb8469 | |
Vitor Santos Costa | cd53167d19 | |
Vitor Santos Costa | 676582fe4f | |
Vitor Santos Costa | 227c75a213 | |
Vitor Santos Costa | d9c1c85d30 | |
Vitor Santos Costa | 6148e8199f | |
Vitor Santos Costa | cbef36b565 | |
Vitor Santos Costa | 1bea4230e4 | |
Vitor Santos Costa | cbafd93b03 | |
Vitor Santos Costa | 6f6e294703 | |
Vitor Santos Costa | ba98f237ae | |
Vitor Santos Costa | 23c1c2d4d7 | |
Vitor Santos Costa | 9ed1546ee6 | |
Vitor Santos Costa | 297aae9d36 | |
Vitor Santos Costa | c4544f042d | |
Vitor Santos Costa | f78ddb6724 | |
Vitor Santos Costa | fce05b85d3 | |
Vitor Santos Costa | eea3da22f1 | |
Vitor Santos Costa | a675f6f49e | |
Vitor Santos Costa | 997a0b9895 | |
Vitor Santos Costa | ce4b6c0931 | |
Vitor Santos Costa | 4dcbac42e9 | |
Vitor Santos Costa | 0b635cb2d5 | |
Vitor Santos Costa | 25e59ecd40 | |
Vitor Santos Costa | e9e03f11d3 | |
Vitor Santos Costa | ddf40b67bd | |
Vitor Santos Costa | fe1a677778 | |
Vitor Santos Costa | 9e59f755ff | |
Vitor Santos Costa | ba730273e7 | |
Vitor Santos Costa | e50d722e66 | |
Vitor Santos Costa | 2aaca174e5 | |
Vitor Santos Costa | b80a6bad97 | |
Vitor Santos Costa | b218af8f1b | |
Vitor Santos Costa | 56b2f14a32 | |
Vitor Santos Costa | 03afaaf887 | |
Vitor Santos Costa | 843f9f8d87 | |
Vitor Santos Costa | b27ab0811b | |
Vitor Santos Costa | f6935510a9 | |
Vitor Santos Costa | 56466a446a | |
Vitor Santos Costa | 670eacc823 | |
Vitor Santos Costa | a270349dae | |
Vitor Santos Costa | 9e5675755e | |
Vitor Santos Costa | 2d94bba498 | |
Vitor Santos Costa | 2a9a88c325 | |
Vitor Santos Costa | 3eeaac8d05 | |
Vitor Santos Costa | 93068241d3 | |
Vitor Santos Costa | 2726fb279c | |
Vitor Santos Costa | fab0075f9b | |
Vitor Santos Costa | 0f32e2cc9f | |
Vitor Santos Costa | 27273290e1 | |
Vitor Santos Costa | f8b0cb2c2d | |
Vitor Santos Costa | eb54e3e052 | |
Vitor Santos Costa | cc1a44c7a7 | |
Vitor Santos Costa | 7b86e28e00 | |
Vitor Santos Costa | 44262405df | |
Vitor Santos Costa | ed6385a3e7 | |
Vitor Santos Costa | cad55bcf71 | |
Vitor Santos Costa | fccf3d9f6f | |
Vitor Santos Costa | 2595555982 | |
Vitor Santos Costa | 02bd8a1760 | |
Vitor Santos Costa | a4fa6c5b4b | |
Vitor Santos Costa | afeb4b2870 | |
Vitor Santos Costa | 121d927e85 | |
Vitor Santos Costa | 05d65070b8 | |
Vitor Santos Costa | 7dcd5179ce | |
Vitor Santos Costa | 8f3321d36b | |
Vitor Santos Costa | 9386d70280 | |
Vitor Santos Costa | 339048c76b | |
Vitor Santos Costa | 04b1d2bafb | |
Vitor Santos Costa | 729b798a23 | |
Vitor Santos Costa | b3a11b339a | |
Vitor Santos Costa | 0aeeb726e3 | |
Vitor Santos Costa | 3d4a525e32 | |
Vitor Santos Costa | 0f19d518f2 | |
Vitor Santos Costa | fdfefbbd46 | |
Vitor Santos Costa | 833ffbb104 | |
Vitor Santos Costa | 384e74ae59 | |
Vitor Santos Costa | be1ce69e07 | |
Vitor Santos Costa | 26d2e9721c | |
Vitor Santos Costa | 8594c41487 | |
Vitor Santos Costa | fd23360c63 | |
Vitor Santos Costa | b705c07ac8 | |
Vitor Santos Costa | c79a5ec372 | |
Vitor Santos Costa | 471d6e4f77 | |
Vitor Santos Costa | 0029fdd0b4 | |
Vitor Santos Costa | b8045f1a39 | |
Vitor Santos Costa | f5e560366c | |
Vitor Santos Costa | 2038dd42b6 | |
Vitor Santos Costa | e16c8c573d | |
Vitor Santos Costa | ca2dfeb51e | |
Vitor Santos Costa | 3ff5ddf04a | |
Vitor Santos Costa | 69c3a54cb6 | |
Vitor Santos Costa | 99488a6cea | |
Vitor Santos Costa | a560031167 | |
Vitor Santos Costa | 0dd5da91ca | |
Vitor Santos Costa | 8050747db7 | |
Vitor Santos Costa | 2dbf860a58 | |
Vitor Santos Costa | 9ef2f87165 | |
Vitor Santos Costa | 79a154cbf4 | |
Vitor Santos Costa | d54446d736 | |
Vitor Santos Costa | 4628adc63e | |
Vitor Santos Costa | d0a8e4a722 | |
Vitor Santos Costa | 5e7c08fff7 | |
Vitor Santos Costa | 304489c74f | |
Vitor Santos Costa | a82a72fc14 | |
Vitor Santos Costa | db0deea576 | |
Vitor Santos Costa | 1d84d39b00 | |
Vitor Santos Costa | afc6e64db2 | |
Vitor Santos Costa | 897d59820f | |
Vitor Santos Costa | 9e01be6a22 | |
Vitor Santos Costa | 8e52352878 | |
Vitor Santos Costa | 7651f507c6 | |
Vitor Santos Costa | 8973689b43 | |
Vitor Santos Costa | 957aa9f977 | |
Vitor Santos Costa | 81c00f9736 | |
Vitor Santos Costa | bff0440b64 | |
Vitor Santos Costa | ccc2efd456 | |
Vitor Santos Costa | 750b31b29a | |
Vitor Santos Costa | 99e9809320 | |
Vitor Santos Costa | d8ee7b1f89 | |
Vitor Santos Costa | 6163533208 | |
Vitor Santos Costa | 37ddd18a9d | |
Vitor Santos Costa | 73b10e7207 | |
Vitor Santos Costa | 50e94c9094 | |
Vitor Santos Costa | d7b5be0ccd | |
Vitor Santos Costa | 5b8dd3eb03 | |
Vitor Santos Costa | cbe205344d | |
Vitor Santos Costa | 0248e3ec2f | |
Vitor Santos Costa | bb4820a086 | |
Vitor Santos Costa | 2fef5ffcea | |
Vitor Santos Costa | f7a2c479e7 | |
Vitor Santos Costa | 275e2c0059 | |
Vitor Santos Costa | 9686275b34 | |
Vitor Santos Costa | 1aa3c26af6 | |
Vitor Santos Costa | 7cda920dbc | |
Vitor Santos Costa | 915316b712 | |
Vitor Santos Costa | a2ab31757f | |
Vitor Santos Costa | e138472f87 | |
Vitor Santos Costa | 83326f1657 | |
Vitor Santos Costa | 1c698f596c | |
Vitor Santos Costa | 71afcd0350 | |
Vitor Santos Costa | f6a90c0cac | |
Vitor Santos Costa | 12664254e9 | |
Vitor Santos Costa | a21547d9d4 | |
Vitor Santos Costa | 9ac1b3f2c6 | |
Vitor Santos Costa | 9db06bcfe1 | |
Vitor Santos Costa | 5db8e25735 | |
Vitor Santos Costa | 77335f2ea0 | |
Vitor Santos Costa | 4477350d08 | |
Vitor Santos Costa | 43993f2b08 | |
Vitor Santos Costa | 14d8b7904f | |
Vitor Santos Costa | 19ec491d22 | |
Vitor Santos Costa | 7a7d36a3ef | |
Vitor Santos Costa | afc0f4386c | |
Vitor Santos Costa | 8d19f397d4 | |
Vitor Santos Costa | 91120de170 | |
Vitor Santos Costa | 0c305e8ce3 | |
Vitor Santos Costa | 9ad6bc3120 | |
Vitor Santos Costa | a8f101cbcf | |
Vitor Santos Costa | d5ce45f09f | |
Vitor Santos Costa | 2213bc6f36 | |
Vitor Santos Costa | 460dfafcc8 | |
Vitor Santos Costa | be313a5b49 | |
Vitor Santos Costa | 468a2279c3 | |
Vitor Santos Costa | 4fa33de8a8 | |
Vitor Santos Costa | 168d0b41ec | |
Vitor Santos Costa | 591d5a8653 | |
Vitor Santos Costa | b6f1079503 | |
Vitor Santos Costa | 04fd092e49 | |
Vitor Santos Costa | 133a4fc215 | |
Vitor Santos Costa | d91a0130fa | |
Vitor Santos Costa | 2e6572bfe5 | |
Vitor Santos Costa | 57ae30c79c | |
Vitor Santos Costa | fa26588bbf | |
Vitor Santos Costa | 9d3b46132b | |
Vitor Santos Costa | d3599da6dc | |
Vitor Santos Costa | c6d174841a | |
Vitor Santos Costa | ee03af37fb | |
Vitor Santos Costa | 728edb6b0a | |
Vitor Santos Costa | 84d5974cca | |
Vitor Santos Costa | 9b3bbf5e33 | |
Vitor Santos Costa | 5f2964cce6 | |
Vitor Santos Costa | 63b985c452 | |
Vitor Santos Costa | 943900865e | |
Vitor Santos Costa | 6a076bc8ac | |
Vitor Santos Costa | 8ecb045cb5 | |
Vitor Santos Costa | 5584eb1a55 | |
Vitor Santos Costa | 0f50b2e49c | |
Vitor Santos Costa | dfd7b8f467 | |
Vitor Santos Costa | 7d6082d39a | |
Vitor Santos Costa | 35e9d432c1 | |
Vitor Santos Costa | 6a878d9568 | |
Vitor Santos Costa | d922933898 | |
Vitor Santos Costa | d4b77458e9 | |
Vitor Santos Costa | 2422417a05 | |
Vitor Santos Costa | c663010312 | |
Vitor Santos Costa | d8fd3de13a | |
Vitor Santos Costa | f474dbdb2a | |
Vitor Santos Costa | 9bfdfeb204 | |
Vitor Santos Costa | 557c89a4ad | |
Vitor Santos Costa | 4ebb83e998 | |
Vitor Santos Costa | 0cc010bc42 | |
Vitor Santos Costa | 075f50a11f | |
Vitor Santos Costa | 2b5f0e7705 | |
Vitor Santos Costa | d6c768da2c | |
Vitor Santos Costa | 5606410a64 | |
Vitor Santos Costa | 1da507902c | |
Vitor Santos Costa | f555ea958c | |
Vitor Santos Costa | 1740175e5c | |
Vitor Santos Costa | 85bcce7d19 | |
Vitor Santos Costa | 72fcd2befa | |
Vitor Santos Costa | fb08cfe5f6 | |
Vitor Santos Costa | 7d44e3188b | |
Vitor Santos Costa | 0dd8f62237 | |
Vitor Santos Costa | 60687f4346 | |
Vitor Santos Costa | 3f59ec40cd | |
Vitor Santos Costa | c2fb631106 | |
Vitor Santos Costa | d9b5a21a54 | |
Vitor Santos Costa | 06f5fa2614 | |
Vitor Santos Costa | a6a769c0de | |
Vitor Santos Costa | ff3185b551 | |
Vitor Santos Costa | 8d64753c54 | |
Vitor Santos Costa | 7ca285eb40 | |
Vitor Santos Costa | 736c8ee66e | |
Vitor Santos Costa | dbda4a4d7b | |
Vitor Santos Costa | 46bf534a27 | |
Vitor Santos Costa | 37155d7296 | |
Vitor Santos Costa | ab135e8b74 | |
Vitor Santos Costa | 19a265073f | |
Vitor Santos Costa | 4123764fcc | |
Vitor Santos Costa | e6eff20e82 | |
Vitor Santos Costa | 2b9b92dac7 | |
Vitor Santos Costa | a382ca43fa | |
Vitor Santos Costa | 4b33d5d87b | |
Vitor Santos Costa | a9839b4d4a | |
Vitor Santos Costa | d1b0f45c28 | |
Vitor Santos Costa | eab3fc33be | |
Vitor Santos Costa | fdc01b0c27 | |
Vitor Santos Costa | 8d126b7de6 | |
Vitor Santos Costa | a94260bd33 | |
Vitor Santos Costa | dc2ed1bea8 | |
Vitor Santos Costa | b2fe557503 | |
Vitor Santos Costa | 710ca208d2 | |
Vitor Santos Costa | 735ccca095 | |
Vitor Santos Costa | 79d40f57b1 | |
Vitor Santos Costa | 647ebac5e4 | |
Vitor Santos Costa | 3c28902ec5 | |
Vitor Santos Costa | 3dfab64306 | |
Vitor Santos Costa | 72f72929d3 | |
Vitor Santos Costa | 0007cb896b | |
Vitor Santos Costa | 8f489b0799 | |
Vitor Santos Costa | 57161d83f4 | |
Vitor Santos Costa | a1ec5e6198 | |
Vitor Santos Costa | 730259d47e | |
Vitor Santos Costa | 5c83d305fc | |
Vitor Santos Costa | 899e892aef | |
Vitor Santos Costa | 807cca51ec | |
Vitor Santos Costa | da6d41433f | |
Vitor Santos Costa | a7720d42ed | |
Vitor Santos Costa | a1a4ac9d0b | |
Vitor Santos Costa | e6bbcc566c | |
Vitor Santos Costa | cd05e3f6d8 | |
Vitor Santos Costa | eecc4ecf06 | |
Vitor Santos Costa | 7278d9ee0e | |
Vitor Santos Costa | 8e5352bc03 | |
Vitor Santos Costa | ba78620e34 | |
Vitor Santos Costa | 42347585d3 | |
Vitor Santos Costa | b2cec5467c | |
Vitor Santos Costa | 3c91e1c9a0 | |
Vitor Santos Costa | 0069222b75 | |
Vitor Santos Costa | 00cfb6e432 | |
Vitor Santos Costa | 67c4e14318 | |
Vitor Santos Costa | 8bb7aaad92 | |
Vitor Santos Costa | f905e4d297 | |
Vitor Santos Costa | 67aba666c6 | |
Vitor Santos Costa | 99b3d0db99 | |
Vitor Santos Costa | 31abcd01c3 | |
Vitor Santos Costa | 52801b660f | |
Vitor Santos Costa | 32743f3731 | |
Vitor Santos Costa | 8ce16f64d9 | |
Vitor Santos Costa | 79e6e3fcc1 | |
Vitor Santos Costa | 0779639baf | |
Vitor Santos Costa | e441f30c4c | |
Vitor Santos Costa | dce28a774e | |
Vitor Santos Costa | 5fd4413ffd | |
Vitor Santos Costa | f7c3aef830 | |
Vitor Santos Costa | 66709db4bb | |
Joseph Lee Nunn III | de693e2095 | |
Vitor Santos Costa | d0658b7b53 | |
Vitor Santos Costa | 8f3bb7fe26 | |
Vitor Santos Costa | 71c49f5063 | |
Vitor Santos Costa | 4ac6d11dca | |
Vitor Santos Costa | 33fa5fa3c0 | |
Vitor Santos Costa | d38986fa07 | |
Vitor Santos Costa | 5d4ee60fc9 | |
Vitor Santos Costa | ceb26b68a0 | |
Vitor Santos Costa | cd7571da7a | |
Vitor Santos Costa | a9fe413dd0 | |
Vitor Santos Costa | 437a303681 | |
Vitor Santos Costa | 7c1ea8f3ae | |
Vitor Santos Costa | d00698b76a | |
Vitor Santos Costa | a5bb2e226c | |
Vitor Santos Costa | ef676f68b0 | |
Vitor Santos Costa | 9fcbfca1fa | |
Vitor Santos Costa | f54e11db94 | |
Vitor Santos Costa | 9f2ba2d4fb | |
Vitor Santos Costa | 87e13a9730 | |
Vitor Santos Costa | a72e66d2ae | |
Vitor Santos Costa | 214b6a74ff | |
Vitor Santos Costa | 8e3789d92a | |
Vitor Santos Costa | af61c886b4 | |
Vitor Santos Costa | 9f664c9e36 | |
Vitor Santos Costa | d375d0ffbb | |
Vitor Santos Costa | 7b977c2538 | |
Vitor Santos Costa | 52442e08ec | |
Vitor Santos Costa | eadfef6c3f | |
Vitor Santos Costa | 3b8325bd41 | |
Vitor Santos Costa | d86f0d1942 | |
Vitor Santos Costa | c0db3d4e18 | |
Vitor Santos Costa | 3a9ecf929e | |
Vitor Santos Costa | 428a6255e1 | |
Vitor Santos Costa | 03da182460 | |
Vitor Santos Costa | e5891afe44 | |
Vitor Santos Costa | b28deedffe | |
Vitor Santos Costa | 033d77b47a | |
Vitor Santos Costa | d58c071200 | |
Vitor Santos Costa | 70f6080857 | |
Vitor Santos Costa | abe1168b1d | |
Vitor Santos Costa | d46bef3adb | |
Vitor Santos Costa | ea7d247ec8 | |
Vitor Santos Costa | 1573d5ebd2 | |
Vitor Santos Costa | 9391a1499d | |
Vitor Santos Costa | 969b022e1c | |
Vitor Santos Costa | c5323b2920 | |
Vitor Santos Costa | e92062886b | |
Vitor Santos Costa | 407280ea3b | |
Vitor Santos Costa | 516f89b76d | |
Vitor Santos Costa | e98c4c9f2a | |
Vitor Santos Costa | efe827db6c | |
Vitor Santos Costa | f94bec3cfc | |
Vitor Santos Costa | 2eab5ef225 | |
Vitor Santos Costa | 91e5f03121 | |
Vitor Santos Costa | 18ed15a4ce | |
Vitor Santos Costa | 83a1269553 | |
Vitor Santos Costa | d7318266fe | |
Vitor Santos Costa | 1e8c0b6583 | |
Vitor Santos Costa | c8f1e8a74a | |
Vitor Santos Costa | 70061308ff | |
Vitor Santos Costa | 61ba15fa3a | |
Vitor Santos Costa | 235179ff47 | |
Vitor Santos Costa | f23b8b5418 | |
Vitor Santos Costa | 9b89e6fd92 | |
Vitor Santos Costa | f039a5d688 | |
Vitor Santos Costa | 9d0722bf2f | |
Vitor Santos Costa | 443fe5af18 | |
Vitor Santos Costa | c0a45cf42c | |
Vitor Santos Costa | 2550fc5b87 | |
Vitor Santos Costa | dbd4c979b1 | |
Vitor Santos Costa | 30593e86d6 | |
Vitor Santos Costa | f4111997e7 | |
Vitor Santos Costa | c06d07985e | |
Vitor Santos Costa | b0766abb5c | |
Vitor Santos Costa | 768b17751b | |
Vitor Santos Costa | 445a7f33c1 | |
Vitor Santos Costa | ea90785c6a | |
Vitor Santos Costa | f966a5b912 | |
Vitor Santos Costa | cd41d373db | |
Vitor Santos Costa | 3d68f0e06b | |
Vitor Santos Costa | 96f03e26e8 | |
Vitor Santos Costa | 49699f52e9 | |
Vitor Santos Costa | 3ac1a285a9 | |
Vitor Santos Costa | 6880fc20a6 | |
vscosta | 37649b7d1a | |
vscosta | c1b8d140db | |
vscosta | 76f4868ff6 | |
Vitor Santos Costa | 068b624fca | |
Vitor Santos Costa | 631eb4c265 | |
Vitor Santos Costa | ab1b8cea39 | |
Vitor Santos Costa | 6ff24e9a16 | |
Vitor Santos Costa | 97375d010b | |
Vitor Santos Costa | a761bd752c | |
Vitor Santos Costa | 05a76a2b3f | |
Vitor Santos Costa | 1aa20e24b7 | |
Vitor Santos Costa | 29fba0238d | |
Vitor Santos Costa | 5a5829a583 | |
Vitor Santos Costa | 786cfb71ad | |
Vitor Santos Costa | c0c002134b | |
Vitor Santos Costa | e6c2503563 | |
Vitor Santos Costa | 69bb5c4d08 | |
Vitor Santos Costa | 65f1cb9741 | |
vscosta | 5830eacfec | |
vscosta | 2a119fdf5e | |
vscosta | 2f5386bd6f | |
vscosta | 6ee452f0c5 | |
vscosta | 948c8e7cbb | |
vscosta | c3488eeaed | |
vscosta | 6b4cc7f8ff | |
vscosta | 1649366574 | |
vscosta | 429c8155c9 | |
Vitor Santos Costa | fa650a6440 | |
Vitor Santos Costa | b7eb38fc44 | |
Vitor Santos Costa | da315b2688 | |
Vitor Santos Costa | d680fa0755 | |
Vitor Santos Costa | 106e4bc13f | |
Vitor Santos Costa | c7bc27cc3e | |
Vitor Santos Costa | b89f6e55b4 | |
Vitor Santos Costa | 55a840e2d8 | |
Vitor Santos Costa | 93bba89d52 | |
Vitor Santos Costa | 4cdbabfa69 | |
Vitor Santos Costa | eb5d90d85f | |
Vitor Santos Costa | e485dbc59b | |
Vitor Santos Costa | dfbdce4240 | |
Vitor Santos Costa | 5dbe54dadc | |
Vitor Santos Costa | 7bf8a20f1b | |
Vitor Santos Costa | 867c9ea47c | |
Vitor Santos Costa | 2e238f6bc1 | |
vscosta | 71f0076ed6 | |
vscosta | 4d3d9c408d | |
vscosta | a5951daea9 | |
vscosta | 562ac0251d | |
vscosta | ac71ba72b5 | |
vscosta | 24e6924769 | |
vscosta | abe5953da7 | |
vscosta | 079ed60248 | |
vscosta | d9bfcc0f78 | |
vscosta | 07f105dd80 | |
vscosta | d4a9f97cdd | |
vscosta | 40765a6afb | |
vscosta | 7312765824 | |
vscosta | 396bd2f8c3 | |
Vítor Santos Costa | 636992781c | |
Vítor Santos Costa | 145ad73255 | |
Vítor Santos Costa | 78ba5d01f2 | |
Vítor Santos Costa | 2d8fdad839 | |
Vítor Santos Costa | a304fc721a | |
Vítor Santos Costa | 6b141078b4 | |
Vítor Santos Costa | 1c2383b5b9 | |
Vítor Santos Costa | e0d82cfb23 | |
Vítor Santos Costa | 4103aa6e83 | |
Vítor Santos Costa | f3e8b8b3da | |
Vítor Santos Costa | 6bc4acec15 | |
Vítor Santos Costa | 9dacc20d34 | |
Vítor Santos Costa | 06e5371afd | |
Vítor Santos Costa | 2dae2363a3 | |
Vítor Santos Costa | 9f722319ec | |
Vítor Santos Costa | cda490eda8 | |
Vítor Santos Costa | 1be002558c | |
Vítor Santos Costa | fa69950c67 | |
Vítor Santos Costa | f6379bcd48 | |
Vítor Santos Costa | e9cac424f0 | |
Vítor Santos Costa | 88b179b603 | |
Vítor Santos Costa | 9d1fa8a907 | |
Vítor Santos Costa | cd1497c475 | |
Vítor Santos Costa | b4742fb3cf | |
Vítor Santos Costa | 17ef6ddf34 | |
Vítor Santos Costa | bac60d2d94 | |
Vítor Santos Costa | bc914e9e91 | |
Vítor Santos Costa | 79d99a7768 | |
Vítor Santos Costa | 23d18ac0fd | |
Vítor Santos Costa | a32ac66167 | |
Vítor Santos Costa | 1155b6b876 | |
Vítor Santos Costa | da51cfe6b9 | |
Vítor Santos Costa | cec2e9638a | |
Vítor Santos Costa | 0f4448fdbe | |
Vítor Santos Costa | 59b1aa9129 | |
Vítor Santos Costa | 812a88e277 | |
Vítor Santos Costa | fdcc75d4ae | |
Vítor Santos Costa | 2fe198f68a | |
Vítor Santos Costa | 50bfe3c014 | |
Vítor Santos Costa | 0522720ff4 | |
Vítor Santos Costa | 0fc0e96306 | |
Vítor Santos Costa | f1c9c08f1f | |
Vítor Santos Costa | 001b169d81 | |
Vítor Santos Costa | 52f949d3f9 | |
Vítor Santos Costa | 87c58493d4 | |
Vítor Santos Costa | 96bc776375 | |
Vítor Santos Costa | 5a95c6bbc7 | |
Vítor Santos Costa | 27b7e32036 | |
Vítor Santos Costa | b50cf8d7b4 | |
Vítor Santos Costa | 8c7756f8fb | |
Vítor Santos Costa | f20599478e | |
Vítor Santos Costa | d3796aba5a | |
Vítor Santos Costa | 5f9752baff | |
Vítor Santos Costa | 0db27196aa | |
Vítor Santos Costa | 5c4cedd4fc | |
Vítor Santos Costa | c552dc6a2c | |
Vítor Santos Costa | b384c40213 | |
Vítor Santos Costa | 638f784f81 | |
Vítor Santos Costa | e81acc117b | |
Vítor Santos Costa | b9eb327d86 | |
Vítor Santos Costa | 0ccee1aa55 | |
Vítor Santos Costa | 2192f73b11 | |
Vítor Santos Costa | 7cc9d2f882 | |
Vítor Santos Costa | 675befae75 | |
Vítor Santos Costa | 56e9a8f8d9 | |
Vítor Santos Costa | 25ee4dd7e8 | |
Vítor Santos Costa | 1f29aea94b | |
Vítor Santos Costa | 56ebb0a91a | |
Vítor Santos Costa | d8a7d05e01 | |
Vítor Santos Costa | 733a03beef | |
Vítor Santos Costa | 77123269e7 | |
Vítor Santos Costa | 54985f4678 | |
Vítor Santos Costa | 62e0f0bece | |
Vítor Santos Costa | 6ceb0bf9f3 | |
Vítor Santos Costa | e9712bc9ab | |
Vítor Santos Costa | 7d3053b906 | |
Vítor Santos Costa | 68633a9c34 | |
Vítor Santos Costa | 0e50546005 | |
Vítor Santos Costa | f823ded57f | |
Vítor Santos Costa | d9fe5133d3 | |
Vítor Santos Costa | 0e7cc378af | |
Vítor Santos Costa | 46140f434d | |
Vítor Santos Costa | d2dceb91d3 | |
Vítor Santos Costa | bc291ed08b | |
Vítor Santos Costa | 34b731a4ae | |
Vítor Santos Costa | c25d35356a | |
Vítor Santos Costa | a448e25d8d | |
Vítor Santos Costa | e4e59dedf7 | |
Vítor Santos Costa | 3af377d610 | |
Vítor Santos Costa | 6f1b5fbef9 | |
Vítor Santos Costa | 712d79c7bb | |
Vítor Santos Costa | 588ef40a16 | |
Vítor Santos Costa | df7feea0aa | |
Vítor Santos Costa | 98bd9d7400 | |
Vítor Santos Costa | c7049b5467 | |
Vítor Santos Costa | 405b20e8fa | |
Vítor Santos Costa | 28b1262455 | |
Vítor Santos Costa | bd72ec8f50 | |
Vítor Santos Costa | f017f38dee | |
Vítor Santos Costa | d5862139c8 | |
Vítor Santos Costa | f7d23f9deb | |
Vítor Santos Costa | 19cedad41d | |
Vítor Santos Costa | 20f639fe7b | |
Vítor Santos Costa | 2cacf6f63a | |
Vítor Santos Costa | 8f9fa802a9 | |
Vítor Santos Costa | 1d76cfc7cb | |
Vítor Santos Costa | 26013e2fb9 | |
Vítor Santos Costa | 504734c879 | |
Vítor Santos Costa | 1c68deb663 | |
Vítor Santos Costa | b7ee47ce46 | |
Vítor Santos Costa | ef06ebe698 | |
vscosta | 52d0a38f8f | |
vscosta | 33ebe61371 | |
Vítor Santos Costa | 88df20efca | |
Vítor Santos Costa | eec32e698a | |
DouglasRMiles | 84b617314a | |
Edward J. Schwartz | 12941d9b50 | |
Vítor Santos Costa | bc71e54f20 | |
Vítor Santos Costa | b27c1964bf | |
Vítor Santos Costa | d8620c785e | |
Vítor Santos Costa | efece26020 | |
Vítor Santos Costa | 7b2ff0f16d | |
Vítor Santos Costa | 24bf4088d7 | |
Vítor Santos Costa | 083d374e02 | |
Vítor Santos Costa | ad91eb0ec9 | |
Vítor Santos Costa | 091be7677a | |
Vítor Santos Costa | c381dbe318 | |
Vítor Santos Costa | 56024b2a2c | |
vscosta | a5e99e09bd | |
Vitor Santos Costa | 0e58a8f41e | |
Vítor Santos Costa | fa0ef4e0c8 | |
Vítor Santos Costa | 484168b1ce | |
Edward J. Schwartz | 9b38690055 | |
Edward J. Schwartz | 693272ecdf | |
Vítor Santos Costa | 05a978ce82 | |
Vítor Santos Costa | fb966536a9 | |
Vítor Santos Costa | 0a9f37710c | |
Vítor Santos Costa | ae65bb0265 | |
Vítor Santos Costa | 42091deffc | |
Vítor Santos Costa | 7b8c1815ae | |
Vítor Santos Costa | aed44554f2 | |
Vítor Santos Costa | 92cb3e34eb | |
Vítor Santos Costa | df0b3d3a0d | |
Vítor Santos Costa | 4138e46955 | |
Vítor Santos Costa | afa085de28 | |
Vítor Santos Costa | 9860b6244f | |
Vítor Santos Costa | 994c5d0dfd | |
Vítor Santos Costa | 1deb238d10 | |
Vítor Santos Costa | 78327cf885 | |
Vítor Santos Costa | 48db20515f | |
Vítor Santos Costa | 52a2d00d0c | |
Vítor Santos Costa | c918c052fc | |
Vítor Santos Costa | bea2431c3e | |
Vítor Santos Costa | 8f9fb0437c | |
Vítor Santos Costa | 21fa15bf10 | |
V'itor Santos Costa | 485d20d908 | |
V'itor Santos Costa | 255da61029 | |
V'itor Santos Costa | ee0335124f | |
V'itor Santos Costa | 9a071d5823 | |
V'itor Santos Costa | 6961626a3d | |
V'itor Santos Costa | 74b2b5561d | |
V'itor Santos Costa | f440981b41 | |
V'itor Santos Costa | 574ab5d0ca | |
V'itor Santos Costa | be835c73e6 | |
V'itor Santos Costa | b13dc6812c | |
V'itor Santos Costa | 55deb884d4 | |
Vitor Santos Costa | c8305988ca | |
Vitor Santos Costa | 143684731e | |
Fabrizio Riguzzi | ec999c1126 | |
Fabrizio Riguzzi | 504407eac3 | |
Vitor Santos Costa | e97eb4696e | |
Vítor Santos Costa | c6b7a186c1 | |
Vítor Santos Costa | 965eb4739e | |
V'itor Santos Costa | 77d3101bd8 | |
V'itor Santos Costa | d83c62051b | |
Vítor Santos Costa | a7874dee62 | |
Vítor Santos Costa | 9b38290b8c | |
Vítor Santos Costa | f031e78def | |
Vítor Santos Costa | 7aba41e7c2 | |
Vítor Santos Costa | 3de5b2c2de | |
Vítor Santos Costa | c9babdd03e | |
Vítor Santos Costa | 73f6c456ae | |
Vítor Santos Costa | 0671a1623c | |
Vítor Santos Costa | 60216989f3 | |
Vítor Santos Costa | a143f07ca0 | |
Vítor Santos Costa | cdad87a6fc | |
Vítor Santos Costa | c428e2256d | |
Vítor Santos Costa | c40899d8ec | |
Vítor Santos Costa | 1f7608a735 | |
Vítor Santos Costa | bd337494f1 | |
Vítor Santos Costa | 32f6c44dea | |
Vítor Santos Costa | ae771e70e2 | |
Vítor Santos Costa | b28532a251 | |
Vítor Santos Costa | e5009c733e | |
Vítor Santos Costa | ad7bef51c6 | |
Vítor Santos Costa | 06a2caf7a9 | |
Vítor Santos Costa | 794d04c851 | |
Vítor Santos Costa | 825bfd11c2 | |
Vítor Santos Costa | 5073ff9b43 | |
Vítor Santos Costa | 8c873350c9 | |
Vítor Santos Costa | 017e356cfb | |
Vítor Santos Costa | 8cf73c59ae | |
Vítor Santos Costa | 9c78086a6a | |
Vítor Santos Costa | 35eb33e27f | |
Vítor Santos Costa | 1ebaf342b6 | |
Vítor Santos Costa | 680dae240f | |
Vítor Santos Costa | ebc73ec01e | |
Vítor Santos Costa | 52b282442f | |
Vítor Santos Costa | 4ff7bdd340 | |
Vítor Santos Costa | 5c1c9a8570 | |
Vítor Santos Costa | fbf0c6bd0d | |
Vítor Santos Costa | 7491481e8e | |
Vítor Santos Costa | 1b98e2238c | |
Vítor Santos Costa | 515d5f3705 | |
Vítor Santos Costa | 4f0c539ed6 | |
Vítor Santos Costa | f5c493507e | |
Vítor Santos Costa | 9444c36ff4 | |
Vítor Santos Costa | d90a0f72b0 | |
Vítor Santos Costa | ddabfe45b8 | |
Vítor Santos Costa | 015fbe6703 | |
Vítor Santos Costa | d573407b4d | |
Vítor Santos Costa | 2edae59610 | |
Vítor Santos Costa | 697f57ecef | |
Vitor Santos Costa | 247aa763b5 | |
Vítor Santos Costa | 703ac35735 | |
Vítor Santos Costa | ca2cd734a2 | |
Vítor Santos Costa | a249156989 | |
Vítor Santos Costa | e8f87d2875 | |
Vítor Santos Costa | 10a29998a3 | |
Vítor Santos Costa | 8c69e3811e | |
Vítor Santos Costa | 3074256cc1 | |
Vítor Santos Costa | 828c2c9f6e | |
Vítor Santos Costa | 3966bf2ee1 | |
Vítor Santos Costa | f7207f3c9d | |
Vítor Santos Costa | a2f1ed92ea | |
Vítor Santos Costa | 77a5090276 | |
Vítor Santos Costa | 8c7c258492 | |
Vítor Santos Costa | 97feeda48a | |
Vítor Santos Costa | 6b60742700 |
|
@ -0,0 +1,203 @@
|
|||
*~
|
||||
*.itf
|
||||
*.po
|
||||
*.qlf
|
||||
*.xwam
|
||||
*.wam
|
||||
*.ma
|
||||
*.s
|
||||
*.o
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
docs/yap.info*
|
||||
.build
|
||||
tags
|
||||
TGSautom4te.cache
|
||||
cscope.*
|
||||
GPATH
|
||||
m32
|
||||
GRTAGS
|
||||
GTAGS
|
||||
tmtags*
|
||||
.autotools
|
||||
.Rhistory
|
||||
.zedstate
|
||||
config.h
|
||||
Yap.h
|
||||
YapConfig.h
|
||||
YapTermConfig.h
|
||||
.graffiti
|
||||
.#*#
|
||||
*/#*#
|
||||
*bak
|
||||
*rej
|
||||
*.db
|
||||
groups
|
||||
*.ede
|
||||
.??*
|
||||
*ggtags*
|
||||
.atom-build.josn
|
||||
.autotools
|
||||
.cproject
|
||||
.dir-locals.el
|
||||
.DS_store
|
||||
.kateproject
|
||||
.project
|
||||
.pydevproject
|
||||
.Rhistory
|
||||
.zedstate
|
||||
.graffiti
|
||||
.kateproject
|
||||
autom4te.cache
|
||||
*rej
|
||||
#*
|
||||
#*#
|
||||
config.h
|
||||
*.html
|
||||
packages/gecode/dev
|
||||
JIT/HPP/bkp
|
||||
cmake_install.cmake
|
||||
cmake_clean.cmake
|
||||
*.build
|
||||
C/myabsmi.c
|
||||
*.ctags#
|
||||
*.hs
|
||||
CMakeFiles
|
||||
*.make
|
||||
C/new_iop.c
|
||||
*.pdf
|
||||
*.log
|
||||
*.orig
|
||||
JIT/HPP/#JIT_In#
|
||||
*.text
|
||||
yap
|
||||
*startup.yss
|
||||
*cmake_files
|
||||
C/pl-yap.c
|
||||
GitSHA1.c
|
||||
.vscode
|
||||
CMakeLists.txt.*
|
||||
FindPackageLog.txt
|
||||
GitSHA1.c
|
||||
clang
|
||||
cmake-build-debug
|
||||
os/YapIOConfig.h
|
||||
CodeBlocks
|
||||
|
||||
os/readterm.c.cpp
|
||||
|
||||
os/readterm.c.cpp
|
||||
|
||||
packages/ProbLog/problog_examples/output/,_query_1_cluster_1.dot
|
||||
|
||||
packages/ProbLog/#problog_lbdd.yap#
|
||||
|
||||
packages/ProbLog/problog_examples/output/,_query_1_cluster_1.dot
|
||||
|
||||
packages/ProbLog/problog_examples/output/out.dat
|
||||
|
||||
packages/ProbLog/problog_examples/outputvalues.pl
|
||||
|
||||
packages/ProbLog/problogbdd
|
||||
|
||||
packages/raptor/raptor_config.h
|
||||
|
||||
packages/real/rconfig.h
|
||||
|
||||
packages/ProbLog/problog/#completion.yap#
|
||||
|
||||
packages/ProbLog/problog_examples/output
|
||||
packages/ProbLog/problog_examples/queries
|
||||
packages/swig/java/*.java
|
||||
packages/swig/java/*.class
|
||||
packages/swig/java/*.jar
|
||||
packages/swig/java/*wrap*
|
||||
*jnilib
|
||||
*.jar
|
||||
*LOG
|
||||
packages/cplint/approx/simplecuddLPADs/LPADBDD
|
||||
|
||||
packages/swi-minisat2/˜:ilp
|
||||
packages/swig/android/app
|
||||
packages/cplint/L
|
||||
|
||||
packages/CLPBN/horus/hcli
|
||||
tmp
|
||||
Eclipse
|
||||
packages/bdd/simplecudd/problogbdd
|
||||
trace
|
||||
packages/bdd/cudd_config.h
|
||||
Makefile
|
||||
build
|
||||
Debug
|
||||
debug
|
||||
Release
|
||||
Build
|
||||
xcode
|
||||
Threads
|
||||
droid
|
||||
mxe
|
||||
mxe32
|
||||
msys2
|
||||
caret
|
||||
codelite
|
||||
configure
|
||||
Qt
|
||||
cmake/cmake-android
|
||||
sublime
|
||||
yap-6.3.workspace
|
||||
yap-6.3.geany
|
||||
YAP.project
|
||||
CBlocks
|
||||
yPQ
|
||||
*.tmp
|
||||
YAP.sublime*
|
||||
yap32
|
||||
Eclipse
|
||||
codeblocks
|
||||
yap-6.3.tags
|
||||
android
|
||||
yap.prj
|
||||
|
||||
yap.VITORs-MBP.vsc.pui
|
||||
vc
|
||||
packages/myddas/pl/myddas_odbc.yap
|
||||
|
||||
packages/myddas/pl/myddas_postgres.yap
|
||||
|
||||
packages/myddas/pl/myddas_sqlite3.ypp
|
||||
|
||||
packages/myddas/pl/#myddas_postgres.ypp#
|
||||
|
||||
packages/myddas/hh
|
||||
|
||||
packages/myddas/DaysInHospital_Y3.csv
|
||||
|
||||
packages/myddas/agile.csv
|
||||
|
||||
*.pyc
|
||||
|
||||
*.cmake#
|
||||
|
||||
*.tex
|
||||
|
||||
*.c#
|
||||
|
||||
packages/swig/yap_wrap.cxx
|
||||
|
||||
packages/swig/yap_wrap.h
|
||||
|
||||
packages/swig/yap_wrap.cpp
|
||||
|
||||
packages/swig/yap.py
|
||||
|
||||
*.ipynb
|
||||
yap
|
||||
packages/python/yap_kernel/x/__init__.py
|
||||
x
|
||||
packages/python/yap_kernel/x/__main__.py
|
||||
|
||||
*.gch
|
||||
mxe
|
||||
build
|
|
@ -0,0 +1,2 @@
|
|||
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee#define GIT_SHA1 "@GIT_SHA1@"
|
||||
const char g_GIT_SHA1[] = GIT_SHA1;
|
|
@ -0,0 +1,26 @@
|
|||
ENABLE_VARS="brew|yes|WITH_BREW\
|
||||
clpbn|yes|WITH_CLPBN \
|
||||
cplint|yes|WITH_CPLINT \
|
||||
horus|yes|WITH_HORUS \
|
||||
clpr|yes|WITH_CLPR \
|
||||
macports|yes|WITH_MACPORTS\
|
||||
problog|yes|WITH_PROBLOG \
|
||||
jit|no|WITH_JIT \
|
||||
chr|no|WITH_CHR \
|
||||
threads|no|WITH_THREADS"
|
||||
WITH_VARS="swig|yes|WITH_SWIG \
|
||||
mpi|yes|WITH_MPI \
|
||||
gecode|yes|WITH_GECODE \
|
||||
docs|yes|WITH_DOCS \
|
||||
r|yes|WITH_R \
|
||||
myddas|yes|WITH_MYDDAS \
|
||||
cudd|yes|WITH_CUDD \
|
||||
xml2|yes|WITH_XML2 \
|
||||
raptor|yes|WITH_RAPTOR \
|
||||
python|yes|WITH_PYTHON \
|
||||
openssl|yes|WITH_OPENSSL\
|
||||
java|yes|WITH_JAVA
|
||||
lbfgs|yes|WITH_LBFGS
|
||||
extensions|yes|WITH_EXTENSIONS
|
||||
readline|yes|WITH_READLINE \
|
||||
gmp|yes|WITH_GMP"
|
9
.ctags
9
.ctags
|
@ -6,11 +6,15 @@
|
|||
--regex-Prolog=/^([a-z][A-Za-z0-9_]*:)?\'(.*)\'\(.*\)\.[ \t]*.*/\2/p,predicate,predicate definition/
|
||||
--regex-Prolog=/^:-[ \t]+(discontiguous|dynamic|multifile|table|thread_local)[ \t]+([a-z][_a-zA-Z0-9]*:)?([a-z0-9_][_a-zA-Z0-9]*)/\1/p,predicate,predicate metadata/
|
||||
--regex-Prolog=/^[ \t]*Yap_InitCPred[ \t]*\"(\$?[A-Za-z0-9_]*)\"([ \t]*).*/\1/p,predicate,predicate definition/
|
||||
--langmap=C:+.(h.cmake).(h.config)
|
||||
--exclude=\._*
|
||||
--exclude=*\.bak
|
||||
--exclude=\.svn
|
||||
--exclude=\.git
|
||||
--exclude=CVS
|
||||
--exclude=Debug
|
||||
--exclude=Release
|
||||
--exclude=Threads
|
||||
--exclude=.*tags.*
|
||||
--exclude=.*TAGS.*
|
||||
--exclude=\.\#.*
|
||||
|
@ -19,3 +23,8 @@
|
|||
--exclude=\#.*
|
||||
--exclude=(.)\#*
|
||||
--exclude=*.dylib
|
||||
--exclude=docs
|
||||
--exclude=build
|
||||
--exclude=cmake-build-debug
|
||||
--exclude=clang
|
||||
|
||||
|
|
|
@ -12,10 +12,12 @@
|
|||
*.dll
|
||||
docs/yap.info*
|
||||
.build
|
||||
build
|
||||
tags
|
||||
TGSautom4te.cache
|
||||
cscope.*
|
||||
GPATH
|
||||
m32
|
||||
GRTAGS
|
||||
GTAGS
|
||||
tmtags*
|
||||
|
@ -23,7 +25,6 @@ tmtags*
|
|||
.Rhistory
|
||||
.zedstate
|
||||
config.h
|
||||
Yap.h
|
||||
YapConfig.h
|
||||
YapTermConfig.h
|
||||
.graffiti
|
||||
|
@ -41,7 +42,6 @@ groups
|
|||
.cproject
|
||||
.dir-locals.el
|
||||
.DS_store
|
||||
.kateproject
|
||||
.project
|
||||
.pydevproject
|
||||
.Rhistory
|
||||
|
@ -79,15 +79,11 @@ GitSHA1.c
|
|||
CMakeLists.txt.*
|
||||
FindPackageLog.txt
|
||||
GitSHA1.c
|
||||
|
||||
GitSHA1.c
|
||||
|
||||
clang
|
||||
cmake-build-debug
|
||||
os/YapIOConfig.h
|
||||
|
||||
os/YapIOConfig.h
|
||||
|
||||
os/YapIOConfig.h
|
||||
|
||||
CodeBlocks
|
||||
x
|
||||
os/readterm.c.cpp
|
||||
|
||||
os/readterm.c.cpp
|
||||
|
@ -118,21 +114,105 @@ packages/swig/java/*.jar
|
|||
packages/swig/java/*wrap*
|
||||
*jnilib
|
||||
*.jar
|
||||
|
||||
*LOG
|
||||
packages/cplint/approx/simplecuddLPADs/LPADBDD
|
||||
|
||||
packages/swi-minisat2/˜:ilp
|
||||
|
||||
packages/swig/android/app
|
||||
packages/cplint/L
|
||||
|
||||
packages/CLPBN/horus/hcli
|
||||
|
||||
tmp
|
||||
Eclipse
|
||||
packages/bdd/simplecudd/problogbdd
|
||||
|
||||
trace
|
||||
packages/bdd/cudd_config.h
|
||||
Makefile
|
||||
build
|
||||
Debug
|
||||
debug
|
||||
Release
|
||||
Build
|
||||
Build
|
||||
xcode
|
||||
Threads
|
||||
droid
|
||||
mxe
|
||||
mxe32
|
||||
msys2
|
||||
caret
|
||||
codelite
|
||||
configure
|
||||
Qt
|
||||
cmake/cmake-android
|
||||
sublime
|
||||
yap-6.3.workspace
|
||||
yap-6.3.geany
|
||||
YAP.project
|
||||
CBlocks
|
||||
yPQ
|
||||
*.tmp
|
||||
YAP.sublime*
|
||||
yap32
|
||||
Eclipse
|
||||
codeblocks
|
||||
yap-6.3.tags
|
||||
android
|
||||
yap.prj
|
||||
|
||||
yap.VITORs-MBP.vsc.pui
|
||||
vc
|
||||
packages/myddas/pl/myddas_odbc.yap
|
||||
|
||||
packages/myddas/pl/myddas_postgres.yap
|
||||
|
||||
packages/myddas/pl/myddas_sqlite3.ypp
|
||||
|
||||
packages/myddas/pl/#myddas_postgres.ypp#
|
||||
|
||||
packages/myddas/hh
|
||||
|
||||
packages/myddas/DaysInHospital_Y3.csv
|
||||
|
||||
packages/myddas/agile.csv
|
||||
|
||||
*.pyc
|
||||
|
||||
*.cmake#
|
||||
|
||||
*.tex
|
||||
|
||||
*.c#
|
||||
|
||||
packages/swig/yap_wrap.cxx
|
||||
|
||||
packages/swig/yap_wrap.h
|
||||
|
||||
packages/swig/yap_wrap.cpp
|
||||
|
||||
packages/swig/yap.py
|
||||
|
||||
*.ipynb
|
||||
|
||||
packages/python/yap_kernel/x/__init__.py
|
||||
|
||||
packages/python/yap_kernel/x/__main__.py
|
||||
|
||||
*.gch
|
||||
mxe
|
||||
build
|
||||
|
||||
library/system/#CMakeLists.txt#
|
||||
*.txt#
|
||||
cmake/CMakeCache.txt
|
||||
|
||||
C/compiling_error.txt
|
||||
|
||||
cmake/compile_commands.json
|
||||
|
||||
cmake/cudd_config.h
|
||||
|
||||
cmake/docs/Doxyfile
|
||||
|
||||
*.stackdump
|
||||
*.gz
|
||||
.Rproj.user
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#ifdef BEAM
|
||||
|
||||
#include "Yap.h"
|
||||
#include "compile.h"
|
||||
#include "clause.h"
|
||||
#include "YapCompile.h"
|
||||
#include "clause.h"
|
||||
#include "eam.h"
|
||||
#include "eamamasm.h"
|
||||
#include <stdio.h>
|
||||
|
@ -85,7 +85,7 @@ int X_Var(Ventry *ve)
|
|||
int var;
|
||||
|
||||
if (ve->KindOfVE == PermVar || ve->KindOfVE == VoidVar ) {
|
||||
printf("Erro no tipo de variavel X ->eamamas.c \n");
|
||||
printf("Erro no tipo de variavel X ->eamamas.c \n");
|
||||
exit(1);
|
||||
}
|
||||
var = ((ve->NoOfVE) & MaskVarAdrs);
|
||||
|
@ -99,7 +99,7 @@ int Y_Var(Ventry *ve)
|
|||
{
|
||||
int var;
|
||||
if (ve->KindOfVE != PermVar) {
|
||||
printf("Erro no tipo de variavel Y ->eamamas.c \n");
|
||||
printf("Erro no tipo de variavel Y ->eamamas.c \n");
|
||||
exit(1);
|
||||
}
|
||||
var = ((ve->NoOfVE) & MaskVarAdrs);
|
||||
|
@ -119,7 +119,7 @@ void eam_pass(CInstr *ppc)
|
|||
{
|
||||
int alloc_found=0;
|
||||
int body=0;
|
||||
|
||||
|
||||
while (ppc) {
|
||||
switch ((int) ppc->op) {
|
||||
|
||||
|
@ -184,7 +184,7 @@ void eam_pass(CInstr *ppc)
|
|||
} else {
|
||||
emit_inst(_unify_val_Y_op);
|
||||
emit_par(Y_Var((Ventry *) ppc->new4));
|
||||
|
||||
|
||||
}
|
||||
} else { emit_inst(_unify_void_op); }
|
||||
break;
|
||||
|
@ -268,7 +268,7 @@ void eam_pass(CInstr *ppc)
|
|||
case put_atom_op:
|
||||
emit_inst(_put_atom_op);
|
||||
emit_par(ppc->new1);
|
||||
emit_par(ppc->new4);
|
||||
emit_par(ppc->new4);
|
||||
break;
|
||||
case put_list_op:
|
||||
emit_inst(_put_list_op);
|
||||
|
@ -349,7 +349,7 @@ void eam_pass(CInstr *ppc)
|
|||
|
||||
case cut_op:
|
||||
emit_inst(_cut_op);
|
||||
break;
|
||||
break;
|
||||
case commit_op:
|
||||
emit_inst(_commit_op);
|
||||
break;
|
||||
|
@ -402,7 +402,7 @@ void eam_pass(CInstr *ppc)
|
|||
}
|
||||
emit_par(ppc->new4);
|
||||
break;
|
||||
|
||||
|
||||
case direct_safe_call_op:
|
||||
if (ppc->new1==1) {
|
||||
emit_inst(_direct_safe_call_unary_op);
|
||||
|
@ -434,8 +434,8 @@ void eam_pass(CInstr *ppc)
|
|||
if (a==NULL) a=Yap_LookupAtom("\n");
|
||||
emit_inst(_put_atom_op);
|
||||
emit_par(1);
|
||||
emit_par((Cell) MkAtomTerm(a));
|
||||
}
|
||||
emit_par((Cell) MkAtomTerm(a));
|
||||
}
|
||||
emit_inst(_write_call);
|
||||
break;
|
||||
case is_op:
|
||||
|
@ -468,50 +468,50 @@ void eam_pass(CInstr *ppc)
|
|||
case remove_box_op:
|
||||
case remove_last_box_op:
|
||||
break;
|
||||
|
||||
|
||||
case jump_op:
|
||||
emit_inst(_jump_op);
|
||||
emit_upar((Cell) Code_Start+ (Cell) labels[ppc->new4]);
|
||||
break;
|
||||
case label_op:
|
||||
if (pass==0) labels[ppc->new4] = get_addr();
|
||||
if (pass==0) labels[ppc->new4] = get_addr();
|
||||
break;
|
||||
|
||||
case run_op:
|
||||
/* se ficar vazio, retirar no eam_am.c o +5 das linhas pc=clause->code+5 no only_1_clause e no call */
|
||||
emit_inst(_try_me_op);
|
||||
emit_par(0);
|
||||
emit_par(0);
|
||||
emit_par(0);
|
||||
emit_par(0);
|
||||
emit_par(0);
|
||||
emit_par(0);
|
||||
break;
|
||||
|
||||
case only_1_clause_op:
|
||||
emit_inst(_only_1_clause_op);
|
||||
emit_par(ppc->new4);
|
||||
emit_par(((struct Clauses *)ppc->new4)->predi->arity);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(0); /* Nr da alternativa */
|
||||
break;
|
||||
case try_me_op:
|
||||
emit_inst(_try_me_op);
|
||||
emit_par(ppc->new4);
|
||||
emit_par(ppc->new4);
|
||||
emit_par(((struct Clauses *)ppc->new4)->predi->arity);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(0); /* Nr da alternativa */
|
||||
break;
|
||||
case retry_me_op:
|
||||
emit_inst(_retry_me_op);
|
||||
emit_par(ppc->new4);
|
||||
emit_par(((struct Clauses *)ppc->new4)->predi->arity);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(ppc->new1);
|
||||
break;
|
||||
case trust_me_op:
|
||||
emit_inst(_trust_me_op);
|
||||
emit_par(ppc->new4);
|
||||
emit_par(((struct Clauses *)ppc->new4)->predi->arity);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(((struct Clauses *)ppc->new4)->nr_vars);
|
||||
emit_par(ppc->new1);
|
||||
break;
|
||||
|
||||
|
@ -529,11 +529,11 @@ void eam_pass(CInstr *ppc)
|
|||
}
|
||||
body=1;
|
||||
break;
|
||||
|
||||
|
||||
case prepare_tries:
|
||||
emit_inst(_prepare_tries);
|
||||
emit_par(ppc->new1);
|
||||
emit_par(ppc->new4);
|
||||
emit_par(ppc->new1);
|
||||
emit_par(ppc->new4);
|
||||
break;
|
||||
|
||||
case exit_op:
|
||||
|
@ -559,7 +559,7 @@ void eam_pass(CInstr *ppc)
|
|||
printf("[ please note that beam still does not support a lot of builtins ]\n");
|
||||
}
|
||||
emit_inst(_fail_op);
|
||||
|
||||
|
||||
}
|
||||
ppc = ppc->nextInst;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#ifdef BEAM
|
||||
|
||||
#include "Yap.h"
|
||||
#include "compile.h"
|
||||
#include "clause.h"
|
||||
#include "YapCompile.h"
|
||||
#include "clause.h"
|
||||
#include "eam.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -40,13 +40,13 @@ int exists_on_table(Cell a,struct HASH_TABLE **table, int i)
|
|||
struct HASH_TABLE *t;
|
||||
|
||||
t=table[i];
|
||||
|
||||
|
||||
while(t) {
|
||||
if (t->value==a) return(1);
|
||||
|
||||
|
||||
t=t->next;
|
||||
}
|
||||
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -61,20 +61,20 @@ Cell *gera_codigo_try(struct Predicates *predi) /* gerar os try's para o predic
|
|||
|
||||
emit_new(prepare_tries,predi->nr_alt,predi->arity);
|
||||
if (predi->nr_alt==1) {
|
||||
emit_new(only_1_clause_op,0,(unsigned long) c);
|
||||
} else if (predi->nr_alt>1) {
|
||||
emit_new(only_1_clause_op,0,(unsigned long) c);
|
||||
} else if (predi->nr_alt>1) {
|
||||
while(c!=NULL) {
|
||||
if (nr+1==predi->nr_alt) emit_new(trust_me_op,nr,(unsigned long) c);
|
||||
if (nr+1==predi->nr_alt) emit_new(trust_me_op,nr,(unsigned long) c);
|
||||
else if (nr==0) emit_new(try_me_op,predi->nr_alt,(unsigned long) c);
|
||||
else emit_new(retry_me_op,nr,(unsigned long) c);
|
||||
|
||||
c=c->next;
|
||||
nr++;
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
emit_new(fail_op,0,0);
|
||||
}
|
||||
|
||||
|
||||
return(eam_assemble(StartCode));
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ Cell *gera_codigo_try_list(struct Predicates *predi) /* gerar os try's para o p
|
|||
c=predi->first;
|
||||
|
||||
emit_new(prepare_tries,nr_preds,predi->arity);
|
||||
if (nr_preds>=1) {
|
||||
if (nr_preds>=1) {
|
||||
while(c!=NULL) {
|
||||
if (c->predi==predi && (c->idx==Lista || c->idx==Variavel)) {
|
||||
if (nr_preds==1) {
|
||||
|
@ -108,20 +108,20 @@ Cell *gera_codigo_try_list(struct Predicates *predi) /* gerar os try's para o p
|
|||
} else {
|
||||
emit_new(fail_op,0,0);
|
||||
}
|
||||
|
||||
|
||||
return(eam_assemble(StartCode));
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct HASH_TABLE **gera_codigo_try_atom(struct Predicates *predi)
|
||||
struct HASH_TABLE **gera_codigo_try_atom(struct Predicates *predi)
|
||||
{
|
||||
int j,nr_preds,nr_atoms;
|
||||
struct HASH_TABLE **table;
|
||||
struct HASH_TABLE *t;
|
||||
struct Clauses *cla;
|
||||
|
||||
nr_atoms=predi->idx_atom;
|
||||
nr_atoms=predi->idx_atom;
|
||||
nr_preds=nr_atoms+predi->idx_var;
|
||||
table=malloc(sizeof(struct HASH_TABLE *)*(nr_atoms+1));
|
||||
for (j=0;j<=nr_atoms;j++) table[j]=NULL;
|
||||
|
@ -132,7 +132,7 @@ struct Clauses *cla;
|
|||
Cell a;
|
||||
unsigned int index;
|
||||
int nr;
|
||||
|
||||
|
||||
a=cla->val;
|
||||
if (a && nr_atoms) {
|
||||
index=index_of_hash_table_atom(a,nr_atoms);
|
||||
|
@ -187,18 +187,18 @@ struct HASH_TABLE **table;
|
|||
struct HASH_TABLE *t;
|
||||
struct Clauses *cla;
|
||||
|
||||
nr_appls=predi->idx_functor;
|
||||
nr_appls=predi->idx_functor;
|
||||
nr_preds=nr_appls+predi->idx_var;
|
||||
table=malloc(sizeof(struct HASH_TABLE *)*(nr_appls+1));
|
||||
for (j=0;j<=nr_appls;j++) table[j]=NULL;
|
||||
|
||||
|
||||
cla=predi->first;
|
||||
while(cla) {
|
||||
if (cla->idx==Estrutura) {
|
||||
Cell a;
|
||||
long int index;
|
||||
int nr;
|
||||
|
||||
|
||||
a=cla->val;
|
||||
if (a && nr_appls) {
|
||||
index=index_of_hash_table_appl(a,nr_appls);
|
||||
|
@ -257,7 +257,7 @@ Cell *gera_codigo_try_only_vars(struct Predicates *predi) /* gerar os try's de V
|
|||
c=predi->first;
|
||||
|
||||
emit_new(prepare_tries,nr_preds,predi->arity);
|
||||
if (nr_preds>=1) {
|
||||
if (nr_preds>=1) {
|
||||
while(c!=NULL) {
|
||||
if (c->predi==predi && c->idx==Variavel) {
|
||||
if (nr_preds==1) {
|
||||
|
@ -274,7 +274,7 @@ Cell *gera_codigo_try_only_vars(struct Predicates *predi) /* gerar os try's de V
|
|||
} else {
|
||||
emit_new(fail_op,0,0);
|
||||
}
|
||||
|
||||
|
||||
return(eam_assemble(StartCode));
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ void do_eam_indexing(struct Predicates *p)
|
|||
p->idx=1;
|
||||
}
|
||||
|
||||
if((Print_Code & 4) && (Print_Code & 8)) {
|
||||
if((Print_Code & 4) && (Print_Code & 8)) {
|
||||
printf("General Case :\n");
|
||||
eam_showcode(p->code);
|
||||
}
|
||||
|
@ -309,10 +309,10 @@ void ver_predicados(struct Predicates *p)
|
|||
|
||||
c=p->first;
|
||||
while(c!=NULL) {
|
||||
printf("Clausula %d do tipo %d (%d locals %d args) (val=0x%X)\n",++i,c->idx,c->nr_vars,c->predi->arity, (unsigned )c->val);
|
||||
printf("Clausula %d do tipo %d (%d locals %d args) (val=0x%X)\n",++i,c->idx,c->nr_vars,c->predi->arity, (unsigned )c->val);
|
||||
c=c->next;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
{
|
||||
#endif /* INDENT_CODE */
|
||||
|
||||
|
||||
BOp(Ystop, l);
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
BOp(Ystop, l);
|
||||
LOCAL_CBorder = 0;
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
/* make sure ASP is initialized */
|
||||
saveregs();
|
||||
|
||||
|
@ -20,11 +20,12 @@ BOp(Ystop, l);
|
|||
#if BP_FREE
|
||||
P1REG = PCBACKUP;
|
||||
#endif
|
||||
LOCAL_CBorder = 0;
|
||||
return 1;
|
||||
ENDBOp();
|
||||
|
||||
BOp(Nstop, e);
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
saveregs();
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(old_regs);
|
||||
|
@ -35,52 +36,53 @@ BOp(Ystop, l);
|
|||
return 0;
|
||||
ENDBOp();
|
||||
|
||||
|
||||
|
||||
/************************************************************************\
|
||||
* Native Code Execution *
|
||||
/************************************************************************\
|
||||
* Native Code Execution *
|
||||
\************************************************************************/
|
||||
|
||||
#if YAP_JIT
|
||||
static void *OpAddress_JIT[] =
|
||||
{
|
||||
#define OPCODE(OP,TYPE) && _##OP
|
||||
static void *OpAddress_JIT[] = {
|
||||
#define OPCODE(OP, TYPE) &&_##OP
|
||||
#include "YapOpcodes.h"
|
||||
#undef OPCODE
|
||||
#undef OPCODE
|
||||
};
|
||||
|
||||
/* native_me */
|
||||
BOp(jit_handler, J);
|
||||
if (!PREG->y_u.J.jh->fi.bcst.c) PREG->y_u.J.jh->mf.isground = IsGround(PREG);
|
||||
PREG->y_u.J.jh->fi.bcst.c++;
|
||||
|
||||
/* Did PREG reach threshold value to become critical? */
|
||||
if (PREG->y_u.J.jh->fi.bcst.c == (COUNT)(ExpEnv.config_struc.frequency_bound*(ExpEnv.config_struc.profiling_startp)) && !PREG->y_u.J.jh->mf.isground) {
|
||||
/* native_me */
|
||||
BOp(jit_handler, J);
|
||||
if (!PREG->y_u.J.jh->fi.bcst.c)
|
||||
PREG->y_u.J.jh->mf.isground = IsGround(PREG);
|
||||
PREG->y_u.J.jh->fi.bcst.c++;
|
||||
|
||||
/* Did PREG reach threshold value to become critical? */
|
||||
if (PREG->y_u.J.jh->fi.bcst.c ==
|
||||
(COUNT)(ExpEnv.config_struc.frequency_bound *
|
||||
(ExpEnv.config_struc.profiling_startp)) &&
|
||||
!PREG->y_u.J.jh->mf.isground) {
|
||||
#if YAP_DBG_PREDS
|
||||
if (ExpEnv.debug_struc.pprint_me.criticals != 0 && ExpEnv.debug_struc.pprint_me.criticals != 0x1) {
|
||||
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);
|
||||
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.criticals);
|
||||
}
|
||||
#endif
|
||||
traced_absmi();
|
||||
|
||||
if (ExpEnv.debug_struc.pprint_me.criticals != 0 &&
|
||||
ExpEnv.debug_struc.pprint_me.criticals != 0x1) {
|
||||
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);
|
||||
fprintf(stderr, "%s", (char *)ExpEnv.debug_struc.pprint_me.criticals);
|
||||
}
|
||||
#if YAP_DBG_PREDS
|
||||
print_main_when_head(PREG, ON_INTERPRETER);
|
||||
#endif
|
||||
PREG = NEXTOP(PREG, J);
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
traced_absmi();
|
||||
}
|
||||
#if YAP_DBG_PREDS
|
||||
print_main_when_head(PREG, ON_INTERPRETER);
|
||||
#endif
|
||||
PREG = NEXTOP(PREG, J);
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
#endif
|
||||
|
||||
#include "cp_absmi_insts.h"
|
||||
#include "lu_absmi_insts.h"
|
||||
#include "fail_absmi_insts.h"
|
||||
#include "control_absmi_insts.h"
|
||||
#include "unify_absmi_insts.h"
|
||||
#include "cp_absmi_insts.h"
|
||||
#include "fail_absmi_insts.h"
|
||||
#include "fli_absmi_insts.h"
|
||||
#include "or_absmi_insts.h"
|
||||
#include "index_absmi_insts.h"
|
||||
#include "type_absmi_insts.h"
|
||||
#include "prim_absmi_insts.h"
|
||||
#include "meta_absmi_insts.h"
|
||||
#include "index_absmi_insts.h"
|
||||
#include "lu_absmi_insts.h"
|
||||
#include "meta_absmi_insts.h"
|
||||
#include "or_absmi_insts.h"
|
||||
#include "prim_absmi_insts.h"
|
||||
#include "type_absmi_insts.h"
|
||||
#include "unify_absmi_insts.h"
|
||||
|
|
111
C/absmi_insts.i
111
C/absmi_insts.i
|
@ -1101,19 +1101,10 @@
|
|||
#if defined(YAPOR) || defined(THREADS)
|
||||
PP = NULL;
|
||||
#endif
|
||||
if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_growglobal(NULL)) {
|
||||
Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage);
|
||||
FAIL();
|
||||
}
|
||||
} else {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gc(3, ENV, CP)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, "stack overflow: gc failed");
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
PELOCK(5,ClauseCodeToLogUpdClause(PREG)->ClPred);
|
||||
PP = ClauseCodeToLogUpdClause(PREG)->ClPred;
|
||||
|
@ -1235,7 +1226,7 @@
|
|||
PREG = NEXTOP(PREG,Osbpa);
|
||||
saveregs();
|
||||
if (!Yap_gcl(sz, arity, YENV, PREG)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
FAIL();
|
||||
} else {
|
||||
|
@ -6440,7 +6431,8 @@
|
|||
#endif /* YAPOR */
|
||||
CACHE_Y(YREG);
|
||||
/* Alocate space for the cut_c structure*/
|
||||
CUT_C_PUSH(NEXTOP(NEXTOP(PREG,OtapFs),OtapFs),S_YREG);
|
||||
|
||||
(NEXTOP(NEXTOP(PREG,OtapFs),OtapFs),S_YREG);
|
||||
S_YREG = S_YREG - PREG->y_u.OtapFs.extra;
|
||||
store_args(PREG->y_u.OtapFs.s);
|
||||
store_yaam_regs(NEXTOP(PREG, OtapFs), 0);
|
||||
|
@ -8168,12 +8160,7 @@
|
|||
saveregs();
|
||||
d0 = p_plus(Yap_Eval(d0), Yap_Eval(d1) PASS_REGS);
|
||||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
||||
}
|
||||
XREG(PREG->y_u.xxx.x) = d0;
|
||||
PREG = NEXTOP(PREG, xxx);
|
||||
|
@ -8215,7 +8202,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8256,7 +8243,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8304,7 +8291,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8348,7 +8335,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8393,7 +8380,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8434,7 +8421,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8482,7 +8469,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8526,7 +8513,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8571,7 +8558,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8612,7 +8599,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8660,7 +8647,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8711,7 +8698,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8756,7 +8743,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8799,7 +8786,7 @@
|
|||
d0 = p_div(MkIntegerTerm(d1),Yap_Eval(d0) PASS_REGS);
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8847,7 +8834,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8895,7 +8882,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8942,7 +8929,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -8987,7 +8974,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9032,7 +9019,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9073,7 +9060,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9121,7 +9108,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9166,7 +9153,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9210,7 +9197,7 @@
|
|||
d0 = p_or(Yap_Eval(d0), MkIntegerTerm(d1) PASS_REGS);
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9251,7 +9238,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9299,7 +9286,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9348,7 +9335,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9394,7 +9381,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9435,7 +9422,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9479,7 +9466,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9528,7 +9515,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9573,7 +9560,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9620,7 +9607,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9664,7 +9651,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9707,7 +9694,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9752,7 +9739,7 @@
|
|||
BEGP(pt0);
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9798,7 +9785,7 @@
|
|||
setregs();
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -9843,7 +9830,7 @@
|
|||
}
|
||||
if (d0 == 0L) {
|
||||
saveregs();
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_PreprocessedError()
|
||||
setregs();
|
||||
FAIL();
|
||||
}
|
||||
|
@ -10940,7 +10927,7 @@
|
|||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxx),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
@ -11057,7 +11044,7 @@
|
|||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxc),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
@ -11167,7 +11154,7 @@
|
|||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,xxn),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
@ -11274,7 +11261,7 @@
|
|||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxx),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
@ -11401,7 +11388,7 @@
|
|||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxc),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
@ -11529,7 +11516,7 @@
|
|||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxn),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
@ -11905,7 +11892,7 @@
|
|||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),Osbmp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed" );
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
|
2215
C/adtdefs.c
2215
C/adtdefs.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
48
C/agc.c
48
C/agc.c
|
@ -34,7 +34,7 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90";
|
|||
|
||||
static void RestoreEntries(PropEntry *, int USES_REGS);
|
||||
static void CleanCode(PredEntry * USES_REGS);
|
||||
static void RestoreDBTerm(DBTerm *dbr, int attachments USES_REGS);
|
||||
static void RestoreDBTerm(DBTerm *dbr, bool src, int attachments USES_REGS);
|
||||
|
||||
#define AtomMarkedBit 1
|
||||
|
||||
|
@ -196,7 +196,7 @@ AdjustTermFlag(flag_term *tarr, UInt i)
|
|||
{
|
||||
CACHE_REGS
|
||||
if (IsVarTerm(tarr[i].at)) {
|
||||
RestoreDBTerm( tarr[i].DBT, 0 PASS_REGS );
|
||||
RestoreDBTerm( tarr[i].DBT, false, 0 PASS_REGS );
|
||||
} else if (IsAtomTerm( tarr[i].at ) )
|
||||
tarr[i].at = AtomTermAdjust(tarr[i].at);
|
||||
}
|
||||
|
@ -340,8 +340,8 @@ mark_global_cell(CELL *pt)
|
|||
Int sz = 3 +
|
||||
(sizeof(MP_INT)+
|
||||
(((MP_INT *)(pt+2))->_mp_alloc*sizeof(mp_limb_t)))/sizeof(CELL);
|
||||
Opaque_CallOnGCMark f;
|
||||
Opaque_CallOnGCRelocate f2;
|
||||
YAP_Opaque_CallOnGCMark f;
|
||||
YAP_Opaque_CallOnGCRelocate f2;
|
||||
Term t = AbsAppl(pt);
|
||||
|
||||
if ( (f = Yap_blob_gc_mark_handler(t)) ) {
|
||||
|
@ -427,12 +427,7 @@ clean_atom_list(AtomHashEntry *HashPtr)
|
|||
Yap_FreeCodeSpace((char *)b);
|
||||
GLOBAL_agc_collected += sizeof(YAP_BlobPropEntry);
|
||||
GLOBAL_agc_collected += sizeof(AtomEntry)+sizeof(size_t)+at->rep.blob->length;
|
||||
} else if (IsWideAtom(atm)) {
|
||||
#ifdef DEBUG_RESTORE3
|
||||
fprintf(stderr, "Purged %p:%S\n", at, at->WStrOfAE);
|
||||
#endif
|
||||
GLOBAL_agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE);
|
||||
} else {
|
||||
} else {
|
||||
#ifdef DEBUG_RESTORE3
|
||||
fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE);
|
||||
#endif
|
||||
|
@ -459,11 +454,6 @@ clean_atoms(void)
|
|||
clean_atom_list(HashPtr);
|
||||
HashPtr++;
|
||||
}
|
||||
HashPtr = WideHashChain;
|
||||
for (i = 0; i < WideAtomHashTableSize; ++i) {
|
||||
clean_atom_list(HashPtr);
|
||||
HashPtr++;
|
||||
}
|
||||
clean_atom_list(&INVISIBLECHAIN);
|
||||
{
|
||||
AtomHashEntry list;
|
||||
|
@ -475,16 +465,17 @@ clean_atoms(void)
|
|||
static void
|
||||
atom_gc(USES_REGS1)
|
||||
{
|
||||
int gc_verbose = Yap_is_gc_verbose();
|
||||
int gc_trace = 0;
|
||||
bool gc_verbose = Yap_is_gc_verbose();
|
||||
bool gc_trace = false;
|
||||
|
||||
|
||||
UInt time_start, agc_time;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (Yap_GetValue(AtomGcTrace) != TermNil)
|
||||
gc_trace = 1;
|
||||
gc_trace = true;
|
||||
|
||||
GLOBAL_agc_calls++;
|
||||
GLOBAL_agc_collected = 0;
|
||||
|
@ -544,31 +535,10 @@ p_inform_agc(USES_REGS1)
|
|||
Yap_unify(ts, ARG3);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_agc_threshold(USES_REGS1)
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
return Yap_unify(ARG1, MkIntegerTerm(GLOBAL_AGcThreshold));
|
||||
} else if (!IsIntegerTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t,"prolog_flag/2 agc_margin");
|
||||
return FALSE;
|
||||
} else {
|
||||
Int i = IntegerOfTerm(t);
|
||||
if (i<0) {
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t,"prolog_flag/2 agc_margin");
|
||||
return FALSE;
|
||||
} else {
|
||||
GLOBAL_AGcThreshold = i;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Yap_init_agc(void)
|
||||
{
|
||||
Yap_InitCPred("$atom_gc", 0, p_atom_gc, 0);
|
||||
Yap_InitCPred("$inform_agc", 3, p_inform_agc, 0);
|
||||
Yap_InitCPred("$agc_threshold", 1, p_agc_threshold, SafePredFlag);
|
||||
}
|
||||
|
|
164
C/alloc.c
164
C/alloc.c
|
@ -1,27 +1,27 @@
|
|||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: alloc.c *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.95 2008-05-10 23:24:11 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: alloc.c * Last
|
||||
*rev: * mods:
|
||||
** comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.95 2008-05-10 23:24:11 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
|
||||
#endif
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
|
||||
#include "YapHeap.h"
|
||||
#include "Yatom.h"
|
||||
#include "alloc.h"
|
||||
#include "yapio.h"
|
||||
#if HAVE_STRING_H
|
||||
|
@ -42,11 +42,17 @@ static char SccsId[] = "%W% %G%";
|
|||
#if HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if __simplescalar__
|
||||
#ifdef USE_SYSTEM_MMAP
|
||||
|
@ -60,17 +66,66 @@ static char SccsId[] = "%W% %G%";
|
|||
/************************************************************************/
|
||||
/* Yap workspace management */
|
||||
|
||||
#define MASK 0x968e00
|
||||
#if USE_SYSTEM_MALLOC
|
||||
#define my_malloc(sz) malloc(sz)
|
||||
#define my_realloc(ptr, sz, osz, safe) realloc(ptr, sz)
|
||||
#define my_realloc0(ptr, sz) realloc(ptr, sz)
|
||||
#define my_free(ptr) free(ptr)
|
||||
|
||||
#if 1
|
||||
|
||||
#undef free
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
|
||||
int write_malloc = 0;
|
||||
|
||||
void *my_malloc(size_t sz) {
|
||||
void *p;
|
||||
|
||||
p = malloc(sz);
|
||||
// Yap_DebugPuts(stderr,"gof\n");
|
||||
if (Yap_do_low_level_trace) {
|
||||
#if __ANDROID__
|
||||
// __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "+ %d %p", write_malloc,p);
|
||||
#else
|
||||
fprintf(stderr, "+s %p\n @%p %ld\n", p, TR, LCL0 - (CELL *)LCL0);
|
||||
#endif
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void *my_realloc(void *ptr, size_t sz) {
|
||||
void *p;
|
||||
|
||||
p = realloc(ptr, sz);
|
||||
//if (Yap_do_low_level_trace)
|
||||
// fprintf(stderr, "+ %p -> %p : " Sizet_F "\n", ptr, p, sz);
|
||||
// Yap_DebugPuts(stderr,"gof\n");
|
||||
// if (sz > 500 && write_malloc++ > 0)
|
||||
// __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "* %d %p",
|
||||
// write_malloc, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
void my_free(void *p) {
|
||||
// printf("f %p\n",p);
|
||||
if (Yap_do_low_level_trace)
|
||||
fprintf(stderr, "- %p\n @%p %ld\n", p, TR, (long int)(LCL0 - (CELL *)B) );
|
||||
//if (write_malloc && write_malloc++ > 0)
|
||||
// __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "- %d %p", write_malloc,
|
||||
// p);
|
||||
|
||||
free(p);
|
||||
// Yap_DebugPuts(stderr,"gof\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#else // USE_SYSTEM_MALLOC
|
||||
|
||||
#define my_malloc(sz) Yap_dlmalloc(sz)
|
||||
#define my_realloc0(ptr, sz) Yap_dlrealloc(ptr, sz)
|
||||
#define my_realloc(ptr, sz) Yap_dlrealloc(ptr, sz)
|
||||
#define my_free(sz) Yap_dlfree(sz)
|
||||
|
||||
static char *my_realloc(char *ptr, UInt sz, UInt osz, int safe) {
|
||||
static char *my_reallocl(char *ptr, UInt sz, UInt osz, int safe) {
|
||||
char *nptr;
|
||||
|
||||
restart:
|
||||
|
@ -165,7 +220,7 @@ static inline char *call_realloc(char *p, size_t size) {
|
|||
tmalloc -= *(CELL *)p;
|
||||
#endif
|
||||
LOCAL_PrologMode |= MallocMode;
|
||||
out = (char *)my_realloc0(p, size);
|
||||
out = (char *)my_realloc(p, size);
|
||||
#if INSTRUMENT_MALLOC
|
||||
*(CELL *)out = size - sizeof(CELL);
|
||||
out += sizeof(CELL);
|
||||
|
@ -248,7 +303,7 @@ ADDR Yap_InitPreAllocCodeSpace(int wid) {
|
|||
#else
|
||||
my_malloc(sz)
|
||||
#endif
|
||||
)) {
|
||||
)) {
|
||||
REMOTE_PrologMode(wid) &= ~MallocMode;
|
||||
#if USE_DL_MALLOC
|
||||
UNLOCK(DLMallocLock);
|
||||
|
@ -301,8 +356,7 @@ ADDR Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) {
|
|||
tmalloc -= LOCAL_ScratchPad.sz;
|
||||
tmalloc += sz;
|
||||
#endif
|
||||
if (!(ptr =
|
||||
my_realloc(LOCAL_ScratchPad.ptr, sz, LOCAL_ScratchPad.sz, safe))) {
|
||||
if (!(ptr = my_realloc(LOCAL_ScratchPad.ptr, sz))) {
|
||||
LOCAL_PrologMode &= ~MallocMode;
|
||||
#if USE_DL_MALLOC
|
||||
UNLOCK(DLMallocLock);
|
||||
|
@ -324,20 +378,21 @@ ADDR Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) {
|
|||
|
||||
struct various_codes *Yap_heap_regs;
|
||||
|
||||
static void InitHeap(void) {
|
||||
Yap_heap_regs =
|
||||
(struct various_codes *)calloc(1, sizeof(struct various_codes));
|
||||
|
||||
// get an approximation to total memory data-base size.
|
||||
size_t Yap_HeapUsed(void)
|
||||
{
|
||||
#if HAVE_MALLINFO
|
||||
struct mallinfo mi = mallinfo();
|
||||
return mi.uordblks - (LOCAL_TrailTop-LOCAL_GlobalBase);
|
||||
#else
|
||||
return Yap_ClauseSpace+Yap_IndexSpace_Tree+Yap_LUClauseSpace+Yap_LUIndexSpace_CP;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Yap_InitHeap(void *heap_addr) {
|
||||
InitHeap();
|
||||
Yap_HoleSize = 0;
|
||||
HeapMax = 0;
|
||||
}
|
||||
|
||||
static void InitExStacks(int wid, int Trail, int Stack) {
|
||||
static void InitExStacks(int wid, size_t Trail, size_t Stack) {
|
||||
CACHE_REGS
|
||||
UInt pm, sa;
|
||||
size_t pm, sa;
|
||||
|
||||
/* sanity checking for data areas */
|
||||
if (Trail < MinTrailSpace)
|
||||
|
@ -346,7 +401,7 @@ static void InitExStacks(int wid, int Trail, int Stack) {
|
|||
Stack = MinStackSpace;
|
||||
pm = (Trail + Stack) * K; /* memory to be
|
||||
* requested */
|
||||
sa = Stack * K; /* stack area size */
|
||||
sa = Stack * K; /* stack area size */
|
||||
|
||||
#ifdef THREADS
|
||||
if (wid)
|
||||
|
@ -363,7 +418,7 @@ static void InitExStacks(int wid, int Trail, int Stack) {
|
|||
|
||||
#if DEBUG
|
||||
if (Yap_output_msg) {
|
||||
UInt ta;
|
||||
size_t ta;
|
||||
|
||||
fprintf(stderr,
|
||||
"HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n",
|
||||
|
@ -378,7 +433,7 @@ static void InitExStacks(int wid, int Trail, int Stack) {
|
|||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
void Yap_InitExStacks(int wid, int Trail, int Stack) {
|
||||
void Yap_InitExStacks(int wid, size_t Trail, size_t Stack) {
|
||||
InitExStacks(wid, Trail, Stack);
|
||||
}
|
||||
|
||||
|
@ -399,7 +454,12 @@ void Yap_KillStacks(int wid) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) { InitHeap(); }
|
||||
void Yap_InitMemory(size_t Trail, size_t Heap, size_t Stack) {
|
||||
Yap_HoleSize = 0;
|
||||
HeapMax = 0;
|
||||
Yap_heap_regs =
|
||||
(struct various_codes *)calloc(1, sizeof(struct various_codes));
|
||||
}
|
||||
|
||||
int Yap_ExtendWorkSpace(Int s) {
|
||||
CACHE_REGS
|
||||
|
@ -594,7 +654,7 @@ GetBlock(unsigned long int n) { /* get free block with size at least n */
|
|||
return (b);
|
||||
}
|
||||
|
||||
static char *AllocHeap(unsigned long int size) {
|
||||
static char *AllocHeap(size_t size) {
|
||||
BlockHeader *b, *n;
|
||||
YAP_SEG_SIZE *sp;
|
||||
UInt align, extra;
|
||||
|
@ -624,7 +684,7 @@ static char *AllocHeap(unsigned long int size) {
|
|||
LOCK(FreeBlocksLock);
|
||||
if ((b = GetBlock(size))) {
|
||||
if (b->b_size >= size + 24 + 1) {
|
||||
n = (BlockHeader *)(((YAP_SEG_SIZE *)b) + size + 1);
|
||||
n = (BlockHeader *)(((YAP_SEG_SIZE *)b) + size + 1) v;
|
||||
n->b_size = b->b_size - size - 1;
|
||||
b->b_size = size;
|
||||
AddToFreeList(n);
|
||||
|
@ -1043,8 +1103,7 @@ static MALLOC_T mmap_extension(Int s, MALLOC_T base, int fixed_allocation) {
|
|||
MAP_PRIVATE
|
||||
#if !defined(__linux)
|
||||
/* use MAP_FIXED, otherwise God knows where you will be placed */
|
||||
|
|
||||
fixed_allocation
|
||||
| fixed_allocation
|
||||
#endif
|
||||
,
|
||||
fd, 0);
|
||||
|
@ -1282,7 +1341,7 @@ XX realloc(MALLOC_T ptr, size_t size) {
|
|||
MALLOC_T new = malloc(size);
|
||||
|
||||
if (ptr)
|
||||
memcpy(new, ptr, size);
|
||||
memmove(new, ptr, size);
|
||||
free(ptr);
|
||||
return (new);
|
||||
}
|
||||
|
@ -1359,6 +1418,7 @@ static int ExtendWorkSpace(Int s) {
|
|||
LOCAL_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
#if MBIT
|
||||
if ((CELL)ptr & MBIT) {
|
||||
LOCAL_ErrorMessage = LOCAL_ErrorSay;
|
||||
snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
|
@ -1366,6 +1426,7 @@ static int ExtendWorkSpace(Int s) {
|
|||
LOCAL_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
LOCAL_PrologMode = OldPrologMode;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1407,7 +1468,7 @@ void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) {
|
|||
#endif
|
||||
pm = (Trail + Heap + Stack); /* memory to be
|
||||
* requested */
|
||||
sa = Stack; /* stack area size */
|
||||
sa = Stack; /* stack area size */
|
||||
ta = Trail; /* trail area size */
|
||||
|
||||
#if RANDOMIZE_START_ADDRESS
|
||||
|
@ -1429,7 +1490,7 @@ void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) {
|
|||
|
||||
LOCAL_GlobalBase = LOCAL_LocalBase - sa;
|
||||
HeapLim = LOCAL_GlobalBase; /* avoid confusions while
|
||||
* * restoring */
|
||||
* * restoring */
|
||||
#if !USE_DL_MALLOC
|
||||
AuxTop = (ADDR)(AuxSp = (CELL *)LOCAL_GlobalBase);
|
||||
#endif
|
||||
|
@ -1448,8 +1509,9 @@ void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) {
|
|||
(UInt)LOCAL_TrailTop);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT
|
||||
"\tTrail: " UInt_FORMAT "\n",
|
||||
fprintf(stderr,
|
||||
"Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT
|
||||
"\tTrail: " UInt_FORMAT "\n",
|
||||
pm - sa - ta, sa, ta);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
|
287
C/args.c
287
C/args.c
|
@ -2,22 +2,18 @@
|
|||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Scan a list of arguments and output results to a pre-processed vector.
|
||||
*
|
||||
/**
|
||||
* Scan a list of arguments and output results to a pre-processed vector.
|
||||
*
|
||||
* @param listl: input list
|
||||
* @param def parameter definition
|
||||
*
|
||||
*
|
||||
* @return all arguments, some of them set, some of them not.
|
||||
*/
|
||||
|
||||
static xarg *
|
||||
matchKey(Atom key, xarg *e0, int n, const param_t *def)
|
||||
{
|
||||
static xarg *matchKey(Atom key, xarg *e0, int n, const param_t *def) {
|
||||
int i;
|
||||
for (i=0; i< n; i++) {
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!strcmp((char *)def->name, (char *)RepAtom(key)->StrOfAE)) {
|
||||
return e0;
|
||||
}
|
||||
|
@ -27,127 +23,110 @@ matchKey(Atom key, xarg *e0, int n, const param_t *def)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
xarg *
|
||||
Yap_ArgListToVector (Term listl, const param_t *def, int n)
|
||||
{
|
||||
/**
|
||||
* Returns the index of an argument key, or -1 if not found.
|
||||
*
|
||||
*/
|
||||
int Yap_ArgKey(Atom key, const param_t *def, int n) {
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!strcmp((char *)def->name, (char *)RepAtom(key)->StrOfAE)) {
|
||||
return i;
|
||||
}
|
||||
def++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define YAP_XARGINFO(Error, Message)
|
||||
|
||||
|
||||
xarg *Yap_ArgListToVector__(const char *file, const char *function, int lineno,
|
||||
Term listl, const param_t *def, int n,
|
||||
yap_error_number err) {
|
||||
CACHE_REGS
|
||||
xarg *a = calloc( n , sizeof(xarg) );
|
||||
if (IsApplTerm(listl) && FunctorOfTerm(listl) == FunctorModule)
|
||||
listl = ArgOfTerm(2,listl);
|
||||
xarg *a;
|
||||
listl = Deref(listl);
|
||||
if (IsVarTerm(listl)) {
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl,
|
||||
"while opening listl = ArgOfTerm(2, listl ,k)");
|
||||
}
|
||||
a = calloc(n, sizeof(xarg));
|
||||
|
||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||
if (IsVarTerm(listl) ) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
}
|
||||
if (IsAtomTerm(listl) ) {
|
||||
xarg *na = matchKey( AtomOfTerm(listl), a, n, def);
|
||||
if (IsAtomTerm(listl)) {
|
||||
xarg *na = matchKey(AtomOfTerm(listl), a, n, def);
|
||||
if (!na) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "match key");
|
||||
}
|
||||
} else if (IsApplTerm(listl)) {
|
||||
Functor f = FunctorOfTerm( listl );
|
||||
Functor f = FunctorOfTerm(listl);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "callable");
|
||||
}
|
||||
arity_t arity = ArityOfFunctor( f );
|
||||
arity_t arity = ArityOfFunctor(f);
|
||||
if (arity != 1) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "bad arity");
|
||||
}
|
||||
xarg *na = matchKey( NameOfFunctor( f ), a, n, def);
|
||||
xarg *na = matchKey(NameOfFunctor(f), a, n, def);
|
||||
if (!na) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, err, listl, "no match");
|
||||
}
|
||||
na->used = true;
|
||||
na->tvalue = ArgOfTerm(1, listl);
|
||||
} else {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_ATOM, listl, "not atom");
|
||||
}
|
||||
listl = MkPairTerm( listl, TermNil );
|
||||
listl = MkPairTerm(listl, TermNil);
|
||||
}
|
||||
while (IsPairTerm(listl)) {
|
||||
Term hd = HeadOfTerm( listl );
|
||||
listl = TailOfTerm( listl );
|
||||
if (IsVarTerm(hd) || IsVarTerm(listl)) {
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
if (IsVarTerm(hd)) {
|
||||
LOCAL_Error_Term = hd;
|
||||
} else {
|
||||
LOCAL_Error_Term = listl;
|
||||
}
|
||||
free( a );
|
||||
return NULL;
|
||||
Term hd = HeadOfTerm(listl);
|
||||
listl = TailOfTerm(listl);
|
||||
if (IsVarTerm(hd)) {
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, hd, "sub-element");
|
||||
}
|
||||
if (IsVarTerm(listl)) {
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, "sub-list");
|
||||
}
|
||||
if (IsAtomTerm(hd)) {
|
||||
xarg *na = matchKey( AtomOfTerm( hd ), a, n, def);
|
||||
xarg *na = matchKey(AtomOfTerm(hd), a, n, def);
|
||||
if (!na)
|
||||
return NULL;
|
||||
|
||||
Yap_ThrowError__(file, function, lineno, err, hd, "bad match in list");
|
||||
na->used = true;
|
||||
na->tvalue = TermNil;
|
||||
continue;
|
||||
} else if (IsApplTerm( hd )) {
|
||||
Functor f = FunctorOfTerm( hd );
|
||||
} else if (IsApplTerm(hd)) {
|
||||
Functor f = FunctorOfTerm(hd);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, err, hd, "bad compound");
|
||||
}
|
||||
arity_t arity = ArityOfFunctor( f );
|
||||
arity_t arity = ArityOfFunctor(f);
|
||||
if (arity != 1) {
|
||||
LOCAL_Error_TYPE = DOMAIN_ERROR_OUT_OF_RANGE;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_OUT_OF_RANGE, hd,
|
||||
"high arity");
|
||||
}
|
||||
xarg *na = matchKey( NameOfFunctor( f ), a, n, def);
|
||||
xarg *na = matchKey(NameOfFunctor(f), a, n, def);
|
||||
if (!na) {
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, err, hd, "no match");
|
||||
}
|
||||
na->used = 1;
|
||||
na->tvalue = ArgOfTerm(1, hd);
|
||||
na->used = true;
|
||||
na->tvalue = ArgOfTerm(1, hd);
|
||||
} else {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, err, hd, "bad type");
|
||||
}
|
||||
}
|
||||
if (IsVarTerm(listl)) {
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
LOCAL_Error_Term = listl;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, "unbound");
|
||||
} else if (listl != TermNil) {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "bad list");
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
static xarg *
|
||||
matchKey2(Atom key, xarg *e0, int n, const param2_t *def)
|
||||
{
|
||||
static xarg *matchKey2(Atom key, xarg *e0, int n, const param2_t *def) {
|
||||
int i;
|
||||
for (i=0; i< n; i++) {
|
||||
if (!strcmp((char*)def->name, (char*)RepAtom(key)->StrOfAE)) {
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!strcmp((char *)def->name, (char *)RepAtom(key)->StrOfAE)) {
|
||||
return e0;
|
||||
}
|
||||
def++;
|
||||
|
@ -155,118 +134,86 @@ matchKey2(Atom key, xarg *e0, int n, const param2_t *def)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/// Yap_ArgList2ToVector is much the same as before,
|
||||
/// but assumes parameters also have something called a
|
||||
/// scope
|
||||
xarg *
|
||||
Yap_ArgList2ToVector (Term listl, const param2_t *def, int n)
|
||||
{
|
||||
xarg *Yap_ArgList2ToVector__(const char *file, const char *function, int lineno,Term listl, const param2_t *def, int n, yap_error_number err) {
|
||||
CACHE_REGS
|
||||
xarg *a = calloc( n , sizeof(xarg) );
|
||||
xarg *a = calloc(n, sizeof(xarg));
|
||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||
if (IsVarTerm(listl) ) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
}
|
||||
if (IsAtomTerm(listl) ) {
|
||||
xarg *na = matchKey2( AtomOfTerm(listl), a, n, def);
|
||||
if (IsVarTerm(listl)) {
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, "unbound");
|
||||
}
|
||||
if (IsAtomTerm(listl)) {
|
||||
xarg *na = matchKey2(AtomOfTerm(listl), a, n, def);
|
||||
if (!na) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, err,
|
||||
listl, "bad match");
|
||||
}
|
||||
}
|
||||
if (IsApplTerm(listl)) {
|
||||
Functor f = FunctorOfTerm( listl );
|
||||
Functor f = FunctorOfTerm(listl);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_PARAMETER, listl,
|
||||
"bad compound");
|
||||
}
|
||||
arity_t arity = ArityOfFunctor( f );
|
||||
arity_t arity = ArityOfFunctor(f);
|
||||
if (arity != 1) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "bad arity");
|
||||
}
|
||||
xarg *na = matchKey2( NameOfFunctor( f ), a, n, def);
|
||||
xarg *na = matchKey2(NameOfFunctor(f), a, n, def);
|
||||
if (!na) {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_GENERIC_ARGUMENT,
|
||||
listl, "bad match");
|
||||
}
|
||||
} else {
|
||||
free( a );
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "");
|
||||
}
|
||||
listl = MkPairTerm( listl, TermNil );
|
||||
listl = MkPairTerm(listl, TermNil);
|
||||
}
|
||||
while (IsPairTerm(listl)) {
|
||||
Term hd = HeadOfTerm( listl );
|
||||
if (IsVarTerm(hd)) {
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
free( a );
|
||||
return NULL;
|
||||
Term hd = HeadOfTerm(listl);
|
||||
if (IsVarTerm(hd)) {
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, hd, "");
|
||||
}
|
||||
if (IsAtomTerm(hd)) {
|
||||
xarg *na = matchKey2( AtomOfTerm( hd ), a, n, def);
|
||||
xarg *na = matchKey2(AtomOfTerm(hd), a, n, def);
|
||||
if (!na) {
|
||||
LOCAL_Error_TYPE = DOMAIN_ERROR_OUT_OF_RANGE;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_GENERIC_ARGUMENT,
|
||||
hd, "bad match");
|
||||
}
|
||||
na->used = true;
|
||||
na->tvalue = TermNil;
|
||||
continue;
|
||||
} else if (IsApplTerm( hd )) {
|
||||
Functor f = FunctorOfTerm( hd );
|
||||
} else if (IsApplTerm(hd)) {
|
||||
Functor f = FunctorOfTerm(hd);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_PARAMETER, hd, "bad compound");
|
||||
}
|
||||
arity_t arity = ArityOfFunctor( f );
|
||||
arity_t arity = ArityOfFunctor(f);
|
||||
if (arity != 1) {
|
||||
LOCAL_Error_TYPE = DOMAIN_ERROR_OUT_OF_RANGE;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_GENERIC_ARGUMENT,
|
||||
hd, "bad arity");
|
||||
}
|
||||
xarg *na = matchKey2( NameOfFunctor( f ), a, n, def);
|
||||
xarg *na = matchKey2(NameOfFunctor(f), a, n, def);
|
||||
if (na) {
|
||||
na->used = 1;
|
||||
na->tvalue = ArgOfTerm(1, hd);
|
||||
na->used = 1;
|
||||
na->tvalue = ArgOfTerm(1, hd);
|
||||
} else {
|
||||
Yap_ThrowError__(file, function, lineno, err,
|
||||
hd, "bad key");
|
||||
}
|
||||
return a;
|
||||
} else {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, hd, "unbound");
|
||||
}
|
||||
listl = TailOfTerm(listl);
|
||||
}
|
||||
if (IsVarTerm(listl)) {
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
free( a );
|
||||
return NULL;
|
||||
if (IsVarTerm(listl)) {
|
||||
Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, "");
|
||||
}
|
||||
if (TermNil != listl) {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
free( a );
|
||||
return NULL;
|
||||
Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "");
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
|
20
C/arith0.c
20
C/arith0.c
|
@ -111,7 +111,8 @@ static char SccsId[] = "%W% %G%";
|
|||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
#include "alloc.h"
|
||||
|
||||
|
||||
|
||||
|
@ -172,9 +173,11 @@ eval0(Int fi) {
|
|||
}
|
||||
case op_heapused:
|
||||
/// - heapused
|
||||
/// Heap (data-base) space used, in bytes.
|
||||
/// Heap (data-base) space used, in bytes. In fact YAP either reports
|
||||
/// the total memory malloced, or the amount of allocated space in
|
||||
/// predicates.
|
||||
///
|
||||
RINT(HeapUsed);
|
||||
RINT(Yap_HeapUsed());
|
||||
case op_localsp:
|
||||
/// - local
|
||||
/// Local stack in use, in bytes
|
||||
|
@ -183,15 +186,6 @@ eval0(Int fi) {
|
|||
RINT((Int)ASP);
|
||||
#else
|
||||
RINT(LCL0 - ASP);
|
||||
#endif
|
||||
case op_b:
|
||||
/// - $b
|
||||
/// current choicepoint
|
||||
///
|
||||
#if YAPOR_SBA
|
||||
RINT((Int)B);
|
||||
#else
|
||||
RINT(LCL0 - (CELL *)B);
|
||||
#endif
|
||||
case op_env:
|
||||
/// - $env
|
||||
|
@ -251,7 +245,6 @@ static InitConstEntry InitConstTab[] = {
|
|||
{"heapused", op_heapused},
|
||||
{"local_sp", op_localsp},
|
||||
{"global_sp", op_globalsp},
|
||||
{"$last_choice_pt", op_b},
|
||||
{"$env", op_env},
|
||||
{"$tr", op_tr},
|
||||
{"stackfree", op_stackfree},
|
||||
|
@ -284,6 +277,7 @@ Yap_InitConstExps(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* This routine is called from Restore to make sure we have the same arithmetic operators */
|
||||
int
|
||||
Yap_ReInitConstExps(void)
|
||||
|
|
916
C/arith1.c
916
C/arith1.c
File diff suppressed because it is too large
Load Diff
194
C/arith2.c
194
C/arith2.c
|
@ -127,7 +127,7 @@ These are the binary numeric operators currently supported by YAP.
|
|||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
|
||||
#include "arith2.h"
|
||||
|
||||
|
@ -150,7 +150,7 @@ p_mod(Term t1, Term t2 USES_REGS) {
|
|||
Int mod;
|
||||
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " mod 0", i1);
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " mod 0", i1);
|
||||
if (i1 == Int_MIN && i2 == -1) {
|
||||
return MkIntTerm(0);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ p_mod(Term t1, Term t2 USES_REGS) {
|
|||
RINT(mod);
|
||||
}
|
||||
case (CELL)double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
case (CELL)big_int_e:
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_mod_int_big(IntegerOfTerm(t1), t2);
|
||||
|
@ -170,7 +170,7 @@ p_mod(Term t1, Term t2 USES_REGS) {
|
|||
break;
|
||||
}
|
||||
case (CELL)double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "mod/2");
|
||||
case (CELL)big_int_e:
|
||||
#ifdef USE_GMP
|
||||
switch (ETypeOfTerm(t2)) {
|
||||
|
@ -180,14 +180,14 @@ p_mod(Term t1, Term t2 USES_REGS) {
|
|||
Int i2 = IntegerOfTerm(t2);
|
||||
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... mod 0");
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... mod 0");
|
||||
return Yap_gmp_mod_big_int(t1, i2);
|
||||
}
|
||||
case (CELL)big_int_e:
|
||||
/* two bignums */
|
||||
return Yap_gmp_mod_big_big(t1, t2);
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
default:
|
||||
RERROR();
|
||||
}
|
||||
|
@ -210,12 +210,12 @@ p_div2(Term t1, Term t2 USES_REGS) {
|
|||
Int res, mod;
|
||||
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " div 0", i1);
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " div 0", i1);
|
||||
if (i1 == Int_MIN && i2 == -1) {
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_add_ints(Int_MAX, 1);
|
||||
return Yap_gmp_add_ints(Int_MAX, 1);
|
||||
#else
|
||||
return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, t1,
|
||||
Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, t1,
|
||||
"// /2 with %d and %d", i1, i2);
|
||||
#endif
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ p_div2(Term t1, Term t2 USES_REGS) {
|
|||
RINT(res);
|
||||
}
|
||||
case (CELL)double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "div/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "div/2");
|
||||
case (CELL)big_int_e:
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_div_int_big(IntegerOfTerm(t1), t2);
|
||||
|
@ -236,7 +236,7 @@ p_div2(Term t1, Term t2 USES_REGS) {
|
|||
break;
|
||||
}
|
||||
case (CELL)double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "div/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "div/2");
|
||||
case (CELL)big_int_e:
|
||||
#ifdef USE_GMP
|
||||
switch (ETypeOfTerm(t2)) {
|
||||
|
@ -246,14 +246,14 @@ p_div2(Term t1, Term t2 USES_REGS) {
|
|||
Int i2 = IntegerOfTerm(t2);
|
||||
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... div 0");
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... div 0");
|
||||
return Yap_gmp_div2_big_int(t1, i2);
|
||||
}
|
||||
case (CELL)big_int_e:
|
||||
/* two bignums */
|
||||
return Yap_gmp_div2_big_big(t1, t2);
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "div/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "div/2");
|
||||
default:
|
||||
RERROR();
|
||||
}
|
||||
|
@ -275,14 +275,14 @@ p_rem(Term t1, Term t2 USES_REGS) {
|
|||
Int i2 = IntegerOfTerm(t2);
|
||||
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " rem 0", i1);
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " rem 0", i1);
|
||||
if (i1 == Int_MIN && i2 == -1) {
|
||||
return MkIntTerm(0);
|
||||
}
|
||||
RINT(i1%i2);
|
||||
}
|
||||
case (CELL)double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rem/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rem/2");
|
||||
case (CELL)big_int_e:
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_rem_int_big(IntegerOfTerm(t1), t2);
|
||||
|
@ -292,19 +292,19 @@ p_rem(Term t1, Term t2 USES_REGS) {
|
|||
}
|
||||
break;
|
||||
case (CELL)double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "rem/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "rem/2");
|
||||
case (CELL)big_int_e:
|
||||
#ifdef USE_GMP
|
||||
switch (ETypeOfTerm(t2)) {
|
||||
case long_int_e:
|
||||
if (IntegerOfTerm(t2) == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... rem 0");
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... rem 0");
|
||||
return Yap_gmp_rem_big_int(t1, IntegerOfTerm(t2));
|
||||
case (CELL)big_int_e:
|
||||
/* two bignums */
|
||||
return Yap_gmp_rem_big_big(t1, t2);
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rem/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rem/2");
|
||||
default:
|
||||
RERROR();
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ p_rdiv(Term t1, Term t2 USES_REGS) {
|
|||
#ifdef USE_GMP
|
||||
switch (ETypeOfTerm(t1)) {
|
||||
case (CELL)double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rdiv/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rdiv/2");
|
||||
case (CELL)long_int_e:
|
||||
switch (ETypeOfTerm(t2)) {
|
||||
case (CELL)long_int_e:
|
||||
|
@ -330,7 +330,7 @@ p_rdiv(Term t1, Term t2 USES_REGS) {
|
|||
Int i2 = IntegerOfTerm(t2);
|
||||
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " rdiv 0", i1);
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " rdiv 0", i1);
|
||||
return Yap_gmq_rdiv_int_int(i1, i2);
|
||||
}
|
||||
case (CELL)big_int_e:
|
||||
|
@ -344,13 +344,13 @@ p_rdiv(Term t1, Term t2 USES_REGS) {
|
|||
switch (ETypeOfTerm(t2)) {
|
||||
case long_int_e:
|
||||
if (IntegerOfTerm(t2) == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... rdiv 0");
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... rdiv 0");
|
||||
/* I know the term is much larger, so: */
|
||||
return Yap_gmq_rdiv_big_int(t1, IntegerOfTerm(t2));
|
||||
case (CELL)big_int_e:
|
||||
return Yap_gmq_rdiv_big_big(t1, t2);
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rdiv/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rdiv/2");
|
||||
default:
|
||||
RERROR();
|
||||
}
|
||||
|
@ -443,13 +443,13 @@ p_xor(Term t1, Term t2 USES_REGS)
|
|||
{
|
||||
switch (ETypeOfTerm(t1)) {
|
||||
case long_int_e:
|
||||
|
||||
|
||||
switch (ETypeOfTerm(t2)) {
|
||||
case long_int_e:
|
||||
/* two integers */
|
||||
RINT(IntegerOfTerm(t1) ^ IntegerOfTerm(t2));
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
case big_int_e:
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_xor_int_big(IntegerOfTerm(t1), t2);
|
||||
|
@ -459,7 +459,7 @@ p_xor(Term t1, Term t2 USES_REGS)
|
|||
}
|
||||
break;
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "#/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "#/2");
|
||||
case big_int_e:
|
||||
#ifdef USE_GMP
|
||||
switch (ETypeOfTerm(t2)) {
|
||||
|
@ -468,7 +468,7 @@ p_xor(Term t1, Term t2 USES_REGS)
|
|||
case big_int_e:
|
||||
return Yap_gmp_xor_big_big(t1, t2);
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
default:
|
||||
RERROR();
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ p_power(Term t1, Term t2 USES_REGS)
|
|||
}
|
||||
|
||||
/* next function is adapted from:
|
||||
Inline C++ integer exponentiation routines
|
||||
Inline C++ integer exponentiation routines
|
||||
Version 1.01
|
||||
Copyright (C) 1999-2004 John C. Bowman <bowman@math.ualberta.ca>
|
||||
*/
|
||||
|
@ -654,9 +654,9 @@ ipow(Int x, Int p)
|
|||
|
||||
if (p == 0) return ((CELL)1);
|
||||
if (x == 0 && p > 0) return 0L;
|
||||
if(p < 0)
|
||||
if(p < 0)
|
||||
return (-p % 2) ? x : ((CELL)1);
|
||||
|
||||
|
||||
r = ((CELL)1);
|
||||
for(;;) {
|
||||
if(p & 1) {
|
||||
|
@ -690,7 +690,7 @@ p_exp(Term t1, Term t2 USES_REGS)
|
|||
Int pow;
|
||||
|
||||
if (i2 < 0) {
|
||||
return Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2,
|
||||
Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2,
|
||||
"%d ^ %d", i1, i2);
|
||||
}
|
||||
pow = ipow(i1,i2);
|
||||
|
@ -836,7 +836,7 @@ p_gcd(Term t1, Term t2 USES_REGS)
|
|||
RINT(gcd(i1,i2 PASS_REGS));
|
||||
}
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
case big_int_e:
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_gcd_int_big(IntegerOfTerm(t1), t2);
|
||||
|
@ -846,7 +846,7 @@ p_gcd(Term t1, Term t2 USES_REGS)
|
|||
}
|
||||
break;
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "gcd/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "gcd/2");
|
||||
case big_int_e:
|
||||
#ifdef USE_GMP
|
||||
switch (ETypeOfTerm(t2)) {
|
||||
|
@ -855,7 +855,7 @@ p_gcd(Term t1, Term t2 USES_REGS)
|
|||
case big_int_e:
|
||||
return Yap_gmp_gcd_big_big(t1, t2);
|
||||
case double_e:
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
default:
|
||||
RERROR();
|
||||
}
|
||||
|
@ -1142,167 +1142,125 @@ static InitBinEntry InitBinTab[] = {
|
|||
{"rdiv", op_rdiv}
|
||||
};
|
||||
|
||||
static Int
|
||||
static Int
|
||||
p_binary_is( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG2);
|
||||
Term t1, t2;
|
||||
yap_error_number err;
|
||||
Term t1, t2, tout;
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_ArithError(INSTANTIATION_ERROR,t, "VAR(X , Y)");
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_ClearExs();
|
||||
t1 = Yap_Eval(Deref(ARG3));
|
||||
if ((err = Yap_FoundArithError())) {
|
||||
Atom name;
|
||||
if (IsIntTerm(t)) {
|
||||
Int i = IntOfTerm(t);
|
||||
name = Yap_NameOfBinaryOp(i);
|
||||
} else {
|
||||
name = AtomOfTerm(Deref(ARG2));
|
||||
}
|
||||
Yap_EvalError(err,ARG3,"X is ~s/2: error in first argument ", RepAtom(name)->StrOfAE);
|
||||
return FALSE;
|
||||
}
|
||||
Yap_ClearExs();
|
||||
t1 = Yap_Eval(Deref(ARG3));
|
||||
t2 = Yap_Eval(Deref(ARG4));
|
||||
if ((err=Yap_FoundArithError())) {
|
||||
Atom name;
|
||||
if (IsIntTerm(t)) {
|
||||
Int i = IntOfTerm(t);
|
||||
name = Yap_NameOfBinaryOp(i);
|
||||
} else {
|
||||
name = AtomOfTerm(Deref(ARG2));
|
||||
}
|
||||
Yap_EvalError(err,ARG3,"X is ~s/2: error in first argument ", RepAtom(name)->StrOfAE);
|
||||
return FALSE;
|
||||
}
|
||||
if (IsIntTerm(t)) {
|
||||
Int i = IntOfTerm(t);
|
||||
Term tout = eval2(i, t1, t2 PASS_REGS);
|
||||
if ((err = Yap_FoundArithError()) != YAP_NO_ERROR) {
|
||||
Term ts[2], terr;
|
||||
Atom name = Yap_NameOfBinaryOp( i );
|
||||
Functor f = Yap_MkFunctor( name, 2 );
|
||||
ts[0] = t1;
|
||||
ts[1] = t2;
|
||||
terr = Yap_MkApplTerm( f, 2, ts );
|
||||
Yap_EvalError(err, terr ,"error in %s/2 ", RepAtom(name)->StrOfAE);
|
||||
return FALSE;
|
||||
}
|
||||
bool go;
|
||||
do {
|
||||
go = false;
|
||||
tout = eval2(i, t1, t2 PASS_REGS);
|
||||
go = Yap_CheckArithError();
|
||||
} while (go);
|
||||
return Yap_unify_constant(ARG1,tout);
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom name = AtomOfTerm(t);
|
||||
ExpEntry *p;
|
||||
Term out;
|
||||
|
||||
bool go;
|
||||
int j;
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 2)))) {
|
||||
Yap_EvalError(TYPE_ERROR_EVALUABLE, takeIndicator(t),
|
||||
"functor %s/2 for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE);
|
||||
P = FAILCODE;
|
||||
return(FALSE);
|
||||
Yap_EvalError(TYPE_ERROR_EVALUABLE, t, "`%s ", name->StrOfAE
|
||||
);
|
||||
}
|
||||
out= eval2(p->FOfEE, t1, t2 PASS_REGS);
|
||||
if ((err = Yap_FoundArithError()) != YAP_NO_ERROR) {
|
||||
Term ts[2], terr;
|
||||
Functor f = Yap_MkFunctor( name, 2 );
|
||||
ts[0] = t1;
|
||||
ts[1] = t2;
|
||||
terr = Yap_MkApplTerm( f, 2, ts );
|
||||
Yap_EvalError(err, terr ,"error in ~s/2 ", RepAtom(name)->StrOfAE);
|
||||
return FALSE;
|
||||
}
|
||||
return Yap_unify_constant(ARG1,out);
|
||||
j = p->FOfEE;
|
||||
|
||||
do {
|
||||
go = false;
|
||||
Yap_ClearExs();
|
||||
tout = eval2(j, t1, t2 PASS_REGS);
|
||||
go = Yap_CheckArithError();
|
||||
} while (go);
|
||||
return Yap_unify_constant(ARG1,tout);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Int
|
||||
static Int
|
||||
do_arith23(arith2_op op USES_REGS)
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG1);
|
||||
Int out;
|
||||
Term t1, t2;
|
||||
yap_error_number err;
|
||||
bool go;
|
||||
Term t1, t2, out;
|
||||
|
||||
Yap_ClearExs();
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_EvalError(INSTANTIATION_ERROR,t, "X is Y");
|
||||
return(FALSE);
|
||||
}
|
||||
t1 = Yap_Eval(t);
|
||||
if (t1 == 0L)
|
||||
return FALSE;
|
||||
do {
|
||||
go = false;
|
||||
Yap_ClearExs();
|
||||
t1 = Yap_Eval(t);
|
||||
t2 = Yap_Eval(Deref(ARG2));
|
||||
if (t2 == 0L)
|
||||
return FALSE;
|
||||
out= eval2(op, t1, t2 PASS_REGS);
|
||||
if ((err=Yap_FoundArithError())) {
|
||||
Term ts[2], t;
|
||||
Functor f = Yap_MkFunctor( Yap_NameOfBinaryOp(op), 2 );
|
||||
ts[0] = t1;
|
||||
ts[1] = t2;
|
||||
t = Yap_MkApplTerm( f, 2, ts );
|
||||
Yap_EvalError(err, t ,"error in ~s(Y,Z) ",Yap_NameOfBinaryOp(op));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
go = Yap_CheckArithError();
|
||||
} while (go);
|
||||
return Yap_unify_constant(ARG3,out);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_plus( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_plus PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_minus( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_minus PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_times( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_times PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_div( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_div PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_and( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_and PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_or( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_or PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_slr( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_slr PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
export_p_sll( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_sll PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
static Int
|
||||
p_binary_op_as_integer( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG1);
|
||||
|
@ -1317,7 +1275,6 @@ p_binary_op_as_integer( USES_REGS1 )
|
|||
if (IsAtomTerm(t)) {
|
||||
Atom name = AtomOfTerm(t);
|
||||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 2)))) {
|
||||
return Yap_unify(ARG1,ARG2);
|
||||
}
|
||||
|
@ -1376,4 +1333,3 @@ Yap_ReInitBinaryExps(void)
|
|||
{
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
|
2196
C/arrays.c
2196
C/arrays.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
58
C/attvar.c
58
C/attvar.c
|
@ -8,31 +8,40 @@
|
|||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: attvar.c *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: YAP support for attributed vars *
|
||||
* File: attvar.c * Last rev:
|
||||
** mods: * comments: YAP support for attributed vars *
|
||||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file attvar.c
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Mon Apr 30 09:31:59 2018
|
||||
*
|
||||
* @brief attributed variables
|
||||
* @namespace prolog
|
||||
*
|
||||
*/
|
||||
#include "Yap.h"
|
||||
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "heapgc.h"
|
||||
#include "Yatom.h"
|
||||
#include "attvar.h"
|
||||
#include "heapgc.h"
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
/** @{ */
|
||||
/**
|
||||
@defgroup AttributedVariables_Builtins Low-level support for Attributed
|
||||
Variables
|
||||
|
||||
/** @defgroup AttributeVariables_Builtins Implementation of Attribute
|
||||
Declarations
|
||||
@ingroup AttributeVariables
|
||||
@brief Implementation of Attribute Declarations
|
||||
@ingroup AttributedVariables
|
||||
@{
|
||||
*/
|
||||
|
||||
#ifdef COROUTINING
|
||||
|
@ -184,7 +193,7 @@ static void WakeAttVar(CELL *pt1, CELL reg2 USES_REGS) {
|
|||
if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) {
|
||||
/* oops, our goal is on the queue to be woken */
|
||||
if (!Yap_unify(attv->Value, reg2)) {
|
||||
AddFailToQueue(PASS_REGS1);
|
||||
AddFailToQueue(PASS_REGS1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -201,7 +210,7 @@ static void WakeAttVar(CELL *pt1, CELL reg2 USES_REGS) {
|
|||
|
||||
void Yap_WakeUp(CELL *pt0) {
|
||||
CACHE_REGS
|
||||
CELL d0 = *pt0;
|
||||
CELL d0 = *pt0;
|
||||
RESET_VARIABLE(pt0);
|
||||
WakeAttVar(pt0, d0 PASS_REGS);
|
||||
}
|
||||
|
@ -674,7 +683,6 @@ static Int free_att(USES_REGS1) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static Int get_atts(USES_REGS1) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
|
@ -886,7 +894,7 @@ static Term AllAttVars(USES_REGS1) {
|
|||
|
||||
while (pt < myH) {
|
||||
switch (*pt) {
|
||||
case (CELL) FunctorAttVar:
|
||||
case (CELL)FunctorAttVar:
|
||||
if (IsUnboundVar(pt + 1)) {
|
||||
if (ASP - myH < 1024) {
|
||||
LOCAL_Error_Size = (ASP - HR) * sizeof(CELL);
|
||||
|
@ -900,24 +908,23 @@ static Term AllAttVars(USES_REGS1) {
|
|||
}
|
||||
pt += (1 + ATT_RECORD_ARITY);
|
||||
break;
|
||||
case (CELL) FunctorDouble:
|
||||
case (CELL)FunctorDouble:
|
||||
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
||||
pt += 4;
|
||||
#else
|
||||
pt += 3;
|
||||
#endif
|
||||
break;
|
||||
case (CELL) FunctorString:
|
||||
case (CELL)FunctorString:
|
||||
pt += 3 + pt[1];
|
||||
break;
|
||||
case (CELL) FunctorBigInt: {
|
||||
Int sz = 3 +
|
||||
(sizeof(MP_INT) +
|
||||
(((MP_INT *)(pt + 2))->_mp_alloc * sizeof(mp_limb_t))) /
|
||||
sizeof(CELL);
|
||||
case (CELL)FunctorBigInt: {
|
||||
Int sz = 3 + (sizeof(MP_INT) +
|
||||
(((MP_INT *)(pt + 2))->_mp_alloc * sizeof(mp_limb_t))) /
|
||||
sizeof(CELL);
|
||||
pt += sz;
|
||||
} break;
|
||||
case (CELL) FunctorLongInt:
|
||||
case (CELL)FunctorLongInt:
|
||||
pt += 3;
|
||||
break;
|
||||
default:
|
||||
|
@ -966,7 +973,7 @@ static Int is_attvar(USES_REGS1) {
|
|||
static Int attvar_bound(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
return IsVarTerm(t) && IsAttachedTerm(t) &&
|
||||
!IsUnboundVar(&(RepAttVar(VarOfTerm(t))->Done));
|
||||
!IsUnboundVar(&(RepAttVar(VarOfTerm(t))->Done));
|
||||
}
|
||||
|
||||
static Int void_term(USES_REGS1) { return Yap_unify(ARG1, TermVoidAtt); }
|
||||
|
@ -1006,7 +1013,7 @@ static Int attvar_bound(USES_REGS1) { return FALSE; }
|
|||
|
||||
void Yap_InitAttVarPreds(void) {
|
||||
CACHE_REGS
|
||||
Term OldCurrentModule = CurrentModule;
|
||||
Term OldCurrentModule = CurrentModule;
|
||||
CurrentModule = ATTRIBUTES_MODULE;
|
||||
#ifdef COROUTINING
|
||||
GLOBAL_attas[attvars_ext].bind_op = WakeAttVar;
|
||||
|
@ -1028,8 +1035,7 @@ void Yap_InitAttVarPreds(void) {
|
|||
Yap_InitCPred("rm_att", 4, rm_att, 0);
|
||||
Yap_InitCPred("bind_attvar", 1, bind_attvar, SafePredFlag);
|
||||
Yap_InitCPred("unbind_attvar", 1, unbind_attvar, SafePredFlag);
|
||||
Yap_InitCPred("modules_with_attributes", 2, modules_with_atts,
|
||||
SafePredFlag);
|
||||
Yap_InitCPred("modules_with_attributes", 2, modules_with_atts, SafePredFlag);
|
||||
Yap_InitCPred("void_term", 1, void_term, SafePredFlag);
|
||||
Yap_InitCPred("free_term", 1, free_term, SafePredFlag);
|
||||
Yap_InitCPred("fast_unify_attributed", 2, fast_unify, 0);
|
||||
|
|
11
C/bb.c
11
C/bb.c
|
@ -18,6 +18,17 @@
|
|||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file bb.c
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Mon Apr 30 09:32:54 2018
|
||||
*
|
||||
* @brief blackboard
|
||||
*
|
||||
* @namespace prolog
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup BlackBoard The Blackboard
|
||||
@ingroup builtins
|
||||
|
|
361
C/bignum.c
361
C/bignum.c
|
@ -1,22 +1,33 @@
|
|||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: arith1.c *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: bignum support through gmp *
|
||||
* *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: arith1.c *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: bignum support through gmp *
|
||||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
/**
|
||||
* @file bignum.c
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Mon Apr 30 09:34:59 2018
|
||||
*
|
||||
* @brief BigNums and More
|
||||
* @namespace prolog
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
|
@ -30,15 +41,13 @@ static char SccsId[] = "%W% %G%";
|
|||
|
||||
#ifdef USE_GMP
|
||||
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
#include "alloc.h"
|
||||
|
||||
Term
|
||||
Yap_MkBigIntTerm(MP_INT *big)
|
||||
{
|
||||
Term Yap_MkBigIntTerm(MP_INT *big) {
|
||||
CACHE_REGS
|
||||
Int nlimbs;
|
||||
MP_INT *dst = (MP_INT *)(HR+2);
|
||||
MP_INT *dst = (MP_INT *)(HR + 2);
|
||||
CELL *ret = HR;
|
||||
Int bytes;
|
||||
|
||||
|
@ -50,38 +59,33 @@ Yap_MkBigIntTerm(MP_INT *big)
|
|||
// nlimbs = ALIGN_YAPTYPE(bytes,CELL)/CellSize;
|
||||
// this works, but it shouldn't need to do this...
|
||||
nlimbs = big->_mp_alloc;
|
||||
bytes = nlimbs*sizeof(CELL);
|
||||
if (nlimbs > (ASP-ret)-1024) {
|
||||
bytes = nlimbs * sizeof(CELL);
|
||||
if (nlimbs > (ASP - ret) - 1024) {
|
||||
return TermNil;
|
||||
}
|
||||
HR[0] = (CELL)FunctorBigInt;
|
||||
HR[1] = BIG_INT;
|
||||
|
||||
dst->_mp_size = big->_mp_size;
|
||||
dst->_mp_alloc = nlimbs*(CellSize/sizeof(mp_limb_t));
|
||||
memmove((void *)(dst+1), (const void *)(big->_mp_d), bytes);
|
||||
HR = (CELL *)(dst+1)+nlimbs;
|
||||
dst->_mp_alloc = nlimbs * (CellSize / sizeof(mp_limb_t));
|
||||
memmove((void *)(dst + 1), (const void *)(big->_mp_d), bytes);
|
||||
HR = (CELL *)(dst + 1) + nlimbs;
|
||||
HR[0] = EndSpecials;
|
||||
HR++;
|
||||
return AbsAppl(ret);
|
||||
}
|
||||
|
||||
MP_INT *Yap_BigIntOfTerm(Term t) {
|
||||
MP_INT *new = (MP_INT *)(RepAppl(t) + 2);
|
||||
|
||||
MP_INT *
|
||||
Yap_BigIntOfTerm(Term t)
|
||||
{
|
||||
MP_INT *new = (MP_INT *)(RepAppl(t)+2);
|
||||
|
||||
new->_mp_d = (mp_limb_t *)(new+1);
|
||||
return(new);
|
||||
new->_mp_d = (mp_limb_t *)(new + 1);
|
||||
return (new);
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_MkBigRatTerm(MP_RAT *big)
|
||||
{
|
||||
Term Yap_MkBigRatTerm(MP_RAT *big) {
|
||||
CACHE_REGS
|
||||
Int nlimbs;
|
||||
MP_INT *dst = (MP_INT *)(HR+2);
|
||||
MP_INT *dst = (MP_INT *)(HR + 2);
|
||||
MP_INT *num = mpq_numref(big);
|
||||
MP_INT *den = mpq_denref(big);
|
||||
MP_RAT *rat;
|
||||
|
@ -89,84 +93,78 @@ Yap_MkBigRatTerm(MP_RAT *big)
|
|||
|
||||
if (mpz_cmp_si(den, 1) == 0)
|
||||
return Yap_MkBigIntTerm(num);
|
||||
if ((num->_mp_alloc+den->_mp_alloc)*(sizeof(mp_limb_t)/CellSize) > (ASP-ret)-1024) {
|
||||
if ((num->_mp_alloc + den->_mp_alloc) * (sizeof(mp_limb_t) / CellSize) >
|
||||
(ASP - ret) - 1024) {
|
||||
return TermNil;
|
||||
}
|
||||
HR[0] = (CELL)FunctorBigInt;
|
||||
HR[1] = BIG_RATIONAL;
|
||||
dst->_mp_size = 0;
|
||||
rat = (MP_RAT *)(dst+1);
|
||||
rat = (MP_RAT *)(dst + 1);
|
||||
rat->_mp_num._mp_size = num->_mp_size;
|
||||
rat->_mp_num._mp_alloc = num->_mp_alloc;
|
||||
nlimbs = (num->_mp_alloc)*(sizeof(mp_limb_t)/CellSize);
|
||||
memmove((void *)(rat+1), (const void *)(num->_mp_d), nlimbs*CellSize);
|
||||
nlimbs = (num->_mp_alloc) * (sizeof(mp_limb_t) / CellSize);
|
||||
memmove((void *)(rat + 1), (const void *)(num->_mp_d), nlimbs * CellSize);
|
||||
rat->_mp_den._mp_size = den->_mp_size;
|
||||
rat->_mp_den._mp_alloc = den->_mp_alloc;
|
||||
HR = (CELL *)(rat+1)+nlimbs;
|
||||
nlimbs = (den->_mp_alloc)*(sizeof(mp_limb_t)/CellSize);
|
||||
memmove((void *)(HR), (const void *)(den->_mp_d), nlimbs*CellSize);
|
||||
HR = (CELL *)(rat + 1) + nlimbs;
|
||||
nlimbs = (den->_mp_alloc) * (sizeof(mp_limb_t) / CellSize);
|
||||
memmove((void *)(HR), (const void *)(den->_mp_d), nlimbs * CellSize);
|
||||
HR += nlimbs;
|
||||
dst->_mp_alloc = (HR-(CELL *)(dst+1));
|
||||
dst->_mp_alloc = (HR - (CELL *)(dst + 1));
|
||||
HR[0] = EndSpecials;
|
||||
HR++;
|
||||
return AbsAppl(ret);
|
||||
}
|
||||
|
||||
MP_RAT *
|
||||
Yap_BigRatOfTerm(Term t)
|
||||
{
|
||||
MP_RAT *new = (MP_RAT *)(RepAppl(t)+2+sizeof(MP_INT)/sizeof(CELL));
|
||||
MP_RAT *Yap_BigRatOfTerm(Term t) {
|
||||
MP_RAT *new = (MP_RAT *)(RepAppl(t) + 2 + sizeof(MP_INT) / sizeof(CELL));
|
||||
mp_limb_t *nt;
|
||||
|
||||
nt = new->_mp_num._mp_d = (mp_limb_t *)(new+1);
|
||||
nt = new->_mp_num._mp_d = (mp_limb_t *)(new + 1);
|
||||
nt += new->_mp_num._mp_alloc;
|
||||
new->_mp_den._mp_d = nt;
|
||||
return new;
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_RatTermToApplTerm(Term t)
|
||||
{
|
||||
Term Yap_RatTermToApplTerm(Term t) {
|
||||
Term ts[2];
|
||||
MP_RAT *rat = Yap_BigRatOfTerm(t);
|
||||
|
||||
ts[0] = Yap_MkBigIntTerm(mpq_numref(rat));
|
||||
ts[1] = Yap_MkBigIntTerm(mpq_denref(rat));
|
||||
return Yap_MkApplTerm(FunctorRDiv,2,ts);
|
||||
ts[0] = Yap_MkBigIntTerm(mpq_numref(rat));
|
||||
ts[1] = Yap_MkBigIntTerm(mpq_denref(rat));
|
||||
return Yap_MkApplTerm(FunctorRDiv, 2, ts);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Term
|
||||
Yap_AllocExternalDataInStack(CELL tag, size_t bytes)
|
||||
{
|
||||
Term Yap_AllocExternalDataInStack(CELL tag, size_t bytes, void *pt) {
|
||||
CACHE_REGS
|
||||
Int nlimbs;
|
||||
MP_INT *dst = (MP_INT *)(HR+2);
|
||||
MP_INT *dst = (MP_INT *)(HR + 2);
|
||||
CELL *ret = HR;
|
||||
|
||||
nlimbs = ALIGN_BY_TYPE(bytes,CELL)/CellSize;
|
||||
if (nlimbs > (ASP-ret)-1024) {
|
||||
CELL **blobp;
|
||||
|
||||
nlimbs = ALIGN_BY_TYPE(bytes, CELL) / CellSize;
|
||||
if (nlimbs > (ASP - ret) - 1024) {
|
||||
return TermNil;
|
||||
}
|
||||
HR[0] = (CELL)FunctorBigInt;
|
||||
HR[1] = tag;
|
||||
dst->_mp_size = 0;
|
||||
dst->_mp_alloc = nlimbs;
|
||||
HR = (CELL *)(dst+1)+nlimbs;
|
||||
HR = (CELL *)(dst + 1) + nlimbs;
|
||||
HR[0] = EndSpecials;
|
||||
HR++;
|
||||
if (tag != EXTERNAL_BLOB) {
|
||||
TrailTerm(TR) = AbsPair(ret);
|
||||
TR++;
|
||||
}
|
||||
blobp = (CELL **)pt;
|
||||
*blobp = (CELL *)(dst + 1);
|
||||
return AbsAppl(ret);
|
||||
}
|
||||
|
||||
int Yap_CleanOpaqueVariable(CELL *pt)
|
||||
{
|
||||
int Yap_CleanOpaqueVariable(CELL d) {
|
||||
CELL blob_info, blob_tag;
|
||||
MP_INT *blobp;
|
||||
|
||||
CELL *pt = RepAppl(HeadOfTerm(d));
|
||||
#ifdef DEBUG
|
||||
/* sanity checking */
|
||||
if (pt[0] != (CELL)FunctorBigInt) {
|
||||
|
@ -175,23 +173,20 @@ int Yap_CleanOpaqueVariable(CELL *pt)
|
|||
}
|
||||
#endif
|
||||
blob_tag = pt[1];
|
||||
if (blob_tag < USER_BLOB_START ||
|
||||
blob_tag >= USER_BLOB_END) {
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag);
|
||||
if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) {
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt),
|
||||
"clean opaque: bad blob with tag " UInt_FORMAT, blob_tag);
|
||||
return FALSE;
|
||||
}
|
||||
blob_info = blob_tag - USER_BLOB_START;
|
||||
blob_info = blob_tag;
|
||||
if (!GLOBAL_OpaqueHandlers)
|
||||
return FALSE;
|
||||
blobp = (MP_INT *)(pt+2);
|
||||
return false;
|
||||
if (!GLOBAL_OpaqueHandlers[blob_info].fail_handler)
|
||||
return TRUE;
|
||||
return (GLOBAL_OpaqueHandlers[blob_info].fail_handler)((void *)(blobp+1));
|
||||
return true;
|
||||
return (GLOBAL_OpaqueHandlers[blob_info].fail_handler)(d);
|
||||
}
|
||||
|
||||
Opaque_CallOnWrite
|
||||
Yap_blob_write_handler(Term t)
|
||||
{
|
||||
YAP_Opaque_CallOnWrite Yap_blob_write_handler(Term t) {
|
||||
CELL blob_info, blob_tag;
|
||||
CELL *pt = RepAppl(t);
|
||||
|
||||
|
@ -203,21 +198,19 @@ Yap_blob_write_handler(Term t)
|
|||
}
|
||||
#endif
|
||||
blob_tag = pt[1];
|
||||
if (blob_tag < USER_BLOB_START ||
|
||||
blob_tag >= USER_BLOB_END) {
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag);
|
||||
if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) {
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt),
|
||||
"clean opaque: bad blob with tag " UInt_FORMAT, blob_tag);
|
||||
return FALSE;
|
||||
}
|
||||
blob_info = blob_tag - USER_BLOB_START;
|
||||
blob_info = blob_tag;
|
||||
if (!GLOBAL_OpaqueHandlers) {
|
||||
return NULL;
|
||||
}
|
||||
return GLOBAL_OpaqueHandlers[blob_info].write_handler;
|
||||
}
|
||||
|
||||
Opaque_CallOnGCMark
|
||||
Yap_blob_gc_mark_handler(Term t)
|
||||
{
|
||||
YAP_Opaque_CallOnGCMark Yap_blob_gc_mark_handler(Term t) {
|
||||
CELL blob_info, blob_tag;
|
||||
CELL *pt = RepAppl(t);
|
||||
|
||||
|
@ -229,19 +222,16 @@ Yap_blob_gc_mark_handler(Term t)
|
|||
}
|
||||
#endif
|
||||
blob_tag = pt[1];
|
||||
if (blob_tag < USER_BLOB_START ||
|
||||
blob_tag >= USER_BLOB_END) {
|
||||
if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) {
|
||||
return NULL;
|
||||
}
|
||||
blob_info = blob_tag - USER_BLOB_START;
|
||||
blob_info = blob_tag;
|
||||
if (!GLOBAL_OpaqueHandlers)
|
||||
return NULL;
|
||||
return GLOBAL_OpaqueHandlers[blob_info].gc_mark_handler;
|
||||
return GLOBAL_OpaqueHandlers[blob_info].mark_handler;
|
||||
}
|
||||
|
||||
Opaque_CallOnGCRelocate
|
||||
Yap_blob_gc_relocate_handler(Term t)
|
||||
{
|
||||
YAP_Opaque_CallOnGCRelocate Yap_blob_gc_relocate_handler(Term t) {
|
||||
CELL blob_info, blob_tag;
|
||||
CELL *pt = RepAppl(t);
|
||||
|
||||
|
@ -253,19 +243,18 @@ Yap_blob_gc_relocate_handler(Term t)
|
|||
}
|
||||
#endif
|
||||
blob_tag = pt[1];
|
||||
if (blob_tag < USER_BLOB_START ||
|
||||
blob_tag >= USER_BLOB_END) {
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag);
|
||||
if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) {
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt),
|
||||
"clean opaque: bad blob with tag " UInt_FORMAT, blob_tag);
|
||||
return FALSE;
|
||||
}
|
||||
blob_info = blob_tag - USER_BLOB_START;
|
||||
blob_info = blob_tag;
|
||||
if (!GLOBAL_OpaqueHandlers)
|
||||
return NULL;
|
||||
return GLOBAL_OpaqueHandlers[blob_info].gc_relocate_handler;
|
||||
return GLOBAL_OpaqueHandlers[blob_info].relocate_handler;
|
||||
}
|
||||
|
||||
extern Int Yap_blob_tag(Term t)
|
||||
{
|
||||
extern Int Yap_blob_tag(Term t) {
|
||||
CELL *pt = RepAppl(t);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -278,9 +267,7 @@ extern Int Yap_blob_tag(Term t)
|
|||
return pt[1];
|
||||
}
|
||||
|
||||
void *
|
||||
Yap_blob_info(Term t)
|
||||
{
|
||||
void *Yap_blob_info(Term t) {
|
||||
MP_INT *blobp;
|
||||
CELL *pt = RepAppl(t);
|
||||
|
||||
|
@ -293,88 +280,83 @@ Yap_blob_info(Term t)
|
|||
#endif
|
||||
if (!GLOBAL_OpaqueHandlers)
|
||||
return FALSE;
|
||||
blobp = (MP_INT *)(pt+2);
|
||||
return (void *)(blobp+1);
|
||||
blobp = (MP_INT *)(pt + 2);
|
||||
return (void *)(blobp + 1);
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_MkULLIntTerm(YAP_ULONG_LONG n)
|
||||
{
|
||||
Term Yap_MkULLIntTerm(YAP_ULONG_LONG n) {
|
||||
#if __GNUC__ && USE_GMP
|
||||
mpz_t new;
|
||||
char tmp[256];
|
||||
Term t;
|
||||
mpz_t new;
|
||||
char tmp[256];
|
||||
Term t;
|
||||
|
||||
#ifdef _WIN32
|
||||
snprintf(tmp,256,"%I64u",n);
|
||||
snprintf(tmp, 256, "%I64u", n);
|
||||
#elif HAVE_SNPRINTF
|
||||
snprintf(tmp,256,"%llu",n);
|
||||
snprintf(tmp, 256, "%llu", n);
|
||||
#else
|
||||
sprintf(tmp,"%llu",n);
|
||||
sprintf(tmp, "%llu", n);
|
||||
#endif
|
||||
/* try to scan it as a bignum */
|
||||
mpz_init_set_str (new, tmp, 10);
|
||||
if (mpz_fits_slong_p(new)) {
|
||||
CACHE_REGS
|
||||
return MkIntegerTerm(mpz_get_si(new));
|
||||
}
|
||||
t = Yap_MkBigIntTerm(new);
|
||||
mpz_clear(new);
|
||||
return t;
|
||||
#else
|
||||
/* try to scan it as a bignum */
|
||||
mpz_init_set_str(new, tmp, 10);
|
||||
if (mpz_fits_slong_p(new)) {
|
||||
CACHE_REGS
|
||||
return MkIntegerTerm(n);
|
||||
return MkIntegerTerm(mpz_get_si(new));
|
||||
}
|
||||
t = Yap_MkBigIntTerm(new);
|
||||
mpz_clear(new);
|
||||
return t;
|
||||
#else
|
||||
CACHE_REGS
|
||||
return MkIntegerTerm(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
CELL *
|
||||
Yap_HeapStoreOpaqueTerm(Term t)
|
||||
{
|
||||
CELL *Yap_HeapStoreOpaqueTerm(Term t) {
|
||||
CELL *ptr = RepAppl(t);
|
||||
size_t sz;
|
||||
void *new;
|
||||
|
||||
if (ptr[0] == (CELL)FunctorBigInt) {
|
||||
sz = sizeof(MP_INT)+2*CellSize+
|
||||
((MP_INT *)(ptr+2))->_mp_alloc*sizeof(mp_limb_t);
|
||||
sz = sizeof(MP_INT) + 2 * CellSize +
|
||||
((MP_INT *)(ptr + 2))->_mp_alloc * sizeof(mp_limb_t);
|
||||
} else { /* string */
|
||||
sz = sizeof(CELL)*(2+ptr[1]);
|
||||
sz = sizeof(CELL) * (2 + ptr[1]);
|
||||
}
|
||||
new = Yap_AllocCodeSpace(sz);
|
||||
if (!new) {
|
||||
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "subgoal_search_loop: no space for %s", StringOfTerm(t) );
|
||||
Yap_Error(RESOURCE_ERROR_HEAP, TermNil,
|
||||
"subgoal_search_loop: no space for %s", StringOfTerm(t));
|
||||
} else {
|
||||
if (ptr[0] == (CELL)FunctorBigInt) {
|
||||
MP_INT *new = (MP_INT *)(RepAppl(t)+2);
|
||||
MP_INT *new = (MP_INT *)(RepAppl(t) + 2);
|
||||
|
||||
new->_mp_d = (mp_limb_t *)(new+1);
|
||||
new->_mp_d = (mp_limb_t *)(new + 1);
|
||||
}
|
||||
memmove(new, ptr, sz);
|
||||
}
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
Yap_OpaqueTermToString(Term t, char *str, size_t max)
|
||||
{
|
||||
size_t Yap_OpaqueTermToString(Term t, char *str, size_t max) {
|
||||
size_t str_index = 0;
|
||||
CELL * li = RepAppl(t);
|
||||
CELL *li = RepAppl(t);
|
||||
unsigned char *ptr = (unsigned char *)StringOfTerm(AbsAppl(li));
|
||||
if (li[0] == (CELL)FunctorString) {
|
||||
str_index += sprintf(& str[str_index], "\"");
|
||||
str_index += sprintf(&str[str_index], "\"");
|
||||
do {
|
||||
utf8proc_int32_t chr;
|
||||
ptr += get_utf8(ptr, &chr);
|
||||
if (chr == '\0') break;
|
||||
str_index += sprintf(str+str_index, "%C", chr);
|
||||
ptr += get_utf8(ptr, -1, &chr);
|
||||
if (chr == '\0')
|
||||
break;
|
||||
str_index += sprintf(str + str_index, "%C", chr);
|
||||
} while (TRUE);
|
||||
str_index += sprintf(str+str_index, "\"");
|
||||
str_index += sprintf(str + str_index, "\"");
|
||||
} else {
|
||||
CELL big_tag = li[1];
|
||||
|
||||
if (big_tag == ARRAY_INT || big_tag == ARRAY_FLOAT) {
|
||||
str_index += sprintf(& str[str_index], "{...}");
|
||||
str_index += sprintf(&str[str_index], "{...}");
|
||||
#ifdef USE_GMP
|
||||
} else if (big_tag == BIG_INT) {
|
||||
MP_INT *big = Yap_BigIntOfTerm(AbsAppl(li));
|
||||
|
@ -398,52 +380,35 @@ Yap_OpaqueTermToString(Term t, char *str, size_t max)
|
|||
return;
|
||||
}
|
||||
} */
|
||||
str_index += sprintf(& str[str_index], "0");
|
||||
str_index += sprintf(&str[str_index], "0");
|
||||
}
|
||||
return str_index;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_bignum( USES_REGS1 )
|
||||
{
|
||||
static Int p_is_bignum(USES_REGS1) {
|
||||
#ifdef USE_GMP
|
||||
Term t = Deref(ARG1);
|
||||
return(
|
||||
IsNonVarTerm(t) &&
|
||||
IsApplTerm(t) &&
|
||||
FunctorOfTerm(t) == FunctorBigInt &&
|
||||
RepAppl(t)[1] == BIG_INT
|
||||
);
|
||||
return (IsNonVarTerm(t) && IsApplTerm(t) &&
|
||||
FunctorOfTerm(t) == FunctorBigInt && RepAppl(t)[1] == BIG_INT);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_string( USES_REGS1 )
|
||||
{
|
||||
static Int p_is_string(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
return(
|
||||
IsNonVarTerm(t) &&
|
||||
IsApplTerm(t) &&
|
||||
FunctorOfTerm(t) == FunctorString
|
||||
);
|
||||
return (IsNonVarTerm(t) && IsApplTerm(t) &&
|
||||
FunctorOfTerm(t) == FunctorString);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_set_bit( USES_REGS1 )
|
||||
{
|
||||
static Int p_nb_set_bit(USES_REGS1) {
|
||||
#ifdef USE_GMP
|
||||
Term t = Deref(ARG1);
|
||||
Term ti = Deref(ARG2);
|
||||
Int i;
|
||||
|
||||
if (!(
|
||||
IsNonVarTerm(t) &&
|
||||
IsApplTerm(t) &&
|
||||
FunctorOfTerm(t) == FunctorBigInt &&
|
||||
RepAppl(t)[1] == BIG_INT
|
||||
))
|
||||
if (!(IsNonVarTerm(t) && IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt &&
|
||||
RepAppl(t)[1] == BIG_INT))
|
||||
return FALSE;
|
||||
if (!IsIntegerTerm(ti)) {
|
||||
return FALSE;
|
||||
|
@ -462,9 +427,7 @@ p_nb_set_bit( USES_REGS1 )
|
|||
#endif
|
||||
}
|
||||
|
||||
static Int
|
||||
p_has_bignums( USES_REGS1 )
|
||||
{
|
||||
static Int p_has_bignums(USES_REGS1) {
|
||||
#ifdef USE_GMP
|
||||
return TRUE;
|
||||
#else
|
||||
|
@ -472,9 +435,7 @@ p_has_bignums( USES_REGS1 )
|
|||
#endif
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_opaque( USES_REGS1 )
|
||||
{
|
||||
static Int p_is_opaque(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t))
|
||||
return FALSE;
|
||||
|
@ -485,14 +446,16 @@ p_is_opaque( USES_REGS1 )
|
|||
if (f != FunctorBigInt)
|
||||
return FALSE;
|
||||
pt = RepAppl(t);
|
||||
return ( pt[1] != BIG_RATIONAL || pt[1] != BIG_INT );
|
||||
return (pt[1] != BIG_RATIONAL || pt[1] != BIG_INT);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_rational( USES_REGS1 )
|
||||
{
|
||||
/** @pred rational( ?:T )
|
||||
|
||||
Checks whether _T_ is a rational number.
|
||||
*/
|
||||
static Int p_is_rational(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t))
|
||||
return FALSE;
|
||||
|
@ -507,14 +470,12 @@ p_is_rational( USES_REGS1 )
|
|||
if (f != FunctorBigInt)
|
||||
return FALSE;
|
||||
pt = RepAppl(t);
|
||||
return ( pt[1] == BIG_RATIONAL || pt[1] == BIG_INT );
|
||||
return (pt[1] == BIG_RATIONAL || pt[1] == BIG_INT);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_rational( USES_REGS1 )
|
||||
{
|
||||
static Int p_rational(USES_REGS1) {
|
||||
#ifdef USE_GMP
|
||||
Term t = Deref(ARG1);
|
||||
Functor f;
|
||||
|
@ -534,37 +495,25 @@ p_rational( USES_REGS1 )
|
|||
return FALSE;
|
||||
rat = Yap_BigRatOfTerm(t);
|
||||
while ((t1 = Yap_MkBigIntTerm(mpq_numref(rat))) == TermNil ||
|
||||
(t2 = Yap_MkBigIntTerm(mpq_denref(rat))) == TermNil) {
|
||||
UInt size =
|
||||
(mpq_numref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize) +
|
||||
(mpq_denref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize);
|
||||
(t2 = Yap_MkBigIntTerm(mpq_denref(rat))) == TermNil) {
|
||||
UInt size = (mpq_numref(rat)->_mp_alloc) * (sizeof(mp_limb_t) / CellSize) +
|
||||
(mpq_denref(rat)->_mp_alloc) * (sizeof(mp_limb_t) / CellSize);
|
||||
if (!Yap_gcl(size, 3, ENV, P)) {
|
||||
Yap_Error(RESOURCE_ERROR_STACK, t, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return
|
||||
Yap_unify(ARG2, t1) &&
|
||||
Yap_unify(ARG3, t2);
|
||||
return Yap_unify(ARG2, t1) && Yap_unify(ARG3, t2);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitBigNums(void)
|
||||
{
|
||||
void Yap_InitBigNums(void) {
|
||||
Yap_InitCPred("$has_bignums", 0, p_has_bignums, SafePredFlag);
|
||||
Yap_InitCPred("$bignum", 1, p_is_bignum, SafePredFlag);
|
||||
Yap_InitCPred("rational", 3, p_rational, 0);
|
||||
Yap_InitCPred("rational", 1, p_is_rational, SafePredFlag);
|
||||
/** @pred rational( _T_)
|
||||
|
||||
|
||||
Checks whether `T` is a rational number.
|
||||
|
||||
|
||||
*/
|
||||
Yap_InitCPred("string", 1, p_is_string, SafePredFlag);
|
||||
Yap_InitCPred("opaque", 1, p_is_opaque, SafePredFlag);
|
||||
Yap_InitCPred("nb_set_bit", 2, p_nb_set_bit, SafePredFlag);
|
||||
|
|
405
C/blobs.c
405
C/blobs.c
|
@ -9,106 +9,98 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "iopreds.h"
|
||||
#include "yapio.h"
|
||||
#include "yapio.h"
|
||||
|
||||
/* for freeBSD9.1 */
|
||||
#define _WITH_DPRINTF
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "fmemopen.h"
|
||||
#endif
|
||||
#include "YapBlobs.h"
|
||||
|
||||
#include "blobs.h"
|
||||
static blob_type_t unregistered_blob_atom = {
|
||||
YAP_BLOB_MAGIC_B, PL_BLOB_NOCOPY | PL_BLOB_TEXT, "unregistered"};
|
||||
|
||||
static blob_type_t unregistered_blob_atom =
|
||||
{ YAP_BLOB_MAGIC_B,
|
||||
PL_BLOB_NOCOPY|PL_BLOB_TEXT,
|
||||
"unregistered"
|
||||
};
|
||||
char *Yap_blob_to_string(AtomEntry *ref, const char *s0, size_t sz) {
|
||||
// int rc;
|
||||
char *s = (char *)s0;
|
||||
|
||||
char * Yap_blob_to_string(AtomEntry *ref, const char *s0, size_t sz)
|
||||
{
|
||||
int rc;
|
||||
char *s = (char *)s0;
|
||||
|
||||
blob_type_t *type = RepBlobProp(ref->PropsOfAE)->blob_type;
|
||||
if (type->write) {
|
||||
FILE *f = fmemopen( s, sz, "w");
|
||||
if (f == NULL){
|
||||
// could not find stream;
|
||||
return NULL;
|
||||
#if HAVE_FMEMOPEN
|
||||
blob_type_t *type = RepBlobProp(ref->PropsOfAE)->blob_type;
|
||||
if (type->write) {
|
||||
FILE *f = fmemopen(s, sz, "w");
|
||||
if (f == NULL) {
|
||||
// could not find stream;
|
||||
return NULL;
|
||||
}
|
||||
Atom at = AbsAtom(ref);
|
||||
rc = type->write(f, at, 0);
|
||||
if (rc < 0) {
|
||||
Yap_Error( EVALUATION_ERROR_UNDEFINED, MkAtomTerm(at), "failure in user-defined blob to string code" );
|
||||
}
|
||||
fclose(f); // return the final result.
|
||||
int rc = type->write(f, at, 0);
|
||||
if (rc < 0) {
|
||||
Yap_Error(EVALUATION_ERROR_UNDEFINED, MkAtomTerm(at),
|
||||
"failure in user-defined blob to string code");
|
||||
}
|
||||
fclose(f); // return the final result.
|
||||
return s;
|
||||
} else {
|
||||
} else {
|
||||
#endif
|
||||
#if __APPLE__
|
||||
size_t sz0 = strlcpy( s, (char *)RepAtom( AtomSWIStream )->StrOfAE, sz);
|
||||
size_t sz0 = strlcpy(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz);
|
||||
#else
|
||||
size_t sz0;
|
||||
char *f = (char *)memcpy(s, (char *)RepAtom( AtomSWIStream )->StrOfAE, sz);
|
||||
f[0]='\0';
|
||||
sz0 = f-s;
|
||||
size_t sz0;
|
||||
char *f = (char *)memmove(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz);
|
||||
f[0] = '\0';
|
||||
sz0 = f - s;
|
||||
#endif
|
||||
s = s+sz0;
|
||||
sz -= sz0;
|
||||
s = s + sz0;
|
||||
sz -= sz0;
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
snprintf(s+strlen(s), sz0, "(%p)", ref);
|
||||
snprintf(s + strlen(s), sz0, "(%p)", ref);
|
||||
#else
|
||||
snprintf(s+strlen(s), sz0, "(0x%p)", ref);
|
||||
snprintf(s + strlen(s), sz0, "(0x%p)", ref);
|
||||
#endif
|
||||
return s;
|
||||
#if HAVE_FMEMOPEN
|
||||
}
|
||||
return NULL;
|
||||
#endif
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int Yap_write_blob(AtomEntry *ref, FILE *stream)
|
||||
{
|
||||
blob_type_t *type = RepBlobProp(ref->PropsOfAE)->blob_type;
|
||||
|
||||
if (type->write) {
|
||||
|
||||
Atom at = AbsAtom(ref);
|
||||
return type->write(stream, at, 0);
|
||||
} else {
|
||||
int Yap_write_blob(AtomEntry *ref, FILE *stream) {
|
||||
blob_type_t *type = RepBlobProp(ref->PropsOfAE)->blob_type;
|
||||
|
||||
if (type->write) {
|
||||
|
||||
Atom at = AbsAtom(ref);
|
||||
return type->write(stream, at, 0);
|
||||
} else {
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
return fprintf(stream, "\'%s\'(%p)", RepAtom(AtomSWIStream)->StrOfAE, ref);
|
||||
return fprintf(stream, "\'%s\'(%p)", RepAtom(AtomSWIStream)->StrOfAE, ref);
|
||||
#else
|
||||
return fprintf(stream, "\'%s\'(0x%p)", RepAtom(AtomSWIStream)->StrOfAE, ref);
|
||||
return fprintf(stream, "\'%s\'(0x%p)", RepAtom(AtomSWIStream)->StrOfAE,
|
||||
ref);
|
||||
#endif
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
YAP_is_blob(Term t, blob_type_t **type)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term yt = Yap_GetFromSlot(t);
|
||||
Atom a;
|
||||
YAP_BlobPropEntry *b;
|
||||
|
||||
if (IsVarTerm(yt))
|
||||
return FALSE;
|
||||
if (!IsAtomTerm(yt))
|
||||
return FALSE;
|
||||
a = AtomOfTerm(yt);
|
||||
if (!IsBlob(a))
|
||||
return FALSE;
|
||||
b = RepBlobProp(a->PropsOfAE);
|
||||
*type = b->blob_type;
|
||||
return TRUE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool YAP_is_blob(Term t, blob_type_t **type) {
|
||||
CACHE_REGS
|
||||
Term yt = Yap_GetFromSlot(t);
|
||||
Atom a;
|
||||
YAP_BlobPropEntry *b;
|
||||
|
||||
if (IsVarTerm(yt))
|
||||
return FALSE;
|
||||
if (!IsAtomTerm(yt))
|
||||
return FALSE;
|
||||
a = AtomOfTerm(yt);
|
||||
if (!IsBlob(a))
|
||||
return FALSE;
|
||||
b = RepBlobProp(a->PropsOfAE);
|
||||
*type = b->blob_type;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* void check_chain(void); */
|
||||
|
||||
|
@ -122,161 +114,134 @@ YAP_is_blob(Term t, blob_type_t **type)
|
|||
/* } */
|
||||
/* } */
|
||||
|
||||
AtomEntry *
|
||||
Yap_lookupBlob(void *blob, size_t len, void *type0, int *new)
|
||||
{
|
||||
YAP_BlobPropEntry *b;
|
||||
AtomEntry *ae;
|
||||
blob_type_t *type = type0;
|
||||
if (new)
|
||||
*new = FALSE;
|
||||
|
||||
LOCK(Blobs_Lock);
|
||||
if (type->flags & PL_BLOB_UNIQUE) {
|
||||
/* just keep a linked chain for now */
|
||||
ae = Blobs;
|
||||
while (ae) {
|
||||
if (ae->PropsOfAE &&
|
||||
RepBlobProp(ae->PropsOfAE)->blob_type == type &&
|
||||
ae->rep.blob->length == len &&
|
||||
!memcmp(ae->rep.blob->data, blob, len)) {
|
||||
UNLOCK(Blobs_Lock);
|
||||
return ae;
|
||||
}
|
||||
ae = RepAtom(ae->NextOfAE);
|
||||
}
|
||||
}
|
||||
if (new)
|
||||
*new = TRUE;
|
||||
b = (YAP_BlobPropEntry *)Yap_AllocCodeSpace(sizeof(YAP_BlobPropEntry));
|
||||
if (!b) {
|
||||
AtomEntry *Yap_lookupBlob(void *blob, size_t len, void *type0, int *new) {
|
||||
YAP_BlobPropEntry *b;
|
||||
AtomEntry *ae;
|
||||
blob_type_t *type = type0;
|
||||
if (new)
|
||||
*new = FALSE;
|
||||
|
||||
LOCK(Blobs_Lock);
|
||||
if (type->flags & PL_BLOB_UNIQUE) {
|
||||
/* just keep a linked chain for now */
|
||||
ae = Blobs;
|
||||
while (ae) {
|
||||
if (ae->PropsOfAE && RepBlobProp(ae->PropsOfAE)->blob_type == type &&
|
||||
ae->rep.blob->length == len &&
|
||||
!memcmp(ae->rep.blob->data, blob, len)) {
|
||||
UNLOCK(Blobs_Lock);
|
||||
return NULL;
|
||||
}
|
||||
b->NextOfPE = NIL;
|
||||
b->KindOfPE = BlobProperty;
|
||||
b->blob_type = type;
|
||||
ae = (AtomEntry *)Yap_AllocCodeSpace(sizeof(AtomEntry)+len+sizeof(size_t));
|
||||
if (!ae) {
|
||||
UNLOCK(Blobs_Lock);
|
||||
return NULL;
|
||||
}
|
||||
NOfBlobs++;
|
||||
INIT_RWLOCK(ae->ARWLock);
|
||||
ae->PropsOfAE = AbsBlobProp(b);
|
||||
ae->NextOfAE = AbsAtom(Blobs);
|
||||
ae->rep.blob->length = len;
|
||||
memcpy(ae->rep.blob->data, blob, len);
|
||||
Blobs = ae;
|
||||
if (NOfBlobs > NOfBlobsMax) {
|
||||
Yap_signal(YAP_CDOVF_SIGNAL);
|
||||
return ae;
|
||||
}
|
||||
ae = RepAtom(ae->NextOfAE);
|
||||
}
|
||||
}
|
||||
if (new)
|
||||
*new = TRUE;
|
||||
b = (YAP_BlobPropEntry *)Yap_AllocCodeSpace(sizeof(YAP_BlobPropEntry));
|
||||
if (!b) {
|
||||
UNLOCK(Blobs_Lock);
|
||||
return ae;
|
||||
return NULL;
|
||||
}
|
||||
b->NextOfPE = NIL;
|
||||
b->KindOfPE = BlobProperty;
|
||||
b->blob_type = type;
|
||||
ae =
|
||||
(AtomEntry *)Yap_AllocCodeSpace(sizeof(AtomEntry) + len + sizeof(size_t));
|
||||
if (!ae) {
|
||||
UNLOCK(Blobs_Lock);
|
||||
return NULL;
|
||||
}
|
||||
NOfBlobs++;
|
||||
INIT_RWLOCK(ae->ARWLock);
|
||||
ae->PropsOfAE = AbsBlobProp(b);
|
||||
ae->NextOfAE = AbsAtom(Blobs);
|
||||
ae->rep.blob->length = len;
|
||||
memmove(ae->rep.blob->data, blob, len);
|
||||
Blobs = ae;
|
||||
if (NOfBlobs > NOfBlobsMax) {
|
||||
Yap_signal(YAP_CDOVF_SIGNAL);
|
||||
}
|
||||
UNLOCK(Blobs_Lock);
|
||||
return ae;
|
||||
}
|
||||
|
||||
bool
|
||||
YAP_unify_blob(Term *t, void *blob, size_t len, blob_type_t *type)
|
||||
{
|
||||
AtomEntry *ae;
|
||||
|
||||
if (!blob)
|
||||
return FALSE;
|
||||
ae = Yap_lookupBlob(blob, len, type, NULL);
|
||||
if (!ae) {
|
||||
return FALSE;
|
||||
}
|
||||
if (type->acquire) {
|
||||
type->acquire(AbsAtom(ae));
|
||||
}
|
||||
*t = MkAtomTerm(AbsAtom(ae));
|
||||
return true;
|
||||
}
|
||||
bool YAP_unify_blob(Term *t, void *blob, size_t len, blob_type_t *type) {
|
||||
AtomEntry *ae;
|
||||
|
||||
bool
|
||||
YAP_get_blob(Term t, void **blob, size_t *len, blob_type_t **type)
|
||||
{
|
||||
CACHE_REGS
|
||||
Atom a;
|
||||
Term tt;
|
||||
AtomEntry *ae;
|
||||
|
||||
tt = Yap_GetFromSlot(t);
|
||||
if (IsVarTerm(tt))
|
||||
return FALSE;
|
||||
if (!IsAtomTerm(tt))
|
||||
return FALSE;
|
||||
a = AtomOfTerm(tt);
|
||||
if (!IsBlob(a))
|
||||
return FALSE;
|
||||
ae = RepAtom(a);
|
||||
if (type)
|
||||
*type = RepBlobProp(ae->PropsOfAE)->blob_type;
|
||||
if (len)
|
||||
*len = ae->rep.blob[0].length;
|
||||
if (blob)
|
||||
*blob = ae->rep.blob[0].data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void *
|
||||
YAP_blob_data(Atom x, size_t *len, blob_type_t **type)
|
||||
{
|
||||
|
||||
if (!IsBlob(x)) {
|
||||
if (IsWideAtom(x)) {
|
||||
if ( len )
|
||||
*len = wcslen(x->WStrOfAE);
|
||||
if ( type )
|
||||
|
||||
|
||||
|
||||
*type = &unregistered_blob_atom;
|
||||
return x->WStrOfAE;
|
||||
}
|
||||
if ( len )
|
||||
*len = strlen((char *)x->StrOfAE);
|
||||
if ( type )
|
||||
*type = &unregistered_blob_atom;
|
||||
return x->StrOfAE;
|
||||
}
|
||||
if ( len )
|
||||
*len = x->rep.blob[0].length;
|
||||
if ( type )
|
||||
*type = RepBlobProp(x->PropsOfAE)->blob_type;
|
||||
return x->rep.blob[0].data;
|
||||
}
|
||||
|
||||
void
|
||||
YAP_register_blob_type(blob_type_t *type)
|
||||
{
|
||||
type->next = (void *)BlobTypes;
|
||||
BlobTypes = (void*)type;
|
||||
}
|
||||
|
||||
blob_type_t*
|
||||
YAP_find_blob_type(const char* name)
|
||||
{
|
||||
AtomEntry *a = RepAtom(Yap_LookupAtom(name));
|
||||
if (!IsBlob(a)) {
|
||||
return &unregistered_blob_atom;
|
||||
}
|
||||
return RepBlobProp(a->PropsOfAE)->blob_type;
|
||||
}
|
||||
|
||||
bool
|
||||
YAP_unregister_blob_type(blob_type_t *type)
|
||||
{
|
||||
fprintf(stderr,"YAP_unregister_blob_type not implemented yet\n");
|
||||
if (!blob)
|
||||
return FALSE;
|
||||
ae = Yap_lookupBlob(blob, len, type, NULL);
|
||||
if (!ae) {
|
||||
return FALSE;
|
||||
}
|
||||
if (type->acquire) {
|
||||
type->acquire(AbsAtom(ae));
|
||||
}
|
||||
*t = MkAtomTerm(AbsAtom(ae));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Yap_install_blobs(void)
|
||||
{
|
||||
|
||||
bool YAP_get_blob(Term t, void **blob, size_t *len, blob_type_t **type) {
|
||||
CACHE_REGS
|
||||
Atom a;
|
||||
Term tt;
|
||||
AtomEntry *ae;
|
||||
|
||||
tt = Yap_GetFromSlot(t);
|
||||
if (IsVarTerm(tt))
|
||||
return FALSE;
|
||||
if (!IsAtomTerm(tt))
|
||||
return FALSE;
|
||||
a = AtomOfTerm(tt);
|
||||
if (!IsBlob(a))
|
||||
return FALSE;
|
||||
ae = RepAtom(a);
|
||||
if (type)
|
||||
*type = RepBlobProp(ae->PropsOfAE)->blob_type;
|
||||
if (len)
|
||||
*len = ae->rep.blob[0].length;
|
||||
if (blob)
|
||||
*blob = ae->rep.blob[0].data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void *YAP_blob_data(YAP_Atom at, size_t *len, blob_type_t **type) {
|
||||
Atom x = at;
|
||||
if (!IsBlob(x)) {
|
||||
|
||||
if (len)
|
||||
*len = strlen_utf8(x->UStrOfAE);
|
||||
if (type)
|
||||
*type = &unregistered_blob_atom;
|
||||
return x->StrOfAE;
|
||||
}
|
||||
if (len)
|
||||
*len = x->rep.blob[0].length;
|
||||
if (type)
|
||||
*type = RepBlobProp(x->PropsOfAE)->blob_type;
|
||||
return x->rep.blob[0].data;
|
||||
}
|
||||
|
||||
void YAP_register_blob_type(blob_type_t *type) {
|
||||
type->next = (void *)BlobTypes;
|
||||
BlobTypes = (void *)type;
|
||||
}
|
||||
|
||||
blob_type_t *YAP_find_blob_type(const char *name) {
|
||||
AtomEntry *a = RepAtom(Yap_LookupAtom(name));
|
||||
if (!IsBlob(a)) {
|
||||
return &unregistered_blob_atom;
|
||||
}
|
||||
return RepBlobProp(a->PropsOfAE)->blob_type;
|
||||
}
|
||||
|
||||
bool YAP_unregister_blob_type(blob_type_t *type) {
|
||||
fprintf(stderr, "YAP_unregister_blob_type not implemented yet\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Yap_install_blobs(void) {}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
1805
C/c_interface.c
1805
C/c_interface.c
File diff suppressed because it is too large
Load Diff
|
@ -3,49 +3,42 @@
|
|||
#include "tracer.h"
|
||||
#ifdef YAPOR
|
||||
#include "or.macros.h"
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
#include "clause_list.h"
|
||||
|
||||
/* need to fix overflow handling */
|
||||
|
||||
static void
|
||||
mk_blob(int sz USES_REGS)
|
||||
{
|
||||
static void mk_blob(int sz USES_REGS) {
|
||||
MP_INT *dst;
|
||||
|
||||
|
||||
HR[0] = (CELL)FunctorBigInt;
|
||||
HR[1] = CLAUSE_LIST;
|
||||
dst = (MP_INT *)(HR+2);
|
||||
dst = (MP_INT *)(HR + 2);
|
||||
dst->_mp_size = 0L;
|
||||
dst->_mp_alloc = sz;
|
||||
HR += (1+sizeof(MP_INT)/sizeof(CELL));
|
||||
HR += (1 + sizeof(MP_INT) / sizeof(CELL));
|
||||
HR[sz] = EndSpecials;
|
||||
HR += sz+1;
|
||||
HR += sz + 1;
|
||||
}
|
||||
|
||||
static CELL *
|
||||
extend_blob(CELL *start, int sz USES_REGS)
|
||||
{
|
||||
static CELL *extend_blob(CELL *start, int sz USES_REGS) {
|
||||
UInt osize;
|
||||
MP_INT *dst;
|
||||
|
||||
|
||||
if (HR + sz > ASP)
|
||||
return NULL;
|
||||
dst = (MP_INT *)(start+2);
|
||||
dst = (MP_INT *)(start + 2);
|
||||
osize = dst->_mp_alloc;
|
||||
start += (1+sizeof(MP_INT)/sizeof(CELL));
|
||||
start[sz+osize] = EndSpecials;
|
||||
start += (1 + sizeof(MP_INT) / sizeof(CELL));
|
||||
start[sz + osize] = EndSpecials;
|
||||
dst->_mp_alloc += sz;
|
||||
HR += sz;
|
||||
return start+osize;
|
||||
return start + osize;
|
||||
}
|
||||
|
||||
/*init of ClasuseList*/
|
||||
X_API clause_list_t
|
||||
Yap_ClauseListInit(clause_list_t in)
|
||||
{
|
||||
CACHE_REGS
|
||||
in->n = 0;
|
||||
clause_list_t Yap_ClauseListInit(clause_list_t in) {
|
||||
CACHE_REGS in->n = 0;
|
||||
in->start = HR;
|
||||
mk_blob(0 PASS_REGS);
|
||||
in->end = HR;
|
||||
|
@ -54,9 +47,7 @@ Yap_ClauseListInit(clause_list_t in)
|
|||
|
||||
/*add clause to ClauseList
|
||||
returns FALSE on error*/
|
||||
X_API int
|
||||
Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
||||
{
|
||||
int Yap_ClauseListExtend(clause_list_t cl, void *clause, void *pred) {
|
||||
CACHE_REGS
|
||||
PredEntry *ap = (PredEntry *)pred;
|
||||
|
||||
|
@ -65,15 +56,19 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||
return FALSE;
|
||||
if (cl->n == 0) {
|
||||
void **ptr;
|
||||
if (!(ptr = (void **)extend_blob(cl->start,1 PASS_REGS))) return FALSE;
|
||||
if (!(ptr = (void **)extend_blob(cl->start, 1 PASS_REGS)))
|
||||
return FALSE;
|
||||
ptr[0] = clause;
|
||||
} else if (cl->n == 1) {
|
||||
} else if (cl->n == 1) {
|
||||
yamop **ptr;
|
||||
yamop *code_p, *fclause;
|
||||
|
||||
if (!(ptr = (yamop **)extend_blob(cl->start,2*(CELL)NEXTOP((yamop *)NULL,Otapl)/sizeof(CELL)-1 PASS_REGS))) return FALSE;
|
||||
|
||||
if (!(ptr = (yamop **)extend_blob(
|
||||
cl->start, 2 * (CELL)NEXTOP((yamop *)NULL, Otapl) / sizeof(CELL) -
|
||||
1 PASS_REGS)))
|
||||
return FALSE;
|
||||
fclause = ptr[-1];
|
||||
code_p = (yamop *)(ptr-1);
|
||||
code_p = (yamop *)(ptr - 1);
|
||||
code_p->opc = Yap_opcode(_try_clause);
|
||||
code_p->y_u.Otapl.d = fclause;
|
||||
code_p->y_u.Otapl.s = ap->ArityOfPE;
|
||||
|
@ -84,7 +79,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(code_p, 0);
|
||||
#endif /* YAPOR */
|
||||
code_p = NEXTOP(code_p,Otapl);
|
||||
code_p = NEXTOP(code_p, Otapl);
|
||||
code_p->opc = Yap_opcode(_trust);
|
||||
code_p->y_u.Otapl.d = clause;
|
||||
code_p->y_u.Otapl.s = ap->ArityOfPE;
|
||||
|
@ -98,7 +93,10 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||
} else {
|
||||
yamop *code_p;
|
||||
|
||||
if (!(code_p = (yamop *)extend_blob(cl->start,((CELL)NEXTOP((yamop *)NULL,Otapl))/sizeof(CELL) PASS_REGS))) return FALSE;
|
||||
if (!(code_p = (yamop *)extend_blob(cl->start,
|
||||
((CELL)NEXTOP((yamop *)NULL, Otapl)) /
|
||||
sizeof(CELL) PASS_REGS)))
|
||||
return FALSE;
|
||||
code_p->opc = Yap_opcode(_trust);
|
||||
code_p->y_u.Otapl.d = clause;
|
||||
code_p->y_u.Otapl.s = ap->ArityOfPE;
|
||||
|
@ -109,7 +107,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(code_p, 0);
|
||||
#endif /* YAPOR */
|
||||
code_p = PREVOP(code_p,Otapl);
|
||||
code_p = PREVOP(code_p, Otapl);
|
||||
code_p->opc = Yap_opcode(_retry);
|
||||
}
|
||||
cl->end = HR;
|
||||
|
@ -118,16 +116,11 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||
}
|
||||
|
||||
/*closes the clause list*/
|
||||
X_API void
|
||||
Yap_ClauseListClose(clause_list_t cl)
|
||||
{
|
||||
/* no need to do nothing */
|
||||
void Yap_ClauseListClose(clause_list_t cl) { /* no need to do nothing */
|
||||
}
|
||||
|
||||
/*destroys the clause list freeing memory*/
|
||||
X_API int
|
||||
Yap_ClauseListDestroy(clause_list_t cl)
|
||||
{
|
||||
int Yap_ClauseListDestroy(clause_list_t cl) {
|
||||
CACHE_REGS
|
||||
if (cl->end != HR)
|
||||
return FALSE;
|
||||
|
@ -136,34 +129,25 @@ Yap_ClauseListDestroy(clause_list_t cl)
|
|||
}
|
||||
|
||||
/*destroys clause list and returns only first clause*/
|
||||
X_API void *
|
||||
Yap_ClauseListToClause(clause_list_t cl)
|
||||
{
|
||||
void *Yap_ClauseListToClause(clause_list_t cl) {
|
||||
CACHE_REGS
|
||||
void **ptr;
|
||||
if (cl->end != HR)
|
||||
return NULL;
|
||||
if (cl->n != 1)
|
||||
return NULL;
|
||||
if (!(ptr = (void **)extend_blob(cl->start,0 PASS_REGS))) return NULL;
|
||||
if (!(ptr = (void **)extend_blob(cl->start, 0 PASS_REGS)))
|
||||
return NULL;
|
||||
return ptr[-1];
|
||||
}
|
||||
|
||||
/*return pointer to start of try-retry-trust sequence*/
|
||||
X_API void *
|
||||
Yap_ClauseListCode(clause_list_t cl)
|
||||
{
|
||||
void *Yap_ClauseListCode(clause_list_t cl) {
|
||||
CELL *ptr;
|
||||
ptr = (CELL *)cl->start;
|
||||
ptr += (1+sizeof(MP_INT)/sizeof(CELL));
|
||||
ptr += (1 + sizeof(MP_INT) / sizeof(CELL));
|
||||
return (void *)ptr;
|
||||
}
|
||||
|
||||
/* where to fail */
|
||||
X_API void *
|
||||
Yap_FAILCODE(void)
|
||||
{
|
||||
return (void *)FAILCODE;
|
||||
}
|
||||
|
||||
|
||||
void *Yap_FAILCODE(void) { return (void *)FAILCODE; }
|
||||
|
|
905
C/cmppreds.c
905
C/cmppreds.c
File diff suppressed because it is too large
Load Diff
2887
C/compiler.c
2887
C/compiler.c
File diff suppressed because it is too large
Load Diff
|
@ -54,22 +54,24 @@ static char SccsId[] = "%W% %G%";
|
|||
|
||||
/*
|
||||
* This file includes a set of utilities, useful to the several compilation
|
||||
* modules
|
||||
* modules
|
||||
*/
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "compile.h"
|
||||
#define COMPILER_NAMES 1
|
||||
#include "YapCompile.h"
|
||||
#undef COMPILER_NAMES
|
||||
#include "YapCompile.h"
|
||||
#include "yapio.h"
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The compiler creates an instruction chain which will be assembled after
|
||||
* afterwards
|
||||
* afterwards
|
||||
*/
|
||||
|
||||
|
||||
|
@ -146,7 +148,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
|||
LOCAL_Error_Size = 256+((char *)cip->freep - (char *)HR);
|
||||
save_machine_regs();
|
||||
siglongjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
|
||||
}
|
||||
}
|
||||
p = cip->freep;
|
||||
cip->freep += size;
|
||||
return p;
|
||||
|
@ -216,7 +218,7 @@ is_a_test(Term arg, Term mod)
|
|||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return pe->PredFlags & (TestPredFlag|BinaryPredFlag);
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +317,7 @@ Yap_emit_6ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3, CELL r4, CELL r5, CE
|
|||
p->rnd1 = r1;
|
||||
p->rnd2 = r2;
|
||||
p->rnd3 = r3;
|
||||
p->rnd4 = r4;
|
||||
p->rnd4 = r4;
|
||||
p->rnd5 = r5;
|
||||
p->rnd6 = r6;
|
||||
p->nextInst = NIL;
|
||||
|
@ -337,7 +339,7 @@ Yap_emit_7ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3, CELL r4, CELL r5, CE
|
|||
p->rnd1 = r1;
|
||||
p->rnd2 = r2;
|
||||
p->rnd3 = r3;
|
||||
p->rnd4 = r4;
|
||||
p->rnd4 = r4;
|
||||
p->rnd5 = r5;
|
||||
p->rnd6 = r6;
|
||||
p->rnd7 = r7;
|
||||
|
@ -520,7 +522,7 @@ write_special_label(special_label_op arg, special_label_id rn, UInt lab)
|
|||
Yap_DebugErrorPuts("fail");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -545,7 +547,6 @@ write_functor(Functor f)
|
|||
}
|
||||
}
|
||||
|
||||
char *opDesc[] = { mklist(f_arr) };
|
||||
|
||||
static void send_pred(PredEntry *p)
|
||||
{
|
||||
|
@ -616,7 +617,7 @@ ShowOp (compiler_vm_op ic, const char *f, struct PSEUDO *cpc)
|
|||
Yap_DebugPlWrite(MkIntegerTerm((Int)(*ptr++)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'l':
|
||||
write_address (arg);
|
||||
break;
|
||||
|
@ -645,7 +646,7 @@ ShowOp (compiler_vm_op ic, const char *f, struct PSEUDO *cpc)
|
|||
Yap_DebugPlWrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs));
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'N':
|
||||
{
|
||||
Ventry *v;
|
||||
|
@ -720,7 +721,7 @@ ShowOp (compiler_vm_op ic, const char *f, struct PSEUDO *cpc)
|
|||
Yap_DebugPlWrite (MkIntTerm (rn & 1));
|
||||
break;
|
||||
case 'w':
|
||||
Yap_DebugPlWrite (arg);
|
||||
Yap_DebugPlWrite (MkIntTerm(arg));
|
||||
break;
|
||||
case 'o':
|
||||
Yap_DebugPlWrite ((Term) * cptr++);
|
||||
|
@ -795,4 +796,3 @@ Yap_ShowCode (struct intermediates *cint)
|
|||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/************************************************************************\
|
||||
* Cut & Commit Instructions *
|
||||
* Cut & Commit Inst
|
||||
|
||||
ructions *
|
||||
\************************************************************************/
|
||||
|
||||
#ifdef INDENT_CODE
|
||||
|
@ -12,7 +14,7 @@
|
|||
Op(cut, s);
|
||||
#ifdef COROUTINING
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
check_stack(NoStackCut, HR);
|
||||
check_stack(NoStackCut, HR);
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
do_cut:
|
||||
#endif
|
||||
|
@ -194,18 +196,18 @@
|
|||
/* Macros for stack trimming */
|
||||
|
||||
/* execute Label */
|
||||
BOp(execute, pp);
|
||||
BOp(execute, Osbpp);
|
||||
{
|
||||
PredEntry *pt0;
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
pt0 = PREG->y_u.pp.p;
|
||||
pt0 = PREG->y_u.Osbpp.p;
|
||||
#ifndef NO_CHECKING
|
||||
check_stack(NoStackExecute, HR);
|
||||
goto skip_do_execute;
|
||||
#endif
|
||||
do_execute:
|
||||
FETCH_Y_FROM_ENV(YREG);
|
||||
pt0 = PREG->y_u.pp.p;
|
||||
pt0 = PREG->y_u.Osbpp.p;
|
||||
skip_do_execute:
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace) {
|
||||
|
@ -244,17 +246,17 @@
|
|||
|
||||
/* dexecute Label */
|
||||
/* joint deallocate and execute */
|
||||
BOp(dexecute, pp);
|
||||
BOp(dexecute, Osbpp);
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace)
|
||||
low_level_trace(enter_pred,PREG->y_u.pp.p,XREGS+1);
|
||||
low_level_trace(enter_pred,PREG->y_u.Osbpp.p,XREGS+1);
|
||||
#endif /* LOW_LEVEL_TRACER */
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
{
|
||||
PredEntry *pt0;
|
||||
|
||||
CACHE_A1();
|
||||
pt0 = PREG->y_u.pp.p;
|
||||
pt0 = PREG->y_u.Osbpp.p;
|
||||
#ifndef NO_CHECKING
|
||||
/* check stacks */
|
||||
check_stack(NoStackDExecute, HR);
|
||||
|
@ -262,7 +264,7 @@
|
|||
#endif
|
||||
continue_dexecute:
|
||||
FETCH_Y_FROM_ENV(YREG);
|
||||
pt0 = PREG->y_u.pp.p;
|
||||
pt0 = PREG->y_u.Osbpp.p;
|
||||
skip_dexecute:
|
||||
#ifdef DEPTH_LIMIT
|
||||
if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is primitives */
|
||||
|
@ -425,6 +427,8 @@
|
|||
|
||||
Op(deallocate, p);
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
// do this before checking
|
||||
SREG = YREG;
|
||||
check_trail(TR);
|
||||
#ifndef NO_CHECKING
|
||||
/* check stacks */
|
||||
|
@ -433,7 +437,6 @@
|
|||
PREG = NEXTOP(PREG, p);
|
||||
/* other instructions do depend on S being set by deallocate
|
||||
:-( */
|
||||
SREG = YREG;
|
||||
CPREG = (yamop *) ENV_YREG[E_CP];
|
||||
ENV = ENV_YREG = (CELL *) ENV_YREG[E_E];
|
||||
#ifdef DEPTH_LIMIT
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(PREG, Otapl);
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
|
@ -42,7 +42,7 @@
|
|||
restore_yaam_regs(PREG->y_u.Otapl.d);
|
||||
restore_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -58,25 +58,24 @@
|
|||
CACHE_Y(B);
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
PREG = NEXTOP(PREG, Otapl);
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
|
@ -89,14 +88,14 @@
|
|||
/* enter_exo Pred,Label */
|
||||
BOp(enter_exo, e);
|
||||
{
|
||||
yamop *pt;
|
||||
saveregs();
|
||||
pt = Yap_ExoLookup(PredFromDefCode(PREG) PASS_REGS);
|
||||
setregs();
|
||||
yamop *pt;
|
||||
saveregs();
|
||||
pt = Yap_ExoLookup(PredFromDefCode(PREG) PASS_REGS);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = S;
|
||||
SREG = S;
|
||||
#endif
|
||||
PREG = pt;
|
||||
PREG = pt;
|
||||
}
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
|
@ -111,14 +110,15 @@
|
|||
* new register to point at YREG =*/
|
||||
CACHE_Y(YREG);
|
||||
{
|
||||
struct index_t *i = (struct index_t *)(PREG->y_u.lp.l);
|
||||
S_YREG[-1] = (CELL)LINK_TO_ADDRESS(i,i->links[EXO_ADDRESS_TO_OFFSET(i, SREG)]);
|
||||
struct index_t *i = (struct index_t *)(PREG->y_u.lp.l);
|
||||
S_YREG[-1] =
|
||||
(CELL)LINK_TO_ADDRESS(i, i->links[EXO_ADDRESS_TO_OFFSET(i, SREG)]);
|
||||
}
|
||||
S_YREG--;
|
||||
/* store arguments for procedure */
|
||||
store_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* store abstract machine registers */
|
||||
store_yaam_regs(NEXTOP(PREG,lp), 0);
|
||||
store_yaam_regs(NEXTOP(PREG, lp), 0);
|
||||
/* On a try_me, set cut to point at previous choicepoint,
|
||||
* that is, to the B before the cut.
|
||||
*/
|
||||
|
@ -127,8 +127,8 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp),lp);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp), lp);
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
GONext();
|
||||
|
@ -147,7 +147,7 @@
|
|||
/* store arguments for procedure */
|
||||
store_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* store abstract machine registers */
|
||||
store_yaam_regs(NEXTOP(PREG,lp), 0);
|
||||
store_yaam_regs(NEXTOP(PREG, lp), 0);
|
||||
/* On a try_me, set cut to point at previous choicepoint,
|
||||
* that is, to the B before the cut.
|
||||
*/
|
||||
|
@ -156,8 +156,8 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp),lp);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp), lp);
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
GONext();
|
||||
|
@ -171,14 +171,12 @@
|
|||
* register, but sometimes (X86) not. In this case, have a
|
||||
* new register to point at YREG =*/
|
||||
CACHE_Y(YREG);
|
||||
{
|
||||
S_YREG[-1] = (CELL)SREG; /* the udi code did S = (CELL*)judyp; */
|
||||
}
|
||||
{ S_YREG[-1] = (CELL)SREG; /* the udi code did S = (CELL*)judyp; */ }
|
||||
S_YREG--;
|
||||
/* store arguments for procedure */
|
||||
store_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* store abstract machine registers */
|
||||
store_yaam_regs(NEXTOP(PREG,lp), 0);
|
||||
store_yaam_regs(NEXTOP(PREG, lp), 0);
|
||||
/* On a try_me, set cut to point at previous choicepoint,
|
||||
* that is, to the B before the cut.
|
||||
*/
|
||||
|
@ -187,8 +185,8 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp),lp);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp), lp);
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
GONext();
|
||||
|
@ -204,16 +202,16 @@
|
|||
* new register to point at YREG =*/
|
||||
CACHE_Y(YREG);
|
||||
{
|
||||
struct index_t *i = (struct index_t *)(PREG->y_u.lp.l);
|
||||
SREG = i->cls;
|
||||
S_YREG[-2] = (CELL)(SREG+i->arity);
|
||||
S_YREG[-1] = (CELL)(SREG+i->arity*i->nels);
|
||||
struct index_t *i = (struct index_t *)(PREG->y_u.lp.l);
|
||||
SREG = i->cls;
|
||||
S_YREG[-2] = (CELL)(SREG + i->arity);
|
||||
S_YREG[-1] = (CELL)(SREG + i->arity * i->nels);
|
||||
}
|
||||
S_YREG-=2;
|
||||
S_YREG -= 2;
|
||||
/* store arguments for procedure */
|
||||
store_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* store abstract machine registers */
|
||||
store_yaam_regs(NEXTOP(PREG,lp), 0);
|
||||
store_yaam_regs(NEXTOP(PREG, lp), 0);
|
||||
/* On a try_me, set cut to point at previous choicepoint,
|
||||
* that is, to the B before the cut.
|
||||
*/
|
||||
|
@ -222,8 +220,8 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp),lp);
|
||||
#endif /* YAPOR */
|
||||
PREG = NEXTOP(NEXTOP(PREG, lp), lp);
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
GONext();
|
||||
|
@ -234,45 +232,46 @@
|
|||
BEGD(d0);
|
||||
CACHE_Y(B);
|
||||
{
|
||||
struct index_t *it = (struct index_t *)(PREG->y_u.lp.l);
|
||||
BITS32 offset = ADDRESS_TO_LINK(it,(BITS32 *)((CELL *)(B+1))[it->arity]);
|
||||
d0 = it->links[offset];
|
||||
((CELL *)(B+1))[it->arity] = (CELL)LINK_TO_ADDRESS(it, d0);
|
||||
SREG = EXO_OFFSET_TO_ADDRESS(it, offset);
|
||||
struct index_t *it = (struct index_t *)(PREG->y_u.lp.l);
|
||||
BITS32 offset =
|
||||
ADDRESS_TO_LINK(it, (BITS32 *)((CELL *)(B + 1))[it->arity]);
|
||||
d0 = it->links[offset];
|
||||
((CELL *)(B + 1))[it->arity] = (CELL)LINK_TO_ADDRESS(it, d0);
|
||||
SREG = EXO_OFFSET_TO_ADDRESS(it, offset);
|
||||
}
|
||||
if (d0) {
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
#endif /* FROZEN_STACKS */
|
||||
SET_BB(B_YREG);
|
||||
SET_BB(B_YREG);
|
||||
} else {
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
}
|
||||
PREG = NEXTOP(PREG, lp);
|
||||
ENDCACHE_Y();
|
||||
|
@ -285,47 +284,47 @@
|
|||
BEGD(d0);
|
||||
CACHE_Y(B);
|
||||
{
|
||||
struct index_t *it = (struct index_t *)(PREG->y_u.lp.l);
|
||||
saveregs();
|
||||
d0 = ((CRetryExoIndex)it->udi_next)(it PASS_REGS);
|
||||
setregs();
|
||||
struct index_t *it = (struct index_t *)(PREG->y_u.lp.l);
|
||||
saveregs();
|
||||
d0 = ((CRetryExoIndex)it->udi_next)(it PASS_REGS);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = S;
|
||||
SREG = S;
|
||||
#endif
|
||||
}
|
||||
if (d0) {
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
#endif /* FROZEN_STACKS */
|
||||
SET_BB(B_YREG);
|
||||
SET_BB(B_YREG);
|
||||
} else {
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
}
|
||||
PREG = NEXTOP(PREG, lp);
|
||||
ENDCACHE_Y();
|
||||
|
@ -338,49 +337,50 @@
|
|||
BEGD(d0);
|
||||
CACHE_Y(B);
|
||||
{
|
||||
// struct udi_index_t *jp = (struct udi_index_t *)((CELL *)(B+1))[it->arity];
|
||||
/* operation has a side-effect: S = (CELL*)NextClause */
|
||||
saveregs();
|
||||
d0 = 0L; // Yap_UDI_NextAlt(jp);
|
||||
setregs();
|
||||
// struct udi_index_t *jp = (struct udi_index_t *)((CELL
|
||||
// *)(B+1))[it->arity];
|
||||
/* operation has a side-effect: S = (CELL*)NextClause */
|
||||
saveregs();
|
||||
d0 = 0L; // Yap_UDI_NextAlt(jp);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = S;
|
||||
SREG = S;
|
||||
#endif
|
||||
/* d0 says if we're last */
|
||||
/* d0 says if we're last */
|
||||
}
|
||||
if (d0) {
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
#endif /* FROZEN_STACKS */
|
||||
SET_BB(B_YREG);
|
||||
SET_BB(B_YREG);
|
||||
} else {
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.lp.p->ArityOfPE);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
}
|
||||
PREG = (yamop *)SREG;
|
||||
ENDCACHE_Y();
|
||||
|
@ -393,45 +393,45 @@
|
|||
BEGD(d0);
|
||||
CACHE_Y(B);
|
||||
{
|
||||
UInt arity = ((struct index_t *)PREG->y_u.lp.l)->arity;
|
||||
CELL *extras = (CELL *)(B+1);
|
||||
SREG = (CELL *)extras[arity];
|
||||
d0 = (SREG+arity != (CELL *)extras[arity+1]);
|
||||
if (d0) {
|
||||
extras[arity] = (CELL)(SREG+arity);
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(arity);
|
||||
UInt arity = ((struct index_t *)PREG->y_u.lp.l)->arity;
|
||||
CELL *extras = (CELL *)(B + 1);
|
||||
SREG = (CELL *)extras[arity];
|
||||
d0 = (SREG + arity != (CELL *)extras[arity + 1]);
|
||||
if (d0) {
|
||||
extras[arity] = (CELL)(SREG + arity);
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
restore_yaam_regs(PREG);
|
||||
restore_at_least_one_arg(arity);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
#endif /* FROZEN_STACKS */
|
||||
SET_BB(B_YREG);
|
||||
} else {
|
||||
SET_BB(B_YREG);
|
||||
} else {
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(arity);
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(arity);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(arity);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(arity);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
}
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
}
|
||||
}
|
||||
PREG = NEXTOP(PREG, lp);
|
||||
ENDCACHE_Y();
|
||||
|
@ -472,7 +472,7 @@
|
|||
restore_yaam_regs(PREG->y_u.Otapl.d);
|
||||
restore_args(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -488,25 +488,24 @@
|
|||
CACHE_Y(B);
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_args(PREG->y_u.Otapl.s);
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_args(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_args(PREG->y_u.Otapl.s);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_args(PREG->y_u.Otapl.s);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
LOCK(PREG->y_u.Otapl.p->StatisticsForPred->lock);
|
||||
|
@ -516,9 +515,9 @@
|
|||
GONext();
|
||||
ENDOp();
|
||||
|
||||
/*****************************************************************
|
||||
* Call count instructions *
|
||||
*****************************************************************/
|
||||
/*****************************************************************
|
||||
* Call count instructions *
|
||||
*****************************************************************/
|
||||
|
||||
/* count_enter_me Label,NArgs */
|
||||
Op(count_call, p);
|
||||
|
@ -527,17 +526,17 @@
|
|||
UNLOCK(PREG->y_u.p.p->StatisticsForPred->lock);
|
||||
LOCAL_ReductionsCounter--;
|
||||
if (LOCAL_ReductionsCounter == 0 && LOCAL_ReductionsCounterOn) {
|
||||
saveregs();
|
||||
Yap_NilError(CALL_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(CALL_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
LOCAL_PredEntriesCounter--;
|
||||
if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) {
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
PREG = NEXTOP(PREG, p);
|
||||
GONext();
|
||||
|
@ -550,20 +549,20 @@
|
|||
UNLOCK(PREG->y_u.p.p->StatisticsForPred->lock);
|
||||
LOCAL_RetriesCounter--;
|
||||
if (LOCAL_RetriesCounter == 0 && LOCAL_RetriesCounterOn) {
|
||||
/* act as if we had backtracked */
|
||||
ENV = B->cp_env;
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
/* act as if we had backtracked */
|
||||
ENV = B->cp_env;
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
LOCAL_PredEntriesCounter--;
|
||||
if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) {
|
||||
ENV = B->cp_env;
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
ENV = B->cp_env;
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
PREG = NEXTOP(PREG, p);
|
||||
GONext();
|
||||
|
@ -574,10 +573,10 @@
|
|||
CACHE_Y(B);
|
||||
restore_yaam_regs(PREG->y_u.Otapl.d);
|
||||
restore_args(PREG->y_u.Otapl.s);
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -589,17 +588,17 @@
|
|||
UNLOCK(((PredEntry *)(PREG->y_u.Otapl.p))->StatisticsForPred->lock);
|
||||
LOCAL_RetriesCounter--;
|
||||
if (LOCAL_RetriesCounter == 0 && LOCAL_RetriesCounterOn) {
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
LOCAL_PredEntriesCounter--;
|
||||
if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) {
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
PREG = NEXTOP(PREG, Otapl);
|
||||
GONext();
|
||||
|
@ -610,40 +609,39 @@
|
|||
CACHE_Y(B);
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_args(PREG->y_u.Otapl.s);
|
||||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_args(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_args(PREG->y_u.Otapl.s);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_args(PREG->y_u.Otapl.s);
|
||||
/* After trust, cut should be pointing at the new top
|
||||
* choicepoint */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
LOCAL_RetriesCounter--;
|
||||
if (LOCAL_RetriesCounter == 0) {
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
LOCAL_PredEntriesCounter--;
|
||||
if (LOCAL_PredEntriesCounter == 0) {
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
LOCK(((PredEntry *)(PREG->y_u.Otapl.p))->StatisticsForPred->lock);
|
||||
((PredEntry *)(PREG->y_u.Otapl.p))->StatisticsForPred->NOfRetries++;
|
||||
|
@ -659,28 +657,28 @@
|
|||
/* ensure_space */
|
||||
BOp(ensure_space, Osbpa);
|
||||
{
|
||||
Int sz = PREG->y_u.Osbpa.i;
|
||||
UInt arity = PREG->y_u.Osbpa.p->ArityOfPE;
|
||||
Int sz = PREG->y_u.Osbpa.i;
|
||||
UInt arity = PREG->y_u.Osbpa.p->ArityOfPE;
|
||||
|
||||
if (Unsigned(HR) + sz > Unsigned(YREG)-StackGap( PASS_REGS1 )) {
|
||||
YENV[E_CP] = (CELL) CPREG;
|
||||
YENV[E_E] = (CELL) ENV;
|
||||
if (Unsigned(HR) + sz > Unsigned(YREG) - StackGap(PASS_REGS1)) {
|
||||
YENV[E_CP] = (CELL)CPREG;
|
||||
YENV[E_E] = (CELL)ENV;
|
||||
#ifdef DEPTH_LIMIT
|
||||
YENV[E_DEPTH] = DEPTH;
|
||||
#endif /* DEPTH_LIMIT */
|
||||
SET_ASP(YREG, PREG->y_u.Osbpa.s);
|
||||
PREG = NEXTOP(PREG,Osbpa);
|
||||
saveregs();
|
||||
if (!Yap_gcl(sz, arity, YENV, PREG)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
setregs();
|
||||
FAIL();
|
||||
} else {
|
||||
setregs();
|
||||
}
|
||||
} else {
|
||||
PREG = NEXTOP(PREG,Osbpa);
|
||||
}
|
||||
YENV[E_DEPTH] = DEPTH;
|
||||
#endif /* DEPTH_LIMIT */
|
||||
SET_ASP(YREG, PREG->y_u.Osbpa.s);
|
||||
PREG = NEXTOP(PREG, Osbpa);
|
||||
saveregs();
|
||||
if (!Yap_gcl(sz, arity, YENV, PREG)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage);
|
||||
setregs();
|
||||
FAIL();
|
||||
} else {
|
||||
setregs();
|
||||
}
|
||||
} else {
|
||||
PREG = NEXTOP(PREG, Osbpa);
|
||||
}
|
||||
}
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
|
@ -693,9 +691,9 @@
|
|||
BOp(spy_or_trymark, Otapl);
|
||||
PELOCK(5, ((PredEntry *)(PREG->y_u.Otapl.p)));
|
||||
PREG = (yamop *)(&(((PredEntry *)(PREG->y_u.Otapl.p))->OpcodeOfPred));
|
||||
UNLOCKPE(11,(PredEntry *)(PREG->y_u.Otapl.p));
|
||||
UNLOCKPE(11, (PredEntry *)(PREG->y_u.Otapl.p));
|
||||
saveregs();
|
||||
spy_goal( PASS_REGS1 );
|
||||
spy_goal(PASS_REGS1);
|
||||
setregs();
|
||||
ENDBOp();
|
||||
|
||||
|
@ -708,30 +706,30 @@
|
|||
CUT_wait_leftmost();
|
||||
#endif /* YAPOR */
|
||||
if (PREG->y_u.Otapl.p->PredFlags & LogUpdatePredFlag) {
|
||||
PELOCK(6,PREG->y_u.Otapl.p);
|
||||
PP = PREG->y_u.Otapl.p;
|
||||
PELOCK(6, PREG->y_u.Otapl.p);
|
||||
PP = PREG->y_u.Otapl.p;
|
||||
}
|
||||
if (PREG->y_u.Otapl.p->CodeOfPred != PREG) {
|
||||
/* oops, someone changed the procedure under our feet,
|
||||
fortunately this is no big deal because we haven't done
|
||||
anything yet */
|
||||
PP = NULL;
|
||||
PREG = PREG->y_u.Otapl.p->CodeOfPred;
|
||||
UNLOCKPE(12,PREG->y_u.Otapl.p);
|
||||
/* for profiler */
|
||||
save_pc();
|
||||
JMPNext();
|
||||
/* oops, someone changed the procedure under our feet,
|
||||
fortunately this is no big deal because we haven't done
|
||||
anything yet */
|
||||
PP = NULL;
|
||||
PREG = PREG->y_u.Otapl.p->CodeOfPred;
|
||||
UNLOCKPE(12, PREG->y_u.Otapl.p);
|
||||
/* for profiler */
|
||||
save_pc();
|
||||
JMPNext();
|
||||
}
|
||||
#endif
|
||||
CACHE_Y(YREG);
|
||||
PREG = PREG->y_u.Otapl.d;
|
||||
/*
|
||||
I've got a read lock on the DB, so I don't need to care...
|
||||
niaaahh.... niahhhh...
|
||||
I've got a read lock on the DB, so I don't need to care...
|
||||
niaaahh.... niahhhh...
|
||||
*/
|
||||
LOCK(DynamicLock(PREG));
|
||||
/* one can now mess around with the predicate */
|
||||
UNLOCKPE(13,((PredEntry *)(PREG->y_u.Otapl.p)));
|
||||
UNLOCKPE(13, ((PredEntry *)(PREG->y_u.Otapl.p)));
|
||||
BEGD(d1);
|
||||
d1 = PREG->y_u.Otapl.s;
|
||||
store_args(d1);
|
||||
|
@ -741,7 +739,7 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
#if MULTIPLE_STACKS
|
||||
|
@ -751,11 +749,11 @@
|
|||
#else
|
||||
if (FlagOff(InUseMask, DynamicFlags(PREG))) {
|
||||
|
||||
SetFlag(InUseMask, DynamicFlags(PREG));
|
||||
TRAIL_CLREF(ClauseCodeToDynamicClause(PREG));
|
||||
SetFlag(InUseMask, DynamicFlags(PREG));
|
||||
TRAIL_CLREF(ClauseCodeToDynamicClause(PREG));
|
||||
}
|
||||
#endif
|
||||
PREG = NEXTOP(PREG,Otapl);
|
||||
PREG = NEXTOP(PREG, Otapl);
|
||||
JMPNext();
|
||||
|
||||
ENDBOp();
|
||||
|
@ -763,17 +761,17 @@
|
|||
BOp(count_retry_and_mark, Otapl);
|
||||
LOCAL_RetriesCounter--;
|
||||
if (LOCAL_RetriesCounter == 0) {
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
LOCAL_PredEntriesCounter--;
|
||||
if (LOCAL_PredEntriesCounter == 0) {
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,"");
|
||||
setregs();
|
||||
JMPNext();
|
||||
saveregs();
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
/* enter a retry dynamic */
|
||||
ENDBOp();
|
||||
|
@ -791,7 +789,7 @@
|
|||
CUT_wait_leftmost();
|
||||
#endif /* YAPOR */
|
||||
/* need to make the DB stable until I get the new clause */
|
||||
PELOCK(7,PREG->y_u.Otapl.p);
|
||||
PELOCK(7, PREG->y_u.Otapl.p);
|
||||
CACHE_Y(B);
|
||||
PREG = PREG->y_u.Otapl.d;
|
||||
LOCK(DynamicLock(PREG));
|
||||
|
@ -799,7 +797,7 @@
|
|||
restore_yaam_regs(PREG);
|
||||
restore_args(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -813,15 +811,14 @@
|
|||
#else
|
||||
if (FlagOff(InUseMask, DynamicFlags(PREG))) {
|
||||
|
||||
SetFlag(InUseMask, DynamicFlags(PREG));
|
||||
TRAIL_CLREF(ClauseCodeToDynamicClause(PREG));
|
||||
SetFlag(InUseMask, DynamicFlags(PREG));
|
||||
TRAIL_CLREF(ClauseCodeToDynamicClause(PREG));
|
||||
}
|
||||
#endif
|
||||
PREG = NEXTOP(PREG, Otapl);
|
||||
JMPNext();
|
||||
|
||||
ENDBOp();
|
||||
|
||||
|
||||
/************************************************************************\
|
||||
* Try / Retry / Trust for main indexing blocks *
|
||||
|
@ -838,7 +835,7 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
JMPNext();
|
||||
|
@ -861,7 +858,7 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
JMPNext();
|
||||
|
@ -882,7 +879,7 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
JMPNext();
|
||||
|
@ -904,7 +901,7 @@
|
|||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
JMPNext();
|
||||
|
@ -915,7 +912,7 @@
|
|||
restore_yaam_regs(NEXTOP(PREG, Otapl));
|
||||
restore_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -933,7 +930,7 @@
|
|||
ARG1 = B_YREG->cp_a1;
|
||||
ARG2 = B_YREG->cp_a2;
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -951,7 +948,7 @@
|
|||
ARG2 = B_YREG->cp_a2;
|
||||
ARG3 = B_YREG->cp_a3;
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -970,7 +967,7 @@
|
|||
ARG3 = B_YREG->cp_a3;
|
||||
ARG4 = B_YREG->cp_a4;
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
|
@ -987,20 +984,19 @@
|
|||
SCH_last_alternative(PREG, B_YREG);
|
||||
restore_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
}
|
||||
else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
} else
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
pop_yaam_regs();
|
||||
pop_at_least_one_arg(PREG->y_u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
S_YREG = (CELL *)PROTECT_FROZEN_B(B_YREG);
|
||||
#endif /* FROZEN_STACKS */
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
set_cut(S_YREG, B);
|
||||
}
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
PREG = PREG->y_u.Otapl.d;
|
||||
|
|
345
C/dbase.c
345
C/dbase.c
|
@ -18,89 +18,100 @@
|
|||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file dbase.c
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Mon Apr 30 09:36:46 2018
|
||||
*
|
||||
* @brief record and other forms of storing terms.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup Internal_Database Internal Data Base
|
||||
@ingroup builtins
|
||||
@{
|
||||
|
||||
Some programs need global information for, e.g. counting or collecting
|
||||
data obtained by backtracking. As a rule, to keep this information, the
|
||||
internal data base should be used instead of asserting and retracting
|
||||
clauses (as most novice programmers do), .
|
||||
In YAP (as in some other Prolog systems) the internal data base (i.d.b.
|
||||
for short) is faster, needs less space and provides a better insulation of
|
||||
program and data than using asserted/retracted clauses.
|
||||
The i.d.b. is implemented as a set of terms, accessed by keys that
|
||||
unlikely what happens in (non-Prolog) data bases are not part of the
|
||||
term. Under each key a list of terms is kept. References are provided so that
|
||||
terms can be identified: each term in the i.d.b. has a unique reference
|
||||
(references are also available for clauses of dynamic predicates).
|
||||
|
||||
There is a strong analogy between the i.d.b. and the way dynamic
|
||||
predicates are stored. In fact, the main i.d.b. predicates might be
|
||||
implemented using dynamic predicates:
|
||||
|
||||
~~~~~
|
||||
recorda(X,T,R) :- asserta(idb(X,T),R).
|
||||
recordz(X,T,R) :- assertz(idb(X,T),R).
|
||||
recorded(X,T,R) :- clause(idb(X,T),R).
|
||||
~~~~~
|
||||
We can take advantage of this, the other way around, as it is quite
|
||||
easy to write a simple Prolog interpreter, using the i.d.b.:
|
||||
|
||||
~~~~~
|
||||
asserta(G) :- recorda(interpreter,G,_).
|
||||
assertz(G) :- recordz(interpreter,G,_).
|
||||
retract(G) :- recorded(interpreter,G,R), !, erase(R).
|
||||
call(V) :- var(V), !, fail.
|
||||
call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B).
|
||||
call(G) :- recorded(interpreter,G,_).
|
||||
~~~~~
|
||||
In YAP, much attention has been given to the implementation of the
|
||||
i.d.b., especially to the problem of accelerating the access to terms kept in
|
||||
a large list under the same key. Besides using the key, YAP uses an internal
|
||||
lookup function, transparent to the user, to find only the terms that might
|
||||
unify. For instance, in a data base containing the terms
|
||||
|
||||
~~~~~
|
||||
b
|
||||
b(a)
|
||||
c(d)
|
||||
e(g)
|
||||
b(X)
|
||||
e(h)
|
||||
~~~~~
|
||||
|
||||
stored under the key k/1, when executing the query
|
||||
|
||||
~~~~~
|
||||
:- recorded(k(_),c(_),R).
|
||||
~~~~~
|
||||
|
||||
`recorded` would proceed directly to the third term, spending almost the
|
||||
time as if `a(X)` or `b(X)` was being searched.
|
||||
The lookup function uses the functor of the term, and its first three
|
||||
arguments (when they exist). So, `recorded(k(_),e(h),_)` would go
|
||||
directly to the last term, while `recorded(k(_),e(_),_)` would find
|
||||
first the fourth term, and then, after backtracking, the last one.
|
||||
|
||||
This mechanism may be useful to implement a sort of hierarchy, where
|
||||
the functors of the terms (and eventually the first arguments) work as
|
||||
secondary keys.
|
||||
|
||||
In the YAP's i.d.b. an optimized representation is used for
|
||||
terms without free variables. This results in a faster retrieval of terms
|
||||
and better space usage. Whenever possible, avoid variables in terms in terms
|
||||
stored in the i.d.b.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
*
|
||||
* @ingroup builtins
|
||||
* @{
|
||||
*
|
||||
* Some programs need global information for, e.g. counting or collecting
|
||||
* data obtained by backtracking. As a rule, to keep this information, the
|
||||
* internal data base should be used instead of asserting and retracting
|
||||
* clauses (as most novice programmers do), .
|
||||
* In YAP (as in some other Prolog systems) the internal data base (i.d.b.
|
||||
* for short) is faster, needs less space and provides a better insulation of
|
||||
* program and data than using asserted/retracted clauses.
|
||||
* The i.d.b. is implemented as a set of terms, accessed by keys that
|
||||
* unlikely what happens in (non-Prolog) data bases are not part of the
|
||||
* term. Under each key a list of terms is kept. References are provided so that
|
||||
* terms can be identified: each term in the i.d.b. has a unique reference
|
||||
* (references are also available for clauses of dynamic predicates).
|
||||
*
|
||||
* There is a strong analogy between the i.d.b. and the way dynamic
|
||||
* predicates are stored. In fact, the main i.d.b. predicates might be
|
||||
* implemented using dynamic predicates:
|
||||
*
|
||||
* ~~~~~
|
||||
* recorda(X,T,R) :- asserta(idb(X,T),R).
|
||||
* recordz(X,T,R) :- assertz(idb(X,T),R).
|
||||
* recorded(X,T,R) :- clause(idb(X,T),R).
|
||||
* ~~~~~
|
||||
* We can take advantage of this, the other way around, as it is quite
|
||||
* easy to write a simple Prolog interpreter, using the i.d.b.:
|
||||
*
|
||||
* ~~~~~
|
||||
* asserta(G) :- recorda(interpreter,G,_).
|
||||
* assertz(G) :- recordz(interpreter,G,_).
|
||||
* retract(G) :- recorded(interpreter,G,R), !, erase(R).
|
||||
* call(V) :- var(V), !, fail.
|
||||
* call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B).
|
||||
* call(G) :- recorded(interpreter,G,_).
|
||||
* ~~~~~
|
||||
* In YAP, much attention has been given to the implementation of the
|
||||
* i.d.b., especially to the problem of accelerating the access to terms kept in
|
||||
* a large list under the same key. Besides using the key, YAP uses an internal
|
||||
* lookup function, transparent to the user, to find only the terms that might
|
||||
* unify. For instance, in a data base containing the terms
|
||||
*
|
||||
* ~~~~~
|
||||
* b
|
||||
* b(a)
|
||||
* c(d)
|
||||
* e(g)
|
||||
* b(X)
|
||||
* e(h)
|
||||
* ~~~~~
|
||||
*
|
||||
* stored under the key k/1, when executing the query
|
||||
*
|
||||
* ~~~~~
|
||||
* :- recorded(k(_),c(_),R).
|
||||
* ~~~~~
|
||||
*
|
||||
* `recorded` would proceed directly to the third term, spending almost the
|
||||
* time as if `a(X)` or `b(X)` was being searched.
|
||||
* The lookup function uses the functor of the term, and its first three
|
||||
* arguments (when they exist). So, `recorded(k(_),e(h),_)` would go
|
||||
* directly to the last term, while `recorded(k(_),e(_),_)` would find
|
||||
* first the fourth term, and then, after backtracking, the last one.
|
||||
*
|
||||
* This mechanism may be useful to implement a sort of hierarchy, where
|
||||
* the functors of the terms (and eventually the first arguments) work as
|
||||
* secondary keys.
|
||||
*
|
||||
* In the YAP's i.d.b. an optimized representation is used for
|
||||
* terms without free variables. This results in a faster retrieval of terms
|
||||
* and better space usage. Whenever possible, avoid variables in terms in terms
|
||||
* stored in the i.d.b.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Yap.h"
|
||||
#include "clause.h"
|
||||
#include "yapio.h"
|
||||
#include "attvar.h"
|
||||
#include "clause.h"
|
||||
#include "heapgc.h"
|
||||
#include "yapio.h"
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
@ -259,7 +270,7 @@ static Int p_rcdz(USES_REGS1);
|
|||
static Int p_rcdzp(USES_REGS1);
|
||||
static Int p_drcdap(USES_REGS1);
|
||||
static Int p_drcdzp(USES_REGS1);
|
||||
static Term GetDBTerm(DBTerm *, int src CACHE_TYPE);
|
||||
static Term GetDBTerm(const DBTerm *, int src CACHE_TYPE);
|
||||
static DBProp FetchDBPropFromKey(Term, int, int, char *);
|
||||
static Int i_recorded(DBProp, Term CACHE_TYPE);
|
||||
static Int c_recorded(int CACHE_TYPE);
|
||||
|
@ -267,8 +278,8 @@ static Int co_rded(USES_REGS1);
|
|||
static Int in_rdedp(USES_REGS1);
|
||||
static Int co_rdedp(USES_REGS1);
|
||||
static Int p_first_instance(USES_REGS1);
|
||||
static void ErasePendingRefs(DBTerm *CACHE_TYPE);
|
||||
static void RemoveDBEntry(DBRef CACHE_TYPE);
|
||||
static void ErasePendingRefs(const DBTerm *CACHE_TYPE);
|
||||
static void RemoveDBEntry(const DBRef CACHE_TYPE);
|
||||
static void EraseLogUpdCl(LogUpdClause *);
|
||||
static void MyEraseClause(DynamicClause *CACHE_TYPE);
|
||||
static void PrepareToEraseClause(DynamicClause *, DBRef);
|
||||
|
@ -292,10 +303,10 @@ static void sf_include(SFKeep *);
|
|||
#endif
|
||||
static Int p_init_queue(USES_REGS1);
|
||||
static Int p_enqueue(USES_REGS1);
|
||||
static void keepdbrefs(DBTerm *CACHE_TYPE);
|
||||
static void keepdbrefs(const DBTerm *ref USES_REGS);
|
||||
static Int p_dequeue(USES_REGS1);
|
||||
static void ErDBE(DBRef CACHE_TYPE);
|
||||
static void ReleaseTermFromDB(DBTerm *CACHE_TYPE);
|
||||
static void ReleaseTermFromDB(const DBTerm *ref USES_REGS);
|
||||
static PredEntry *new_lu_entry(Term);
|
||||
static PredEntry *new_lu_int_key(Int);
|
||||
static PredEntry *find_lu_entry(Term);
|
||||
|
@ -336,19 +347,18 @@ static int recover_from_record_error(int nargs) {
|
|||
goto recover_record;
|
||||
case RESOURCE_ERROR_HEAP:
|
||||
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
|
||||
Yap_Error(RESOURCE_ERROR_HEAP, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
goto recover_record;
|
||||
case RESOURCE_ERROR_AUXILIARY_STACK:
|
||||
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) {
|
||||
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, LOCAL_Error_Term,
|
||||
LOCAL_ErrorMessage);
|
||||
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
goto recover_record;
|
||||
default:
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_Error(LOCAL_Error_TYPE, TermNil, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
recover_record:
|
||||
|
@ -419,12 +429,6 @@ static Int cmpclls(CELL *a, CELL *b, Int n) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#if !THREADS
|
||||
int Yap_DBTrailOverflow() {
|
||||
return ((CELL *)LOCAL_s_dbg->lr > (CELL *)LOCAL_s_dbg->tofref - 2048);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* get DB entry for ap/arity; */
|
||||
static Prop FindDBPropHavingLock(AtomEntry *ae, int CodeDB, unsigned int arity,
|
||||
Term dbmod) {
|
||||
|
@ -634,7 +638,7 @@ static CELL *copy_double(CELL *st, CELL *pt) {
|
|||
static CELL *copy_string(CELL *st, CELL *pt) {
|
||||
UInt sz = pt[1] + 3;
|
||||
/* first thing, store a link to the list before we move on */
|
||||
memcpy(st, pt, sizeof(CELL) * sz);
|
||||
memmove(st, pt, sizeof(CELL) * sz);
|
||||
/* now reserve space */
|
||||
return st + sz;
|
||||
}
|
||||
|
@ -648,7 +652,7 @@ static CELL *copy_big_int(CELL *st, CELL *pt) {
|
|||
st[0] = (CELL)FunctorBigInt;
|
||||
st[1] = pt[1];
|
||||
/* then the actual number */
|
||||
memcpy((void *)(st + 2), (void *)(pt + 2), sz);
|
||||
memmove((void *)(st + 2), (void *)(pt + 2), sz);
|
||||
st = st + 2 + sz / CellSize;
|
||||
/* then the tail for gc */
|
||||
st[0] = EndSpecials;
|
||||
|
@ -712,15 +716,22 @@ loop:
|
|||
f = (Functor)(*ap2);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
switch ((CELL)f) {
|
||||
case (CELL) FunctorDBRef: {
|
||||
case (CELL)FunctorDBRef: {
|
||||
DBRef dbentry;
|
||||
/* store now the correct entry */
|
||||
|
||||
dbentry = DBRefOfTerm(d0);
|
||||
*StoPoint++ = d0;
|
||||
dbg->lr--;
|
||||
if (dbentry->Flags & LogUpdMask) {
|
||||
LogUpdClause *cl = (LogUpdClause *)dbentry;
|
||||
|
||||
/* store now the correct entry */
|
||||
#if DEBUG
|
||||
if (GLOBAL_Option['i' - 'a' + 1]) {
|
||||
Yap_DebugPlWriteln(d0);
|
||||
fprintf(stderr, "+%p@%p %s\n", cl, cl->ClPred,
|
||||
IndicatorOfPred(cl->ClPred));
|
||||
}
|
||||
#endif
|
||||
cl->ClRefCount++;
|
||||
} else {
|
||||
dbentry->NOfRefsTo++;
|
||||
|
@ -731,14 +742,14 @@ loop:
|
|||
++pt0;
|
||||
continue;
|
||||
}
|
||||
case (CELL) FunctorLongInt:
|
||||
case (CELL)FunctorLongInt:
|
||||
CheckDBOverflow(3);
|
||||
*StoPoint++ = AbsAppl(CodeMax);
|
||||
CodeMax = copy_long_int(CodeMax, ap2);
|
||||
++pt0;
|
||||
continue;
|
||||
#ifdef USE_GMP
|
||||
case (CELL) FunctorBigInt:
|
||||
case (CELL)FunctorBigInt:
|
||||
CheckDBOverflow(3 + Yap_SizeOfBigInt(d0));
|
||||
/* first thing, store a link to the list before we move on */
|
||||
*StoPoint++ = AbsAppl(CodeMax);
|
||||
|
@ -746,7 +757,7 @@ loop:
|
|||
++pt0;
|
||||
continue;
|
||||
#endif
|
||||
case (CELL) FunctorString: {
|
||||
case (CELL)FunctorString: {
|
||||
CELL *st = CodeMax;
|
||||
|
||||
CheckDBOverflow(3 + ap2[1]);
|
||||
|
@ -756,7 +767,7 @@ loop:
|
|||
++pt0;
|
||||
continue;
|
||||
}
|
||||
case (CELL) FunctorDouble: {
|
||||
case (CELL)FunctorDouble: {
|
||||
CELL *st = CodeMax;
|
||||
|
||||
CheckDBOverflow(4);
|
||||
|
@ -953,7 +964,7 @@ loop:
|
|||
if (HR + sz >= ASP) {
|
||||
goto error2;
|
||||
}
|
||||
memcpy((void *)HR, (void *)(to_visit_base), sz * sizeof(CELL *));
|
||||
memmove((void *)HR, (void *)(to_visit_base), sz * sizeof(CELL *));
|
||||
to_visit_base = (CELL **)HR;
|
||||
to_visit = to_visit_base + sz;
|
||||
}
|
||||
|
@ -1114,7 +1125,6 @@ static void sf_include(SFKeep *sfp, struct db_globs *dbg) SFKeep *sfp;
|
|||
j += 2;
|
||||
} else {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_DBTERM;
|
||||
LOCAL_Error_Term = d0;
|
||||
LOCAL_ErrorMessage = "wrong term in SF";
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -1235,7 +1245,6 @@ static DBRef generate_dberror_msg(int errnumb, UInt sz, char *msg) {
|
|||
CACHE_REGS
|
||||
LOCAL_Error_Size = sz;
|
||||
LOCAL_Error_TYPE = errnumb;
|
||||
LOCAL_Error_Term = TermNil;
|
||||
LOCAL_ErrorMessage = msg;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1340,7 +1349,7 @@ static DBRef CreateDBRefForAtom(Term Tm, DBProp p, int InFlag,
|
|||
UInt sz = DBLength(NIL);
|
||||
|
||||
flag = DBAtomic;
|
||||
if (InFlag &MkIfNot && (dbg->found_one = check_if_cons(p->First, Tm)))
|
||||
if (InFlag & MkIfNot && (dbg->found_one = check_if_cons(p->First, Tm)))
|
||||
return dbg->found_one;
|
||||
pp = AllocDBSpace(sz);
|
||||
if (pp == NIL) {
|
||||
|
@ -1368,7 +1377,7 @@ static DBRef CreateDBRefForVar(Term Tm, DBProp p, int InFlag,
|
|||
Register DBRef pp;
|
||||
UInt sz = DBLength(NULL);
|
||||
|
||||
if (InFlag &MkIfNot && (dbg->found_one = check_if_var(p->First)))
|
||||
if (InFlag & MkIfNot && (dbg->found_one = check_if_var(p->First)))
|
||||
return dbg->found_one;
|
||||
pp = AllocDBSpace(sz);
|
||||
if (pp == NULL) {
|
||||
|
@ -1398,12 +1407,14 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
SMALLUNSGN flag;
|
||||
int NOfLinks = 0;
|
||||
/* place DBRefs in ConsultStack */
|
||||
DBRef *TmpRefBase = (DBRef *)LOCAL_TrailTop;
|
||||
DBRef *TmpRefBase;
|
||||
CELL *CodeAbs; /* how much code did we find */
|
||||
int vars_found = FALSE;
|
||||
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||
|
||||
retry_record:
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
|
||||
TmpRefBase = (DBRef *)LOCAL_TrailTop;
|
||||
if (p == NULL) {
|
||||
if (IsVarTerm(Tm)) {
|
||||
#ifdef COROUTINING
|
||||
|
@ -1411,6 +1422,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
#endif
|
||||
DBRef out = (DBRef)CreateDBTermForVar(extra_size, dbg);
|
||||
*pstat = TRUE;
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return out;
|
||||
#ifdef COROUTINING
|
||||
}
|
||||
|
@ -1418,6 +1430,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
} else if (IsAtomOrIntTerm(Tm)) {
|
||||
DBRef out = (DBRef)CreateDBTermForAtom(Tm, extra_size, dbg);
|
||||
*pstat = FALSE;
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return out;
|
||||
}
|
||||
} else {
|
||||
|
@ -1427,8 +1440,10 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
#endif
|
||||
) {
|
||||
*pstat = TRUE;
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return CreateDBRefForVar(Tm, p, InFlag, dbg);
|
||||
} else if (IsAtomOrIntTerm(Tm)) {
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return CreateDBRefForAtom(Tm, p, InFlag, dbg);
|
||||
}
|
||||
}
|
||||
|
@ -1456,6 +1471,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
LOCAL_Error_Size = (UInt)(extra_size + sizeof(ppt0));
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK;
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return NULL;
|
||||
}
|
||||
ntp0 = ppt0->Contents;
|
||||
|
@ -1463,6 +1479,8 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
LOCAL_Error_Size = 0;
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL;
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
dbg->lr = dbg->LinkAr = (link_entry *)TR;
|
||||
|
@ -1470,10 +1488,11 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
/* attachment */
|
||||
if (IsVarTerm(Tm)) {
|
||||
tt = (CELL)(ppt0->Contents);
|
||||
ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0 + 1, ntp0 - 1,
|
||||
ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0 + 1, ntp0 - 1,
|
||||
&attachments, &vars_found, dbg);
|
||||
if (ntp == NULL) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
|
@ -1488,28 +1507,53 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
&vars_found, dbg);
|
||||
if (ntp == NULL) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
unsigned int arity;
|
||||
Functor fun;
|
||||
|
||||
vars_found = true;
|
||||
tt = AbsAppl(ppt0->Contents);
|
||||
/* we need to store the functor manually */
|
||||
fun = FunctorOfTerm(Tm);
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
switch ((CELL)fun) {
|
||||
case (CELL) FunctorDouble:
|
||||
case (CELL)FunctorDouble:
|
||||
ntp = copy_double(ntp0, RepAppl(Tm));
|
||||
break;
|
||||
case (CELL) FunctorString:
|
||||
ntp = copy_string(ntp0, RepAppl(Tm));
|
||||
case (CELL)FunctorString:
|
||||
{
|
||||
UInt sz = 1024+sizeof(CELL)*(3 + RepAppl(Tm)[1]);
|
||||
if (sz >
|
||||
(char*)AuxSp-(char*)ppt0) {
|
||||
LOCAL_Error_Size = sz;
|
||||
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) {
|
||||
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return NULL;
|
||||
}
|
||||
goto retry_record;
|
||||
}
|
||||
}
|
||||
ntp = copy_string(ntp0, RepAppl(Tm));
|
||||
break;
|
||||
case (CELL) FunctorDBRef:
|
||||
case (CELL)FunctorDBRef:
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return CreateDBWithDBRef(Tm, p, dbg);
|
||||
#ifdef USE_GMP
|
||||
case (CELL) FunctorBigInt:
|
||||
case (CELL)FunctorBigInt:
|
||||
{
|
||||
UInt sz = 1024+sizeof(CELL)*Yap_SizeOfBigInt(Tm);
|
||||
if (sz >
|
||||
(char*)AuxSp-(char*)ppt0) {
|
||||
LOCAL_Error_Size = sizeof(CELL)*(3 + RepAppl(Tm)[1]);
|
||||
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) {
|
||||
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return NULL;
|
||||
}
|
||||
goto retry_record;
|
||||
}
|
||||
}
|
||||
ntp = copy_big_int(ntp0, RepAppl(Tm));
|
||||
break;
|
||||
#endif
|
||||
|
@ -1528,6 +1572,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
&vars_found, dbg);
|
||||
if (ntp == NULL) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1535,6 +1580,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
CodeAbs = (CELL *)((CELL)ntp - (CELL)ntp0);
|
||||
if (LOCAL_Error_TYPE) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return NULL; /* Error Situation */
|
||||
}
|
||||
NOfCells = ntp - ntp0; /* End Of Code Info */
|
||||
|
@ -1553,11 +1599,13 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
LOCAL_Error_Size = (UInt)DBLength(CodeAbs);
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK;
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return NULL;
|
||||
}
|
||||
if ((InFlag & MkIfNot) &&
|
||||
(dbg->found_one = check_if_wvars(p->First, NOfCells, ntp0))) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return dbg->found_one;
|
||||
}
|
||||
} else {
|
||||
|
@ -1565,6 +1613,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
if ((InFlag & MkIfNot) &&
|
||||
(dbg->found_one = check_if_nvars(p->First, NOfCells, ntp0, dbg))) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return dbg->found_one;
|
||||
}
|
||||
}
|
||||
|
@ -1574,6 +1623,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
LOCAL_Error_Size = (UInt)DBLength(CodeAbs);
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK;
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return NULL;
|
||||
}
|
||||
flag |= DBWithRefs;
|
||||
|
@ -1581,6 +1631,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
#if SIZEOF_LINK_ENTRY == 2
|
||||
if (Unsigned(CodeAbs) >= 0x40000) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return generate_dberror_msg(SYSTEM_ERROR_INTERNAL, 0,
|
||||
"trying to store term larger than 256KB");
|
||||
}
|
||||
|
@ -1591,6 +1642,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
ppt = (DBTerm *)(ptr + extra_size);
|
||||
if (ptr == NULL) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return generate_dberror_msg(RESOURCE_ERROR_HEAP, sz,
|
||||
"heap crashed against stacks");
|
||||
}
|
||||
|
@ -1602,6 +1654,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
pp = AllocDBSpace(sz);
|
||||
if (pp == NULL) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return generate_dberror_msg(RESOURCE_ERROR_HEAP, sz,
|
||||
"heap crashed against stacks");
|
||||
}
|
||||
|
@ -1627,7 +1680,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
nar = ppt->Contents + Unsigned(NOfCells);
|
||||
}
|
||||
woar = (link_entry *)nar;
|
||||
memcpy((void *)woar, (const void *)dbg->LinkAr,
|
||||
memmove((void *)woar, (const void *)dbg->LinkAr,
|
||||
(size_t)(NOfLinks * sizeof(link_entry)));
|
||||
woar += NOfLinks;
|
||||
#ifdef ALIGN_LONGS
|
||||
|
@ -1675,6 +1728,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
|||
ppt->DBRefs = NULL;
|
||||
}
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
LOCAL_Error_TYPE = oerr;
|
||||
return pp;
|
||||
}
|
||||
}
|
||||
|
@ -1686,7 +1740,6 @@ static DBRef record(int Flag, Term key, Term t_data, Term t_code USES_REGS) {
|
|||
int needs_vars;
|
||||
struct db_globs dbg;
|
||||
|
||||
LOCAL_s_dbg = &dbg;
|
||||
dbg.found_one = NULL;
|
||||
#ifdef SFUNC
|
||||
FathersPlace = NIL;
|
||||
|
@ -1762,7 +1815,6 @@ static DBRef record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS) {
|
|||
int needs_vars;
|
||||
struct db_globs dbg;
|
||||
|
||||
LOCAL_s_dbg = &dbg;
|
||||
#ifdef SFUNC
|
||||
FathersPlace = NIL;
|
||||
#endif
|
||||
|
@ -1847,7 +1899,6 @@ static LogUpdClause *new_lu_db_entry(Term t, PredEntry *pe) {
|
|||
if (!pe || !(pe->PredFlags & ThreadLocalPredFlag))
|
||||
d_flag |= InQueue;
|
||||
#endif
|
||||
LOCAL_s_dbg = &dbg;
|
||||
ipc = NEXTOP(((LogUpdClause *)NULL)->ClCode, e);
|
||||
if ((x = (DBTerm *)CreateDBStruct(t, NULL, d_flag, &needs_vars, (UInt)ipc,
|
||||
&dbg)) == NULL) {
|
||||
|
@ -2479,7 +2530,7 @@ Int Yap_unify_immediate_ref(DBRef ref USES_REGS) {
|
|||
}
|
||||
}
|
||||
|
||||
static Term GetDBTerm(DBTerm *DBSP, int src USES_REGS) {
|
||||
static Term GetDBTerm(const DBTerm *DBSP, int src USES_REGS) {
|
||||
Term t = DBSP->Entry;
|
||||
|
||||
if (IsVarTerm(t)
|
||||
|
@ -2503,6 +2554,7 @@ static Term GetDBTerm(DBTerm *DBSP, int src USES_REGS) {
|
|||
CalculateStackGap(PASS_REGS1);
|
||||
if (HR + NOf > ASP - EventFlag / sizeof(CELL)) {
|
||||
if (LOCAL_PrologMode & InErrorMode) {
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
if (HR + NOf > ASP)
|
||||
fprintf(stderr,
|
||||
"\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
|
||||
|
@ -2584,7 +2636,6 @@ static int resize_int_keys(UInt new_size) {
|
|||
if (new == NULL) {
|
||||
YAPLeaveCriticalSection();
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||
LOCAL_Error_Term = TermNil;
|
||||
LOCAL_ErrorMessage = "could not allocate space";
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -2666,7 +2717,6 @@ static PredEntry *new_lu_int_key(Int key) {
|
|||
if (INT_LU_KEYS == NULL) {
|
||||
CACHE_REGS
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||
LOCAL_Error_Term = TermNil;
|
||||
LOCAL_ErrorMessage = "could not allocate space";
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2681,11 +2731,17 @@ static PredEntry *new_lu_int_key(Int key) {
|
|||
p->ArityOfPE = 3;
|
||||
p->OpcodeOfPred = Yap_opcode(_op_fail);
|
||||
p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = FAILCODE;
|
||||
if (p->PredFlags & ProfiledPredFlag) {
|
||||
if (!Yap_initProfiler(p)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
INT_LU_KEYS[hash_key] = p0;
|
||||
return p;
|
||||
}
|
||||
|
||||
static PredEntry *new_lu_entry(Term t) {
|
||||
CACHE_REGS
|
||||
Prop p0;
|
||||
PredEntry *pe;
|
||||
|
||||
|
@ -2707,12 +2763,20 @@ static PredEntry *new_lu_entry(Term t) {
|
|||
pe->PredFlags |= LogUpdatePredFlag;
|
||||
if (IsAtomTerm(t)) {
|
||||
pe->PredFlags |= AtomDBPredFlag;
|
||||
pe->FunctorOfPred = (Functor)AtomOfTerm(t);
|
||||
} else {
|
||||
pe->FunctorOfPred = FunctorOfTerm(t);
|
||||
}
|
||||
pe->ArityOfPE = 3;
|
||||
pe->OpcodeOfPred = Yap_opcode(_op_fail);
|
||||
if (CurrentModule == PROLOG_MODULE)
|
||||
pe->PredFlags |= StandardPredFlag;
|
||||
pe->cs.p_code.TrueCodeOfPred = pe->CodeOfPred = FAILCODE;
|
||||
if (pe->PredFlags & ProfiledPredFlag) {
|
||||
if (!Yap_initProfiler(pe)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return pe;
|
||||
}
|
||||
|
||||
|
@ -2737,7 +2801,8 @@ static DBProp find_entry(Term t) {
|
|||
at = AtomDot;
|
||||
arity = 2;
|
||||
}
|
||||
return RepDBProp(FindDBProp(RepAtom(at), 0, arity, 0));
|
||||
DBProp rc = RepDBProp(FindDBProp(RepAtom(at), 0, arity, 0));
|
||||
return rc;
|
||||
}
|
||||
|
||||
static PredEntry *find_lu_entry(Term t) {
|
||||
|
@ -2783,7 +2848,6 @@ static DBProp FetchIntDBPropFromKey(Int key, int flag, int new,
|
|||
if (INT_KEYS == NULL) {
|
||||
CACHE_REGS
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||
LOCAL_Error_Term = TermNil;
|
||||
LOCAL_ErrorMessage = "could not allocate space";
|
||||
return NULL;
|
||||
}
|
||||
|
@ -3303,6 +3367,7 @@ static Int lu_recorded(PredEntry *pe USES_REGS) {
|
|||
}
|
||||
if (pe->PredFlags & ProfiledPredFlag) {
|
||||
LOCK(pe->StatisticsForPred->lock);
|
||||
|
||||
pe->StatisticsForPred->NOfEntries++;
|
||||
UNLOCK(pe->StatisticsForPred->lock);
|
||||
}
|
||||
|
@ -3725,7 +3790,7 @@ static Int p_heap_space_info(USES_REGS1) {
|
|||
* This is called when we are erasing a data base clause, because we may have
|
||||
* pending references
|
||||
*/
|
||||
static void ErasePendingRefs(DBTerm *entryref USES_REGS) {
|
||||
static void ErasePendingRefs(const DBTerm *entryref USES_REGS) {
|
||||
DBRef *cp;
|
||||
DBRef ref;
|
||||
|
||||
|
@ -3886,11 +3951,11 @@ static void complete_lu_erase(LogUpdClause *clau) {
|
|||
|
||||
static void EraseLogUpdCl(LogUpdClause *clau) {
|
||||
PredEntry *ap;
|
||||
|
||||
ap = clau->ClPred;
|
||||
/* no need to erase what has been erased */
|
||||
if (!(clau->ClFlags & ErasedMask)) {
|
||||
/* get ourselves out of the list */
|
||||
clau->ClFlags |= ErasedMask;
|
||||
/* get ourselves out of the list */
|
||||
if (clau->ClNext != NULL) {
|
||||
clau->ClNext->ClPrev = clau->ClPrev;
|
||||
}
|
||||
|
@ -3912,9 +3977,9 @@ static void EraseLogUpdCl(LogUpdClause *clau) {
|
|||
ap->cs.p_code.LastClause = clau->ClPrev->ClCode;
|
||||
}
|
||||
}
|
||||
clau->ClTimeEnd = ap->TimeStampOfPred;
|
||||
ap->cs.p_code.NOfClauses--;
|
||||
}
|
||||
clau->ClFlags |= ErasedMask;
|
||||
#ifndef THREADS
|
||||
{
|
||||
LogUpdClause *er_head = DBErasedList;
|
||||
|
@ -3936,7 +4001,7 @@ static void EraseLogUpdCl(LogUpdClause *clau) {
|
|||
if (ap->cs.p_code.NOfClauses > 1) {
|
||||
if (ap->TimeStampOfPred >= TIMESTAMP_RESET)
|
||||
Yap_UpdateTimestamps(ap);
|
||||
++ap->TimeStampOfPred;
|
||||
++(ap->TimeStampOfPred);
|
||||
/* fprintf(stderr,"-
|
||||
* %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/
|
||||
ap->LastCallOfPred = LUCALL_RETRACT;
|
||||
|
@ -3953,7 +4018,7 @@ static void EraseLogUpdCl(LogUpdClause *clau) {
|
|||
ap->LastCallOfPred = LUCALL_ASSERT;
|
||||
}
|
||||
}
|
||||
clau->ClTimeEnd = ap->TimeStampOfPred;
|
||||
//clau->ClTimeEnd = ap->TimeStampOfPred;
|
||||
Yap_RemoveClauseFromIndex(ap, clau->ClCode);
|
||||
/* release the extra reference */
|
||||
}
|
||||
|
@ -4857,17 +4922,21 @@ static Int cont_current_key_integer(USES_REGS1) {
|
|||
return Yap_unify(term, ARG1) && Yap_unify(term, ARG2);
|
||||
}
|
||||
|
||||
Term Yap_FetchTermFromDB(DBTerm *ref) {
|
||||
Term Yap_FetchTermFromDB(const void *ref) {
|
||||
CACHE_REGS
|
||||
if (ref == NULL)
|
||||
return 0;
|
||||
return GetDBTerm(ref, FALSE PASS_REGS);
|
||||
}
|
||||
|
||||
Term Yap_FetchClauseTermFromDB(DBTerm *ref) {
|
||||
Term Yap_FetchClauseTermFromDB(const void *ref) {
|
||||
CACHE_REGS
|
||||
if (ref == NULL)
|
||||
return 0;
|
||||
return GetDBTerm(ref, TRUE PASS_REGS);
|
||||
}
|
||||
|
||||
Term Yap_PopTermFromDB(DBTerm *ref) {
|
||||
Term Yap_PopTermFromDB(const void *ref) {
|
||||
CACHE_REGS
|
||||
|
||||
Term t = GetDBTerm(ref, FALSE PASS_REGS);
|
||||
|
@ -4881,7 +4950,6 @@ static DBTerm *StoreTermInDB(Term t, int nargs USES_REGS) {
|
|||
int needs_vars;
|
||||
struct db_globs dbg;
|
||||
|
||||
LOCAL_s_dbg = &dbg;
|
||||
LOCAL_Error_Size = 0;
|
||||
while ((x = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, InQueue, &needs_vars, 0,
|
||||
&dbg)) == NULL) {
|
||||
|
@ -4912,7 +4980,6 @@ DBTerm *Yap_StoreTermInDBPlusExtraSpace(Term t, UInt extra_size, UInt *sz) {
|
|||
struct db_globs dbg;
|
||||
DBTerm *o;
|
||||
|
||||
LOCAL_s_dbg = &dbg;
|
||||
o = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, InQueue, &needs_vars,
|
||||
extra_size, &dbg);
|
||||
*sz = dbg.sz;
|
||||
|
@ -5085,7 +5152,7 @@ static Int p_enqueue_unlocked(USES_REGS1) {
|
|||
entry itself is still accessible from a trail entry, so we could not remove
|
||||
the target entry,
|
||||
*/
|
||||
static void keepdbrefs(DBTerm *entryref USES_REGS) {
|
||||
static void keepdbrefs (const DBTerm *entryref USES_REGS) {
|
||||
DBRef *cp;
|
||||
DBRef ref;
|
||||
|
||||
|
@ -5244,7 +5311,7 @@ static Int p_resize_int_keys(USES_REGS1) {
|
|||
return resize_int_keys(IntegerOfTerm(t1));
|
||||
}
|
||||
|
||||
static void ReleaseTermFromDB(DBTerm *ref USES_REGS) {
|
||||
static void ReleaseTermFromDB(const DBTerm *ref USES_REGS) {
|
||||
if (!ref)
|
||||
return;
|
||||
keepdbrefs(ref PASS_REGS);
|
||||
|
@ -5252,7 +5319,7 @@ static void ReleaseTermFromDB(DBTerm *ref USES_REGS) {
|
|||
FreeDBSpace((char *)ref);
|
||||
}
|
||||
|
||||
void Yap_ReleaseTermFromDB(DBTerm *ref) {
|
||||
void Yap_ReleaseTermFromDB(const void *ref) {
|
||||
CACHE_REGS
|
||||
ReleaseTermFromDB(ref PASS_REGS);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,459 @@
|
|||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: cdmgr.c *
|
||||
* comments: Code manager *
|
||||
* *
|
||||
* Last rev: $Date: 2008-07-22 23:34:44 $,$Author: vsc $ 8
|
||||
*************************************************************************/
|
||||
|
||||
#include "Yap.h"
|
||||
#include "YapEval.h"
|
||||
#include "clause.h"
|
||||
#include "tracer.h"
|
||||
#include "yapio.h"
|
||||
|
||||
#include <Yatom.h>
|
||||
#include <assert.h>
|
||||
#include <heapgc.h>
|
||||
#include <iopreds.h>
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
static UInt total_megaclause, total_released, nof_megaclauses;
|
||||
#endif
|
||||
|
||||
/******************************************************************
|
||||
|
||||
Mega Clauses
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#define OrArgAdjust(P)
|
||||
#define TabEntryAdjust(P)
|
||||
#define DoubleInCodeAdjust(D)
|
||||
#define IntegerInCodeAdjust(D)
|
||||
#define IntegerAdjust(D) (D)
|
||||
#define PtoPredAdjust(X) (X)
|
||||
#define PtoOpAdjust(X) (X)
|
||||
#define PtoLUClauseAdjust(P) (P)
|
||||
#define PtoLUIndexAdjust(P) (P)
|
||||
#define XAdjust(X) (X)
|
||||
#define YAdjust(X) (X)
|
||||
#define AtomTermAdjust(X) (X)
|
||||
#define CellPtoHeapAdjust(X) (X)
|
||||
#define FuncAdjust(X) (X)
|
||||
#define CodeAddrAdjust(X) (X)
|
||||
#define CodeComposedTermAdjust(X) (X)
|
||||
#define ConstantAdjust(X) (X)
|
||||
#define ArityAdjust(X) (X)
|
||||
#define OpcodeAdjust(X) (X)
|
||||
#define ModuleAdjust(X) (X)
|
||||
#define ExternalFunctionAdjust(X) (X)
|
||||
#define AdjustSwitchTable(X, Y, Z)
|
||||
#define DBGroundTermAdjust(X) (X)
|
||||
#define rehash(A, B, C)
|
||||
|
||||
static Term BlobTermInCodeAdjust(Term t) {
|
||||
CACHE_REGS
|
||||
#if TAGS_FAST_OPS
|
||||
return t - LOCAL_ClDiff;
|
||||
#else
|
||||
return t + LOCAL_ClDiff;
|
||||
#endif
|
||||
}
|
||||
|
||||
static Term ConstantTermAdjust(Term t) {
|
||||
if (IsAtomTerm(t))
|
||||
return AtomTermAdjust(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
#include "rclause.h"
|
||||
|
||||
|
||||
void Yap_BuildMegaClause(PredEntry *ap) {
|
||||
CACHE_REGS
|
||||
StaticClause *cl;
|
||||
UInt sz;
|
||||
MegaClause *mcl;
|
||||
yamop *ptr;
|
||||
size_t required;
|
||||
UInt has_blobs = 0;
|
||||
|
||||
if (ap->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MegaClausePredFlag
|
||||
#ifdef TABLING
|
||||
| TabledPredFlag
|
||||
#endif /* TABLING */
|
||||
| UDIPredFlag) ||
|
||||
ap->cs.p_code.FirstClause == NULL || ap->cs.p_code.NOfClauses < 16) {
|
||||
return;
|
||||
}
|
||||
cl = ClauseCodeToStaticClause(ap->cs.p_code.FirstClause);
|
||||
sz = cl->ClSize;
|
||||
while (TRUE) {
|
||||
if (!(cl->ClFlags & FactMask))
|
||||
return; /* no mega clause, sorry */
|
||||
if (cl->ClSize != sz)
|
||||
return; /* no mega clause, sorry */
|
||||
if (cl->ClCode == ap->cs.p_code.LastClause)
|
||||
break;
|
||||
has_blobs |= (cl->ClFlags & HasBlobsMask);
|
||||
cl = cl->ClNext;
|
||||
}
|
||||
/* ok, we got the chance for a mega clause */
|
||||
if (has_blobs) {
|
||||
sz -= sizeof(StaticClause);
|
||||
} else {
|
||||
sz -= (UInt)NEXTOP((yamop *)NULL, p) + sizeof(StaticClause);
|
||||
}
|
||||
required = sz * ap->cs.p_code.NOfClauses + sizeof(MegaClause) +
|
||||
(UInt)NEXTOP((yamop *)NULL, l);
|
||||
while (!(mcl = (MegaClause *)Yap_AllocCodeSpace(required))) {
|
||||
if (!Yap_growheap(FALSE, required, NULL)) {
|
||||
/* just fail, the system will keep on going */
|
||||
return;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
total_megaclause += required;
|
||||
cl = ClauseCodeToStaticClause(ap->cs.p_code.FirstClause);
|
||||
total_released += ap->cs.p_code.NOfClauses * cl->ClSize;
|
||||
nof_megaclauses++;
|
||||
#endif
|
||||
Yap_ClauseSpace += required;
|
||||
/* cool, it's our turn to do the conversion */
|
||||
mcl->ClFlags = MegaMask | has_blobs;
|
||||
mcl->ClSize = required;
|
||||
mcl->ClPred = ap;
|
||||
mcl->ClItemSize = sz;
|
||||
mcl->ClNext = NULL;
|
||||
cl = ClauseCodeToStaticClause(ap->cs.p_code.FirstClause);
|
||||
mcl->ClLine = cl->usc.ClLine;
|
||||
ptr = mcl->ClCode;
|
||||
while (TRUE) {
|
||||
memmove((void *)ptr, (void *)cl->ClCode, sz);
|
||||
if (has_blobs) {
|
||||
LOCAL_ClDiff = (char *)(ptr) - (char *)cl->ClCode;
|
||||
restore_opcodes(ptr, NULL PASS_REGS);
|
||||
}
|
||||
ptr = (yamop *)((char *)ptr + sz);
|
||||
if (cl->ClCode == ap->cs.p_code.LastClause)
|
||||
break;
|
||||
cl = cl->ClNext;
|
||||
}
|
||||
ptr->opc = Yap_opcode(_Ystop);
|
||||
cl = ClauseCodeToStaticClause(ap->cs.p_code.FirstClause);
|
||||
/* recover the space spent on the original clauses */
|
||||
while (TRUE) {
|
||||
StaticClause *ncl, *curcl = cl;
|
||||
|
||||
ncl = cl->ClNext;
|
||||
Yap_InformOfRemoval(cl);
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((ADDR)cl);
|
||||
if (curcl->ClCode == ap->cs.p_code.LastClause)
|
||||
break;
|
||||
cl = ncl;
|
||||
}
|
||||
ap->cs.p_code.FirstClause = ap->cs.p_code.LastClause = mcl->ClCode;
|
||||
ap->PredFlags |= MegaClausePredFlag;
|
||||
Yap_inform_profiler_of_clause(mcl, (char *)mcl + required, ap, GPROF_MEGA);
|
||||
}
|
||||
|
||||
void Yap_split_megaclause(PredEntry *ap) {
|
||||
StaticClause *start = NULL, *prev = NULL;
|
||||
MegaClause *mcl;
|
||||
yamop *ptr;
|
||||
UInt ncls = ap->cs.p_code.NOfClauses, i;
|
||||
|
||||
mcl = ClauseCodeToMegaClause(ap->cs.p_code.FirstClause);
|
||||
if (mcl->ClFlags & ExoMask) {
|
||||
Yap_Error(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, Yap_PredicateToIndicator(ap),
|
||||
"while deleting clause from exo predicate %s/%d\n",
|
||||
RepAtom(NameOfFunctor(ap->FunctorOfPred))->StrOfAE,
|
||||
ap->ArityOfPE);
|
||||
return;
|
||||
}
|
||||
for (i = 0, ptr = mcl->ClCode; i < ncls; i++) {
|
||||
StaticClause *new = (StaticClause *)Yap_AllocCodeSpace(
|
||||
sizeof(StaticClause) + mcl->ClItemSize +
|
||||
(UInt)NEXTOP((yamop *)NULL, p));
|
||||
if (new == NULL) {
|
||||
if (!Yap_growheap(FALSE,
|
||||
(sizeof(StaticClause) + mcl->ClItemSize) * (ncls - i),
|
||||
NULL)) {
|
||||
while (start) {
|
||||
StaticClause *cl = start;
|
||||
start = cl->ClNext;
|
||||
Yap_InformOfRemoval(cl);
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)cl);
|
||||
}
|
||||
if (ap->ArityOfPE) {
|
||||
Yap_Error(RESOURCE_ERROR_HEAP, TermNil,
|
||||
"while breaking up mega clause for %s/%d\n",
|
||||
RepAtom(NameOfFunctor(ap->FunctorOfPred))->StrOfAE,
|
||||
ap->ArityOfPE);
|
||||
} else {
|
||||
Yap_Error(RESOURCE_ERROR_HEAP, TermNil,
|
||||
"while breaking up mega clause for %s\n",
|
||||
RepAtom((Atom)ap->FunctorOfPred)->StrOfAE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Yap_ClauseSpace +=
|
||||
sizeof(StaticClause) + mcl->ClItemSize + (UInt)NEXTOP((yamop *)NULL, p);
|
||||
new->ClFlags = StaticMask | FactMask;
|
||||
new->ClSize = mcl->ClItemSize;
|
||||
new->usc.ClLine = Yap_source_line_no();
|
||||
new->ClNext = NULL;
|
||||
memmove((void *)new->ClCode, (void *)ptr, mcl->ClItemSize);
|
||||
if (prev) {
|
||||
prev->ClNext = new;
|
||||
} else {
|
||||
start = new;
|
||||
}
|
||||
ptr = (yamop *)((char *)ptr + mcl->ClItemSize);
|
||||
prev = new;
|
||||
}
|
||||
ap->PredFlags &= ~MegaClausePredFlag;
|
||||
ap->cs.p_code.FirstClause = start->ClCode;
|
||||
ap->cs.p_code.LastClause = prev->ClCode;
|
||||
}
|
||||
|
||||
|
||||
static UInt compute_dbcl_size(arity_t arity) {
|
||||
UInt sz;
|
||||
switch (arity) {
|
||||
case 2:
|
||||
sz = (UInt)NEXTOP((yamop *)NULL, cc);
|
||||
break;
|
||||
case 3:
|
||||
sz = (UInt)NEXTOP((yamop *)NULL, ccc);
|
||||
break;
|
||||
case 4:
|
||||
sz = (UInt)NEXTOP((yamop *)NULL, cccc);
|
||||
break;
|
||||
case 5:
|
||||
sz = (UInt)NEXTOP((yamop *)NULL, ccccc);
|
||||
break;
|
||||
case 6:
|
||||
sz = (UInt)NEXTOP((yamop *)NULL, cccccc);
|
||||
break;
|
||||
default:
|
||||
sz = arity * (UInt)NEXTOP((yamop *)NULL, xc);
|
||||
break;
|
||||
}
|
||||
return (UInt)NEXTOP((yamop *)sz, p);
|
||||
}
|
||||
|
||||
#define DerefAndCheck(t, V) \
|
||||
t = Deref(V); \
|
||||
if (IsVarTerm(t) || !(IsAtomOrIntTerm(t))) \
|
||||
Yap_Error(TYPE_ERROR_ATOM, t0, "load_db");
|
||||
|
||||
static int store_dbcl_size(yamop *pc, arity_t arity, Term t0, PredEntry *pe) {
|
||||
Term t;
|
||||
CELL *tp = RepAppl(t0) + 1;
|
||||
switch (arity) {
|
||||
case 2:
|
||||
pc->opc = Yap_opcode(_get_2atoms);
|
||||
DerefAndCheck(t, tp[0]);
|
||||
pc->y_u.cc.c1 = t;
|
||||
DerefAndCheck(t, tp[1]);
|
||||
pc->y_u.cc.c2 = t;
|
||||
pc = NEXTOP(pc, cc);
|
||||
break;
|
||||
case 3:
|
||||
pc->opc = Yap_opcode(_get_3atoms);
|
||||
DerefAndCheck(t, tp[0]);
|
||||
pc->y_u.ccc.c1 = t;
|
||||
DerefAndCheck(t, tp[1]);
|
||||
pc->y_u.ccc.c2 = t;
|
||||
DerefAndCheck(t, tp[2]);
|
||||
pc->y_u.ccc.c3 = t;
|
||||
pc = NEXTOP(pc, ccc);
|
||||
break;
|
||||
case 4:
|
||||
pc->opc = Yap_opcode(_get_4atoms);
|
||||
DerefAndCheck(t, tp[0]);
|
||||
pc->y_u.cccc.c1 = t;
|
||||
DerefAndCheck(t, tp[1]);
|
||||
pc->y_u.cccc.c2 = t;
|
||||
DerefAndCheck(t, tp[2]);
|
||||
pc->y_u.cccc.c3 = t;
|
||||
DerefAndCheck(t, tp[3]);
|
||||
pc->y_u.cccc.c4 = t;
|
||||
pc = NEXTOP(pc, cccc);
|
||||
break;
|
||||
case 5:
|
||||
pc->opc = Yap_opcode(_get_5atoms);
|
||||
DerefAndCheck(t, tp[0]);
|
||||
pc->y_u.ccccc.c1 = t;
|
||||
DerefAndCheck(t, tp[1]);
|
||||
pc->y_u.ccccc.c2 = t;
|
||||
DerefAndCheck(t, tp[2]);
|
||||
pc->y_u.ccccc.c3 = t;
|
||||
DerefAndCheck(t, tp[3]);
|
||||
pc->y_u.ccccc.c4 = t;
|
||||
DerefAndCheck(t, tp[4]);
|
||||
pc->y_u.ccccc.c5 = t;
|
||||
pc = NEXTOP(pc, ccccc);
|
||||
break;
|
||||
case 6:
|
||||
pc->opc = Yap_opcode(_get_6atoms);
|
||||
DerefAndCheck(t, tp[0]);
|
||||
pc->y_u.cccccc.c1 = t;
|
||||
DerefAndCheck(t, tp[1]);
|
||||
pc->y_u.cccccc.c2 = t;
|
||||
DerefAndCheck(t, tp[2]);
|
||||
pc->y_u.cccccc.c3 = t;
|
||||
DerefAndCheck(t, tp[3]);
|
||||
pc->y_u.cccccc.c4 = t;
|
||||
DerefAndCheck(t, tp[4]);
|
||||
pc->y_u.cccccc.c5 = t;
|
||||
DerefAndCheck(t, tp[5]);
|
||||
pc->y_u.cccccc.c6 = t;
|
||||
pc = NEXTOP(pc, cccccc);
|
||||
break;
|
||||
default: {
|
||||
arity_t i;
|
||||
for (i = 0; i < arity; i++) {
|
||||
pc->opc = Yap_opcode(_get_atom);
|
||||
#if PRECOMPUTE_REGADDRESS
|
||||
pc->y_u.xc.x = (CELL)(XREGS + (i + 1));
|
||||
#else
|
||||
pc->y_u.xc.x = i + 1;
|
||||
#endif
|
||||
DerefAndCheck(t, tp[0]);
|
||||
pc->y_u.xc.c = t;
|
||||
tp++;
|
||||
pc = NEXTOP(pc, xc);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
pc->opc = Yap_opcode(_procceed);
|
||||
pc->y_u.p.p = pe;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_dbload_get_space(USES_REGS1) { /* '$number_of_clauses'(Predicate,M,N) */
|
||||
Term t = Deref(ARG1);
|
||||
Term mod = Deref(ARG2);
|
||||
Term tn = Deref(ARG3);
|
||||
arity_t arity;
|
||||
Prop pe;
|
||||
PredEntry *ap;
|
||||
UInt sz;
|
||||
MegaClause *mcl;
|
||||
yamop *ptr;
|
||||
UInt ncls;
|
||||
UInt required;
|
||||
|
||||
if (IsVarTerm(mod) || !IsAtomTerm(mod)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom a = AtomOfTerm(t);
|
||||
arity = 0;
|
||||
pe = PredPropByAtom(a, mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
register Functor f = FunctorOfTerm(t);
|
||||
arity = ArityOfFunctor(f);
|
||||
pe = PredPropByFunc(f, mod);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
if (EndOfPAEntr(pe))
|
||||
return FALSE;
|
||||
ap = RepPredProp(pe);
|
||||
if (ap->PredFlags & (DynamicPredFlag | LogUpdatePredFlag
|
||||
#ifdef TABLING
|
||||
| TabledPredFlag
|
||||
#endif /* TABLING */
|
||||
)) {
|
||||
Yap_Error(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, Yap_PredicateToIndicator(ap),
|
||||
"dbload_get_space/4");
|
||||
return FALSE;
|
||||
}
|
||||
if (IsVarTerm(tn) || !IsIntegerTerm(tn)) {
|
||||
return FALSE;
|
||||
}
|
||||
ncls = IntegerOfTerm(tn);
|
||||
if (ncls <= 1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sz = compute_dbcl_size(arity);
|
||||
required = sz * ncls + sizeof(MegaClause) + (UInt)NEXTOP((yamop *)NULL, l);
|
||||
#ifdef DEBUG
|
||||
total_megaclause += required;
|
||||
nof_megaclauses++;
|
||||
#endif
|
||||
while (!(mcl = (MegaClause *)Yap_AllocCodeSpace(required))) {
|
||||
if (!Yap_growheap(FALSE, required, NULL)) {
|
||||
/* just fail, the system will keep on going */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
Yap_ClauseSpace += required;
|
||||
/* cool, it's our turn to do the conversion */
|
||||
mcl->ClFlags = MegaMask;
|
||||
mcl->ClSize = sz * ncls;
|
||||
mcl->ClPred = ap;
|
||||
mcl->ClItemSize = sz;
|
||||
mcl->ClNext = NULL;
|
||||
ap->cs.p_code.FirstClause = ap->cs.p_code.LastClause = mcl->ClCode;
|
||||
ap->PredFlags |= (MegaClausePredFlag);
|
||||
ap->cs.p_code.NOfClauses = ncls;
|
||||
if (ap->PredFlags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) {
|
||||
ap->OpcodeOfPred = Yap_opcode(_spy_pred);
|
||||
} else {
|
||||
ap->OpcodeOfPred = INDEX_OPCODE;
|
||||
}
|
||||
ap->CodeOfPred = ap->cs.p_code.TrueCodeOfPred =
|
||||
(yamop *)(&(ap->OpcodeOfPred));
|
||||
ptr = (yamop *)((ADDR)mcl->ClCode + ncls * sz);
|
||||
ptr->opc = Yap_opcode(_Ystop);
|
||||
return Yap_unify(ARG4, MkIntegerTerm((Int)mcl));
|
||||
}
|
||||
|
||||
static Int p_dbassert(USES_REGS1) { /* '$number_of_clauses'(Predicate,M,N) */
|
||||
Term thandle = Deref(ARG2);
|
||||
Term tn = Deref(ARG3);
|
||||
PredEntry *pe;
|
||||
MegaClause *mcl;
|
||||
Int n;
|
||||
|
||||
if (IsVarTerm(thandle) || !IsIntegerTerm(thandle)) {
|
||||
return FALSE;
|
||||
}
|
||||
mcl = (MegaClause *)IntegerOfTerm(thandle);
|
||||
if (IsVarTerm(tn) || !IsIntegerTerm(tn)) {
|
||||
return FALSE;
|
||||
}
|
||||
n = IntegerOfTerm(tn);
|
||||
pe = mcl->ClPred;
|
||||
return store_dbcl_size((yamop *)((ADDR)mcl->ClCode + n * (mcl->ClItemSize)),
|
||||
pe->ArityOfPE, Deref(ARG1), pe);
|
||||
}
|
||||
|
||||
void Yap_InitDBLoadPreds(void) {
|
||||
CACHE_REGS
|
||||
//CurrentModule = DBLOAD_MODULE;
|
||||
Yap_InitCPred("$dbload_get_space", 4, p_dbload_get_space, 0L);
|
||||
Yap_InitCPred("$dbassert", 3, p_dbassert, 0L);
|
||||
//CurrentModule = cm;
|
||||
}
|
|
@ -22,7 +22,7 @@ static char SccsId[] = "%W% %G%";
|
|||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
|
||||
|
|
|
@ -1978,7 +1978,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||
assert(ncopies >= 3);
|
||||
|
||||
if (ncopies > 9)
|
||||
memcpy(d, s, copysize);
|
||||
memmove(d, s, copysize);
|
||||
|
||||
else {
|
||||
*(d+0) = *(s+0);
|
||||
|
@ -2077,7 +2077,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||
/* Must alloc, copy, free. */
|
||||
newmem = mALLOc(nb - MALLOC_ALIGN_MASK);
|
||||
if (newmem != 0) {
|
||||
memcpy(newmem, oldmem, oldsize - 2*SIZE_SZ);
|
||||
memmove(newmem, oldmem, oldsize - 2*SIZE_SZ);
|
||||
fREe(oldmem);
|
||||
}
|
||||
}
|
||||
|
|
1496
C/errors.c
1496
C/errors.c
File diff suppressed because it is too large
Load Diff
399
C/eval.c
399
C/eval.c
|
@ -15,24 +15,34 @@
|
|||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
/**
|
||||
* @file eval.c
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Mon Apr 30 09:37:59 2018
|
||||
*
|
||||
* @brief is/2
|
||||
*
|
||||
*
|
||||
* @namespace prolog
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
//! @file eval.c
|
||||
|
||||
//! @{
|
||||
//! @{
|
||||
|
||||
/**
|
||||
@defgroup arithmetic_preds Arithmetic Predicates
|
||||
@ingroup arithmetic
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapEval.h"
|
||||
#if HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
@ -46,41 +56,39 @@ static char SccsId[] = "%W% %G%";
|
|||
|
||||
static Term Eval(Term t1 USES_REGS);
|
||||
|
||||
static Term
|
||||
get_matrix_element(Term t1, Term t2 USES_REGS)
|
||||
{
|
||||
static Term get_matrix_element(Term t1, Term t2 USES_REGS) {
|
||||
if (!IsPairTerm(t2)) {
|
||||
if (t2 == MkAtomTerm(AtomLength)) {
|
||||
Int sz = 1;
|
||||
while (IsApplTerm(t1)) {
|
||||
Functor f = FunctorOfTerm(t1);
|
||||
if (NameOfFunctor(f) != AtomNil) {
|
||||
return MkIntegerTerm(sz);
|
||||
}
|
||||
sz *= ArityOfFunctor(f);
|
||||
t1 = ArgOfTerm(1, t1);
|
||||
Functor f = FunctorOfTerm(t1);
|
||||
if (NameOfFunctor(f) != AtomNil) {
|
||||
return MkIntegerTerm(sz);
|
||||
}
|
||||
sz *= ArityOfFunctor(f);
|
||||
t1 = ArgOfTerm(1, t1);
|
||||
}
|
||||
return MkIntegerTerm(sz);
|
||||
}
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t2, "X is Y^[A]");
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
while (IsPairTerm(t2)) {
|
||||
Int indx;
|
||||
Term indxt = Eval(HeadOfTerm(t2) PASS_REGS);
|
||||
if (!IsIntegerTerm(indxt)) {
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t2, "X is Y^[A]");
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
indx = IntegerOfTerm(indxt);
|
||||
if (!IsApplTerm(t1)) {
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t1, "X is Y^[A]");
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
} else {
|
||||
Functor f = FunctorOfTerm(t1);
|
||||
if (ArityOfFunctor(f) < indx) {
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t1, "X is Y^[A]");
|
||||
return FALSE;
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t1, "X is Y^[A]");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
t1 = ArgOfTerm(indx, t1);
|
||||
|
@ -93,95 +101,93 @@ get_matrix_element(Term t1, Term t2 USES_REGS)
|
|||
return Eval(t1 PASS_REGS);
|
||||
}
|
||||
|
||||
static Term
|
||||
Eval(Term t USES_REGS)
|
||||
{
|
||||
static Term Eval(Term t USES_REGS) {
|
||||
eval_context_t ctx;
|
||||
ctx.p = LOCAL_ctx;
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
return Yap_ArithError(INSTANTIATION_ERROR,t,"in arithmetic");
|
||||
Yap_ArithError(INSTANTIATION_ERROR, t, "in arithmetic");
|
||||
} else if (IsNumTerm(t)) {
|
||||
return t;
|
||||
} else if (IsAtomTerm(t)) {
|
||||
ExpEntry *p;
|
||||
Atom name = AtomOfTerm(t);
|
||||
Atom name = AtomOfTerm(t);
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 0)))) {
|
||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, takeIndicator(t),
|
||||
"atom %s in arithmetic expression",
|
||||
RepAtom(name)->StrOfAE);
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, takeIndicator(t),
|
||||
"atom %s in arithmetic expression",
|
||||
RepAtom(name)->StrOfAE);
|
||||
}
|
||||
return Yap_eval_atom(p->FOfEE);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
if (fun == FunctorString) {
|
||||
const char *s = (const char*)StringOfTerm(t);
|
||||
const char *s = (const char *)StringOfTerm(t);
|
||||
if (s[1] == '\0')
|
||||
return MkIntegerTerm(s[0]);
|
||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||
"string in arithmetic expression");
|
||||
return MkIntegerTerm(s[0]);
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||
"string in arithmetic expression");
|
||||
} else if ((Atom)fun == AtomFoundVar) {
|
||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil,
|
||||
"cyclic term in arithmetic expression");
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil,
|
||||
"cyclic term in arithmetic expression");
|
||||
} else {
|
||||
Int n = ArityOfFunctor(fun);
|
||||
Atom name = NameOfFunctor(fun);
|
||||
Atom name = NameOfFunctor(fun);
|
||||
ExpEntry *p;
|
||||
Term t1, t2;
|
||||
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, n)))) {
|
||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, takeIndicator(t),
|
||||
"functor %s/%d for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE,n);
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, takeIndicator(t),
|
||||
"functor %s/%d for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE, n);
|
||||
}
|
||||
if (p->FOfEE == op_power && p->ArityOfEE == 2) {
|
||||
t2 = ArgOfTerm(2, t);
|
||||
if (IsPairTerm(t2)) {
|
||||
return get_matrix_element(ArgOfTerm(1, t), t2 PASS_REGS);
|
||||
}
|
||||
t2 = ArgOfTerm(2, t);
|
||||
if (IsPairTerm(t2)) {
|
||||
return get_matrix_element(ArgOfTerm(1, t), t2 PASS_REGS);
|
||||
}
|
||||
}
|
||||
ctx.f = fun;
|
||||
ctx.fp = RepAppl(t);
|
||||
LOCAL_ctx = &ctx;
|
||||
*RepAppl(t) = (CELL)AtomFoundVar;
|
||||
t1 = Eval(ArgOfTerm(1,t) PASS_REGS);
|
||||
if (t1 == 0L) {
|
||||
*RepAppl(t) = (CELL)fun;
|
||||
return FALSE;
|
||||
}
|
||||
t1 = Eval(ArgOfTerm(1, t) PASS_REGS);
|
||||
if (n == 1) {
|
||||
*RepAppl(t) = (CELL)fun;
|
||||
return Yap_eval_unary(p->FOfEE, t1);
|
||||
*RepAppl(t) = (CELL)fun;
|
||||
LOCAL_ctx = ctx.p;
|
||||
return Yap_eval_unary(p->FOfEE, t1);
|
||||
}
|
||||
t2 = Eval(ArgOfTerm(2,t) PASS_REGS);
|
||||
t2 = Eval(ArgOfTerm(2, t) PASS_REGS);
|
||||
*RepAppl(t) = (CELL)fun;
|
||||
if (t2 == 0L)
|
||||
return FALSE;
|
||||
return Yap_eval_binary(p->FOfEE,t1,t2);
|
||||
LOCAL_ctx = ctx.p;
|
||||
return Yap_eval_binary(p->FOfEE, t1, t2);
|
||||
}
|
||||
} /* else if (IsPairTerm(t)) */ {
|
||||
} /* else if (IsPairTerm(t)) */
|
||||
{
|
||||
if (TailOfTerm(t) != TermNil) {
|
||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||
"string must contain a single character to be evaluated as an arithmetic expression");
|
||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||
"string must contain a single character to be "
|
||||
"evaluated as an arithmetic expression");
|
||||
}
|
||||
return Eval(HeadOfTerm(t) PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_InnerEval__(Term t USES_REGS)
|
||||
{
|
||||
Term Yap_InnerEval__(Term t USES_REGS) {
|
||||
return Eval(t PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BEAM
|
||||
Int BEAM_is(void);
|
||||
|
||||
Int
|
||||
BEAM_is(void)
|
||||
{ /* X is Y */
|
||||
Int BEAM_is(void) { /* X is Y */
|
||||
union arith_ret res;
|
||||
blob_type bt;
|
||||
|
||||
bt = Eval(Deref(XREGS[2]), &res);
|
||||
if (bt==db_ref_e) return (NULL);
|
||||
return (EvalToTerm(bt,&res));
|
||||
if (bt == db_ref_e)
|
||||
return (NULL);
|
||||
return (EvalToTerm(bt, &res));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -197,39 +203,26 @@ X is 2+3*4
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
succeeds with `X = 14`.
|
||||
|
||||
Consult @ref arithmetic_operators for the complete list of arithmetic_operators
|
||||
Consult @ref arithmetic_operators for the complete list of
|
||||
arithmetic_operators
|
||||
|
||||
*/
|
||||
|
||||
/// @memberof is/2
|
||||
static Int
|
||||
p_is( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term out;
|
||||
yap_error_number err;
|
||||
|
||||
static Int p_is(USES_REGS1) { /* X is Y */
|
||||
Term out = TermNil;
|
||||
bool go;
|
||||
Term t = Deref(ARG2);
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_EvalError(INSTANTIATION_ERROR,t, "X is Y");
|
||||
return(FALSE);
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, t, "var(Y) in X is Y");
|
||||
return (FALSE);
|
||||
}
|
||||
Yap_ClearExs();
|
||||
do {
|
||||
out = Yap_InnerEval(Deref(ARG2));
|
||||
if ((err = Yap_FoundArithError()) == YAP_NO_ERROR)
|
||||
break;
|
||||
if (err == RESOURCE_ERROR_STACK) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
|
||||
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
Yap_EvalError(err, takeIndicator( ARG2 ), "X is Exp");
|
||||
return FALSE;
|
||||
}
|
||||
} while (TRUE);
|
||||
return Yap_unify_constant(ARG1,out);
|
||||
go = false;
|
||||
out = Yap_Eval(t PASS_REGS);
|
||||
go = Yap_CheckArithError();
|
||||
} while (go);
|
||||
return Yap_unify_constant(ARG1, out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,20 +232,18 @@ p_is( USES_REGS1 )
|
|||
*/
|
||||
|
||||
/// @memberof isnan/1
|
||||
static Int
|
||||
p_isnan( USES_REGS1 )
|
||||
{ /* X isnan Y */
|
||||
static Int p_isnan(USES_REGS1) { /* X isnan Y */
|
||||
Term out = 0L;
|
||||
|
||||
|
||||
while (!(out = Eval(Deref(ARG1) PASS_REGS))) {
|
||||
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, CP)) {
|
||||
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
Yap_EvalError(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_EvalError(LOCAL_Error_TYPE, ARG1, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -268,15 +259,13 @@ p_isnan( USES_REGS1 )
|
|||
}
|
||||
|
||||
/**
|
||||
@pred isinf(? X:float) is det</b>
|
||||
@pred isinf(? X:float) is det
|
||||
|
||||
Interface to the IEE754 `isinf` test.
|
||||
*/
|
||||
|
||||
/// @memberof isnan/1
|
||||
static Int
|
||||
p_isinf( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
static Int p_isinf(USES_REGS1) { /* X is Y */
|
||||
Term out = 0L;
|
||||
|
||||
while (!(out = Eval(Deref(ARG1) PASS_REGS))) {
|
||||
|
@ -287,7 +276,7 @@ p_isinf( USES_REGS1 )
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
Yap_EvalError(LOCAL_Error_TYPE, ARG1, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -312,14 +301,12 @@ True if _Log1_ is the logarithm of the positive number _A1_,
|
|||
*/
|
||||
|
||||
/// @memberof logsum/3
|
||||
static Int
|
||||
p_logsum( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
static Int p_logsum(USES_REGS1) { /* X is Y */
|
||||
Term t1 = Deref(ARG1);
|
||||
Term t2 = Deref(ARG2);
|
||||
int done = FALSE;
|
||||
Float f1, f2;
|
||||
|
||||
|
||||
while (!done) {
|
||||
if (IsFloatTerm(t1)) {
|
||||
f1 = FloatOfTerm(t1);
|
||||
|
@ -334,16 +321,16 @@ p_logsum( USES_REGS1 )
|
|||
#endif
|
||||
} else {
|
||||
while (!(t1 = Eval(t1 PASS_REGS))) {
|
||||
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, CP)) {
|
||||
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, CP)) {
|
||||
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
Yap_EvalError(LOCAL_Error_TYPE, ARG1, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -362,88 +349,47 @@ p_logsum( USES_REGS1 )
|
|||
#endif
|
||||
} else {
|
||||
while (!(t2 = Eval(t2 PASS_REGS))) {
|
||||
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
|
||||
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
|
||||
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
Yap_EvalError(LOCAL_Error_TYPE, ARG1, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f1 >= f2) {
|
||||
Float fi = exp(f2-f1);
|
||||
return Yap_unify(ARG3,MkFloatTerm(f1+log(1+fi)));
|
||||
Float fi = exp(f2 - f1);
|
||||
return Yap_unify(ARG3, MkFloatTerm(f1 + log(1 + fi)));
|
||||
} else {
|
||||
Float fi = exp(f1-f2);
|
||||
return Yap_unify(ARG3,MkFloatTerm(f2+log(1+fi)));
|
||||
Float fi = exp(f1 - f2);
|
||||
return Yap_unify(ARG3, MkFloatTerm(f2 + log(1 + fi)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Int
|
||||
Yap_ArithError__(const char *file, const char *function, int lineno, yap_error_number type, Term where,...)
|
||||
{
|
||||
void Yap_EvalError__(const char *file, const char *function, int lineno,
|
||||
yap_error_number type, Term where, ...) {
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
char *format;
|
||||
|
||||
if (LOCAL_ArithError)
|
||||
return 0L;
|
||||
LOCAL_ArithError = TRUE;
|
||||
LOCAL_Error_TYPE = type;
|
||||
LOCAL_Error_File = file;
|
||||
LOCAL_Error_Function = function;
|
||||
LOCAL_Error_Lineno = lineno;
|
||||
LOCAL_Error_Term = where;
|
||||
if (!LOCAL_ErrorMessage)
|
||||
LOCAL_ErrorMessage = LOCAL_ErrorSay;
|
||||
va_start (ap, where);
|
||||
format = va_arg( ap, char *);
|
||||
if (format != NULL) {
|
||||
#if HAVE_VSNPRINTF
|
||||
(void) vsnprintf(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, format, ap);
|
||||
#else
|
||||
(void) vsprintf(LOCAL_ErrorMessage, format, ap);
|
||||
#endif
|
||||
} else {
|
||||
LOCAL_ErrorMessage[0] = '\0';
|
||||
}
|
||||
va_end (ap);
|
||||
return 0L;
|
||||
}
|
||||
char *format, buf[MAX_ERROR_MSG_SIZE];
|
||||
|
||||
yamop *
|
||||
Yap_EvalError__(const char *file, const char *function, int lineno,yap_error_number type, Term where,...)
|
||||
{
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
char *format;
|
||||
|
||||
if (LOCAL_ArithError) {
|
||||
LOCAL_ArithError = YAP_NO_ERROR;
|
||||
return Yap_Error__(file, function, lineno, LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
}
|
||||
|
||||
if (!LOCAL_ErrorMessage)
|
||||
LOCAL_ErrorMessage = LOCAL_ErrorSay;
|
||||
va_start (ap, where);
|
||||
va_start(ap, where);
|
||||
format = va_arg(ap, char *);
|
||||
if (format != NULL) {
|
||||
#if HAVE_VSNPRINTF
|
||||
(void) vsnprintf(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, format, ap);
|
||||
#if HAVE_VSNPRINTF
|
||||
(void)vsnprintf(buf, MAX_ERROR_MSG_SIZE, format, ap);
|
||||
#else
|
||||
(void) vsprintf(LOCAL_ErrorMessage, format, ap);
|
||||
(void)vsprintf(buf, format, ap);
|
||||
#endif
|
||||
} else {
|
||||
LOCAL_ErrorMessage[0] = '\0';
|
||||
buf[0] = '\0';
|
||||
}
|
||||
va_end (ap);
|
||||
return Yap_Error__(file, function, lineno, type, where, LOCAL_ErrorMessage);
|
||||
va_end(ap);
|
||||
Yap_Error__(false, file, function, lineno, type, where, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -461,11 +407,10 @@ Yap_EvalError__(const char *file, const char *function, int lineno,yap_error_num
|
|||
*/
|
||||
|
||||
/// @memberof between/3
|
||||
static Int cont_between( USES_REGS1 )
|
||||
{
|
||||
Term t1 = EXTRA_CBACK_ARG(3,1);
|
||||
Term t2 = EXTRA_CBACK_ARG(3,2);
|
||||
|
||||
static Int cont_between(USES_REGS1) {
|
||||
Term t1 = EXTRA_CBACK_ARG(3, 1);
|
||||
Term t2 = EXTRA_CBACK_ARG(3, 2);
|
||||
|
||||
Yap_unify(ARG3, t1);
|
||||
if (IsIntegerTerm(t1)) {
|
||||
Int i1;
|
||||
|
@ -475,7 +420,7 @@ static Int cont_between( USES_REGS1 )
|
|||
cut_succeed();
|
||||
i1 = IntegerOfTerm(t1);
|
||||
tn = add_int(i1, 1 PASS_REGS);
|
||||
EXTRA_CBACK_ARG(3,1) = tn;
|
||||
EXTRA_CBACK_ARG(3, 1) = tn;
|
||||
HB = B->cp_h = HR;
|
||||
return TRUE;
|
||||
} else {
|
||||
|
@ -489,16 +434,14 @@ static Int cont_between( USES_REGS1 )
|
|||
t[0] = t1;
|
||||
t[1] = MkIntTerm(1);
|
||||
tn = Eval(Yap_MkApplTerm(FunctorPlus, 2, t) PASS_REGS);
|
||||
EXTRA_CBACK_ARG(3,1) = tn;
|
||||
EXTRA_CBACK_ARG(3, 1) = tn;
|
||||
HB = B->cp_h = HR;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/// @memberof between/3
|
||||
static Int
|
||||
init_between( USES_REGS1 )
|
||||
{
|
||||
static Int init_between(USES_REGS1) {
|
||||
Term t1 = Deref(ARG1);
|
||||
Term t2 = Deref(ARG2);
|
||||
|
||||
|
@ -510,14 +453,11 @@ init_between( USES_REGS1 )
|
|||
Yap_EvalError(INSTANTIATION_ERROR, t1, "between/3");
|
||||
return FALSE;
|
||||
}
|
||||
if (!IsIntegerTerm(t1) &&
|
||||
!IsBigIntTerm(t1)) {
|
||||
if (!IsIntegerTerm(t1) && !IsBigIntTerm(t1)) {
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t1, "between/3");
|
||||
return FALSE;
|
||||
}
|
||||
if (!IsIntegerTerm(t2) &&
|
||||
!IsBigIntTerm(t2) &&
|
||||
t2 != MkAtomTerm(AtomInf) &&
|
||||
if (!IsIntegerTerm(t2) && !IsBigIntTerm(t2) && t2 != MkAtomTerm(AtomInf) &&
|
||||
t2 != MkAtomTerm(AtomInfinity)) {
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t2, "between/3");
|
||||
return FALSE;
|
||||
|
@ -530,19 +470,20 @@ init_between( USES_REGS1 )
|
|||
t3 = Deref(ARG3);
|
||||
if (!IsVarTerm(t3)) {
|
||||
if (!IsIntegerTerm(t3)) {
|
||||
if (!IsBigIntTerm(t3)) {
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
|
||||
return FALSE;
|
||||
}
|
||||
cut_fail();
|
||||
if (!IsBigIntTerm(t3)) {
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
|
||||
return FALSE;
|
||||
}
|
||||
cut_fail();
|
||||
} else {
|
||||
Int i3 = IntegerOfTerm(t3);
|
||||
if (i3 >= i1 && i3 <= i2)
|
||||
cut_succeed();
|
||||
cut_fail();
|
||||
Int i3 = IntegerOfTerm(t3);
|
||||
if (i3 >= i1 && i3 <= i2)
|
||||
cut_succeed();
|
||||
cut_fail();
|
||||
}
|
||||
}
|
||||
if (i1 > i2) cut_fail();
|
||||
if (i1 > i2)
|
||||
cut_fail();
|
||||
if (i1 == i2) {
|
||||
Yap_unify(ARG3, t1);
|
||||
cut_succeed();
|
||||
|
@ -554,16 +495,16 @@ init_between( USES_REGS1 )
|
|||
t3 = Deref(ARG3);
|
||||
if (!IsVarTerm(t3)) {
|
||||
if (!IsIntegerTerm(t3)) {
|
||||
if (!IsBigIntTerm(t3)) {
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
|
||||
return FALSE;
|
||||
}
|
||||
cut_fail();
|
||||
if (!IsBigIntTerm(t3)) {
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
|
||||
return FALSE;
|
||||
}
|
||||
cut_fail();
|
||||
} else {
|
||||
Int i3 = IntegerOfTerm(t3);
|
||||
if (i3 >= i1)
|
||||
cut_succeed();
|
||||
cut_fail();
|
||||
Int i3 = IntegerOfTerm(t3);
|
||||
if (i3 >= i1)
|
||||
cut_succeed();
|
||||
cut_fail();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -572,28 +513,28 @@ init_between( USES_REGS1 )
|
|||
|
||||
if (!IsVarTerm(t3)) {
|
||||
if (!IsIntegerTerm(t3) && !IsBigIntTerm(t3)) {
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
|
||||
return FALSE;
|
||||
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
|
||||
return FALSE;
|
||||
}
|
||||
if (Yap_acmp(t3, t1 PASS_REGS) >= 0 && Yap_acmp(t2,t3 PASS_REGS) >= 0 && P != FAILCODE)
|
||||
cut_succeed();
|
||||
if (Yap_acmp(t3, t1 PASS_REGS) >= 0 && Yap_acmp(t2, t3 PASS_REGS) >= 0 &&
|
||||
P != FAILCODE)
|
||||
cut_succeed();
|
||||
cut_fail();
|
||||
}
|
||||
cmp = Yap_acmp(t1, t2 PASS_REGS);
|
||||
if (cmp > 0) cut_fail();
|
||||
if (cmp > 0)
|
||||
cut_fail();
|
||||
if (cmp == 0) {
|
||||
Yap_unify(ARG3, t1);
|
||||
cut_succeed();
|
||||
}
|
||||
}
|
||||
EXTRA_CBACK_ARG(3,1) = t1;
|
||||
EXTRA_CBACK_ARG(3,2) = t2;
|
||||
return cont_between( PASS_REGS1 );
|
||||
EXTRA_CBACK_ARG(3, 1) = t1;
|
||||
EXTRA_CBACK_ARG(3, 2) = t2;
|
||||
return cont_between(PASS_REGS1);
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitEval(void)
|
||||
{
|
||||
void Yap_InitEval(void) {
|
||||
/* here are the arithmetical predicates */
|
||||
Yap_InitConstExps();
|
||||
Yap_InitUnaryExps();
|
||||
|
|
18
C/exo.c
18
C/exo.c
|
@ -21,7 +21,7 @@
|
|||
#include "Yap.h"
|
||||
#include "clause.h"
|
||||
#include "yapio.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
#include "tracer.h"
|
||||
#ifdef YAPOR
|
||||
#include "or.macros.h"
|
||||
|
@ -87,10 +87,10 @@ inline BITS32 fmix32 ( BITS32 h )
|
|||
return h;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||
{
|
||||
UInt hash;
|
||||
|
@ -139,10 +139,10 @@ HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
|||
/*DJB2*/
|
||||
#define DJB2_OFFSET 5381
|
||||
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||
{
|
||||
BITS32 hash;
|
||||
|
@ -165,11 +165,11 @@ HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
|||
return hash;
|
||||
}
|
||||
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||
|
||||
/* RS Hash Function */
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||
{
|
||||
UInt hash=0;
|
||||
|
@ -194,7 +194,7 @@ HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
|||
return hash;
|
||||
}
|
||||
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||
|
||||
/* Simple hash function:
|
||||
|
@ -203,7 +203,7 @@ HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
|||
hash0 spreads extensions coming from different elements.
|
||||
spread over j quadrants.
|
||||
*/
|
||||
INLINE_ONLY inline BITS32
|
||||
INLINE_ONLY BITS32
|
||||
HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||
{
|
||||
UInt hash;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "Yap.h"
|
||||
#include "clause.h"
|
||||
#include "yapio.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
#include "tracer.h"
|
||||
#include "attvar.h"
|
||||
#ifdef YAPOR
|
||||
|
@ -253,7 +253,7 @@ IntervalUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS)
|
|||
qsort(s0+1, (size_t)*s0, sizeof(BITS32), compar);
|
||||
it->links[offset0] = s0-sorted0;
|
||||
if (it->udi_free_args) {
|
||||
memcpy(sorted, s0+1, sizeof(BITS32)*(*s0));
|
||||
memmove(sorted, s0+1, sizeof(BITS32)*(*s0));
|
||||
qsort(sorted, (size_t)*s0, sizeof(BITS32), compar2);
|
||||
sorted += *s0;
|
||||
}
|
||||
|
|
|
@ -4,411 +4,411 @@
|
|||
|
||||
#ifdef INDENT_CODE
|
||||
{
|
||||
{
|
||||
{
|
||||
#endif /* INDENT_CODE */
|
||||
|
||||
/* trust_fail */
|
||||
BOp(trust_fail, e);
|
||||
{
|
||||
while (POP_CHOICE_POINT(B->cp_b))
|
||||
{
|
||||
POP_EXECUTE();
|
||||
}
|
||||
}
|
||||
/* trust_fail */
|
||||
BOp(trust_fail, e);
|
||||
{
|
||||
while (POP_CHOICE_POINT(B->cp_b)) {
|
||||
POP_EXECUTE();
|
||||
}
|
||||
}
|
||||
#ifdef YAPOR
|
||||
{
|
||||
choiceptr cut_pt;
|
||||
cut_pt = B->cp_b;
|
||||
CUT_prune_to(cut_pt);
|
||||
B = cut_pt;
|
||||
}
|
||||
{
|
||||
choiceptr cut_pt;
|
||||
cut_pt = B->cp_b;
|
||||
CUT_prune_to(cut_pt);
|
||||
B = cut_pt;
|
||||
}
|
||||
#else
|
||||
B = B->cp_b;
|
||||
#endif /* YAPOR */
|
||||
goto fail;
|
||||
ENDBOp();
|
||||
B = B->cp_b;
|
||||
#endif /* YAPOR */
|
||||
goto fail;
|
||||
ENDBOp();
|
||||
|
||||
#ifdef YAPOR
|
||||
shared_fail:
|
||||
B = Get_LOCAL_top_cp();
|
||||
SET_BB(PROTECT_FROZEN_B(B));
|
||||
goto fail;
|
||||
#endif /* YAPOR */
|
||||
shared_fail:
|
||||
B = Get_LOCAL_top_cp();
|
||||
SET_BB(PROTECT_FROZEN_B(B));
|
||||
goto fail;
|
||||
#endif /* YAPOR */
|
||||
|
||||
/* fail */
|
||||
PBOp(op_fail, e);
|
||||
/* fail */
|
||||
PBOp(op_fail, e);
|
||||
|
||||
if (PP) {
|
||||
UNLOCK(PP->PELock);
|
||||
PP = NULL;
|
||||
}
|
||||
if (PP) {
|
||||
UNLOCK(PP->PELock);
|
||||
PP = NULL;
|
||||
}
|
||||
#ifdef COROUTINING
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
check_stack(NoStackFail, HR);
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
check_stack(NoStackFail, HR);
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#endif
|
||||
|
||||
fail:
|
||||
{
|
||||
register tr_fr_ptr pt0 = TR;
|
||||
fail : {
|
||||
register tr_fr_ptr pt0 = TR;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (PP) {
|
||||
UNLOCK(PP->PELock);
|
||||
PP = NULL;
|
||||
}
|
||||
if (PP) {
|
||||
UNLOCK(PP->PELock);
|
||||
PP = NULL;
|
||||
}
|
||||
#endif
|
||||
PREG = B->cp_ap;
|
||||
save_pc();
|
||||
CACHE_TR(B->cp_tr);
|
||||
PREFETCH_OP(PREG);
|
||||
failloop:
|
||||
if (pt0 == S_TR) {
|
||||
SP = SP0;
|
||||
PREG = B->cp_ap;
|
||||
save_pc();
|
||||
CACHE_TR(B->cp_tr);
|
||||
PREFETCH_OP(PREG);
|
||||
failloop:
|
||||
if (pt0 == S_TR) {
|
||||
SP = SP0;
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace) {
|
||||
int go_on = true;
|
||||
yamop *ipc = PREG;
|
||||
if (Yap_do_low_level_trace) {
|
||||
int go_on = true;
|
||||
yamop *ipc = PREG;
|
||||
|
||||
while (go_on) {
|
||||
op_numbers opnum = Yap_op_from_opcode(ipc->opc);
|
||||
while (go_on) {
|
||||
op_numbers opnum = Yap_op_from_opcode(ipc->opc);
|
||||
|
||||
go_on = false;
|
||||
switch (opnum) {
|
||||
go_on = false;
|
||||
switch (opnum) {
|
||||
#ifdef TABLING
|
||||
case _table_load_answer:
|
||||
low_level_trace(retry_table_loader, LOAD_CP(B)->cp_pred_entry, NULL);
|
||||
break;
|
||||
case _table_try_answer:
|
||||
case _table_retry_me:
|
||||
case _table_trust_me:
|
||||
case _table_retry:
|
||||
case _table_trust:
|
||||
case _table_completion:
|
||||
case _table_load_answer:
|
||||
low_level_trace(retry_table_loader, LOAD_CP(B)->cp_pred_entry, NULL);
|
||||
break;
|
||||
case _table_try_answer:
|
||||
case _table_retry_me:
|
||||
case _table_trust_me:
|
||||
case _table_retry:
|
||||
case _table_trust:
|
||||
case _table_completion:
|
||||
#ifdef THREADS_CONSUMER_SHARING
|
||||
case _table_answer_resolution_completion:
|
||||
case _table_answer_resolution_completion:
|
||||
#endif /* THREADS_CONSUMER_SHARING */
|
||||
#ifdef DETERMINISTIC_TABLING
|
||||
if (IS_DET_GEN_CP(B))
|
||||
low_level_trace(retry_table_generator, DET_GEN_CP(B)->cp_pred_entry, NULL);
|
||||
else
|
||||
if (IS_DET_GEN_CP(B))
|
||||
low_level_trace(retry_table_generator, DET_GEN_CP(B)->cp_pred_entry,
|
||||
NULL);
|
||||
else
|
||||
#endif /* DETERMINISTIC_TABLING */
|
||||
low_level_trace(retry_table_generator, GEN_CP(B)->cp_pred_entry, (CELL *)(GEN_CP(B) + 1));
|
||||
break;
|
||||
case _table_answer_resolution:
|
||||
low_level_trace(retry_table_consumer, CONS_CP(B)->cp_pred_entry, NULL);
|
||||
break;
|
||||
case _trie_trust_var:
|
||||
case _trie_retry_var:
|
||||
case _trie_trust_var_in_pair:
|
||||
case _trie_retry_var_in_pair:
|
||||
case _trie_trust_val:
|
||||
case _trie_retry_val:
|
||||
case _trie_trust_val_in_pair:
|
||||
case _trie_retry_val_in_pair:
|
||||
case _trie_trust_atom:
|
||||
case _trie_retry_atom:
|
||||
case _trie_trust_atom_in_pair:
|
||||
case _trie_retry_atom_in_pair:
|
||||
case _trie_trust_null:
|
||||
case _trie_retry_null:
|
||||
case _trie_trust_null_in_pair:
|
||||
case _trie_retry_null_in_pair:
|
||||
case _trie_trust_pair:
|
||||
case _trie_retry_pair:
|
||||
case _trie_trust_appl:
|
||||
case _trie_retry_appl:
|
||||
case _trie_trust_appl_in_pair:
|
||||
case _trie_retry_appl_in_pair:
|
||||
case _trie_trust_extension:
|
||||
case _trie_retry_extension:
|
||||
case _trie_trust_double:
|
||||
case _trie_retry_double:
|
||||
case _trie_trust_longint:
|
||||
case _trie_retry_longint:
|
||||
case _trie_trust_gterm:
|
||||
case _trie_retry_gterm:
|
||||
low_level_trace(retry_table_loader, UndefCode, NULL);
|
||||
break;
|
||||
low_level_trace(retry_table_generator, GEN_CP(B)->cp_pred_entry,
|
||||
(CELL *)(GEN_CP(B) + 1));
|
||||
break;
|
||||
case _table_answer_resolution:
|
||||
low_level_trace(retry_table_consumer, CONS_CP(B)->cp_pred_entry,
|
||||
NULL);
|
||||
break;
|
||||
case _trie_trust_var:
|
||||
case _trie_retry_var:
|
||||
case _trie_trust_var_in_pair:
|
||||
case _trie_retry_var_in_pair:
|
||||
case _trie_trust_val:
|
||||
case _trie_retry_val:
|
||||
case _trie_trust_val_in_pair:
|
||||
case _trie_retry_val_in_pair:
|
||||
case _trie_trust_atom:
|
||||
case _trie_retry_atom:
|
||||
case _trie_trust_atom_in_pair:
|
||||
case _trie_retry_atom_in_pair:
|
||||
case _trie_trust_null:
|
||||
case _trie_retry_null:
|
||||
case _trie_trust_null_in_pair:
|
||||
case _trie_retry_null_in_pair:
|
||||
case _trie_trust_pair:
|
||||
case _trie_retry_pair:
|
||||
case _trie_trust_appl:
|
||||
case _trie_retry_appl:
|
||||
case _trie_trust_appl_in_pair:
|
||||
case _trie_retry_appl_in_pair:
|
||||
case _trie_trust_extension:
|
||||
case _trie_retry_extension:
|
||||
case _trie_trust_double:
|
||||
case _trie_retry_double:
|
||||
case _trie_trust_longint:
|
||||
case _trie_retry_longint:
|
||||
case _trie_trust_gterm:
|
||||
case _trie_retry_gterm:
|
||||
low_level_trace(retry_table_loader, UndefCode, NULL);
|
||||
break;
|
||||
#endif /* TABLING */
|
||||
case _or_else:
|
||||
case _or_last:
|
||||
low_level_trace(retry_or, (PredEntry *)ipc, &(B->cp_a1));
|
||||
break;
|
||||
case _retry2:
|
||||
case _retry3:
|
||||
case _retry4:
|
||||
ipc = NEXTOP(ipc,l);
|
||||
go_on = true;
|
||||
break;
|
||||
case _jump:
|
||||
ipc = ipc->y_u.l.l;
|
||||
go_on = true;
|
||||
break;
|
||||
case _retry_c:
|
||||
case _retry_userc:
|
||||
low_level_trace(retry_pred, ipc->y_u.OtapFs.p, B->cp_args);
|
||||
break;
|
||||
case _retry_profiled:
|
||||
case _count_retry:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
go_on = true;
|
||||
break;
|
||||
case _retry_me:
|
||||
case _trust_me:
|
||||
case _count_retry_me:
|
||||
case _count_trust_me:
|
||||
case _profiled_retry_me:
|
||||
case _profiled_trust_me:
|
||||
case _retry_and_mark:
|
||||
case _profiled_retry_and_mark:
|
||||
case _retry:
|
||||
case _trust:
|
||||
low_level_trace(retry_pred, ipc->y_u.Otapl.p, B->cp_args);
|
||||
break;
|
||||
case _try_logical:
|
||||
case _retry_logical:
|
||||
case _profiled_retry_logical:
|
||||
case _count_retry_logical:
|
||||
case _trust_logical:
|
||||
case _profiled_trust_logical:
|
||||
case _count_trust_logical:
|
||||
low_level_trace(retry_pred, ipc->y_u.OtILl.d->ClPred, B->cp_args);
|
||||
break;
|
||||
case _Nstop:
|
||||
case _Ystop:
|
||||
low_level_trace(retry_pred, NULL, B->cp_args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LOW_LEVEL_TRACER */
|
||||
#ifdef FROZEN_STACKS
|
||||
#ifdef YAPOR_SBA
|
||||
if (pt0 < TR_FZ || pt0 > (ADDR)CurrentTrailTop+MinTrailGap)
|
||||
#else
|
||||
if (pt0 < TR_FZ)
|
||||
#endif /* YAPOR_SBA */
|
||||
{
|
||||
TR = TR_FZ;
|
||||
TRAIL_LINK(pt0);
|
||||
} else
|
||||
#endif /* FROZEN_STACKS */
|
||||
RESTORE_TR();
|
||||
GONext();
|
||||
}
|
||||
BEGD(d1);
|
||||
d1 = TrailTerm(pt0-1);
|
||||
pt0--;
|
||||
if (IsVarTerm(d1)) {
|
||||
#if defined(YAPOR_SBA) && defined(YAPOR)
|
||||
/* clean up the trail when we backtrack */
|
||||
if (Unsigned((Int)(d1)-(Int)(H_FZ)) >
|
||||
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) {
|
||||
RESET_VARIABLE(STACK_TO_SBA(d1));
|
||||
} else
|
||||
#endif
|
||||
/* normal variable */
|
||||
RESET_VARIABLE(d1);
|
||||
goto failloop;
|
||||
}
|
||||
/* pointer to code space */
|
||||
/* or updatable variable */
|
||||
#if defined(TERM_EXTENSIONS) || defined(FROZEN_STACKS) || defined(MULTI_ASSIGNMENT_VARIABLES)
|
||||
if (IsPairTerm(d1))
|
||||
#endif /* TERM_EXTENSIONS || FROZEN_STACKS || MULTI_ASSIGNMENT_VARIABLES */
|
||||
{
|
||||
register CELL flags;
|
||||
CELL *pt1 = RepPair(d1);
|
||||
#ifdef LIMIT_TABLING
|
||||
if ((ADDR) pt1 == LOCAL_TrailBase) {
|
||||
sg_fr_ptr sg_fr = (sg_fr_ptr) TrailVal(pt0);
|
||||
TrailTerm(pt0) = AbsPair((CELL *)(pt0 - 1));
|
||||
SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use --> compiled */
|
||||
insert_into_global_sg_fr_list(sg_fr);
|
||||
goto failloop;
|
||||
}
|
||||
#endif /* LIMIT_TABLING */
|
||||
#ifdef FROZEN_STACKS /* TRAIL */
|
||||
/* avoid frozen segments */
|
||||
if (
|
||||
#ifdef YAPOR_SBA
|
||||
(ADDR) pt1 >= HeapTop
|
||||
#else
|
||||
IN_BETWEEN(LOCAL_TrailBase, pt1, (ADDR)CurrentTrailTop+MinTrailGap)
|
||||
#endif /* YAPOR_SBA */
|
||||
)
|
||||
{
|
||||
pt0 = (tr_fr_ptr) pt1;
|
||||
goto failloop;
|
||||
} else
|
||||
#endif /* FROZEN_STACKS */
|
||||
if (IN_BETWEEN(H0,pt1,HR)) {
|
||||
if (IsAttVar(pt1)) {
|
||||
goto failloop;
|
||||
} else if (*pt1 == (CELL)FunctorBigInt) {
|
||||
Yap_CleanOpaqueVariable(pt1);
|
||||
goto failloop;
|
||||
}
|
||||
}
|
||||
#ifdef FROZEN_STACKS /* TRAIL */
|
||||
/* don't reset frozen variables */
|
||||
if (pt0 < TR_FZ)
|
||||
goto failloop;
|
||||
#endif
|
||||
flags = *pt1;
|
||||
#if MULTIPLE_STACKS
|
||||
if (FlagOn(DBClMask, flags)) {
|
||||
DBRef dbr = DBStructFlagsToDBStruct(pt1);
|
||||
int erase;
|
||||
|
||||
LOCK(dbr->lock);
|
||||
DEC_DBREF_COUNT(dbr);
|
||||
erase = (dbr->Flags & ErasedMask) && (dbr->ref_count == 0);
|
||||
UNLOCK(dbr->lock);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
Yap_ErDBE(dbr);
|
||||
setregs();
|
||||
}
|
||||
} else {
|
||||
if (flags & LogUpdMask) {
|
||||
if (flags & IndexMask) {
|
||||
LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt1);
|
||||
int erase;
|
||||
#if PARALLEL_YAP
|
||||
PredEntry *ap = cl->ClPred;
|
||||
#endif
|
||||
|
||||
PELOCK(8,ap);
|
||||
DEC_CLREF_COUNT(cl);
|
||||
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_ErLogUpdIndex(cl);
|
||||
setregs();
|
||||
} else if (cl->ClFlags & DirtyMask) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_CleanUpIndex(cl);
|
||||
setregs();
|
||||
}
|
||||
UNLOCK(ap->PELock);
|
||||
} else {
|
||||
LogUpdClause *cl = ClauseFlagsToLogUpdClause(pt1);
|
||||
int erase;
|
||||
#if PARALLEL_YAP
|
||||
PredEntry *ap = cl->ClPred;
|
||||
#endif
|
||||
/* BB support */
|
||||
if (ap) {
|
||||
|
||||
PELOCK(9,ap);
|
||||
DEC_CLREF_COUNT(cl);
|
||||
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_ErLogUpdCl(cl);
|
||||
setregs();
|
||||
}
|
||||
UNLOCK(ap->PELock);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DynamicClause *cl = ClauseFlagsToDynamicClause(pt1);
|
||||
int erase;
|
||||
|
||||
LOCK(cl->ClLock);
|
||||
DEC_CLREF_COUNT(cl);
|
||||
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
|
||||
UNLOCK(cl->ClLock);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_ErCl(cl);
|
||||
setregs();
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
ResetFlag(InUseMask, flags);
|
||||
*pt1 = flags;
|
||||
if (FlagOn((ErasedMask|DirtyMask), flags)) {
|
||||
if (FlagOn(DBClMask, flags)) {
|
||||
saveregs();
|
||||
Yap_ErDBE(DBStructFlagsToDBStruct(pt1));
|
||||
setregs();
|
||||
} else {
|
||||
saveregs();
|
||||
if (flags & LogUpdMask) {
|
||||
if (flags & IndexMask) {
|
||||
if (FlagOn(ErasedMask, flags)) {
|
||||
Yap_ErLogUpdIndex(ClauseFlagsToLogUpdIndex(pt1));
|
||||
} else {
|
||||
Yap_CleanUpIndex(ClauseFlagsToLogUpdIndex(pt1));
|
||||
}
|
||||
} else {
|
||||
Yap_ErLogUpdCl(ClauseFlagsToLogUpdClause(pt1));
|
||||
}
|
||||
} else {
|
||||
Yap_ErCl(ClauseFlagsToDynamicClause(pt1));
|
||||
}
|
||||
setregs();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
goto failloop;
|
||||
}
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
else /* if (IsApplTerm(d1)) */ {
|
||||
CELL *pt = RepAppl(d1);
|
||||
/* AbsAppl means */
|
||||
/* multi-assignment variable */
|
||||
/* so the next cell is the old value */
|
||||
#ifdef FROZEN_STACKS
|
||||
--pt0;
|
||||
pt[0] = TrailVal(pt0);
|
||||
#else
|
||||
pt[0] = TrailTerm(pt0-1);
|
||||
pt0 -= 2;
|
||||
#endif /* FROZEN_STACKS */
|
||||
goto failloop;
|
||||
}
|
||||
#endif
|
||||
ENDD(d1);
|
||||
ENDCACHE_TR();
|
||||
case _or_else:
|
||||
case _or_last:
|
||||
low_level_trace(retry_or, NULL, NULL);
|
||||
break;
|
||||
case _retry2:
|
||||
case _retry3:
|
||||
case _retry4:
|
||||
ipc = NEXTOP(ipc, l);
|
||||
go_on = true;
|
||||
break;
|
||||
case _jump:
|
||||
ipc = ipc->y_u.l.l;
|
||||
go_on = true;
|
||||
break;
|
||||
case _retry_c:
|
||||
case _retry_userc:
|
||||
low_level_trace(retry_pred, ipc->y_u.OtapFs.p, B->cp_args);
|
||||
break;
|
||||
case _retry_profiled:
|
||||
case _count_retry:
|
||||
ipc = NEXTOP(ipc, p);
|
||||
go_on = true;
|
||||
break;
|
||||
case _retry_me:
|
||||
case _trust_me:
|
||||
case _count_retry_me:
|
||||
case _count_trust_me:
|
||||
case _profiled_retry_me:
|
||||
case _profiled_trust_me:
|
||||
case _retry_and_mark:
|
||||
case _profiled_retry_and_mark:
|
||||
case _retry:
|
||||
case _trust:
|
||||
low_level_trace(retry_pred, ipc->y_u.Otapl.p, B->cp_args);
|
||||
break;
|
||||
case _try_logical:
|
||||
case _retry_logical:
|
||||
case _profiled_retry_logical:
|
||||
case _count_retry_logical:
|
||||
case _trust_logical:
|
||||
case _profiled_trust_logical:
|
||||
case _count_trust_logical:
|
||||
low_level_trace(retry_pred, ipc->y_u.OtILl.d->ClPred, B->cp_args);
|
||||
break;
|
||||
case _Nstop:
|
||||
case _Ystop:
|
||||
low_level_trace(retry_pred, NULL, B->cp_args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LOW_LEVEL_TRACER */
|
||||
#ifdef FROZEN_STACKS
|
||||
#ifdef YAPOR_SBA
|
||||
if (pt0 < TR_FZ || pt0 > (ADDR)CurrentTrailTop + MinTrailGap)
|
||||
#else
|
||||
if (pt0 < TR_FZ)
|
||||
#endif /* YAPOR_SBA */
|
||||
{
|
||||
TR = TR_FZ;
|
||||
TRAIL_LINK(pt0);
|
||||
} else
|
||||
#endif /* FROZEN_STACKS */
|
||||
RESTORE_TR();
|
||||
GONext();
|
||||
}
|
||||
BEGD(d1);
|
||||
d1 = TrailTerm(pt0 - 1);
|
||||
pt0--;
|
||||
if (IsVarTerm(d1)) {
|
||||
#if defined(YAPOR_SBA) && defined(YAPOR)
|
||||
/* clean up the trail when we backtrack */
|
||||
if (Unsigned((Int)(d1) - (Int)(H_FZ)) >
|
||||
Unsigned((Int)(B_FZ) - (Int)(H_FZ))) {
|
||||
RESET_VARIABLE(STACK_TO_SBA(d1));
|
||||
} else
|
||||
#endif
|
||||
/* normal variable */
|
||||
RESET_VARIABLE(d1);
|
||||
goto failloop;
|
||||
}
|
||||
/* pointer to code space */
|
||||
/* or updatable variable */
|
||||
if (IsPairTerm(d1))
|
||||
{
|
||||
register CELL flags;
|
||||
CELL *pt1 = RepPair(d1);
|
||||
#ifdef LIMIT_TABLING
|
||||
if ((ADDR)pt1 == LOCAL_TrailBase) {
|
||||
sg_fr_ptr sg_fr = (sg_fr_ptr)TrailVal(pt0);
|
||||
TrailTerm(pt0) = AbsPair((CELL *)(pt0 - 1));
|
||||
SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use -->
|
||||
compiled */
|
||||
insert_into_global_sg_fr_list(sg_fr);
|
||||
goto failloop;
|
||||
}
|
||||
#endif /* LIMIT_TABLING */
|
||||
#ifdef FROZEN_STACKS /* TRAIL */
|
||||
/* avoid frozen segments */
|
||||
if (
|
||||
#ifdef YAPOR_SBA
|
||||
(ADDR)pt1 >= HeapTop
|
||||
#else
|
||||
IN_BETWEEN(LOCAL_TrailBase, pt1, (ADDR)CurrentTrailTop + MinTrailGap)
|
||||
#endif /* YAPOR_SBA */
|
||||
) {
|
||||
pt0 = (tr_fr_ptr)pt1;
|
||||
goto failloop;
|
||||
} else
|
||||
#endif /* FROZEN_STACKS */
|
||||
if (IN_BETWEEN(H0, pt1, LCL0)) {
|
||||
if (IsAttVar(pt1)) {
|
||||
goto failloop;
|
||||
} else {
|
||||
TR = pt0;
|
||||
|
||||
Yap_CleanOpaqueVariable(d1);
|
||||
|
||||
goto failloop;
|
||||
}
|
||||
}
|
||||
#ifdef FROZEN_STACKS /* TRAIL */
|
||||
/* don't reset frozen variables */
|
||||
else if (pt0 < TR_FZ)
|
||||
goto failloop;
|
||||
#endif
|
||||
flags = *pt1;
|
||||
#if MULTIPLE_STACKS
|
||||
if (FlagOn(DBClMask, flags)) {
|
||||
DBRef dbr = DBStructFlagsToDBStruct(pt1);
|
||||
int erase;
|
||||
|
||||
LOCK(dbr->lock);
|
||||
DEC_DBREF_COUNT(dbr);
|
||||
erase = (dbr->Flags & ErasedMask) && (dbr->ref_count == 0);
|
||||
UNLOCK(dbr->lock);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
Yap_ErDBE(dbr);
|
||||
setregs();
|
||||
}
|
||||
} else {
|
||||
if (flags & LogUpdMask) {
|
||||
if (flags & IndexMask) {
|
||||
LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt1);
|
||||
int erase;
|
||||
#if PARALLEL_YAP
|
||||
PredEntry *ap = cl->ClPred;
|
||||
#endif
|
||||
|
||||
PELOCK(8, ap);
|
||||
DEC_CLREF_COUNT(cl);
|
||||
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_ErLogUpdIndex(cl);
|
||||
setregs();
|
||||
} else if (cl->ClFlags & DirtyMask) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_CleanUpIndex(cl);
|
||||
setregs();
|
||||
}
|
||||
UNLOCK(ap->PELock);
|
||||
} else {
|
||||
LogUpdClause *cl = ClauseFlagsToLogUpdClause(pt1);
|
||||
int erase;
|
||||
PredEntry *ap = cl->ClPred;
|
||||
/* BB support */
|
||||
if (ap) {
|
||||
|
||||
PELOCK(9, ap);
|
||||
DEC_CLREF_COUNT(cl);
|
||||
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_ErLogUpdCl(cl);
|
||||
setregs();
|
||||
}
|
||||
UNLOCK(ap->PELock);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DynamicClause *cl = ClauseFlagsToDynamicClause(pt1);
|
||||
int erase;
|
||||
|
||||
LOCK(cl->ClLock);
|
||||
DEC_CLREF_COUNT(cl);
|
||||
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
|
||||
UNLOCK(cl->ClLock);
|
||||
if (erase) {
|
||||
saveregs();
|
||||
/* at this point,
|
||||
we are the only ones accessing the clause,
|
||||
hence we don't need to have a lock it */
|
||||
Yap_ErCl(cl);
|
||||
setregs();
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
ResetFlag(InUseMask, flags);
|
||||
*pt1 = flags;
|
||||
if (FlagOn((ErasedMask | DirtyMask), flags)) {
|
||||
if (FlagOn(DBClMask, flags)) {
|
||||
saveregs();
|
||||
Yap_ErDBE(DBStructFlagsToDBStruct(pt1));
|
||||
setregs();
|
||||
} else {
|
||||
saveregs();
|
||||
if (flags & LogUpdMask) {
|
||||
if (flags & IndexMask) {
|
||||
if (FlagOn(ErasedMask, flags)) {
|
||||
Yap_ErLogUpdIndex(ClauseFlagsToLogUpdIndex(pt1));
|
||||
} else {
|
||||
Yap_CleanUpIndex(ClauseFlagsToLogUpdIndex(pt1));
|
||||
}
|
||||
} else {
|
||||
Yap_ErLogUpdCl(ClauseFlagsToLogUpdClause(pt1));
|
||||
}
|
||||
} else {
|
||||
Yap_ErCl(ClauseFlagsToDynamicClause(pt1));
|
||||
}
|
||||
setregs();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
goto failloop;
|
||||
}
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
else /* if (IsApplTerm(d1)) */
|
||||
{
|
||||
CELL *pt = RepAppl(d1);
|
||||
/* AbsAppl means */
|
||||
/* multi-assignment variable */
|
||||
/* so the next cell is the old value */
|
||||
#ifdef FROZEN_STACKS
|
||||
--pt0;
|
||||
pt[0] = TrailVal(pt0);
|
||||
#else
|
||||
pt[0] = TrailTerm(pt0 - 1);
|
||||
pt0 -= 2;
|
||||
#endif /* FROZEN_STACKS */
|
||||
goto failloop;
|
||||
}
|
||||
#endif
|
||||
ENDD(d1);
|
||||
ENDCACHE_TR();
|
||||
}
|
||||
|
||||
#ifdef COROUTINING
|
||||
NoStackFail:
|
||||
BEGD(d0);
|
||||
NoStackFail:
|
||||
BEGD(d0);
|
||||
#ifdef SHADOW_S
|
||||
Yap_REGS.S_ = SREG;
|
||||
Yap_REGS.S_ = SREG;
|
||||
#endif
|
||||
saveregs();
|
||||
d0 = interrupt_fail( PASS_REGS1 );
|
||||
setregs();
|
||||
saveregs();
|
||||
d0 = interrupt_fail(PASS_REGS1);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = Yap_REGS.S_;
|
||||
SREG = Yap_REGS.S_;
|
||||
#endif
|
||||
if (!d0) FAIL();
|
||||
JMPNext();
|
||||
ENDD(d0);
|
||||
if (!d0)
|
||||
FAIL();
|
||||
JMPNext();
|
||||
ENDD(d0);
|
||||
|
||||
#endif /* COROUTINING */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
|
||||
ENDPBOp();
|
||||
#ifdef INDENT_CODE
|
||||
}
|
||||
#endif /* INDENT_CODE */
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Call C predicates instructions *
|
||||
\************************************************************************/
|
||||
|
||||
|
||||
#ifdef INDENT_CODE
|
||||
{
|
||||
{
|
||||
|
@ -11,48 +10,53 @@
|
|||
|
||||
BOp(call_cpred, Osbpp);
|
||||
#if __ANDROID__ && STRONG_DEBUG
|
||||
char *s; Atom name;
|
||||
char *s;
|
||||
Atom name;
|
||||
if (PREG->y_u.Osbpp.p->ArityOfPE) {
|
||||
Functor f = PREG->y_u.Osbpp.p->FunctorOfPred;
|
||||
name = f->NameOfFE;
|
||||
Functor f = PREG->y_u.Osbpp.p->FunctorOfPred;
|
||||
name = f->NameOfFE;
|
||||
} else {
|
||||
name = (Atom)(PREG->y_u.Osbpp.p->FunctorOfPred);
|
||||
name = (Atom)(PREG->y_u.Osbpp.p->FunctorOfPred);
|
||||
}
|
||||
s = name->StrOfAE;
|
||||
|
||||
LOG( " %s ", s);
|
||||
LOG(" %s ", s);
|
||||
#endif
|
||||
check_trail(TR);
|
||||
if (!(PREG->y_u.Osbpp.p->PredFlags & (SafePredFlag|NoTracePredFlag|HiddenPredFlag))) {
|
||||
if (!(PREG->y_u.Osbpp.p->PredFlags &
|
||||
(SafePredFlag | NoTracePredFlag | HiddenPredFlag))) {
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
check_stack(NoStackCCall, HR);
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
}
|
||||
do_c_call:
|
||||
do_c_call :
|
||||
#ifdef FROZEN_STACKS
|
||||
{
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||
{
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||
|
||||
#ifdef YAPOR_SBA
|
||||
if (YREG > (CELL *) top_b || YREG < HR) ASP = (CELL *)top_b;
|
||||
if (YREG > (CELL *)top_b || YREG < HR)
|
||||
ASP = (CELL *)top_b;
|
||||
#else
|
||||
if (YREG > (CELL *) top_b) ASP = (CELL *)top_b;
|
||||
if (YREG > (CELL *)top_b)
|
||||
ASP = (CELL *)top_b;
|
||||
#endif /* YAPOR_SBA */
|
||||
else ASP = (CELL *)(((char *)YREG) + PREG->y_u.Osbpp.s);
|
||||
}
|
||||
else
|
||||
ASP = (CELL *)(((char *)YREG) + PREG->y_u.Osbpp.s);
|
||||
}
|
||||
#else
|
||||
SET_ASP(YREG, PREG->y_u.Osbpp.s);
|
||||
/* for slots to work */
|
||||
/* for slots to work */
|
||||
#endif /* FROZEN_STACKS */
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace)
|
||||
low_level_trace(enter_pred,PREG->y_u.Osbpp.p,XREGS+1);
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
low_level_trace(enter_pred, PREG->y_u.Osbpp.p, XREGS + 1);
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
BEGD(d0);
|
||||
CPredicate f = PREG->y_u.Osbpp.p->cs.f_code;
|
||||
PREG = NEXTOP(PREG, Osbpp);
|
||||
saveregs();
|
||||
d0 = (f)(PASS_REGS1);
|
||||
d0 = f(PASS_REGS1);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = Yap_REGS.S_;
|
||||
|
@ -70,7 +74,7 @@
|
|||
ENDBOp();
|
||||
|
||||
/* execute Label */
|
||||
BOp(execute_cpred, pp);
|
||||
BOp(execute_cpred, Osbpp);
|
||||
check_trail(TR);
|
||||
{
|
||||
PredEntry *pt0;
|
||||
|
@ -79,29 +83,32 @@
|
|||
CACHE_Y_AS_ENV(YREG);
|
||||
#ifndef NO_CHECKING
|
||||
check_stack(NoStackExecuteC, HR);
|
||||
do_executec:
|
||||
do_executec :
|
||||
#endif
|
||||
#ifdef FROZEN_STACKS
|
||||
{
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||
{
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||
|
||||
#ifdef YAPOR_SBA
|
||||
if (YREG > (CELL *) top_b || YREG < HR) ASP = (CELL *)top_b;
|
||||
if (YREG > (CELL *)top_b || YREG < HR)
|
||||
ASP = (CELL *)top_b;
|
||||
#else
|
||||
if (YREG > (CELL *) top_b) ASP = (CELL *)top_b;
|
||||
if (YREG > (CELL *)top_b)
|
||||
ASP = (CELL *)top_b;
|
||||
#endif /* YAPOR_SBA */
|
||||
else ASP = YREG+E_CB;
|
||||
}
|
||||
else
|
||||
ASP = YREG + E_CB;
|
||||
}
|
||||
#else
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
/* for slots to work */
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
/* for slots to work */
|
||||
#endif /* FROZEN_STACKS */
|
||||
pt0 = PREG->y_u.pp.p;
|
||||
pt0 = PREG->y_u.Osbpp.p;
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace) {
|
||||
low_level_trace(enter_pred,pt0,XREGS+1);
|
||||
low_level_trace(enter_pred, pt0, XREGS + 1);
|
||||
}
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
CACHE_A1();
|
||||
BEGD(d0);
|
||||
d0 = (CELL)B;
|
||||
|
@ -110,24 +117,24 @@
|
|||
ENV_YREG[E_CB] = d0;
|
||||
ENDD(d0);
|
||||
#ifdef DEPTH_LIMIT
|
||||
if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is prolog */
|
||||
if (DEPTH <= MkIntTerm(1)) { /* I assume Module==0 is prolog */
|
||||
if (pt0->ModuleOfPred) {
|
||||
if (DEPTH == MkIntTerm(0)) {
|
||||
FAIL();
|
||||
} else{
|
||||
DEPTH = RESET_DEPTH();
|
||||
}
|
||||
} else {
|
||||
DEPTH = RESET_DEPTH();
|
||||
}
|
||||
}
|
||||
} else if (pt0->ModuleOfPred) {
|
||||
DEPTH -= MkIntConstant(2);
|
||||
}
|
||||
#endif /* DEPTH_LIMIT */
|
||||
#endif /* DEPTH_LIMIT */
|
||||
/* now call C-Code */
|
||||
{
|
||||
CPredicate f = PREG->y_u.pp.p->cs.f_code;
|
||||
CPredicate f = PREG->y_u.Osbpp.p->cs.f_code;
|
||||
yamop *oldPREG = PREG;
|
||||
saveregs();
|
||||
d0 = (f)(PASS_REGS1);
|
||||
d0 = f(PASS_REGS1);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = Yap_REGS.S_;
|
||||
|
@ -169,25 +176,29 @@
|
|||
do_user_call:
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace) {
|
||||
low_level_trace(enter_pred,PREG->y_u.Osbpp.p,XREGS+1);
|
||||
low_level_trace(enter_pred, PREG->y_u.Osbpp.p, XREGS + 1);
|
||||
}
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
#ifdef FROZEN_STACKS
|
||||
{
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||
#ifdef YAPOR_SBA
|
||||
if (YREG > (CELL *) top_b || YREG < HR) ASP = (CELL *) top_b;
|
||||
if (YREG > (CELL *)top_b || YREG < HR)
|
||||
ASP = (CELL *)top_b;
|
||||
#else
|
||||
if (YREG > (CELL *) top_b) ASP = (CELL *) top_b;
|
||||
if (YREG > (CELL *)top_b)
|
||||
ASP = (CELL *)top_b;
|
||||
#endif /* YAPOR_SBA */
|
||||
else ASP = (CELL *)(((char *)YREG) + PREG->y_u.Osbpp.s);
|
||||
else
|
||||
ASP = (CELL *)(((char *)YREG) + PREG->y_u.Osbpp.s);
|
||||
}
|
||||
#else
|
||||
SET_ASP(YREG, PREG->y_u.Osbpp.s);
|
||||
/* for slots to work */
|
||||
/* for slots to work */
|
||||
#endif /* FROZEN_STACKS */
|
||||
{
|
||||
/* make sure that we can still have access to our old PREG after calling user defined goals and backtracking or failing */
|
||||
/* make sure that we can still have access to our old PREG after calling
|
||||
* user defined goals and backtracking or failing */
|
||||
yamop *savedP;
|
||||
|
||||
LOCAL_PrologMode |= UserCCallMode;
|
||||
|
@ -199,17 +210,15 @@
|
|||
saveregs();
|
||||
save_machine_regs();
|
||||
|
||||
SREG = (CELL *) YAP_Execute(p, p->cs.f_code);
|
||||
SREG = (CELL *)YAP_Execute(p, p->cs.f_code);
|
||||
}
|
||||
setregs();
|
||||
LOCAL_PrologMode &= ~UserCCallMode;
|
||||
restore_machine_regs();
|
||||
PREG = savedP;
|
||||
}
|
||||
if (EX) {
|
||||
struct DB_TERM *exp = EX;
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(Yap_PopTermFromDB(exp));
|
||||
if (Yap_HasException()) {
|
||||
Yap_RaiseException();
|
||||
SREG = NULL;
|
||||
}
|
||||
if (!SREG) {
|
||||
|
@ -228,16 +237,18 @@
|
|||
BOp(call_c_wfail, slpp);
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace) {
|
||||
low_level_trace(enter_pred,PREG->y_u.slpp.p,XREGS+1);
|
||||
low_level_trace(enter_pred, PREG->y_u.slpp.p, XREGS + 1);
|
||||
}
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
#ifdef FROZEN_STACKS
|
||||
{
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||
#ifdef YAPOR_SBA
|
||||
if (YREG > (CELL *) top_b || YREG < HR) ASP = (CELL *) top_b;
|
||||
if (YREG > (CELL *)top_b || YREG < HR)
|
||||
ASP = (CELL *)top_b;
|
||||
#else
|
||||
if (YREG > (CELL *) top_b) ASP = (CELL *) top_b;
|
||||
if (YREG > (CELL *)top_b)
|
||||
ASP = (CELL *)top_b;
|
||||
#endif /* YAPOR_SBA */
|
||||
else {
|
||||
BEGD(d0);
|
||||
|
@ -247,12 +258,12 @@
|
|||
}
|
||||
}
|
||||
#else
|
||||
if (YREG > (CELL *) B)
|
||||
ASP = (CELL *) B;
|
||||
if (YREG > (CELL *)B)
|
||||
ASP = (CELL *)B;
|
||||
else {
|
||||
BEGD(d0);
|
||||
d0 = PREG->y_u.slpp.s;
|
||||
ASP = ((CELL *) YREG) + d0;
|
||||
ASP = ((CELL *)YREG) + d0;
|
||||
ENDD(d0);
|
||||
}
|
||||
#endif /* FROZEN_STACKS */
|
||||
|
@ -279,14 +290,14 @@
|
|||
#endif /* YAPOR */
|
||||
CACHE_Y(YREG);
|
||||
/* Alocate space for the cut_c structure*/
|
||||
CUT_C_PUSH(NEXTOP(NEXTOP(PREG,OtapFs),OtapFs),S_YREG);
|
||||
CUT_C_PUSH(NEXTOP(NEXTOP(PREG, OtapFs), OtapFs), S_YREG);
|
||||
S_YREG = S_YREG - PREG->y_u.OtapFs.extra;
|
||||
store_args(PREG->y_u.OtapFs.s);
|
||||
store_yaam_regs(NEXTOP(PREG, OtapFs), 0);
|
||||
store_yaam_regs(NEXTOP(P, OtapFs), 0);
|
||||
B = B_YREG;
|
||||
#ifdef YAPOR
|
||||
SCH_set_load(B_YREG);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
|
||||
|
@ -295,9 +306,9 @@
|
|||
{
|
||||
CPredicate f = (CPredicate)(PREG->y_u.OtapFs.f);
|
||||
saveregs();
|
||||
SREG = (CELL *) ((f) (PASS_REGS1));
|
||||
SREG = (CELL *)((f)(PASS_REGS1));
|
||||
/* This last instruction changes B B*/
|
||||
while (POP_CHOICE_POINT(B)){
|
||||
while (POP_CHOICE_POINT(B)) {
|
||||
cut_c_pop();
|
||||
}
|
||||
setregs();
|
||||
|
@ -306,11 +317,11 @@
|
|||
/* Removes the cut functions from the stack
|
||||
without executing them because we have fail
|
||||
and not cuted the predicate*/
|
||||
while(POP_CHOICE_POINT(B))
|
||||
while (POP_CHOICE_POINT(B))
|
||||
cut_c_pop();
|
||||
FAIL();
|
||||
}
|
||||
if ((CELL *) B == YREG && ASP != (CELL *) B) {
|
||||
if ((CELL *)B == YREG && ASP != (CELL *)B) {
|
||||
/* as Luis says, the predicate that did the try C might
|
||||
* have left some data on the stack. We should preserve
|
||||
* it, unless the builtin also did cut */
|
||||
|
@ -332,7 +343,7 @@
|
|||
ENV = B_YREG->cp_env;
|
||||
HR = PROTECT_FROZEN_H(B);
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH =B->cp_depth;
|
||||
DEPTH = B->cp_depth;
|
||||
#endif
|
||||
HBREG = HR;
|
||||
restore_args(PREG->y_u.OtapFs.s);
|
||||
|
@ -341,11 +352,12 @@
|
|||
ENDBOp();
|
||||
|
||||
BOp(cut_c, OtapFs);
|
||||
/*This is a phantom instruction. This is not executed by the WAM*/
|
||||
/*This is a phantom instruction. This is not executed by the WAM*/
|
||||
#ifdef DEBUG
|
||||
/*If WAM executes this instruction, probably there's an error
|
||||
when we put this instruction, cut_c, after retry_c*/
|
||||
printf ("ERROR: Should not print this message FILE: absmi.c %d\n",__LINE__);
|
||||
printf("ERROR: Should not print this message FILE: absmi.c %d\n",
|
||||
__LINE__);
|
||||
#endif /*DEBUG*/
|
||||
ENDBOp();
|
||||
|
||||
|
@ -355,7 +367,7 @@
|
|||
#endif /* YAPOR */
|
||||
CACHE_Y(YREG);
|
||||
/* Alocate space for the cut_c structure*/
|
||||
CUT_C_PUSH(NEXTOP(NEXTOP(PREG,OtapFs),OtapFs),S_YREG);
|
||||
CUT_C_PUSH(NEXTOP(NEXTOP(PREG, OtapFs), OtapFs), S_YREG);
|
||||
S_YREG = S_YREG - PREG->y_u.OtapFs.extra;
|
||||
store_args(PREG->y_u.OtapFs.s);
|
||||
store_yaam_regs(NEXTOP(PREG, OtapFs), 0);
|
||||
|
@ -369,15 +381,16 @@
|
|||
ASP = YREG;
|
||||
saveregs();
|
||||
save_machine_regs();
|
||||
SREG = (CELL *) YAP_ExecuteFirst(PREG->y_u.OtapFs.p, (CPredicate)(PREG->y_u.OtapFs.f));
|
||||
EX = NULL;
|
||||
SREG = (CELL *)YAP_ExecuteFirst(PREG->y_u.OtapFs.p,
|
||||
(CPredicate)(PREG->y_u.OtapFs.f));
|
||||
Yap_ResetException( worker_id );
|
||||
restore_machine_regs();
|
||||
setregs();
|
||||
LOCAL_PrologMode &= UserMode;
|
||||
if (!SREG) {
|
||||
FAIL();
|
||||
}
|
||||
if ((CELL *) B == YREG && ASP != (CELL *) B) {
|
||||
if ((CELL *)B == YREG && ASP != (CELL *)B) {
|
||||
/* as Luis says, the predicate that did the try C might
|
||||
* have left some data on the stack. We should preserve
|
||||
* it, unless the builtin also did cut */
|
||||
|
@ -399,18 +412,19 @@
|
|||
ENV = B_YREG->cp_env;
|
||||
HR = PROTECT_FROZEN_H(B);
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH =B->cp_depth;
|
||||
DEPTH = B->cp_depth;
|
||||
#endif
|
||||
HBREG = HR;
|
||||
restore_args(PREG->y_u.OtapFs.s);
|
||||
ENDCACHE_Y();
|
||||
|
||||
LOCAL_PrologMode |= UserCCallMode;
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
saveregs();
|
||||
save_machine_regs();
|
||||
SREG = (CELL *) YAP_ExecuteNext(PREG->y_u.OtapFs.p, (CPredicate)(PREG->y_u.OtapFs.f));
|
||||
EX = NULL;
|
||||
SREG = (CELL *)YAP_ExecuteNext(PREG->y_u.OtapFs.p,
|
||||
(CPredicate)(PREG->y_u.OtapFs.f));
|
||||
Yap_ResetException( worker_id);
|
||||
restore_machine_regs();
|
||||
setregs();
|
||||
LOCAL_PrologMode &= ~UserCCallMode;
|
||||
|
@ -418,11 +432,11 @@
|
|||
/* Removes the cut functions from the stack
|
||||
without executing them because we have fail
|
||||
and not cuted the predicate*/
|
||||
while(POP_CHOICE_POINT(B))
|
||||
while (POP_CHOICE_POINT(B))
|
||||
cut_c_pop();
|
||||
FAIL();
|
||||
}
|
||||
if ((CELL *) B == YREG && ASP != (CELL *) B) {
|
||||
if ((CELL *)B == YREG && ASP != (CELL *)B) {
|
||||
/* as Luis says, the predicate that did the try C might
|
||||
* have left some data on the stack. We should preserve
|
||||
* it, unless the builtin also did cut */
|
||||
|
@ -436,17 +450,17 @@
|
|||
ENDBOp();
|
||||
|
||||
BOp(cut_userc, OtapFs);
|
||||
/*This is a phantom instruction. This is not executed by the WAM*/
|
||||
/*This is a phantom instruction. This is not executed by the WAM*/
|
||||
#ifdef DEBUG
|
||||
/*If WAM executes this instruction, probably there's an error
|
||||
when we put this instruction, cut_userc, after retry_userc*/
|
||||
printf ("ERROR: Should not print this message FILE: absmi.c %d\n",__LINE__);
|
||||
printf("ERROR: Should not print this message FILE: absmi.c %d\n",
|
||||
__LINE__);
|
||||
#endif /*DEBUG*/
|
||||
CACHE_A1();
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
|
||||
|
||||
/************************************************************************\
|
||||
* support instructions *
|
||||
\************************************************************************/
|
||||
|
@ -454,10 +468,10 @@
|
|||
BOp(lock_pred, e);
|
||||
{
|
||||
PredEntry *ap = PredFromDefCode(PREG);
|
||||
PELOCK(10,ap);
|
||||
PELOCK(10, ap);
|
||||
PP = ap;
|
||||
if (!ap->cs.p_code.NOfClauses) {
|
||||
UNLOCKPE(11,ap);
|
||||
UNLOCKPE(11, ap);
|
||||
FAIL();
|
||||
}
|
||||
/*
|
||||
|
@ -467,10 +481,11 @@
|
|||
if (ap->cs.p_code.NOfClauses > 1 &&
|
||||
!(ap->PredFlags & IndexedPredFlag)) {
|
||||
/* update ASP before calling IPred */
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
saveregs();
|
||||
Yap_IPred(ap, 0, CP);
|
||||
/* IPred can generate errors, it thus must get rid of the lock itself */
|
||||
/* IPred can generate errors, it thus must get rid of the lock itself
|
||||
*/
|
||||
setregs();
|
||||
CACHE_A1();
|
||||
/* for profiler */
|
||||
|
@ -490,12 +505,12 @@
|
|||
we must take extra care here
|
||||
*/
|
||||
if (!PP) {
|
||||
PELOCK(11,ap);
|
||||
PELOCK(11, ap);
|
||||
}
|
||||
if (ap->OpcodeOfPred != INDEX_OPCODE) {
|
||||
/* someone was here before we were */
|
||||
if (!PP) {
|
||||
UNLOCKPE(11,ap);
|
||||
UNLOCKPE(11, ap);
|
||||
}
|
||||
PREG = ap->CodeOfPred;
|
||||
/* for profiler */
|
||||
|
@ -504,7 +519,7 @@
|
|||
}
|
||||
#endif
|
||||
/* update ASP before calling IPred */
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
saveregs();
|
||||
Yap_IPred(ap, 0, CP);
|
||||
/* IPred can generate errors, it thus must get rid of the lock itself */
|
||||
|
@ -516,8 +531,7 @@
|
|||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (!PP)
|
||||
#endif
|
||||
UNLOCKPE(14,ap);
|
||||
|
||||
UNLOCKPE(14, ap);
|
||||
}
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
|
@ -541,15 +555,15 @@
|
|||
yamop *pt0;
|
||||
|
||||
/* update ASP before calling IPred */
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (!PP) {
|
||||
PELOCK(12,pe);
|
||||
PELOCK(12, pe);
|
||||
}
|
||||
if (!same_lu_block(PREG_ADDR, PREG)) {
|
||||
PREG = *PREG_ADDR;
|
||||
if (!PP) {
|
||||
UNLOCKPE(15,pe);
|
||||
UNLOCKPE(15, pe);
|
||||
}
|
||||
JMPNext();
|
||||
}
|
||||
|
@ -567,7 +581,7 @@
|
|||
PREG = pt0;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (!PP) {
|
||||
UNLOCKPE(12,pe);
|
||||
UNLOCKPE(12, pe);
|
||||
}
|
||||
#endif
|
||||
JMPNext();
|
||||
|
@ -580,49 +594,53 @@
|
|||
yamop *pt0;
|
||||
|
||||
/* update ASP before calling IPred */
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (PP == NULL) {
|
||||
PELOCK(13,pe);
|
||||
PELOCK(13, pe);
|
||||
}
|
||||
if (!same_lu_block(PREG_ADDR, PREG)) {
|
||||
PREG = *PREG_ADDR;
|
||||
if (!PP) {
|
||||
UNLOCKPE(16,pe);
|
||||
UNLOCKPE(16, pe);
|
||||
}
|
||||
JMPNext();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
saveregs();
|
||||
pt0 = Yap_ExpandIndex(pe, 0);
|
||||
/* restart index */
|
||||
setregs();
|
||||
PREG = pt0;
|
||||
saveregs();
|
||||
pt0 = Yap_ExpandIndex(pe, 0);
|
||||
/* restart index */
|
||||
setregs();
|
||||
PREG = pt0;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (!PP) {
|
||||
UNLOCKPE(18,pe);
|
||||
}
|
||||
if (!PP) {
|
||||
UNLOCKPE(18, pe);
|
||||
}
|
||||
#endif
|
||||
JMPNext();
|
||||
JMPNext();
|
||||
}
|
||||
ENDBOp();
|
||||
|
||||
BOp(undef_p, e);
|
||||
/* save S for module name */
|
||||
saveregs();
|
||||
undef_goal( PASS_REGS1 );
|
||||
if (LOCAL_DoingUndefp) {
|
||||
PREG=FAILCODE;
|
||||
JMPNext();
|
||||
}
|
||||
LOCAL_DoingUndefp = true;
|
||||
saveregs();
|
||||
undef_goal(PASS_REGS1);
|
||||
setregs();
|
||||
/* for profiler */
|
||||
LOCAL_DoingUndefp = false;
|
||||
CACHE_A1();
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
|
||||
BOp(spy_pred, e);
|
||||
saveregs();
|
||||
spy_goal( PASS_REGS1 );
|
||||
spy_goal(PASS_REGS1);
|
||||
setregs();
|
||||
CACHE_A1();
|
||||
JMPNext();
|
||||
ENDBOp();
|
||||
|
||||
|
||||
|
|
701
C/globals.c
701
C/globals.c
File diff suppressed because it is too large
Load Diff
103
C/gmp_support.c
103
C/gmp_support.c
|
@ -18,7 +18,7 @@
|
|||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@ MkBigAndClose(MP_INT *new)
|
|||
Term t = Yap_MkBigIntTerm(new);
|
||||
mpz_clear(new);
|
||||
if (t == TermNil) {
|
||||
return Yap_ArithError(RESOURCE_ERROR_STACK, t, ">>/2");
|
||||
Yap_ArithError(RESOURCE_ERROR_STACK, t, ">>/2");
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ MkRatAndClose(MP_RAT *new)
|
|||
Term t = Yap_MkBigRatTerm(new);
|
||||
mpq_clear(new);
|
||||
if (t == TermNil) {
|
||||
return Yap_ArithError(RESOURCE_ERROR_STACK, t, ">>/2");
|
||||
Yap_ArithError(RESOURCE_ERROR_STACK, t, ">>/2");
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ Yap_gmp_div_big_int(Term t, Int i)
|
|||
if (i > 0) {
|
||||
mpz_tdiv_q_ui(&new, &new, i);
|
||||
} else if (i == 0) {
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, MkIntTerm(0), "// /2");
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, MkIntTerm(0), "// /2");
|
||||
} else {
|
||||
/* we do not handle MIN_INT */
|
||||
mpz_tdiv_q_ui(&new, &new, -i);
|
||||
|
@ -253,7 +253,7 @@ Yap_gmp_div_big_int(Term t, Int i)
|
|||
if (i > 0) {
|
||||
mpz_fdiv_q_ui(&new, &new, i);
|
||||
} else if (i == 0) {
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, MkIntTerm(0), "// /2");
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, MkIntTerm(0), "// /2");
|
||||
} else {
|
||||
/* we do not handle MIN_INT */
|
||||
mpz_fdiv_q_ui(&new, &new, -i);
|
||||
|
@ -285,7 +285,7 @@ Yap_gmp_div2_big_int(Term t, Int i)
|
|||
if (i > 0) {
|
||||
mpz_fdiv_q_ui(&new, &new, i);
|
||||
} else if (i == 0) {
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, MkIntTerm(0), "// /2");
|
||||
Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, MkIntTerm(0), "// /2");
|
||||
} else {
|
||||
/* we do not handle MIN_INT */
|
||||
mpz_fdiv_q_ui(&new, &new, -i);
|
||||
|
@ -311,7 +311,7 @@ Yap_gmp_and_int_big(Int i, Term t)
|
|||
CELL *pt = RepAppl(t);
|
||||
MP_INT *b;
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "/\\/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "/\\/2");
|
||||
}
|
||||
b = Yap_BigIntOfTerm(t);
|
||||
|
||||
|
@ -328,7 +328,7 @@ Yap_gmp_ior_int_big(Int i, Term t)
|
|||
CELL *pt = RepAppl(t);
|
||||
MP_INT *b;
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "\\/ /2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "\\/ /2");
|
||||
}
|
||||
b = Yap_BigIntOfTerm(t);
|
||||
|
||||
|
@ -367,7 +367,7 @@ Yap_gmp_xor_int_big(Int i, Term t)
|
|||
CELL *pt = RepAppl(t);
|
||||
MP_INT *b;
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "#/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "#/2");
|
||||
}
|
||||
b = Yap_BigIntOfTerm(t);
|
||||
|
||||
|
@ -394,7 +394,7 @@ Yap_gmp_sll_big_int(Term t, Int i)
|
|||
mpz_init(&new);
|
||||
if (i == Int_MIN) {
|
||||
CACHE_REGS
|
||||
return Yap_ArithError(RESOURCE_ERROR_HUGE_INT, MkIntegerTerm(i), "<</2");
|
||||
Yap_ArithError(RESOURCE_ERROR_HUGE_INT, MkIntegerTerm(i), "<</2");
|
||||
}
|
||||
mpz_fdiv_q_2exp(&new, b, -i);
|
||||
}
|
||||
|
@ -628,9 +628,9 @@ Yap_gmp_and_big_big(Term t1, Term t2)
|
|||
return MkBigAndClose(&new);
|
||||
} else {
|
||||
if (pt1[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "/\\/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "/\\/2");
|
||||
}
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "/\\/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "/\\/2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -649,9 +649,9 @@ Yap_gmp_ior_big_big(Term t1, Term t2)
|
|||
return MkBigAndClose(&new);
|
||||
} else {
|
||||
if (pt1[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "\\/ /2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "\\/ /2");
|
||||
}
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -670,9 +670,9 @@ Yap_gmp_xor_big_big(Term t1, Term t2)
|
|||
return MkBigAndClose(&new);
|
||||
} else {
|
||||
if (pt1[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "\\/ /2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "\\/ /2");
|
||||
}
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -691,9 +691,9 @@ Yap_gmp_mod_big_big(Term t1, Term t2)
|
|||
return MkBigAndClose(&new);
|
||||
} else {
|
||||
if (pt1[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "mod/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "mod/2");
|
||||
}
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ Yap_gmp_mod_big_int(Term t, Int i2)
|
|||
{
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "mod/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "mod/2");
|
||||
} else {
|
||||
MP_INT *b = Yap_BigIntOfTerm(t);
|
||||
MP_INT new;
|
||||
|
@ -719,7 +719,7 @@ Yap_gmp_mod_int_big(Int i1, Term t)
|
|||
CACHE_REGS
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "mod/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "mod/2");
|
||||
} else {
|
||||
MP_INT *b = Yap_BigIntOfTerm(t);
|
||||
/* integer is much smaller */
|
||||
|
@ -768,9 +768,9 @@ Yap_gmp_rem_big_big(Term t1, Term t2)
|
|||
return MkBigAndClose(&new);
|
||||
} else {
|
||||
if (pt1[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "rem/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "rem/2");
|
||||
}
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rem/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rem/2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -779,7 +779,7 @@ Yap_gmp_rem_big_int(Term t, Int i2)
|
|||
{
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "rem/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "rem/2");
|
||||
} else {
|
||||
MP_INT *b = Yap_BigIntOfTerm(t);
|
||||
MP_INT new;
|
||||
|
@ -796,7 +796,7 @@ Yap_gmp_rem_int_big(Int i1, Term t)
|
|||
CACHE_REGS
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "rem/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "rem/2");
|
||||
} else {
|
||||
/* integer is much smaller */
|
||||
return MkIntegerTerm(i1);
|
||||
|
@ -818,9 +818,9 @@ Yap_gmp_gcd_big_big(Term t1, Term t2)
|
|||
return MkBigAndClose(&new);
|
||||
} else {
|
||||
if (pt1[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "gcd/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t1, "gcd/2");
|
||||
}
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -830,7 +830,7 @@ Yap_gmp_gcd_int_big(Int i, Term t)
|
|||
CACHE_REGS
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] != BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "gcd/2");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "gcd/2");
|
||||
} else {
|
||||
/* integer is much smaller */
|
||||
if (i > 0) {
|
||||
|
@ -992,7 +992,7 @@ Yap_gmp_exp_int_big(Int i, Term t)
|
|||
CACHE_REGS
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] == BIG_INT) {
|
||||
return Yap_ArithError(RESOURCE_ERROR_HUGE_INT, t, "^/2");
|
||||
Yap_ArithError(RESOURCE_ERROR_HUGE_INT, t, "^/2");
|
||||
} else {
|
||||
MP_INT *b = Yap_BigIntOfTerm(t);
|
||||
Float dbl = mpz_get_d(b);
|
||||
|
@ -1009,7 +1009,7 @@ Yap_gmp_exp_big_big(Term t1, Term t2)
|
|||
Float dbl1, dbl2;
|
||||
|
||||
if (pt1[1] == BIG_INT && pt2[1] == BIG_INT) {
|
||||
return Yap_ArithError(RESOURCE_ERROR_HUGE_INT, t2, "^/2");
|
||||
Yap_ArithError(RESOURCE_ERROR_HUGE_INT, t2, "^/2");
|
||||
} else {
|
||||
if (pt1[1] != BIG_INT) {
|
||||
dbl1 = mpz_get_d(Yap_BigIntOfTerm(t1));
|
||||
|
@ -1234,6 +1234,19 @@ Yap_gmp_cmp_big_int(Term t, Int i)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
Yap_gmp_cmp_int_big(Int i, Term t)
|
||||
{
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] == BIG_INT) {
|
||||
MP_INT *b = Yap_BigIntOfTerm(t);
|
||||
return -mpz_cmp_si(b,i);
|
||||
} else {
|
||||
MP_RAT *b = Yap_BigRatOfTerm(t);
|
||||
return -mpq_cmp_si(b,i,1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Yap_gmp_cmp_big_float(Term t, Float d)
|
||||
{
|
||||
|
@ -1304,6 +1317,18 @@ Yap_gmp_tcmp_big_int(Term t, Int i)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
Yap_gmp_tcmp_int_big(Int i, Term t)
|
||||
{
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] == BIG_INT) {
|
||||
MP_INT *b = Yap_BigIntOfTerm(t);
|
||||
return -mpz_cmp_si(b,i);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Yap_gmp_tcmp_big_float(Term t, Float d)
|
||||
{
|
||||
|
@ -1451,7 +1476,7 @@ Yap_gmp_unot_big(Term t)
|
|||
mpz_com(&new, &new);
|
||||
return MkBigAndClose(&new);
|
||||
} else {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "#/1");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "#/1");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1571,7 @@ Yap_gmp_float_fractional_part(Term t)
|
|||
{
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] == BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_fractional_part(%f)", FloatOfTerm(t));
|
||||
Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_fractional_part(%f)", FloatOfTerm(t));
|
||||
} else {
|
||||
MP_RAT *b = Yap_BigRatOfTerm(t);
|
||||
MP_RAT new;
|
||||
|
@ -1566,7 +1591,7 @@ Yap_gmp_float_integer_part(Term t)
|
|||
{
|
||||
CELL *pt = RepAppl(t);
|
||||
if (pt[1] == BIG_INT) {
|
||||
return Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_integer_part(%f)", FloatOfTerm(t));
|
||||
Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_integer_part(%f)", FloatOfTerm(t));
|
||||
} else {
|
||||
MP_RAT *b = Yap_BigRatOfTerm(t);
|
||||
MP_INT new;
|
||||
|
@ -1599,12 +1624,12 @@ Yap_gmp_lsb(Term t)
|
|||
if (pt[1] == BIG_INT) {
|
||||
MP_INT *big = Yap_BigIntOfTerm(t);
|
||||
if ( mpz_sgn(big) <= 0 ) {
|
||||
return Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t,
|
||||
Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t,
|
||||
"lsb/1 received negative bignum");
|
||||
}
|
||||
return MkIntegerTerm(mpz_scan1(big,0));
|
||||
} else {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "lsb");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "lsb");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1616,12 +1641,12 @@ Yap_gmp_msb(Term t)
|
|||
if (pt[1] == BIG_INT) {
|
||||
MP_INT *big = Yap_BigIntOfTerm(t);
|
||||
if ( mpz_sgn(big) <= 0 ) {
|
||||
return Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t,
|
||||
Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t,
|
||||
"msb/1 received negative bignum");
|
||||
}
|
||||
return MkIntegerTerm(mpz_sizeinbase(big,2));
|
||||
} else {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "popcount");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "popcount");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1633,17 +1658,17 @@ Yap_gmp_popcount(Term t)
|
|||
if (pt[1] == BIG_INT) {
|
||||
MP_INT *big = Yap_BigIntOfTerm(t);
|
||||
if ( mpz_sgn(big) <= 0 ) {
|
||||
return Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t,
|
||||
Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t,
|
||||
"popcount/1 received negative bignum");
|
||||
}
|
||||
return MkIntegerTerm(mpz_popcount(big));
|
||||
} else {
|
||||
return Yap_ArithError(TYPE_ERROR_INTEGER, t, "popcount");
|
||||
Yap_ArithError(TYPE_ERROR_INTEGER, t, "popcount");
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
Yap_mpz_to_string(MP_INT *b, char *s, size_t sz, int base)
|
||||
Yap_mpz_to_string( MP_INT *b, char *s, size_t sz, int base)
|
||||
{
|
||||
if (s) {
|
||||
size_t size = mpz_sizeinbase(b, base);
|
||||
|
|
80
C/gprof.c
80
C/gprof.c
|
@ -35,7 +35,7 @@
|
|||
* Revision 1.3 2006/01/17 14:10:40 vsc
|
||||
* YENV may be an HW register (breaks some tabling code)
|
||||
* All YAAM instructions are now brackedted, so Op introduced an { and EndOp introduces an }. This is because Ricardo assumes that.
|
||||
* Fix attvars when COROUTING is undefined.
|
||||
* Fix attvars
|
||||
*
|
||||
* Revision 1.2 2005/12/23 00:20:13 vsc
|
||||
* updates to gprof
|
||||
|
@ -47,40 +47,40 @@
|
|||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/// @file gprof.c
|
||||
|
||||
/** @defgroup Tick_Profiler Tick Profiler
|
||||
@ingroup Profiling
|
||||
@{
|
||||
|
||||
The tick profiler works by interrupting the Prolog code every so often
|
||||
and checking at each point the code was. The profiler must be able to
|
||||
retrace the state of the abstract machine at every moment. The major
|
||||
advantage of this approach is that it gives the actual amount of time
|
||||
being spent per procedure, or whether garbage collection dominates
|
||||
execution time. The major drawback is that tracking down the state of
|
||||
the abstract machine may take significant time, and in the worst case
|
||||
may slow down the whole execution.
|
||||
|
||||
The following procedures are available:
|
||||
|
||||
+ profinit
|
||||
|
||||
|
||||
Initialise the data-structures for the profiler. Unnecessary for
|
||||
dynamic profiler.
|
||||
|
||||
+ profon
|
||||
|
||||
|
||||
Start profiling.
|
||||
|
||||
+ profoff
|
||||
|
||||
|
||||
Stop profiling.
|
||||
|
||||
|
||||
*/
|
||||
/** @addtogroup Tick_Profiler
|
||||
* @ingroup Profiling@{
|
||||
*
|
||||
* The tick profiler works by interrupting the Prolog code every so often
|
||||
* and checking at each point the code was. The pro/filer must be able to
|
||||
* retrace the state of the abstract machine at every moment. The major
|
||||
* advantage of this approach is that it gives the actual amount of time
|
||||
* being spent per procedure, or whether garbage collection dominates
|
||||
* execution time. The major drawback is that tracking down the state of
|
||||
* the abstract machine may take significant time, and in the worst case
|
||||
* may slow down the whole execution.
|
||||
*
|
||||
* The following procedures are available:
|
||||
*
|
||||
* + profinit/0
|
||||
* Initialise the data-structures for the profiler. Unnecessary for
|
||||
* dynamic profiler.
|
||||
*
|
||||
* + profon/0
|
||||
* Start profiling.
|
||||
*
|
||||
* + profoff/0
|
||||
* Stop profiling.
|
||||
*
|
||||
* + profoff/0
|
||||
* Stop profiling.
|
||||
*
|
||||
* + showprofres/0 and showprofres/1
|
||||
* Stop tick counts per predicate.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
|
@ -728,20 +728,18 @@ return GLOBAL_DIRNAME;
|
|||
|
||||
char *profile_names(int);
|
||||
char *profile_names(int k) {
|
||||
static char *FNAME=NULL;
|
||||
char *FNAME=NULL;
|
||||
int size=200;
|
||||
|
||||
if (GLOBAL_DIRNAME==NULL) set_profile_dir(NULL);
|
||||
size=strlen(GLOBAL_DIRNAME)+40;
|
||||
if (FNAME!=NULL) free(FNAME);
|
||||
FNAME=malloc(size);
|
||||
if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
|
||||
strcpy(FNAME,GLOBAL_DIRNAME);
|
||||
|
||||
if (k==PROFILING_FILE) {
|
||||
sprintf(FNAME,"%s/PROFILING_%d",FNAME,getpid());
|
||||
sprintf(FNAME,"%s/PROFILING_%d",GLOBAL_DIRNAME,getpid());
|
||||
} else {
|
||||
sprintf(FNAME,"%s/PROFPREDS_%d",FNAME,getpid());
|
||||
sprintf(FNAME,"%s/PROFPREDS_%d",GLOBAL_DIRNAME,getpid());
|
||||
}
|
||||
|
||||
// printf("%s\n",FNAME);
|
||||
|
@ -841,7 +839,7 @@ static void RemoveCode(CODEADDR clau)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
showprofres( USES_REGS1 ) {
|
||||
buf_ptr buf;
|
||||
|
||||
|
@ -973,7 +971,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
|
|||
current_p = PREVOP(P,Osbpp)->y_u.Osbpp.p->CodeOfPred;
|
||||
} else if ((oop = Yap_op_from_opcode(P->opc)) == _execute_cpred) {
|
||||
/* doing C-code */
|
||||
current_p = P->y_u.pp.p->CodeOfPred;
|
||||
current_p = P->y_u.Osbpp.p->CodeOfPred;
|
||||
} else {
|
||||
current_p = P;
|
||||
}
|
||||
|
|
126
C/grow.c
126
C/grow.c
|
@ -20,7 +20,7 @@
|
|||
#include "yapio.h"
|
||||
#include "alloc.h"
|
||||
#include "sshift.h"
|
||||
#include "compile.h"
|
||||
#include "YapCompile.h"
|
||||
#include "attvar.h"
|
||||
#include "cut_c.h"
|
||||
#if HAVE_STRING_H
|
||||
|
@ -205,13 +205,13 @@ CopyLocalAndTrail( USES_REGS1 )
|
|||
static void
|
||||
IncrementalCopyStacksFromWorker( USES_REGS1 )
|
||||
{
|
||||
memcpy((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy),
|
||||
memmove((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy),
|
||||
(void *) (LOCAL_start_global_copy),
|
||||
(size_t) (LOCAL_end_global_copy - LOCAL_start_global_copy));
|
||||
memcpy((void *) PtoLocAdjust((CELL *)LOCAL_start_local_copy),
|
||||
memmove((void *) PtoLocAdjust((CELL *)LOCAL_start_local_copy),
|
||||
(void *) LOCAL_start_local_copy,
|
||||
(size_t) (LOCAL_end_local_copy - LOCAL_start_local_copy));
|
||||
memcpy((void *) PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy),
|
||||
memmove((void *) PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy),
|
||||
(void *) (LOCAL_start_trail_copy),
|
||||
(size_t) (LOCAL_end_trail_copy - LOCAL_start_trail_copy));
|
||||
}
|
||||
|
@ -324,15 +324,15 @@ MoveGlobalWithHole( USES_REGS1 )
|
|||
}
|
||||
|
||||
static void
|
||||
MoveHalfGlobal(CELL *OldPt USES_REGS)
|
||||
MoveHalfGlobal(CELL *OldPt, size_t request USES_REGS)
|
||||
{
|
||||
/*
|
||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||
* absmi.asm
|
||||
*/
|
||||
UInt diff = LOCAL_OldH-OldPt;
|
||||
CELL *NewPt = (CELL *)((char*)OldPt+LOCAL_GDiff);
|
||||
CELL *IntPt = (CELL *)((char*)OldPt+LOCAL_GDiff0);
|
||||
CELL *NewPt = IntPt+request/sizeof(CELL);
|
||||
cpcellsd(NewPt, IntPt, diff);
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ AdjustTrail(bool adjusting_heap, bool thread_copying USES_REGS)
|
|||
register CELL reg = TrailTerm(ptt-1);
|
||||
#ifdef FROZEN_STACKS
|
||||
register CELL reg2 = TrailVal(ptt-1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ptt--;
|
||||
if (IsVarTerm(reg)) {
|
||||
|
@ -436,6 +436,8 @@ fixPointerCells(CELL *pt, CELL *pt_bot, bool thread_copying USES_REGS)
|
|||
{
|
||||
while (pt > pt_bot) {
|
||||
CELL reg = *--pt;
|
||||
// if (pt-pt_bot> 4300 && pt-pt_bot < 4500)
|
||||
// printf("%d %d %lx\n", pt-pt_bot, pt-LOCAL_GSplit, reg);
|
||||
if (IsVarTerm(reg)) {
|
||||
if (IsOldLocal(reg))
|
||||
*pt = LocalAdjust(reg);
|
||||
|
@ -450,6 +452,8 @@ fixPointerCells(CELL *pt, CELL *pt_bot, bool thread_copying USES_REGS)
|
|||
} else if (IsPairTerm(reg)) {
|
||||
*pt = AdjustPair(reg PASS_REGS);
|
||||
}
|
||||
// if (pt-pt_bot> 4300 && pt-pt_bot < 4500)
|
||||
// printf("%lx\n", *pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,8 +590,8 @@ AdjustGlobal(Int sz, bool thread_copying USES_REGS)
|
|||
(sizeof(MP_INT)+
|
||||
(((MP_INT *)(pt+2))->_mp_alloc*sizeof(mp_limb_t)))/CellSize;
|
||||
//printf("sz *%ld* at @%ld@\n", sz, pt-H0);
|
||||
Opaque_CallOnGCMark f;
|
||||
Opaque_CallOnGCRelocate f2;
|
||||
YAP_Opaque_CallOnGCMark f;
|
||||
YAP_Opaque_CallOnGCRelocate f2;
|
||||
Term t = AbsAppl(pt);
|
||||
|
||||
if ( (f = Yap_blob_gc_mark_handler(t)) ) {
|
||||
|
@ -749,9 +753,7 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep USES_REGS)
|
|||
break;
|
||||
case Var_tok:
|
||||
case String_tok:
|
||||
case WString_tok:
|
||||
case BQString_tok:
|
||||
case WBQString_tok:
|
||||
if (IsOldTrail(tks->TokInfo))
|
||||
tks->TokInfo = TrailAdjust(tks->TokInfo);
|
||||
break;
|
||||
|
@ -834,7 +836,7 @@ static_growheap(size_t esize, bool fix_code, struct intermediates *cip, tr_fr_pt
|
|||
fprintf( stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf( stderr, "%% Database Overflow %d\n", LOCAL_heap_overflows);
|
||||
fprintf( stderr, "%% growing the heap %ld bytes\n", size);
|
||||
fprintf( stderr, "%% growing the heap " Int_FORMAT " bytes\n", size);
|
||||
}
|
||||
/* CreepFlag is set to force heap expansion */
|
||||
if ( Yap_only_has_signal( YAP_CDOVF_SIGNAL) ) {
|
||||
|
@ -888,15 +890,13 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
{
|
||||
UInt start_growth_time, growth_time;
|
||||
int gc_verbose;
|
||||
char *omax = (char *)H0;
|
||||
ADDR old_GlobalBase = LOCAL_GlobalBase;
|
||||
UInt minimal_request = 0L;
|
||||
Int size = request;
|
||||
char vb_msg1 = '\0', *vb_msg2;
|
||||
Int size = request/sizeof(CELL);
|
||||
char vb_msg1 = '\0', *vb_msg2 = "";
|
||||
bool do_grow = true;
|
||||
bool insert_in_delays = false;
|
||||
/*
|
||||
request is the amount of memory we requested, in bytes;
|
||||
request is the amount of memory we requesd, in bytes;
|
||||
base_move is the shift in global stacks we had to do
|
||||
size is how much space we allocate: it's negative if we just expand
|
||||
the delay stack.
|
||||
|
@ -904,55 +904,41 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
*/
|
||||
|
||||
if (hsplit) {
|
||||
/* just a little bit of sanity checking */
|
||||
if (hsplit < H0 && hsplit > (CELL *)LOCAL_GlobalBase) {
|
||||
insert_in_delays = TRUE;
|
||||
/* expanding attributed variables */
|
||||
if (omax - size > LOCAL_GlobalBase+4096*sizeof(CELL)) {
|
||||
/* we can just ask for more room */
|
||||
size = 0;
|
||||
do_grow = FALSE;
|
||||
}
|
||||
} else if (hsplit < (CELL*)omax ||
|
||||
if (hsplit < H0 ||
|
||||
hsplit > HR)
|
||||
return FALSE;
|
||||
else if (hsplit == (CELL *)omax)
|
||||
hsplit = NULL;
|
||||
if (size < 0 ||
|
||||
(Unsigned(HR)+size < Unsigned(ASP)-StackGap( PASS_REGS1 ) &&
|
||||
hsplit > H0)) {
|
||||
/* don't need to expand stacks */
|
||||
insert_in_delays = FALSE;
|
||||
do_grow = FALSE;
|
||||
}
|
||||
} else {
|
||||
if (Unsigned(HR)+size < Unsigned(ASP)-CreepFlag) {
|
||||
/* we can just ask for more room */
|
||||
do_grow = FALSE;
|
||||
return false;
|
||||
if (hsplit == HR && Unsigned(HR)+request < Unsigned(ASP)-StackGap( PASS_REGS1 )) {
|
||||
HR += request/sizeof(CELL);
|
||||
return request;
|
||||
}
|
||||
}
|
||||
if (size < 0 ||
|
||||
(Unsigned(HR)+request < Unsigned(ASP-StackGap( PASS_REGS1 )))) {
|
||||
do_grow = false;
|
||||
}
|
||||
if (do_grow) {
|
||||
if (size < YAP_ALLOC_SIZE)
|
||||
size = YAP_ALLOC_SIZE;
|
||||
size = AdjustPageSize(size);
|
||||
if (request < YAP_ALLOC_SIZE)
|
||||
request = YAP_ALLOC_SIZE;
|
||||
request = AdjustPageSize(request);
|
||||
}
|
||||
/* adjust to a multiple of 256) */
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
LOCAL_PrologMode |= GrowStackMode;
|
||||
start_growth_time = Yap_cputime();
|
||||
|
||||
if (do_grow) {
|
||||
if (!GLOBAL_AllowGlobalExpansion) {
|
||||
LOCAL_ErrorMessage = "Global Stack crashed against Local Stack";
|
||||
LeaveGrowMode(GrowStackMode);
|
||||
return 0;
|
||||
}
|
||||
if (!GLOBAL_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) {
|
||||
if (!GLOBAL_AllowGlobalExpansion || !Yap_ExtendWorkSpace(request)) {
|
||||
/* always fails when using malloc */
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
size += AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+MinHeapGap);
|
||||
minimal_request = size;
|
||||
size = Yap_ExtendWorkSpaceThroughHole(size);
|
||||
if (size < 0) {
|
||||
request += AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+MinHeapGap);
|
||||
minimal_request = request;
|
||||
request = Yap_ExtendWorkSpaceThroughHole(request);
|
||||
if (request < 0) {
|
||||
LOCAL_ErrorMessage = "Global Stack crashed against Local Stack";
|
||||
LeaveGrowMode(GrowStackMode);
|
||||
return 0;
|
||||
|
@ -960,15 +946,11 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
}
|
||||
}
|
||||
gc_verbose = Yap_is_gc_verbose();
|
||||
LOCAL_delay_overflows++;
|
||||
if (gc_verbose) {
|
||||
if (hsplit) {
|
||||
if (hsplit > H0) {
|
||||
vb_msg1 = 'H';
|
||||
vb_msg2 = "Global Variable Space";
|
||||
} else {
|
||||
vb_msg1 = 'D';
|
||||
vb_msg2 = "Global Variable Delay Space";
|
||||
}
|
||||
} else {
|
||||
vb_msg1 = 'D';
|
||||
|
@ -978,7 +960,7 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
fprintf(stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(stderr, "%% %cO %s Overflow %d\n", vb_msg1, vb_msg2, LOCAL_delay_overflows);
|
||||
fprintf(stderr, "%% %cO growing the stacks %ld bytes\n", vb_msg1, size);
|
||||
fprintf(stderr, "%% %cO growing the stacks " UInt_FORMAT " bytes\n", vb_msg1, request);
|
||||
}
|
||||
ASP -= 256;
|
||||
YAPEnterCriticalSection();
|
||||
|
@ -987,13 +969,13 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
/* we got over a hole */
|
||||
if (minimal_request) {
|
||||
/* we went over a hole */
|
||||
LOCAL_BaseDiff = size+((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)-minimal_request;
|
||||
LOCAL_LDiff = LOCAL_TrDiff = size;
|
||||
LOCAL_BaseDiff = request+((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)-minimal_request;
|
||||
LOCAL_LDiff = LOCAL_TrDiff = request;
|
||||
} else {
|
||||
/* we may still have an overflow */
|
||||
LOCAL_BaseDiff = LOCAL_GlobalBase - old_GlobalBase;
|
||||
/* if we grow, we need to move the stacks */
|
||||
LOCAL_LDiff = LOCAL_TrDiff = LOCAL_BaseDiff+size;
|
||||
LOCAL_LDiff = LOCAL_TrDiff = LOCAL_BaseDiff+request;
|
||||
}
|
||||
} else {
|
||||
/* stay still */
|
||||
|
@ -1004,25 +986,21 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
hole in global */
|
||||
if (!hsplit) {
|
||||
if (!do_grow) {
|
||||
LOCAL_DelayDiff = LOCAL_GDiff = LOCAL_GDiff0 = size;
|
||||
LOCAL_GDiff = LOCAL_GDiff0 = request;
|
||||
request = 0L;
|
||||
} else {
|
||||
/* expand delay stack */
|
||||
LOCAL_DelayDiff = LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_LDiff;
|
||||
}
|
||||
} else if (insert_in_delays) {
|
||||
/* we want to expand a hole for the delay stack */
|
||||
LOCAL_DelayDiff = size-request;
|
||||
LOCAL_GDiff = LOCAL_GDiff0 = size;
|
||||
LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_LDiff;
|
||||
}
|
||||
} else {
|
||||
/* we want to expand a hole for the delay stack */
|
||||
LOCAL_GDiff0 = LOCAL_DelayDiff = LOCAL_BaseDiff;
|
||||
LOCAL_GDiff0 = LOCAL_BaseDiff;
|
||||
LOCAL_GDiff = LOCAL_BaseDiff+request;
|
||||
}
|
||||
LOCAL_GSplit = hsplit;
|
||||
LOCAL_XDiff = LOCAL_HDiff = 0;
|
||||
LOCAL_GlobalBase = old_GlobalBase;
|
||||
SetHeapRegs(FALSE PASS_REGS);
|
||||
SetHeapRegs(FALSE PASS_REGS);
|
||||
if (do_grow) {
|
||||
MoveLocalAndTrail( PASS_REGS1 );
|
||||
if (hsplit) {
|
||||
|
@ -1044,17 +1022,12 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
*ptr = PtoLocAdjust(*ptr);
|
||||
}
|
||||
if (hsplit) {
|
||||
if (insert_in_delays) {
|
||||
/* we have things not quite where we want to have them */
|
||||
cpcellsd((CELL *)(omax+LOCAL_DelayDiff), (CELL *)(omax+LOCAL_GDiff0), (ADDR)hsplit-omax);
|
||||
} else {
|
||||
MoveHalfGlobal(hsplit PASS_REGS);
|
||||
}
|
||||
MoveHalfGlobal(hsplit, request PASS_REGS);
|
||||
}
|
||||
YAPLeaveCriticalSection();
|
||||
ASP += 256;
|
||||
if (minimal_request) {
|
||||
Yap_AllocHole(minimal_request, size);
|
||||
Yap_AllocHole(minimal_request, request);
|
||||
}
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_delay_overflow_time += growth_time;
|
||||
|
@ -1065,8 +1038,9 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||
LeaveGrowMode(GrowStackMode);
|
||||
if (hsplit) {
|
||||
return request;
|
||||
} else
|
||||
} else {
|
||||
return LOCAL_GDiff-LOCAL_BaseDiff;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1505,7 +1479,7 @@ Yap_growheap(bool fix_code, size_t in_size, void *cip)
|
|||
int
|
||||
Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
{
|
||||
CACHE_REGS
|
||||
CACHE_REGS
|
||||
int res;
|
||||
|
||||
res=do_growheap(FALSE, 0L, NULL, old_trp, tksp, vep PASS_REGS);
|
||||
|
@ -1796,7 +1770,7 @@ static int do_growtrail(size_t esize, bool contiguous_only, bool in_parser, tr_f
|
|||
fprintf(stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
|
||||
#endif
|
||||
fprintf(stderr, "%% growing the trail %ld bytes\n", size);
|
||||
fprintf(stderr, "%% growing the trail " UInt_FORMAT " bytes\n", size);
|
||||
}
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
if (!GLOBAL_AllowTrailExpansion) {
|
||||
|
|
407
C/heapgc.c
407
C/heapgc.c
File diff suppressed because it is too large
Load Diff
197
C/init.c
197
C/init.c
|
@ -25,11 +25,12 @@ static char SccsId[] = "%W% %G%";
|
|||
|
||||
#define __INIT_C__ 1
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "Yap.h"
|
||||
#include "alloc.h"
|
||||
#include "clause.h"
|
||||
#include "yapio.h"
|
||||
#include "alloc.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Foreign.h"
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
|
@ -56,6 +57,10 @@ static char SccsId[] = "%W% %G%";
|
|||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef YAPOR
|
||||
Atom AtomFoundVar, AtomFreeTerm, AtomNil, AtomDot;
|
||||
#endif // !YAPOR
|
||||
|
||||
int Yap_output_msg = FALSE;
|
||||
|
||||
#if DEBUG
|
||||
|
@ -70,8 +75,8 @@ static void SetOp(int, int, char *, Term);
|
|||
static void InitOps(void);
|
||||
static void InitDebug(void);
|
||||
static void CleanBack(PredEntry *, CPredicate, CPredicate, CPredicate);
|
||||
static void InitStdPreds(void);
|
||||
static void InitCodes(void);
|
||||
static void InitStdPreds(struct yap_boot_params *yapi);
|
||||
static void InitCodes(struct yap_boot_params *yapi);
|
||||
static void InitVersion(void);
|
||||
void exit(int);
|
||||
static void InitWorker(int wid);
|
||||
|
@ -93,17 +98,17 @@ int Yap_Portray_delays = FALSE;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
void *YAP_save;
|
||||
|
||||
/**
|
||||
|
||||
@defgroup Operators Summary of YAP Predefined Operators
|
||||
@ingroup Syntax
|
||||
@ingroup YAPSyntax
|
||||
@{
|
||||
|
||||
|
||||
|
||||
The Prolog syntax caters for operators of three main kinds:
|
||||
|
||||
+ prefix;
|
||||
+ prefix;
|
||||
+ infix;
|
||||
+ postfix.
|
||||
|
||||
|
@ -160,8 +165,10 @@ The following is the list of the declarations of the predefined operators:
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
:-op(1200,fx,['?-', ':-']).
|
||||
:-op(1200,xfx,[':-','-->']).
|
||||
:-op(1150,fx,[block,dynamic,mode,public,multifile,meta_predicate,
|
||||
sequential,table,initialization]).
|
||||
:-op(1150,fx,[block,
|
||||
discontiguous,dynamic,
|
||||
initialization,mode,multifile,meta_predicate,
|
||||
public,sequential,table]).
|
||||
:-op(1100,xfy,[';','|']).
|
||||
:-op(1050,xfy,->).
|
||||
:-op(1000,xfy,',').
|
||||
|
@ -201,10 +208,17 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
|||
AtomEntry *ae = RepAtom(a);
|
||||
OpEntry *info;
|
||||
|
||||
if (m == TermProlog)
|
||||
m = PROLOG_MODULE;
|
||||
else if (m == USER_MODULE)
|
||||
#if defined(MODULE_INDEPENDENT_OPERATORS_FLAG)
|
||||
if (booleanFlag(MODULE_INDEPENDENT_OPERATORS_FLAG)) {
|
||||
m = PROLOG_MODULE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (m == TermProlog)
|
||||
m = PROLOG_MODULE;
|
||||
else if (m == USER_MODULE)
|
||||
m = PROLOG_MODULE;
|
||||
}
|
||||
for (i = 1; i <= 7; ++i)
|
||||
if (strcmp(type, optypes[i]) == 0)
|
||||
break;
|
||||
|
@ -222,8 +236,13 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
|||
WRITE_LOCK(ae->ARWLock);
|
||||
info = Yap_GetOpPropForAModuleHavingALock(ae, m);
|
||||
if (EndOfPAEntr(info)) {
|
||||
ModEntry *me;
|
||||
info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry));
|
||||
if (!info)
|
||||
return false;
|
||||
info->KindOfPE = Ord(OpProperty);
|
||||
info->NextForME = (me = Yap_GetModuleEntry(m))->OpForME;
|
||||
me->OpForME = info;
|
||||
info->OpModule = m;
|
||||
info->OpName = a;
|
||||
// LOCK(OpListLock);
|
||||
|
@ -245,7 +264,7 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
|||
/* ISO dictates */
|
||||
WRITE_UNLOCK(info->OpRWLock);
|
||||
Yap_Error(PERMISSION_ERROR_CREATE_OPERATOR, MkAtomTerm(a), "op/3");
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
info->Infix = p;
|
||||
} else if (i <= 5) {
|
||||
|
@ -255,14 +274,14 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
|||
/* ISO dictates */
|
||||
WRITE_UNLOCK(info->OpRWLock);
|
||||
Yap_Error(PERMISSION_ERROR_CREATE_OPERATOR, MkAtomTerm(a), "op/3");
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
info->Posfix = p;
|
||||
} else {
|
||||
info->Prefix = p;
|
||||
}
|
||||
WRITE_UNLOCK(info->OpRWLock);
|
||||
return (TRUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
int Yap_OpDec(int p, char *type, Atom a, Term m) {
|
||||
|
@ -277,6 +296,20 @@ static void SetOp(int p, int type, char *at, Term m) {
|
|||
OpDec(p, optypes[type], Yap_LookupAtom(at), m);
|
||||
}
|
||||
|
||||
bool Yap_dup_op(OpEntry *op, ModEntry *she) {
|
||||
AtomEntry *ae = RepAtom(op->OpName);
|
||||
OpEntry *info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry));
|
||||
if (!info)
|
||||
return false;
|
||||
memmove(info, op, sizeof(OpEntry));
|
||||
info->NextForME = she->OpForME;
|
||||
she->OpForME = info;
|
||||
info->OpModule = MkAtomTerm(she->AtomOfME);
|
||||
AddPropToAtom(ae, AbsOpProp(info));
|
||||
INIT_RWLOCK(info->OpRWLock);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Gets the info about an operator in a prop */
|
||||
Atom Yap_GetOp(OpEntry *pp, int *prio, int fix) {
|
||||
int n;
|
||||
|
@ -397,7 +430,7 @@ static void InitOps(void) {
|
|||
/// @}
|
||||
|
||||
#if DEBUG
|
||||
#ifdef HAVE_ISATTY
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
@ -412,7 +445,11 @@ static void InitDebug(void) {
|
|||
if (Yap_output_msg) {
|
||||
char ch;
|
||||
|
||||
#if HAVE_ISATTY
|
||||
#if _WIN32
|
||||
if (!_isatty(_fileno(stdin))) {
|
||||
return;
|
||||
}
|
||||
#elif HAVE_ISATTY
|
||||
if (!isatty(0)) {
|
||||
return;
|
||||
}
|
||||
|
@ -422,9 +459,11 @@ static void InitDebug(void) {
|
|||
fprintf(stderr, "a getch\t\tb token\t\tc Lookup\td LookupVar\ti Index\n");
|
||||
fprintf(stderr, "e SetOp\t\tf compile\tg icode\t\th boot\t\tl log\n");
|
||||
fprintf(stderr, "m Machine\t p parser\n");
|
||||
while ((ch = putchar(getchar())) != '\n')
|
||||
while ((ch = putchar(getchar())) != '\n' && ch != '\r') {
|
||||
if (ch >= 'a' && ch <= 'z')
|
||||
GLOBAL_Option[ch - 'a' + 1] = 1;
|
||||
GLOBAL_Option[ch - 'a' + 1] = 1;
|
||||
}
|
||||
if (GLOBAL_Option['l' - 96]) {
|
||||
GLOBAL_logfile = fopen(LOGFILE, "w");
|
||||
if (GLOBAL_logfile == NULL) {
|
||||
|
@ -462,7 +501,7 @@ static UInt update_flags_from_prolog(UInt flags, PredEntry *pe) {
|
|||
return flags;
|
||||
}
|
||||
|
||||
void Yap_InitCPred(const char *Name, UInt Arity, CPredicate code,
|
||||
void Yap_InitCPred(const char *Name, arity_t Arity, CPredicate code,
|
||||
pred_flags_t flags) {
|
||||
CACHE_REGS
|
||||
Atom atom = NIL;
|
||||
|
@ -606,7 +645,7 @@ bool Yap_AddCutToFli(PredEntry *pe, CPredicate CUT) {
|
|||
}
|
||||
}
|
||||
|
||||
void Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code,
|
||||
void Yap_InitCmpPred(const char *Name, arity_t Arity, CmpPredicate cmp_code,
|
||||
pred_flags_t flags) {
|
||||
CACHE_REGS
|
||||
Atom atom = NIL;
|
||||
|
@ -685,7 +724,7 @@ void Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code,
|
|||
p_code->y_u.l.l = cl->ClCode;
|
||||
}
|
||||
|
||||
void Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def,
|
||||
void Yap_InitAsmPred(const char *Name, arity_t Arity, int code, CPredicate def,
|
||||
pred_flags_t flags) {
|
||||
CACHE_REGS
|
||||
Atom atom = NIL;
|
||||
|
@ -825,18 +864,18 @@ static void CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont,
|
|||
code->y_u.OtapFs.f = Cut;
|
||||
}
|
||||
|
||||
void Yap_InitCPredBack(const char *Name, UInt Arity, unsigned int Extra,
|
||||
CPredicate Start, CPredicate Cont, pred_flags_t flags) {
|
||||
Yap_InitCPredBack_(Name, Arity, Extra, Start, Cont, NULL, flags);
|
||||
void Yap_InitCPredBack(const char *Name, arity_t Arity, arity_t Extra,
|
||||
CPredicate Call, CPredicate Retry, pred_flags_t flags) {
|
||||
Yap_InitCPredBack_(Name, Arity, Extra, Call, Retry, NULL, flags);
|
||||
}
|
||||
|
||||
void Yap_InitCPredBackCut(const char *Name, UInt Arity, unsigned int Extra,
|
||||
void Yap_InitCPredBackCut(const char *Name, arity_t Arity, arity_t Extra,
|
||||
CPredicate Start, CPredicate Cont, CPredicate Cut,
|
||||
pred_flags_t flags) {
|
||||
Yap_InitCPredBack_(Name, Arity, Extra, Start, Cont, Cut, flags);
|
||||
}
|
||||
|
||||
void Yap_InitCPredBack_(const char *Name, UInt Arity, unsigned int Extra,
|
||||
void Yap_InitCPredBack_(const char *Name, arity_t Arity, arity_t Extra,
|
||||
CPredicate Start, CPredicate Cont, CPredicate Cut,
|
||||
pred_flags_t flags) {
|
||||
CACHE_REGS
|
||||
|
@ -943,12 +982,14 @@ void Yap_InitCPredBack_(const char *Name, UInt Arity, unsigned int Extra,
|
|||
}
|
||||
}
|
||||
|
||||
static void InitStdPreds(void) {
|
||||
static void InitStdPreds(struct yap_boot_params *yapi)
|
||||
{
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
Yap_InitCPreds();
|
||||
Yap_InitBackCPreds();
|
||||
BACKUP_MACHINE_REGS();
|
||||
Yap_InitPlIO();
|
||||
Yap_InitFlags(false);
|
||||
Yap_InitPlIO(yapi);
|
||||
#if HAVE_MPE
|
||||
Yap_InitMPE();
|
||||
#endif
|
||||
|
@ -1002,39 +1043,31 @@ static void InitOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe) {
|
|||
}
|
||||
|
||||
static void InitDBErasedMarker(void) {
|
||||
DBErasedMarker = (DBRef)Yap_AllocCodeSpace(sizeof(DBStruct));
|
||||
DBErasedMarker = (DBRef)Yap_AllocCodeSpace(sizeof(DBStruct));
|
||||
Yap_LUClauseSpace += sizeof(DBStruct);
|
||||
DBErasedMarker->id = FunctorDBRef;
|
||||
DBErasedMarker->Flags = ErasedMask;
|
||||
DBErasedMarker->Code = NULL;
|
||||
DBErasedMarker->DBT.DBRefs = NULL;
|
||||
DBErasedMarker->Parent = NULL;
|
||||
DBErasedMarker->id = FunctorDBRef;
|
||||
DBErasedMarker->Flags = ErasedMask;
|
||||
DBErasedMarker->Code = NULL;
|
||||
DBErasedMarker->DBT.DBRefs = NULL;
|
||||
DBErasedMarker->Parent = NULL;
|
||||
}
|
||||
|
||||
static void InitLogDBErasedMarker(void) {
|
||||
LogDBErasedMarker = (LogUpdClause *)Yap_AllocCodeSpace(
|
||||
LogDBErasedMarker = (LogUpdClause *)Yap_AllocCodeSpace(
|
||||
sizeof(LogUpdClause) + (UInt)NEXTOP((yamop *)NULL, e));
|
||||
Yap_LUClauseSpace += sizeof(LogUpdClause) + (UInt)NEXTOP((yamop *)NULL, e);
|
||||
LogDBErasedMarker->Id = FunctorDBRef;
|
||||
LogDBErasedMarker->ClFlags = ErasedMask | LogUpdMask;
|
||||
LogDBErasedMarker->lusl.ClSource = NULL;
|
||||
LogDBErasedMarker->ClRefCount = 0;
|
||||
LogDBErasedMarker->ClExt = NULL;
|
||||
LogDBErasedMarker->ClPrev = NULL;
|
||||
LogDBErasedMarker->ClNext = NULL;
|
||||
LogDBErasedMarker->ClSize =
|
||||
(UInt)NEXTOP(((LogUpdClause *)NULL)->ClCode, e);
|
||||
LogDBErasedMarker->ClCode->opc = Yap_opcode(_op_fail);
|
||||
LogDBErasedMarker->Id = FunctorDBRef;
|
||||
LogDBErasedMarker->ClFlags = ErasedMask | LogUpdMask;
|
||||
LogDBErasedMarker->lusl.ClSource = NULL;
|
||||
LogDBErasedMarker->ClRefCount = 0;
|
||||
LogDBErasedMarker->ClExt = NULL;
|
||||
LogDBErasedMarker->ClPrev = NULL;
|
||||
LogDBErasedMarker->ClNext = NULL;
|
||||
LogDBErasedMarker->ClSize = (UInt)NEXTOP(((LogUpdClause *)NULL)->ClCode, e);
|
||||
LogDBErasedMarker->ClCode->opc = Yap_opcode(_op_fail);
|
||||
INIT_CLREF_COUNT(LogDBErasedMarker);
|
||||
}
|
||||
|
||||
static void InitSWIAtoms(void) {
|
||||
MaxAtomTranslations = N_SWI_ATOMS;
|
||||
MaxFunctorTranslations = N_SWI_FUNCTORS;
|
||||
SWI_Atoms = (Atom *)malloc(sizeof(Atom) * MaxAtomTranslations);
|
||||
SWI_Functors = (Functor *)malloc(sizeof(Functor) * 2 * N_SWI_ATOMS);
|
||||
}
|
||||
|
||||
static void InitEmptyWakeups(void) {}
|
||||
|
||||
static void InitAtoms(void) {
|
||||
|
@ -1051,7 +1084,7 @@ static void InitAtoms(void) {
|
|||
HashChain[i].Entry = NIL;
|
||||
}
|
||||
NOfAtoms = 0;
|
||||
#if OLD_STYLE_INITIAL_ATOMS
|
||||
#if 0 && OLD_STYLE_INITIAL_ATOMS
|
||||
Yap_LookupAtomWithAddress("**", (AtomEntry *)&(SF_STORE->AtFoundVar));
|
||||
Yap_ReleaseAtom(AtomFoundVar);
|
||||
Yap_LookupAtomWithAddress("?", (AtomEntry *)&(SF_STORE->AtFreeTerm));
|
||||
|
@ -1059,12 +1092,12 @@ static void InitAtoms(void) {
|
|||
Yap_LookupAtomWithAddress("[]", (AtomEntry *)&(SF_STORE->AtNil));
|
||||
Yap_LookupAtomWithAddress(".", (AtomEntry *)&(SF_STORE->AtDot));
|
||||
#else
|
||||
SF_STORE->AtFoundVar = Yap_LookupAtom("**");
|
||||
AtomFoundVar = Yap_LookupAtom("**");
|
||||
Yap_ReleaseAtom(AtomFoundVar);
|
||||
SF_STORE->AtFreeTerm = Yap_LookupAtom("?");
|
||||
AtomFreeTerm = Yap_LookupAtom("?");
|
||||
Yap_ReleaseAtom(AtomFreeTerm);
|
||||
SF_STORE->AtNil = Yap_LookupAtom("[]");
|
||||
SF_STORE->AtDot = Yap_LookupAtom(".");
|
||||
AtomNil = Yap_LookupAtom("[]");
|
||||
AtomDot = Yap_LookupAtom(".");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1130,7 +1163,7 @@ void Yap_init_yapor_workers(void) {
|
|||
worker_id = proc;
|
||||
Yap_remap_yapor_memory();
|
||||
LOCAL = REMOTE(worker_id);
|
||||
memcpy(REMOTE(worker_id), REMOTE(0), sizeof(struct worker_local));
|
||||
memmove(REMOTE(worker_id), REMOTE(0), sizeof(struct worker_local));
|
||||
InitWorker(worker_id);
|
||||
break;
|
||||
} else
|
||||
|
@ -1221,9 +1254,9 @@ void Yap_CloseScratchPad(void) {
|
|||
LOCAL_ScratchPad.msz = SCRATCH_START_SIZE;
|
||||
}
|
||||
|
||||
#include "heap/iglobals.h"
|
||||
#include "iglobals.h"
|
||||
|
||||
#include "heap/ilocals.h"
|
||||
#include "ilocals.h"
|
||||
|
||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||
struct global_data *Yap_global;
|
||||
|
@ -1239,7 +1272,8 @@ struct worker_local *Yap_local;
|
|||
struct worker_local Yap_local;
|
||||
#endif
|
||||
|
||||
static void InitCodes(void) {
|
||||
static void InitCodes(struct yap_boot_params *yapi)
|
||||
{
|
||||
CACHE_REGS
|
||||
#if THREADS
|
||||
int wid;
|
||||
|
@ -1247,7 +1281,7 @@ static void InitCodes(void) {
|
|||
Yap_local[wid] = NULL;
|
||||
}
|
||||
#endif
|
||||
#include "heap/ihstruct.h"
|
||||
#include "ihstruct.h"
|
||||
#if THREADS
|
||||
Yap_InitThread(0);
|
||||
#endif /* THREADS */
|
||||
|
@ -1281,9 +1315,16 @@ static void InitVersion(void) {
|
|||
Yap_PutValue(AtomVersionNumber, MkAtomTerm(Yap_LookupAtom(YAP_FULL_VERSION)));
|
||||
}
|
||||
|
||||
void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts,
|
||||
UInt max_table_size, int n_workers, int sch_loop,
|
||||
int delay_load) {
|
||||
const char *Yap_version(void) {
|
||||
Term t = Yap_GetValue(AtomVersionNumber);
|
||||
return RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||
}
|
||||
|
||||
void Yap_InitWorkspace(struct yap_boot_params *yapi,
|
||||
UInt Heap, size_t Stack, size_t Trail, size_t Atts,
|
||||
size_t max_table_size, int n_workers, int sch_loop,
|
||||
int delay_load)
|
||||
{
|
||||
CACHE_REGS
|
||||
|
||||
/* initialize system stuff */
|
||||
|
@ -1323,11 +1364,7 @@ void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts,
|
|||
Stack = MinStackSpace;
|
||||
Stack = AdjustPageSize(Stack * K);
|
||||
Stack /= (K);
|
||||
if (!Atts)
|
||||
Atts = 2048 * sizeof(CELL);
|
||||
else
|
||||
Atts = AdjustPageSize(Atts * K);
|
||||
Atts /= (K);
|
||||
Atts = 0;
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
worker_id = 0;
|
||||
#endif /* YAPOR || THREADS */
|
||||
|
@ -1358,7 +1395,6 @@ void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts,
|
|||
#endif /* YAPOR || TABLING */
|
||||
|
||||
Yap_AttsSize = Atts;
|
||||
Yap_InitTime(0);
|
||||
/* InitAbsmi must be done before InitCodes */
|
||||
/* This must be done before initializing predicates */
|
||||
#ifdef MPW
|
||||
|
@ -1366,7 +1402,7 @@ void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts,
|
|||
#else
|
||||
Yap_InitAbsmi();
|
||||
#endif
|
||||
InitCodes();
|
||||
InitCodes(yapi);
|
||||
InitOps();
|
||||
InitDebug();
|
||||
InitVersion();
|
||||
|
@ -1391,12 +1427,12 @@ void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts,
|
|||
LOCAL_ThreadHandle.ssize = Stack;
|
||||
#endif
|
||||
#endif
|
||||
GLOBAL_AllowGlobalExpansion = TRUE;
|
||||
GLOBAL_AllowLocalExpansion = TRUE;
|
||||
GLOBAL_AllowTrailExpansion = TRUE;
|
||||
GLOBAL_AllowGlobalExpansion = true;
|
||||
GLOBAL_AllowLocalExpansion = true;
|
||||
GLOBAL_AllowTrailExpansion = true;
|
||||
Yap_InitExStacks(0, Trail, Stack);
|
||||
Yap_InitYaamRegs(0);
|
||||
InitStdPreds();
|
||||
Yap_InitYaamRegs(0, true);
|
||||
InitStdPreds(yapi);
|
||||
/* make sure tmp area is available */
|
||||
{ Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace()); }
|
||||
}
|
||||
|
@ -1439,6 +1475,9 @@ void Yap_exit(int value) {
|
|||
run_halt_hooks(value);
|
||||
Yap_ShutdownLoadForeign();
|
||||
}
|
||||
Yap_CloseStreams(false);
|
||||
Yap_CloseStreams();
|
||||
Yap_CloseReadline();
|
||||
#if USE_SYSTEM_MALLOC
|
||||
#endif
|
||||
exit(value);
|
||||
}
|
||||
|
|
236
C/inlines.c
236
C/inlines.c
|
@ -16,9 +16,16 @@
|
|||
*************************************************************************/
|
||||
|
||||
|
||||
/** @defgroup YAP_Terms Predicates on terms
|
||||
@ingroup builtins
|
||||
@{
|
||||
/**
|
||||
|
||||
|
||||
@file inlines.c
|
||||
|
||||
@{
|
||||
|
||||
@defgroup YAP_Inlines Inlined Tests nad Ter Manipulation
|
||||
|
||||
@ingroup builtins
|
||||
|
||||
|
||||
*/
|
||||
|
@ -45,6 +52,57 @@ static Int p_dif( USES_REGS1 );
|
|||
static Int p_eq( USES_REGS1 );
|
||||
static Int p_arg( USES_REGS1 );
|
||||
static Int p_functor( USES_REGS1 );
|
||||
static Int p_fail( USES_REGS1 );
|
||||
static Int p_true( USES_REGS1 );
|
||||
|
||||
/** @pred fail is iso
|
||||
|
||||
Always fails. Defined as if by:
|
||||
|
||||
~~~~~
|
||||
fail :- 2=1.
|
||||
~~~~~
|
||||
*/
|
||||
|
||||
/** @pred false is iso
|
||||
|
||||
The same as fail. Defined as if by:
|
||||
|
||||
~~~~~
|
||||
false :- 2=1.
|
||||
~~~~~
|
||||
*/
|
||||
|
||||
static Int p_fail( USES_REGS1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @pred true is iso
|
||||
Succeed.
|
||||
|
||||
Succeeds once. Defined as if by:
|
||||
|
||||
~~~~~
|
||||
true :- true.
|
||||
~~~~~
|
||||
*/
|
||||
|
||||
/** @pred otherwise is iso
|
||||
Succeed.
|
||||
|
||||
Succeeds once. Defined as if by:
|
||||
|
||||
~~~~~
|
||||
otherwise.
|
||||
~~~~~
|
||||
*/
|
||||
|
||||
|
||||
static Int p_true( USES_REGS1 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** @pred atom( _T_) is iso
|
||||
|
@ -665,6 +723,7 @@ p_arg( USES_REGS1 )
|
|||
pt0 = RepAppl(d1);
|
||||
d1 = *pt0;
|
||||
if (IsExtensionFunctor((Functor) d1)) {
|
||||
Yap_Error(TYPE_ERROR_COMPOUND, d1, "arg 2 of arg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
save_hb();
|
||||
|
@ -708,7 +767,7 @@ p_arg( USES_REGS1 )
|
|||
ENDP(pt0);
|
||||
}
|
||||
else {
|
||||
/* Yap_Error(TYPE_ERROR_COMPOUND, d1, "arg 2 of arg/3"); */
|
||||
Yap_Error(TYPE_ERROR_COMPOUND, d1, "arg 2 of arg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
@ -997,41 +1056,65 @@ p_erroneous_call( USES_REGS1 )
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @genarg( ?_Index_, +_Term_ , -_Arg_ )
|
||||
*
|
||||
* Similar to arg/3, but it can also backtrack through _T_'s arguments, that is:
|
||||
static Int
|
||||
p_save_cp( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term td;
|
||||
#if SHADOW_HB
|
||||
register CELL *HBREG = HB;
|
||||
#endif
|
||||
if (!IsVarTerm(t)) return(FALSE);
|
||||
td = cp_as_integer(B PASS_REGS);
|
||||
YapBind((CELL *)t,td);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
~~~~~~~~~
|
||||
?- arg:genarg(I, f(a,b), A).
|
||||
A = a,
|
||||
I = 1.
|
||||
;
|
||||
A = b,
|
||||
I = 2.
|
||||
~~~~~~~~~
|
||||
*
|
||||
* Note: SWI-Prolog defines arg/3 as genarg/3.
|
||||
*/
|
||||
static Int
|
||||
genarg( USES_REGS1 )
|
||||
{ /* getarg(?Atom) */
|
||||
Term t0 = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
CELL *pt, *end;
|
||||
int res;
|
||||
UInt arity;
|
||||
/// @}
|
||||
|
||||
if (!IsVarTerm(t0)) {
|
||||
res = p_arg( PASS_REGS1 );
|
||||
if (res) {
|
||||
cut_succeed();
|
||||
} else {
|
||||
cut_fail();
|
||||
}
|
||||
}
|
||||
if (IsVarTerm(t1)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"genarg/3");
|
||||
/**
|
||||
*
|
||||
* @addtogroup args
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @namespace args
|
||||
*
|
||||
* @pred genarg( ?Index, +Term , -Arg )
|
||||
*
|
||||
*
|
||||
* Similar to arg/3, but it can also backtrack through _T_'s arguments, that is:
|
||||
|
||||
~~~~~~~~~
|
||||
?- arg:genarg(I, f(a,b), A).
|
||||
A = a,
|
||||
I = 1.
|
||||
;
|
||||
A = b,
|
||||
I = 2.
|
||||
~~~~~~~~~
|
||||
*
|
||||
* Note: SWI-Prolog defines arg/3 as genarg/3.
|
||||
*/
|
||||
static Int
|
||||
genarg( USES_REGS1 )
|
||||
{ /* getarg(?Atom) */
|
||||
Term t0 = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
CELL *pt, *end;
|
||||
int res;
|
||||
UInt arity;
|
||||
|
||||
if (!IsVarTerm(t0)) {
|
||||
res = p_arg( PASS_REGS1 );
|
||||
if (res) {
|
||||
cut_succeed();
|
||||
} else {
|
||||
cut_fail();
|
||||
}
|
||||
}
|
||||
if (IsVarTerm(t1)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"genarg/3");
|
||||
return FALSE;
|
||||
}
|
||||
if (IsPrimitiveTerm(t1)) {
|
||||
|
@ -1087,50 +1170,43 @@ cont_genarg( USES_REGS1 )
|
|||
Yap_unify(ARG3,pt[0]);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_save_cp( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term td;
|
||||
#if SHADOW_HB
|
||||
register CELL *HBREG = HB;
|
||||
|
||||
void
|
||||
Yap_InitInlines(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||
Yap_InitAsmPred("$$save_by", 1, _save_by, p_save_cp, SafePredFlag);
|
||||
Yap_InitAsmPred("atom", 1, _atom, p_atom, SafePredFlag);
|
||||
Yap_InitAsmPred("atomic", 1, _atomic, p_atomic, SafePredFlag);
|
||||
Yap_InitAsmPred("integer", 1, _integer, p_integer, SafePredFlag);
|
||||
Yap_InitAsmPred("nonvar", 1, _nonvar, p_nonvar, SafePredFlag);
|
||||
Yap_InitAsmPred("number", 1, _number, p_number, SafePredFlag);
|
||||
Yap_InitAsmPred("var", 1, _var, p_var, SafePredFlag);
|
||||
Yap_InitAsmPred("db_reference", 1, _db_ref, p_db_ref, SafePredFlag);
|
||||
Yap_InitAsmPred("primitive", 1, _primitive, p_primitive, SafePredFlag);
|
||||
Yap_InitAsmPred("compound", 1, _compound, p_compound, SafePredFlag);
|
||||
Yap_InitAsmPred("float", 1, _float, p_float, SafePredFlag);
|
||||
Yap_InitAsmPred("=", 2, _equal, p_equal, SafePredFlag);
|
||||
#if INLINE_BIG_COMPARISONS
|
||||
Yap_InitAsmPred("\\=", 2, _dif, p_dif, SafePredFlag|TestPredFlag);
|
||||
Yap_InitAsmPred("==", 2, _eq, p_eq, SafePredFlag|TestPredFlag);
|
||||
#else
|
||||
Yap_InitCPred("\\=", 2, p_dif, SafePredFlag);
|
||||
Yap_InitCPred("==", 2, p_eq, SafePredFlag);
|
||||
#endif
|
||||
if (!IsVarTerm(t)) return(FALSE);
|
||||
td = cp_as_integer(B PASS_REGS);
|
||||
YapBind((CELL *)t,td);
|
||||
return(TRUE);
|
||||
Yap_InitAsmPred("arg", 3, _arg, p_arg, SafePredFlag);
|
||||
Yap_InitAsmPred("functor", 3, _functor, p_functor, 0);
|
||||
Yap_InitAsmPred("$label_ctl", 2, _p_label_ctl, p_erroneous_call, SafePredFlag);
|
||||
CurrentModule = ARG_MODULE;
|
||||
Yap_InitCPredBack("genarg", 3, 3, genarg, cont_genarg,SafePredFlag);
|
||||
CurrentModule = cm;
|
||||
Yap_InitCPred("true", 0, p_true, SafePredFlag);
|
||||
Yap_InitCPred("otherwise", 0, p_true, SafePredFlag);
|
||||
Yap_InitCPred("false", 0, p_fail, SafePredFlag);
|
||||
Yap_InitCPred("fail", 0, p_fail, SafePredFlag);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Yap_InitInlines(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||
Yap_InitAsmPred("$$save_by", 1, _save_by, p_save_cp, SafePredFlag);
|
||||
Yap_InitAsmPred("atom", 1, _atom, p_atom, SafePredFlag);
|
||||
Yap_InitAsmPred("atomic", 1, _atomic, p_atomic, SafePredFlag);
|
||||
Yap_InitAsmPred("integer", 1, _integer, p_integer, SafePredFlag);
|
||||
Yap_InitAsmPred("nonvar", 1, _nonvar, p_nonvar, SafePredFlag);
|
||||
Yap_InitAsmPred("number", 1, _number, p_number, SafePredFlag);
|
||||
Yap_InitAsmPred("var", 1, _var, p_var, SafePredFlag);
|
||||
Yap_InitAsmPred("db_reference", 1, _db_ref, p_db_ref, SafePredFlag);
|
||||
Yap_InitAsmPred("primitive", 1, _primitive, p_primitive, SafePredFlag);
|
||||
Yap_InitAsmPred("compound", 1, _compound, p_compound, SafePredFlag);
|
||||
Yap_InitAsmPred("float", 1, _float, p_float, SafePredFlag);
|
||||
Yap_InitAsmPred("=", 2, _equal, p_equal, SafePredFlag);
|
||||
Yap_InitAsmPred("\\=", 2, _dif, p_dif, SafePredFlag);
|
||||
Yap_InitAsmPred("==", 2, _eq, p_eq, SafePredFlag);
|
||||
Yap_InitAsmPred("arg", 3, _arg, p_arg, SafePredFlag);
|
||||
Yap_InitAsmPred("functor", 3, _functor, p_functor, 0);
|
||||
Yap_InitAsmPred("$label_ctl", 2, _p_label_ctl, p_erroneous_call, SafePredFlag);
|
||||
CurrentModule = ARG_MODULE;
|
||||
Yap_InitCPredBack("genarg", 3, 3, genarg, cont_genarg,SafePredFlag);
|
||||
CurrentModule = cm;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
// @}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/local/bin/python3.4
|
||||
import os, sys
|
||||
if 'LD_LIBRARY_PATH' not in os.environ:
|
||||
os.environ['LD_LIBRARY_PATH'] = '/usr/local/lib'
|
||||
try:
|
||||
os.execv(sys.argv[0], sys.argv)
|
||||
except Exception as exc:
|
||||
print( 'Failed re-exec:', exc )
|
||||
sys.exit(1)
|
||||
#
|
||||
# import yourmodule
|
||||
print( 'Success:', os.environ['LD_LIBRARY_PATH']
|
||||
# your program goes here
|
||||
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
|
||||
|
||||
#import sys, os
|
||||
sys.path = sys.path + [os.getcwd()]
|
||||
|
||||
sys.druwid_root = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
import dru.druwid
|
||||
import dru.druplot
|
||||
from dru.shell import AlephShell
|
||||
|
||||
cq = dru.druwid.ClauseQueue()
|
||||
|
||||
learner = dru.druwid.Aleph( cq )
|
||||
|
||||
#
|
||||
# initialize engine
|
||||
#
|
||||
def main():
|
||||
if not learner:
|
||||
print("Nothing to do, bye!")
|
||||
exit(2)
|
||||
AlephShell(learner).cmdloop()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -69,7 +69,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
|||
strcpy(LOCAL_ErrorSay," Load Failed: in AIX you must load a single object file");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if (!Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE)) {
|
||||
if (!Yap_AbsoluteFileInBuffer(AtomName(ofiles->name), LOCAL_FileNameBuf, YAP_FILENAME_MAX, true)) {
|
||||
strcpy(LOCAL_ErrorSay, " Trying to open unexisting file in LoadForeign ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ Yap_FindExecutable(void)
|
|||
if (*GLOBAL_argv[0] == '/') {
|
||||
if (oktox(GLOBAL_argv[0])) {
|
||||
strcpy(LOCAL_FileNameBuf, GLOBAL_argv[0]);
|
||||
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
|
||||
Yap_AbsoluteFileInBuffer(LOCAL_FileNameBuf, true);
|
||||
strncpy( GLOBAL_Executable, LOCAL_FileNameBuf, YAP_MAXPATHLEN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -87,12 +88,12 @@ Yap_FindExecutable(void)
|
|||
cp++;
|
||||
if (!oktox(LOCAL_FileNameBuf))
|
||||
continue;
|
||||
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
|
||||
Yap_AbsoluteFileInBuffer(Yap_AbsoluteFileInBuffer(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
|
||||
return;
|
||||
}
|
||||
/* one last try for dual systems */
|
||||
strcpy(LOCAL_FileNameBuf, GLOBAL_argv[0]);
|
||||
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
|
||||
strcpy(LOCAL_FileNameBuf, GLOBAL_argv[0]);
|
||||
Yap_AbsoluteFileInBuffer(Yap_AbsoluteFileInBuffer(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
|
||||
if (oktox(GLOBAL_Executable))
|
||||
return GLOBAL_Executable;
|
||||
else
|
||||
|
|
245
C/load_dl.c
245
C/load_dl.c
|
@ -1,64 +1,60 @@
|
|||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: load_dl.c *
|
||||
* comments: dl based dynamic loaderr of external routines *
|
||||
* tested on i486-linuxelf *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: load_dl.c *
|
||||
* comments: dl based dynamic loaderr of external routines *
|
||||
* tested on i486-linuxelf *
|
||||
*************************************************************************/
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "Yatom.h"
|
||||
#include "yapio.h"
|
||||
|
||||
#include "Foreign.h"
|
||||
|
||||
#if LOAD_DL
|
||||
|
||||
// use SWI-Prolog code if all else fails
|
||||
char *
|
||||
findExecutable(const char *av0, char *buffer);
|
||||
char *findExecutable(const char *av0, char *buffer);
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#if defined(__APPLE__)
|
||||
#include <mach-o/dyld.h>
|
||||
#include <dlfcn.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef void (*prismf)(void);
|
||||
|
||||
/* only works for dlls */
|
||||
int
|
||||
Yap_CallFunctionByName(const char *thing_string);
|
||||
int Yap_CallFunctionByName(const char *thing_string);
|
||||
|
||||
int
|
||||
Yap_CallFunctionByName(const char *thing_string)
|
||||
{
|
||||
void * handle = dlopen(NULL, RTLD_LAZY
|
||||
int Yap_CallFunctionByName(const char *thing_string) {
|
||||
void *handle = dlopen(NULL, RTLD_LAZY
|
||||
#ifndef __CYGWIN__
|
||||
#ifdef RTLD_NOLOAD
|
||||
| RTLD_NOLOAD
|
||||
| RTLD_NOLOAD
|
||||
#endif
|
||||
#endif
|
||||
);
|
||||
);
|
||||
// you could do RTLD_NOW as well. shouldn't matter
|
||||
if (!handle) {
|
||||
CACHE_REGS
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "Dynamic linking on main module : %s\n", dlerror());
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1,
|
||||
"Dynamic linking on main module : %s\n", dlerror());
|
||||
}
|
||||
prismf * addr = (prismf *)dlsym(handle, thing_string);
|
||||
prismf *addr = (prismf *)dlsym(handle, thing_string);
|
||||
if (addr)
|
||||
(*addr)();
|
||||
dlclose(handle);
|
||||
|
@ -68,44 +64,34 @@ Yap_CallFunctionByName(const char *thing_string)
|
|||
/*
|
||||
* YAP_FindExecutable(argv[0]) should be called on yap initialization to
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
char *
|
||||
Yap_FindExecutable(void)
|
||||
{
|
||||
*/
|
||||
char *Yap_FindExecutable(void) {
|
||||
#if HAVE_GETEXECNAME
|
||||
// Solaris
|
||||
return getexecname();
|
||||
#elif __APPLE__
|
||||
char path[1024];
|
||||
char *buf;
|
||||
char *buf = malloc(YAP_FILENAME_MAX);
|
||||
|
||||
uint32_t size = sizeof(path);
|
||||
if (!_NSGetExecutablePath(path, &size)) {
|
||||
size_t sz = strlen(path);
|
||||
buf = malloc(sz+1);
|
||||
strncpy(buf, path, sz);
|
||||
uint32_t size;
|
||||
if (!_NSGetExecutablePath(buf, &size)) {
|
||||
buf = realloc(buf, size + 1);
|
||||
return buf;
|
||||
} else {
|
||||
char *rc = malloc(size+1);
|
||||
if (_NSGetExecutablePath(rc, &size) == 0)
|
||||
return "yap";
|
||||
return rc;
|
||||
}
|
||||
return "yap";
|
||||
#elif defined(__linux__)
|
||||
enum { BUFFERSIZE = 1024 };
|
||||
char *buf = malloc(BUFFERSIZE);
|
||||
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf)-1);
|
||||
|
||||
char *buf = malloc(YAP_FILENAME_MAX);
|
||||
ssize_t len = readlink("/proc/self/exe", buf, YAP_FILENAME_MAX - 1);
|
||||
|
||||
if (len != -1) {
|
||||
buf[len] = '\0';
|
||||
return buf;
|
||||
}
|
||||
// follow through to standard method
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
// follow through to standard method
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
enum { BUFFERSIZE = 1024 };
|
||||
char *buf = malloc(BUFFERSIZE);
|
||||
ssize_t len = readlink("/proc/curproc/file", buf, sizeof(buf)-1);
|
||||
|
||||
ssize_t len = readlink("/proc/curproc/file", buf, sizeof(buf) - 1);
|
||||
|
||||
if (len != -1) {
|
||||
buf[len] = '\0';
|
||||
return buf;
|
||||
|
@ -117,41 +103,32 @@ Yap_FindExecutable(void)
|
|||
mib[3] = -1; // current process
|
||||
size_t cb = BUFFERSIZE;
|
||||
sysctl(mib, 4, buf, &cb, NULL, 0);
|
||||
// follow through to standard method
|
||||
// follow through to standard method
|
||||
#endif
|
||||
return
|
||||
NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
Yap_LoadForeignFile(char *file, int flags)
|
||||
{
|
||||
void *Yap_LoadForeignFile(char *file, int flags) {
|
||||
CACHE_REGS
|
||||
int dlflag;
|
||||
void *out;
|
||||
|
||||
|
||||
if (flags & EAGER_LOADING)
|
||||
if (flags & EAGER_LOADING)
|
||||
dlflag = RTLD_NOW;
|
||||
else
|
||||
dlflag = RTLD_LAZY;
|
||||
if (flags & GLOBAL_LOADING)
|
||||
if (flags & GLOBAL_LOADING)
|
||||
dlflag |= RTLD_GLOBAL;
|
||||
#ifndef __CYGWIN__
|
||||
else
|
||||
else
|
||||
dlflag |= RTLD_LOCAL;
|
||||
#endif
|
||||
if (!Yap_TrueFileName(file, LOCAL_FileNameBuf, true)){
|
||||
/* use LD_LIBRARY_PATH */
|
||||
strncpy(LOCAL_FileNameBuf,file, YAP_FILENAME_MAX-1);
|
||||
strncat(LOCAL_FileNameBuf,".", YAP_FILENAME_MAX-1);
|
||||
strncat(LOCAL_FileNameBuf, "SO_EXT", YAP_FILENAME_MAX-1);
|
||||
}
|
||||
out = (void *)dlopen(LOCAL_FileNameBuf, flags);
|
||||
out = (void *)dlopen(file, dlflag);
|
||||
if (out == NULL) {
|
||||
char *m_os = dlerror();
|
||||
const char *m_os = dlerror();
|
||||
if (m_os) {
|
||||
LOCAL_ErrorMessage = dlerror();
|
||||
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE);
|
||||
strncpy(LOCAL_ErrorMessage, m_os, MAX_ERROR_MSG_SIZE - 1);
|
||||
} else {
|
||||
LOCAL_ErrorMessage = "dlopen failed";
|
||||
}
|
||||
|
@ -159,22 +136,18 @@ Yap_LoadForeignFile(char *file, int flags)
|
|||
return out;
|
||||
}
|
||||
|
||||
int
|
||||
Yap_CallForeignFile(void *handle, char *f)
|
||||
{
|
||||
YapInitProc proc = (YapInitProc) dlsym(handle, f);
|
||||
int Yap_CallForeignFile(void *handle, char *f) {
|
||||
YapInitProc proc = (YapInitProc)dlsym(handle, f);
|
||||
if (!proc) {
|
||||
/* Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "dlsym error %s\n", dlerror());*/
|
||||
return FALSE;
|
||||
}
|
||||
(*proc) ();
|
||||
(*proc)();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
Yap_CloseForeignFile(void *handle)
|
||||
{
|
||||
if ( dlclose(handle) < 0) {
|
||||
int Yap_CloseForeignFile(void *handle) {
|
||||
if (dlclose(handle) < 0) {
|
||||
CACHE_REGS
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "dlclose error %s\n", dlerror());
|
||||
return -1;
|
||||
|
@ -182,83 +155,70 @@ Yap_CloseForeignFile(void *handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* LoadForeign(ofiles,libs,proc_name,init_proc) dynamically loads foreign
|
||||
* code files and libraries and locates an initialization routine
|
||||
*/
|
||||
static Int
|
||||
LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
*/
|
||||
static Int LoadForeign(StringList
|
||||
ofiles, StringList libs, char *proc_name,
|
||||
YapInitProc *init_proc) {
|
||||
CACHE_REGS
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
|
||||
while (libs) {
|
||||
if (!Yap_TrueFileName((char *)AtomName(libs->name), LOCAL_FileNameBuf, true)) {
|
||||
/* use LD_LIBRARY_PATH */
|
||||
strncpy(LOCAL_FileNameBuf, (char *)AtomName(libs->name), YAP_FILENAME_MAX);
|
||||
}
|
||||
|
||||
const char *file = AtomName(libs->name);
|
||||
#ifdef __osf__
|
||||
if((libs->handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY)) == NULL)
|
||||
if ((libs->handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY)) == NULL)
|
||||
#else
|
||||
if((libs->handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == NULL)
|
||||
if ((libs->handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL)) ==
|
||||
NULL)
|
||||
#endif
|
||||
{
|
||||
strcpy(LOCAL_ErrorSay,dlerror());
|
||||
return LOAD_FAILLED;
|
||||
if (LOCAL_ErrorMessage == NULL) {
|
||||
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE);
|
||||
strcpy(LOCAL_ErrorMessage, dlerror());
|
||||
}
|
||||
}
|
||||
libs = libs->next;
|
||||
}
|
||||
|
||||
while (ofiles) {
|
||||
void *handle;
|
||||
|
||||
/* load libraries first so that their symbols are available to
|
||||
other routines */
|
||||
/* load libraries first so that their symbols are available to
|
||||
other routines */
|
||||
const char *file = AtomName(ofiles->name);
|
||||
|
||||
/* dlopen wants to follow the LD_CONFIG_PATH */
|
||||
if (!Yap_TrueFileName((char *)AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE)) {
|
||||
strcpy(LOCAL_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
#ifdef __osf__
|
||||
if((handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY)) == 0)
|
||||
#else
|
||||
if((handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == 0)
|
||||
#endif
|
||||
if ((ofiles->handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL)) ==
|
||||
NULL)
|
||||
{
|
||||
fprintf(stderr,"dlopen of image %s failed: %s\n", LOCAL_FileNameBuf, dlerror());
|
||||
/* strcpy(LOCAL_ErrorSay,dlerror());*/
|
||||
return LOAD_FAILLED;
|
||||
if (LOCAL_ErrorMessage == NULL) {
|
||||
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE);
|
||||
fprintf(stderr, "dlopen of image %s failed: %s\n", LOCAL_FileNameBuf,
|
||||
dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
ofiles->handle = handle;
|
||||
|
||||
if (proc_name && !*init_proc)
|
||||
*init_proc = (YapInitProc) dlsym(handle,proc_name);
|
||||
|
||||
if (ofiles->handle && proc_name && !*init_proc)
|
||||
*init_proc = (YapInitProc)dlsym(ofiles->handle, proc_name);
|
||||
ofiles = ofiles->next;
|
||||
}
|
||||
|
||||
if(! *init_proc) {
|
||||
strcpy(LOCAL_ErrorSay,"Could not locate initialization routine");
|
||||
if (!*init_proc && LOCAL_ErrorMessage == NULL) {
|
||||
char *buf = malloc(1058);
|
||||
snprintf(buf, 1058 - 1, "Could not locate routine %s in %s: %s\n",
|
||||
proc_name, LOCAL_FileNameBuf, dlerror());
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
return LOAD_SUCCEEDED;
|
||||
}
|
||||
|
||||
Int
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
Int Yap_LoadForeign(StringList ofiles, StringList libs, char *proc_name,
|
||||
YapInitProc *init_proc) {
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
void Yap_ShutdownLoadForeign(void) {
|
||||
ForeignObj *f_code;
|
||||
|
||||
f_code = ForeignCodeLoaded;
|
||||
|
@ -270,7 +230,7 @@ Yap_ShutdownLoadForeign(void)
|
|||
while (objs != NULL) {
|
||||
old = objs;
|
||||
if (dlclose(objs->handle) != 0)
|
||||
return; /* ERROR */
|
||||
return; /* ERROR */
|
||||
objs = objs->next;
|
||||
Yap_FreeCodeSpace((ADDR)old);
|
||||
}
|
||||
|
@ -278,7 +238,7 @@ Yap_ShutdownLoadForeign(void)
|
|||
while (libs != NULL) {
|
||||
old = libs;
|
||||
if (dlclose(libs->handle) != 0)
|
||||
return; /* ERROR */
|
||||
return; /* ERROR */
|
||||
libs = libs->next;
|
||||
Yap_FreeCodeSpace((ADDR)old);
|
||||
}
|
||||
|
@ -292,30 +252,19 @@ Yap_ShutdownLoadForeign(void)
|
|||
ForeignCodeLoaded = NULL;
|
||||
}
|
||||
|
||||
Int
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
Int Yap_ReLoadForeign(StringList ofiles, StringList libs, char *proc_name,
|
||||
YapInitProc *init_proc) {
|
||||
return (LoadForeign(ofiles, libs, proc_name, init_proc));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if SIMICS
|
||||
|
||||
void dlopen(void)
|
||||
{
|
||||
}
|
||||
void dlopen(void) {}
|
||||
|
||||
void dlclose(void)
|
||||
{
|
||||
}
|
||||
void dlclose(void) {}
|
||||
|
||||
void dlsym(void)
|
||||
{
|
||||
}
|
||||
void dlsym(void) {}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
44
C/load_dll.c
44
C/load_dll.c
|
@ -19,7 +19,7 @@
|
|||
#include "yapio.h"
|
||||
#include "Foreign.h"
|
||||
|
||||
#if LOAD_DLL
|
||||
#if _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
@ -42,15 +42,14 @@ Yap_FindExecutable(void)
|
|||
void *
|
||||
Yap_LoadForeignFile(char *file, int flags)
|
||||
{
|
||||
void *ptr= (void *)LoadLibrary(file);
|
||||
char *buf = malloc(1024);
|
||||
void *ptr= (void *)LoadLibrary(file);
|
||||
if (!ptr) {
|
||||
CACHE_REGS
|
||||
LOCAL_ErrorSay[0]='\0';
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), LOCAL_ErrorSay, 256,
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 1023,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
@ -76,23 +75,33 @@ Yap_CloseForeignFile(void *handle)
|
|||
*/
|
||||
static Int
|
||||
LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
const char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
CACHE_REGS
|
||||
while (ofiles) {
|
||||
HINSTANCE handle;
|
||||
|
||||
if (Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE) &&
|
||||
if (*init_proc == NULL &&
|
||||
(*init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name)))
|
||||
{
|
||||
YapInitProc f = *init_proc;
|
||||
f();
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *file = AtomName(ofiles->name);
|
||||
if (Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf, true, YAP_OBJ, true, true) &&
|
||||
(handle=LoadLibrary(LOCAL_FileNameBuf)) != 0)
|
||||
{
|
||||
LOCAL_ErrorSay[0]=~'\0';
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
if (*init_proc == NULL)
|
||||
*init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name);
|
||||
} else {
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), LOCAL_ErrorSay, 256,
|
||||
NULL);
|
||||
char *buf = malloc(1024);
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 1023,
|
||||
NULL);
|
||||
//fprintf(stderr,"WinError: %s\n", LOCAL_ErrorSay);
|
||||
}
|
||||
ofiles = ofiles->next;
|
||||
|
@ -101,7 +110,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
|||
other routines */
|
||||
while (libs) {
|
||||
HINSTANCE handle;
|
||||
char * s = AtomName(libs->name);
|
||||
const char * s = AtomName(libs->name);
|
||||
|
||||
if (s[0] == '-') {
|
||||
strcat(LOCAL_FileNameBuf,s+2);
|
||||
|
@ -123,7 +132,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
|||
}
|
||||
|
||||
if(*init_proc == NULL) {
|
||||
strcpy(LOCAL_ErrorSay,"Could not locate initialization routine");
|
||||
LOCAL_ErrorMessage = "Could not locate initialization routine";
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
|
@ -137,7 +146,7 @@ Yap_LoadForeign(StringList ofiles, StringList libs,
|
|||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
}
|
||||
|
@ -150,4 +159,3 @@ Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -158,7 +158,8 @@ LoadForeign(StringList ofiles, StringList libs,
|
|||
void *handle;
|
||||
|
||||
/* mydlopen wants to follow the LD_CONFIG_PATH */
|
||||
if (!Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE)) {
|
||||
iconst char *file = AtomName(ofiles->name);
|
||||
if (!Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf, true, YAP_OBJ, true, true) ) {
|
||||
strcpy(LOCAL_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
|
208
C/load_foreign.c
208
C/load_foreign.c
|
@ -13,15 +13,14 @@
|
|||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%.2";
|
||||
static char SccsId[] = "%W% %G%.2";
|
||||
#endif
|
||||
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "yapio.h"
|
||||
#include "YapText.h"
|
||||
#include "Yatom.h"
|
||||
#include "yapio.h"
|
||||
#include <stdlib.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
|
@ -35,32 +34,30 @@ static char SccsId[] = "%W% %G%.2";
|
|||
#endif
|
||||
#endif
|
||||
|
||||
Int p_load_foreign( USES_REGS1 );
|
||||
Int p_load_foreign(USES_REGS1);
|
||||
|
||||
Int
|
||||
p_load_foreign( USES_REGS1 )
|
||||
{
|
||||
Int p_load_foreign(USES_REGS1) {
|
||||
StringList ofiles = NULL;
|
||||
StringList libs = NULL;
|
||||
char *InitProcName;
|
||||
YapInitProc InitProc = NULL;
|
||||
Term t, t1;
|
||||
StringList new;
|
||||
Int returncode = FALSE;
|
||||
bool returncode = FALSE;
|
||||
yhandle_t CurSlot = Yap_StartSlots();
|
||||
|
||||
strcpy(LOCAL_ErrorSay,"Invalid arguments");
|
||||
// Yap_DebugPlWrite(ARG1); printf("%s\n", " \n");
|
||||
//Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");
|
||||
//ap_DebugPlWrite(ARG3); printf("%s\n", " \n");
|
||||
// Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");
|
||||
// ap_DebugPlWrite(ARG3); printf("%s\n", " \n");
|
||||
|
||||
/* collect the list of object files */
|
||||
t = Deref(ARG1);
|
||||
while(1) {
|
||||
if (t == TermNil) break;
|
||||
while (1) {
|
||||
if (t == TermNil)
|
||||
break;
|
||||
t1 = HeadOfTerm(t);
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new = (StringList)Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = ofiles;
|
||||
new->name = AtomOfTerm(t1);
|
||||
ofiles = new;
|
||||
|
@ -68,11 +65,12 @@ p_load_foreign( USES_REGS1 )
|
|||
|
||||
/* collect the list of library files */
|
||||
t = Deref(ARG2);
|
||||
while(1) {
|
||||
if (t == TermNil) break;
|
||||
while (1) {
|
||||
if (t == TermNil)
|
||||
break;
|
||||
t1 = HeadOfTerm(t);
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new = (StringList)Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = libs;
|
||||
new->name = AtomOfTerm(t1);
|
||||
libs = new;
|
||||
|
@ -81,15 +79,32 @@ p_load_foreign( USES_REGS1 )
|
|||
/* get the initialization function name */
|
||||
t1 = Deref(ARG3);
|
||||
InitProcName = (char *)RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
|
||||
/* call the OS specific function for dynamic loading */
|
||||
if(Yap_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {
|
||||
Yap_StartSlots( );
|
||||
|
||||
// verify if it was waiting for initialization
|
||||
if (Yap_LateInit(InitProcName)) {
|
||||
returncode = true;
|
||||
} else
|
||||
/* call the OS specific function for dynamic loading */
|
||||
if (Yap_LoadForeign(ofiles, libs, InitProcName, &InitProc) ==
|
||||
LOAD_SUCCEEDED) {
|
||||
if (InitProc == NULL) {
|
||||
char *f;
|
||||
if (ofiles) {
|
||||
f = RepAtom(ofiles->name)->StrOfAE;
|
||||
} else {
|
||||
f = RepAtom(libs->name)->StrOfAE;
|
||||
}
|
||||
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG3,
|
||||
"Foreign module %s does not have initialization function %s", f,
|
||||
InitProcName);
|
||||
return false;
|
||||
}
|
||||
Yap_StartSlots();
|
||||
(*InitProc)();
|
||||
Yap_CloseSlots(CurSlot);
|
||||
returncode = TRUE;
|
||||
returncode = true;
|
||||
}
|
||||
|
||||
|
||||
/* I should recover space if load foreign fails */
|
||||
if (returncode == TRUE) {
|
||||
ForeignObj *f_code = (ForeignObj *)Yap_AllocCodeSpace(sizeof(ForeignObj));
|
||||
|
@ -114,60 +129,60 @@ p_load_foreign( USES_REGS1 )
|
|||
return returncode;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_open_shared_object( USES_REGS1 ) {
|
||||
static Int p_open_shared_object(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
Term tflags = Deref(ARG2);
|
||||
char *s;
|
||||
void *handle;
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "open_shared_object/3");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"open_shared_object/3");
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "open_shared_object/3");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (IsVarTerm(tflags)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,tflags,"open_shared_object/3");
|
||||
return FALSE;
|
||||
}
|
||||
if (!IsIntegerTerm(tflags)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER,tflags,"open_shared_object/3");
|
||||
Yap_Error(INSTANTIATION_ERROR, tflags, "open_shared_object/3");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!IsIntegerTerm(tflags)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER, tflags, "open_shared_object/3");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s = (char *)RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||
if ((handle = Yap_LoadForeignFile(s, IntegerOfTerm(tflags)))==NULL) {
|
||||
Yap_Error(EXISTENCE_ERROR_SOURCE_SINK,t,"open_shared_object_failed for %s with %s\n", s, LOCAL_ErrorSay);
|
||||
if ((handle = Yap_LoadForeignFile(s, IntegerOfTerm(tflags))) == NULL) {
|
||||
Yap_Error(EXISTENCE_ERROR_SOURCE_SINK, t,
|
||||
"open_shared_object_failed for %s"
|
||||
" with %s\n",
|
||||
s, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
} else {
|
||||
return Yap_unify(MkIntegerTerm((Int)handle),ARG3);
|
||||
return Yap_unify(MkIntegerTerm((Int)handle), ARG3);
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
p_close_shared_object( USES_REGS1 ) {
|
||||
static Int p_close_shared_object(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
void *handle;
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"close_shared_object/1");
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "close_shared_object/1");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!IsIntegerTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t,"close_shared_object/1");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t, "close_shared_object/1");
|
||||
return FALSE;
|
||||
}
|
||||
handle = (char *)IntegerOfTerm(t);
|
||||
|
||||
|
||||
return Yap_CloseForeignFile(handle);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_call_shared_object_function( USES_REGS1 ) {
|
||||
static Int p_call_shared_object_function(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
Term tfunc = Deref(ARG2);
|
||||
Term tmod;
|
||||
|
@ -176,51 +191,51 @@ p_call_shared_object_function( USES_REGS1 ) {
|
|||
Int res;
|
||||
|
||||
tmod = CurrentModule;
|
||||
restart:
|
||||
restart:
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2");
|
||||
return FALSE;
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
if (fun == FunctorModule) {
|
||||
tmod = ArgOfTerm(1, t);
|
||||
if (IsVarTerm(tmod) ) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
|
||||
return FALSE;
|
||||
if (IsVarTerm(tmod)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2");
|
||||
return FALSE;
|
||||
}
|
||||
if (!IsAtomTerm(tmod) ) {
|
||||
Yap_Error(TYPE_ERROR_ATOM,ARG1,"call_shared_object_function/2");
|
||||
return FALSE;
|
||||
if (!IsAtomTerm(tmod)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, ARG1, "call_shared_object_function/2");
|
||||
return FALSE;
|
||||
}
|
||||
t = ArgOfTerm(2, t);
|
||||
goto restart;
|
||||
}
|
||||
} else if (!IsIntegerTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t,"call_shared_object_function/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t, "call_shared_object_function/2");
|
||||
return FALSE;
|
||||
}
|
||||
handle = (void *)IntegerOfTerm(t);
|
||||
if (IsVarTerm(tfunc)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!IsAtomTerm(tfunc)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"call_shared_object_function/2/3");
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "call_shared_object_function/2/3");
|
||||
return FALSE;
|
||||
}
|
||||
CurrentModule = tmod;
|
||||
res = Yap_CallForeignFile(handle, (char *)RepAtom(AtomOfTerm(tfunc))->StrOfAE);
|
||||
res =
|
||||
Yap_CallForeignFile(handle, (char *)RepAtom(AtomOfTerm(tfunc))->StrOfAE);
|
||||
CurrentModule = OldCurrentModule;
|
||||
return res;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_obj_suffix( USES_REGS1 ) {
|
||||
return Yap_unify(Yap_CharsToListOfCodes(SO_EXT, ENC_ISO_LATIN1 PASS_REGS),ARG1);
|
||||
static Int p_obj_suffix(USES_REGS1) {
|
||||
return Yap_unify(Yap_CharsToListOfCodes(SO_EXT, ENC_ISO_LATIN1 PASS_REGS),
|
||||
ARG1);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_open_shared_objects( USES_REGS1 ) {
|
||||
static Int p_open_shared_objects(USES_REGS1) {
|
||||
#ifdef SO_EXT
|
||||
return TRUE;
|
||||
#else
|
||||
|
@ -228,26 +243,46 @@ p_open_shared_objects( USES_REGS1 ) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitLoadForeign( void )
|
||||
static Int check_embedded(USES_REGS1)
|
||||
{
|
||||
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag);
|
||||
const char *s = Yap_TextTermToText(Deref(ARG1));
|
||||
if (!s)
|
||||
return false;
|
||||
#if EMBEDDED_MYDDAS
|
||||
if (!strcmp("init_myddas",s)) {
|
||||
init_myddas();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if EMBEDDED_SQLITE3
|
||||
if (!strcmp("init_sqlite3",s)) {
|
||||
init_sqlite3();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void Yap_InitLoadForeign(void) {
|
||||
Yap_InitCPred("$check_embedded", 1, check_embedded, SafePredFlag);
|
||||
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$open_shared_objects", 0, p_open_shared_objects, SafePredFlag);
|
||||
Yap_InitCPred("$open_shared_object", 3, p_open_shared_object, SyncPredFlag);
|
||||
Yap_InitCPred("close_shared_object", 1, p_close_shared_object, SyncPredFlag|SafePredFlag);
|
||||
/** @pred close_shared_object(+ _Handle_)
|
||||
Yap_InitCPred("close_shared_object", 1, p_close_shared_object,
|
||||
SyncPredFlag | SafePredFlag);
|
||||
/** @pred close_shared_object(+ _Handle_)
|
||||
|
||||
Detach the shared object identified by _Handle_.
|
||||
Detach the shared object identified by _Handle_.
|
||||
|
||||
|
||||
*/
|
||||
Yap_InitCPred("$call_shared_object_function", 2, p_call_shared_object_function, SyncPredFlag);
|
||||
|
||||
*/
|
||||
Yap_InitCPred("$call_shared_object_function", 2,
|
||||
p_call_shared_object_function, SyncPredFlag);
|
||||
Yap_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag);
|
||||
}
|
||||
|
||||
void
|
||||
Yap_ReOpenLoadForeign(void)
|
||||
{
|
||||
void Yap_ReOpenLoadForeign(void) {
|
||||
CACHE_REGS
|
||||
ForeignObj *f_code = ForeignCodeLoaded;
|
||||
Term OldModule = CurrentModule;
|
||||
|
@ -256,19 +291,18 @@ Yap_ReOpenLoadForeign(void)
|
|||
YapInitProc InitProc = NULL;
|
||||
|
||||
CurrentModule = f_code->module;
|
||||
if(Yap_ReLoadForeign(f_code->objs,f_code->libs,(char *)RepAtom(f_code->f)->StrOfAE,&InitProc)==LOAD_SUCCEEDED) {
|
||||
if (Yap_ReLoadForeign(f_code->objs, f_code->libs,
|
||||
(char *)RepAtom(f_code->f)->StrOfAE,
|
||||
&InitProc) == LOAD_SUCCEEDED) {
|
||||
if (InitProc)
|
||||
(*InitProc)();
|
||||
(*InitProc)();
|
||||
}
|
||||
f_code = f_code->next;
|
||||
}
|
||||
CurrentModule = OldModule;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
X_API bool load_none(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,8 @@ LoadForeign( StringList ofiles, StringList libs,
|
|||
int valid_fname;
|
||||
|
||||
/* shl_load wants to follow the LD_CONFIG_PATH */
|
||||
valid_fname = Yap_TrueFileName( AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE );
|
||||
const char *file = AtomName(ofiles->name);
|
||||
valid_fname = Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf, true, YAP_OBJ, true, true);
|
||||
|
||||
if( !valid_fname ) {
|
||||
strcpy( LOCAL_ErrorSay, "%% Trying to open non-existing file in LoadForeign" );
|
||||
|
|
20
C/mavar.c
20
C/mavar.c
|
@ -16,9 +16,13 @@
|
|||
*************************************************************************/
|
||||
|
||||
|
||||
/** @defgroup Term_Modification Term Modification
|
||||
/**
|
||||
|
||||
@file mavar.c
|
||||
|
||||
@defgroup Term_Modification Term Modification
|
||||
@ingroup builtins
|
||||
@{
|
||||
|
||||
|
||||
It is sometimes useful to change the value of instantiated
|
||||
variables. Although, this is against the spirit of logic programming, it
|
||||
|
@ -26,14 +30,14 @@ is sometimes useful. As in other Prolog systems, YAP has
|
|||
several primitives that allow updating Prolog terms. Note that these
|
||||
primitives are also backtrackable.
|
||||
|
||||
The `setarg/3` primitive allows updating any argument of a Prolog
|
||||
compound terms. The `mutable` family of predicates provides
|
||||
<em>mutable variables</em>. They should be used instead of `setarg/3`,
|
||||
The setarg/3 primitive allows updating any argument of a Prolog
|
||||
compound terms. The _mutable_ family of predicates provides
|
||||
<em>mutable variables</em>. They should be used instead of setarg/3,
|
||||
as they allow the encapsulation of accesses to updatable
|
||||
variables. Their implementation can also be more efficient for long
|
||||
deterministic computations.
|
||||
|
||||
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
|
@ -44,7 +48,7 @@ deterministic computations.
|
|||
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
|
||||
static Int p_setarg( USES_REGS1 );
|
||||
static Int p_create_mutable( USES_REGS1 );
|
||||
|
@ -315,7 +319,6 @@ p_update_mutable( USES_REGS1 )
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
static Int
|
||||
/** @pred is_mutable(? _D_)
|
||||
|
||||
|
||||
|
@ -323,6 +326,7 @@ Holds if _D_ is a mutable term.
|
|||
|
||||
|
||||
*/
|
||||
static Int
|
||||
p_is_mutable( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
/* original goal */
|
||||
d0 = ENV_YREG[-EnvSizeInCells-1];
|
||||
/* predicate we had used */
|
||||
pen = RepPredProp((Prop)IntegerOfTerm(ENV_YREG[-EnvSizeInCells-2]));
|
||||
pen = RepPredProp(AddressOfTerm(ENV_YREG[-EnvSizeInCells-2]));
|
||||
/* current module at the time */
|
||||
mod = ENV_YREG[-EnvSizeInCells-3];
|
||||
/* set YREG */
|
||||
|
@ -116,7 +116,7 @@
|
|||
}
|
||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||
execute_pred_f:
|
||||
if (pen->PredFlags & MetaPredFlag) {
|
||||
if (pen->PredFlags & (MetaPredFlag|UndefPredFlag)) {
|
||||
/* just strip all of M:G */
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,d0);
|
||||
|
@ -242,7 +242,7 @@
|
|||
if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is primitives */
|
||||
if (pen->ModuleOfPred) {
|
||||
if (DEPTH == MkIntTerm(0)) {
|
||||
FAIL();
|
||||
FAIL();
|
||||
} else {
|
||||
DEPTH = RESET_DEPTH();
|
||||
}
|
||||
|
|
334
C/modules.c
334
C/modules.c
|
@ -14,22 +14,84 @@
|
|||
* comments: module support *
|
||||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
|
||||
|
||||
#ifdef SCCSLookupSystemModule
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "Yatom.h"
|
||||
|
||||
static Int current_module(USES_REGS1);
|
||||
static Int current_module1(USES_REGS1);
|
||||
static ModEntry *LookupModule(Term a);
|
||||
static ModEntry *LookupSystemModule(Term a);
|
||||
static ModEntry *GetModuleEntry(Atom at USES_REGS);
|
||||
static ModEntry *FetchModuleEntry(Atom at);
|
||||
|
||||
static ModEntry *FetchModuleEntry(Atom at)
|
||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||
{
|
||||
/**
|
||||
* initialize module data-structure
|
||||
*
|
||||
* @param to parent module (CurrentModule)
|
||||
* @param ae module name.
|
||||
*
|
||||
* @return a new module structure
|
||||
*/ /** */
|
||||
static ModEntry *initMod(AtomEntry *toname, AtomEntry *ae) {
|
||||
CACHE_REGS
|
||||
ModEntry *n, *parent;
|
||||
|
||||
if (toname == NULL)
|
||||
parent = NULL;
|
||||
else {
|
||||
parent = FetchModuleEntry(toname);
|
||||
}
|
||||
n = (ModEntry *)Yap_AllocAtomSpace(sizeof(*n));
|
||||
INIT_RWLOCK(n->ModRWLock);
|
||||
n->KindOfPE = ModProperty;
|
||||
n->PredForME = NULL;
|
||||
n->OpForME = NULL;
|
||||
n->NextME = CurrentModules;
|
||||
CurrentModules = n;
|
||||
n->AtomOfME = ae;
|
||||
n->NextOfPE = NULL;
|
||||
n->OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
AddPropToAtom(ae, (PropEntry *)n);
|
||||
Yap_setModuleFlags(n, parent);
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* get predicate entry for ap/arity; create it if neccessary
|
||||
*
|
||||
* @param[in] at
|
||||
*
|
||||
* @return module descriptorxs
|
||||
*/
|
||||
static ModEntry *GetModuleEntry(Atom at USES_REGS) {
|
||||
Prop p0;
|
||||
AtomEntry *ae = RepAtom(at);
|
||||
|
||||
READ_LOCK(ae->ARWLock);
|
||||
p0 = ae->PropsOfAE;
|
||||
while (p0) {
|
||||
ModEntry *me = RepModProp(p0);
|
||||
if (me->KindOfPE == ModProperty) {
|
||||
READ_UNLOCK(ae->ARWLock);
|
||||
return me;
|
||||
}
|
||||
p0 = me->NextOfPE;
|
||||
}
|
||||
READ_UNLOCK(ae->ARWLock);
|
||||
|
||||
return initMod(
|
||||
(CurrentModule == PROLOG_MODULE ? NULL : AtomOfTerm(CurrentModule)), at);
|
||||
}
|
||||
|
||||
/** get entry for ap/arity; assumes one is there. */
|
||||
static ModEntry *FetchModuleEntry(Atom at) {
|
||||
Prop p0;
|
||||
AtomEntry *ae = RepAtom(at);
|
||||
|
||||
|
@ -47,40 +109,6 @@ static ModEntry *LookupSystemModule(Term a);
|
|||
return NULL;
|
||||
}
|
||||
|
||||
inline static ModEntry *GetModuleEntry(Atom at)
|
||||
/* Get predicate entry for ap/arity; create it if necessary. */
|
||||
{
|
||||
Prop p0;
|
||||
AtomEntry *ae = RepAtom(at);
|
||||
ModEntry *new, *oat;
|
||||
|
||||
p0 = ae->PropsOfAE;
|
||||
while (p0) {
|
||||
if (p0->KindOfPE == ModProperty) {
|
||||
return RepModProp(p0);
|
||||
}
|
||||
p0 = p0->NextOfPE;
|
||||
}
|
||||
{
|
||||
CACHE_REGS
|
||||
new = (ModEntry *)Yap_AllocAtomSpace(sizeof(*new));
|
||||
INIT_RWLOCK(new->ModRWLock);
|
||||
new->KindOfPE = ModProperty;
|
||||
new->PredForME = NULL;
|
||||
new->NextME = CurrentModules;
|
||||
CurrentModules = new;
|
||||
new->AtomOfME = ae;
|
||||
new->OwnerFile = Yap_ConsultingFile( PASS_REGS1);
|
||||
AddPropToAtom(ae, (PropEntry *)new);
|
||||
if (CurrentModule == 0L || (oat = GetModuleEntry(AtomOfTerm(CurrentModule))) == new) {
|
||||
Yap_setModuleFlags(new, NULL);
|
||||
} else {
|
||||
Yap_setModuleFlags(new, oat);
|
||||
}
|
||||
}
|
||||
return new;
|
||||
}
|
||||
|
||||
Term Yap_getUnknownModule(ModEntry *m) {
|
||||
if (m && m->flags & UNKNOWN_ERROR) {
|
||||
return TermError;
|
||||
|
@ -93,75 +121,73 @@ Term Yap_getUnknownModule(ModEntry *m) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Yap_getUnknown ( Term mod) {
|
||||
ModEntry *m = LookupModule( mod );
|
||||
return Yap_getUnknownModule( m );
|
||||
bool Yap_getUnknown(Term mod) {
|
||||
ModEntry *m = LookupModule(mod);
|
||||
return Yap_getUnknownModule(m);
|
||||
}
|
||||
|
||||
|
||||
bool Yap_CharacterEscapes(Term mt) {
|
||||
if (mt == PROLOG_MODULE) mt = TermProlog;
|
||||
return GetModuleEntry(AtomOfTerm(mt))->flags & M_CHARESCAPE;
|
||||
bool Yap_CharacterEscapes(Term mt) {
|
||||
CACHE_REGS
|
||||
if (mt == PROLOG_MODULE)
|
||||
mt = TermProlog;
|
||||
return GetModuleEntry(AtomOfTerm(mt) PASS_REGS)->flags & M_CHARESCAPE;
|
||||
}
|
||||
|
||||
|
||||
#define ByteAdr(X) ((char *)&(X))
|
||||
Term Yap_Module_Name(PredEntry *ap) {
|
||||
CACHE_REGS
|
||||
Term mod;
|
||||
|
||||
if (!ap)
|
||||
return TermUser;
|
||||
if (!ap->ModuleOfPred)
|
||||
/* If the system predicate is a metacall I should return the
|
||||
/* If the system predicate is a meta-call I should return the
|
||||
module for the metacall, which I will suppose has to be
|
||||
reachable from the current module anyway.
|
||||
|
||||
So I will return the current module in case the system
|
||||
predicate is a meta-call. Otherwise it will still work.
|
||||
*/
|
||||
mod = CurrentModule;
|
||||
return TermProlog;
|
||||
else {
|
||||
mod = ap->ModuleOfPred;
|
||||
return ap->ModuleOfPred;
|
||||
}
|
||||
if (mod)
|
||||
return mod;
|
||||
return TermProlog;
|
||||
|
||||
}
|
||||
|
||||
static ModEntry *LookupSystemModule(Term a) {
|
||||
CACHE_REGS
|
||||
Atom at;
|
||||
ModEntry *me;
|
||||
|
||||
|
||||
/* prolog module */
|
||||
if (a == 0) {
|
||||
return GetModuleEntry(AtomProlog);
|
||||
a = TermProlog;
|
||||
}
|
||||
at = AtomOfTerm(a);
|
||||
me = GetModuleEntry(at);
|
||||
me = GetModuleEntry(at PASS_REGS);
|
||||
if (!me)
|
||||
return NULL;
|
||||
me->flags |= M_SYSTEM;
|
||||
me->OwnerFile = Yap_ConsultingFile( PASS_REGS1 );
|
||||
return me;}
|
||||
|
||||
me->OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
return me;
|
||||
}
|
||||
|
||||
static ModEntry *LookupModule(Term a) {
|
||||
CACHE_REGS
|
||||
Atom at;
|
||||
ModEntry *me;
|
||||
|
||||
/* prolog module */
|
||||
if (a == 0) {
|
||||
return GetModuleEntry(AtomProlog);
|
||||
return GetModuleEntry(AtomProlog PASS_REGS);
|
||||
}
|
||||
at = AtomOfTerm(a);
|
||||
me = GetModuleEntry(at);
|
||||
me = GetModuleEntry(at PASS_REGS);
|
||||
return me;
|
||||
}
|
||||
|
||||
bool Yap_isSystemModule(Term a) {
|
||||
ModEntry *me = LookupModule(a);
|
||||
return
|
||||
me != NULL &&
|
||||
me->flags & M_SYSTEM;
|
||||
return me != NULL && me->flags & M_SYSTEM;
|
||||
}
|
||||
|
||||
Term Yap_Module(Term tmod) {
|
||||
|
@ -171,10 +197,10 @@ Term Yap_Module(Term tmod) {
|
|||
|
||||
ModEntry *Yap_GetModuleEntry(Term mod) {
|
||||
ModEntry *me;
|
||||
|
||||
if (!(me = LookupModule(mod)))
|
||||
return NULL;
|
||||
return me;
|
||||
|
||||
}
|
||||
|
||||
Term Yap_GetModuleFromEntry(ModEntry *me) {
|
||||
|
@ -192,6 +218,8 @@ struct pred_entry *Yap_ModulePred(Term mod) {
|
|||
void Yap_NewModulePred(Term mod, struct pred_entry *ap) {
|
||||
ModEntry *me;
|
||||
|
||||
if (mod == 0)
|
||||
mod = TermProlog;
|
||||
if (!(me = LookupModule(mod)))
|
||||
return;
|
||||
WRITE_LOCK(me->ModRWLock);
|
||||
|
@ -201,7 +229,7 @@ void Yap_NewModulePred(Term mod, struct pred_entry *ap) {
|
|||
}
|
||||
|
||||
static Int
|
||||
current_module(USES_REGS1) { /* $current_module(Old,New) */
|
||||
current_module(USES_REGS1) { /* $current_module(Old,N) */
|
||||
Term t;
|
||||
|
||||
if (CurrentModule) {
|
||||
|
@ -225,7 +253,7 @@ static Int
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static Int change_module(USES_REGS1) { /* $change_module(New) */
|
||||
static Int change_module(USES_REGS1) { /* $change_module(N) */
|
||||
Term mod = Deref(ARG1);
|
||||
LookupModule(mod);
|
||||
CurrentModule = mod;
|
||||
|
@ -234,13 +262,12 @@ static Int change_module(USES_REGS1) { /* $change_module(New) */
|
|||
}
|
||||
|
||||
static Int current_module1(USES_REGS1) { /* $current_module(Old)
|
||||
*/
|
||||
*/
|
||||
if (CurrentModule)
|
||||
return Yap_unify_constant(ARG1, CurrentModule);
|
||||
return Yap_unify_constant(ARG1, TermProlog);
|
||||
}
|
||||
|
||||
|
||||
static Int cont_current_module(USES_REGS1) {
|
||||
ModEntry *imod = AddressOfTerm(EXTRA_CBACK_ARG(1, 1)), *next;
|
||||
Term t = MkAtomTerm(imod->AtomOfME);
|
||||
|
@ -283,7 +310,7 @@ static Int cont_ground_module(USES_REGS1) {
|
|||
}
|
||||
|
||||
static Int init_ground_module(USES_REGS1) {
|
||||
/* current_module(?ModuleName) */
|
||||
/* current_module(?ModuleName) */
|
||||
Term t1 = Deref(ARG1), tmod = CurrentModule, t3;
|
||||
if (tmod == PROLOG_MODULE) {
|
||||
tmod = TermProlog;
|
||||
|
@ -304,51 +331,48 @@ static Int init_ground_module(USES_REGS1) {
|
|||
}
|
||||
cut_fail();
|
||||
}
|
||||
if (!Yap_unify(ARG2, tmod) ||
|
||||
!Yap_unify(ARG3, t3) ) {
|
||||
cut_fail();
|
||||
}
|
||||
// make sure we keep the binding
|
||||
if (!Yap_unify(ARG2, tmod) || !Yap_unify(ARG3, t3)) {
|
||||
cut_fail();
|
||||
}
|
||||
// make sure we keep the binding
|
||||
B->cp_tr = TR;
|
||||
B->cp_h = HR;
|
||||
EXTRA_CBACK_ARG(3, 1) = MkAddressTerm(CurrentModules);
|
||||
return cont_ground_module(PASS_REGS1);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @pred system_module( + _Mod_)
|
||||
*
|
||||
* @param module
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @param module
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static Int is_system_module( USES_REGS1 )
|
||||
{
|
||||
static Int is_system_module(USES_REGS1) {
|
||||
Term t;
|
||||
if (IsVarTerm(t = Deref (ARG1))) {
|
||||
if (IsVarTerm(t = Deref(ARG1))) {
|
||||
return false;
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "load_files/2");
|
||||
return false;
|
||||
}
|
||||
return Yap_isSystemModule( t );
|
||||
return Yap_isSystemModule(t);
|
||||
}
|
||||
|
||||
static Int new_system_module( USES_REGS1 )
|
||||
{
|
||||
static Int new_system_module(USES_REGS1) {
|
||||
ModEntry *me;
|
||||
Term t;
|
||||
if (IsVarTerm(t = Deref (ARG1))) {
|
||||
Yap_Error( INSTANTIATION_ERROR, t, NULL);
|
||||
if (IsVarTerm(t = Deref(ARG1))) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, NULL);
|
||||
return false;
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, NULL);
|
||||
return false;
|
||||
}
|
||||
me = LookupSystemModule( t );
|
||||
me->OwnerFile = Yap_ConsultingFile( PASS_REGS1);
|
||||
if ((me = LookupSystemModule(t)))
|
||||
me->OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
return me != NULL;
|
||||
}
|
||||
|
||||
|
@ -365,13 +389,58 @@ static Int strip_module(USES_REGS1) {
|
|||
return Yap_unify(ARG3, t1) && Yap_unify(ARG2, tmod);
|
||||
}
|
||||
|
||||
static Int yap_strip_clause(USES_REGS1) {
|
||||
Term t1 = Deref(ARG1), tmod = LOCAL_SourceModule;
|
||||
if (tmod == PROLOG_MODULE) {
|
||||
tmod = TermProlog;
|
||||
}
|
||||
t1 = Yap_StripModule(t1, &tmod);
|
||||
if (IsVarTerm(t1) || IsVarTerm(tmod)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "trying to obtain module");
|
||||
return false;
|
||||
} else if (IsApplTerm(t1)) {
|
||||
Functor f = FunctorOfTerm(t1);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module");
|
||||
return false;
|
||||
}
|
||||
if (f == FunctorAssert || f == FunctorDoubleArrow) {
|
||||
Term thmod = tmod;
|
||||
Term th = ArgOfTerm(1, t1);
|
||||
th = Yap_StripModule(th, &thmod);
|
||||
if (IsVarTerm(th)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "trying to obtain module");
|
||||
return false;
|
||||
} else if (IsVarTerm(thmod)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, thmod, "trying to obtain module");
|
||||
return false;
|
||||
} else if (IsIntTerm(th) ||
|
||||
(IsApplTerm(th) && IsExtensionFunctor(FunctorOfTerm(t1)))) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module");
|
||||
return false;
|
||||
} else if (!IsAtomTerm(thmod)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, thmod, "trying to obtain module");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (IsIntTerm(t1) || IsIntTerm(tmod)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module");
|
||||
return false;
|
||||
}
|
||||
return Yap_unify(ARG3, t1) && Yap_unify(ARG2, tmod);
|
||||
}
|
||||
|
||||
Term Yap_YapStripModule(Term t, Term *modp) {
|
||||
CACHE_REGS
|
||||
Term tmod;
|
||||
|
||||
if (modp)
|
||||
if (modp) {
|
||||
tmod = *modp;
|
||||
else {
|
||||
if (tmod == PROLOG_MODULE) {
|
||||
*modp = tmod = TermProlog;
|
||||
}
|
||||
} else {
|
||||
tmod = CurrentModule;
|
||||
if (tmod == PROLOG_MODULE) {
|
||||
tmod = TermProlog;
|
||||
|
@ -388,7 +457,9 @@ restart:
|
|||
Term t1 = ArgOfTerm(1, t);
|
||||
tmod = t1;
|
||||
if (!IsVarTerm(tmod) && !IsAtomTerm(tmod)) {
|
||||
return 0L;
|
||||
if (modp)
|
||||
*modp = tmod;
|
||||
return t;
|
||||
}
|
||||
t = ArgOfTerm(2, t);
|
||||
goto restart;
|
||||
|
@ -406,7 +477,7 @@ static Int yap_strip_module(USES_REGS1) {
|
|||
tmod = TermProlog;
|
||||
}
|
||||
t1 = Yap_YapStripModule(t1, &tmod);
|
||||
if (!t1) {
|
||||
if (!t1 || (!IsVarTerm(tmod) && !IsAtomTerm(tmod))) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -431,13 +502,13 @@ static Int context_module(USES_REGS1) {
|
|||
return Yap_unify(ARG1, CurrentModule);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @pred source_module(-Mod)
|
||||
*
|
||||
* @param Mod is the current text source module.
|
||||
*
|
||||
*
|
||||
* @param Mod is the current text source module.
|
||||
*
|
||||
* : _Mod_ is the current read-in or source module.
|
||||
*/
|
||||
*/
|
||||
static Int source_module(USES_REGS1) {
|
||||
if (LOCAL_SourceModule == PROLOG_MODULE) {
|
||||
return Yap_unify(ARG1, TermProlog);
|
||||
|
@ -445,9 +516,60 @@ static Int source_module(USES_REGS1) {
|
|||
return Yap_unify(ARG1, LOCAL_SourceModule);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pred source_module(-Mod)
|
||||
*
|
||||
* @param Mod is the current text source module.
|
||||
*
|
||||
* : _Mod_ is the current read-in or source module.
|
||||
*/
|
||||
static Int current_source_module(USES_REGS1) {
|
||||
Term t;
|
||||
if (LOCAL_SourceModule == PROLOG_MODULE) {
|
||||
LOCAL_SourceModule = TermProlog;
|
||||
}
|
||||
if (!Yap_unify(ARG1, LOCAL_SourceModule)) {
|
||||
return false;
|
||||
};
|
||||
if (IsVarTerm(t = Deref(ARG2))) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, NULL);
|
||||
return false;
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, NULL);
|
||||
return false;
|
||||
}
|
||||
LOCAL_SourceModule = CurrentModule = t;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @pred $copy_operators(+Mode, +ModTarget)
|
||||
*
|
||||
* Copy all operators in ModSource to ModTarget
|
||||
*
|
||||
* : _Mod_ is the current read-in or source module.
|
||||
*/
|
||||
static Int copy_operators(USES_REGS1) {
|
||||
ModEntry *me = LookupModule(Deref(ARG1));
|
||||
if (!me)
|
||||
return true;
|
||||
ModEntry *she = LookupModule(Deref(ARG2));
|
||||
if (!she)
|
||||
return true;
|
||||
OpEntry *op = me->OpForME;
|
||||
while (op) {
|
||||
if (!Yap_dup_op(op, she)) {
|
||||
return false;
|
||||
}
|
||||
op = op->NextForME;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Term Yap_StripModule(Term t, Term *modp) {
|
||||
CACHE_REGS
|
||||
Term tmod;
|
||||
Term tmod;
|
||||
|
||||
if (modp)
|
||||
tmod = *modp;
|
||||
|
@ -492,11 +614,16 @@ void Yap_InitModulesC(void) {
|
|||
Yap_InitCPred("$change_module", 1, change_module,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("strip_module", 3, strip_module, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("source_module", 1, source_module, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$yap_strip_module", 3, yap_strip_module,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("source_module", 1, source_module, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("current_source_module", 2, current_source_module,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$yap_strip_clause", 3, yap_strip_clause,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("context_module", 1, context_module, 0);
|
||||
Yap_InitCPred("$is_system_module", 1, is_system_module, SafePredFlag);
|
||||
Yap_InitCPred("$copy_operators", 2, copy_operators, 0);
|
||||
Yap_InitCPred("new_system_module", 1, new_system_module, SafePredFlag);
|
||||
Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module,
|
||||
cont_current_module, SafePredFlag | SyncPredFlag);
|
||||
|
@ -506,6 +633,7 @@ void Yap_InitModulesC(void) {
|
|||
|
||||
void Yap_InitModules(void) {
|
||||
CACHE_REGS
|
||||
CurrentModules = NULL;
|
||||
LookupSystemModule(MkAtomTerm(AtomProlog));
|
||||
LOCAL_SourceModule = MkAtomTerm(AtomProlog);
|
||||
LookupModule(USER_MODULE);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
Op(either, Osblp);
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace) {
|
||||
low_level_trace(try_or, (PredEntry *)PREG, NULL);
|
||||
low_level_trace(try_or, PREG->y_u.Osblp.p0, NULL);
|
||||
}
|
||||
#endif
|
||||
#ifdef COROUTINING
|
||||
|
|
556
C/parser.c
556
C/parser.c
File diff suppressed because it is too large
Load Diff
1938
C/prim_absmi_insts.h
1938
C/prim_absmi_insts.h
File diff suppressed because it is too large
Load Diff
487
C/qlyw.c
487
C/qlyw.c
|
@ -1,64 +1,73 @@
|
|||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: qlyw.c *
|
||||
* comments: quick saver/loader *
|
||||
* *
|
||||
* Last rev: $Date: 2011-08-29$,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $ *
|
||||
* *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: qlyw.c *
|
||||
* comments: quick saver/loader *
|
||||
* *
|
||||
* Last rev: $Date: 2011-08-29$,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $ *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
* @file qlyr.c
|
||||
*
|
||||
* @addtogroup SaveRestoreSupport
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#include "absmi.h"
|
||||
#include "Foreign.h"
|
||||
#include "absmi.h"
|
||||
#include "alloc.h"
|
||||
#include "yapio.h"
|
||||
#include "iopreds.h"
|
||||
#include "attvar.h"
|
||||
#include "iopreds.h"
|
||||
#include "yapio.h"
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "qly.h"
|
||||
|
||||
static void RestoreEntries(PropEntry *, int USES_REGS);
|
||||
static void CleanCode(PredEntry * USES_REGS);
|
||||
static void RestoreEntries(PropEntry *, int USES_REGS);
|
||||
static void CleanCode(PredEntry *USES_REGS);
|
||||
|
||||
static void
|
||||
GrowAtomTable(void) {
|
||||
static void GrowAtomTable(void) {
|
||||
CACHE_REGS
|
||||
UInt size = LOCAL_ExportAtomHashTableSize;
|
||||
UInt size = LOCAL_ExportAtomHashTableSize;
|
||||
export_atom_hash_entry_t *p, *newt, *oldt = LOCAL_ExportAtomHashChain;
|
||||
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||
UInt i;
|
||||
|
||||
newt = (export_atom_hash_entry_t *)calloc(new_size,sizeof(export_atom_hash_entry_t));
|
||||
newt = (export_atom_hash_entry_t *)calloc(new_size,
|
||||
sizeof(export_atom_hash_entry_t));
|
||||
if (!newt) {
|
||||
return;
|
||||
}
|
||||
p = oldt;
|
||||
for (i = 0 ; i < size ; p++,i++) {
|
||||
for (i = 0; i < size; p++, i++) {
|
||||
Atom a = p->val;
|
||||
export_atom_hash_entry_t *newp;
|
||||
CELL hash;
|
||||
const unsigned char *apt;
|
||||
|
||||
|
||||
if (!a) continue;
|
||||
if (!a)
|
||||
continue;
|
||||
apt = RepAtom(a)->UStrOfAE;
|
||||
hash = HashFunction(apt)/(2*sizeof(CELL)) % new_size;
|
||||
newp = newt+hash;
|
||||
hash = HashFunction(apt) / (2 * sizeof(CELL)) % new_size;
|
||||
newp = newt + hash;
|
||||
while (newp->val) {
|
||||
newp++;
|
||||
if (newp == newt+new_size)
|
||||
newp = newt;
|
||||
if (newp == newt + new_size)
|
||||
newp = newt;
|
||||
}
|
||||
newp->val = a;
|
||||
}
|
||||
|
@ -67,29 +76,24 @@ GrowAtomTable(void) {
|
|||
free(oldt);
|
||||
}
|
||||
|
||||
static void
|
||||
LookupAtom(Atom at)
|
||||
{
|
||||
static void LookupAtom(Atom at) {
|
||||
CACHE_REGS
|
||||
const unsigned char *p = RepAtom(at)->UStrOfAE;
|
||||
CELL hash = HashFunction(p) % LOCAL_ExportAtomHashTableSize;
|
||||
export_atom_hash_entry_t *a;
|
||||
|
||||
a = LOCAL_ExportAtomHashChain+hash;
|
||||
a = LOCAL_ExportAtomHashChain + hash;
|
||||
while (a->val) {
|
||||
if (a->val == at) {
|
||||
return;
|
||||
}
|
||||
a++;
|
||||
if (a == LOCAL_ExportAtomHashChain+LOCAL_ExportAtomHashTableSize)
|
||||
if (a == LOCAL_ExportAtomHashChain + LOCAL_ExportAtomHashTableSize)
|
||||
a = LOCAL_ExportAtomHashChain;
|
||||
|
||||
}
|
||||
a->val = at;
|
||||
LOCAL_ExportAtomHashTableNum++;
|
||||
if (LOCAL_ExportAtomHashTableNum >
|
||||
LOCAL_ExportAtomHashTableSize/2
|
||||
) {
|
||||
if (LOCAL_ExportAtomHashTableNum > LOCAL_ExportAtomHashTableSize / 2) {
|
||||
GrowAtomTable();
|
||||
if (!LOCAL_ExportAtomHashChain) {
|
||||
return;
|
||||
|
@ -97,31 +101,32 @@ LookupAtom(Atom at)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
GrowFunctorTable(void) {
|
||||
static void GrowFunctorTable(void) {
|
||||
CACHE_REGS
|
||||
UInt size = LOCAL_ExportFunctorHashTableSize;
|
||||
UInt size = LOCAL_ExportFunctorHashTableSize;
|
||||
export_functor_hash_entry_t *p, *newt, *oldt = LOCAL_ExportFunctorHashChain;
|
||||
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||
UInt i;
|
||||
|
||||
newt = (export_functor_hash_entry_t *)calloc(new_size,sizeof(export_functor_hash_entry_t));
|
||||
newt = (export_functor_hash_entry_t *)calloc(
|
||||
new_size, sizeof(export_functor_hash_entry_t));
|
||||
if (!newt) {
|
||||
return;
|
||||
}
|
||||
p = oldt;
|
||||
for (i = 0 ; i < size ; p++,i++) {
|
||||
for (i = 0; i < size; p++, i++) {
|
||||
Functor f = p->val;
|
||||
export_functor_hash_entry_t *newp;
|
||||
CELL hash;
|
||||
|
||||
if (!f) continue;
|
||||
hash = ((CELL)(f))/(2*sizeof(CELL)) % new_size;
|
||||
newp = newt+hash;
|
||||
if (!f)
|
||||
continue;
|
||||
hash = ((CELL)(f)) / (2 * sizeof(CELL)) % new_size;
|
||||
newp = newt + hash;
|
||||
while (newp->val) {
|
||||
newp++;
|
||||
if (newp == newt+new_size)
|
||||
newp = newt;
|
||||
if (newp == newt + new_size)
|
||||
newp = newt;
|
||||
}
|
||||
newp->val = p->val;
|
||||
newp->arity = p->arity;
|
||||
|
@ -132,22 +137,21 @@ GrowFunctorTable(void) {
|
|||
free(oldt);
|
||||
}
|
||||
|
||||
static void
|
||||
LookupFunctor(Functor fun)
|
||||
{
|
||||
static void LookupFunctor(Functor fun) {
|
||||
CACHE_REGS
|
||||
CELL hash = ((CELL)(fun))/(2*sizeof(CELL)) % LOCAL_ExportFunctorHashTableSize;
|
||||
CELL hash =
|
||||
((CELL)(fun)) / (2 * sizeof(CELL)) % LOCAL_ExportFunctorHashTableSize;
|
||||
export_functor_hash_entry_t *f;
|
||||
Atom name = NameOfFunctor(fun);
|
||||
UInt arity = ArityOfFunctor(fun);
|
||||
UInt arity = ArityOfFunctor(fun);
|
||||
|
||||
f = LOCAL_ExportFunctorHashChain+hash;
|
||||
f = LOCAL_ExportFunctorHashChain + hash;
|
||||
while (f->val) {
|
||||
if (f->val == fun) {
|
||||
return;
|
||||
}
|
||||
f++;
|
||||
if (f == LOCAL_ExportFunctorHashChain+LOCAL_ExportFunctorHashTableSize)
|
||||
if (f == LOCAL_ExportFunctorHashChain + LOCAL_ExportFunctorHashTableSize)
|
||||
f = LOCAL_ExportFunctorHashChain;
|
||||
}
|
||||
LookupAtom(name);
|
||||
|
@ -155,9 +159,7 @@ LookupFunctor(Functor fun)
|
|||
f->name = name;
|
||||
f->arity = arity;
|
||||
LOCAL_ExportFunctorHashTableNum++;
|
||||
if (LOCAL_ExportFunctorHashTableNum >
|
||||
LOCAL_ExportFunctorHashTableSize/2
|
||||
) {
|
||||
if (LOCAL_ExportFunctorHashTableNum > LOCAL_ExportFunctorHashTableSize / 2) {
|
||||
GrowFunctorTable();
|
||||
if (!LOCAL_ExportFunctorHashChain) {
|
||||
return;
|
||||
|
@ -165,31 +167,33 @@ LookupFunctor(Functor fun)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
GrowPredTable(void) {
|
||||
static void GrowPredTable(void) {
|
||||
CACHE_REGS
|
||||
UInt size = LOCAL_ExportPredEntryHashTableSize;
|
||||
export_pred_entry_hash_entry_t *p, *newt, *oldt = LOCAL_ExportPredEntryHashChain;
|
||||
UInt size = LOCAL_ExportPredEntryHashTableSize;
|
||||
export_pred_entry_hash_entry_t *p, *newt,
|
||||
*oldt = LOCAL_ExportPredEntryHashChain;
|
||||
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||
UInt i;
|
||||
|
||||
newt = (export_pred_entry_hash_entry_t *)calloc(new_size,sizeof(export_pred_entry_hash_entry_t));
|
||||
newt = (export_pred_entry_hash_entry_t *)calloc(
|
||||
new_size, sizeof(export_pred_entry_hash_entry_t));
|
||||
if (!newt) {
|
||||
return;
|
||||
}
|
||||
p = oldt;
|
||||
for (i = 0 ; i < size ; p++,i++) {
|
||||
for (i = 0; i < size; p++, i++) {
|
||||
PredEntry *pe = p->val;
|
||||
export_pred_entry_hash_entry_t *newp;
|
||||
CELL hash;
|
||||
|
||||
if (!pe) continue;
|
||||
hash = ((CELL)(pe))/(2*sizeof(CELL)) % new_size;
|
||||
newp = newt+hash;
|
||||
if (!pe)
|
||||
continue;
|
||||
hash = ((CELL)(pe)) / (2 * sizeof(CELL)) % new_size;
|
||||
newp = newt + hash;
|
||||
while (newp->val) {
|
||||
newp++;
|
||||
if (newp == newt+new_size)
|
||||
newp = newt;
|
||||
if (newp == newt + new_size)
|
||||
newp = newt;
|
||||
}
|
||||
newp->val = p->val;
|
||||
newp->arity = p->arity;
|
||||
|
@ -201,21 +205,21 @@ GrowPredTable(void) {
|
|||
free(oldt);
|
||||
}
|
||||
|
||||
static void
|
||||
LookupPredEntry(PredEntry *pe)
|
||||
{
|
||||
static void LookupPredEntry(PredEntry *pe) {
|
||||
CACHE_REGS
|
||||
CELL hash = (((CELL)(pe))/(2*sizeof(CELL))) % LOCAL_ExportPredEntryHashTableSize;
|
||||
CELL hash =
|
||||
(((CELL)(pe)) / (2 * sizeof(CELL))) % LOCAL_ExportPredEntryHashTableSize;
|
||||
export_pred_entry_hash_entry_t *p;
|
||||
UInt arity = pe->ArityOfPE;
|
||||
UInt arity = pe->ArityOfPE;
|
||||
|
||||
p = LOCAL_ExportPredEntryHashChain+hash;
|
||||
p = LOCAL_ExportPredEntryHashChain + hash;
|
||||
while (p->val) {
|
||||
if (p->val == pe) {
|
||||
return;
|
||||
}
|
||||
p++;
|
||||
if (p == LOCAL_ExportPredEntryHashChain+LOCAL_ExportPredEntryHashTableSize)
|
||||
if (p ==
|
||||
LOCAL_ExportPredEntryHashChain + LOCAL_ExportPredEntryHashTableSize)
|
||||
p = LOCAL_ExportPredEntryHashChain;
|
||||
}
|
||||
p->arity = arity;
|
||||
|
@ -248,9 +252,8 @@ LookupPredEntry(PredEntry *pe)
|
|||
}
|
||||
LookupAtom(p->module);
|
||||
LOCAL_ExportPredEntryHashTableNum++;
|
||||
if (LOCAL_ExportPredEntryHashTableNum >
|
||||
LOCAL_ExportPredEntryHashTableSize/2
|
||||
) {
|
||||
if (LOCAL_ExportPredEntryHashTableNum >
|
||||
LOCAL_ExportPredEntryHashTableSize / 2) {
|
||||
GrowPredTable();
|
||||
if (!LOCAL_ExportPredEntryHashChain) {
|
||||
return;
|
||||
|
@ -258,32 +261,32 @@ LookupPredEntry(PredEntry *pe)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
GrowDBRefTable(void) {
|
||||
static void GrowDBRefTable(void) {
|
||||
CACHE_REGS
|
||||
UInt size = LOCAL_ExportDBRefHashTableSize;
|
||||
UInt size = LOCAL_ExportDBRefHashTableSize;
|
||||
export_dbref_hash_entry_t *p, *newt, *oldt = LOCAL_ExportDBRefHashChain;
|
||||
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||
UInt i;
|
||||
|
||||
newt = (export_dbref_hash_entry_t *)calloc(new_size,sizeof(export_dbref_hash_entry_t));
|
||||
newt = (export_dbref_hash_entry_t *)calloc(new_size,
|
||||
sizeof(export_dbref_hash_entry_t));
|
||||
if (!newt) {
|
||||
return;
|
||||
}
|
||||
p = oldt;
|
||||
for (i = 0 ; i < size ; p++,i++) {
|
||||
for (i = 0; i < size; p++, i++) {
|
||||
DBRef dbr = p->val;
|
||||
export_dbref_hash_entry_t *newp;
|
||||
CELL hash;
|
||||
|
||||
if (!dbr) continue;
|
||||
hash = ((CELL)(dbr))/(2*sizeof(CELL)) % new_size;
|
||||
newp = newt+hash;
|
||||
if (!dbr)
|
||||
continue;
|
||||
hash = ((CELL)(dbr)) / (2 * sizeof(CELL)) % new_size;
|
||||
newp = newt + hash;
|
||||
while (newp->val) {
|
||||
newp++;
|
||||
if (newp == newt+new_size)
|
||||
newp = newt;
|
||||
if (newp == newt + new_size)
|
||||
newp = newt;
|
||||
}
|
||||
newp->val = p->val;
|
||||
newp->sz = p->sz;
|
||||
|
@ -294,30 +297,27 @@ GrowDBRefTable(void) {
|
|||
free(oldt);
|
||||
}
|
||||
|
||||
static void
|
||||
LookupDBRef(DBRef ref)
|
||||
{
|
||||
static void LookupDBRef(DBRef ref) {
|
||||
CACHE_REGS
|
||||
CELL hash = ((CELL)(ref))/(2*sizeof(CELL)) % LOCAL_ExportDBRefHashTableSize;
|
||||
CELL hash =
|
||||
((CELL)(ref)) / (2 * sizeof(CELL)) % LOCAL_ExportDBRefHashTableSize;
|
||||
export_dbref_hash_entry_t *a;
|
||||
|
||||
a = LOCAL_ExportDBRefHashChain+hash;
|
||||
a = LOCAL_ExportDBRefHashChain + hash;
|
||||
while (a->val) {
|
||||
if (a->val == ref) {
|
||||
a->refs++;
|
||||
return;
|
||||
}
|
||||
a++;
|
||||
if (a == LOCAL_ExportDBRefHashChain+LOCAL_ExportDBRefHashTableSize)
|
||||
if (a == LOCAL_ExportDBRefHashChain + LOCAL_ExportDBRefHashTableSize)
|
||||
a = LOCAL_ExportDBRefHashChain;
|
||||
}
|
||||
a->val = ref;
|
||||
a->sz = ((LogUpdClause *)ref)->ClSize;
|
||||
a->refs = 1;
|
||||
LOCAL_ExportDBRefHashTableNum++;
|
||||
if (LOCAL_ExportDBRefHashTableNum >
|
||||
LOCAL_ExportDBRefHashTableSize/2
|
||||
) {
|
||||
if (LOCAL_ExportDBRefHashTableNum > LOCAL_ExportDBRefHashTableSize / 2) {
|
||||
GrowDBRefTable();
|
||||
if (!LOCAL_ExportDBRefHashChain) {
|
||||
return;
|
||||
|
@ -325,27 +325,28 @@ LookupDBRef(DBRef ref)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
InitHash(void)
|
||||
{
|
||||
static void InitHash(void) {
|
||||
CACHE_REGS
|
||||
LOCAL_ExportFunctorHashTableNum = 0;
|
||||
LOCAL_ExportFunctorHashTableSize = EXPORT_FUNCTOR_TABLE_SIZE;
|
||||
LOCAL_ExportFunctorHashChain = (export_functor_hash_entry_t *)calloc(LOCAL_ExportFunctorHashTableSize, sizeof(export_functor_hash_entry_t ));
|
||||
LOCAL_ExportFunctorHashChain = (export_functor_hash_entry_t *)calloc(
|
||||
LOCAL_ExportFunctorHashTableSize, sizeof(export_functor_hash_entry_t));
|
||||
LOCAL_ExportAtomHashTableNum = 0;
|
||||
LOCAL_ExportAtomHashTableSize = EXPORT_ATOM_TABLE_SIZE;
|
||||
LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t *)calloc( LOCAL_ExportAtomHashTableSize, sizeof(export_atom_hash_entry_t));
|
||||
LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t *)calloc(
|
||||
LOCAL_ExportAtomHashTableSize, sizeof(export_atom_hash_entry_t));
|
||||
LOCAL_ExportPredEntryHashTableNum = 0;
|
||||
LOCAL_ExportPredEntryHashTableSize = EXPORT_PRED_ENTRY_TABLE_SIZE;
|
||||
LOCAL_ExportPredEntryHashChain = (export_pred_entry_hash_entry_t *)calloc(LOCAL_ExportPredEntryHashTableSize, sizeof(export_pred_entry_hash_entry_t));
|
||||
LOCAL_ExportPredEntryHashChain = (export_pred_entry_hash_entry_t *)calloc(
|
||||
LOCAL_ExportPredEntryHashTableSize,
|
||||
sizeof(export_pred_entry_hash_entry_t));
|
||||
LOCAL_ExportDBRefHashTableNum = 0;
|
||||
LOCAL_ExportDBRefHashTableSize = EXPORT_DBREF_TABLE_SIZE;
|
||||
LOCAL_ExportDBRefHashChain = (export_dbref_hash_entry_t *)calloc(EXPORT_DBREF_TABLE_SIZE, sizeof(export_dbref_hash_entry_t));
|
||||
LOCAL_ExportDBRefHashChain = (export_dbref_hash_entry_t *)calloc(
|
||||
EXPORT_DBREF_TABLE_SIZE, sizeof(export_dbref_hash_entry_t));
|
||||
}
|
||||
|
||||
static void
|
||||
CloseHash(void)
|
||||
{
|
||||
static void CloseHash(void) {
|
||||
CACHE_REGS
|
||||
LOCAL_ExportFunctorHashTableNum = 0;
|
||||
LOCAL_ExportFunctorHashTableSize = 0L;
|
||||
|
@ -361,37 +362,27 @@ CloseHash(void)
|
|||
free(LOCAL_ExportDBRefHashChain);
|
||||
}
|
||||
|
||||
static inline Atom
|
||||
AtomAdjust(Atom a)
|
||||
{
|
||||
static inline Atom AtomAdjust(Atom a) {
|
||||
LookupAtom(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline Functor
|
||||
FuncAdjust(Functor f)
|
||||
{
|
||||
static inline Functor FuncAdjust(Functor f) {
|
||||
LookupFunctor(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
static inline Term
|
||||
AtomTermAdjust(Term t)
|
||||
{
|
||||
static inline Term AtomTermAdjust(Term t) {
|
||||
LookupAtom(AtomOfTerm(t));
|
||||
return t;
|
||||
return t;
|
||||
}
|
||||
|
||||
static inline Term
|
||||
TermToGlobalOrAtomAdjust(Term t)
|
||||
{
|
||||
static inline Term TermToGlobalOrAtomAdjust(Term t) {
|
||||
if (t && IsAtomTerm(t))
|
||||
return AtomTermAdjust(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
#define IsOldCode(P) FALSE
|
||||
#define IsOldCodeCellPtr(P) FALSE
|
||||
#define IsOldDelay(P) FALSE
|
||||
|
@ -405,44 +396,38 @@ TermToGlobalOrAtomAdjust(Term t)
|
|||
|
||||
#define CharP(X) ((char *)(X))
|
||||
|
||||
#define REINIT_LOCK(P)
|
||||
#define REINIT_RWLOCK(P)
|
||||
#define REINIT_LOCK(P)
|
||||
#define REINIT_RWLOCK(P)
|
||||
#define BlobTypeAdjust(P) (P)
|
||||
#define NoAGCAtomAdjust(P) (P)
|
||||
#define OrArgAdjust(P)
|
||||
#define TabEntryAdjust(P)
|
||||
#define IntegerAdjust(D) (D)
|
||||
#define OrArgAdjust(P)
|
||||
#define TabEntryAdjust(P)
|
||||
#define IntegerAdjust(D) (D)
|
||||
#define AddrAdjust(P) (P)
|
||||
#define MFileAdjust(P) (P)
|
||||
#define CodeVarAdjust(P) (P)
|
||||
#define ConstantAdjust(P) (P)
|
||||
#define ArityAdjust(P) (P)
|
||||
#define DoubleInCodeAdjust(P)
|
||||
#define IntegerInCodeAdjust(P)
|
||||
#define DoubleInCodeAdjust(P)
|
||||
#define IntegerInCodeAdjust(P)
|
||||
#define OpcodeAdjust(P) (P)
|
||||
|
||||
static inline Term
|
||||
ModuleAdjust(Term t)
|
||||
{
|
||||
if (!t) return t;
|
||||
static inline Term ModuleAdjust(Term t) {
|
||||
if (!t)
|
||||
return t;
|
||||
return AtomTermAdjust(t);
|
||||
}
|
||||
|
||||
static inline PredEntry *
|
||||
PredEntryAdjust(PredEntry *pe)
|
||||
{
|
||||
static inline PredEntry *PredEntryAdjust(PredEntry *pe) {
|
||||
LookupPredEntry(pe);
|
||||
return pe;
|
||||
}
|
||||
|
||||
static inline PredEntry *
|
||||
PtoPredAdjust(PredEntry *pe)
|
||||
{
|
||||
static inline PredEntry *PtoPredAdjust(PredEntry *pe) {
|
||||
LookupPredEntry(pe);
|
||||
return pe;
|
||||
}
|
||||
|
||||
|
||||
#define ExternalFunctionAdjust(P) (P)
|
||||
#define DBRecordAdjust(P) (P)
|
||||
#define ModEntryPtrAdjust(P) (P)
|
||||
|
@ -459,10 +444,8 @@ PtoPredAdjust(PredEntry *pe)
|
|||
#define DelayAdjust(P) (P)
|
||||
#define GlobalAdjust(P) (P)
|
||||
|
||||
#define DBRefAdjust(P,DoRef) DBRefAdjust__(P PASS_REGS)
|
||||
static inline DBRef
|
||||
DBRefAdjust__ (DBRef dbt USES_REGS)
|
||||
{
|
||||
#define DBRefAdjust(P, DoRef) DBRefAdjust__(P PASS_REGS)
|
||||
static inline DBRef DBRefAdjust__(DBRef dbt USES_REGS) {
|
||||
LookupDBRef(dbt);
|
||||
return dbt;
|
||||
}
|
||||
|
@ -505,68 +488,48 @@ DBRefAdjust__ (DBRef dbt USES_REGS)
|
|||
|
||||
#define rehash(oldcode, NOfE, KindOfEntries)
|
||||
|
||||
#define RestoreSWIHash()
|
||||
|
||||
static void RestoreFlags( UInt NFlags )
|
||||
{
|
||||
}
|
||||
static void RestoreFlags(UInt NFlags) {}
|
||||
|
||||
#include "rheap.h"
|
||||
|
||||
static void
|
||||
RestoreHashPreds( USES_REGS1 )
|
||||
{
|
||||
}
|
||||
static void RestoreHashPreds(USES_REGS1) {}
|
||||
|
||||
static void RestoreAtomList(Atom atm USES_REGS) {}
|
||||
|
||||
static void
|
||||
RestoreAtomList(Atom atm USES_REGS)
|
||||
{
|
||||
}
|
||||
|
||||
static size_t save_bytes(FILE *stream, void *ptr, size_t sz)
|
||||
{
|
||||
static size_t save_bytes(FILE *stream, void *ptr, size_t sz) {
|
||||
return fwrite(ptr, sz, 1, stream);
|
||||
}
|
||||
|
||||
static size_t save_byte(FILE *stream, int byte)
|
||||
{
|
||||
static size_t save_byte(FILE *stream, int byte) {
|
||||
fputc(byte, stream);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static size_t save_bits16(FILE *stream, BITS16 val)
|
||||
{
|
||||
static size_t save_bits16(FILE *stream, BITS16 val) {
|
||||
BITS16 v = val;
|
||||
return save_bytes(stream, &v, sizeof(BITS16));
|
||||
}
|
||||
|
||||
static size_t save_UInt(FILE *stream, UInt val)
|
||||
{
|
||||
static size_t save_UInt(FILE *stream, UInt val) {
|
||||
UInt v = val;
|
||||
return save_bytes(stream, &v, sizeof(UInt));
|
||||
}
|
||||
|
||||
static size_t save_Int(FILE *stream, Int val)
|
||||
{
|
||||
static size_t save_Int(FILE *stream, Int val) {
|
||||
Int v = val;
|
||||
return save_bytes(stream, &v, sizeof(Int));
|
||||
}
|
||||
|
||||
static size_t save_tag(FILE *stream, qlf_tag_t tag)
|
||||
{
|
||||
static size_t save_tag(FILE *stream, qlf_tag_t tag) {
|
||||
return save_byte(stream, tag);
|
||||
}
|
||||
|
||||
static size_t save_predFlags(FILE *stream, pred_flags_t predFlags)
|
||||
{
|
||||
static size_t save_predFlags(FILE *stream, pred_flags_t predFlags) {
|
||||
pred_flags_t v = predFlags;
|
||||
return save_bytes(stream, &v, sizeof(pred_flags_t));
|
||||
}
|
||||
|
||||
static int
|
||||
SaveHash(FILE *stream)
|
||||
{
|
||||
static int SaveHash(FILE *stream) {
|
||||
CACHE_REGS
|
||||
UInt i;
|
||||
/* first, current opcodes */
|
||||
|
@ -574,31 +537,26 @@ SaveHash(FILE *stream)
|
|||
save_UInt(stream, (UInt)&ARG1);
|
||||
CHECK(save_tag(stream, QLY_START_OPCODES));
|
||||
save_Int(stream, _std_top);
|
||||
for (i= 0; i <= _std_top; i++) {
|
||||
for (i = 0; i <= _std_top; i++) {
|
||||
save_UInt(stream, (UInt)Yap_opcode(i));
|
||||
}
|
||||
CHECK(save_tag(stream, QLY_START_ATOMS));
|
||||
CHECK(save_UInt(stream, LOCAL_ExportAtomHashTableNum));
|
||||
for (i = 0; i < LOCAL_ExportAtomHashTableSize; i++) {
|
||||
export_atom_hash_entry_t *a = LOCAL_ExportAtomHashChain+i;
|
||||
export_atom_hash_entry_t *a = LOCAL_ExportAtomHashChain + i;
|
||||
if (a->val) {
|
||||
Atom at = a->val;
|
||||
CHECK(save_UInt(stream, (UInt)at));
|
||||
if (IsWideAtom(at)) {
|
||||
CHECK(save_tag(stream, QLY_ATOM_WIDE));
|
||||
CHECK(save_UInt(stream, wcslen(RepAtom(at)->WStrOfAE)));
|
||||
CHECK(save_bytes(stream, at->WStrOfAE, (wcslen(at->WStrOfAE)+1)*sizeof(wchar_t)));
|
||||
} else {
|
||||
CHECK(save_tag(stream, QLY_ATOM));
|
||||
CHECK(save_UInt(stream, strlen((char *)RepAtom(at)->StrOfAE)));
|
||||
CHECK(save_bytes(stream, (char *)at->StrOfAE, (strlen((char *)at->StrOfAE)+1)*sizeof(char)));
|
||||
}
|
||||
CHECK(save_tag(stream, QLY_ATOM));
|
||||
CHECK(save_UInt(stream, strlen((char *)RepAtom(at)->StrOfAE)));
|
||||
CHECK(save_bytes(stream, (char *)at->StrOfAE,
|
||||
(strlen((char *)at->StrOfAE) + 1) * sizeof(char)));
|
||||
}
|
||||
}
|
||||
save_tag(stream, QLY_START_FUNCTORS);
|
||||
save_UInt(stream, LOCAL_ExportFunctorHashTableNum);
|
||||
for (i = 0; i < LOCAL_ExportFunctorHashTableSize; i++) {
|
||||
export_functor_hash_entry_t *f = LOCAL_ExportFunctorHashChain+i;
|
||||
export_functor_hash_entry_t *f = LOCAL_ExportFunctorHashChain + i;
|
||||
if (!(f->val))
|
||||
continue;
|
||||
CHECK(save_UInt(stream, (UInt)(f->val)));
|
||||
|
@ -608,7 +566,7 @@ SaveHash(FILE *stream)
|
|||
save_tag(stream, QLY_START_PRED_ENTRIES);
|
||||
save_UInt(stream, LOCAL_ExportPredEntryHashTableNum);
|
||||
for (i = 0; i < LOCAL_ExportPredEntryHashTableSize; i++) {
|
||||
export_pred_entry_hash_entry_t *p = LOCAL_ExportPredEntryHashChain+i;
|
||||
export_pred_entry_hash_entry_t *p = LOCAL_ExportPredEntryHashChain + i;
|
||||
if (!(p->val))
|
||||
continue;
|
||||
CHECK(save_UInt(stream, (UInt)(p->val)));
|
||||
|
@ -619,7 +577,7 @@ SaveHash(FILE *stream)
|
|||
save_tag(stream, QLY_START_DBREFS);
|
||||
save_UInt(stream, LOCAL_ExportDBRefHashTableNum);
|
||||
for (i = 0; i < LOCAL_ExportDBRefHashTableSize; i++) {
|
||||
export_dbref_hash_entry_t *p = LOCAL_ExportDBRefHashChain+i;
|
||||
export_dbref_hash_entry_t *p = LOCAL_ExportDBRefHashChain + i;
|
||||
if (p->val) {
|
||||
CHECK(save_UInt(stream, (UInt)(p->val)));
|
||||
CHECK(save_UInt(stream, p->sz));
|
||||
|
@ -631,9 +589,8 @@ SaveHash(FILE *stream)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static size_t
|
||||
save_clauses(FILE *stream, PredEntry *pp) {
|
||||
yamop *FirstC, *LastC;
|
||||
static size_t save_clauses(FILE *stream, PredEntry *pp) {
|
||||
yamop *FirstC, *LastC;
|
||||
|
||||
FirstC = pp->cs.p_code.FirstClause;
|
||||
LastC = pp->cs.p_code.LastClause;
|
||||
|
@ -645,11 +602,11 @@ save_clauses(FILE *stream, PredEntry *pp) {
|
|||
|
||||
while (cl != NULL) {
|
||||
if (IN_BETWEEN(cl->ClTimeStart, pp->TimeStampOfPred, cl->ClTimeEnd)) {
|
||||
UInt size = cl->ClSize;
|
||||
CHECK(save_tag(stream, QLY_START_LU_CLAUSE));
|
||||
CHECK(save_UInt(stream, (UInt)cl));
|
||||
CHECK(save_UInt(stream, size));
|
||||
CHECK(save_bytes(stream, cl, size));
|
||||
UInt size = cl->ClSize;
|
||||
CHECK(save_tag(stream, QLY_START_LU_CLAUSE));
|
||||
CHECK(save_UInt(stream, (UInt)cl));
|
||||
CHECK(save_UInt(stream, size));
|
||||
CHECK(save_bytes(stream, cl, size));
|
||||
}
|
||||
cl = cl->ClNext;
|
||||
}
|
||||
|
@ -672,7 +629,8 @@ save_clauses(FILE *stream, PredEntry *pp) {
|
|||
CHECK(save_UInt(stream, (UInt)cl));
|
||||
CHECK(save_UInt(stream, size));
|
||||
CHECK(save_bytes(stream, dcl, size));
|
||||
if (cl == LastC) return 1;
|
||||
if (cl == LastC)
|
||||
return 1;
|
||||
cl = NextDynamicClause(cl);
|
||||
} while (TRUE);
|
||||
} else {
|
||||
|
@ -687,15 +645,15 @@ save_clauses(FILE *stream, PredEntry *pp) {
|
|||
CHECK(save_UInt(stream, (UInt)cl));
|
||||
CHECK(save_UInt(stream, size));
|
||||
CHECK(save_bytes(stream, cl, size));
|
||||
if (cl->ClCode == LastC) return 1;
|
||||
if (cl->ClCode == LastC)
|
||||
return 1;
|
||||
cl = cl->ClNext;
|
||||
} while (TRUE);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static size_t
|
||||
save_pred(FILE *stream, PredEntry *ap) {
|
||||
static size_t save_pred(FILE *stream, PredEntry *ap) {
|
||||
CHECK(save_UInt(stream, (UInt)ap));
|
||||
CHECK(save_predFlags(stream, ap->PredFlags));
|
||||
if (ap->PredFlags & ForeignPredFlags)
|
||||
|
@ -706,19 +664,17 @@ save_pred(FILE *stream, PredEntry *ap) {
|
|||
return save_clauses(stream, ap);
|
||||
}
|
||||
|
||||
static int
|
||||
clean_pred(PredEntry *pp USES_REGS) {
|
||||
static int clean_pred(PredEntry *pp USES_REGS) {
|
||||
if (pp->PredFlags & ForeignPredFlags) {
|
||||
return true;
|
||||
} else {
|
||||
CleanClauses(pp->cs.p_code.FirstClause, pp->cs.p_code.LastClause, pp PASS_REGS);
|
||||
CleanClauses(pp->cs.p_code.FirstClause, pp->cs.p_code.LastClause,
|
||||
pp PASS_REGS);
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static size_t
|
||||
mark_pred(PredEntry *ap)
|
||||
{
|
||||
static size_t mark_pred(PredEntry *ap) {
|
||||
CACHE_REGS
|
||||
if (ap->ModuleOfPred != IDB_MODULE) {
|
||||
if (ap->ArityOfPE) {
|
||||
|
@ -733,7 +689,7 @@ mark_pred(PredEntry *ap)
|
|||
FuncAdjust(ap->FunctorOfPred);
|
||||
}
|
||||
}
|
||||
if (!(ap->PredFlags & (MultiFileFlag|NumberDBPredFlag)) &&
|
||||
if (!(ap->PredFlags & (MultiFileFlag | NumberDBPredFlag)) &&
|
||||
ap->src.OwnerFile) {
|
||||
AtomAdjust(ap->src.OwnerFile);
|
||||
}
|
||||
|
@ -741,22 +697,20 @@ mark_pred(PredEntry *ap)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static size_t
|
||||
mark_ops(FILE *stream, Term mod) {
|
||||
static size_t mark_ops(FILE *stream, Term mod) {
|
||||
OpEntry *op = OpList;
|
||||
while (op) {
|
||||
if (!mod || op->OpModule == mod) {
|
||||
AtomAdjust(op->OpName);
|
||||
if (op->OpModule)
|
||||
AtomTermAdjust(op->OpModule);
|
||||
AtomTermAdjust(op->OpModule);
|
||||
}
|
||||
op = op->OpNext;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static size_t
|
||||
save_ops(FILE *stream, Term mod) {
|
||||
static size_t save_ops(FILE *stream, Term mod) {
|
||||
OpEntry *op = OpList;
|
||||
while (op) {
|
||||
if (!mod || op->OpModule == mod) {
|
||||
|
@ -773,19 +727,20 @@ save_ops(FILE *stream, Term mod) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
save_header(FILE *stream, char type[])
|
||||
{
|
||||
char msg[256];
|
||||
static size_t save_header(FILE *stream, char type[]) {
|
||||
char msg[2048];
|
||||
|
||||
sprintf(msg, "#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 \"$@\"\n%s %s\n", YAP_BINDIR, type, YAP_FULL_VERSION);
|
||||
return save_bytes(stream, msg, strlen(msg)+1);
|
||||
memset(msg, 0, 2048);
|
||||
sprintf(msg,
|
||||
"#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 "
|
||||
"\"$@\"\n%s %s\n",
|
||||
YAP_BINDIR, type, YAP_FULL_VERSION);
|
||||
return save_bytes(stream, msg, 2048);
|
||||
}
|
||||
|
||||
static size_t
|
||||
save_module(FILE *stream, Term mod) {
|
||||
static size_t save_module(FILE *stream, Term mod) {
|
||||
PredEntry *ap = Yap_ModulePred(mod);
|
||||
save_header( stream, "saved module," );
|
||||
save_header(stream, "saved module,");
|
||||
InitHash();
|
||||
ModuleAdjust(mod);
|
||||
while (ap) {
|
||||
|
@ -811,12 +766,11 @@ save_module(FILE *stream, Term mod) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static size_t
|
||||
save_program(FILE *stream) {
|
||||
static size_t save_program(FILE *stream) {
|
||||
ModEntry *me = CurrentModules;
|
||||
|
||||
InitHash();
|
||||
save_header( stream, "saved state," );
|
||||
save_header(stream, "saved state,");
|
||||
/* should we allow the user to see hidden predicates? */
|
||||
while (me) {
|
||||
PredEntry *pp;
|
||||
|
@ -824,7 +778,7 @@ save_program(FILE *stream) {
|
|||
AtomAdjust(me->AtomOfME);
|
||||
while (pp != NULL) {
|
||||
#if DEBUG
|
||||
// Yap_PrintPredName( pp );
|
||||
// Yap_PrintPredName( pp );
|
||||
#endif
|
||||
pp = PredEntryAdjust(pp);
|
||||
CHECK(mark_pred(pp));
|
||||
|
@ -856,12 +810,11 @@ save_program(FILE *stream) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static size_t
|
||||
save_file(FILE *stream, Atom FileName) {
|
||||
static size_t save_file(FILE *stream, Atom FileName) {
|
||||
ModEntry *me = CurrentModules;
|
||||
|
||||
InitHash();
|
||||
save_header( stream, "saved file," );
|
||||
save_header(stream, "saved file,");
|
||||
/* should we allow the user to see hidden predicates? */
|
||||
while (me) {
|
||||
PredEntry *pp;
|
||||
|
@ -870,10 +823,10 @@ save_file(FILE *stream, Atom FileName) {
|
|||
while (pp != NULL) {
|
||||
pp = PredEntryAdjust(pp);
|
||||
if (pp &&
|
||||
!(pp->PredFlags & (MultiFileFlag|NumberDBPredFlag|AtomDBPredFlag|CPredFlag|AsmPredFlag|UserCPredFlag)) &&
|
||||
pp->ModuleOfPred != IDB_MODULE &&
|
||||
pp->src.OwnerFile == FileName) {
|
||||
CHECK(mark_pred(pp));
|
||||
!(pp->PredFlags & (MultiFileFlag | NumberDBPredFlag | AtomDBPredFlag |
|
||||
CPredFlag | AsmPredFlag | UserCPredFlag)) &&
|
||||
pp->ModuleOfPred != IDB_MODULE && pp->src.OwnerFile == FileName) {
|
||||
CHECK(mark_pred(pp));
|
||||
}
|
||||
pp = pp->NextPredOfModule;
|
||||
}
|
||||
|
@ -891,10 +844,11 @@ save_file(FILE *stream, Atom FileName) {
|
|||
CHECK(save_UInt(stream, (UInt)MkAtomTerm(me->AtomOfME)));
|
||||
while (pp != NULL) {
|
||||
if (pp &&
|
||||
!(pp->PredFlags & (MultiFileFlag|NumberDBPredFlag|AtomDBPredFlag|CPredFlag|AsmPredFlag|UserCPredFlag)) &&
|
||||
pp->src.OwnerFile == FileName) {
|
||||
CHECK(save_tag(stream, QLY_START_PREDICATE));
|
||||
CHECK(save_pred(stream, pp));
|
||||
!(pp->PredFlags & (MultiFileFlag | NumberDBPredFlag | AtomDBPredFlag |
|
||||
CPredFlag | AsmPredFlag | UserCPredFlag)) &&
|
||||
pp->src.OwnerFile == FileName) {
|
||||
CHECK(save_tag(stream, QLY_START_PREDICATE));
|
||||
CHECK(save_pred(stream, pp));
|
||||
}
|
||||
pp = pp->NextPredOfModule;
|
||||
}
|
||||
|
@ -907,75 +861,72 @@ save_file(FILE *stream, Atom FileName) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static Int
|
||||
qsave_module_preds( USES_REGS1 )
|
||||
{
|
||||
static Int qsave_module_preds(USES_REGS1) {
|
||||
FILE *stream;
|
||||
Term tmod = Deref(ARG2);
|
||||
Term t1 = Deref(ARG1);
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"save_module/3");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "save_module/3");
|
||||
return FALSE;
|
||||
}
|
||||
if (!IsAtomTerm(t1)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM,t1,"save_module/3");
|
||||
return(FALSE);
|
||||
Yap_Error(TYPE_ERROR_ATOM, t1, "save_module/3");
|
||||
return (FALSE);
|
||||
}
|
||||
if (!(stream = Yap_GetOutputStream(t1, "save_module") )){
|
||||
if (!(stream = Yap_GetOutputStream(t1, "save_module"))) {
|
||||
return FALSE;
|
||||
}
|
||||
if (IsVarTerm(tmod)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,tmod,"save_module/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, tmod, "save_module/2");
|
||||
return FALSE;
|
||||
}
|
||||
if (!IsAtomTerm(tmod)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM,tmod,"save_module/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM, tmod, "save_module/2");
|
||||
return FALSE;
|
||||
}
|
||||
return save_module(stream, tmod) != 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
qsave_program( USES_REGS1 )
|
||||
{
|
||||
static Int qsave_program(USES_REGS1) {
|
||||
FILE *stream;
|
||||
Term t1 = Deref(ARG1);
|
||||
|
||||
if (!(stream = Yap_GetOutputStream(t1,"save_program")) ) {
|
||||
if (!(stream = Yap_GetOutputStream(t1, "save_program"))) {
|
||||
return FALSE;
|
||||
}
|
||||
return save_program(stream) != 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
qsave_file( USES_REGS1 )
|
||||
{
|
||||
static Int qsave_file(USES_REGS1) {
|
||||
FILE *stream;
|
||||
Term t1 = Deref(ARG1);
|
||||
Term tfile = Deref(ARG2);
|
||||
|
||||
if (!(stream = Yap_GetOutputStream(t1, "save_file/2") ) ) {
|
||||
if (!(stream = Yap_GetOutputStream(t1, "save_file/2"))) {
|
||||
return FALSE;
|
||||
}
|
||||
if (IsVarTerm(tfile)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,tfile,"save_file/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, tfile, "save_file/2");
|
||||
return FALSE;
|
||||
}
|
||||
if (!IsAtomTerm(tfile)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM,tfile,"save_file/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM, tfile, "save_file/2");
|
||||
return FALSE;
|
||||
}
|
||||
return save_file(stream, AtomOfTerm(tfile) ) != 0;
|
||||
return save_file(stream, AtomOfTerm(tfile)) != 0;
|
||||
}
|
||||
|
||||
void Yap_InitQLY(void)
|
||||
{
|
||||
Yap_InitCPred("$qsave_module_preds", 2, qsave_module_preds, SyncPredFlag|UserCPredFlag);
|
||||
Yap_InitCPred("$qsave_program", 1, qsave_program, SyncPredFlag|UserCPredFlag);
|
||||
Yap_InitCPred("$qsave_file_preds", 2, qsave_file, SyncPredFlag|UserCPredFlag);
|
||||
void Yap_InitQLY(void) {
|
||||
Yap_InitCPred("$qsave_module_preds", 2, qsave_module_preds,
|
||||
SyncPredFlag | UserCPredFlag);
|
||||
Yap_InitCPred("$qsave_program", 1, qsave_program,
|
||||
SyncPredFlag | UserCPredFlag);
|
||||
Yap_InitCPred("$qsave_file_preds", 2, qsave_file,
|
||||
SyncPredFlag | UserCPredFlag);
|
||||
if (FALSE) {
|
||||
restore_codes();
|
||||
}
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -21,7 +21,7 @@ static char SccsId[] = "%W% %G%";
|
|||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
|
||||
static Int
|
||||
p_in_range( USES_REGS1 ) {
|
||||
|
|
1259
C/scanner.c
1259
C/scanner.c
File diff suppressed because it is too large
Load Diff
43
C/signals.c
43
C/signals.c
|
@ -25,18 +25,18 @@ static char SccsId[] = "%W% %G%";
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
#if _WIN32
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include "Yatom.h"
|
||||
#include "YapEval.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "Yatom.h"
|
||||
#include "yapio.h"
|
||||
#ifdef TABLING
|
||||
#include "tab.macros.h"
|
||||
#endif /* TABLING */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
@ -63,7 +63,10 @@ static yap_signals InteractSIGINT(int ch) {
|
|||
#endif
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
/* abort computation */
|
||||
/* abort computation */
|
||||
#if PUSH_REGS
|
||||
// restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
return YAP_ABORT_SIGNAL;
|
||||
case 'b':
|
||||
/* continue */
|
||||
|
@ -107,9 +110,11 @@ static yap_signals InteractSIGINT(int ch) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
This function talks to the user about a signal. We assume we are in
|
||||
the context of the main Prolog thread (trivial in Unix, but hard in WIN32)
|
||||
/**
|
||||
This function interacts with the user about a signal. We assume we are in
|
||||
the context of the main Prolog thread (trivial in Unix, but hard in WIN32).
|
||||
|
||||
|
||||
*/
|
||||
static yap_signals ProcessSIGINT(void) {
|
||||
CACHE_REGS
|
||||
|
@ -183,20 +188,32 @@ inline static bool get_signal(yap_signals sig USES_REGS) {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool Yap_DisableInterrupts(int wid) {
|
||||
LOCAL_InterruptsDisabled = true;
|
||||
YAPEnterCriticalSection();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Yap_EnableInterrupts(int wid) {
|
||||
LOCAL_InterruptsDisabled = false;
|
||||
YAPLeaveCriticalSection();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Function called to handle delayed interrupts.
|
||||
*/
|
||||
int Yap_HandleInterrupts(void) {
|
||||
bool Yap_HandleSIGINT(void) {
|
||||
CACHE_REGS
|
||||
yap_signals sig;
|
||||
|
||||
if (get_signal(YAP_INT_SIGNAL PASS_REGS)) {
|
||||
do {
|
||||
if ((sig = ProcessSIGINT()) != YAP_NO_SIGNAL)
|
||||
do_signal(worker_id, sig PASS_REGS);
|
||||
LOCAL_PrologMode &= ~InterruptMode;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
} while (get_signal(YAP_INT_SIGNAL PASS_REGS));
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int p_creep(USES_REGS1) {
|
||||
|
|
2
C/sort.c
2
C/sort.c
|
@ -59,7 +59,7 @@ build_new_list(CELL *pt, Term t USES_REGS)
|
|||
pt += 2;
|
||||
if (pt > ASP - 4096) {
|
||||
if (!Yap_gcl((ASP-HR)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
Yap_ThrowError(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
* @brief Get to know what is in your stack.
|
||||
*
|
||||
*
|
||||
*/
|
||||
` */
|
||||
|
||||
#include "Yap.h"
|
||||
#include "clause.h"
|
||||
#include "yapio.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
#include "tracer.h"
|
||||
#ifdef YAPOR
|
||||
#include "or.macros.h"
|
||||
|
|
426
C/stdpreds.c
426
C/stdpreds.c
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
|
@ -13,255 +12,7 @@
|
|||
* comments: General-purpose C implemented system predicates *
|
||||
* *
|
||||
* Last rev: $Date: 2008-07-24 16:02:00 $,$Author: vsc $
|
||||
**
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.131 2008/06/12 10:55:52 vsc
|
||||
* fix syntax error messages
|
||||
*
|
||||
* Revision 1.130 2008/04/06 11:53:02 vsc
|
||||
* fix some restore bugs
|
||||
*
|
||||
* Revision 1.129 2008/03/15 12:19:33 vsc
|
||||
* fix flags
|
||||
*
|
||||
* Revision 1.128 2008/02/15 12:41:33 vsc
|
||||
* more fixes to modules
|
||||
*
|
||||
* Revision 1.127 2008/02/13 10:15:35 vsc
|
||||
* fix some bugs from yesterday plus improve support for modules in
|
||||
* operators.
|
||||
*
|
||||
* Revision 1.126 2008/02/07 23:09:13 vsc
|
||||
* don't break ISO standard in current_predicate/1.
|
||||
* Include Nicos flag.
|
||||
*
|
||||
* Revision 1.125 2008/01/23 17:57:53 vsc
|
||||
* valgrind it!
|
||||
* enable atom garbage collection.
|
||||
*
|
||||
* Revision 1.124 2007/11/26 23:43:08 vsc
|
||||
* fixes to support threads and assert correctly, even if inefficiently.
|
||||
*
|
||||
* Revision 1.123 2007/11/06 17:02:12 vsc
|
||||
* compile ground terms away.
|
||||
*
|
||||
* Revision 1.122 2007/10/18 08:24:16 vsc
|
||||
* fix global variables
|
||||
*
|
||||
* Revision 1.121 2007/10/10 09:44:24 vsc
|
||||
* some more fixes to make YAP swi compatible
|
||||
* fix absolute_file_name (again)
|
||||
* fix setarg
|
||||
*
|
||||
* Revision 1.120 2007/10/08 23:02:15 vsc
|
||||
* minor fixes
|
||||
*
|
||||
* Revision 1.119 2007/04/18 23:01:16 vsc
|
||||
* fix deadlock when trying to create a module with the same name as a
|
||||
* predicate (for now, just don't lock modules). obs Paulo Moura.
|
||||
*
|
||||
* Revision 1.118 2007/02/26 10:41:40 vsc
|
||||
* fix prolog_flags for chr.
|
||||
*
|
||||
* Revision 1.117 2007/01/28 14:26:37 vsc
|
||||
* WIN32 support
|
||||
*
|
||||
* Revision 1.116 2006/12/13 16:10:23 vsc
|
||||
* several debugger and CLP(BN) improvements.
|
||||
*
|
||||
* Revision 1.115 2006/11/28 13:46:41 vsc
|
||||
* fix wide_char support for name/2.
|
||||
*
|
||||
* Revision 1.114 2006/11/27 17:42:03 vsc
|
||||
* support for UNICODE, and other bug fixes.
|
||||
*
|
||||
* Revision 1.113 2006/11/16 14:26:00 vsc
|
||||
* fix handling of infinity in name/2 and friends.
|
||||
*
|
||||
* Revision 1.112 2006/11/08 01:56:47 vsc
|
||||
* fix argument order in db statistics.
|
||||
*
|
||||
* Revision 1.111 2006/11/06 18:35:04 vsc
|
||||
* 1estranha
|
||||
*
|
||||
* Revision 1.110 2006/10/10 14:08:17 vsc
|
||||
* small fixes on threaded implementation.
|
||||
*
|
||||
* Revision 1.109 2006/09/15 19:32:47 vsc
|
||||
* ichanges for QSAR
|
||||
*
|
||||
* Revision 1.108 2006/09/01 20:14:42 vsc
|
||||
* more fixes for global data-structures.
|
||||
* statistics on atom space.
|
||||
*
|
||||
* Revision 1.107 2006/08/22 16:12:46 vsc
|
||||
* global variables
|
||||
*
|
||||
* Revision 1.106 2006/08/07 18:51:44 vsc
|
||||
* fix garbage collector not to try to garbage collect when we ask for large
|
||||
* chunks of stack in a single go.
|
||||
*
|
||||
* Revision 1.105 2006/06/05 19:36:00 vsc
|
||||
* hacks
|
||||
*
|
||||
* Revision 1.104 2006/05/19 14:31:32 vsc
|
||||
* get rid of IntArrays and FloatArray code.
|
||||
* include holes when calculating memory usage.
|
||||
*
|
||||
* Revision 1.103 2006/05/18 16:33:05 vsc
|
||||
* fix info reported by memory manager under DL_MALLOC and SYSTEM_MALLOC
|
||||
*
|
||||
* Revision 1.102 2006/04/28 17:53:44 vsc
|
||||
* fix the expand_consult patch
|
||||
*
|
||||
* Revision 1.101 2006/04/28 13:23:23 vsc
|
||||
* fix number of overflow bugs affecting threaded version
|
||||
* make current_op faster.
|
||||
*
|
||||
* Revision 1.100 2006/02/05 02:26:35 tiagosoares
|
||||
* MYDDAS: Top Level Functionality
|
||||
*
|
||||
* Revision 1.99 2006/02/05 02:17:54 tiagosoares
|
||||
* MYDDAS: Top Level Functionality
|
||||
*
|
||||
* Revision 1.98 2005/12/17 03:25:39 vsc
|
||||
* major changes to support online event-based profiling
|
||||
* improve error discovery and restart on scanner.
|
||||
*
|
||||
* Revision 1.97 2005/11/22 11:25:59 tiagosoares
|
||||
* support for the MyDDAS interface library
|
||||
*
|
||||
* Revision 1.96 2005/10/28 17:38:49 vsc
|
||||
* sveral updates
|
||||
*
|
||||
* Revision 1.95 2005/10/21 16:09:02 vsc
|
||||
* SWI compatible module only operators
|
||||
*
|
||||
* Revision 1.94 2005/09/08 22:06:45 rslopes
|
||||
* BEAM for YAP update...
|
||||
*
|
||||
* Revision 1.93 2005/08/04 15:45:53 ricroc
|
||||
* TABLING NEW: support to limit the table space size
|
||||
*
|
||||
* Revision 1.92 2005/07/20 13:54:27 rslopes
|
||||
* solved warning: cast from pointer to integer of different size
|
||||
*
|
||||
* Revision 1.91 2005/07/06 19:33:54 ricroc
|
||||
* TABLING: answers for completed calls can now be obtained by loading (new
|
||||
*option) or executing (default) them from the trie data structure.
|
||||
*
|
||||
* Revision 1.90 2005/07/06 15:10:14 vsc
|
||||
* improvements to compiler: merged instructions and fixes for ->
|
||||
*
|
||||
* Revision 1.89 2005/05/26 18:01:11 rslopes
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.88 2005/04/27 20:09:25 vsc
|
||||
* indexing code could get confused with suspension points
|
||||
* some further improvements on oveflow handling
|
||||
* fix paths in Java makefile
|
||||
* changs to support gibbs sampling in CLP(BN)
|
||||
*
|
||||
* Revision 1.87 2005/04/07 17:48:55 ricroc
|
||||
* Adding tabling support for mixed strategy evaluation (batched and local
|
||||
*scheduling)
|
||||
* UPDATE: compilation flags -DTABLING_BATCHED_SCHEDULING and
|
||||
*-DTABLING_LOCAL_SCHEDULING removed. To support tabling use -DTABLING in the
|
||||
*Makefile or --enable-tabling in configure.
|
||||
* NEW: yap_flag(tabling_mode,MODE) changes the tabling execution mode of all
|
||||
*tabled predicates to MODE (batched, local or default).
|
||||
* NEW: tabling_mode(PRED,MODE) changes the default tabling execution mode of
|
||||
*predicate PRED to MODE (batched or local).
|
||||
*
|
||||
* Revision 1.86 2005/03/13 06:26:11 vsc
|
||||
* fix excessive pruning in meta-calls
|
||||
* fix Term->int breakage in compiler
|
||||
* improve JPL (at least it does something now for amd64).
|
||||
*
|
||||
* Revision 1.85 2005/03/02 19:48:02 vsc
|
||||
* Fix some possible errors in name/2 and friends, and cleanup code a bit
|
||||
* YAP_Error changed.
|
||||
*
|
||||
* Revision 1.84 2005/03/02 18:35:46 vsc
|
||||
* try to make initialization process more robust
|
||||
* try to make name more robust (in case Lookup new atom fails)
|
||||
*
|
||||
* Revision 1.83 2005/03/01 22:25:09 vsc
|
||||
* fix pruning bug
|
||||
* make DL_MALLOC less enthusiastic about walking through buckets.
|
||||
*
|
||||
* Revision 1.82 2005/02/21 16:50:04 vsc
|
||||
* amd64 fixes
|
||||
* library fixes
|
||||
*
|
||||
* Revision 1.81 2005/02/08 04:05:35 vsc
|
||||
* fix mess with add clause
|
||||
* improves on sigsegv handling
|
||||
*
|
||||
* Revision 1.80 2005/01/05 05:32:37 vsc
|
||||
* Ricardo's latest version of profiler.
|
||||
*
|
||||
* Revision 1.79 2004/12/28 22:20:36 vsc
|
||||
* some extra bug fixes for trail overflows: some cannot be recovered that
|
||||
*easily,
|
||||
* some can.
|
||||
*
|
||||
* Revision 1.78 2004/12/08 04:45:03 vsc
|
||||
* polish changes to undefp
|
||||
* get rid of a few warnings
|
||||
*
|
||||
* Revision 1.77 2004/12/05 05:07:26 vsc
|
||||
* name/2 should accept [] as a valid list (string)
|
||||
*
|
||||
* Revision 1.76 2004/12/05 05:01:25 vsc
|
||||
* try to reduce overheads when running with goal expansion enabled.
|
||||
* CLPBN fixes
|
||||
* Handle overflows when allocating big clauses properly.
|
||||
*
|
||||
* Revision 1.75 2004/12/02 06:06:46 vsc
|
||||
* fix threads so that they at least start
|
||||
* allow error handling to work with threads
|
||||
* replace heap_base by Yap_heap_base, according to Yap's convention for globals.
|
||||
*
|
||||
* Revision 1.74 2004/11/19 22:08:43 vsc
|
||||
* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever
|
||||
*appropriate.
|
||||
*
|
||||
* Revision 1.73 2004/11/19 17:14:14 vsc
|
||||
* a few fixes for 64 bit compiling.
|
||||
*
|
||||
* Revision 1.72 2004/11/18 22:32:37 vsc
|
||||
* fix situation where we might assume nonextsing double initialization of C
|
||||
*predicates (use
|
||||
* Hidden Pred Flag).
|
||||
* $host_type was double initialized.
|
||||
*
|
||||
* Revision 1.71 2004/07/23 21:08:44 vsc
|
||||
* windows fixes
|
||||
*
|
||||
* Revision 1.70 2004/06/29 19:04:42 vsc
|
||||
* fix multithreaded version
|
||||
* include new version of Ricardo's profiler
|
||||
* new predicat atomic_concat
|
||||
* allow multithreaded-debugging
|
||||
* small fixes
|
||||
*
|
||||
* Revision 1.69 2004/06/16 14:12:53 vsc
|
||||
* miscellaneous fixes
|
||||
*
|
||||
* Revision 1.68 2004/05/14 17:11:30 vsc
|
||||
* support BigNums in interface
|
||||
*
|
||||
* Revision 1.67 2004/05/14 16:33:45 vsc
|
||||
* add Yap_ReadBuffer
|
||||
*
|
||||
* Revision 1.66 2004/05/13 20:54:58 vsc
|
||||
* debugger fixes
|
||||
* make sure we always go back to current module, even during initizlization.
|
||||
*
|
||||
* Revision 1.65 2004/04/27 15:14:36 vsc
|
||||
* fix halt/0 and halt/1
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
|
@ -283,11 +34,11 @@ static char SccsId[] = "%W% %G%";
|
|||
#if YAP_JIT
|
||||
#include "amijit.h"
|
||||
#endif
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "yapio.h"
|
||||
#include "Foreign.h"
|
||||
#include "YapHeap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapEval.h"
|
||||
#include "yapio.h"
|
||||
#ifdef TABLING
|
||||
#include "tab.macros.h"
|
||||
#endif /* TABLING */
|
||||
|
@ -304,8 +55,11 @@ static char SccsId[] = "%W% %G%";
|
|||
#if YAP_JIT
|
||||
#include <JIT_Compiler.hpp>
|
||||
#endif
|
||||
#include <wchar.h>
|
||||
#include <fcntl.h>
|
||||
#include <wchar.h>
|
||||
|
||||
extern int init_tries(void);
|
||||
|
||||
|
||||
static Int p_setval(USES_REGS1);
|
||||
static Int p_value(USES_REGS1);
|
||||
|
@ -323,7 +77,7 @@ static Int p_halt(USES_REGS1);
|
|||
#endif
|
||||
static Int current_predicate(USES_REGS1);
|
||||
static Int cont_current_predicate(USES_REGS1);
|
||||
static OpEntry *NextOp(OpEntry *CACHE_TYPE);
|
||||
static OpEntry *NextOp(Prop CACHE_TYPE);
|
||||
static Int init_current_op(USES_REGS1);
|
||||
static Int cont_current_op(USES_REGS1);
|
||||
static Int init_current_atom_op(USES_REGS1);
|
||||
|
@ -450,11 +204,11 @@ Int show_time(USES_REGS1) /* MORE PRECISION */
|
|||
}
|
||||
|
||||
#endif /* BEAM */
|
||||
// @{
|
||||
|
||||
/**
|
||||
@defgroup YAPSetVal
|
||||
@defgroup YAPSetVal Atom to Atomic Family of Built-ins.
|
||||
@ingroup Internal_Database
|
||||
@{
|
||||
|
||||
Maintain a light-weight map where the key is an atom, and the value can be
|
||||
any constant.
|
||||
|
@ -530,7 +284,7 @@ static Int p_values(USES_REGS1) { /* '$values'(Atom,Old,New) */
|
|||
return (TRUE);
|
||||
}
|
||||
|
||||
//@}
|
||||
///@}
|
||||
|
||||
static Int p_opdec(USES_REGS1) { /* '$opdec'(p,type,atom) */
|
||||
/* we know the arguments are integer, atom, atom */
|
||||
|
@ -633,10 +387,12 @@ static Int p_systime(USES_REGS1) {
|
|||
}
|
||||
|
||||
static Int p_walltime(USES_REGS1) {
|
||||
Int now, interval;
|
||||
Yap_walltime_interval(&now, &interval);
|
||||
return (Yap_unify_constant(ARG1, MkIntegerTerm(now)) &&
|
||||
Yap_unify_constant(ARG2, MkIntegerTerm(interval)));
|
||||
uint64_t now, interval;
|
||||
uint64_t t = Yap_walltime();
|
||||
now = t - Yap_StartOfWTimes;
|
||||
interval = t - LOCAL_LastWTime;
|
||||
return (Yap_unify_constant(ARG1, MkIntegerTerm(now / 1000)) &&
|
||||
Yap_unify_constant(ARG2, MkIntegerTerm(interval / 1000)));
|
||||
}
|
||||
|
||||
static Int p_univ(USES_REGS1) { /* A =.. L */
|
||||
|
@ -878,15 +634,15 @@ static Int
|
|||
}
|
||||
|
||||
static bool valid_prop(Prop p, Term task) {
|
||||
if ((RepPredProp(p)->PredFlags & HiddenPredFlag) ||
|
||||
(RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE) ){
|
||||
PredEntry *pe = RepPredProp(p);
|
||||
if ((pe->PredFlags & HiddenPredFlag) || (pe->OpcodeOfPred == UNDEF_OPCODE)) {
|
||||
return false;
|
||||
}
|
||||
if(task == TermSystem || task == TermProlog) {
|
||||
return RepPredProp(p)->PredFlags & StandardPredFlag;
|
||||
if (task == TermSystem || task == TermProlog) {
|
||||
return pe->PredFlags & StandardPredFlag;
|
||||
}
|
||||
if(task == TermUser) {
|
||||
return !(RepPredProp(p)->PredFlags & StandardPredFlag);
|
||||
if (task == TermUser) {
|
||||
return !(pe->PredFlags & StandardPredFlag);
|
||||
}
|
||||
if (IsVarTerm(task)) {
|
||||
return true;
|
||||
|
@ -906,10 +662,8 @@ static PropEntry *followLinkedListOfProps(PropEntry *p, Term task) {
|
|||
}
|
||||
|
||||
static PropEntry *getPredProp(PropEntry *p, Term task) {
|
||||
PredEntry *pe;
|
||||
if (p == NIL)
|
||||
return NIL;
|
||||
pe = RepPredProp(p);
|
||||
while (p != NIL) {
|
||||
if (p->KindOfPE == PEProp && valid_prop(p, task)) {
|
||||
return p;
|
||||
|
@ -931,8 +685,8 @@ static PropEntry *nextPredForAtom(PropEntry *p, Term task) {
|
|||
return NIL;
|
||||
pe = RepPredProp(p);
|
||||
if (pe->ArityOfPE == 0 ||
|
||||
(pe->PredFlags & (NumberDBPredFlag |AtomDBPredFlag) ) ) {
|
||||
// if atom prop, search atom list
|
||||
(pe->PredFlags & (NumberDBPredFlag | AtomDBPredFlag))) {
|
||||
// if atom prop, search atom list
|
||||
return followLinkedListOfProps(p->NextOfPE, task);
|
||||
} else {
|
||||
FunctorEntry *f = pe->FunctorOfPred;
|
||||
|
@ -1008,12 +762,14 @@ static PredEntry *firstModulesPred(PredEntry *npp, ModEntry *m, Term task) {
|
|||
static Int cont_current_predicate(USES_REGS1) {
|
||||
UInt Arity;
|
||||
Term name, task;
|
||||
Term t1 = ARG1, t2 = ARG2, t3 = ARG3;
|
||||
Term t1 = ARG1, t2 = Deref(ARG2), t3 = ARG3;
|
||||
bool rc, will_cut = false;
|
||||
Functor f;
|
||||
PredEntry *pp;
|
||||
t1 = Yap_YapStripModule(t1, &t2);
|
||||
t3 = Yap_YapStripModule(t3, &t2);
|
||||
t1 = Deref(t1);
|
||||
t2 = Deref(t2);
|
||||
task = Deref(ARG4);
|
||||
|
||||
pp = AddressOfTerm(EXTRA_CBACK_ARG(4, 1));
|
||||
|
@ -1022,7 +778,7 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||
|
||||
if (IsNonVarTerm(t2)) {
|
||||
// module and functor known, should be easy
|
||||
if (IsAtomTerm(t2)) {
|
||||
if (IsAtomTerm(t3)) {
|
||||
if ((p = Yap_GetPredPropByAtom(AtomOfTerm(t3), t2)) &&
|
||||
valid_prop(p, task)) {
|
||||
cut_succeed();
|
||||
|
@ -1102,17 +858,23 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||
|
||||
if (!pp) {
|
||||
if (!IsAtomTerm(t2)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t2, "current_predicate/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM, t2, "module name");
|
||||
}
|
||||
ModEntry *m = Yap_GetModuleEntry(t2);
|
||||
pp = firstModulePred(m->PredForME, task);
|
||||
if (!pp)
|
||||
pp = m->PredForME;
|
||||
while (pp && !valid_prop(AbsPredProp(pp), task)) {
|
||||
pp = pp->NextPredOfModule;
|
||||
}
|
||||
if (!pp) {
|
||||
/* try Prolog Module */
|
||||
cut_fail();
|
||||
}
|
||||
}
|
||||
npp = firstModulePred(pp, task);
|
||||
|
||||
if (!npp)
|
||||
if (!npp) {
|
||||
will_cut = true;
|
||||
}
|
||||
// just try next one
|
||||
else {
|
||||
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(npp);
|
||||
|
@ -1122,7 +884,7 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||
// operating across all modules.
|
||||
PredEntry *npp = pp;
|
||||
ModEntry *me;
|
||||
|
||||
|
||||
if (!pp) {
|
||||
pp = firstModulesPred(CurrentModules->PredForME, CurrentModules, task);
|
||||
}
|
||||
|
@ -1164,11 +926,12 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||
}
|
||||
}
|
||||
if (Arity) {
|
||||
rc = Yap_unify(t3, Yap_MkNewApplTerm(f, Arity));
|
||||
rc = Yap_unify(ARG3, Yap_MkNewApplTerm(f, Arity));
|
||||
} else {
|
||||
rc = Yap_unify(t3, name);
|
||||
rc = Yap_unify(ARG3, name);
|
||||
}
|
||||
rc = rc && Yap_unify(t2, ModToTerm(pp->ModuleOfPred)) && Yap_unify(t1, name);
|
||||
rc = rc && (IsAtomTerm(t2) || Yap_unify(ARG2, ModToTerm(pp->ModuleOfPred))) &&
|
||||
Yap_unify(ARG1, name);
|
||||
if (will_cut) {
|
||||
if (rc)
|
||||
cut_succeed();
|
||||
|
@ -1183,22 +946,25 @@ static Int current_predicate(USES_REGS1) {
|
|||
return cont_current_predicate(PASS_REGS1);
|
||||
}
|
||||
|
||||
static OpEntry *NextOp(OpEntry *pp USES_REGS) {
|
||||
while (!EndOfPAEntr(pp) && pp->KindOfPE != OpProperty &&
|
||||
(pp->OpModule != PROLOG_MODULE || pp->OpModule != CurrentModule))
|
||||
pp = RepOpProp(pp->NextOfPE);
|
||||
return (pp);
|
||||
static OpEntry *NextOp(Prop pp USES_REGS) {
|
||||
|
||||
while (!EndOfPAEntr(pp) &&
|
||||
pp->KindOfPE != OpProperty &&
|
||||
(RepOpProp(pp)->OpModule != PROLOG_MODULE || RepOpProp(pp)->OpModule != CurrentModule)
|
||||
)
|
||||
pp = pp->NextOfPE;
|
||||
return RepOpProp(pp);
|
||||
}
|
||||
|
||||
int Yap_IsOp(Atom at) {
|
||||
CACHE_REGS
|
||||
OpEntry *op = NextOp(RepOpProp((Prop)(RepAtom(at)->PropsOfAE)) PASS_REGS);
|
||||
OpEntry *op = NextOp(RepAtom(at)->PropsOfAE PASS_REGS);
|
||||
return (!EndOfPAEntr(op));
|
||||
}
|
||||
|
||||
int Yap_IsOpMaxPrio(Atom at) {
|
||||
CACHE_REGS
|
||||
OpEntry *op = NextOp(RepOpProp((Prop)(RepAtom(at)->PropsOfAE)) PASS_REGS);
|
||||
OpEntry *op = NextOp(RepAtom(at)->PropsOfAE PASS_REGS);
|
||||
int max;
|
||||
|
||||
if (EndOfPAEntr(op))
|
||||
|
@ -1260,7 +1026,7 @@ static Int cont_current_atom_op(USES_REGS1) {
|
|||
OpEntry *op = (OpEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(5, 1)), *next;
|
||||
|
||||
READ_LOCK(op->OpRWLock);
|
||||
next = NextOp(RepOpProp(op->NextOfPE) PASS_REGS);
|
||||
next = NextOp(op->NextOfPE PASS_REGS);
|
||||
if (unify_op(op PASS_REGS)) {
|
||||
READ_UNLOCK(op->OpRWLock);
|
||||
if (next) {
|
||||
|
@ -1293,7 +1059,7 @@ static Int init_current_atom_op(
|
|||
cut_fail();
|
||||
}
|
||||
ae = RepAtom(AtomOfTerm(t));
|
||||
if (EndOfPAEntr((ope = NextOp(RepOpProp(ae->PropsOfAE) PASS_REGS)))) {
|
||||
if (EndOfPAEntr((ope = NextOp(ae->PropsOfAE PASS_REGS)))) {
|
||||
cut_fail();
|
||||
}
|
||||
EXTRA_CBACK_ARG(5, 1) = (CELL)MkIntegerTerm((Int)ope);
|
||||
|
@ -1301,6 +1067,28 @@ static Int init_current_atom_op(
|
|||
return cont_current_atom_op(PASS_REGS1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static Int
|
||||
copy_local_ops(USES_REGS1) { /* current_op(-Precedence,-Type,-Atom) */
|
||||
Term tmodin = Deref(ARG1);
|
||||
Term t = Deref(ARG1);
|
||||
AtomEntry *ae;
|
||||
OpEntry *ope;
|
||||
|
||||
if (IsVarTerm(t) || !IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "current_op/3");
|
||||
cut_fail();
|
||||
}
|
||||
ae = RepAtom(AtomOfTerm(t));
|
||||
if (EndOfPAEntr((ope = NextOp(ae->PropsOfAE PASS_REGS)))) {
|
||||
cut_fail();
|
||||
}
|
||||
EXTRA_CBACK_ARG(5, 1) = (CELL)MkIntegerTerm((Int)ope);
|
||||
B->cp_h = HR;
|
||||
return cont_current_atom_op(PASS_REGS1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Yap_show_statistics(void) {
|
||||
CACHE_REGS
|
||||
unsigned long int heap_space_taken;
|
||||
|
@ -1317,23 +1105,25 @@ void Yap_show_statistics(void) {
|
|||
#endif
|
||||
frag = (100.0 * (heap_space_taken - HeapUsed)) / heap_space_taken;
|
||||
|
||||
fprintf(stderr, "Code Space: %ld (%ld bytes needed, %ld bytes used, "
|
||||
fprintf(stderr, "Code Space: " UInt_FORMAT " (" UInt_FORMAT
|
||||
" bytes needed, " UInt_FORMAT " bytes used, "
|
||||
"fragmentation %.3f%%).\n",
|
||||
(unsigned long int)(Unsigned(H0) - Unsigned(Yap_HeapBase)),
|
||||
(unsigned long int)(Unsigned(HeapTop) - Unsigned(Yap_HeapBase)),
|
||||
(unsigned long int)(HeapUsed), frag);
|
||||
fprintf(stderr, "Stack Space: %ld (%ld for Global, %ld for local).\n",
|
||||
(unsigned long int)(sizeof(CELL) * (LCL0 - H0)),
|
||||
(unsigned long int)(sizeof(CELL) * (HR - H0)),
|
||||
(unsigned long int)(sizeof(CELL) * (LCL0 - ASP)));
|
||||
fprintf(stderr, "Trail Space: %ld (%ld used).\n",
|
||||
(unsigned long int)(sizeof(tr_fr_ptr) * (Unsigned(LOCAL_TrailTop) -
|
||||
Unsigned(LOCAL_TrailBase))),
|
||||
(unsigned long int)(sizeof(tr_fr_ptr) *
|
||||
(Unsigned(TR) - Unsigned(LOCAL_TrailBase))));
|
||||
fprintf(stderr, "Runtime: %lds.\n", (unsigned long int)(runtime(PASS_REGS1)));
|
||||
fprintf(stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime()));
|
||||
fprintf(stderr, "Walltime: %lds.\n", (unsigned long int)(Yap_walltime()));
|
||||
Unsigned(H0) - Unsigned(Yap_HeapBase),
|
||||
Unsigned(HeapTop) - Unsigned(Yap_HeapBase), Unsigned(HeapUsed), frag);
|
||||
fprintf(stderr, "Stack Space: " UInt_FORMAT " (" UInt_FORMAT
|
||||
" for Global, " UInt_FORMAT " for local).\n",
|
||||
Unsigned(sizeof(CELL) * (LCL0 - H0)),
|
||||
Unsigned(sizeof(CELL) * (HR - H0)),
|
||||
Unsigned(sizeof(CELL) * (LCL0 - ASP)));
|
||||
fprintf(
|
||||
stderr, "Trail Space: " UInt_FORMAT " (" UInt_FORMAT " used).\n",
|
||||
Unsigned(sizeof(tr_fr_ptr) *
|
||||
(Unsigned(LOCAL_TrailTop) - Unsigned(LOCAL_TrailBase))),
|
||||
Unsigned(sizeof(tr_fr_ptr) * (Unsigned(TR) - Unsigned(LOCAL_TrailBase))));
|
||||
fprintf(stderr, "Runtime: " UInt_FORMAT "\n", runtime(PASS_REGS1));
|
||||
fprintf(stderr, "Cputime: " UInt_FORMAT "\n", Yap_cputime());
|
||||
|
||||
fprintf(stderr, "Walltime: %" PRIu64 ".\n", Yap_walltime() / (UInt)1000);
|
||||
}
|
||||
|
||||
static Int p_statistics_heap_max(USES_REGS1) {
|
||||
|
@ -1559,12 +1349,17 @@ static Int p_statistics_lu_db_size(USES_REGS1) {
|
|||
}
|
||||
|
||||
static Int p_executable(USES_REGS1) {
|
||||
if (GLOBAL_argv && GLOBAL_argv[0])
|
||||
Yap_TrueFileName(GLOBAL_argv[0], LOCAL_FileNameBuf, FALSE);
|
||||
else
|
||||
strncpy(LOCAL_FileNameBuf, Yap_FindExecutable(), YAP_FILENAME_MAX - 1);
|
||||
int lvl = push_text_stack();
|
||||
const char *tmp =
|
||||
|
||||
return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), ARG1);
|
||||
Yap_AbsoluteFile(GLOBAL_argv[0], true);
|
||||
if (!tmp || tmp[0] == '\0' ) {
|
||||
tmp = Malloc(YAP_FILENAME_MAX + 1);
|
||||
strncpy((char *)tmp, Yap_FindExecutable(), YAP_FILENAME_MAX);
|
||||
}
|
||||
Atom at = Yap_LookupAtom(tmp);
|
||||
pop_text_stack(lvl);
|
||||
return Yap_unify(MkAtomTerm(at), ARG1);
|
||||
}
|
||||
|
||||
static Int p_system_mode(USES_REGS1) {
|
||||
|
@ -1779,11 +1574,12 @@ void Yap_InitCPreds(void) {
|
|||
Yap_InitCmpPreds();
|
||||
Yap_InitCoroutPreds();
|
||||
Yap_InitDBPreds();
|
||||
Yap_InitErrorPreds();
|
||||
Yap_InitExecFs();
|
||||
Yap_InitErrorPreds();
|
||||
Yap_InitGlobals();
|
||||
Yap_InitInlines();
|
||||
Yap_InitIOPreds();
|
||||
Yap_InitDBLoadPreds();
|
||||
Yap_InitExoPreds();
|
||||
Yap_InitLoadForeign();
|
||||
Yap_InitModulesC();
|
||||
|
@ -1797,6 +1593,7 @@ void Yap_InitCPreds(void) {
|
|||
Yap_udi_init();
|
||||
Yap_udi_Interval_init();
|
||||
Yap_InitSignalCPreds();
|
||||
Yap_InitTermCPreds();
|
||||
Yap_InitUserCPreds();
|
||||
Yap_InitUtilCPreds();
|
||||
Yap_InitSortPreds();
|
||||
|
@ -1841,7 +1638,6 @@ void Yap_InitCPreds(void) {
|
|||
#if SUPPORT_CONDOR
|
||||
init_sys();
|
||||
init_random();
|
||||
// init_tries();
|
||||
init_regexp();
|
||||
#endif
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
21
C/threads.c
21
C/threads.c
|
@ -26,11 +26,13 @@ static char SccsId[] = "%W% %G%";
|
|||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
#include "YapEval.h"
|
||||
#include "yapio.h"
|
||||
#include "blobs.h"
|
||||
#include "YapBlobs.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
@ -382,7 +384,7 @@ setup_engine(int myworker_id, int init_thread)
|
|||
// create a mbox
|
||||
mboxCreate( MkIntTerm(myworker_id), &REMOTE_ThreadHandle(myworker_id).mbox_handle PASS_REGS );
|
||||
Yap_InitTime( myworker_id );
|
||||
Yap_InitYaamRegs( myworker_id );
|
||||
Yap_InitYaamRegs( myworker_id, true] );
|
||||
REFRESH_CACHE_REGS
|
||||
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
|
||||
/* I exist */
|
||||
|
@ -1172,9 +1174,9 @@ p_with_mutex( USES_REGS1 )
|
|||
rc = TRUE;
|
||||
}
|
||||
end:
|
||||
excep = Yap_GetException();
|
||||
excep = Yap_GetException(LOCAL_ComiittedError);
|
||||
if ( !UnLockMutex(mut PASS_REGS) ) {
|
||||
return FALSE;
|
||||
return FALSE;c
|
||||
}
|
||||
if (creeping) {
|
||||
Yap_signal( YAP_CREEP_SIGNAL );
|
||||
|
@ -1754,7 +1756,7 @@ p_new_mutex(void)
|
|||
p_with_mutex( USES_REGS1 )
|
||||
{
|
||||
Int mut;
|
||||
Term t1 = Deref(ARG1), excep;
|
||||
Term t1 = Deref(ARG1);
|
||||
Int rc = FALSE;
|
||||
Int creeping = Yap_get_signal(YAP_CREEP_SIGNAL);
|
||||
PredEntry *pe;
|
||||
|
@ -1811,11 +1813,12 @@ p_new_mutex(void)
|
|||
}
|
||||
end:
|
||||
ARG1 = MkIntegerTerm(mut);
|
||||
excep = Yap_GetException();
|
||||
yap_error_descriptor_t *err = Yap_GetException();
|
||||
if (creeping) {
|
||||
Yap_signal( YAP_CREEP_SIGNAL );
|
||||
} else if ( excep != 0) {
|
||||
return Yap_JumpToEnv(excep);
|
||||
} else if ( err ) {
|
||||
LOCAL_ActiveError->errorNo = err->errorNo;
|
||||
return Yap_JumpToEnv();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
271
C/tracer.c
271
C/tracer.c
|
@ -1,67 +1,122 @@
|
|||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog @(#)amidefs.h 1.3 3/15/90
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: tracer.h *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: definitions for low level tracer *
|
||||
* *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog @(#)amidefs.h 1.3 3/15/90
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: tracer.h *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: definitions for low level tracer *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#include "Yap.h"
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "YapText.h"
|
||||
#include "Yatom.h"
|
||||
#include "attvar.h"
|
||||
#include "yapio.h"
|
||||
#include "clause.h"
|
||||
#include "iopreds.h"
|
||||
#include "tracer.h"
|
||||
#include "yapio.h"
|
||||
|
||||
static void send_tracer_message(char *start, char *name, Int arity, char *mname,
|
||||
CELL *args) {
|
||||
if (name == NULL) {
|
||||
#ifdef YAPOR
|
||||
fprintf(stderr, "(%d)%s", worker_id, start);
|
||||
#else
|
||||
fprintf(stderr, "%s", start);
|
||||
#endif
|
||||
} else {
|
||||
int i;
|
||||
static char *send_tracer_message(char *start, char *name, arity_t arity,
|
||||
char *mname, CELL *args, char **s0, char *s,
|
||||
char **top) {
|
||||
bool expand = false;
|
||||
size_t max = *top - (s + 1);
|
||||
int d, min = 1024;
|
||||
char *s1 = s;
|
||||
do {
|
||||
if (expand || max < 32) {
|
||||
Int cbeg = s1 - *s0;
|
||||
max = *top - *s0;
|
||||
max += min;
|
||||
*s0 = Realloc(*s0, max);
|
||||
|
||||
if (arity) {
|
||||
if (args)
|
||||
fprintf(stderr, "%s %s:%s(", start, mname, name);
|
||||
else
|
||||
fprintf(stderr, "%s %s:%s/%lu", start, mname, name,
|
||||
(unsigned long int)arity);
|
||||
} else {
|
||||
fprintf(stderr, "%s %s:%s", start, mname, name);
|
||||
*top = *s0 + max;
|
||||
max--;
|
||||
s1 = *s0 + cbeg;
|
||||
s = s1;
|
||||
expand = false;
|
||||
}
|
||||
min = 1024;
|
||||
if (name == NULL) {
|
||||
#ifdef YAPOR
|
||||
d = snprintf(s, max, "(%d)%s", worker_id, start);
|
||||
#else
|
||||
d = snprintf(s, max, "%s", start);
|
||||
#endif
|
||||
} else {
|
||||
|
||||
if (arity) {
|
||||
if (args)
|
||||
d = snprintf(s, max, "%s %s:%s(", start, mname, name);
|
||||
else
|
||||
d = snprintf(s, max, "%s %s:%s/%lu", start, mname, name,
|
||||
(unsigned long int)arity);
|
||||
} else {
|
||||
d = snprintf(s, max, "%s %s:%s", start, mname, name);
|
||||
}
|
||||
}
|
||||
if (d >= max) {
|
||||
expand = true;
|
||||
min = d + 1024;
|
||||
continue;
|
||||
}
|
||||
max -= d;
|
||||
s += d;
|
||||
if (args) {
|
||||
int i;
|
||||
for (i = 0; i < arity; i++) {
|
||||
if (i > 0)
|
||||
fprintf(stderr, ",");
|
||||
Yap_plwrite(args[i], NULL, 15, Handle_vars_f | AttVar_Portray_f,
|
||||
GLOBAL_MaxPriority);
|
||||
if (i > 0) {
|
||||
if (max > 16) {
|
||||
*s++ = ',';
|
||||
*s++ = ' ';
|
||||
max -= 2;
|
||||
} else {
|
||||
expand = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const char *sn = Yap_TermToBuffer(args[i],
|
||||
Handle_cyclics_f|Quote_illegal_f | Handle_vars_f);
|
||||
size_t sz;
|
||||
if (sn == NULL) {
|
||||
sn = malloc(strlen("<* error *>")+1);
|
||||
strcpy((char*)sn, "<* error *>");
|
||||
}
|
||||
sz = strlen(sn);
|
||||
if (max <= sz) {
|
||||
min = sz + 1024;
|
||||
expand = true;
|
||||
continue;
|
||||
}
|
||||
strcpy(s, sn);
|
||||
sn = NULL;
|
||||
s += sz;
|
||||
max -= sz;
|
||||
}
|
||||
if (arity) {
|
||||
fprintf(stderr, ")");
|
||||
*s++ = ' ';
|
||||
*s++ = ')';
|
||||
max -= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
} while (expand);
|
||||
s[0] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
unsigned long long vsc_count;
|
||||
#else
|
||||
unsigned long vsc_count;
|
||||
|
@ -106,7 +161,7 @@ void jmp_deb2(void) { fprintf(stderr, "Here\n"); }
|
|||
|
||||
void jmp_deb(int i) {
|
||||
if (i)
|
||||
printf("Here we go %ld\n", old_value++);
|
||||
printf("Here we go " Int_FORMAT "\n", old_value++);
|
||||
if (old_value == 716)
|
||||
jmp_deb2();
|
||||
}
|
||||
|
@ -136,41 +191,23 @@ check_area(void)
|
|||
jmp_deb(i);
|
||||
}
|
||||
*/
|
||||
// PredEntry *old_p[10000];
|
||||
// Term old_x1[10000], old_x2[10000], old_x3[10000];
|
||||
|
||||
PredEntry *old_p[10000];
|
||||
Term old_x1[10000], old_x2[10000], old_x3[10000];
|
||||
// static CELL oldv = 0;
|
||||
|
||||
// static CELL oldv;
|
||||
|
||||
void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
||||
bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
||||
CACHE_REGS
|
||||
char *s;
|
||||
char *mname;
|
||||
Int arity;
|
||||
int l = push_text_stack();
|
||||
/* extern int gc_calls; */
|
||||
vsc_count++;
|
||||
// if (HR < ASP ) return;
|
||||
// fif (vsc_count == 12534) jmp_deb( 2 );
|
||||
#if __ANDROID__ && 0
|
||||
PredEntry *ap = pred;
|
||||
if (pred && port == enter_pred) {
|
||||
UInt flags = ap->PredFlags;
|
||||
if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n",
|
||||
NameOfFunctor(ap->FunctorOfPred)->StrOfAE,
|
||||
ap->ArityOfPE, flags);
|
||||
/* printf(" %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE,
|
||||
* ap->ArityOfPE, flags); */
|
||||
else if (ap->ModuleOfPred != IDB_MODULE)
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n",
|
||||
((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE,
|
||||
flags);
|
||||
/* printf(" %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE,
|
||||
* ap->ArityOfPE, flags); */
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %x ", ap->src.OwnerFile);
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
//fprintf(stderr,"%p-%p\n",B->cp_tr,TR);
|
||||
// if (HR < ASP ) return;
|
||||
// fif (vsc_count == 12534) jmp_deb( 2 );
|
||||
char *buf = Malloc(512), *top = buf + 511, *b = buf;
|
||||
|
||||
// if (!worker_id) return;
|
||||
LOCK(Yap_low_level_trace_lock);
|
||||
|
@ -180,10 +217,10 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
LOCAL_ThreadHandle.thread_inst_count++;
|
||||
#endif
|
||||
#ifdef COMMENTED
|
||||
fprintf(stderr, "in %p\n");
|
||||
b = snprintf(b, top - b, "in %p\n");
|
||||
CELL *gc_ENV = ENV;
|
||||
while (gc_ENV != NULL) { /* no more environments */
|
||||
fprintf(stderr, "%ld\n", LCL0 - gc_ENV);
|
||||
b = snprintf(b, top - b, "%ld\n", LCL0 - gc_ENV);
|
||||
gc_ENV = (CELL *)gc_ENV[E_E]; /* link to prev
|
||||
* environment */
|
||||
}
|
||||
|
@ -191,7 +228,8 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
{
|
||||
choiceptr b_p = B;
|
||||
while (b_p) {
|
||||
fprintf(stderr, "%p %ld\n", b_p, Yap_op_from_opcode(b_p->cp_ap->opc));
|
||||
b = snprintf(b, top - b, "%p %ld\n", b_p,
|
||||
Yap_op_from_opcode(b_p->cp_ap->opc));
|
||||
b_p = b_p->cp_b;
|
||||
}
|
||||
}
|
||||
|
@ -208,8 +246,8 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
if (vsc_count % 1LL == 0) {
|
||||
UInt sz = Yap_regp->H0_[17];
|
||||
UInt end = sizeof(MP_INT) / sizeof(CELL) + sz + 1;
|
||||
fprintf(stderr, "VAL %lld %d %x/%x\n", vsc_count, sz, H0[16],
|
||||
H0[16 + end]);
|
||||
b = snprintf(b, top - b, "VAL %lld %d %x/%x\n", vsc_count, sz, H0[16],
|
||||
H0[16 + end]);
|
||||
}
|
||||
} else
|
||||
return;
|
||||
|
@ -280,8 +318,9 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
if (vsc_count == 173118LL)
|
||||
jmp_deb(1);
|
||||
if (!(vsc_count >= 287934LL && vsc_count <= 287939LL) &&
|
||||
!(vsc_count >= 173100LL && vsc_count <= 173239LL) && vsc_count != -1)
|
||||
!(vsc_count >= 173100LL && vsc_count <= 173239LL) && vsc_count != -1) {
|
||||
return;
|
||||
}
|
||||
if (vsc_count == 51021) {
|
||||
printf("Here I go\n");
|
||||
}
|
||||
|
@ -307,12 +346,10 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
while (env_ptr) {
|
||||
PredEntry *pe = EnvPreg(env_ptr[E_CP]);
|
||||
|
||||
printf("%p->", env_ptr, pe);
|
||||
if (vsc_count == 52LL)
|
||||
printf("\n");
|
||||
if (p == pe) {
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
pop_text_stack(l);
|
||||
return (true);
|
||||
}
|
||||
if (env_ptr != NULL)
|
||||
env_ptr = (CELL *)(env_ptr[E_E]);
|
||||
|
@ -320,64 +357,77 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "%lld %ld ", vsc_count, LCL0 - (CELL *)B);
|
||||
b += snprintf(b, top - b, "%llud " UInt_FORMAT " ", vsc_count,
|
||||
LCL0 - (CELL *)B);
|
||||
b += snprintf(b, top - b, Int_FORMAT " ", LCL0 - (CELL *)Yap_REGS.CUT_C_TOP);
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
fprintf(stderr, "(%d)", worker_id);
|
||||
b += snprintf(b, top - b, "(%d)", worker_id);
|
||||
#endif
|
||||
/* check_trail_consistency(); */
|
||||
if (pred == NULL) {
|
||||
UNLOCK(Yap_low_level_trace_lock);
|
||||
return;
|
||||
pop_text_stack(l);
|
||||
return (true);
|
||||
}
|
||||
if (pred->ModuleOfPred == 0 && !LOCAL_do_trace_primitives) {
|
||||
UNLOCK(Yap_low_level_trace_lock);
|
||||
return;
|
||||
if (pred->ModuleOfPred == PROLOG_MODULE) {
|
||||
if (!LOCAL_do_trace_primitives) {
|
||||
UNLOCK(Yap_low_level_trace_lock);
|
||||
pop_text_stack(l);
|
||||
return (true);
|
||||
}
|
||||
mname = "prolog";
|
||||
} else {
|
||||
mname = RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE;
|
||||
}
|
||||
switch (port) {
|
||||
case enter_pred:
|
||||
mname = (char *)RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
if (arity == 0)
|
||||
if (arity == 0) {
|
||||
s = (char *)RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
else
|
||||
} else {
|
||||
s = (char *)RepAtom(NameOfFunctor((pred->FunctorOfPred)))->StrOfAE;
|
||||
}
|
||||
/* if ((pred->ModuleOfPred == 0) && (s[0] == '$'))
|
||||
return; */
|
||||
send_tracer_message("CALL: ", s, arity, mname, args);
|
||||
b = send_tracer_message("CALL: ", s, arity, mname, args, &buf, b, &top);
|
||||
break;
|
||||
case try_or:
|
||||
send_tracer_message("TRY_OR ", NULL, 0, NULL, args);
|
||||
b = send_tracer_message("TRY_OR ", NULL, 0, NULL, args, &buf, b, &top);
|
||||
break;
|
||||
case retry_or:
|
||||
send_tracer_message("FAIL ", NULL, 0, NULL, args);
|
||||
send_tracer_message("RETRY_OR ", NULL, 0, NULL, args);
|
||||
b = send_tracer_message("FAIL ", NULL, 0, NULL, args, &buf, b, &top);
|
||||
b = send_tracer_message("RETRY_OR ", NULL, 0, NULL, args, &buf, b, &top);
|
||||
break;
|
||||
case retry_table_generator:
|
||||
send_tracer_message("FAIL ", NULL, 0, NULL, args);
|
||||
b = send_tracer_message("FAIL ", NULL, 0, NULL, args, &buf, b, &top);
|
||||
mname = (char *)RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
if (arity == 0)
|
||||
s = (char *)RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
else
|
||||
s = (char *)RepAtom(NameOfFunctor((pred->FunctorOfPred)))->StrOfAE;
|
||||
send_tracer_message("RETRY GENERATOR: ", s, arity, mname, args);
|
||||
b = send_tracer_message("RETRY GENERATOR: ", s, arity, mname, args, &buf, b,
|
||||
&top);
|
||||
break;
|
||||
case retry_table_consumer:
|
||||
send_tracer_message("FAIL ", NULL, 0, NULL, args);
|
||||
b = send_tracer_message("FAIL ", NULL, 0, NULL, args, &buf, b, &top);
|
||||
mname = (char *)RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
if (arity == 0) {
|
||||
s = (char *)RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
send_tracer_message("RETRY CONSUMER: ", s, 0, mname, NULL);
|
||||
b = send_tracer_message("RETRY CONSUMER: ", s, 0, mname, NULL, &buf, b,
|
||||
&top);
|
||||
} else {
|
||||
s = (char *)RepAtom(NameOfFunctor((pred->FunctorOfPred)))->StrOfAE;
|
||||
send_tracer_message("RETRY CONSUMER: ", s, pred->ArityOfPE, mname, NULL);
|
||||
b = send_tracer_message("RETRY CONSUMER: ", s, pred->ArityOfPE, mname,
|
||||
NULL, &buf, b, &top);
|
||||
}
|
||||
break;
|
||||
case retry_table_loader:
|
||||
send_tracer_message("FAIL ", NULL, 0, NULL, args);
|
||||
b = send_tracer_message("FAIL ", NULL, 0, NULL, args, &buf, b, &top);
|
||||
if (pred == UndefCode) {
|
||||
send_tracer_message("RETRY LOADER ", NULL, 0, NULL, NULL);
|
||||
b = send_tracer_message("RETRY LOADER ", NULL, 0, NULL, NULL, &buf, b,
|
||||
&top);
|
||||
} else {
|
||||
mname = (char *)RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
|
@ -385,11 +435,12 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
s = (char *)RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
else
|
||||
s = (char *)RepAtom(NameOfFunctor((pred->FunctorOfPred)))->StrOfAE;
|
||||
send_tracer_message("RETRY LOADER: ", s, 0, mname, NULL);
|
||||
b = send_tracer_message("RETRY LOADER: ", s, 0, mname, NULL, &buf, b,
|
||||
&top);
|
||||
}
|
||||
break;
|
||||
case retry_pred:
|
||||
send_tracer_message("FAIL ", NULL, 0, NULL, args);
|
||||
b = send_tracer_message("FAIL ", NULL, 0, NULL, args, &buf, b, &top);
|
||||
if (pred != NULL) {
|
||||
mname = (char *)RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
|
@ -401,12 +452,20 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||
} else {
|
||||
s = (char *)RepAtom(NameOfFunctor((pred->FunctorOfPred)))->StrOfAE;
|
||||
}
|
||||
send_tracer_message("RETRY: ", s, arity, mname, args);
|
||||
b = send_tracer_message("RETRY: ", s, arity, mname, args, &buf, b, &top);
|
||||
}
|
||||
break;
|
||||
}
|
||||
fflush(NULL);
|
||||
UNLOCK(Yap_low_level_trace_lock);
|
||||
#if __ANDROID__
|
||||
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid", "%s\n", buf);
|
||||
#else
|
||||
*b++ = '\n';
|
||||
*b = '\0';
|
||||
fputs(buf, stderr);
|
||||
#endif
|
||||
pop_text_stack(l);
|
||||
return (true);
|
||||
}
|
||||
|
||||
void toggle_low_level_trace(void) {
|
||||
|
@ -454,7 +513,7 @@ not being output.
|
|||
static Int stop_low_level_trace(USES_REGS1) {
|
||||
Yap_do_low_level_trace = FALSE;
|
||||
LOCAL_do_trace_primitives = TRUE;
|
||||
#if DEBUG_LOCKS
|
||||
#if DEBUG_LOCKS////
|
||||
debug_locks = TRUE;
|
||||
#endif
|
||||
return (TRUE);
|
||||
|
|
|
@ -463,7 +463,7 @@ p_cyclic( USES_REGS1 )
|
|||
return rational_tree(t);
|
||||
}
|
||||
|
||||
int Yap_IsAcyclicTerm(Term t)
|
||||
bool Yap_IsAcyclicTerm(Term t)
|
||||
{
|
||||
return !rational_tree(t);
|
||||
}
|
||||
|
@ -604,12 +604,10 @@ InitReverseLookupOpcode(void)
|
|||
int hash_size_mask = OP_HASH_SIZE-1;
|
||||
UInt sz = OP_HASH_SIZE*sizeof(struct opcode_tab_entry);
|
||||
|
||||
while (OP_RTABLE == NULL) {
|
||||
if ((OP_RTABLE = (op_entry *)Yap_AllocCodeSpace(sz)) == NULL) {
|
||||
if (!Yap_growheap(FALSE, sz, NULL)) {
|
||||
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
|
||||
"Couldn't obtain space for the reverse translation opcode table");
|
||||
}
|
||||
}
|
||||
}
|
||||
memset(OP_RTABLE, 0, sz);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* Get Instructions *
|
||||
\************************************************************************/
|
||||
|
||||
#include <amiops.h>
|
||||
|
||||
#ifdef INDENT_CODE
|
||||
{
|
||||
{
|
||||
|
|
3425
C/utilpreds.c
3425
C/utilpreds.c
File diff suppressed because it is too large
Load Diff
561
C/write.c
561
C/write.c
|
@ -1,32 +1,30 @@
|
|||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: write.c *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: Writing a Prolog Term *
|
||||
* *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: write.c * Last
|
||||
*rev: * mods:
|
||||
** comments: Writing a Prolog Term *
|
||||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "YapText.h"
|
||||
#include "yapio.h"
|
||||
#include "Yatom.h"
|
||||
#include "clause.h"
|
||||
#include "yapio.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#if COROUTINING
|
||||
#include "attvar.h"
|
||||
#endif
|
||||
|
@ -72,40 +70,43 @@ typedef struct rewind_term {
|
|||
|
||||
typedef struct write_globs {
|
||||
StreamDesc *stream;
|
||||
int Quote_illegal, Ignore_ops, Handle_vars, Use_portray, Portray_delays;
|
||||
int Keep_terms;
|
||||
int Write_Loops;
|
||||
int Write_strings;
|
||||
int last_atom_minus;
|
||||
bool Quote_illegal, Ignore_ops, Handle_vars, Use_portray, Portray_delays;
|
||||
bool Keep_terms;
|
||||
bool Write_Loops;
|
||||
bool Write_strings;
|
||||
UInt last_atom_minus;
|
||||
UInt MaxDepth, MaxArgs;
|
||||
wtype lw;
|
||||
CELL *visited, *visited0, *visited_top;
|
||||
} wglbs;
|
||||
|
||||
#define lastw wglb->lw
|
||||
#define last_minus wglb->last_atom_minus
|
||||
|
||||
static bool callPortray(Term t, struct DB_TERM **old_EXp, int sno USES_REGS) {
|
||||
static bool callPortray(Term t, int sno USES_REGS) {
|
||||
PredEntry *pe;
|
||||
Int b0 = LCL0 - (CELL *)B;
|
||||
|
||||
EX = NULL;
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorPortray, USER_MODULE))) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, &t, true PASS_REGS)) {
|
||||
choiceptr B0 = (choiceptr)(LCL0 - b0);
|
||||
if (EX && !*old_EXp)
|
||||
*old_EXp = EX;
|
||||
Yap_fail_all(B0 PASS_REGS);
|
||||
LOCK(GLOBAL_Stream[sno].streamlock);
|
||||
return true;
|
||||
}
|
||||
LOCK(GLOBAL_Stream[sno].streamlock);
|
||||
if (EX && !*old_EXp)
|
||||
*old_EXp = EX;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#define PROTECT(t, F) \
|
||||
{ \
|
||||
yhandle_t yt = Yap_InitHandle(t); \
|
||||
F; \
|
||||
t = Yap_PopHandle(yt); \
|
||||
}
|
||||
static void wrputn(Int, struct write_globs *);
|
||||
static void wrputf(Float, struct write_globs *);
|
||||
static void wrputref(CODEADDR, int, struct write_globs *);
|
||||
|
@ -164,7 +165,6 @@ static void protect_close_number(struct write_globs *wglb, int used_bracket) {
|
|||
|
||||
static void wrputn(Int n,
|
||||
struct write_globs *wglb) /* writes an integer */
|
||||
|
||||
{
|
||||
wrf stream = wglb->stream;
|
||||
char s[256], *s1 = s; /* that should be enough for most integers */
|
||||
|
@ -188,12 +188,6 @@ inline static void wrputs(char *s, StreamDesc *stream) {
|
|||
wrputc(c, stream);
|
||||
}
|
||||
|
||||
static void wrputws(wchar_t *s, wrf stream) /* writes a string */
|
||||
{
|
||||
while (*s)
|
||||
wrputc(*s++, stream);
|
||||
}
|
||||
|
||||
#ifdef USE_GMP
|
||||
|
||||
static char *ensure_space(size_t sz) {
|
||||
|
@ -278,10 +272,10 @@ static void writebig(Term t, int p, int depth, int rinfixarg,
|
|||
return;
|
||||
#endif
|
||||
} else if (big_tag >= USER_BLOB_START && big_tag < USER_BLOB_END) {
|
||||
Opaque_CallOnWrite f;
|
||||
YAP_Opaque_CallOnWrite f;
|
||||
CELL blob_info;
|
||||
|
||||
blob_info = big_tag - USER_BLOB_START;
|
||||
blob_info = big_tag;
|
||||
if (GLOBAL_OpaqueHandlers &&
|
||||
(f = GLOBAL_OpaqueHandlers[blob_info].write_handler)) {
|
||||
(f)(wglb->stream->file, big_tag, ExternalBlobFromTerm(t), 0);
|
||||
|
@ -326,7 +320,7 @@ static void wrputf(Float f, struct write_globs *wglb) /* writes a float */
|
|||
int found_dot = FALSE;
|
||||
char *pt = s;
|
||||
int ch;
|
||||
/* always use C locale for writing numbers */
|
||||
/* always use C locale for writing numbers */
|
||||
#if O_LOCALE
|
||||
const unsigned char *decimalpoint =
|
||||
(unsigned char *)localeconv()->decimal_point;
|
||||
|
@ -361,7 +355,7 @@ static void wrputf(Float f, struct write_globs *wglb) /* writes a float */
|
|||
found_dot = TRUE;
|
||||
wrputs(".0", stream);
|
||||
}
|
||||
found_dot = TRUE;
|
||||
found_dot = true;
|
||||
}
|
||||
wrputc(ch, stream);
|
||||
pt++;
|
||||
|
@ -387,18 +381,17 @@ int Yap_FormatFloat(Float f, char **s, size_t sz) {
|
|||
CACHE_REGS
|
||||
struct write_globs wglb;
|
||||
int sno;
|
||||
char *so;
|
||||
|
||||
sno = Yap_open_buf_write_stream(
|
||||
*s, sz, &GLOBAL_Stream[LOCAL_c_output_stream].encoding, 0);
|
||||
sno = Yap_open_buf_write_stream(GLOBAL_Stream[LOCAL_c_output_stream].encoding,
|
||||
0);
|
||||
if (sno < 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
wglb.lw = separator;
|
||||
wglb.stream = GLOBAL_Stream + sno;
|
||||
wrputf(f, &wglb);
|
||||
so = Yap_MemExportStreamPtr(sno);
|
||||
*s = Yap_MemExportStreamPtr(sno);
|
||||
Yap_CloseStream(sno);
|
||||
*s = so;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* writes a data base reference */
|
||||
|
@ -417,6 +410,57 @@ static void wrputref(CODEADDR ref, int Quote_illegal,
|
|||
lastw = alphanum;
|
||||
}
|
||||
|
||||
static inline bool was_visited(Term t, wglbs *wg, Term *ta) {
|
||||
Term *tp;
|
||||
if (IsApplTerm(t)) {
|
||||
tp = RepAppl(t);
|
||||
*ta = tp[0];
|
||||
return false;
|
||||
if (IsExtensionFunctor(FunctorOfTerm(t))) {
|
||||
return false;
|
||||
}
|
||||
} else if (IsPairTerm(t)) {
|
||||
tp = RepPair(t);
|
||||
*ta = tp[0];
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
if (IsAtomTerm(*tp)) {
|
||||
CELL *pt = (CELL *)AtomOfTerm(*tp);
|
||||
if (pt >= wg->visited0 && pt < wg->visited) {
|
||||
int depth = (wg->visited) - pt;
|
||||
wrputs(" @[-", wg->stream);
|
||||
wrputn(depth, wg);
|
||||
wrputs("] ", wg->stream);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
wg->visited[0] = *tp;
|
||||
*tp = MkAtomTerm((Atom)wg->visited);
|
||||
wg->visited++;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline Term visited_indirection(Term t, wglbs *wg) {
|
||||
Term *tp = (CELL *)AtomOfTerm(t);
|
||||
if (tp >= wg->visited0 && (CELL *)tp < wg->visited_top)
|
||||
return *tp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void done_visiting(Term t, wglbs *wg) {
|
||||
Term *tp;
|
||||
return;
|
||||
if (IsApplTerm(t))
|
||||
tp = RepAppl(t);
|
||||
else if (IsPairTerm(t))
|
||||
tp = RepPair(t);
|
||||
else
|
||||
return;
|
||||
*tp = *--wg->visited;
|
||||
}
|
||||
|
||||
/* writes a blob (default) */
|
||||
static int wrputblob(AtomEntry *ref, int Quote_illegal,
|
||||
struct write_globs *wglb) {
|
||||
|
@ -472,9 +516,7 @@ static wtype
|
|||
AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
|
||||
{
|
||||
int ch;
|
||||
if ( Yap_chtype[(int)s[0]] == SL &&
|
||||
s[1] == '\0'
|
||||
)
|
||||
if (Yap_chtype[(int)s[0]] == SL && s[1] == '\0')
|
||||
return (separator);
|
||||
while ((ch = *s++) != '\0') {
|
||||
if (Yap_chtype[ch] != SY)
|
||||
|
@ -572,11 +614,17 @@ static void write_string(const unsigned char *s,
|
|||
qt = '"';
|
||||
wrputc(qt, stream);
|
||||
do {
|
||||
ptr += get_utf8(ptr, &chr);
|
||||
if (chr == '\0')
|
||||
int delta;
|
||||
ptr += (delta = get_utf8(ptr, -1, &chr));
|
||||
|
||||
if (chr == '\0') {
|
||||
break;
|
||||
}
|
||||
if (delta == 0) {
|
||||
chr = *ptr++;
|
||||
}
|
||||
write_quoted(chr, qt, stream);
|
||||
} while (TRUE);
|
||||
} while (true);
|
||||
wrputc(qt, stream);
|
||||
}
|
||||
|
||||
|
@ -585,28 +633,21 @@ static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) {
|
|||
unsigned char *s;
|
||||
wtype atom_or_symbol;
|
||||
wrf stream = wglb->stream;
|
||||
|
||||
if (atom == NULL)
|
||||
return;
|
||||
s = RepAtom(atom)->UStrOfAE;
|
||||
if (s[0] == '\0') {
|
||||
if (Quote_illegal) {
|
||||
wrputc('\'', stream);
|
||||
wrputc('\'', stream);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (IsBlob(atom)) {
|
||||
wrputblob(RepAtom(atom), Quote_illegal, wglb);
|
||||
return;
|
||||
}
|
||||
if (IsWideAtom(atom)) {
|
||||
wchar_t *ws = RepAtom(atom)->WStrOfAE;
|
||||
|
||||
if (Quote_illegal) {
|
||||
wrputc('\'', stream);
|
||||
while (*ws) {
|
||||
wchar_t ch = *ws++;
|
||||
write_quoted(ch, '\'', stream);
|
||||
}
|
||||
wrputc('\'', stream);
|
||||
} else {
|
||||
wrputws(ws, stream);
|
||||
}
|
||||
return;
|
||||
}
|
||||
s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
||||
/* #define CRYPT_FOR_STEVE 1*/
|
||||
/* #define CRYPT_FOR_STEVE 1*/
|
||||
#ifdef CRYPT_FOR_STEVE
|
||||
if (Yap_GetValue(AtomCryptAtoms) != TermNil &&
|
||||
Yap_GetAProp(atom, OpProperty) == NIL) {
|
||||
|
@ -625,7 +666,8 @@ static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) {
|
|||
if (Quote_illegal && !legalAtom(s)) {
|
||||
wrputc('\'', stream);
|
||||
while (*s) {
|
||||
wchar_t ch = *s++;
|
||||
int32_t ch;
|
||||
s += get_utf8(s, -1, &ch);
|
||||
write_quoted(ch, '\'', stream);
|
||||
}
|
||||
wrputc('\'', stream);
|
||||
|
@ -694,61 +736,6 @@ static void putUnquotedString(Term string, struct write_globs *wglb)
|
|||
lastw = alphanum;
|
||||
}
|
||||
|
||||
static Term from_pointer(CELL *ptr0, struct rewind_term *rwt,
|
||||
struct write_globs *wglb) {
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
CELL *ptr = ptr0;
|
||||
|
||||
while (IsVarTerm(*ptr) && !IsUnboundVar(ptr))
|
||||
ptr = (CELL *)*ptr;
|
||||
t = *ptr;
|
||||
if (wglb->Keep_terms) {
|
||||
struct rewind_term *x = rwt->parent;
|
||||
|
||||
rwt->u_sd.s.old = Yap_InitSlot(t);
|
||||
rwt->u_sd.s.ptr = Yap_InitSlot((CELL)ptr0);
|
||||
|
||||
if (!IsAtomicTerm(t) && !IsVarTerm(t)) {
|
||||
while (x) {
|
||||
if (Yap_GetDerefedFromSlot(x->u_sd.s.old) == t)
|
||||
return TermFoundVar;
|
||||
x = x->parent;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rwt->u_sd.d.old = t;
|
||||
rwt->u_sd.d.ptr = ptr0;
|
||||
if (!IsVarTerm(t) && !IsAtomicTerm(t)) {
|
||||
struct rewind_term *x = rwt->parent;
|
||||
|
||||
while (x) {
|
||||
if (x->u_sd.d.old == t)
|
||||
return TermFoundVar;
|
||||
x = x->parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static CELL *restore_from_write(struct rewind_term *rwt,
|
||||
struct write_globs *wglb) {
|
||||
CACHE_REGS
|
||||
CELL *ptr;
|
||||
|
||||
if (wglb->Keep_terms) {
|
||||
ptr = Yap_GetPtrFromSlot(rwt->u_sd.s.ptr );
|
||||
Yap_RecoverSlots(2, rwt->u_sd.s.old );
|
||||
// printf("leak=%d %d\n", LOCALCurSlot,rwt->u_sd.s.old) ;
|
||||
} else {
|
||||
ptr = rwt->u_sd.d.ptr;
|
||||
}
|
||||
rwt->u_sd.s.ptr = 0;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* writes an unbound variable */
|
||||
static void write_var(CELL *t, struct write_globs *wglb,
|
||||
struct rewind_term *rwt) {
|
||||
CACHE_REGS
|
||||
|
@ -774,12 +761,11 @@ static void write_var(CELL *t, struct write_globs *wglb,
|
|||
wrputs("$AT(", wglb->stream);
|
||||
write_var(t, wglb, rwt);
|
||||
wrputc(',', wglb->stream);
|
||||
writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt);
|
||||
l = restore_from_write(&nrwt, wglb);
|
||||
PROTECT(*t, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
|
||||
attv = RepAttVar(t);
|
||||
wrputc(',', wglb->stream);
|
||||
l++;
|
||||
writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
writeTerm(*l, 999, 1, FALSE, wglb, &nrwt);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
wglb->Portray_delays = TRUE;
|
||||
|
@ -792,97 +778,52 @@ static void write_var(CELL *t, struct write_globs *wglb,
|
|||
}
|
||||
}
|
||||
|
||||
static Term check_infinite_loop(Term t, struct rewind_term *x,
|
||||
struct write_globs *wglb) {
|
||||
CACHE_REGS
|
||||
if (wglb->Keep_terms) {
|
||||
while (x) {
|
||||
if (Yap_GetFromSlot(x->u_sd.s.old) == t)
|
||||
return TermFoundVar;
|
||||
x = x->parent;
|
||||
}
|
||||
} else {
|
||||
while (x) {
|
||||
if (x->u_sd.d.old == t)
|
||||
return TermFoundVar;
|
||||
x = x->parent;
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static void write_list(Term t, int direction, int depth,
|
||||
static void write_list(Term t, Term hot, int direction, int depth,
|
||||
struct write_globs *wglb, struct rewind_term *rwt) {
|
||||
Term ti;
|
||||
struct rewind_term nrwt;
|
||||
nrwt.parent = rwt;
|
||||
nrwt.u_sd.s.ptr = 0;
|
||||
|
||||
while (1) {
|
||||
int ndirection;
|
||||
int do_jump;
|
||||
|
||||
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE,
|
||||
wglb, &nrwt);
|
||||
t = AbsPair(restore_from_write(&nrwt, wglb));
|
||||
while (true) {
|
||||
PROTECT(t, writeTerm(hot, 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
ti = TailOfTerm(t);
|
||||
if (IsVarTerm(ti))
|
||||
break;
|
||||
if (!IsPairTerm(ti) ||
|
||||
!IsPairTerm((ti = check_infinite_loop(ti, rwt, wglb))))
|
||||
if (!IsPairTerm(ti))
|
||||
break;
|
||||
ndirection = RepPair(ti) - RepPair(t);
|
||||
/* make sure we're not trapped in loops */
|
||||
if (ndirection > 0) {
|
||||
do_jump = (direction <= 0);
|
||||
} else if (ndirection == 0) {
|
||||
wrputc(',', wglb->stream);
|
||||
putAtom(AtomFoundVar, wglb->Quote_illegal, wglb);
|
||||
lastw = separator;
|
||||
return;
|
||||
} else {
|
||||
do_jump = (direction >= 0);
|
||||
}
|
||||
if (wglb->MaxDepth != 0 && depth > wglb->MaxDepth) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
putAtom(Atom3Dots, wglb->Quote_illegal, wglb);
|
||||
done_visiting(t, wglb);
|
||||
return;
|
||||
}
|
||||
lastw = separator;
|
||||
direction = ndirection;
|
||||
depth++;
|
||||
if (do_jump)
|
||||
break;
|
||||
wrputc(',', wglb->stream);
|
||||
t = ti;
|
||||
if ((was_visited(ti, wglb, &hot))) {
|
||||
break;
|
||||
}
|
||||
write_list(ti, hot, direction, depth, wglb, &nrwt);
|
||||
done_visiting(ti, wglb);
|
||||
return;
|
||||
}
|
||||
if (IsPairTerm(ti)) {
|
||||
Term nt = from_pointer(RepPair(t) + 1, &nrwt, wglb);
|
||||
/* we found an infinite loop */
|
||||
if (IsAtomTerm(nt)) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
writeTerm(nt, 999, depth, FALSE, wglb, rwt);
|
||||
} else {
|
||||
/* keep going on the list */
|
||||
wrputc(',', wglb->stream);
|
||||
write_list(nt, direction, depth, wglb, &nrwt);
|
||||
/* keep going on the list */
|
||||
wrputc(',', wglb->stream);
|
||||
write_list(ti, hot, direction, depth, wglb, &nrwt);
|
||||
done_visiting(ti, wglb);
|
||||
} else if (ti != TermNil) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
restore_from_write(&nrwt, wglb);
|
||||
} else if (ti != MkAtomTerm(AtomNil)) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth, FALSE,
|
||||
wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
writeTerm(ti, 999, depth, FALSE, wglb, &nrwt);
|
||||
done_visiting(ti, wglb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -890,7 +831,6 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
struct write_globs *wglb, struct rewind_term *rwt)
|
||||
/* term to write */
|
||||
/* context priority */
|
||||
|
||||
{
|
||||
CACHE_REGS
|
||||
struct rewind_term nrwt;
|
||||
|
@ -901,71 +841,84 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
putAtom(Atom3Dots, wglb->Quote_illegal, wglb);
|
||||
return;
|
||||
}
|
||||
DBTerm *oEX = EX;
|
||||
EX = NULL;
|
||||
t = Deref(t);
|
||||
if (IsVarTerm(t)) {
|
||||
write_var((CELL *)t, wglb, &nrwt);
|
||||
} else if (IsIntTerm(t)) {
|
||||
|
||||
wrputn((Int)IntOfTerm(t), wglb);
|
||||
} else if (IsAtomTerm(t)) {
|
||||
putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb);
|
||||
} else if (IsPairTerm(t)) {
|
||||
if (wglb->Ignore_ops) {
|
||||
wrputs("'.'(", wglb->stream);
|
||||
lastw = separator;
|
||||
|
||||
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE,
|
||||
wglb, &nrwt);
|
||||
t = AbsPair(restore_from_write(&nrwt, wglb));
|
||||
wrputs(",", wglb->stream);
|
||||
writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
EX = oEX;
|
||||
Term tn;
|
||||
if ((tn = visited_indirection(t, wglb)) != 0) {
|
||||
writeTerm(tn, p, depth, rinfixarg, wglb, rwt);
|
||||
return;
|
||||
}
|
||||
if (wglb->Use_portray)
|
||||
if (callPortray(t, &EX, wglb->stream - GLOBAL_Stream PASS_REGS)) {
|
||||
EX = oEX;
|
||||
putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb);
|
||||
} else if (IsPairTerm(t)) {
|
||||
Term hot;
|
||||
if ((was_visited(t, wglb, &hot))) {
|
||||
return;
|
||||
}
|
||||
if (wglb->Ignore_ops) {
|
||||
wrputs("'.'(", wglb->stream);
|
||||
lastw = separator;
|
||||
|
||||
PROTECT(t, writeTerm(hot, 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
wrputs(",", wglb->stream);
|
||||
writeTerm(TailOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
done_visiting(t, wglb);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
return;
|
||||
}
|
||||
if (wglb->Use_portray) {
|
||||
done_visiting(t, wglb);
|
||||
if (callPortray(t, wglb->stream - GLOBAL_Stream PASS_REGS)) {
|
||||
return;
|
||||
}
|
||||
if ((was_visited(t, wglb, &hot))) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
if (trueGlobalPrologFlag(WRITE_STRINGS_FLAG) && IsCodesTerm(t)) {
|
||||
putString(t, wglb);
|
||||
} else {
|
||||
wrputc('[', wglb->stream);
|
||||
lastw = separator;
|
||||
/* we assume t was already saved in the stack */
|
||||
write_list(t, 0, depth, wglb, rwt);
|
||||
write_list(t, hot, 0, depth, wglb, rwt);
|
||||
done_visiting(t, wglb);
|
||||
wrputc(']', wglb->stream);
|
||||
lastw = separator;
|
||||
}
|
||||
} else { /* compound term */
|
||||
Functor functor = FunctorOfTerm(t);
|
||||
Functor functor;
|
||||
int Arity;
|
||||
Atom atom;
|
||||
int op, lp, rp;
|
||||
|
||||
Term argf;
|
||||
if (was_visited(t, wglb, &argf)) {
|
||||
return;
|
||||
}
|
||||
functor = (Functor)argf;
|
||||
if (IsExtensionFunctor(functor)) {
|
||||
switch ((CELL)functor) {
|
||||
case (CELL) FunctorDouble:
|
||||
case (CELL)FunctorDouble:
|
||||
wrputf(FloatOfTerm(t), wglb);
|
||||
return;
|
||||
case (CELL) FunctorString:
|
||||
case (CELL)FunctorString:
|
||||
write_string(UStringOfTerm(t), wglb);
|
||||
return;
|
||||
case (CELL) FunctorAttVar:
|
||||
case (CELL)FunctorAttVar:
|
||||
write_var(RepAppl(t) + 1, wglb, &nrwt);
|
||||
return;
|
||||
case (CELL) FunctorDBRef:
|
||||
case (CELL)FunctorDBRef:
|
||||
wrputref(RefOfTerm(t), wglb->Quote_illegal, wglb);
|
||||
return;
|
||||
case (CELL) FunctorLongInt:
|
||||
case (CELL)FunctorLongInt:
|
||||
wrputn(LongIntOfTerm(t), wglb);
|
||||
return;
|
||||
/* case (CELL)FunctorBigInt: */
|
||||
/* case (CELL)FunctorBigInt: */
|
||||
default:
|
||||
writebig(t, p, depth, rinfixarg, wglb, rwt);
|
||||
return;
|
||||
|
@ -990,9 +943,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
*p++;
|
||||
lastw = separator;
|
||||
/* cannot use the term directly with the SBA */
|
||||
writeTerm(from_pointer(p, &nrwt, wglb), 999, depth + 1, FALSE, wglb,
|
||||
&nrwt);
|
||||
p = restore_from_write(&nrwt, wglb) + 1;
|
||||
PROTECT(t, writeTerm(*p, 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
if (*p)
|
||||
wrputc(',', wglb->stream);
|
||||
argno++;
|
||||
|
@ -1002,11 +953,15 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
}
|
||||
#endif
|
||||
if (wglb->Use_portray) {
|
||||
if (callPortray(t, &EX, wglb->stream - GLOBAL_Stream PASS_REGS)) {
|
||||
EX = oEX;
|
||||
done_visiting(t, wglb);
|
||||
if (callPortray(t, wglb->stream - GLOBAL_Stream PASS_REGS)) {
|
||||
return;
|
||||
}
|
||||
Term tf;
|
||||
was_visited(t, wglb, &tf);
|
||||
functor = (Functor)tf;
|
||||
}
|
||||
|
||||
if (!wglb->Ignore_ops && Arity == 1 && Yap_IsPrefixOp(atom, &op, &rp)) {
|
||||
Term tright = ArgOfTerm(1, t);
|
||||
int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) &&
|
||||
|
@ -1021,9 +976,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
} else if (atom == AtomMinus) {
|
||||
last_minus = TRUE;
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), rp, depth + 1, TRUE,
|
||||
wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
writeTerm(tright, rp, depth + 1, TRUE, wglb, &nrwt);
|
||||
if (bracket_right) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
|
@ -1032,7 +985,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
}
|
||||
} else if (!wglb->Ignore_ops &&
|
||||
(Arity == 1 ||
|
||||
((atom == AtomEmptyBrackets || atom == AtomEmptyCurlyBrackets ||
|
||||
((atom == AtomEmptyBrackets || atom == AtomCurly ||
|
||||
atom == AtomEmptySquareBrackets) &&
|
||||
Yap_IsListTerm(ArgOfTerm(1, t)))) &&
|
||||
Yap_IsPosfixOp(atom, &op, &lp)) {
|
||||
|
@ -1056,9 +1009,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
if (bracket_left) {
|
||||
wropen_bracket(wglb, TRUE);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t) + offset, &nrwt, wglb), lp, depth + 1,
|
||||
rinfixarg, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
writeTerm(ArgOfTerm(offset, t), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||
if (bracket_left) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
|
@ -1067,16 +1018,16 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
wrputc('(', wglb->stream);
|
||||
} else if (atom == AtomEmptySquareBrackets) {
|
||||
wrputc('[', wglb->stream);
|
||||
} else if (atom == AtomEmptyCurlyBrackets) {
|
||||
} else if (atom == AtomCurly) {
|
||||
wrputc('{', wglb->stream);
|
||||
}
|
||||
lastw = separator;
|
||||
write_list(tleft, 0, depth, wglb, rwt);
|
||||
writeTerm(tleft, 0, rinfixarg, depth, wglb, rwt);
|
||||
if (atom == AtomEmptyBrackets) {
|
||||
wrputc(')', wglb->stream);
|
||||
} else if (atom == AtomEmptySquareBrackets) {
|
||||
wrputc(']', wglb->stream);
|
||||
} else if (atom == AtomEmptyCurlyBrackets) {
|
||||
} else if (atom == AtomCurly) {
|
||||
wrputc('}', wglb->stream);
|
||||
}
|
||||
lastw = separator;
|
||||
|
@ -1103,9 +1054,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
if (bracket_left) {
|
||||
wropen_bracket(wglb, TRUE);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), lp, depth + 1,
|
||||
rinfixarg, wglb, &nrwt);
|
||||
t = AbsAppl(restore_from_write(&nrwt, wglb) - 1);
|
||||
PROTECT(
|
||||
t, writeTerm(ArgOfTerm(1, t), lp, depth + 1, rinfixarg, wglb, &nrwt));
|
||||
if (bracket_left) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
|
@ -1124,31 +1074,27 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
if (bracket_right) {
|
||||
wropen_bracket(wglb, TRUE);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t) + 2, &nrwt, wglb), rp, depth + 1, TRUE,
|
||||
wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
writeTerm(ArgOfTerm(2, t), rp, depth + 1, TRUE, wglb, &nrwt);
|
||||
if (bracket_right) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
if (op > p) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
} else if ( functor == FunctorDollarVar) {
|
||||
} else if (functor == FunctorDollarVar) {
|
||||
Term ti = ArgOfTerm(1, t);
|
||||
if (lastw == alphanum) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
if (wglb->Handle_vars &&
|
||||
!IsVarTerm(ti) &&
|
||||
(IsIntTerm(ti) ||
|
||||
IsCodesTerm(ti) ||
|
||||
IsAtomTerm(ti) ||
|
||||
IsStringTerm(ti) )) {
|
||||
if (wglb->Handle_vars && !IsVarTerm(ti) &&
|
||||
(IsIntTerm(ti) || IsCodesTerm(ti) || IsAtomTerm(ti) ||
|
||||
IsStringTerm(ti))) {
|
||||
if (IsIntTerm(ti)) {
|
||||
Int k = IntOfTerm(ti);
|
||||
if (k == -1) {
|
||||
wrputc('_', wglb->stream);
|
||||
lastw = alphanum;
|
||||
done_visiting(t, wglb);
|
||||
return;
|
||||
} else {
|
||||
wrputc((k % 26) + 'A', wglb->stream);
|
||||
|
@ -1169,17 +1115,14 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
} else {
|
||||
wrputs("'$VAR'(", wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
writeTerm(ArgOfTerm(1, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
} else if (!wglb->Ignore_ops && functor == FunctorBraces) {
|
||||
wrputc('{', wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), GLOBAL_MaxPriority, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
writeTerm(ArgOfTerm(1, t), GLOBAL_MaxPriority, depth + 1, FALSE, wglb,
|
||||
&nrwt);
|
||||
wrputc('}', wglb->stream);
|
||||
lastw = separator;
|
||||
} else if (atom == AtomArray) {
|
||||
|
@ -1190,39 +1133,41 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||
wrputs("...", wglb->stream);
|
||||
break;
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
t = AbsAppl(restore_from_write(&nrwt, wglb) - op);
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
if (op != Arity) {
|
||||
PROTECT(t, writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb,
|
||||
&nrwt));
|
||||
wrputc(',', wglb->stream);
|
||||
lastw = separator;
|
||||
}
|
||||
}
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
wrputc('}', wglb->stream);
|
||||
lastw = separator;
|
||||
} else {
|
||||
if (!wglb->Ignore_ops && atom == AtomHeap) {
|
||||
Arity = 3 + 2 * IntegerOfTerm(ArgOfTerm(1, t));
|
||||
}
|
||||
putAtom(atom, wglb->Quote_illegal, wglb);
|
||||
lastw = separator;
|
||||
wropen_bracket(wglb, FALSE);
|
||||
for (op = 1; op <= Arity; ++op) {
|
||||
for (op = 1; op < Arity; ++op) {
|
||||
if (op == wglb->MaxArgs) {
|
||||
wrputc('.', wglb->stream);
|
||||
wrputc('.', wglb->stream);
|
||||
wrputc('.', wglb->stream);
|
||||
break;
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
if (op != Arity) {
|
||||
wrputc(',', wglb->stream);
|
||||
lastw = separator;
|
||||
}
|
||||
PROTECT(
|
||||
t, writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
wrputc(',', wglb->stream);
|
||||
lastw = separator;
|
||||
}
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
done_visiting(t, wglb);
|
||||
}
|
||||
EX = oEX;
|
||||
}
|
||||
|
||||
void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
||||
|
@ -1232,32 +1177,35 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
|||
/* write options */
|
||||
{
|
||||
CACHE_REGS
|
||||
|
||||
yhandle_t lvl = push_text_stack();
|
||||
struct write_globs wglb;
|
||||
struct rewind_term rwt;
|
||||
yhandle_t sls = Yap_CurrentSlot();
|
||||
|
||||
if (!mywrite) {
|
||||
CACHE_REGS
|
||||
wglb.stream = GLOBAL_Stream + LOCAL_c_error_stream;
|
||||
} else
|
||||
wglb.stream = mywrite;
|
||||
wglb.lw = start;
|
||||
wglb.last_atom_minus = FALSE;
|
||||
wglb.Quote_illegal = flags & Quote_illegal_f;
|
||||
wglb.Handle_vars = flags & Handle_vars_f;
|
||||
wglb.Use_portray = flags & Use_portray_f;
|
||||
wglb.Portray_delays = flags & AttVar_Portray_f;
|
||||
wglb.MaxDepth = max_depth;
|
||||
wglb.MaxArgs = max_depth;
|
||||
/* notice: we must have ASP well set when using portray, otherwise
|
||||
we cannot make recursive Prolog calls */
|
||||
wglb.Keep_terms = (flags & (Use_portray_f | To_heap_f));
|
||||
/* initialize wglb */
|
||||
t = Deref(t);
|
||||
rwt.parent = NULL;
|
||||
wglb.stream = mywrite;
|
||||
wglb.Ignore_ops = flags & Ignore_ops_f;
|
||||
wglb.Write_strings = flags & BackQuote_String_f;
|
||||
wglb.Use_portray = flags & Use_portray_f;
|
||||
wglb.Handle_vars = flags & Handle_vars_f;
|
||||
wglb.Portray_delays = flags & AttVar_Portray_f;
|
||||
wglb.Keep_terms = flags & To_heap_f;
|
||||
wglb.Write_Loops = flags & Handle_cyclics_f;
|
||||
wglb.Quote_illegal = flags & Quote_illegal_f;
|
||||
wglb.MaxArgs = 0;
|
||||
wglb.MaxDepth = 0;
|
||||
wglb.lw = separator;
|
||||
Term tp;
|
||||
|
||||
if (true && (flags & Handle_cyclics_f)) {
|
||||
// tp = Yap_CyclesInTerm(t PASS_REGS);
|
||||
wglb.visited = Malloc(1024 * sizeof(CELL)), wglb.visited0 = wglb.visited,
|
||||
wglb.visited_top = wglb.visited + 1024;
|
||||
}
|
||||
tp = t;
|
||||
|
||||
/* protect slots for portray */
|
||||
writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt);
|
||||
writeTerm(tp, priority, 1, false, &wglb, &rwt);
|
||||
if (flags & New_Line_f) {
|
||||
if (flags & Fullstop_f) {
|
||||
wrputc('.', wglb.stream);
|
||||
|
@ -1271,28 +1219,5 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
|||
wrputc(' ', wglb.stream);
|
||||
}
|
||||
}
|
||||
restore_from_write(&rwt, &wglb);
|
||||
Yap_CloseSlots(sls);
|
||||
}
|
||||
|
||||
char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length,
|
||||
encoding_t *encp, int flags) {
|
||||
CACHE_REGS
|
||||
int sno = Yap_open_buf_write_stream(s, sz, encp, flags);
|
||||
int old_output_stream = LOCAL_c_output_stream;
|
||||
|
||||
if (sno < 0)
|
||||
return NULL;
|
||||
LOCAL_c_output_stream = sno;
|
||||
if (encp)
|
||||
GLOBAL_Stream[sno].encoding = *encp;
|
||||
else
|
||||
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
||||
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority);
|
||||
s = Yap_MemExportStreamPtr(sno);
|
||||
Yap_CloseStream(sno);
|
||||
LOCAL_c_output_stream = old_output_stream;
|
||||
if (EX == 0)
|
||||
return s;
|
||||
return NULL;
|
||||
pop_text_stack(lvl);
|
||||
}
|
||||
|
|
1683
C/yap-args.c
1683
C/yap-args.c
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,272 @@
|
|||
#
|
||||
# DO NOT EDIT! THIS FILE WAS GENERATED BY CMAKE!
|
||||
#
|
||||
|
||||
DOXYFILE_ENCODING = @DOXYGEN_DOXYFILE_ENCODING@
|
||||
PROJECT_NAME = @DOXYGEN_PROJECT_NAME@
|
||||
PROJECT_NUMBER = @DOXYGEN_PROJECT_NUMBER@
|
||||
PROJECT_BRIEF = @DOXYGEN_PROJECT_BRIEF@
|
||||
PROJECT_LOGO = @DOXYGEN_PROJECT_LOGO@
|
||||
OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@
|
||||
CREATE_SUBDIRS = @DOXYGEN_CREATE_SUBDIRS@
|
||||
ALLOW_UNICODE_NAMES = @DOXYGEN_ALLOW_UNICODE_NAMES@
|
||||
OUTPUT_LANGUAGE = @DOXYGEN_OUTPUT_LANGUAGE@
|
||||
BRIEF_MEMBER_DESC = @DOXYGEN_BRIEF_MEMBER_DESC@
|
||||
REPEAT_BRIEF = @DOXYGEN_REPEAT_BRIEF@
|
||||
ABBREVIATE_BRIEF = @DOXYGEN_ABBREVIATE_BRIEF@
|
||||
ALWAYS_DETAILED_SEC = @DOXYGEN_ALWAYS_DETAILED_SEC@
|
||||
INLINE_INHERITED_MEMB = @DOXYGEN_INLINE_INHERITED_MEMB@
|
||||
FULL_PATH_NAMES = @DOXYGEN_FULL_PATH_NAMES@
|
||||
STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@
|
||||
STRIP_FROM_INC_PATH = @DOXYGEN_STRIP_FROM_INC_PATH@
|
||||
SHORT_NAMES = @DOXYGEN_SHORT_NAMES@
|
||||
JAVADOC_AUTOBRIEF = @DOXYGEN_JAVADOC_AUTOBRIEF@
|
||||
QT_AUTOBRIEF = @DOXYGEN_QT_AUTOBRIEF@
|
||||
MULTILINE_CPP_IS_BRIEF = @DOXYGEN_MULTILINE_CPP_IS_BRIEF@
|
||||
INHERIT_DOCS = @DOXYGEN_INHERIT_DOCS@
|
||||
SEPARATE_MEMBER_PAGES = @DOXYGEN_SEPARATE_MEMBER_PAGES@
|
||||
TAB_SIZE = @DOXYGEN_TAB_SIZE@
|
||||
ALIASES = @DOXYGEN_ALIASES@
|
||||
TCL_SUBST = @DOXYGEN_TCL_SUBST@
|
||||
OPTIMIZE_OUTPUT_FOR_C = @DOXYGEN_OPTIMIZE_OUTPUT_FOR_C@
|
||||
OPTIMIZE_OUTPUT_JAVA = @DOXYGEN_OPTIMIZE_OUTPUT_JAVA@
|
||||
OPTIMIZE_FOR_FORTRAN = @DOXYGEN_OPTIMIZE_FOR_FORTRAN@
|
||||
OPTIMIZE_OUTPUT_VHDL = @DOXYGEN_OPTIMIZE_OUTPUT_VHDL@
|
||||
EXTENSION_MAPPING = @DOXYGEN_EXTENSION_MAPPING@
|
||||
MARKDOWN_SUPPORT = @DOXYGEN_MARKDOWN_SUPPORT@
|
||||
TOC_INCLUDE_HEADINGS = @DOXYGEN_TOC_INCLUDE_HEADINGS@
|
||||
AUTOLINK_SUPPORT = @DOXYGEN_AUTOLINK_SUPPORT@
|
||||
BUILTIN_STL_SUPPORT = @DOXYGEN_BUILTIN_STL_SUPPORT@
|
||||
CPP_CLI_SUPPORT = @DOXYGEN_CPP_CLI_SUPPORT@
|
||||
SIP_SUPPORT = @DOXYGEN_SIP_SUPPORT@
|
||||
IDL_PROPERTY_SUPPORT = @DOXYGEN_IDL_PROPERTY_SUPPORT@
|
||||
DISTRIBUTE_GROUP_DOC = @DOXYGEN_DISTRIBUTE_GROUP_DOC@
|
||||
GROUP_NESTED_COMPOUNDS = @DOXYGEN_GROUP_NESTED_COMPOUNDS@
|
||||
SUBGROUPING = @DOXYGEN_SUBGROUPING@
|
||||
INLINE_GROUPED_CLASSES = @DOXYGEN_INLINE_GROUPED_CLASSES@
|
||||
INLINE_SIMPLE_STRUCTS = @DOXYGEN_INLINE_SIMPLE_STRUCTS@
|
||||
TYPEDEF_HIDES_STRUCT = @DOXYGEN_TYPEDEF_HIDES_STRUCT@
|
||||
LOOKUP_CACHE_SIZE = @DOXYGEN_LOOKUP_CACHE_SIZE@
|
||||
EXTRACT_ALL = @DOXYGEN_EXTRACT_ALL@
|
||||
EXTRACT_PRIVATE = @DOXYGEN_EXTRACT_PRIVATE@
|
||||
EXTRACT_PACKAGE = @DOXYGEN_EXTRACT_PACKAGE@
|
||||
EXTRACT_STATIC = @DOXYGEN_EXTRACT_STATIC@
|
||||
EXTRACT_LOCAL_CLASSES = @DOXYGEN_EXTRACT_LOCAL_CLASSES@
|
||||
EXTRACT_LOCAL_METHODS = @DOXYGEN_EXTRACT_LOCAL_METHODS@
|
||||
EXTRACT_ANON_NSPACES = @DOXYGEN_EXTRACT_ANON_NSPACES@
|
||||
HIDE_UNDOC_MEMBERS = @DOXYGEN_HIDE_UNDOC_MEMBERS@
|
||||
HIDE_UNDOC_CLASSES = @DOXYGEN_HIDE_UNDOC_CLASSES@
|
||||
HIDE_FRIEND_COMPOUNDS = @DOXYGEN_HIDE_FRIEND_COMPOUNDS@
|
||||
HIDE_IN_BODY_DOCS = @DOXYGEN_HIDE_IN_BODY_DOCS@
|
||||
INTERNAL_DOCS = @DOXYGEN_INTERNAL_DOCS@
|
||||
CASE_SENSE_NAMES = @DOXYGEN_CASE_SENSE_NAMES@
|
||||
HIDE_SCOPE_NAMES = @DOXYGEN_HIDE_SCOPE_NAMES@
|
||||
HIDE_COMPOUND_REFERENCE= @DOXYGEN_HIDE_COMPOUND_REFERENCE@
|
||||
SHOW_INCLUDE_FILES = @DOXYGEN_SHOW_INCLUDE_FILES@
|
||||
SHOW_GROUPED_MEMB_INC = @DOXYGEN_SHOW_GROUPED_MEMB_INC@
|
||||
FORCE_LOCAL_INCLUDES = @DOXYGEN_FORCE_LOCAL_INCLUDES@
|
||||
INLINE_INFO = @DOXYGEN_INLINE_INFO@
|
||||
SORT_MEMBER_DOCS = @DOXYGEN_SORT_MEMBER_DOCS@
|
||||
SORT_BRIEF_DOCS = @DOXYGEN_SORT_BRIEF_DOCS@
|
||||
SORT_MEMBERS_CTORS_1ST = @DOXYGEN_SORT_MEMBERS_CTORS_1ST@
|
||||
SORT_GROUP_NAMES = @DOXYGEN_SORT_GROUP_NAMES@
|
||||
SORT_BY_SCOPE_NAME = @DOXYGEN_SORT_BY_SCOPE_NAME@
|
||||
STRICT_PROTO_MATCHING = @DOXYGEN_STRICT_PROTO_MATCHING@
|
||||
GENERATE_TODOLIST = @DOXYGEN_GENERATE_TODOLIST@
|
||||
GENERATE_TESTLIST = @DOXYGEN_GENERATE_TESTLIST@
|
||||
GENERATE_BUGLIST = @DOXYGEN_GENERATE_BUGLIST@
|
||||
GENERATE_DEPRECATEDLIST= @DOXYGEN_GENERATE_DEPRECATEDLIST@
|
||||
ENABLED_SECTIONS = @DOXYGEN_ENABLED_SECTIONS@
|
||||
MAX_INITIALIZER_LINES = @DOXYGEN_MAX_INITIALIZER_LINES@
|
||||
SHOW_USED_FILES = @DOXYGEN_SHOW_USED_FILES@
|
||||
SHOW_FILES = @DOXYGEN_SHOW_FILES@
|
||||
SHOW_NAMESPACES = @DOXYGEN_SHOW_NAMESPACES@
|
||||
FILE_VERSION_FILTER = @DOXYGEN_FILE_VERSION_FILTER@
|
||||
LAYOUT_FILE = @DOXYGEN_LAYOUT_FILE@
|
||||
CITE_BIB_FILES = @DOXYGEN_CITE_BIB_FILES@
|
||||
QUIET = @DOXYGEN_QUIET@
|
||||
WARNINGS = @DOXYGEN_WARNINGS@
|
||||
WARN_IF_UNDOCUMENTED = @DOXYGEN_WARN_IF_UNDOCUMENTED@
|
||||
WARN_IF_DOC_ERROR = @DOXYGEN_WARN_IF_DOC_ERROR@
|
||||
WARN_NO_PARAMDOC = @DOXYGEN_WARN_NO_PARAMDOC@
|
||||
WARN_AS_ERROR = @DOXYGEN_WARN_AS_ERROR@
|
||||
WARN_FORMAT = @DOXYGEN_WARN_FORMAT@
|
||||
WARN_LOGFILE = @DOXYGEN_WARN_LOGFILE@
|
||||
INPUT = @DOXYGEN_INPUT@
|
||||
INPUT_ENCODING = @DOXYGEN_INPUT_ENCODING@
|
||||
FILE_PATTERNS = @DOXYGEN_FILE_PATTERNS@
|
||||
RECURSIVE = @DOXYGEN_RECURSIVE@
|
||||
EXCLUDE = @DOXYGEN_EXCLUDE@
|
||||
EXCLUDE_SYMLINKS = @DOXYGEN_EXCLUDE_SYMLINKS@
|
||||
EXCLUDE_PATTERNS = @DOXYGEN_EXCLUDE_PATTERNS@
|
||||
EXCLUDE_SYMBOLS = @DOXYGEN_EXCLUDE_SYMBOLS@
|
||||
EXAMPLE_PATH = @DOXYGEN_EXAMPLE_PATH@
|
||||
EXAMPLE_PATTERNS = @DOXYGEN_EXAMPLE_PATTERNS@
|
||||
EXAMPLE_RECURSIVE = @DOXYGEN_EXAMPLE_RECURSIVE@
|
||||
IMAGE_PATH = @DOXYGEN_IMAGE_PATH@
|
||||
INPUT_FILTER = @DOXYGEN_INPUT_FILTER@
|
||||
FILTER_PATTERNS = @DOXYGEN_FILTER_PATTERNS@
|
||||
FILTER_SOURCE_FILES = @DOXYGEN_FILTER_SOURCE_FILES@
|
||||
FILTER_SOURCE_PATTERNS = @DOXYGEN_FILTER_SOURCE_PATTERNS@
|
||||
USE_MDFILE_AS_MAINPAGE = @DOXYGEN_USE_MDFILE_AS_MAINPAGE@
|
||||
SOURCE_BROWSER = @DOXYGEN_SOURCE_BROWSER@
|
||||
INLINE_SOURCES = @DOXYGEN_INLINE_SOURCES@
|
||||
STRIP_CODE_COMMENTS = @DOXYGEN_STRIP_CODE_COMMENTS@
|
||||
REFERENCED_BY_RELATION = @DOXYGEN_REFERENCED_BY_RELATION@
|
||||
REFERENCES_RELATION = @DOXYGEN_REFERENCES_RELATION@
|
||||
REFERENCES_LINK_SOURCE = @DOXYGEN_REFERENCES_LINK_SOURCE@
|
||||
SOURCE_TOOLTIPS = @DOXYGEN_SOURCE_TOOLTIPS@
|
||||
USE_HTAGS = @DOXYGEN_USE_HTAGS@
|
||||
VERBATIM_HEADERS = @DOXYGEN_VERBATIM_HEADERS@
|
||||
CLANG_ASSISTED_PARSING = @DOXYGEN_CLANG_ASSISTED_PARSING@
|
||||
CLANG_OPTIONS = @DOXYGEN_CLANG_OPTIONS@
|
||||
ALPHABETICAL_INDEX = @DOXYGEN_ALPHABETICAL_INDEX@
|
||||
COLS_IN_ALPHA_INDEX = @DOXYGEN_COLS_IN_ALPHA_INDEX@
|
||||
IGNORE_PREFIX = @DOXYGEN_IGNORE_PREFIX@
|
||||
GENERATE_HTML = @DOXYGEN_GENERATE_HTML@
|
||||
HTML_OUTPUT = @DOXYGEN_HTML_OUTPUT@
|
||||
HTML_FILE_EXTENSION = @DOXYGEN_HTML_FILE_EXTENSION@
|
||||
HTML_HEADER = @DOXYGEN_HTML_HEADER@
|
||||
HTML_FOOTER = @DOXYGEN_HTML_FOOTER@
|
||||
HTML_STYLESHEET = @DOXYGEN_HTML_STYLESHEET@
|
||||
HTML_EXTRA_STYLESHEET = @DOXYGEN_HTML_EXTRA_STYLESHEET@
|
||||
HTML_EXTRA_FILES = @DOXYGEN_HTML_EXTRA_FILES@
|
||||
HTML_COLORSTYLE_HUE = @DOXYGEN_HTML_COLORSTYLE_HUE@
|
||||
HTML_COLORSTYLE_SAT = @DOXYGEN_HTML_COLORSTYLE_SAT@
|
||||
HTML_COLORSTYLE_GAMMA = @DOXYGEN_HTML_COLORSTYLE_GAMMA@
|
||||
HTML_TIMESTAMP = @DOXYGEN_HTML_TIMESTAMP@
|
||||
HTML_DYNAMIC_SECTIONS = @DOXYGEN_HTML_DYNAMIC_SECTIONS@
|
||||
HTML_INDEX_NUM_ENTRIES = @DOXYGEN_HTML_INDEX_NUM_ENTRIES@
|
||||
GENERATE_DOCSET = @DOXYGEN_GENERATE_DOCSET@
|
||||
DOCSET_FEEDNAME = @DOXYGEN_DOCSET_FEEDNAME@
|
||||
DOCSET_BUNDLE_ID = @DOXYGEN_DOCSET_BUNDLE_ID@
|
||||
DOCSET_PUBLISHER_ID = @DOXYGEN_DOCSET_PUBLISHER_ID@
|
||||
DOCSET_PUBLISHER_NAME = @DOXYGEN_DOCSET_PUBLISHER_NAME@
|
||||
GENERATE_HTMLHELP = @DOXYGEN_GENERATE_HTMLHELP@
|
||||
CHM_FILE = @DOXYGEN_CHM_FILE@
|
||||
HHC_LOCATION = @DOXYGEN_HHC_LOCATION@
|
||||
GENERATE_CHI = @DOXYGEN_GENERATE_CHI@
|
||||
CHM_INDEX_ENCODING = @DOXYGEN_CHM_INDEX_ENCODING@
|
||||
BINARY_TOC = @DOXYGEN_BINARY_TOC@
|
||||
TOC_EXPAND = @DOXYGEN_TOC_EXPAND@
|
||||
GENERATE_QHP = @DOXYGEN_GENERATE_QHP@
|
||||
QCH_FILE = @DOXYGEN_QCH_FILE@
|
||||
QHP_NAMESPACE = @DOXYGEN_QHP_NAMESPACE@
|
||||
QHP_VIRTUAL_FOLDER = @DOXYGEN_QHP_VIRTUAL_FOLDER@
|
||||
QHP_CUST_FILTER_NAME = @DOXYGEN_QHP_CUST_FILTER_NAME@
|
||||
QHP_CUST_FILTER_ATTRS = @DOXYGEN_QHP_CUST_FILTER_ATTRS@
|
||||
QHP_SECT_FILTER_ATTRS = @DOXYGEN_QHP_SECT_FILTER_ATTRS@
|
||||
QHG_LOCATION = @DOXYGEN_QHG_LOCATION@
|
||||
GENERATE_ECLIPSEHELP = @DOXYGEN_GENERATE_ECLIPSEHELP@
|
||||
ECLIPSE_DOC_ID = @DOXYGEN_ECLIPSE_DOC_ID@
|
||||
DISABLE_INDEX = @DOXYGEN_DISABLE_INDEX@
|
||||
GENERATE_TREEVIEW = @DOXYGEN_GENERATE_TREEVIEW@
|
||||
ENUM_VALUES_PER_LINE = @DOXYGEN_ENUM_VALUES_PER_LINE@
|
||||
TREEVIEW_WIDTH = @DOXYGEN_TREEVIEW_WIDTH@
|
||||
EXT_LINKS_IN_WINDOW = @DOXYGEN_EXT_LINKS_IN_WINDOW@
|
||||
FORMULA_FONTSIZE = @DOXYGEN_FORMULA_FONTSIZE@
|
||||
FORMULA_TRANSPARENT = @DOXYGEN_FORMULA_TRANSPARENT@
|
||||
USE_MATHJAX = @DOXYGEN_USE_MATHJAX@
|
||||
MATHJAX_FORMAT = @DOXYGEN_MATHJAX_FORMAT@
|
||||
MATHJAX_RELPATH = @DOXYGEN_MATHJAX_RELPATH@
|
||||
MATHJAX_EXTENSIONS = @DOXYGEN_MATHJAX_EXTENSIONS@
|
||||
MATHJAX_CODEFILE = @DOXYGEN_MATHJAX_CODEFILE@
|
||||
SEARCHENGINE = @DOXYGEN_SEARCHENGINE@
|
||||
SERVER_BASED_SEARCH = @DOXYGEN_SERVER_BASED_SEARCH@
|
||||
EXTERNAL_SEARCH = @DOXYGEN_EXTERNAL_SEARCH@
|
||||
SEARCHENGINE_URL = @DOXYGEN_SEARCHENGINE_URL@
|
||||
SEARCHDATA_FILE = @DOXYGEN_SEARCHDATA_FILE@
|
||||
EXTERNAL_SEARCH_ID = @DOXYGEN_EXTERNAL_SEARCH_ID@
|
||||
EXTRA_SEARCH_MAPPINGS = @DOXYGEN_EXTRA_SEARCH_MAPPINGS@
|
||||
GENERATE_LATEX = @DOXYGEN_GENERATE_LATEX@
|
||||
LATEX_OUTPUT = @DOXYGEN_LATEX_OUTPUT@
|
||||
LATEX_CMD_NAME = @DOXYGEN_LATEX_CMD_NAME@
|
||||
MAKEINDEX_CMD_NAME = @DOXYGEN_MAKEINDEX_CMD_NAME@
|
||||
COMPACT_LATEX = @DOXYGEN_COMPACT_LATEX@
|
||||
PAPER_TYPE = @DOXYGEN_PAPER_TYPE@
|
||||
EXTRA_PACKAGES = @DOXYGEN_EXTRA_PACKAGES@
|
||||
LATEX_HEADER = @DOXYGEN_LATEX_HEADER@
|
||||
LATEX_FOOTER = @DOXYGEN_LATEX_FOOTER@
|
||||
LATEX_EXTRA_STYLESHEET = @DOXYGEN_LATEX_EXTRA_STYLESHEET@
|
||||
LATEX_EXTRA_FILES = @DOXYGEN_LATEX_EXTRA_FILES@
|
||||
PDF_HYPERLINKS = @DOXYGEN_PDF_HYPERLINKS@
|
||||
USE_PDFLATEX = @DOXYGEN_USE_PDFLATEX@
|
||||
LATEX_BATCHMODE = @DOXYGEN_LATEX_BATCHMODE@
|
||||
LATEX_HIDE_INDICES = @DOXYGEN_LATEX_HIDE_INDICES@
|
||||
LATEX_SOURCE_CODE = @DOXYGEN_LATEX_SOURCE_CODE@
|
||||
LATEX_BIB_STYLE = @DOXYGEN_LATEX_BIB_STYLE@
|
||||
LATEX_TIMESTAMP = @DOXYGEN_LATEX_TIMESTAMP@
|
||||
GENERATE_RTF = @DOXYGEN_GENERATE_RTF@
|
||||
RTF_OUTPUT = @DOXYGEN_RTF_OUTPUT@
|
||||
COMPACT_RTF = @DOXYGEN_COMPACT_RTF@
|
||||
RTF_HYPERLINKS = @DOXYGEN_RTF_HYPERLINKS@
|
||||
RTF_STYLESHEET_FILE = @DOXYGEN_RTF_STYLESHEET_FILE@
|
||||
RTF_EXTENSIONS_FILE = @DOXYGEN_RTF_EXTENSIONS_FILE@
|
||||
RTF_SOURCE_CODE = @DOXYGEN_RTF_SOURCE_CODE@
|
||||
GENERATE_MAN = @DOXYGEN_GENERATE_MAN@
|
||||
MAN_OUTPUT = @DOXYGEN_MAN_OUTPUT@
|
||||
MAN_EXTENSION = @DOXYGEN_MAN_EXTENSION@
|
||||
MAN_SUBDIR = @DOXYGEN_MAN_SUBDIR@
|
||||
MAN_LINKS = @DOXYGEN_MAN_LINKS@
|
||||
GENERATE_XML = @DOXYGEN_GENERATE_XML@
|
||||
XML_OUTPUT = @DOXYGEN_XML_OUTPUT@
|
||||
XML_PROGRAMLISTING = @DOXYGEN_XML_PROGRAMLISTING@
|
||||
GENERATE_DOCBOOK = @DOXYGEN_GENERATE_DOCBOOK@
|
||||
DOCBOOK_OUTPUT = @DOXYGEN_DOCBOOK_OUTPUT@
|
||||
DOCBOOK_PROGRAMLISTING = @DOXYGEN_DOCBOOK_PROGRAMLISTING@
|
||||
GENERATE_AUTOGEN_DEF = @DOXYGEN_GENERATE_AUTOGEN_DEF@
|
||||
GENERATE_PERLMOD = @DOXYGEN_GENERATE_PERLMOD@
|
||||
PERLMOD_LATEX = @DOXYGEN_PERLMOD_LATEX@
|
||||
PERLMOD_PRETTY = @DOXYGEN_PERLMOD_PRETTY@
|
||||
PERLMOD_MAKEVAR_PREFIX = @DOXYGEN_PERLMOD_MAKEVAR_PREFIX@
|
||||
ENABLE_PREPROCESSING = @DOXYGEN_ENABLE_PREPROCESSING@
|
||||
MACRO_EXPANSION = @DOXYGEN_MACRO_EXPANSION@
|
||||
EXPAND_ONLY_PREDEF = @DOXYGEN_EXPAND_ONLY_PREDEF@
|
||||
SEARCH_INCLUDES = @DOXYGEN_SEARCH_INCLUDES@
|
||||
INCLUDE_PATH = @DOXYGEN_INCLUDE_PATH@
|
||||
INCLUDE_FILE_PATTERNS = @DOXYGEN_INCLUDE_FILE_PATTERNS@
|
||||
PREDEFINED = @DOXYGEN_PREDEFINED@
|
||||
EXPAND_AS_DEFINED = @DOXYGEN_EXPAND_AS_DEFINED@
|
||||
SKIP_FUNCTION_MACROS = @DOXYGEN_SKIP_FUNCTION_MACROS@
|
||||
TAGFILES = @DOXYGEN_TAGFILES@
|
||||
GENERATE_TAGFILE = @DOXYGEN_GENERATE_TAGFILE@
|
||||
ALLEXTERNALS = @DOXYGEN_ALLEXTERNALS@
|
||||
EXTERNAL_GROUPS = @DOXYGEN_EXTERNAL_GROUPS@
|
||||
EXTERNAL_PAGES = @DOXYGEN_EXTERNAL_PAGES@
|
||||
PERL_PATH = @DOXYGEN_PERL_PATH@
|
||||
CLASS_DIAGRAMS = @DOXYGEN_CLASS_DIAGRAMS@
|
||||
MSCGEN_PATH = @DOXYGEN_MSCGEN_PATH@
|
||||
DIA_PATH = @DOXYGEN_DIA_PATH@
|
||||
HIDE_UNDOC_RELATIONS = @DOXYGEN_HIDE_UNDOC_RELATIONS@
|
||||
HAVE_DOT = @DOXYGEN_HAVE_DOT@
|
||||
DOT_NUM_THREADS = @DOXYGEN_DOT_NUM_THREADS@
|
||||
DOT_FONTNAME = @DOXYGEN_DOT_FONTNAME@
|
||||
DOT_FONTSIZE = @DOXYGEN_DOT_FONTSIZE@
|
||||
DOT_FONTPATH = @DOXYGEN_DOT_FONTPATH@
|
||||
CLASS_GRAPH = @DOXYGEN_CLASS_GRAPH@
|
||||
COLLABORATION_GRAPH = @DOXYGEN_COLLABORATION_GRAPH@
|
||||
GROUP_GRAPHS = @DOXYGEN_GROUP_GRAPHS@
|
||||
UML_LOOK = @DOXYGEN_UML_LOOK@
|
||||
UML_LIMIT_NUM_FIELDS = @DOXYGEN_UML_LIMIT_NUM_FIELDS@
|
||||
TEMPLATE_RELATIONS = @DOXYGEN_TEMPLATE_RELATIONS@
|
||||
INCLUDE_GRAPH = @DOXYGEN_INCLUDE_GRAPH@
|
||||
INCLUDED_BY_GRAPH = @DOXYGEN_INCLUDED_BY_GRAPH@
|
||||
CALL_GRAPH = @DOXYGEN_CALL_GRAPH@
|
||||
CALLER_GRAPH = @DOXYGEN_CALLER_GRAPH@
|
||||
GRAPHICAL_HIERARCHY = @DOXYGEN_GRAPHICAL_HIERARCHY@
|
||||
DIRECTORY_GRAPH = @DOXYGEN_DIRECTORY_GRAPH@
|
||||
DOT_IMAGE_FORMAT = @DOXYGEN_DOT_IMAGE_FORMAT@
|
||||
INTERACTIVE_SVG = @DOXYGEN_INTERACTIVE_SVG@
|
||||
DOT_PATH = @DOXYGEN_DOT_PATH@
|
||||
DOTFILE_DIRS = @DOXYGEN_DOTFILE_DIRS@
|
||||
MSCFILE_DIRS = @DOXYGEN_MSCFILE_DIRS@
|
||||
DIAFILE_DIRS = @DOXYGEN_DIAFILE_DIRS@
|
||||
PLANTUML_JAR_PATH = @DOXYGEN_PLANTUML_JAR_PATH@
|
||||
PLANTUML_CFG_FILE = @DOXYGEN_PLANTUML_CFG_FILE@
|
||||
PLANTUML_INCLUDE_PATH = @DOXYGEN_PLANTUML_INCLUDE_PATH@
|
||||
DOT_GRAPH_MAX_NODES = @DOXYGEN_DOT_GRAPH_MAX_NODES@
|
||||
MAX_DOT_GRAPH_DEPTH = @DOXYGEN_MAX_DOT_GRAPH_DEPTH@
|
||||
DOT_TRANSPARENT = @DOXYGEN_DOT_TRANSPARENT@
|
||||
DOT_MULTI_TARGETS = @DOXYGEN_DOT_MULTI_TARGETS@
|
||||
GENERATE_LEGEND = @DOXYGEN_GENERATE_LEGEND@
|
||||
DOT_CLEANUP = @DOXYGEN_DOT_CLEANUP@
|
|
@ -0,0 +1,654 @@
|
|||
#
|
||||
# DO NOT EDIT! THIS FILE WAS GENERATED BY CMAKE!
|
||||
#
|
||||
|
||||
if(NOT DEFINED DOXYGEN_DOXYFILE_ENCODING)
|
||||
set(DOXYGEN_DOXYFILE_ENCODING UTF-8)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_PROJECT_NAME)
|
||||
set(DOXYGEN_PROJECT_NAME "My Project")
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CREATE_SUBDIRS)
|
||||
set(DOXYGEN_CREATE_SUBDIRS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ALLOW_UNICODE_NAMES)
|
||||
set(DOXYGEN_ALLOW_UNICODE_NAMES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_OUTPUT_LANGUAGE)
|
||||
set(DOXYGEN_OUTPUT_LANGUAGE English)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_BRIEF_MEMBER_DESC)
|
||||
set(DOXYGEN_BRIEF_MEMBER_DESC YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_REPEAT_BRIEF)
|
||||
set(DOXYGEN_REPEAT_BRIEF YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ABBREVIATE_BRIEF)
|
||||
set(DOXYGEN_ABBREVIATE_BRIEF "The $name class"
|
||||
"The $name widget"
|
||||
"The $name file"
|
||||
is
|
||||
provides
|
||||
specifies
|
||||
contains
|
||||
represents
|
||||
a
|
||||
an
|
||||
the)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ALWAYS_DETAILED_SEC)
|
||||
set(DOXYGEN_ALWAYS_DETAILED_SEC NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INLINE_INHERITED_MEMB)
|
||||
set(DOXYGEN_INLINE_INHERITED_MEMB NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_FULL_PATH_NAMES)
|
||||
set(DOXYGEN_FULL_PATH_NAMES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SHORT_NAMES)
|
||||
set(DOXYGEN_SHORT_NAMES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_JAVADOC_AUTOBRIEF)
|
||||
set(DOXYGEN_JAVADOC_AUTOBRIEF NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_QT_AUTOBRIEF)
|
||||
set(DOXYGEN_QT_AUTOBRIEF NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MULTILINE_CPP_IS_BRIEF)
|
||||
set(DOXYGEN_MULTILINE_CPP_IS_BRIEF NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INHERIT_DOCS)
|
||||
set(DOXYGEN_INHERIT_DOCS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SEPARATE_MEMBER_PAGES)
|
||||
set(DOXYGEN_SEPARATE_MEMBER_PAGES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_TAB_SIZE)
|
||||
set(DOXYGEN_TAB_SIZE 4)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_OPTIMIZE_OUTPUT_FOR_C)
|
||||
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_OPTIMIZE_OUTPUT_JAVA)
|
||||
set(DOXYGEN_OPTIMIZE_OUTPUT_JAVA NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_OPTIMIZE_FOR_FORTRAN)
|
||||
set(DOXYGEN_OPTIMIZE_FOR_FORTRAN NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_OPTIMIZE_OUTPUT_VHDL)
|
||||
set(DOXYGEN_OPTIMIZE_OUTPUT_VHDL NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MARKDOWN_SUPPORT)
|
||||
set(DOXYGEN_MARKDOWN_SUPPORT YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_TOC_INCLUDE_HEADINGS)
|
||||
set(DOXYGEN_TOC_INCLUDE_HEADINGS 0)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_AUTOLINK_SUPPORT)
|
||||
set(DOXYGEN_AUTOLINK_SUPPORT YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_BUILTIN_STL_SUPPORT)
|
||||
set(DOXYGEN_BUILTIN_STL_SUPPORT NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CPP_CLI_SUPPORT)
|
||||
set(DOXYGEN_CPP_CLI_SUPPORT NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SIP_SUPPORT)
|
||||
set(DOXYGEN_SIP_SUPPORT NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_IDL_PROPERTY_SUPPORT)
|
||||
set(DOXYGEN_IDL_PROPERTY_SUPPORT YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DISTRIBUTE_GROUP_DOC)
|
||||
set(DOXYGEN_DISTRIBUTE_GROUP_DOC NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GROUP_NESTED_COMPOUNDS)
|
||||
set(DOXYGEN_GROUP_NESTED_COMPOUNDS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SUBGROUPING)
|
||||
set(DOXYGEN_SUBGROUPING YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INLINE_GROUPED_CLASSES)
|
||||
set(DOXYGEN_INLINE_GROUPED_CLASSES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INLINE_SIMPLE_STRUCTS)
|
||||
set(DOXYGEN_INLINE_SIMPLE_STRUCTS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_TYPEDEF_HIDES_STRUCT)
|
||||
set(DOXYGEN_TYPEDEF_HIDES_STRUCT NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LOOKUP_CACHE_SIZE)
|
||||
set(DOXYGEN_LOOKUP_CACHE_SIZE 0)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTRACT_ALL)
|
||||
set(DOXYGEN_EXTRACT_ALL NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTRACT_PRIVATE)
|
||||
set(DOXYGEN_EXTRACT_PRIVATE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTRACT_PACKAGE)
|
||||
set(DOXYGEN_EXTRACT_PACKAGE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTRACT_STATIC)
|
||||
set(DOXYGEN_EXTRACT_STATIC NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTRACT_LOCAL_CLASSES)
|
||||
set(DOXYGEN_EXTRACT_LOCAL_CLASSES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTRACT_LOCAL_METHODS)
|
||||
set(DOXYGEN_EXTRACT_LOCAL_METHODS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTRACT_ANON_NSPACES)
|
||||
set(DOXYGEN_EXTRACT_ANON_NSPACES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HIDE_UNDOC_MEMBERS)
|
||||
set(DOXYGEN_HIDE_UNDOC_MEMBERS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HIDE_UNDOC_CLASSES)
|
||||
set(DOXYGEN_HIDE_UNDOC_CLASSES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HIDE_FRIEND_COMPOUNDS)
|
||||
set(DOXYGEN_HIDE_FRIEND_COMPOUNDS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HIDE_IN_BODY_DOCS)
|
||||
set(DOXYGEN_HIDE_IN_BODY_DOCS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INTERNAL_DOCS)
|
||||
set(DOXYGEN_INTERNAL_DOCS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CASE_SENSE_NAMES)
|
||||
set(DOXYGEN_CASE_SENSE_NAMES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HIDE_SCOPE_NAMES)
|
||||
set(DOXYGEN_HIDE_SCOPE_NAMES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HIDE_COMPOUND_REFERENCE)
|
||||
set(DOXYGEN_HIDE_COMPOUND_REFERENCE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SHOW_INCLUDE_FILES)
|
||||
set(DOXYGEN_SHOW_INCLUDE_FILES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SHOW_GROUPED_MEMB_INC)
|
||||
set(DOXYGEN_SHOW_GROUPED_MEMB_INC NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_FORCE_LOCAL_INCLUDES)
|
||||
set(DOXYGEN_FORCE_LOCAL_INCLUDES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INLINE_INFO)
|
||||
set(DOXYGEN_INLINE_INFO YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SORT_MEMBER_DOCS)
|
||||
set(DOXYGEN_SORT_MEMBER_DOCS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SORT_BRIEF_DOCS)
|
||||
set(DOXYGEN_SORT_BRIEF_DOCS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SORT_MEMBERS_CTORS_1ST)
|
||||
set(DOXYGEN_SORT_MEMBERS_CTORS_1ST NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SORT_GROUP_NAMES)
|
||||
set(DOXYGEN_SORT_GROUP_NAMES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SORT_BY_SCOPE_NAME)
|
||||
set(DOXYGEN_SORT_BY_SCOPE_NAME NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_STRICT_PROTO_MATCHING)
|
||||
set(DOXYGEN_STRICT_PROTO_MATCHING NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_TODOLIST)
|
||||
set(DOXYGEN_GENERATE_TODOLIST YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_TESTLIST)
|
||||
set(DOXYGEN_GENERATE_TESTLIST YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_BUGLIST)
|
||||
set(DOXYGEN_GENERATE_BUGLIST YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_DEPRECATEDLIST)
|
||||
set(DOXYGEN_GENERATE_DEPRECATEDLIST YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MAX_INITIALIZER_LINES)
|
||||
set(DOXYGEN_MAX_INITIALIZER_LINES 30)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SHOW_USED_FILES)
|
||||
set(DOXYGEN_SHOW_USED_FILES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SHOW_FILES)
|
||||
set(DOXYGEN_SHOW_FILES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SHOW_NAMESPACES)
|
||||
set(DOXYGEN_SHOW_NAMESPACES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_QUIET)
|
||||
set(DOXYGEN_QUIET NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_WARNINGS)
|
||||
set(DOXYGEN_WARNINGS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_WARN_IF_UNDOCUMENTED)
|
||||
set(DOXYGEN_WARN_IF_UNDOCUMENTED YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_WARN_IF_DOC_ERROR)
|
||||
set(DOXYGEN_WARN_IF_DOC_ERROR YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_WARN_NO_PARAMDOC)
|
||||
set(DOXYGEN_WARN_NO_PARAMDOC NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_WARN_AS_ERROR)
|
||||
set(DOXYGEN_WARN_AS_ERROR NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_WARN_FORMAT)
|
||||
set(DOXYGEN_WARN_FORMAT "$file:$line: $text")
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INPUT_ENCODING)
|
||||
set(DOXYGEN_INPUT_ENCODING UTF-8)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_FILE_PATTERNS)
|
||||
set(DOXYGEN_FILE_PATTERNS *.c
|
||||
*.cc
|
||||
*.cxx
|
||||
*.cpp
|
||||
*.c++
|
||||
*.java
|
||||
*.ii
|
||||
*.ixx
|
||||
*.ipp
|
||||
*.i++
|
||||
*.inl
|
||||
*.idl
|
||||
*.ddl
|
||||
*.odl
|
||||
*.h
|
||||
*.hh
|
||||
*.hxx
|
||||
*.hpp
|
||||
*.h++
|
||||
*.cs
|
||||
*.d
|
||||
*.php
|
||||
*.php4
|
||||
*.php5
|
||||
*.phtml
|
||||
*.inc
|
||||
*.m
|
||||
*.markdown
|
||||
*.md
|
||||
*.mm
|
||||
*.dox
|
||||
*.py
|
||||
*.pyw
|
||||
*.f90
|
||||
*.f95
|
||||
*.f03
|
||||
*.f08
|
||||
*.f
|
||||
*.for
|
||||
*.tcl
|
||||
*.vhd
|
||||
*.vhdl
|
||||
*.ucf
|
||||
*.qsf)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_RECURSIVE)
|
||||
set(DOXYGEN_RECURSIVE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXCLUDE_SYMLINKS)
|
||||
set(DOXYGEN_EXCLUDE_SYMLINKS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXAMPLE_PATTERNS)
|
||||
set(DOXYGEN_EXAMPLE_PATTERNS *)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXAMPLE_RECURSIVE)
|
||||
set(DOXYGEN_EXAMPLE_RECURSIVE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_FILTER_SOURCE_FILES)
|
||||
set(DOXYGEN_FILTER_SOURCE_FILES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SOURCE_BROWSER)
|
||||
set(DOXYGEN_SOURCE_BROWSER NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INLINE_SOURCES)
|
||||
set(DOXYGEN_INLINE_SOURCES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_STRIP_CODE_COMMENTS)
|
||||
set(DOXYGEN_STRIP_CODE_COMMENTS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_REFERENCED_BY_RELATION)
|
||||
set(DOXYGEN_REFERENCED_BY_RELATION NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_REFERENCES_RELATION)
|
||||
set(DOXYGEN_REFERENCES_RELATION NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_REFERENCES_LINK_SOURCE)
|
||||
set(DOXYGEN_REFERENCES_LINK_SOURCE YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SOURCE_TOOLTIPS)
|
||||
set(DOXYGEN_SOURCE_TOOLTIPS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_USE_HTAGS)
|
||||
set(DOXYGEN_USE_HTAGS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_VERBATIM_HEADERS)
|
||||
set(DOXYGEN_VERBATIM_HEADERS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CLANG_ASSISTED_PARSING)
|
||||
set(DOXYGEN_CLANG_ASSISTED_PARSING NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ALPHABETICAL_INDEX)
|
||||
set(DOXYGEN_ALPHABETICAL_INDEX YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_COLS_IN_ALPHA_INDEX)
|
||||
set(DOXYGEN_COLS_IN_ALPHA_INDEX 5)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_HTML)
|
||||
set(DOXYGEN_GENERATE_HTML YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_OUTPUT)
|
||||
set(DOXYGEN_HTML_OUTPUT html)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_FILE_EXTENSION)
|
||||
set(DOXYGEN_HTML_FILE_EXTENSION .html)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_COLORSTYLE_HUE)
|
||||
set(DOXYGEN_HTML_COLORSTYLE_HUE 220)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_COLORSTYLE_SAT)
|
||||
set(DOXYGEN_HTML_COLORSTYLE_SAT 100)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_COLORSTYLE_GAMMA)
|
||||
set(DOXYGEN_HTML_COLORSTYLE_GAMMA 80)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_TIMESTAMP)
|
||||
set(DOXYGEN_HTML_TIMESTAMP NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_DYNAMIC_SECTIONS)
|
||||
set(DOXYGEN_HTML_DYNAMIC_SECTIONS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HTML_INDEX_NUM_ENTRIES)
|
||||
set(DOXYGEN_HTML_INDEX_NUM_ENTRIES 100)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_DOCSET)
|
||||
set(DOXYGEN_GENERATE_DOCSET NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOCSET_FEEDNAME)
|
||||
set(DOXYGEN_DOCSET_FEEDNAME "Doxygen generated docs")
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOCSET_BUNDLE_ID)
|
||||
set(DOXYGEN_DOCSET_BUNDLE_ID org.doxygen.Project)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOCSET_PUBLISHER_ID)
|
||||
set(DOXYGEN_DOCSET_PUBLISHER_ID org.doxygen.Publisher)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOCSET_PUBLISHER_NAME)
|
||||
set(DOXYGEN_DOCSET_PUBLISHER_NAME Publisher)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_HTMLHELP)
|
||||
set(DOXYGEN_GENERATE_HTMLHELP NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_CHI)
|
||||
set(DOXYGEN_GENERATE_CHI NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_BINARY_TOC)
|
||||
set(DOXYGEN_BINARY_TOC NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_TOC_EXPAND)
|
||||
set(DOXYGEN_TOC_EXPAND NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_QHP)
|
||||
set(DOXYGEN_GENERATE_QHP NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_QHP_NAMESPACE)
|
||||
set(DOXYGEN_QHP_NAMESPACE org.doxygen.Project)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_QHP_VIRTUAL_FOLDER)
|
||||
set(DOXYGEN_QHP_VIRTUAL_FOLDER doc)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_ECLIPSEHELP)
|
||||
set(DOXYGEN_GENERATE_ECLIPSEHELP NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ECLIPSE_DOC_ID)
|
||||
set(DOXYGEN_ECLIPSE_DOC_ID org.doxygen.Project)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DISABLE_INDEX)
|
||||
set(DOXYGEN_DISABLE_INDEX NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_TREEVIEW)
|
||||
set(DOXYGEN_GENERATE_TREEVIEW NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ENUM_VALUES_PER_LINE)
|
||||
set(DOXYGEN_ENUM_VALUES_PER_LINE 4)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_TREEVIEW_WIDTH)
|
||||
set(DOXYGEN_TREEVIEW_WIDTH 250)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXT_LINKS_IN_WINDOW)
|
||||
set(DOXYGEN_EXT_LINKS_IN_WINDOW NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_FORMULA_FONTSIZE)
|
||||
set(DOXYGEN_FORMULA_FONTSIZE 10)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_FORMULA_TRANSPARENT)
|
||||
set(DOXYGEN_FORMULA_TRANSPARENT YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_USE_MATHJAX)
|
||||
set(DOXYGEN_USE_MATHJAX NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MATHJAX_FORMAT)
|
||||
set(DOXYGEN_MATHJAX_FORMAT HTML-CSS)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MATHJAX_RELPATH)
|
||||
set(DOXYGEN_MATHJAX_RELPATH http://cdn.mathjax.org/mathjax/latest)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SEARCHENGINE)
|
||||
set(DOXYGEN_SEARCHENGINE YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SERVER_BASED_SEARCH)
|
||||
set(DOXYGEN_SERVER_BASED_SEARCH NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTERNAL_SEARCH)
|
||||
set(DOXYGEN_EXTERNAL_SEARCH NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SEARCHDATA_FILE)
|
||||
set(DOXYGEN_SEARCHDATA_FILE searchdata.xml)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_LATEX)
|
||||
set(DOXYGEN_GENERATE_LATEX YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LATEX_OUTPUT)
|
||||
set(DOXYGEN_LATEX_OUTPUT latex)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LATEX_CMD_NAME)
|
||||
set(DOXYGEN_LATEX_CMD_NAME latex)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MAKEINDEX_CMD_NAME)
|
||||
set(DOXYGEN_MAKEINDEX_CMD_NAME makeindex)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_COMPACT_LATEX)
|
||||
set(DOXYGEN_COMPACT_LATEX NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_PAPER_TYPE)
|
||||
set(DOXYGEN_PAPER_TYPE a4)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_PDF_HYPERLINKS)
|
||||
set(DOXYGEN_PDF_HYPERLINKS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_USE_PDFLATEX)
|
||||
set(DOXYGEN_USE_PDFLATEX YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LATEX_BATCHMODE)
|
||||
set(DOXYGEN_LATEX_BATCHMODE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LATEX_HIDE_INDICES)
|
||||
set(DOXYGEN_LATEX_HIDE_INDICES NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LATEX_SOURCE_CODE)
|
||||
set(DOXYGEN_LATEX_SOURCE_CODE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LATEX_BIB_STYLE)
|
||||
set(DOXYGEN_LATEX_BIB_STYLE plain)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_LATEX_TIMESTAMP)
|
||||
set(DOXYGEN_LATEX_TIMESTAMP NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_RTF)
|
||||
set(DOXYGEN_GENERATE_RTF NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_RTF_OUTPUT)
|
||||
set(DOXYGEN_RTF_OUTPUT rtf)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_COMPACT_RTF)
|
||||
set(DOXYGEN_COMPACT_RTF NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_RTF_HYPERLINKS)
|
||||
set(DOXYGEN_RTF_HYPERLINKS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_RTF_SOURCE_CODE)
|
||||
set(DOXYGEN_RTF_SOURCE_CODE NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_MAN)
|
||||
set(DOXYGEN_GENERATE_MAN NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MAN_OUTPUT)
|
||||
set(DOXYGEN_MAN_OUTPUT man)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MAN_EXTENSION)
|
||||
set(DOXYGEN_MAN_EXTENSION .3)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MAN_LINKS)
|
||||
set(DOXYGEN_MAN_LINKS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_XML)
|
||||
set(DOXYGEN_GENERATE_XML NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_XML_OUTPUT)
|
||||
set(DOXYGEN_XML_OUTPUT xml)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_XML_PROGRAMLISTING)
|
||||
set(DOXYGEN_XML_PROGRAMLISTING YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_DOCBOOK)
|
||||
set(DOXYGEN_GENERATE_DOCBOOK NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOCBOOK_OUTPUT)
|
||||
set(DOXYGEN_DOCBOOK_OUTPUT docbook)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOCBOOK_PROGRAMLISTING)
|
||||
set(DOXYGEN_DOCBOOK_PROGRAMLISTING NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_AUTOGEN_DEF)
|
||||
set(DOXYGEN_GENERATE_AUTOGEN_DEF NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_PERLMOD)
|
||||
set(DOXYGEN_GENERATE_PERLMOD NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_PERLMOD_LATEX)
|
||||
set(DOXYGEN_PERLMOD_LATEX NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_PERLMOD_PRETTY)
|
||||
set(DOXYGEN_PERLMOD_PRETTY YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ENABLE_PREPROCESSING)
|
||||
set(DOXYGEN_ENABLE_PREPROCESSING YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MACRO_EXPANSION)
|
||||
set(DOXYGEN_MACRO_EXPANSION NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXPAND_ONLY_PREDEF)
|
||||
set(DOXYGEN_EXPAND_ONLY_PREDEF NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SEARCH_INCLUDES)
|
||||
set(DOXYGEN_SEARCH_INCLUDES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_SKIP_FUNCTION_MACROS)
|
||||
set(DOXYGEN_SKIP_FUNCTION_MACROS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_ALLEXTERNALS)
|
||||
set(DOXYGEN_ALLEXTERNALS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTERNAL_GROUPS)
|
||||
set(DOXYGEN_EXTERNAL_GROUPS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_EXTERNAL_PAGES)
|
||||
set(DOXYGEN_EXTERNAL_PAGES YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_PERL_PATH)
|
||||
set(DOXYGEN_PERL_PATH /usr/bin/perl)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CLASS_DIAGRAMS)
|
||||
set(DOXYGEN_CLASS_DIAGRAMS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HIDE_UNDOC_RELATIONS)
|
||||
set(DOXYGEN_HIDE_UNDOC_RELATIONS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_HAVE_DOT)
|
||||
set(DOXYGEN_HAVE_DOT YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_NUM_THREADS)
|
||||
set(DOXYGEN_DOT_NUM_THREADS 0)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_FONTNAME)
|
||||
set(DOXYGEN_DOT_FONTNAME Helvetica)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_FONTSIZE)
|
||||
set(DOXYGEN_DOT_FONTSIZE 10)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CLASS_GRAPH)
|
||||
set(DOXYGEN_CLASS_GRAPH YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_COLLABORATION_GRAPH)
|
||||
set(DOXYGEN_COLLABORATION_GRAPH YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GROUP_GRAPHS)
|
||||
set(DOXYGEN_GROUP_GRAPHS YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_UML_LOOK)
|
||||
set(DOXYGEN_UML_LOOK NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_UML_LIMIT_NUM_FIELDS)
|
||||
set(DOXYGEN_UML_LIMIT_NUM_FIELDS 10)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_TEMPLATE_RELATIONS)
|
||||
set(DOXYGEN_TEMPLATE_RELATIONS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INCLUDE_GRAPH)
|
||||
set(DOXYGEN_INCLUDE_GRAPH YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INCLUDED_BY_GRAPH)
|
||||
set(DOXYGEN_INCLUDED_BY_GRAPH YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CALL_GRAPH)
|
||||
set(DOXYGEN_CALL_GRAPH NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_CALLER_GRAPH)
|
||||
set(DOXYGEN_CALLER_GRAPH NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GRAPHICAL_HIERARCHY)
|
||||
set(DOXYGEN_GRAPHICAL_HIERARCHY YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DIRECTORY_GRAPH)
|
||||
set(DOXYGEN_DIRECTORY_GRAPH YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_IMAGE_FORMAT)
|
||||
set(DOXYGEN_DOT_IMAGE_FORMAT png)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_INTERACTIVE_SVG)
|
||||
set(DOXYGEN_INTERACTIVE_SVG NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_GRAPH_MAX_NODES)
|
||||
set(DOXYGEN_DOT_GRAPH_MAX_NODES 50)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_MAX_DOT_GRAPH_DEPTH)
|
||||
set(DOXYGEN_MAX_DOT_GRAPH_DEPTH 0)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_TRANSPARENT)
|
||||
set(DOXYGEN_DOT_TRANSPARENT NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_MULTI_TARGETS)
|
||||
set(DOXYGEN_DOT_MULTI_TARGETS NO)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_GENERATE_LEGEND)
|
||||
set(DOXYGEN_GENERATE_LEGEND YES)
|
||||
endif()
|
||||
if(NOT DEFINED DOXYGEN_DOT_CLEANUP)
|
||||
set(DOXYGEN_DOT_CLEANUP YES)
|
||||
endif()
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,17 @@
|
|||
set (CPACK_PACKAGE_NAME YAP)
|
||||
set (CPACK_PACKAGE_VENDOR Artur)
|
||||
|
||||
set (CPACK_PACKAGE_VERSION_MAJOR 6)
|
||||
set (CPACK_PACKAGE_VERSION_MINOR 3)
|
||||
set (CPACK_PACKAGE_VERSION_PATCH 6)
|
||||
|
||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "YAP CPACK NSIS")
|
||||
|
||||
set (CPACK_PACKAGE_DESCRIPTION_FILE "README.md")
|
||||
|
||||
#set (CPACK_INSTALL_CMAKE_PROJECTS Release)
|
||||
set (CPACK_INSTALLED_DIRECTORIES "C:\\Program Files\\YAP" .)
|
||||
|
||||
set (CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME})
|
||||
|
||||
set (CPACK_RESOURCE_FILE_LICENSE "C:\\Program Files\\YAP\\Artistic")
|
|
@ -1,22 +1,38 @@
|
|||
|
||||
add_library (Yap++ SHARED
|
||||
yapa.hh
|
||||
yapdb.hh
|
||||
yapi.cpp
|
||||
yapi.hh
|
||||
yapie.hh
|
||||
yapq.hh
|
||||
yapt.hh
|
||||
# Be sure to also update these in Makefile!
|
||||
set(SO_MAJOR 1)
|
||||
set(SO_MINOR 0)
|
||||
set(SO_PATCH 0)
|
||||
|
||||
set (CXX_SOURCES
|
||||
yapi.cpp
|
||||
)
|
||||
list(APPEND LIBYAP_SOURCES ${CXX_SOURCES} PARENT_SCOPE)
|
||||
|
||||
if ( WIN32 OR ANDROID)
|
||||
add_component (YAP++ ${CXX_SOURCES} )
|
||||
|
||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE;YAP_KERNEL=1" )
|
||||
else()
|
||||
add_library(YAP++ ${CXX_SOURCES} )
|
||||
if (WITH_PYTHON AND PYTHON_LIBRARIES)
|
||||
target_link_libraries(YAP++ ${PYTHON_LIBRARIES} )
|
||||
endif()
|
||||
target_link_libraries(YAP++ ${CMAKE_DL_LIBS} libYap)
|
||||
|
||||
|
||||
MY_install(TARGETS YAP++
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories (H include ${CMAKE_BINARY_DIR} ${GMP_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(Yap++ libYap)
|
||||
include_directories ( . ${CMAKE_BINARY_DIR} ${GMP_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIRS} )
|
||||
|
||||
|
||||
install(TARGETS Yap++
|
||||
LIBRARY DESTINATION ${libdir} )
|
||||
|
||||
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIR} )
|
||||
#set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GMP_LIBRARIES} )
|
||||
|
||||
|
||||
|
|
150
CXX/yapa.hh
150
CXX/yapa.hh
|
@ -1,43 +1,65 @@
|
|||
/// @file yapa.hh
|
||||
///
|
||||
/// @brief C++ Interface to atoms and their properties.
|
||||
|
||||
#ifndef YAPA_HH
|
||||
#define YAPA_HH 1
|
||||
|
||||
/**
|
||||
Prolog operates over constants, called atoms
|
||||
YAP, like lisp, associates properties with atoms.
|
||||
*/
|
||||
*
|
||||
* @defgroup yap-cplus-interface-atoms Prolog Atoms
|
||||
*
|
||||
* @brief Symbols and associated propeeties.
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @tableofcontents
|
||||
* @{
|
||||
*
|
||||
*
|
||||
* Prolog interns symbols, called *atoms* in a Hash table, usually
|
||||
called the atom table_. Each entry in this table stores the atom's
|
||||
name, but also may have a linked list of _properties_ We use
|
||||
properties to represent all kinds of data including. data-base
|
||||
tecords, predicates. operators, and more.
|
||||
*
|
||||
* In a nutshell:
|
||||
* - YAPAtom serves as the gateway to the data-base;
|
||||
*
|
||||
* - YAProp abstracts most data-base objects.
|
||||
*
|
||||
* - PropTag allows distinguishing the different classes of YAPProp.
|
||||
*/
|
||||
enum PropTag {
|
||||
/// predicate
|
||||
PRED_TAG = PEProp, // 0x0000,
|
||||
/// db key, may be associated with a functor
|
||||
DB_TAG = DBProperty, // 0x8000,
|
||||
DB_TAG = DBProperty, // 0x8000,
|
||||
/// generic functor, may include sub-properties
|
||||
FUNCTOR_TAG = FunctorProperty, // 0xBB00,
|
||||
FUNCTOR_TAG = FunctorProperty, // 0xBB00,
|
||||
// SPARSE_FUNCTOR_TAG = 0xFFDF,
|
||||
/// arithmetic function
|
||||
ARITHMETIC_PROPERTY_TAG = ExpProperty, // 0xFFE0,
|
||||
ARITHMETIC_PROPERTY_TAG = ExpProperty, // 0xFFE0,
|
||||
/// map the atom to an integer
|
||||
TRANSLATION_TAG = TranslationProperty, // 0xFFF4,
|
||||
/// ensure the atom may not be garbafe colected
|
||||
HOLD_TAG = HoldProperty, // 0xFFF6
|
||||
/// named mutEX
|
||||
MUTEX_TAG = MutexProperty, // 0xFFF6,
|
||||
TRANSLATION_TAG = TranslationProperty, // 0xFFF4,
|
||||
/// ensure the atom may not be garbafe colected
|
||||
HOLD_TAG = HoldProperty, // 0xFFF6
|
||||
/// named mutEX
|
||||
MUTEX_TAG = MutexProperty, // 0xFFF6,
|
||||
/// A typed array, may be in-db or in-stack deped
|
||||
ARRAY_TAG = ArrayProperty, // 0xFFF7,
|
||||
/// atom does not fit ISO-LATIN-1
|
||||
WIDE_TAG = WideAtomProperty, // 0xFFF8,
|
||||
ARRAY_TAG = ArrayProperty, // 0xFFF7,
|
||||
/// module
|
||||
MODULE_TAG = ModProperty, // 0xFFFA,
|
||||
MODULE_TAG = ModProperty, // 0xFFFA,
|
||||
/// the original SICStus blackboard
|
||||
BLACKBOARD_TAG = BBProperty, // 0xFFFB,
|
||||
BLACKBOARD_TAG = BBProperty, // 0xFFFB,
|
||||
/// associate an atomic value with the atom
|
||||
VALUE_TAG = ValProperty, // 0xFFFC,
|
||||
VALUE_TAG = ValProperty, // 0xFFFC,
|
||||
/// Demoen's proposal for gkobal variables
|
||||
GLOBAL_VAR_TAG = GlobalProperty, // 0xFFFD
|
||||
GLOBAL_VAR_TAG = GlobalProperty, // 0xFFFD
|
||||
/// SWI-STYLE ATOM Extension
|
||||
BLOB_TAG = BlobProperty, // 0xFFFE,
|
||||
/// Prolog operator,
|
||||
OPERATOR_TAG = OpProperty, // 0xFFFF,
|
||||
};
|
||||
BLOB_TAG = BlobProperty, // 0xFFFE,
|
||||
/// Prolog operator,
|
||||
OPERATOR_TAG = OpProperty, // 0xFFFF,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Atom
|
||||
|
@ -46,29 +68,35 @@ enum PropTag {
|
|||
* predicates, operators, modules, almost everything.
|
||||
*
|
||||
*/
|
||||
class YAPAtom {
|
||||
class X_API YAPAtom {
|
||||
friend class YAPEngine;
|
||||
friend class YAPModuleProp;
|
||||
friend class YAPPredicate;
|
||||
friend class YAPFunctor;
|
||||
friend class YAPAtomTerm;
|
||||
friend class YAProp;
|
||||
friend class YAPModule;
|
||||
friend class YAPQuery;
|
||||
Atom a;
|
||||
/// construct new YAPAtom from Atom
|
||||
YAPAtom( Atom at ) { a = at; }
|
||||
public:
|
||||
/// construct new YAPAtom from string
|
||||
/// construct new YAPAtom from UTF-8 string
|
||||
YAPAtom( const char * s) { a = Yap_LookupAtom( s ); }
|
||||
/// construct new YAPAtom from UTF-8 string
|
||||
YAPAtom( const wchar_t * s) { CACHE_REGS a = UTF32ToAtom( s PASS_REGS ); }
|
||||
/// construct new YAPAtom from wide string
|
||||
YAPAtom( const wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); }
|
||||
//YAPAtom( const wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); }
|
||||
/// construct new YAPAtom from max-length string
|
||||
YAPAtom( const char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
|
||||
/// construct new YAPAtom from max-length wide string
|
||||
YAPAtom( const wchar_t * s, size_t len) { a = Yap_LookupMaybeWideAtomWithLength( s, len ); }
|
||||
YAPAtom( const char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
|
||||
/// get name of atom
|
||||
char *getName(void);
|
||||
/// get prop of type
|
||||
Prop getProp( PropTag tag ) { return Yap_GetAProp( a , (PropFlags)tag ); }
|
||||
const char *getName(void);
|
||||
/// get name of (other way)
|
||||
inline const char *text(void) { return getName(); } ;
|
||||
/// get prop of type
|
||||
Prop getProp( PropTag tag ) { return Yap_GetAProp( a , (PropFlags)tag ); };
|
||||
/// as Atom
|
||||
Atom asAtom() { return a; };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -78,7 +106,7 @@ YAPAtom( const char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
|
|||
* predicates, operators, modules, almost everything.
|
||||
*
|
||||
*/
|
||||
class YAPProp {
|
||||
class X_API YAPProp {
|
||||
friend class YAPModuleProp;
|
||||
friend class YAPFunctor;
|
||||
/// does nothing, p is defined by the subclass
|
||||
|
@ -87,10 +115,62 @@ class YAPProp {
|
|||
PropTag tag( Prop p ) { return (PropTag)(p->KindOfPE); }
|
||||
public:
|
||||
/// get name of property
|
||||
virtual YAPAtom name() = 0;
|
||||
virtual ~YAPProp() {};
|
||||
|
||||
// virtual YAPAtom name();
|
||||
virtual ~YAPProp() {};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief YAPFunctor represents Prolog functors Name/Arity
|
||||
*/
|
||||
class X_API YAPFunctor : public YAPProp {
|
||||
friend class YAPApplTerm;
|
||||
friend class YAPTerm;
|
||||
friend class YAPPredicate;
|
||||
friend class YAPQuery;
|
||||
Functor f;
|
||||
/// Constructor: receives Prolog functor and casts it to YAPFunctor
|
||||
///
|
||||
/// Notice that this is designed for internal use only.
|
||||
inline YAPFunctor(Functor ff) { f = ff; }
|
||||
|
||||
public:
|
||||
/// Constructor: receives name as an atom, plus arity
|
||||
///
|
||||
/// This is the default method, and the most popular
|
||||
YAPFunctor(YAPAtom at, uintptr_t arity) { f = Yap_MkFunctor(at.a, arity); }
|
||||
|
||||
/// Constructor: receives name as a string plus arity
|
||||
///
|
||||
/// Notice that this is designed for ISO-LATIN-1 right now
|
||||
/// Note: Python confuses the 3 constructors,
|
||||
/// use YAPFunctorFromString
|
||||
inline YAPFunctor(const char *s, uintptr_t arity, bool isutf8 = true) {
|
||||
f = Yap_MkFunctor(Yap_LookupAtom(s), arity);
|
||||
}
|
||||
/// Constructor: receives name as a wide string plus arity
|
||||
///
|
||||
/// Notice that this is designed for UNICODE right now
|
||||
///
|
||||
/// Note: Python confuses the 3 constructors,
|
||||
/// use YAPFunctorFromWideString
|
||||
inline YAPFunctor(const wchar_t *s, uintptr_t arity) {
|
||||
CACHE_REGS f = Yap_MkFunctor(UTF32ToAtom(s PASS_REGS), arity);
|
||||
}
|
||||
/// Getter: extract name of functor as an atom
|
||||
///
|
||||
/// this is for external usage.
|
||||
inline YAPAtom name() { return YAPAtom(NameOfFunctor(f)); };
|
||||
|
||||
/// Getter: extract arity of functor as an unsigned integer
|
||||
///
|
||||
/// this is for external usage.
|
||||
inline arity_t arity() { return ArityOfFunctor(f); };
|
||||
/// Getter: extract functor as C pointer
|
||||
///
|
||||
/// inline Functor functor() { return f; };
|
||||
};
|
||||
|
||||
|
||||
#endif /* YAPA_HH */
|
||||
/// @}
|
||||
|
|
336
CXX/yapdb.hh
336
CXX/yapdb.hh
|
@ -1,21 +1,36 @@
|
|||
/// @file yapdb.hh
|
||||
///
|
||||
/// @brief C++ Interface to generated code.
|
||||
|
||||
#ifndef _YAPDB_H
|
||||
#define _YAPDB_H
|
||||
|
||||
#include <YapInterface.h>
|
||||
|
||||
#define YAP_CPP_DB_INTERFACE 1
|
||||
|
||||
//! @{
|
||||
|
||||
/**
|
||||
*
|
||||
* @defgroup yap-cplus-db-interface Data-Base Component of YAP interface.
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @{
|
||||
* @tableofcontents
|
||||
*
|
||||
*
|
||||
* Data-base component of C++ interface to YAP. It manipulates sets of
|
||||
* atoms, each one containing a number of props.
|
||||
* These classes define the main data-structures stored to represent compiled
|
||||
* programs:
|
||||
*
|
||||
* + YAPFunctor represents a name/arity combination.
|
||||
*
|
||||
* + YAPModule wraps the YAP module implementation.
|
||||
*
|
||||
* + YAPPredicate and subclasses store the actual program, Preliminary
|
||||
* support covers Prolog and C-defined predicates.
|
||||
*/
|
||||
|
||||
class YAPTerm;
|
||||
class YAPAtomTerm;
|
||||
|
||||
class YAPError;
|
||||
|
||||
|
@ -28,15 +43,18 @@ class YAPModule;
|
|||
* Info about the module is in YAPModuleProp
|
||||
*
|
||||
*/
|
||||
class YAPModule : protected YAPAtomTerm {
|
||||
class X_API YAPModule : protected YAPAtomTerm {
|
||||
friend class YAPPredicate;
|
||||
YAPModule( Term t ): YAPAtomTerm( t ) {};
|
||||
friend class YAPModuleProp;
|
||||
Term t() { return gt(); }
|
||||
Term curModule() {CACHE_REGS return Yap_CurrentModule(); }
|
||||
Term curModule() { CACHE_REGS return Yap_CurrentModule(); }
|
||||
|
||||
public:
|
||||
~YAPModule( ) {};
|
||||
YAPModule( ): YAPAtomTerm( curModule() ) {};
|
||||
YAPModule( YAPAtom t ): YAPAtomTerm( t ) {};
|
||||
YAPModule(YAP_Term t) : YAPAtomTerm(t){};
|
||||
YAPModule() : YAPAtomTerm(curModule()){};
|
||||
YAPModule(YAPAtom t) : YAPAtomTerm(t){};
|
||||
YAPModule(YAPStringTerm t) : YAPAtomTerm(t.getString()){};
|
||||
Term term() { return gt(); };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -44,178 +62,206 @@ public:
|
|||
* A YAPModuleProp controls access to a module property.
|
||||
*
|
||||
*/
|
||||
class YAPModuleProp: public YAPProp {
|
||||
class X_API YAPModuleProp : public YAPProp {
|
||||
friend class YAPPredicate;
|
||||
ModEntry *m;
|
||||
|
||||
YAPModuleProp(ModEntry *mod) {m = mod;};
|
||||
YAPModuleProp(Term tmod) { m = Yap_GetModuleEntry(tmod); };
|
||||
YAPModuleProp(ModEntry *mod) { m = mod; };
|
||||
YAPModuleProp(Term tmod) { m = Yap_GetModuleEntry(tmod); };
|
||||
|
||||
public:
|
||||
YAPModuleProp() { CACHE_REGS m = Yap_GetModuleEntry(Yap_CurrentModule()); };
|
||||
YAPModuleProp(YAPModule tmod) ;
|
||||
YAPModuleProp(YAPModule tmod) { m = Yap_GetModuleEntry(tmod.gt()); };
|
||||
YAPModuleProp() { m = Yap_GetModuleEntry(Yap_CurrentModule()); };
|
||||
virtual YAPModule module() { return YAPModule(m->AtomOfME); };
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief YAPFunctor represents Prolog functors Name/Arity
|
||||
*/
|
||||
class YAPFunctor: public YAPProp {
|
||||
friend class YAPApplTerm;
|
||||
friend class YAPPredicate;
|
||||
Functor f;
|
||||
/// Constructor: receives Prolog functor and casts it to YAPFunctor
|
||||
///
|
||||
/// Notice that this is designed for internal use only.
|
||||
YAPFunctor( Functor ff) { f = ff; }
|
||||
public:
|
||||
~YAPFunctor( ) { };
|
||||
/// Constructor: receives name as a string plus arity
|
||||
///
|
||||
/// Notice that this is designed for ISO-LATIN-1 right now
|
||||
YAPFunctor( char * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); }
|
||||
/// Constructor: receives name as a wide string plus arity
|
||||
///
|
||||
/// Notice that this is designed for UNICODE right now
|
||||
YAPFunctor( wchar_t * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupWideAtom( s ), arity ) ; }
|
||||
/// Constructor: receives name as an atom, plus arity
|
||||
///
|
||||
/// This is the default method, and the most popi;at
|
||||
YAPFunctor( YAPAtom at, arity_t arity) { f = Yap_MkFunctor( at.a, arity ); }
|
||||
|
||||
/// Getter: extract name of functor as an atom
|
||||
///
|
||||
/// this is for external usage.
|
||||
YAPAtom name(void) {
|
||||
return YAPAtom( NameOfFunctor( f ) );
|
||||
}
|
||||
|
||||
/// Getter: extract arity of functor as an unsigned integer
|
||||
///
|
||||
/// this is for external usage.
|
||||
arity_t arity(void) {
|
||||
return ArityOfFunctor( f );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Predicates
|
||||
*
|
||||
* This class interfaces with PredEntry in Yatom.
|
||||
*/
|
||||
class YAPPredicate: public YAPModuleProp {
|
||||
class X_API YAPPredicate : public YAPModuleProp {
|
||||
friend class YAPQuery;
|
||||
friend class YAPEngine;
|
||||
|
||||
protected:
|
||||
PredEntry *ap;
|
||||
|
||||
/// auxiliary routine to find a predicate in the current module.
|
||||
PredEntry *getPred( Term &t, Term* &outp ) ;
|
||||
|
||||
/// String constructor for predicates
|
||||
/// auxiliary routine to find a predicate in the current module.
|
||||
PredEntry *getPred(Term &t, Term &tm, CELL *&outp);
|
||||
|
||||
PredEntry *asPred() { return ap; };
|
||||
|
||||
/// Empty constructor for predicates
|
||||
///
|
||||
/// It also communicates the array of arguments t[]
|
||||
/// and the array of variables
|
||||
/// back to yapquery
|
||||
YAPPredicate(const char *s, Term &out, Term &names ) {
|
||||
CACHE_REGS
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term *outp;
|
||||
|
||||
out = Yap_StringToTerm(s, strlen(s)+1, &LOCAL_encoding, 1200, &names ) ;
|
||||
//extern char *s0;
|
||||
//fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s);
|
||||
// Yap_DebugPlWrite(out);
|
||||
// delete [] ns;
|
||||
if (out == 0L)
|
||||
throw YAPError(SYNTAX_ERROR);
|
||||
ap = getPred( out, outp);
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
|
||||
/// Just do nothing.
|
||||
inline YAPPredicate() {}
|
||||
YAPPredicate(Term &to, Term &tmod, CELL *&ts, const char *pname);
|
||||
|
||||
/// Term constructor for predicates
|
||||
///
|
||||
/// It is just a call to getPred
|
||||
inline YAPPredicate(Term t, CELL *&v) {
|
||||
if (t) {
|
||||
Term tm = Yap_CurrentModule();
|
||||
ap = getPred(t, tm, v);
|
||||
}
|
||||
}
|
||||
|
||||
inline YAPPredicate(Term t) {
|
||||
CELL * v = NULL;
|
||||
ap = getPred( t , v );
|
||||
if (t) {
|
||||
CELL *v = nullptr;
|
||||
Term tm = Yap_CurrentModule();
|
||||
ap = getPred(t, tm, v);
|
||||
}
|
||||
}
|
||||
|
||||
/// Term constructor for predicates
|
||||
///
|
||||
/// It is just a call to getPred
|
||||
inline YAPPredicate(YAPTerm t, CELL *&v) {
|
||||
Term tp = t.term(), tm = Yap_CurrentModule();
|
||||
ap = getPred(tp, tm, v);
|
||||
}
|
||||
inline YAPPredicate(YAPTerm t) {
|
||||
CELL *v = nullptr;
|
||||
Term tp = t.term();
|
||||
Term tm = Yap_CurrentModule();
|
||||
ap = getPred(tp, tm, v);
|
||||
}
|
||||
|
||||
/// Cast constructor for predicates,
|
||||
/// if we have the implementation data.
|
||||
///
|
||||
inline YAPPredicate(PredEntry *pe) {
|
||||
ap = pe;
|
||||
inline YAPPredicate(PredEntry *pe) { ap = pe; }
|
||||
|
||||
/// Functor constructor for predicates, is given a specific module.
|
||||
/// This version avoids manufacturing objects
|
||||
inline YAPPredicate(Functor f, Term mod) {
|
||||
ap = RepPredProp(PredPropByFunc(f, mod));
|
||||
}
|
||||
|
||||
public:
|
||||
~YAPPredicate() {};
|
||||
/// String constructor for predicates
|
||||
///
|
||||
/// It also communicates the array of arguments t[]
|
||||
/// and the array of variables
|
||||
/// back to yapquery
|
||||
YAPPredicate(const char *s0, Term &tout, YAPPairTerm &names, CELL *&nts) {
|
||||
CACHE_REGS
|
||||
const char *s = (const char *)s0;
|
||||
Term tnames = MkVarTerm();
|
||||
tout =
|
||||
Yap_BufferToTermWithPrioBindings(s, TermNil, tnames, strlen(s0), 1200);
|
||||
// fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s);
|
||||
// Yap_DebugPlWrite(out);
|
||||
if (tout == 0L) {
|
||||
return;
|
||||
throw YAPError();
|
||||
}
|
||||
Term tm = Yap_CurrentModule();
|
||||
ap = getPred(tout, tm, nts);
|
||||
tout = Yap_SaveTerm(tout);
|
||||
names = YAPPairTerm(tnames);
|
||||
}
|
||||
|
||||
/// Functor constructor for predicates
|
||||
///
|
||||
/// Asssumes that we use the current module.
|
||||
YAPPredicate(YAPFunctor f) {
|
||||
YAPPredicate(YAPFunctor f) {
|
||||
CACHE_REGS
|
||||
ap = RepPredProp(PredPropByFunc(f.f,Yap_CurrentModule()));
|
||||
};
|
||||
ap = RepPredProp(PredPropByFunc(f.f, Yap_CurrentModule()));
|
||||
}
|
||||
|
||||
/// Functor constructor for predicates, is given a specific module.
|
||||
///
|
||||
inline YAPPredicate(YAPFunctor f, YAPTerm mod) {
|
||||
ap = RepPredProp(PredPropByFunc(f.f,mod.t));
|
||||
ap = RepPredProp(PredPropByFunc(f.f, mod.term()));
|
||||
}
|
||||
|
||||
/// Name/arity constructor for predicates.
|
||||
///
|
||||
inline YAPPredicate(YAPAtom at, YAPTerm mod) {
|
||||
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
|
||||
ap = RepPredProp(PredPropByAtom(at.a, mod.term()));
|
||||
}
|
||||
|
||||
|
||||
/// Name/0 constructor for predicates.
|
||||
///
|
||||
YAPPredicate(YAPAtom at);
|
||||
|
||||
/// Mod:Name/Arity constructor for predicates.
|
||||
///
|
||||
inline YAPPredicate(YAPAtom at, arity_t arity, YAPModule mod) {
|
||||
inline YAPPredicate(YAPAtom at, uintptr_t arity, YAPModule mod) {
|
||||
if (arity) {
|
||||
Functor f = Yap_MkFunctor(at.a, arity);
|
||||
ap = RepPredProp(PredPropByFunc(f,mod.t()));
|
||||
ap = RepPredProp(PredPropByFunc(f, mod.term()));
|
||||
} else {
|
||||
ap = RepPredProp(PredPropByAtom(at.a,mod.t()));
|
||||
ap = RepPredProp(PredPropByAtom(at.a, mod.term()));
|
||||
}
|
||||
}
|
||||
|
||||
/// Atom/Arity constructor for predicates.
|
||||
///
|
||||
YAPPredicate(YAPAtom at, arity_t arity);
|
||||
YAPPredicate(YAPAtom at, uintptr_t arity);
|
||||
|
||||
/// char */module constructor for predicates.
|
||||
///
|
||||
inline YAPPredicate(const char *at, uintptr_t arity) {
|
||||
ap = RepPredProp(PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at), arity),
|
||||
Yap_CurrentModule()));
|
||||
};
|
||||
|
||||
/// char */module constructor for predicates.
|
||||
///
|
||||
inline YAPPredicate(const char *at, uintptr_t arity, YAPTerm mod) {
|
||||
ap = RepPredProp(
|
||||
PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at), arity), mod.term()));
|
||||
};
|
||||
|
||||
/// char */module constructor for predicates.
|
||||
///
|
||||
inline YAPPredicate(const char *at, YAPTerm mod) {
|
||||
ap = RepPredProp(PredPropByAtom(Yap_LookupAtom(at), mod.term()));
|
||||
}
|
||||
|
||||
/// module of a predicate
|
||||
///
|
||||
/// notice that modules are currently treated as atoms, this should change.
|
||||
YAPModule module() {
|
||||
if (ap->ModuleOfPred == PROLOG_MODULE)
|
||||
return YAPModule(AtomProlog);
|
||||
return YAPModule(AtomProlog);
|
||||
else
|
||||
return YAPModule(AtomOfTerm(ap->ModuleOfPred));
|
||||
return YAPModule(AtomOfTerm(ap->ModuleOfPred));
|
||||
}
|
||||
|
||||
/// name of predicate
|
||||
///
|
||||
/// notice that we return the atom, not a string.
|
||||
YAPAtom name() { if (ap->ArityOfPE)
|
||||
return YAPAtom((Atom)ap->FunctorOfPred);
|
||||
YAPAtom name() {
|
||||
if (ap->ArityOfPE)
|
||||
return YAPAtom((Atom)ap->FunctorOfPred);
|
||||
else
|
||||
return YAPAtom(NameOfFunctor(ap->FunctorOfPred));
|
||||
return YAPAtom(NameOfFunctor(ap->FunctorOfPred));
|
||||
}
|
||||
|
||||
/// functor of predicate
|
||||
///
|
||||
/// onlu defined if arity >= 1
|
||||
YAPFunctor functor() {
|
||||
if (ap->ArityOfPE)
|
||||
return YAPFunctor(ap->FunctorOfPred);
|
||||
Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, MkIntTerm(0),
|
||||
"YAPFunctor::functor");
|
||||
}
|
||||
|
||||
/// arity of predicate
|
||||
///
|
||||
/// we return a positive number.
|
||||
arity_t getArity() { return ap->ArityOfPE; }
|
||||
uintptr_t getArity() { return ap->ArityOfPE; }
|
||||
arity_t arity() { return ap->ArityOfPE; }
|
||||
PredEntry *predEntry() { return ap; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -223,28 +269,22 @@ public:
|
|||
*
|
||||
* This class interfaces with Predicates Implemented in Prolog.
|
||||
*/
|
||||
class YAPPrologPredicate: public YAPPredicate {
|
||||
class X_API YAPPrologPredicate : public YAPPredicate {
|
||||
public:
|
||||
YAPPrologPredicate(YAPAtom name,
|
||||
arity_t arity,
|
||||
YAPModule module = YAPModule(),
|
||||
bool tabled = false,
|
||||
bool logical_updates = false,
|
||||
bool local = false,
|
||||
bool sourced = true,
|
||||
bool discontiguous = false,
|
||||
bool multiFile = false,
|
||||
bool hidden = false,
|
||||
bool untraceable = false,
|
||||
bool unspyable = false,
|
||||
bool meta = false,
|
||||
bool sync = false,
|
||||
bool quasi_quotable = false,
|
||||
size_t mega_clause = 0
|
||||
);
|
||||
void *assertClause( YAPTerm clause, bool last=true, YAPTerm source= YAPTerm(TermNil));
|
||||
void *retractClause( YAPTerm skeleton, bool all=false);
|
||||
void *clause( YAPTerm skeleton, YAPTerm &body );
|
||||
YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){};
|
||||
YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){};
|
||||
YAPPrologPredicate(YAPAtom s, arity_t arity) : YAPPredicate(s, arity){};
|
||||
/// add a new clause
|
||||
bool assertClause(YAPTerm clause, bool last = true,
|
||||
YAPTerm source = YAPTerm());
|
||||
/// add a new tuple
|
||||
bool assertFact(YAPTerm *tuple, bool last = true);
|
||||
/// retract at least the first clause matching the predicate.
|
||||
void *retractClause(YAPTerm skeleton, bool all = false);
|
||||
/// return the Nth clause (if source is available)
|
||||
// YAPTerm clause(size_t index, YAPPredicate p) { return YAPTerm(); };
|
||||
/// return the Nth clause (if source is available)
|
||||
YAPTerm *nextClause() { return nullptr; };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -252,50 +292,36 @@ public:
|
|||
*
|
||||
* This class interfaces with Predicates Implemented in Prolog.
|
||||
*/
|
||||
class YAPFLIP: public YAPPredicate {
|
||||
class X_API YAPFLIP : public YAPPredicate {
|
||||
public:
|
||||
YAPFLIP(CPredicate call,
|
||||
YAPAtom name,
|
||||
arity_t arity,
|
||||
YAPModule module = YAPModule(),
|
||||
CPredicate retry = 0,
|
||||
CPredicate cut = 0,
|
||||
size_t extra = 0,
|
||||
bool test = false
|
||||
) : YAPPredicate( name, arity, module) {
|
||||
YAPFLIP(YAP_UserCPred call, YAPAtom name, YAP_Arity arity,
|
||||
YAPModule module = YAPModule(), YAP_UserCPred retry = 0,
|
||||
YAP_UserCPred cut = 0, YAP_Arity extra = 0, bool test = false)
|
||||
: YAPPredicate(name, arity, module) {
|
||||
if (retry) {
|
||||
Yap_InitCPredBackCut(name.getName(), arity, extra, call, retry, cut, UserCPredFlag);
|
||||
YAP_UserBackCutCPredicate(name.getName(), call, retry, cut, arity, extra);
|
||||
} else {
|
||||
if (test) {
|
||||
YAP_UserCPredicate (name.getName(),
|
||||
call, arity);
|
||||
YAP_UserCPredicate(name.getName(), call, arity);
|
||||
} else {
|
||||
YAP_UserCPredicate (name.getName(),
|
||||
call, arity);
|
||||
YAP_UserCPredicate(name.getName(), call, arity);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
YAPFLIP(const char *name,
|
||||
arity_t arity,
|
||||
YAPModule module = YAPModule(),
|
||||
bool backtrackable = false
|
||||
) : YAPPredicate( YAPAtom(name), arity, module) {
|
||||
YAPFLIP(const char *name, uintptr_t arity, YAPModule module = YAPModule(),
|
||||
bool backtrackable = false)
|
||||
: YAPPredicate(YAPAtom(name), arity, module) {
|
||||
if (backtrackable) {
|
||||
Yap_InitCPredBackCut(name, arity, 0, 0, 0, 0, UserCPredFlag);
|
||||
} else {
|
||||
YAP_UserCPredicate (name,
|
||||
0, arity);
|
||||
}
|
||||
YAP_UserCPredicate(name, 0, arity);
|
||||
}
|
||||
};
|
||||
bool addCall(CPredicate call) {
|
||||
return Yap_AddCallToFli( ap, call );
|
||||
}
|
||||
bool addRetry(CPredicate call) {
|
||||
return Yap_AddRetryToFli( ap, call );
|
||||
}
|
||||
bool addCut(CPredicate call) {
|
||||
return Yap_AddCutToFli( ap, call );
|
||||
}
|
||||
|
||||
bool addCall(CPredicate call) { return Yap_AddCallToFli(ap, call); }
|
||||
bool addRetry(CPredicate call) { return Yap_AddRetryToFli(ap, call); }
|
||||
bool addCut(CPredicate call) { return Yap_AddCutToFli(ap, call); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/// @}
|
||||
|
|
1433
CXX/yapi.cpp
1433
CXX/yapi.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,35 +1,62 @@
|
|||
|
||||
/**
|
||||
@file yapi.hh
|
||||
|
||||
@brief entry file for the YAP C++ interface
|
||||
|
||||
*/
|
||||
|
||||
#define YAP_CPP_INTERFACE 1
|
||||
|
||||
//! @{
|
||||
|
||||
/**
|
||||
*
|
||||
* @defgroup yap-cplus-interface An object oriented interface for YAP.
|
||||
*
|
||||
* @ingroup ChYInterface
|
||||
* @tableofcontents
|
||||
*
|
||||
*
|
||||
* C++ interface to YAP. Designed to be object oriented and to fit naturally
|
||||
* with the swig interface language generator. It uses ideas from the old YAP
|
||||
* interface and from the SWI foreign language interface.
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// Bad export from Python
|
||||
#ifdef HAVE_STAT
|
||||
#undef HAVE_STAT
|
||||
#endif
|
||||
#include <config.h>
|
||||
#include <vector>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include "YapConfig.h"
|
||||
|
||||
}
|
||||
|
||||
#include <gmpxx.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
*
|
||||
* @ingroup fli_c_cxx
|
||||
* @defgroup yap-cplus-interface An object oriented interface for YAP.
|
||||
*
|
||||
1 * @{
|
||||
*
|
||||
*
|
||||
* @brief C++ wrapper to terms, predicates and queries
|
||||
*
|
||||
* This new interface is designed to be object oriented and to fit
|
||||
* naturally with the swig interface language generator. It uses ideas
|
||||
* from the old YAP interface and from the SWI foreign language
|
||||
* interface.
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// Bad export from Python
|
||||
|
||||
#include <YapConfig.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if YAP_PYTHON
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
extern bool python_in_python;
|
||||
#endif
|
||||
|
||||
#include "Yap.h"
|
||||
|
||||
#include "Yatom.h"
|
||||
|
@ -59,23 +86,33 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#include <windows.h>
|
||||
//#include <windows.h>
|
||||
#endif
|
||||
|
||||
// taken from yap_structs.h
|
||||
#include "iopreds.h"
|
||||
|
||||
extern void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity);
|
||||
X_API extern void YAP_UserCPredicate(const char *, YAP_UserCPred,
|
||||
YAP_Arity arity);
|
||||
|
||||
/* void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int arity) */
|
||||
extern void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity, YAP_Term);
|
||||
/* extern void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int
|
||||
* arity)
|
||||
*/
|
||||
X_API extern void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred,
|
||||
YAP_Arity, YAP_Term);
|
||||
|
||||
/* void UserBackCPredicate(const char *name, int *init(), int *cont(), int
|
||||
arity, int extra) */
|
||||
extern void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred, YAP_Arity, unsigned int);
|
||||
X_API extern void YAP_UserBackCPredicate(const char *name, YAP_UserCPred init,
|
||||
YAP_UserCPred cont, YAP_Arity arity,
|
||||
YAP_Arity extra);
|
||||
|
||||
extern Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio, Term *bindings_p);
|
||||
X_API extern void YAP_UserBackCutCPredicate(const char *name,
|
||||
YAP_UserCPred init,
|
||||
YAP_UserCPred cont,
|
||||
YAP_UserCPred cut, YAP_Arity arity,
|
||||
YAP_Arity extra);
|
||||
|
||||
X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp);
|
||||
|
||||
extern YAP_Term YAP_MkcharPTerm(char *s);
|
||||
}
|
||||
|
||||
class YAPEngine;
|
||||
|
|
93
CXX/yapie.hh
93
CXX/yapie.hh
|
@ -1,11 +1,92 @@
|
|||
/**
|
||||
* @file yapie.hh
|
||||
*
|
||||
* @defgroup yap-cplus-error-hanadlinge Error Handling in the YAP interface.
|
||||
*
|
||||
* @brief error handling in C++ and OO languages
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* These classes define an object that we can then throw when an error
|
||||
* or unexoected event interrupts YAP. Often, the object is built by
|
||||
* YAP itself. One can also define one's own error objects.
|
||||
*
|
||||
* Errors will be thrown from the `C++` code, and may be processed in
|
||||
* very different ways. The error object should provide as much data as
|
||||
* possible.
|
||||
*/
|
||||
|
||||
|
||||
class YAPError {
|
||||
int errNo;
|
||||
#ifndef YAPIE_HH
|
||||
#define YAPIE_HH
|
||||
|
||||
class X_API YAPPPredicate;
|
||||
|
||||
|
||||
|
||||
/// take information on a Prolog error:
|
||||
class X_API YAPError {
|
||||
//int swigcode;
|
||||
yap_error_descriptor_t *info;
|
||||
|
||||
public:
|
||||
YAPError() { errNo = YAP_NO_ERROR; };
|
||||
YAPError(int err) { errNo = err; };
|
||||
int get();
|
||||
const char *text();
|
||||
/// wraps the default error descriptor
|
||||
YAPError() {
|
||||
info = LOCAL_ActiveError;
|
||||
if (!info)
|
||||
LOCAL_ActiveError = info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1);
|
||||
// if (info->errorNo != YAP_NO_ERROR) {};
|
||||
//std::cerr << "Error detected" << info->errorNo << "\n";
|
||||
}
|
||||
/// if des != nullptr, wrap a preexisting error descriptor;
|
||||
/// otherwise, generate a new one
|
||||
YAPError(yap_error_descriptor_t *des) {
|
||||
if (des)
|
||||
info= des;
|
||||
else info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1);
|
||||
// if (info->errorNo != YAP_NO_ERROR) {};
|
||||
//std::cerr << "Error detected" << info->errorNo << "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// error handler object with initial data when receiving the error term
|
||||
// YAPError( std::string file, std::string function, int lineno,
|
||||
// yap_error_number id, YAPTerm culprit, std::string txt) {
|
||||
// info = new yap_error_descriptor_t;
|
||||
// Yap_MkErrorRecord(info, file.c_str(), function.c_str(), lineno, id, culprit.term(), txt.c_str());
|
||||
//}
|
||||
|
||||
/// error handler object with initial data when receiving the error term
|
||||
YAPError( const char * file, const char * function, int lineno,
|
||||
yap_error_number id, YAP_Term culprit, const char * txt) {
|
||||
info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1);
|
||||
Yap_MkErrorRecord(info, file, function, lineno, id, culprit, txt);
|
||||
}
|
||||
|
||||
/// short version
|
||||
#define SOURCE() __FILE__, __FUNCTION__, __LINE__
|
||||
|
||||
/// we just know the error number
|
||||
/// exact error ID
|
||||
yap_error_number getID() { return info->errorNo; };
|
||||
/// class of error
|
||||
yap_error_class_number getErrorClass() {
|
||||
return Yap_errorClass(info->errorNo);
|
||||
};
|
||||
/// where in the code things happened;
|
||||
const char *getFile() { return info->errorFile; };
|
||||
/// predicate things happened;
|
||||
Int getLine() { return info->errorLine; };
|
||||
/// the term that caused the bug
|
||||
// YAPTerm getCulprit(info->errorFile){};
|
||||
/// text describing the Error
|
||||
std::string text();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/// @}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue